// ISelectionPathInterpreter Members public DependencyObject ResolveSelectionPath(CategoryList root, SelectionPath path, out bool pendingGeneration) { pendingGeneration = false; if (path == null || !string.Equals(PathTypeId, path.PathTypeId)) { Debug.Fail("Invalid SelectionPath specified."); return(null); } if (root == null) { Debug.Fail("No CategoryList specified."); return(null); } string[] pathValues = path.Path.Split(','); string categoryName = PersistedStateUtilities.Unescape(pathValues[0]); bool isAdvanced = pathValues.Length == 2; CategoryEntry category = root.FindCategory(categoryName); if (category == null) { return(null); } DependencyObject categoryVisual = root.FindCategoryEntryVisual(category); if (categoryVisual == null) { return(null); } DependencyObject searchStart; // For basic section, start at the root. // For advanced section, start at the advanced expander. // The next SelectionStop in both cases will be the section header SelectionStop. if (!isAdvanced) { searchStart = categoryVisual; } else { searchStart = VisualTreeUtils.GetNamedChild <FrameworkElement>(categoryVisual, "PART_AdvancedExpander"); } return(PropertySelection.FindNeighborSelectionStop <DependencyObject>(searchStart, SearchDirection.Next)); }
// IPropertyViewManager Members // <summary> // Add a property into the correct category within the specified CategoryList. // </summary> // <param name="propertySet">Specified property (passed in as a set for multi-select scenarios)</param> // <param name="propertyName">Name of the current property (perf optimization)</param> // <param name="categoryList">CategoryList instance to populate</param> // <returns>Wrapped ModelPropertyEntry for the specified propertySet</returns> public ModelPropertyEntry AddProperty(IEnumerable <ModelProperty> propertySet, string propertyName, CategoryList categoryList) { string categoryName = GetCategoryName(propertySet); ModelCategoryEntry category = categoryList.FindCategory(categoryName) as ModelCategoryEntry; bool reuseEntries = ExtensibilityAccessor.IsEditorReusable(propertySet); if (reuseEntries && category != null) { ModelPropertyEntry foundProperty; if ((foundProperty = (ModelPropertyEntry)category[propertyName]) != null) { if (foundProperty.PropertyType != null && foundProperty.PropertyType.Equals(System.Activities.Presentation.Internal.PropertyEditing.Model.ModelUtilities.GetPropertyType(propertySet))) { // Found a match for the property, so reuse it bool oldIsBrowsable = foundProperty.IsBrowsable; bool oldIsAdvanced = foundProperty.IsAdvanced; foundProperty.SetUnderlyingModelProperty(propertySet); // If the IsBrowsable or IsAdvanced value of the property changed, // refresh the property within the category, because how and whether // this property should be rendered may have changed. // Note that refreshing a selected property also nullifies its stickiness // (ie. it resets CategoryList.PropertySelectionMode) if (oldIsAdvanced != foundProperty.IsAdvanced || oldIsBrowsable != foundProperty.IsBrowsable) { category.Refresh(foundProperty, category.GetBucket(foundProperty), this.PropertyComparer); } return(foundProperty); } } } if (category == null) { category = new ModelCategoryEntry(categoryName); categoryList.InsertAlphabetically(category); } ModelPropertyEntry property = new ModelPropertyEntry(propertySet, null); category.Add(property, category.GetBucket(property), this.PropertyComparer); return(property); }
// ISelectionPathInterpreter Members public DependencyObject ResolveSelectionPath(CategoryList root, SelectionPath path, out bool pendingGeneration) { pendingGeneration = false; if (path == null || !string.Equals(PathTypeId, path.PathTypeId)) { Debug.Fail("Invalid SelectionPath specified."); return null; } if (root == null) { Debug.Fail("No CategoryList specified."); return null; } string[] pathValues = path.Path.Split(','); string categoryName = PersistedStateUtilities.Unescape(pathValues[0]); bool isAdvanced = pathValues.Length == 2; CategoryEntry category = root.FindCategory(categoryName); if (category == null) { return null; } DependencyObject categoryVisual = root.FindCategoryEntryVisual(category); if (categoryVisual == null) { return null; } DependencyObject searchStart; // For basic section, start at the root. // For advanced section, start at the advanced expander. // The next SelectionStop in both cases will be the section header SelectionStop. if (!isAdvanced) { searchStart = categoryVisual; } else { searchStart = VisualTreeUtils.GetNamedChild<FrameworkElement>(categoryVisual, "PART_AdvancedExpander"); } return PropertySelection.FindNeighborSelectionStop<DependencyObject>(searchStart, SearchDirection.Next); }
// IPropertyViewManager Members // <summary> // Add a property into the correct category within the specified CategoryList. // </summary> // <param name="propertySet">Specified property (passed in as a set for multi-select scenarios)</param> // <param name="propertyName">Name of the current property (perf optimization)</param> // <param name="categoryList">CategoryList instance to populate</param> // <returns>Wrapped ModelPropertyEntry for the specified propertySet</returns> public ModelPropertyEntry AddProperty(IEnumerable<ModelProperty> propertySet, string propertyName, CategoryList categoryList) { string categoryName = GetCategoryName(propertySet); ModelCategoryEntry category = categoryList.FindCategory(categoryName) as ModelCategoryEntry; bool reuseEntries = ExtensibilityAccessor.IsEditorReusable(propertySet); if (reuseEntries && category != null) { ModelPropertyEntry foundProperty; if ((foundProperty = (ModelPropertyEntry)category[propertyName]) != null) { if (foundProperty.PropertyType != null && foundProperty.PropertyType.Equals(System.Activities.Presentation.Internal.PropertyEditing.Model.ModelUtilities.GetPropertyType(propertySet))) { // Found a match for the property, so reuse it bool oldIsBrowsable = foundProperty.IsBrowsable; bool oldIsAdvanced = foundProperty.IsAdvanced; foundProperty.SetUnderlyingModelProperty(propertySet); // If the IsBrowsable or IsAdvanced value of the property changed, // refresh the property within the category, because how and whether // this property should be rendered may have changed. // Note that refreshing a selected property also nullifies its stickiness // (ie. it resets CategoryList.PropertySelectionMode) if (oldIsAdvanced != foundProperty.IsAdvanced || oldIsBrowsable != foundProperty.IsBrowsable) { category.Refresh(foundProperty, category.GetBucket(foundProperty), this.PropertyComparer); } return foundProperty; } } } if (category == null) { category = new ModelCategoryEntry(categoryName); categoryList.InsertAlphabetically(category); } ModelPropertyEntry property = new ModelPropertyEntry(propertySet, null); category.Add(property, category.GetBucket(property), this.PropertyComparer); return property; }