Esempio n. 1
0
 void IScrollInfo.LineDown()
 {
     if (scrollInfo != null)
     {
         scrollInfo.LineDown();
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Scrolls down within content by one logical unit.
 /// </summary>
 public void LineDown()
 {
     if (_childScrollInfo == null)
     {
         return;
     }
     _childScrollInfo.LineDown();
 }
        void IScrollInfo.LineDown()
        {
            IScrollInfo realImplementation = Content as IScrollInfo;

            if (realImplementation != null)
            {
                realImplementation.LineDown();
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Esempio n. 4
0
        protected override Script.IScriptCommand executeInner(ParameterDic pm, Control sender,
                                                              RoutedEventArgs evnt, IUIInput input, IList <IUIInputProcessor> inpProcs)
        {
            var scp = ControlUtils.GetScrollContentPresenter(sender);

            if (input != null)
            {
                Point       posRelToScp = pm.GetValue <Point>(CurrentRelativePositionKey);
                IScrollInfo isInfo      = UITools.FindVisualChild <Panel>(scp) as IScrollInfo;
                if (isInfo != null)
                {
                    if (isInfo.CanHorizontallyScroll)
                    {
                        if (posRelToScp.X < 0)
                        {
                            isInfo.LineLeft();
                        }
                        else if (posRelToScp.X > (isInfo as Panel).ActualWidth)
                        {
                            isInfo.LineRight();
                        }
                    }
                    if (isInfo.CanVerticallyScroll)
                    {
                        if (posRelToScp.Y < 0)
                        {
                            isInfo.LineUp();
                        }
                        else if (posRelToScp.Y > (isInfo as Panel).ActualHeight) //isInfo.ViewportHeight is bugged.
                        {
                            isInfo.LineDown();
                        }
                    }
                }
            }
            return(NextCommand);
        }
            /// A handler for an event reporting that the drag over during drag-and-drop operation.
            internal void TargetOnDragOver(DragEventArgs e)
            {
                if (!AllowDragDrop(e))
                {
                    return;
                }

                // Ok, there's data to move or copy here.
                if ((e.AllowedEffects & DragDropEffects.Move) != 0)
                {
                    e.Effects = DragDropEffects.Move;
                }

                bool ctrlKeyDown = ((int)(e.KeyStates & DragDropKeyStates.ControlKey) != 0);

                if (ctrlKeyDown)
                {
                    e.Effects |= DragDropEffects.Copy;
                }

                // Show the caret on the drag over target position.
                if (_caretDragDrop != null)
                {
                    // Update the layout to get the corrected text position. Otherwise, we can get the
                    // incorrected text position.
                    if (!_textEditor.TextView.Validate(e.GetPosition(_textEditor.TextView.RenderScope)))
                    {
                        return;
                    }

                    // Find the scroller from the render scope
                    FrameworkElement scroller = _textEditor._Scroller;

                    // Automatically scroll the dropable content(line or page up/down) if scroller is available
                    if (scroller != null)
                    {
                        // Get the ScrollInfo to scroll a line or page up/down
                        IScrollInfo scrollInfo = scroller as IScrollInfo;

                        if (scrollInfo == null && scroller is ScrollViewer)
                        {
                            scrollInfo = ((ScrollViewer)scroller).ScrollInfo;
                        }

                        Invariant.Assert(scrollInfo != null);

                        // Takes care of scrolling mechanism when vertical scrollbar is available, it creates a virtual
                        // block within the viewport where if you position your mouse during drag leads to scrolling,here
                        // it is of 16pixels and within first 8pixels it does scrolling by line and for next it scrolls by page.

                        Point  pointScroller  = e.GetPosition((IInputElement)scroller);
                        double pageHeight     = (double)_textEditor.UiScope.GetValue(TextEditor.PageHeightProperty);
                        double slowAreaHeight = ScrollViewer._scrollLineDelta;

                        if (pointScroller.Y < slowAreaHeight)
                        {
                            // Drag position is on the scroll area that we need to scroll up
                            if (pointScroller.Y > slowAreaHeight / 2)
                            {
                                // scroll a line up
                                scrollInfo.LineUp();
                            }
                            else
                            {
                                // scroll a page up
                                scrollInfo.PageUp();
                            }
                        }
                        else if (pointScroller.Y > (pageHeight - slowAreaHeight))
                        {
                            // Drag position is on the scroll area that we need to scroll down
                            if (pointScroller.Y < (pageHeight - slowAreaHeight / 2))
                            {
                                // scroll a line down
                                scrollInfo.LineDown();
                            }
                            else
                            {
                                // scroll a page down
                                scrollInfo.PageDown();
                            }
                        }
                    }

                    // Get the current text position from the dropable mouse point.
                    _textEditor.TextView.RenderScope.UpdateLayout(); // REVIEW:benwest:6/27/2006: This should use TextView.Validate, and check the return value instead of using IsValid below.

                    if (_textEditor.TextView.IsValid)
                    {
                        ITextPointer dragPosition = GetDropPosition(_textEditor.TextView.RenderScope as Visual, e.GetPosition(_textEditor.TextView.RenderScope));

                        if (dragPosition != null)
                        {
                            // Get the caret position to show the dropable point.
                            Rect caretRectangle = this.TextView.GetRectangleFromTextPosition(dragPosition);

                            // NOTE: We DO NOT use GetCurrentValue because springload formatting should NOT be involved for drop caret.
                            object fontStylePropertyValue = dragPosition.GetValue(TextElement.FontStyleProperty);
                            bool   italic     = (_textEditor.AcceptsRichContent && fontStylePropertyValue != DependencyProperty.UnsetValue && (FontStyle)fontStylePropertyValue == FontStyles.Italic);
                            Brush  caretBrush = TextSelection.GetCaretBrush(_textEditor);

                            // Show the caret on the dropable position.
                            _caretDragDrop.Update(/*visible:*/ true, caretRectangle, caretBrush, 0.5, italic, CaretScrollMethod.None, /*wordWrappingPosition*/ double.NaN);
                        }
                    }
                }
            }
Esempio n. 6
0
            // Token: 0x060085BC RID: 34236 RVA: 0x0024A7EC File Offset: 0x002489EC
            internal void TargetOnDragOver(DragEventArgs e)
            {
                if (!this.AllowDragDrop(e))
                {
                    return;
                }
                if ((e.AllowedEffects & DragDropEffects.Move) != DragDropEffects.None)
                {
                    e.Effects = DragDropEffects.Move;
                }
                bool flag = (e.KeyStates & DragDropKeyStates.ControlKey) > DragDropKeyStates.None;

                if (flag)
                {
                    e.Effects |= DragDropEffects.Copy;
                }
                if (this._caretDragDrop != null)
                {
                    if (!this._textEditor.TextView.Validate(e.GetPosition(this._textEditor.TextView.RenderScope)))
                    {
                        return;
                    }
                    FrameworkElement scroller = this._textEditor._Scroller;
                    if (scroller != null)
                    {
                        IScrollInfo scrollInfo = scroller as IScrollInfo;
                        if (scrollInfo == null && scroller is ScrollViewer)
                        {
                            scrollInfo = ((ScrollViewer)scroller).ScrollInfo;
                        }
                        Invariant.Assert(scrollInfo != null);
                        Point  position = e.GetPosition(scroller);
                        double num      = (double)this._textEditor.UiScope.GetValue(TextEditor.PageHeightProperty);
                        double num2     = 16.0;
                        if (position.Y < num2)
                        {
                            if (position.Y > num2 / 2.0)
                            {
                                scrollInfo.LineUp();
                            }
                            else
                            {
                                scrollInfo.PageUp();
                            }
                        }
                        else if (position.Y > num - num2)
                        {
                            if (position.Y < num - num2 / 2.0)
                            {
                                scrollInfo.LineDown();
                            }
                            else
                            {
                                scrollInfo.PageDown();
                            }
                        }
                    }
                    this._textEditor.TextView.RenderScope.UpdateLayout();
                    if (this._textEditor.TextView.IsValid)
                    {
                        ITextPointer dropPosition = this.GetDropPosition(this._textEditor.TextView.RenderScope, e.GetPosition(this._textEditor.TextView.RenderScope));
                        if (dropPosition != null)
                        {
                            Rect   rectangleFromTextPosition = this.TextView.GetRectangleFromTextPosition(dropPosition);
                            object value      = dropPosition.GetValue(TextElement.FontStyleProperty);
                            bool   italic     = this._textEditor.AcceptsRichContent && value != DependencyProperty.UnsetValue && (FontStyle)value == FontStyles.Italic;
                            Brush  caretBrush = TextSelection.GetCaretBrush(this._textEditor);
                            this._caretDragDrop.Update(true, rectangleFromTextPosition, caretBrush, 0.5, italic, CaretScrollMethod.None, double.NaN);
                        }
                    }
                }
            }