예제 #1
0
 public PanData(PanState state, Vector2 delta, Vector2 value, Vector2 absolute, Transform target)
     : this()
 {
     this.state    = state;
     this.delta    = delta;
     this.value    = value;
     this.absolute = absolute;
     this.target   = target;
 }
 private void StartPanningIfNecessary(MouseButtonEventArgs e)
 {
     if (DesignerView.IsMouseInViewport(e, this.scrollViewer))
     {
         this.draggingMouseButton = e.ChangedButton;
         this.CurrentPanState     = PanState.Panning;
         this.scrollViewer.Focus();
         this.panningStartPosition = Mouse.GetPosition(this.scrollViewer);
         Mouse.Capture(this.scrollViewer);
         e.Handled = true;
     }
 }
 private void StopPanning()
 {
     // stop panning
     if (this.InPanMode ||
         (Keyboard.IsKeyDown(Key.Space) && this.CurrentPanState == PanState.Panning))
     {
         this.CurrentPanState = PanState.ReadyToPan;
     }
     else
     {
         this.CurrentPanState = PanState.Normal;
     }
 }
        internal void OnScrollViewerKeyUp(object sender, KeyEventArgs e)
        {
            switch (this.CurrentPanState)
            {
            case PanState.ReadyToPan:
                if (e.Key == Key.Space && !this.InPanMode)
                {
                    this.CurrentPanState = PanState.Normal;
                }

                break;

            default:
                break;
            }
        }
        internal void OnScrollViewerKeyDown(object sender, KeyEventArgs e)
        {
            switch (this.CurrentPanState)
            {
            // Don't change to ReadyToPan mode if the space is a
            // repeated input, because repeated-key input may come
            // from activity element on the scroll view.
            case PanState.Normal:
                if (e.Key == Key.Space &&
                    !e.IsRepeat &&
                    this.AllowSwitchToPanning())
                {
                    this.CurrentPanState = PanState.ReadyToPan;
                }

                break;

            default:
                break;
            }
        }
 private void StopPanning()
 {
     // stop panning
     if (this.InPanMode
         || (Keyboard.IsKeyDown(Key.Space) && this.CurrentPanState == PanState.Panning))
     {
         this.CurrentPanState = PanState.ReadyToPan;
     }
     else
     {
         this.CurrentPanState = PanState.Normal;
     }
 }
 private void StartPanningIfNecessary(MouseButtonEventArgs e)
 {
     if (DesignerView.IsMouseInViewport(e, this.scrollViewer))
     {
         this.draggingMouseButton = e.ChangedButton;
         this.CurrentPanState = PanState.Panning;
         this.scrollViewer.Focus();
         this.panningStartPosition = Mouse.GetPosition(this.scrollViewer);
         Mouse.Capture(this.scrollViewer);
         e.Handled = true;
     }
 }
        internal void OnScrollViewerKeyUp(object sender, KeyEventArgs e)
        {
            switch (this.CurrentPanState)
            {
                case PanState.ReadyToPan:
                    if (e.Key == Key.Space && !this.InPanMode)
                    {
                        this.CurrentPanState = PanState.Normal;
                    }

                    break;
                default:
                    break;
            }
        }
        internal void OnScrollViewerKeyDown(object sender, KeyEventArgs e)
        {
            switch (this.CurrentPanState)
            {
                // Don't change to ReadyToPan mode if the space is a 
                // repeated input, because repeated-key input may come 
                // from activity element on the scroll view.
                case PanState.Normal:
                    if (e.Key == Key.Space 
                        && !e.IsRepeat
                        && this.AllowSwitchToPanning()) 
                    {
                        this.CurrentPanState = PanState.ReadyToPan;
                    }

                    break;
                default:
                    break;
            }
        }
예제 #10
0
 protected override void OnMouseMove(MouseEventArgs args)
 {
     base.OnMouseMove(args);
     if(panState != PanState.None) {
         if(panState == PanState.Pending) {
             panState = PanState.Active;
             Cursor = Cursors.SizeAll;
         }
         Vector mousePosition = (Vector)args.Location;
         Vector delta = lastMousePosition - mousePosition;
         camera.Pan(delta.X, delta.Y);
         Refresh();
     }
     lastMousePosition = (Vector)args.Location;
 }
예제 #11
0
 protected override void OnMouseDown(MouseEventArgs args)
 {
     base.OnMouseDown(args);
     if(args.Button == MouseButtons.Middle)
         panState = PanState.Pending;
 }
예제 #12
0
 protected override void OnMouseUp(MouseEventArgs args)
 {
     base.OnMouseUp(args);
     if(args.Button == MouseButtons.Middle) {
         if(panState == PanState.Pending) {
             // The user pressed and released the middle mouse button without dragging;
             // reset the zoom.
             camera.Scale = 1;
         }
         panState = PanState.None;
         Cursor = Cursors.Default;
     }
 }