[runtime] Fix corlib out of date error with disabled COM
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Base / Core / Internal / PropertyEditing / Selection / CategorySelectionStop.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.Selection 
5 {
6     using System;
7     using System.Globalization;
8     using System.Windows;
9     using System.Activities.Presentation;
10
11     using Blend = System.Activities.Presentation.Internal.PropertyEditing.FromExpression.Framework.PropertyInspector;
12
13     // <summary>
14     // Helper class used to manage the selection stop behavior of a given CategoryContainer's basic
15     // and advanced sections.  It deals with both expanding and collapsing of the specified section
16     // as well as knowing how to get a SelectionPath leading to its heading.
17     // </summary>
18     internal class CategorySelectionStop : ISelectionStop 
19     {
20
21         private CiderCategoryContainer _parent;
22         private DependencyProperty _expansionProperty;
23         private SelectionPath _selectionPath;
24         private string _description;
25
26         // <summary>
27         // Creates a new selection stop logic for the specified CiderCategoryContainer.
28         // </summary>
29         // <param name="parent">CategoryContainer to wrap around</param>
30         // <param name="isAdvanced">True if this selection stop wraps around the
31         // advanced set of properties, false otherwise.</param>
32         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly")]
33         public CategorySelectionStop(CiderCategoryContainer parent, bool isAdvanced) 
34         {
35
36             if (parent == null) 
37             {
38                 throw FxTrace.Exception.ArgumentNull("parent");
39             }
40             if (parent.Category == null) 
41             {
42                 throw FxTrace.Exception.ArgumentNull("parent.Category");
43             }
44
45             _parent = parent;
46             _expansionProperty = isAdvanced ? Blend.CategoryContainer.AdvancedSectionPinnedProperty : Blend.CategoryContainer.ExpandedProperty;
47             _selectionPath = CategoryContainerSelectionPathInterpreter.Instance.ConstructSelectionPath(parent.Category.CategoryName, isAdvanced);
48             _description = isAdvanced ?
49                 string.Format(
50                 CultureInfo.CurrentCulture,
51                 System.Activities.Presentation.Internal.Properties.Resources.PropertyEditing_SelectionStatus_AdvancedCategory,
52                 parent.Category.CategoryName) :
53                 string.Format(
54                 CultureInfo.CurrentCulture,
55                 System.Activities.Presentation.Internal.Properties.Resources.PropertyEditing_SelectionStatus_Category,
56                 parent.Category.CategoryName);
57         }
58
59         // <summary>
60         // Gets or sets a flag indicating whether the basic/advanced section is expanded
61         // </summary>
62         public bool IsExpanded 
63         {
64             get { return (bool)_parent.GetValue(_expansionProperty); }
65             set { _parent.SetValue(_expansionProperty, value); }
66         }
67
68         // <summary>
69         // Returns true
70         // </summary>
71         public bool IsExpandable 
72         {
73             get { return true; }
74         }
75
76         // <summary>
77         // Gets the SelectionPath to the contained CategoryContainer section
78         // </summary>
79         public SelectionPath Path 
80         {
81             get { return _selectionPath; }
82         }
83
84         // <summary>
85         // Gets a description of the contained category container
86         // to expose through automation
87         // </summary>
88         public string Description 
89         {
90             get { return _description; }
91         }
92     }
93 }