// 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 editorTypeName = path.Path; if (string.IsNullOrEmpty(editorTypeName)) { Debug.Fail("Invalid SelectionPath specified."); return(null); } ModelCategoryEntry category; CategoryEditor editor = root.FindCategoryEditor(editorTypeName, out category); if (editor == null || category == null) { return(null); } return(root.FindCategoryEditorVisual(editor, category, out pendingGeneration)); }
public CategorySelectionStop(CiderCategoryContainer parent, bool isAdvanced) { if (parent == null) { throw FxTrace.Exception.ArgumentNull("parent"); } if (parent.Category == null) { throw FxTrace.Exception.ArgumentNull("parent.Category"); } _parent = parent; _expansionProperty = isAdvanced ? Blend.CategoryContainer.AdvancedSectionPinnedProperty : Blend.CategoryContainer.ExpandedProperty; _selectionPath = CategoryContainerSelectionPathInterpreter.Instance.ConstructSelectionPath(parent.Category.CategoryName, isAdvanced); _description = isAdvanced ? string.Format( CultureInfo.CurrentCulture, System.Activities.Presentation.Internal.Properties.Resources.PropertyEditing_SelectionStatus_AdvancedCategory, parent.Category.CategoryName) : string.Format( CultureInfo.CurrentCulture, System.Activities.Presentation.Internal.Properties.Resources.PropertyEditing_SelectionStatus_Category, parent.Category.CategoryName); }
// 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 editorTypeName = path.Path; if (string.IsNullOrEmpty(editorTypeName)) { Debug.Fail("Invalid SelectionPath specified."); return null; } ModelCategoryEntry category; CategoryEditor editor = root.FindCategoryEditor(editorTypeName, out category); if (editor == null || category == null) { return null; } return root.FindCategoryEditorVisual(editor, category, out pendingGeneration); }
// 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)); }
// <summary> // Attempt to resolve the given SelectionPath into the corresponding visual in the // specified CategoryList control. // </summary> // <param name="root">CategoryList control instance to look in</param> // <param name="path">SelectionPath to resolve</param> // <returns>Corresponding visual, if found, null otherwise</returns> public static DependencyObject ResolveSelectionPath(CategoryList root, SelectionPath path, out bool pendingGeneration) { pendingGeneration = false; if (root == null || path == null) { return null; } ISelectionPathInterpreter interpreter; if (!_interpreters.TryGetValue(path.PathTypeId, out interpreter)) { return null; } return interpreter.ResolveSelectionPath(root, path, out pendingGeneration); }
// <summary> // Attempt to resolve the given SelectionPath into the corresponding visual in the // specified CategoryList control. // </summary> // <param name="root">CategoryList control instance to look in</param> // <param name="path">SelectionPath to resolve</param> // <returns>Corresponding visual, if found, null otherwise</returns> public static DependencyObject ResolveSelectionPath(CategoryList root, SelectionPath path, out bool pendingGeneration) { pendingGeneration = false; if (root == null || path == null) { return(null); } ISelectionPathInterpreter interpreter; if (!_interpreters.TryGetValue(path.PathTypeId, out interpreter)) { return(null); } return(interpreter.ResolveSelectionPath(root, path, out pendingGeneration)); }
// 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); }
public CategorySelectionStop(CiderCategoryContainer parent, bool isAdvanced) { if (parent == null) { throw FxTrace.Exception.ArgumentNull("parent"); } if (parent.Category == null) { throw FxTrace.Exception.ArgumentNull("parent.Category"); } _parent = parent; _expansionProperty = isAdvanced ? Blend.CategoryContainer.AdvancedSectionPinnedProperty : Blend.CategoryContainer.ExpandedProperty; _selectionPath = CategoryContainerSelectionPathInterpreter.Instance.ConstructSelectionPath(parent.Category.CategoryName, isAdvanced); _description = isAdvanced ? string.Format( CultureInfo.CurrentCulture, System.Activities.Presentation.Internal.Properties.Resources.PropertyEditing_SelectionStatus_AdvancedCategory, parent.Category.CategoryName) : string.Format( CultureInfo.CurrentCulture, System.Activities.Presentation.Internal.Properties.Resources.PropertyEditing_SelectionStatus_Category, parent.Category.CategoryName); }
private void SelectPropertyByPathOnIdle() { SelectionPath selectionPath = new SelectionPath(PropertySelectionPathInterpreter.PropertyPathTypeId, propertyPathToSelect); bool pendingGeneration; bool result = this._categoryList.SetSelectionPath(selectionPath, out pendingGeneration); if (!result && pendingGeneration) { Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new MethodInvoker(SelectPropertyByPathOnIdle)); } }
// 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(','); if (pathValues.Length < 1) { Debug.Fail("Invalid SelectionPath specified."); return null; } // // Note: By the time this method gets called, all the visuals should have been expanded // and rendered. Hence, if we can't find a visual in the visual tree, it doesn't exist // and we shouldn't worry about trying to expand some parent visual and waiting for it // to render. // ModelCategoryEntry parentCategory; PropertyEntry currentProperty = root.FindPropertyEntry(PersistedStateUtilities.Unescape(pathValues[0]), out parentCategory); PropertyContainer currentContainer = root.FindPropertyEntryVisual(currentProperty, parentCategory, out pendingGeneration); DependencyObject lastFoundContainer = currentContainer; int pathIndex = 1; while (currentContainer != null && pathIndex < pathValues.Length) { SubPropertyEditor subPropertyEditor = VisualTreeUtils.GetTemplateChild<SubPropertyEditor>(currentContainer); if (subPropertyEditor == null) { break; } // If the subpropertyEditor is not expanded and is expandable, we won't be able to get the target property's visual // element, Expand it, set pendingGeneration to True, and return null. Expect the caller to call again. if (subPropertyEditor.IsExpandable && !subPropertyEditor.IsExpanded) { subPropertyEditor.IsExpanded = true; pendingGeneration = true; return null; } PropertyEntry property = subPropertyEditor.FindSubPropertyEntry(PersistedStateUtilities.Unescape(pathValues[pathIndex])); if (property == null) { break; } currentContainer = subPropertyEditor.FindSubPropertyEntryVisual(property); lastFoundContainer = currentContainer ?? lastFoundContainer; pathIndex++; } if (lastFoundContainer == null) { return null; } return lastFoundContainer; }
// 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(','); if (pathValues.Length < 1) { Debug.Fail("Invalid SelectionPath specified."); return(null); } // // Note: By the time this method gets called, all the visuals should have been expanded // and rendered. Hence, if we can't find a visual in the visual tree, it doesn't exist // and we shouldn't worry about trying to expand some parent visual and waiting for it // to render. // ModelCategoryEntry parentCategory; PropertyEntry currentProperty = root.FindPropertyEntry(PersistedStateUtilities.Unescape(pathValues[0]), out parentCategory); PropertyContainer currentContainer = root.FindPropertyEntryVisual(currentProperty, parentCategory, out pendingGeneration); DependencyObject lastFoundContainer = currentContainer; int pathIndex = 1; while (currentContainer != null && pathIndex < pathValues.Length) { SubPropertyEditor subPropertyEditor = VisualTreeUtils.GetTemplateChild <SubPropertyEditor>(currentContainer); if (subPropertyEditor == null) { break; } // If the subpropertyEditor is not expanded and is expandable, we won't be able to get the target property's visual // element, Expand it, set pendingGeneration to True, and return null. Expect the caller to call again. if (subPropertyEditor.IsExpandable && !subPropertyEditor.IsExpanded) { subPropertyEditor.IsExpanded = true; pendingGeneration = true; return(null); } PropertyEntry property = subPropertyEditor.FindSubPropertyEntry(PersistedStateUtilities.Unescape(pathValues[pathIndex])); if (property == null) { break; } currentContainer = subPropertyEditor.FindSubPropertyEntryVisual(property); lastFoundContainer = currentContainer ?? lastFoundContainer; pathIndex++; } if (lastFoundContainer == null) { return(null); } return(lastFoundContainer); }