示例#1
0
        /// <summary>
        /// Exeuctes the <see cref="ScrollBar.ScrollHereCommand"/> command.
        /// </summary>
        private static void ExecutedScrollHereCommand(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
        {
            var scrollBar    = (HScrollBar)element;
            var scrollBarMin = scrollBar.Minimum;
            var newValue     = scrollBar.lastRightClickedPoint.HasValue ?
                               (scrollBar.Track?.ValueFromPoint(scrollBar.lastRightClickedPoint.Value) ?? scrollBarMin) : scrollBarMin;

            if (newValue != scrollBar.Value)
            {
                scrollBar.Value = newValue;
                scrollBar.RaiseScrollEvent(ScrollEventType.ThumbPosition);
            }
        }
示例#2
0
 /// <summary>
 /// Exeuctes the <see cref="ScrollBar.PageRightCommand"/> command.
 /// </summary>
 private static void ExecutedPageRightCommand(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
 {
     ((HScrollBar)element).PageRight();
 }
示例#3
0
 /// <summary>
 /// Exeuctes the <see cref="ScrollBar.ScrollToLeftEndCommand"/> command.
 /// </summary>
 private static void ExecutedScrollToLeftEndCommand(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
 {
     ((HScrollBar)element).ScrollToLeftEnd();
 }
        /// <summary>
        /// Executes the <see cref="ApplicationCommands.Copy"/> command.
        /// </summary>
        private static void ExecutedCopy(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
        {
            var textEditor = ((TextEditingControl)element).TextEditor;

            if (textEditor == null || textEditor.IsMasked || textEditor.SelectionLength == 0 || !textEditor.IsEnabled)
            {
                return;
            }

            textEditor.Copy();
        }
        /// <summary>
        /// Executes the <see cref="ApplicationCommands.Paste"/> command.
        /// </summary>
        private static void ExecutedPaste(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
        {
            var textEditor = ((TextEditingControl)element).TextEditor;

            if (textEditor == null || textEditor.IsReadOnly || !textEditor.IsEnabled)
            {
                return;
            }

            textEditor.Paste();
        }
        /// <summary>
        /// Executes the <see cref="EditingCommands.MoveLeftByWord"/> command.
        /// </summary>
        private static void ExecutedMoveLeftByWord(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
        {
            var textEditor = ((TextEditingControl)element).TextEditor;

            if (textEditor == null || (textEditor.IsReadOnly && !textEditor.IsReadOnlyCaretVisible) || !textEditor.IsEnabled)
            {
                return;
            }

            if (textEditor.IsRightToLeft())
            {
                textEditor.MoveCaretToNextWord(false);
            }
            else
            {
                textEditor.MoveCaretToPreviousWord(false);
            }
        }
        /// <summary>
        /// Executes the <see cref="EditingCommands.MoveToDocumentEnd"/> command.
        /// </summary>
        private static void ExecutedMoveToDocumentEnd(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
        {
            var textEditor = ((TextEditingControl)element).TextEditor;

            if (textEditor == null || (textEditor.IsReadOnly && !textEditor.IsReadOnlyCaretVisible) || !textEditor.IsEnabled)
            {
                return;
            }

            textEditor.MoveCaretToEnd(false, true);
        }
        /// <summary>
        /// Executes the <see cref="ApplicationCommands.SelectAll"/> command.
        /// </summary>
        private static void ExecutedSelectAll(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
        {
            var textEditor = ((TextEditingControl)element).TextEditor;

            if (textEditor == null || (textEditor.IsReadOnly && !textEditor.IsReadOnlyCaretVisible) || !textEditor.IsEnabled)
            {
                return;
            }

            textEditor.SelectAll();
        }
        /// <summary>
        /// Executes the <see cref="EditingCommands.SelectRightByCharacter"/> command.
        /// </summary>
        private static void ExecutedSelectRightByCharacter(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
        {
            var textEditor = ((TextEditingControl)element).TextEditor;

            if (textEditor == null || (textEditor.IsReadOnly && !textEditor.IsReadOnlyCaretVisible) || !textEditor.IsEnabled)
            {
                return;
            }

            if (textEditor.IsRightToLeft())
            {
                textEditor.MoveCaretLeft(true);
            }
            else
            {
                textEditor.MoveCaretRight(true);
            }
        }
示例#10
0
        /// <summary>
        /// Executes a scroll command.
        /// </summary>
        private static void ExecutedScrollCommand(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
        {
            var scrollBar = element as ScrollBar;

            if (scrollBar == null || data.OriginalSource != scrollBar)
            {
                return;
            }

            var orientedScrollBar = (scrollBar.Orientation == Orientation.Horizontal) ? scrollBar.PART_HScrollBar : scrollBar.PART_VScrollBar;

            if (orientedScrollBar != null)
            {
                ((RoutedCommand)command).Execute(scrollBar.View, parameter, orientedScrollBar);
                data.Handled = true;
            }
        }
示例#11
0
        /// <summary>
        /// Executes the <see cref="Slider.MinimizeValueCommand"/> command.
        /// </summary>
        private static void ExecutedMinimizeValueCommand(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
        {
            var slider = element as OrientedSlider;

            if (slider == null)
            {
                return;
            }

            slider.OnMinimizeValue();
            data.Handled = true;
        }
示例#12
0
        /// <summary>
        /// Executes the <see cref="MinimizeValueCommand"/> command.
        /// </summary>
        private static void ExecutedMinimizeValueCommand(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
        {
            var slider = element as Slider;

            if (slider == null || data.OriginalSource != slider)
            {
                return;
            }

            slider.OnMinimizeValue();
            slider.ForwardCommandToOrientedSlider(command, parameter);
            data.Handled = true;
        }
示例#13
0
 /// <summary>
 /// Exeuctes the <see cref="ScrollBar.LineUpCommand"/> command.
 /// </summary>
 private static void ExecutedLineUpCommand(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
 {
     ((VScrollBar)element).LineUp();
 }
 /// <summary>
 /// Executes the <see cref="Track.DecreaseCommand"/> command.
 /// </summary>
 private static void ExecutedTrackDecreaseCommand(DependencyObject element, ICommand command, Object parameter, ExecutedRoutedEventData data)
 {
     if (element is FrameworkElement fe)
     {
         ScrollBar.PageLeftCommand.Execute(fe.View, null, fe);
     }
 }