Esempio n. 1
0
        /// <summary>
        ///     This API supports the Entity Framework infrastructure and is not intended to be used directly from your code.
        /// </summary>
        /// <returns>This API supports the Entity Framework infrastructure and is not intended to be used directly from your code.</returns>
        protected override DependencyObject GetContainerForItemOverride()
        {
            var treeViewItem = new ExplorerTreeViewItem();

            treeViewItem.Indent = Indent + 19;
            return(treeViewItem);
        }
Esempio n. 2
0
        internal void FocusTreeViewItem(ExplorerTreeViewItem treeViewItem)
        {
            if (null == treeViewItem)
            {
                Debug.Assert(false, "FocusTreeViewItem: should not be passed null ExplorerTreeViewItem");
                return;
            }

            ScrollToMakeVisible(treeViewItem);

            // having scrolled to the correct position, do the actual focus
            Keyboard.Focus(treeViewItem);
        }
Esempio n. 3
0
        internal double GetY(ExplorerTreeViewItem treeViewItem)
        {
            UIElement uiElement = treeViewItem;

            while (uiElement != null &&
                   !uiElement.IsVisible)
            {
                uiElement = VisualTreeHelper.GetParent(uiElement) as UIElement;
            }
            if (uiElement == null)
            {
                return(0);
            }
            else
            {
                return(uiElement.TranslatePoint(new Point(0, 0), _frameContent.ExplorerTreeRoot).Y);
            }
        }
Esempio n. 4
0
        // Change selection for right-mouse button as well as left
        private void OnTreeViewPreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed ||
                e.RightButton == MouseButtonState.Pressed)
            {
                ExplorerTreeViewItem treeViewItem = null;
                var item = e.OriginalSource as UIElement;
                while (item != null)
                {
                    var toggleButton = item as ToggleButton;
                    if (toggleButton != null &&
                        toggleButton.Name == "Expander")
                    {
                        if (e.LeftButton == MouseButtonState.Pressed)
                        {
                            // have hit the expand/collapse button - so
                            // return without handling event here
                            return;
                        }
                    }
                    treeViewItem = item as ExplorerTreeViewItem;
                    if (treeViewItem != null)
                    {
                        break;
                    }
                    if (item.Focusable)
                    {
                        break;
                    }
                    item = VisualTreeHelper.GetParent(item) as UIElement;
                }

                if (treeViewItem != null)
                {
                    treeViewItem.IsSelected = true;
                    Keyboard.Focus(treeViewItem);
                    if (e.LeftButton == MouseButtonState.Pressed)
                    {
                        _isTreeViewMouseDown = true;
                    }
                }
            }
        }
 /// <summary>
 ///     Get the immediate children of the current ExplorerTreeViewItem, create automation peers for them, and return them for
 ///     accessibility/automation
 /// </summary>
 /// <param name="parent"></param>
 /// <returns></returns>
 private static List<AutomationPeer> GetAutomationChildren(ExplorerTreeViewItem parent)
 {
     var automationChildren = new List<AutomationPeer>();
     foreach (ExplorerEFElement element in parent.Items)
     {
         // get the TreeViewItem from the explorer element.
         var treeViewItem = parent.ItemContainerGenerator.ContainerFromItem(element) as ExplorerTreeViewItem;
         if (treeViewItem != null)
         {
             // create an AutomationPeer for this TreeViewItem (will call OnCreateAutomationPeer) and add that to the list to return
             var automationChild = CreatePeerForElement(treeViewItem);
             Debug.Assert(automationChild != null, "Every ExplorerTreeViewItem should have an automation peer");
             if (automationChild != null)
             {
                 automationChildren.Add(automationChild);
             }
         }
     }
     return automationChildren;
 }
Esempio n. 6
0
        internal void ScrollToMakeVisible(ExplorerTreeViewItem treeViewItem)
        {
            if (null == treeViewItem)
            {
                Debug.Assert(false, "ScrollToMakeVisible: should not be passed null ExplorerTreeViewItem");
                return;
            }

            // select item and scroll so that it is visible
            treeViewItem.IsSelected = true;
            if (ScrollViewer != null)
            {
                var y = GetY(treeViewItem);
                var viewPortHeight = ScrollViewer.ViewportHeight;
                if (Math.Abs(ScrollViewer.VerticalOffset + viewPortHeight / 2 - y) > viewPortHeight / 2)
                {
                    // bring to view and center vertically
                    ScrollViewer.ScrollToVerticalOffset(y - viewPortHeight / 2);
                }

                var partHeader = ExplorerUtility.GetTreeViewItemPartHeader(treeViewItem);
                if (partHeader != null)
                {
                    // bring to view horizontally and maximize visible width
                    var x                = partHeader.TranslatePoint(new Point(0, 0), ExplorerTreeRoot).X;
                    var width            = partHeader.DesiredSize.Width;
                    var viewPortWidth    = ScrollViewer.ViewportWidth;
                    var horizontalOffset = ScrollViewer.HorizontalOffset;
                    if ((horizontalOffset > x) ||
                        ((x + width) > (horizontalOffset + viewPortWidth)))
                    {
                        ScrollViewer.ScrollToHorizontalOffset(x);
                    }
                }
            }
        }
Esempio n. 7
0
 public ExplorerTreeViewItemAutomationPeer(ExplorerTreeViewItem owner)
     : base(owner)
 {
 }
Esempio n. 8
0
        internal void ScrollToMakeVisible(ExplorerTreeViewItem treeViewItem)
        {
            if (null == treeViewItem)
            {
                Debug.Assert(false, "ScrollToMakeVisible: should not be passed null ExplorerTreeViewItem");
                return;
            }

            // select item and scroll so that it is visible
            treeViewItem.IsSelected = true;
            if (ScrollViewer != null)
            {
                var y = GetY(treeViewItem);
                var viewPortHeight = ScrollViewer.ViewportHeight;
                if (Math.Abs(ScrollViewer.VerticalOffset + viewPortHeight / 2 - y) > viewPortHeight / 2)
                {
                    // bring to view and center vertically
                    ScrollViewer.ScrollToVerticalOffset(y - viewPortHeight / 2);
                }

                var partHeader = ExplorerUtility.GetTreeViewItemPartHeader(treeViewItem);
                if (partHeader != null)
                {
                    // bring to view horizontally and maximize visible width
                    var x = partHeader.TranslatePoint(new Point(0, 0), ExplorerTreeRoot).X;
                    var width = partHeader.DesiredSize.Width;
                    var viewPortWidth = ScrollViewer.ViewportWidth;
                    var horizontalOffset = ScrollViewer.HorizontalOffset;
                    if ((horizontalOffset > x)
                        || ((x + width) > (horizontalOffset + viewPortWidth)))
                    {
                        ScrollViewer.ScrollToHorizontalOffset(x);
                    }
                }
            }
        }
Esempio n. 9
0
        internal void FocusTreeViewItem(ExplorerTreeViewItem treeViewItem)
        {
            if (null == treeViewItem)
            {
                Debug.Assert(false, "FocusTreeViewItem: should not be passed null ExplorerTreeViewItem");
                return;
            }

            ScrollToMakeVisible(treeViewItem);

            // having scrolled to the correct position, do the actual focus
            Keyboard.Focus(treeViewItem);
        }
Esempio n. 10
0
 internal double GetY(ExplorerTreeViewItem treeViewItem)
 {
     UIElement uiElement = treeViewItem;
     while (uiElement != null
            && !uiElement.IsVisible)
     {
         uiElement = VisualTreeHelper.GetParent(uiElement) as UIElement;
     }
     if (uiElement == null)
     {
         return 0;
     }
     else
     {
         return uiElement.TranslatePoint(new Point(0, 0), _frameContent.ExplorerTreeRoot).Y;
     }
 }
 public ExplorerTreeViewItemAutomationPeer(ExplorerTreeViewItem owner)
     : base(owner)
 {
 }
 /// <summary>
 ///     This API supports the Entity Framework infrastructure and is not intended to be used directly from your code.
 /// </summary>
 /// <returns>This API supports the Entity Framework infrastructure and is not intended to be used directly from your code.</returns>
 protected override DependencyObject GetContainerForItemOverride()
 {
     var treeViewItem = new ExplorerTreeViewItem();
     treeViewItem.Indent = Indent + 19;
     return treeViewItem;
 }