Esempio n. 1
0
        private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            //Correctly rotate the handle for vertical movement
            if (Orientation == Orientation.VerticalMovement)
            {
                gradientRotator.Angle = 0;
            }

            if (Orientation == Orientation.BiDimentionalMovement)
            {
                //No handle visible in BiDim case
                theBorder.Background = new SolidColorBrush(Colors.Blue);
            }

            //Don't attach events during design time
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            var mainWindow = Application.Current.Windows.OfType <Window>().FirstOrDefault();

            Mouse.AddPreviewMouseDownHandler(this, OnLocalMouseDown);
            Mouse.AddMouseLeaveHandler(this, OnLocalMouseLeave);
            Mouse.AddMouseEnterHandler(this, OnLocalMouseEnter);
            Mouse.AddPreviewMouseMoveHandler(mainWindow, OnGlobalMouseMove);
            Mouse.AddPreviewMouseUpHandler(mainWindow, OnGlobalMouseUp);
        }
Esempio n. 2
0
 private void onCanvasAttached()
 {
     Mouse.AddPreviewMouseDownHandler(canvas, OnMouseDown);
     Mouse.AddPreviewMouseMoveHandler(canvas, OnMouseMove);
     Mouse.AddPreviewMouseUpHandler(canvas, OnMouseUp);
     Mouse.AddPreviewMouseWheelHandler(canvas, OnMouseWheel);
 }
        void IPlotterElement.OnPlotterAttached(Plotter plotter)
        {
            this.plotter = (Plotter2D)plotter;

            Mouse.AddPreviewMouseDownHandler(plotter.CentralGrid, OnMouseDown);
            Mouse.AddPreviewMouseUpHandler(plotter.CentralGrid, OnMouseUp);
            plotter.CentralGrid.MouseLeave += CentralGrid_MouseLeave;
        }
Esempio n. 4
0
        public override void OnPlotterAttached(Plotter plotter)
        {
            base.OnPlotterAttached(plotter);

            Mouse.AddPreviewMouseDownHandler(Parent, OnMouseDown);
            Mouse.AddPreviewMouseMoveHandler(Parent, OnMouseMove);
            Mouse.AddPreviewMouseUpHandler(Parent, OnMouseUp);
            Mouse.AddPreviewMouseWheelHandler(Parent, OnMouseWheel);
        }
        }         // proc LoadInternAsync

        /// <summary>Control is created.</summary>
        protected virtual void OnControlCreated()
        {
            CallMemberDirect(nameof(OnControlCreated), Array.Empty <object>(), rawGet: true, ignoreNilFunction: true);

            Mouse.AddPreviewMouseDownHandler(Control, Control_MouseDownHandler);
            Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(Control, Control_MouseDownHandler);
            Keyboard.AddPreviewGotKeyboardFocusHandler(Control, Control_GotKeyboardFocusHandler);
            Keyboard.AddPreviewLostKeyboardFocusHandler(Control, Control_LostKeyboardFocusHandler);
            Keyboard.AddPreviewKeyUpHandler(Control, Control_KeyUpHandler);
        }         // proc OnControlCreated
Esempio n. 6
0
        /// <summary>
        /// Gets the surrounding textview and adds the mouse handler.
        /// </summary>
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            DependencyObject current = this;

            while (!(current is IWpfTextView) && current != null)
            {
                current = VisualTreeHelper.GetParent(current);
            }

            _textView = (current as IWpfTextView)?.VisualElement ?? current;

            Mouse.AddMouseUpHandler(_textView, OnMouseUp);
            Mouse.AddPreviewMouseDownHandler(_textView, OnPreviewMouseDown);
        }
Esempio n. 7
0
        /// <summary>
        /// Attaches all event handlers we need to have a nice behavior in this view.
        /// </summary>
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            _window = Window.GetWindow(this);
            if (_window == null)
            {
                return;
            }

            Mouse.AddPreviewMouseDownHandler(_window, OnPreviewMouseButtonDown);
        }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Track"/> class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="name">The element's identifying name within its namescope.</param>
        public Track(UltravioletContext uv, String name)
            : base(uv, name)
        {
            this.Thumb = new Button(uv, null)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Focusable           = false,
            };
            this.Thumb.Classes.Add("track-thumb");
            this.Thumb.ChangeLogicalAndVisualParents(this, this);
            KeyboardNavigation.SetIsTabStop(this.Thumb, false);

            this.IncreaseButton = new RepeatButton(uv, null)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Opacity             = 0,
                Focusable           = false,
            };
            this.IncreaseButton.Classes.Add("track-increase");
            this.IncreaseButton.Click += HandleIncreaseButtonClick;
            this.IncreaseButton.ChangeLogicalAndVisualParents(this, this);
            KeyboardNavigation.SetIsTabStop(this.IncreaseButton, false);

            this.DecreaseButton = new RepeatButton(uv, null)
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Opacity             = 0,
                Focusable           = false,
            };
            this.DecreaseButton.Classes.Add("track-decrease");
            this.DecreaseButton.Click += HandleDecreaseButtonClick;
            this.DecreaseButton.ChangeLogicalAndVisualParents(this, this);
            KeyboardNavigation.SetIsTabStop(this.DecreaseButton, false);

            Mouse.AddPreviewMouseMoveHandler(this.Thumb, HandleThumbPreviewMouseMove);
            Mouse.AddPreviewMouseDownHandler(this.Thumb, HandleThumbPreviewMouseDown);
            Mouse.AddPreviewMouseUpHandler(this.Thumb, HandleThumbPreviewMouseUp);
        }
Esempio n. 9
0
        private void SplitButton_Loaded(object sender, RoutedEventArgs e)
        {
            PartPopup            = (Popup)GetTemplateChild("PART_Popup");
            PartButtonWith1      = (Button)GetTemplateChild("PART_ButtonWith1");
            PartButtonWith5      = (Button)GetTemplateChild("PART_ButtonWith5");
            PartButtonWith10     = (Button)GetTemplateChild("PART_ButtonWith10");
            PartButtonWithCustom = (Button)GetTemplateChild("PART_ButtonWithCustom");

            if (this.TryFindVisualChildElementByName("PART_ToggleButton", out FrameworkElement tb))
            {
                PartToggleButton = (ToggleButton)tb;
            }

            if (PartPopup != null)
            {
                PartPopup.ApplyTemplateRecursively();
            }

            if (PartButtonWith1 != null)
            {
                PartButtonWith1.Click += Btns_NewTimer_Click;
            }
            if (PartButtonWith5 != null)
            {
                PartButtonWith5.Click += Btns_NewTimer_Click;
            }
            if (PartButtonWith10 != null)
            {
                PartButtonWith10.Click += Btns_NewTimer_Click;
            }
            if (PartButtonWithCustom != null)
            {
                PartButtonWithCustom.Click += BtnCustom_Click;
            }

            Mouse.AddPreviewMouseDownHandler(Application.Current.MainWindow, KeepPopupOpen);
        }