private ScrollBar GetVerticalScrollBar()
        {
            // wire up events for the scrollbar
            var explorerTreeView = ExplorerTreeView;
            var scrollBar        = (explorerTreeView == null ? null : ExplorerUtility.FindFirstVerticalScrollBar(explorerTreeView));

            // Is cached scrollbar the same as the one in the visual tree?
            if (!ReferenceEquals(_vScrollBar, scrollBar))
            {
                if (_vScrollBar != null)
                {
                    UnhookScrollBarEvents(_vScrollBar);
                    _vScrollBar   = null;
                    _scrollViewer = null;
                }

                // wire up events for the scrollbar
                _vScrollBar = scrollBar;
                if (_vScrollBar != null)
                {
                    _vScrollBar.SizeChanged      += VScrollBar_SizeChanged;
                    _vScrollBar.IsVisibleChanged += VScrollBar_IsVisibleChanged;
                    _vScrollBar.Unloaded         += VScrollBar_Unloaded;
                }
            }

            return(_vScrollBar);
        }
        internal void OnDropDownLoaded(object sender, RoutedEventArgs e)
        {
            var searchTextBox = ExplorerUtility.GetTypeDescendents(SearchBox, typeof(TextBox)).FirstOrDefault() as TextBox;

            if (searchTextBox != null)
            {
                searchTextBox.MaxLength = 1000;
            }
        }
        private ExplorerFrame GetExplorerFrame()
        {
            if (_explorerFrame == null)
            {
                _explorerFrame = ExplorerUtility.FindLogicalAncestorOfType <ExplorerFrame>(this);
            }

            return(_explorerFrame);
        }
        internal void OnMouseDownAncestorOfSearchResultItemStyle(object sender)
        {
            var treeViewItem = ExplorerUtility.FindVisualAncestorOfType <ExplorerTreeViewItem>(sender as FrameworkElement);

            Debug.Assert(treeViewItem != null);
            if (treeViewItem != null)
            {
                FocusTreeViewItem(treeViewItem);
                WaitUIUpdate();
                UpdateNextAndPreviousResults(true);
                WaitUIUpdate();
                OnSelectNextSearchResult();
            }
        }
Exemple #5
0
        public void ExecutePutInRenameMode()
        {
            var selectedExplorerEFElement = GetSelectedExplorerEFElement();

            if (selectedExplorerEFElement != null)
            {
                var treeViewItem = GetTreeViewItem(selectedExplorerEFElement, false);
                if (treeViewItem != null)
                {
                    var editableContentControl =
                        ExplorerUtility.GetTypeDescendents(treeViewItem, typeof(EditableContentControl)).FirstOrDefault() as
                        EditableContentControl;
                    if (editableContentControl != null)
                    {
                        // put the EditableContentControl into edit mode so user can change the name
                        editableContentControl.IsInEditMode = true;
                    }
                }
            }
        }
Exemple #6
0
        internal void PutElementInRenameMode(ExplorerEFElement explorerElement)
        {
            Debug.Assert(explorerElement != null, "explorerElement must not be null");
            if (explorerElement != null)
            {
                // if ExplorerElement.IsEditableInline is false then there will be no EditableContentControl to find
                Debug.Assert(
                    explorerElement.IsEditableInline,
                    "explorerElement.IsEditableInline should be true but was false. ExplorerElement has name " + explorerElement.Name
                    + " and type " + explorerElement.GetType().FullName);
                if (explorerElement.IsEditableInline)
                {
                    var treeViewItem = GetTreeViewItem(explorerElement, false);
                    Debug.Assert(treeViewItem != null, "Could not find TreeViewItem for Explorer element named " + explorerElement.Name);
                    if (treeViewItem != null)
                    {
                        // Note: if the ItemContainerGenerator status is NotStarted, the UI Element is not created yet.
                        // This causes ExplorerUtility.GetTypeDescendents() call to return null.
                        if (treeViewItem.ItemContainerGenerator.Status == GeneratorStatus.NotStarted)
                        {
                            treeViewItem.UpdateLayout();
                        }

                        var editableContentControl =
                            ExplorerUtility.GetTypeDescendents(treeViewItem, typeof(EditableContentControl)).FirstOrDefault() as
                            EditableContentControl;
                        Debug.Assert(
                            null != editableContentControl,
                            "Could not find EditableContentControl for Explorer element named " + explorerElement.Name);
                        if (null != editableContentControl)
                        {
                            // put the EditableContentControl into edit mode so user can change the name
                            editableContentControl.IsInEditMode = true;
                        }
                    }
                }
            }
        }
        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);
                    }
                }
            }
        }
Exemple #8
0
 private static ExplorerFrame GetExplorerFrame(FrameworkElement element)
 {
     return(ExplorerUtility.FindVisualAncestorOfType <ExplorerFrame>(element));
 }