예제 #1
0
 void _partDesignContent_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
 {
     if (!enableBringIntoView)
     {
         e.Handled = true;
     }
     enableBringIntoView = false;
 }
예제 #2
0
 private void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
 {
     if (Keyboard.IsKeyDown(Key.Down) || Keyboard.IsKeyDown(Key.Up))
     {
         return;
     }
     e.Handled = true;
 }
예제 #3
0
 private void UserControl_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
 {
     if (CurrentItem != null)
     {
         //OnPropertyChanged("CurrentItem");
         CurrentItem.RefreshData();
     }
 }
예제 #4
0
 private void FontComboBox_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
 {
     if (((ComboBoxItem)e.TargetObject).Content == FontComboBox.SelectedItem)
     {
         return;
     }
     e.Handled = true;
 }
예제 #5
0
 private void DisableScrollEventHandler(object sender, RequestBringIntoViewEventArgs e)
 {
     // Prevent autoscroll uppon cell selections
     // Such an stupid smart idea
     if (!_scrolling)
     {
         e.Handled = true;
     }
 }
        public void ComboBoxItem_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            if (Keyboard.IsKeyDown(Key.Down) || Keyboard.IsKeyDown(Key.Up))
            {
                return;
            }

            e.Handled = true;
        }
예제 #7
0
        /// <summary>
        /// Handles the RequestBringIntoView event of the category combobox. Prevents annoying autoscroll.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            //Allows the keyboard to bring the items into view as expected:
            if (Keyboard.IsKeyDown(Key.Down) || Keyboard.IsKeyDown(Key.Up))
            {
                return;
            }

            e.Handled = true;
        }
예제 #8
0
 void NotesEditor_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
 {
     // prevent scrollviewer to automaticaly adjust itself to editor
     if (_trackingCaret)
     {
         _trackingCaret = false;
         return;
     }
     e.Handled = true;
 }
예제 #9
0
        private static void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            LoopPanel        lp     = sender as LoopPanel;
            DependencyObject target = e.TargetObject as DependencyObject;

            if (lp.BringChildrenIntoView && target != lp)
            {
                UIElement child = null;
                while (target != null)
                {
                    if ((target is UIElement) &&
                        lp.InternalChildren.Contains(target as UIElement))
                    {
                        child = target as UIElement;
                        break;
                    }
                    target = VisualTreeHelper.GetParent(target);
                    if (target == lp)
                    {
                        break;
                    }
                }

                if (child != null &&
                    lp.InternalChildren.Contains(child))
                {
                    e.Handled = true;

                    // determine if the child needs to be brought into view
                    GeneralTransform childTransform = child.TransformToAncestor(lp);
                    Rect             childRect      = childTransform.TransformBounds(new Rect(new Point(0, 0), child.RenderSize));
                    Rect             intersection   = Rect.Intersect(new Rect(new Point(0, 0), lp.RenderSize), childRect);

                    // if the intersection is different than the child rect, it is either not visible
                    // or only partially visible, so adjust the Offset to bring it into view
                    if (!childRect.AreVirtuallyEqual(intersection))
                    {
                        if (!intersection.IsEmpty)
                        {
                            // the child is already partially visible, so just scroll it into view
                            lp.Scroll((lp.Orientation == Orientation.Horizontal)
                                ? (childRect.X.AreVirtuallyEqual(intersection.X) ? childRect.Width - intersection.Width + Math.Min(0, lp.RenderSize.Width - childRect.Width) : childRect.X - intersection.X)
                                : (childRect.Y.AreVirtuallyEqual(intersection.Y) ? childRect.Height - intersection.Height + Math.Min(0, lp.RenderSize.Height - childRect.Height) : childRect.Y - intersection.Y));
                        }
                        else
                        {
                            // the child is not visible at all
                            lp.Scroll((lp.Orientation == Orientation.Horizontal)
                                ? (childRect.Right.StrictlyLessThan(0.0d) ? childRect.X : childRect.Right - lp.RenderSize.Width + Math.Min(0, lp.RenderSize.Width - childRect.Width))
                                : (childRect.Bottom.StrictlyLessThan(0.0d) ? childRect.Y : childRect.Bottom - lp.RenderSize.Height + Math.Min(0, lp.RenderSize.Height - childRect.Height)));
                        }
                    }
                }
            }
        }
예제 #10
0
 private void Page_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
 {
     foreach (FrameworkElement fwe in new FrameworkElement[] { tbInstalledProfile, btnExisting, btnNewProfile })
     {
         if (fwe.IsVisible && fwe.IsEnabled)
         {
             fwe.Focus();
             return;
         }
     }
 }
예제 #11
0
 private void OnTreeViewItemRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
 {
     if (internalRequestBeingIntoView)
     {
         internalRequestBeingIntoView = false;
     }
     else
     {
         e.Handled = true;
     }
 }
예제 #12
0
 void BodyFocusHack(object sender, RequestBringIntoViewEventArgs e)
 {
     if (e.TargetObject == bodyMarkdown)
     {
         // Hack to prevent pane scrolling to top. Instead focus selected tree view item.
         // See https://github.com/github/VisualStudio/issues/1042
         var node = changesTree.GetTreeViewItem(changesTree.SelectedItem);
         node?.Focus();
         e.Handled = true;
     }
 }
예제 #13
0
        private void setComboBindingAndHanldeUnsetValue(object sender, RequestBringIntoViewEventArgs e)
        {
            ComboBox combo = sender as ComboBox;
            DataGridComboBoxColumn column = AssignedDataGridColumn as DataGridComboBoxColumn;

            if (column.ItemsSource == null)
            {
                if (combo.ItemsSource != null)
                {
                    IList list = combo.ItemsSource.Cast <object>().ToList();

                    if (list.Count > 0 && list[0] != DependencyProperty.UnsetValue)
                    {
                        combo.RequestBringIntoView -=
                            new RequestBringIntoViewEventHandler(setComboBindingAndHanldeUnsetValue);

                        list.Insert(0, DependencyProperty.UnsetValue);

                        combo.DisplayMemberPath = column.DisplayMemberPath;
                        combo.SelectedValuePath = column.SelectedValuePath;

                        combo.ItemsSource = list;
                    }
                }
            }
            else
            {
                combo.RequestBringIntoView -=
                    new RequestBringIntoViewEventHandler(setComboBindingAndHanldeUnsetValue);

                IList comboList  = null;
                IList columnList = null;

                if (combo.ItemsSource != null)
                {
                    comboList = combo.ItemsSource.Cast <object>().ToList();
                }

                columnList = column.ItemsSource.Cast <object>().ToList();

                if (comboList == null ||
                    (columnList.Count > 0 && columnList.Count + 1 != comboList.Count))
                {
                    columnList = column.ItemsSource.Cast <object>().ToList();
                    columnList.Insert(0, DependencyProperty.UnsetValue);

                    combo.ItemsSource = columnList;
                }

                combo.RequestBringIntoView +=
                    new RequestBringIntoViewEventHandler(setComboBindingAndHanldeUnsetValue);
            }
        }
예제 #14
0
        private void tv1_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            base.BringIntoView();
            // e.Handled = true;

            var scrollViewer = tv1.Template.FindName("_tv_scrollviewer_", tv1) as ScrollViewer;

            if (scrollViewer != null)
            {
                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Loaded, (Action)(() => scrollViewer.ScrollToLeftEnd()));
            }
        }
예제 #15
0
 private void TreeView_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
 {
     if (treeViewScrollViewer == null)
     {
         treeViewScrollViewer = TreeView.Template.FindName("_tv_scrollviewer_", TreeView) as ScrollViewer;
         if (this.treeViewScrollViewer != null)
         {
             this.treeViewScrollViewer.ScrollChanged += new ScrollChangedEventHandler(TreeViewScrollViewerScrollChanged);
         }
     }
     this.treeViewResetHorizScroll = true;
     this.treeViewHorizScrollPos   = this.treeViewScrollViewer.HorizontalOffset;
 }
예제 #16
0
        private static void HandleRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            var treeViewItem = (TreeViewItem)sender;

            if (treeViewItem.Parent == null)
            {
                var scrollViewer = treeViewItem.FindParent <ScrollViewer>();
                if (scrollViewer != null)
                {
                    treeViewItem.Dispatcher.BeginInvoke(() => scrollViewer.ScrollToLeftEnd());
                }
            }
        }
예제 #17
0
        private async void TabItem_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            await GetData();

            SalesList.ItemsSource = Sales;
            SalesList.Items.Refresh();

            try
            {
                SalesInfos = (await SalesInfo.CreateSalesInfo(Beers, Sales)).ToList();
            }
            catch { }
        }
예제 #18
0
        private void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            //Allows the keyboard to bring the items into view as expected:
            if (Keyboard.IsKeyDown(Key.Down) || Keyboard.IsKeyDown(Key.Up))
            {
                return;
            }
            if (((ComboBoxItem)e.TargetObject).Content == list.SelectedItem)
            {
                return;
            }

            e.Handled = true;
        }
예제 #19
0
        /// <summary>
        /// tries to bring the content to the view
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnRequestBringIntoView(RequestBringIntoViewEventArgs e)
        {
            if (e.TargetObject == this && _header != null)
            {
                var m = _header.TransformToVisual(this);

                if (m.HasValue)
                {
                    var bounds = new Rect(_header.Bounds.Size);
                    var rect   = bounds.TransformToAABB(m.Value);
                    e.TargetRect = rect;
                }
            }
        }
예제 #20
0
 void DiagramDesignerItem_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
 {
     // no need for a diagram link to be brought into view, since it will not be done correctly anyways
     if (IsDiagramLink)
     {
         e.Handled = true;
     }
     else
     {
         e.Handled = false;
         DiagramRubberbandSelector.IgnoreRubberbandSelectionOnce = true;
         //ParentCanvas.CancelRubberbandSelection();
     }
 }
예제 #21
0
        private static void HandleBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            if (e.TargetObject == sender)
            {
                return;
            }
            TimelineTreeRow    timelineTreeRow    = (TimelineTreeRow)sender;
            InlineStringEditor inlineStringEditor = timelineTreeRow.FindName("ItemTitle") as InlineStringEditor;

            if (inlineStringEditor == null || !inlineStringEditor.IsEditing || e.TargetRect.IsEmpty)
            {
                return;
            }
            timelineTreeRow.BringIntoView(new Rect(e.TargetRect.X, e.TargetRect.Y, inlineStringEditor.ActualWidth, inlineStringEditor.ActualHeight));
            e.Handled = true;
        }
예제 #22
0
        /// <summary>
        /// The framework element on request bring into view.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void FrameworkElementOnRequestBringIntoView(
            [CanBeNull] object sender,
            [NotNull] RequestBringIntoViewEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            // Allows the keyboard to bring the items into view as expected:
            if (Keyboard.IsKeyDown(Key.Down) || Keyboard.IsKeyDown(Key.Up))
            {
                return;
            }

            e.Handled = true;
        }
예제 #23
0
        void popup_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            if (!subsequentCall)
            {
                if (DropDownContent != null)
                {
                    if (DropDownContent.GetType().GetProperty("ActiveSmartPart") != null)
                    {
                        object smartPart = DropDownContent.GetType().GetProperty("ActiveSmartPart").GetValue(DropDownContent, null);
                        if (smartPart != null)
                        {
                            subsequentCall = true;

                            if (smartPart is UserControl)
                            {
                                if (((UserControl)smartPart).Content != null)
                                {
                                    object content = ((UserControl)smartPart).Content;

                                    if (content != null && content is Grid)
                                    {
                                        Grid grid = (Grid)content;

                                        if (grid.RowDefinitions.Count == 2)
                                        {
                                            RowDefinition rowDef = grid.RowDefinitions[0];

                                            if (rowDef.ActualHeight > (popup.Height / 3))
                                            {
                                                popup.Height = rowDef.ActualHeight + 200;
                                                double newWidth = (rowDef.ActualHeight + 200) * 1.618;
                                                if (newWidth > popup.Width)
                                                {
                                                    popup.Width = newWidth;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #24
0
        private void TreeViewItemRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            if (_treeViewScrollViewer == null)
            {
                _treeViewScrollViewer = TheNavigationView.Navigation.Template.FindName("_tv_scrollviewer_", TheNavigationView.Navigation) as ScrollViewer;
                if (_treeViewScrollViewer != null)
                {
                    _treeViewScrollViewer.ScrollChanged += TreeViewScrollViewerScrollChanged;
                }
            }
            _treeViewResetHorizScroll = true;
            var treeViewScrollViewer = _treeViewScrollViewer;

            if (treeViewScrollViewer != null)
            {
                _treeViewHorizScrollPos = treeViewScrollViewer.HorizontalOffset;
            }
        }
        void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            bool?targetIsOnFrontSide = GetIsOnFrontSide(e.TargetObject);

            if (!targetIsOnFrontSide.HasValue)
            {
                return;
            }

            if (targetIsOnFrontSide.Value)
            {
                this.BringFrontSideIntoView();
            }
            else
            {
                this.BringBackSideIntoView();
            }
        }
예제 #26
0
        private void BringIntoViewOverride(RequestBringIntoViewEventArgs e)
        {
            ExpandAncestors();

            // Only bring header into view. Ignore children.
            if (e.TargetRect.IsEmpty)
            {
                if (_header != null)
                {
                    e.Handled = true;
                    _header.BringIntoView();
                }
                else
                {
                    // Retry when loaded.
                    Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => _header?.BringIntoView()));
                }
            }
        }
예제 #27
0
        private void InspectionResultsGrid_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            if (_requestingModifiedBringIntoView ||
                !(e?.OriginalSource is FrameworkElement source))
            {
                return;
            }

            e.Handled = true;

            //Prevents adjustment of the adjusted event triggered below.
            _requestingModifiedBringIntoView = true;

            var newRectangle = new Rect(-HorizontalRectangleAdjustment, 0, source.ActualWidth + HorizontalRectangleAdjustment, source.ActualHeight);

            source.BringIntoView(newRectangle);

            _requestingModifiedBringIntoView = false;
        }
예제 #28
0
        private void TreeViewItem_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            if (_mSuppressRequestBringIntoView)
            {
                return;
            }

            e.Handled = true;

            _mSuppressRequestBringIntoView = true;

            if (sender is TreeViewItem tvi)
            {
                var newTargetRect = new Rect(-1000, 0, tvi.ActualWidth + 1000, tvi.ActualHeight);
                tvi.BringIntoView(newTargetRect);
            }

            _mSuppressRequestBringIntoView = false;
        }
예제 #29
0
        private void treeView_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
        {
            // keep tree view from scrolling horizontally when an item is (mouse) selected
            var treeViewItem = (TreeViewItem)sender;
            var scrollViewer = treeView.Template.FindName("_tv_scrollviewer_", treeView) as ScrollViewer;

            Point topLeftInTreeViewCoordinates = treeViewItem.TransformToAncestor(treeView).Transform(new Point(0, 0));
            var   treeViewItemTop = topLeftInTreeViewCoordinates.Y;

            if (treeViewItemTop < 0 ||
                treeViewItemTop + treeViewItem.ActualHeight > scrollViewer.ViewportHeight ||
                treeViewItem.ActualHeight > scrollViewer.ViewportHeight)
            {
                // if the item is not visible or too "tall", don't do anything; let them scroll it into view
                return;
            }

            // if the item is already fully within the viewport vertically, disallow horizontal scrolling
            e.Handled = true;
        }
예제 #30
0
        private void HandleBringIntoView(RequestBringIntoViewEventArgs e)
        {
            for (var i = ParentTreeViewItem; i != null; i = i.ParentTreeViewItem)
            {
                if (!i.IsExpanded)
                {
                    i.IsExpanded = true;
                }
            }

            if (e.TargetRect.IsEmpty)
            {
                var headerElement = GetFirstHeaderElement();
                if (headerElement != null)
                {
                    headerElement.BringIntoView();
                    e.Handled = true;
                }
            }
        }
        /// <summary>
        /// Makes sure the target is visible in the client area.
        /// </summary>
        /// <param name="args">RequestBringIntoViewEventArgs indicates the element and region to scroll into view.</param>
        private void HandleRequestBringIntoView(RequestBringIntoViewEventArgs args)
        {
            DependencyObject child;
            DependencyObject document;
            IContentHost ich;
            ReadOnlyCollection<Rect> rects;
            UIElement targetUIElement;
            Rect targetRect = Rect.Empty;

            if (args != null && args.TargetObject != null && Document != null)
            {
                document = Document;

                // If the passed in object is a logical child of FlowDocumentScrollViewer's Document,
                // attempt to make it visible now.
                // Special case: TargetObject is the document itself. Then scroll to the top (page 1).
                // This supports navigating from baseURI#anchor to just baseURI.
                if (args.TargetObject == document)
                {
                    if (_contentHost != null)
                    {
                        _contentHost.ScrollToHome();
                    }
                    args.Handled = true; // Mark the event as handled.
                }
                else if (args.TargetObject is UIElement)
                {
                    targetUIElement = (UIElement)args.TargetObject;
                    // Since entire content of FlowDocument is represented by
                    // bottomless page, the target has to be connected to visual tree.
                    // Otherwise, it is not descendant of FlowDocument.
                    if (RenderScope != null && RenderScope.IsAncestorOf(targetUIElement))
                    {
                        targetRect = args.TargetRect;
                        if (targetRect.IsEmpty)
                        {
                            targetRect = new Rect(targetUIElement.RenderSize);
                        }

                        targetRect = MakeVisible((IScrollInfo)RenderScope, targetUIElement, targetRect);

                        if(!targetRect.IsEmpty)
                        {
                            GeneralTransform t = RenderScope.TransformToAncestor(this);
                            targetRect = t.TransformBounds(targetRect);
                        }
                        args.Handled = true; // Mark the event as handled.
                    }
                }
                else if (args.TargetObject is ContentElement)
                {
                    // Verify if TargetObject is in fact a child of Document.
                    child = args.TargetObject;
                    while (child != null && child != document)
                    {
                       child = LogicalTreeHelper.GetParent(child);
                    }

                    if (child != null)
                    {
                        ich = GetIContentHost();
                        if (ich != null)
                        {
                            // Get the position of the content.
                            rects = ich.GetRectangles((ContentElement)args.TargetObject);
                            if (rects.Count > 0)
                            {
                                targetRect = MakeVisible((IScrollInfo)RenderScope, (Visual)ich, rects[0]);

                                if(!targetRect.IsEmpty)
                                {
                                    GeneralTransform t = RenderScope.TransformToAncestor(this);
                                    targetRect = t.TransformBounds(targetRect);
                                }
                            }
                        }
                        args.Handled = true; // Mark the event as handled.
                    }
                }

                if (args.Handled)
                {
                    // Create new BringIntoView request for this element, so
                    // if there is an ancestor handling BringIntoView, it can
                    // react appropriately and bring this element into view.
                    if (targetRect.IsEmpty)
                    {
                        BringIntoView();
                    }
                    else
                    {
                        BringIntoView(targetRect);
                    }
                }
            }
        }
 /// <summary>
 /// Called from the event handler to make sure the target is visible in the client
 /// area. May cause navigation to a different page.
 /// </summary>
 /// <param name="sender">The instance handling the event.</param>
 /// <param name="args">RequestBringIntoViewEventArgs indicates the element and region to scroll into view.</param>
 private static void HandleRequestBringIntoView(object sender, RequestBringIntoViewEventArgs args)
 {
     if (sender != null && sender is DocumentViewerBase)
     {
         ((DocumentViewerBase)sender).HandleRequestBringIntoView(args);
     }
 }
        /// <summary>
        /// Makes sure the target is visible in the client area. May cause navigation
        /// to a different page.
        /// </summary>
        /// <param name="args">RequestBringIntoViewEventArgs indicates the element and region to scroll into view.</param>
        private void HandleRequestBringIntoView(RequestBringIntoViewEventArgs args)
        {
            DependencyObject child;
            DependencyObject parent;
            ContentPosition contentPosition;
            BringIntoViewState bringIntoViewState;
            DynamicDocumentPaginator documentPaginator;
            Rect targetRect = Rect.Empty;

            if (args != null && args.TargetObject != null && _document is DependencyObject)
            {
                // If the passed in object is a logical child of DocumentViewer's Document,
                // attempt to make it visible now.
                // Special case: TargetObject is the document itself. Then scroll to the top (page 1).
                // This supports navigating from baseURI#anchor to just baseURI.
                parent = _document as DependencyObject;
                if (args.TargetObject == _document)
                {
                    OnGoToPageCommand(1);
                    args.Handled = true; // Mark the event as handled.
                }
                else
                {
                    // Verify if TargetObject is in fact a child of Document.
                    child = args.TargetObject;
                    while (child != null && child != parent)
                    {
                        // Skip elements in the control's template (if such exists) and 
                        // walk up logical tree to find if the focused element is within
                        // the document.
                        FrameworkElement fe = child as FrameworkElement;
                        if (fe != null && fe.TemplatedParent != null)
                        {
                            child = fe.TemplatedParent;
                        }
                        else
                        {
                            child = LogicalTreeHelper.GetParent(child);
                        }
                    }

                    if (child != null)
                    {
                        // Special case UIElements already connected to visual tree.
                        if (args.TargetObject is UIElement)
                        {
                            UIElement targetObject = (UIElement)args.TargetObject;
                            if (VisualTreeHelper.IsAncestorOf(this, targetObject))
                            {
                                targetRect = args.TargetRect;
                                if (targetRect.IsEmpty)
                                {
                                    targetRect = new Rect(targetObject.RenderSize);
                                }
                                GeneralTransform transform = targetObject.TransformToAncestor(this);
                                targetRect = transform.TransformBounds(targetRect);
                                targetRect.IntersectsWith(new Rect(this.RenderSize));
                            }
                        }

                        // If target is not already visible, bring appropriate page into view.
                        if (targetRect.IsEmpty)
                        {
                            // Get content position for given target.
                            documentPaginator = _document.DocumentPaginator as DynamicDocumentPaginator;
                            if (documentPaginator != null)
                            {
                                contentPosition = documentPaginator.GetObjectPosition(args.TargetObject);
                                if (contentPosition != null && contentPosition != ContentPosition.Missing)
                                {
                                    // Asynchronously retrieve PageNumber for given ContentPosition.
                                    bringIntoViewState = new BringIntoViewState(this, contentPosition, args.TargetObject, args.TargetRect);
                                    documentPaginator.GetPageNumberAsync(contentPosition, bringIntoViewState);
                                }
                            }
                        }
                        args.Handled = true; // Mark the event as handled.
                    }
                }
                if (args.Handled)
                {
                    // Create new BringIntoView request for this element, so 
                    // if there is an ancestor handling BringIntoView, it can
                    // react appropriately and bring this element into view.
                    if (targetRect.IsEmpty)
                    {
                        BringIntoView();
                    }
                    else
                    {
                        BringIntoView(targetRect);
                    }
                }
            }
        }
예제 #34
0
        // ------------------------------------------------------------------
        // OnRequestBringIntoView is called from the event handler TextBlock
        // registers for the event.
        // Handle the event for hosted ContentElements, and raise a new BringIntoView
        // event with the following values:
        // * object: (this)
        // * rect: A rect indicating the position of the ContentElement
        //
        //      sender - The instance handling the event.
        //      args   - RequestBringIntoViewEventArgs indicates the element
        //               and region to scroll into view.
        // ------------------------------------------------------------------
        private static void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs args)
        {
            TextBlock textBlock = sender as TextBlock;
            ContentElement child = args.TargetObject as ContentElement;

            if (textBlock != null && child != null)
            {
                if (TextBlock.ContainsContentElement(textBlock, child))
                {
                    // Handle original event.
                    args.Handled = true;

                    // Retrieve the first rectangle representing the child and
                    // raise a new BrightIntoView event with such rectangle.

                    ReadOnlyCollection<Rect> rects = textBlock.GetRectanglesCore(child);
                    Invariant.Assert(rects != null, "Rect collection cannot be null.");
                    if (rects.Count > 0)
                    {
                        textBlock.BringIntoView(rects[0]);
                    }
                    else
                    {
                        textBlock.BringIntoView();
                    }
                }
            }
        }
예제 #35
0
        private void BringIntoViewRequested(object sender, RequestBringIntoViewEventArgs e)
        {
            var transform = e.TargetObject.TransformToVisual(this.GetVisualChildren().Single());
            var rect = e.TargetRect * transform;
            var offset = this.Offset;

            if (rect.Bottom > offset.Y + this.Viewport.Height)
            {
                offset = offset.WithY(rect.Bottom - this.Viewport.Height);
                e.Handled = true;
            }

            if (rect.Y < offset.Y)
            {
                offset = offset.WithY(rect.Y);
                e.Handled = true;
            }

            if (rect.Right > offset.X + this.Viewport.Width)
            {
                offset = offset.WithX(rect.Right - this.Viewport.Width);
                e.Handled = true;
            }

            if (rect.X < offset.X)
            {
                offset = offset.WithX(rect.X);
                e.Handled = true;
            }

            this.Offset = offset;
        }
예제 #36
0
 private void BringIntoViewRequested(object sender, RequestBringIntoViewEventArgs e)
 {
     e.Handled = BringDescendentIntoView(e.TargetObject, e.TargetRect);
 }
 /// <summary>
 /// Called from the event handler to make sure the target is visible in the client area.
 /// </summary>
 /// <param name="sender">The instance handling the event.</param>
 /// <param name="args">RequestBringIntoViewEventArgs indicates the element and region to scroll into view.</param>
 private static void HandleRequestBringIntoView(object sender, RequestBringIntoViewEventArgs args)
 {
     if (sender != null && sender is FlowDocumentScrollViewer)
     {
         ((FlowDocumentScrollViewer)sender).HandleRequestBringIntoView(args);
     }
 }