Beispiel #1
0
        protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
        {
            if (double.IsNaN(ShiftX))
            {
                ShiftX = 0;
            }
            if (double.IsNaN(ShiftY))
            {
                ShiftY = 0;
            }
            var    oldx = ShiftX;
            var    oldy = ShiftY;
            double newx = ShiftX, newy = ShiftY;

            base.OnPointerWheelChanged(e);
            var delta = e.Delta.Y;

            Debug.WriteLine("Delta = " + e.Delta);
            Debug.WriteLine(e.KeyModifiers);
            if (e.KeyModifiers == KeyModifiers.Control)
            {
                Debug.WriteLine("Raw position: " + e.GetPosition(this));
                // get the screen coordinate of the current point.
                var p = ScreenPointToDominoCoordinates(e.GetPosition(this));
                Debug.WriteLine("Computed position in domino coordinates: " + oldx + ", " + oldy);
                var newzoom = Zoom;
                if (delta > 0)
                {
                    newzoom *= 1.1;
                }
                else
                {
                    newzoom *= 1 / 1.1;
                }
                if (newzoom > FitAllZoomValue / 4 && newzoom < 4)
                {
                    Zoom = newzoom;
                }

                newx = (p.X - e.GetPosition(this).X / Zoom);

                newy = (p.Y - e.GetPosition(this).Y / Zoom);
            }
            else
            {
                if (e.KeyModifiers == KeyModifiers.Shift)
                {
                    newx = oldx - 100 * (e.Delta.X + e.Delta.Y);
                }
                else
                {
                    newx = oldx - 100 * e.Delta.X;
                    newy = oldy - 100 * delta;
                }
            }
            ShiftX = newx;
            ShiftY = newy;
        }
 /// <summary>
 /// Converts <see cref="MouseWheelEventArgs" /> to <see cref="OxyMouseWheelEventArgs" /> for a mouse wheel event.
 /// </summary>
 /// <param name="e">The <see cref="MouseWheelEventArgs" /> instance containing the event data.</param>
 /// <param name="relativeTo">The <see cref="IInputElement" /> that the event is relative to.</param>
 /// <returns>A <see cref="OxyMouseWheelEventArgs" /> containing the converted event arguments.</returns>
 public static OxyMouseWheelEventArgs ToMouseWheelEventArgs(this PointerWheelEventArgs e, IInputElement relativeTo)
 {
     return(new OxyMouseWheelEventArgs
     {
         Position = e.GetPosition(relativeTo).ToScreenPoint(),
         ModifierKeys = Keyboard.Instance.GetModifierKeys(),
         Delta = (int)(e.Delta.Y + e.Delta.X) * 120
     });
 }
Beispiel #3
0
 private void Border_PointerWheelChanged(object sender, PointerWheelEventArgs e)
 {
     if (_element != null)
     {
         Point point = e.GetPosition(_element);
         point = FixInvalidPointPosition(point);
         ZoomDeltaTo(e.Delta.Y, point);
     }
 }
        protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
        {
            var pointer = e.GetPosition(this);

            var controlPressed = e.InputModifiers.HasFlag(InputModifiers.Control);

            if (controlPressed)
            {
                double scale = 0.9 * (e.Delta.Y / 120);

                var newFontSize = FontSize;
                if (scale < 0)
                {
                    newFontSize *= Math.Abs(scale);
                }
                else
                {
                    newFontSize /= scale;
                }

                if (newFontSize < 2)
                {
                    newFontSize = 2;
                }
                if (newFontSize > 20)
                {
                    newFontSize = 20;
                }

                if (newFontSize != FontSize)
                {
                    FontSize = newFontSize;

                    InvalidateVisual();
                }
            }
            else
            {
                int oldViewTop = ViewTop;

                ViewTop -= (int)(e.Delta.Y / 40);

                if (ViewTop < 0)
                {
                    ViewTop = 0;
                }
                else if (ViewTop > Terminal.ViewPort.TopRow)
                {
                    ViewTop = Terminal.ViewPort.TopRow;
                }

                if (oldViewTop != ViewTop)
                {
                    InvalidateVisual();
                }
            }
        }
Beispiel #5
0
    private void Wheel(PointerWheelEventArgs e)
    {
        if (_element == null || _captured)
        {
            return;
        }
        var point = e.GetPosition(_element);

        ZoomDeltaTo(e.Delta.Y, point.X, point.Y);
    }
Beispiel #6
0
        private void MouseScrollCanvas(object sender, PointerWheelEventArgs args)
        {
            var pos    = args.GetPosition(this);
            var matrix = mt.Matrix;

            double scale = 1 + args.Delta.Y / 10;

            mt.Matrix = ZoomToLocation(matrix, new Point(pos.X - graphCanvas.Bounds.Width / 2, pos.Y - graphCanvas.Bounds.Height / 2), scale);

            if (fsmData != null)
            {
                fsmData.matrix = mt.Matrix;
            }
        }
Beispiel #7
0
 private void PanAndZoomBorder_PointerWheelChanged(object sender, PointerWheelEventArgs e)
 {
     if (_initialize == false && _child != null)
     {
         var    st   = GetScaleTransform(_child);
         var    tt   = GetTranslateTransform(_child);
         double zoom = e.Delta.Y > 0 ? .2 : -.2;
         if (!(e.Delta.Y > 0) && (st.ScaleX < .4 || st.ScaleY < .4))
         {
             return;
         }
         Point  relative   = e.GetPosition(_child);
         double abosuluteX = relative.X * st.ScaleX + tt.X;
         double abosuluteY = relative.Y * st.ScaleY + tt.Y;
         st.ScaleX += zoom;
         st.ScaleY += zoom;
         tt.X       = abosuluteX - relative.X * st.ScaleX;
         tt.Y       = abosuluteY - relative.Y * st.ScaleY;
     }
 }