示例#1
0
        // We use the ItemStatus to convey read-only property selection status
        protected override string GetItemStatusCore()
        {
            FrameworkElement selection = _control.Selection;
            string           status;

            if (selection != null)
            {
                ISelectionStop selectionStop = PropertySelection.GetSelectionStop(selection);
                status = selectionStop == null ? null : selectionStop.Description;

                if (status == null)
                {
                    status = string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.PropertyEditing_SelectionStatus_Unknown,
                        selection.GetType().Name);
                }
            }
            else
            {
                status = Resources.PropertyEditing_SelectionStatus_Empty;
            }

            return(status);
        }
示例#2
0
        // <summary>
        // Sets PropertySelection.SelectionStop property on the specified DependencyObject
        // </summary>
        // <param name="obj">DependencyObject to modify</param>
        // <param name="value">New value of SelectionStop</param>
        internal static void SetSelectionStop(DependencyObject obj, ISelectionStop value)
        {
            if (obj == null)
            {
                throw FxTrace.Exception.ArgumentNull("obj");
            }

            obj.SetValue(SelectionStopProperty, value);
        }
示例#3
0
        // Keyboard Navigation

        protected override void OnKeyDown(KeyEventArgs e)
        {
            // Intercept Up, Down, Left, Right key strokes and use them to navigate around the
            // the control
            //
            if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down)
            {
                if (_selection != null && !e.Handled)
                {
                    if (object.Equals(
                            Keyboard.FocusedElement,
                            VisualTreeUtils.FindFocusableElement <FrameworkElement>(_selection)))
                    {
                        ISelectionStop selectionStop = PropertySelection.GetSelectionStop(_selection);
                        if (selectionStop != null)
                        {
                            if (selectionStop.IsExpandable)
                            {
                                if ((e.Key == Key.Right && !selectionStop.IsExpanded) ||
                                    (e.Key == Key.Left && selectionStop.IsExpanded))
                                {
                                    selectionStop.IsExpanded = !selectionStop.IsExpanded;
                                    e.Handled = true;
                                }
                            }
                        }

                        if (!e.Handled)
                        {
                            SearchDirection  direction = e.Key == Key.Up || e.Key == Key.Left ? SearchDirection.Previous : SearchDirection.Next;
                            FrameworkElement nextStop  = PropertySelection.FindNeighborSelectionStop <FrameworkElement>(_selection, direction);

                            // If need to select something, select it
                            if (nextStop != null)
                            {
                                SelectAndFocus(nextStop, StealFocusMode.Always);
                            }

                            e.Handled = true;
                        }
                    }
                }
            }

            base.OnKeyDown(e);
        }
示例#4
0
        // Called when the UI object representing a SelectionStop gets clicked:
        //
        //      * If this is a double-click and the SelectionStop can be expanded / collapsed,
        //        expand / collapse the SelectionStop
        //
        private static void OnSelectionStopDoubleClickTargetMouseDown(object sender, MouseButtonEventArgs e)
        {
            DependencyObject target = e.OriginalSource as DependencyObject;

            if (target == null)
            {
                return;
            }

            if (e.ClickCount > 1)
            {
                FrameworkElement parentSelectionStopVisual = PropertySelection.FindParentSelectionStop <FrameworkElement>(target);
                if (parentSelectionStopVisual != null)
                {
                    ISelectionStop parentSelectionStop = PropertySelection.GetSelectionStop(parentSelectionStopVisual);
                    if (parentSelectionStop != null && parentSelectionStop.IsExpandable)
                    {
                        parentSelectionStop.IsExpanded = !parentSelectionStop.IsExpanded;
                    }
                }
            }
        }
示例#5
0
        // Helper method that returns false if the given element is a collapsed SelectionStop,
        // true otherwise.
        //
        private static bool IsExpanded(DependencyObject element)
        {
            ISelectionStop selectionStop = PropertySelection.GetSelectionStop(element);

            return(selectionStop == null || selectionStop.IsExpanded);
        }