Exemplo n.º 1
0
 private void Workbench_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Left)
     {
         leftPressed = true;
         Workbench workbench = (Workbench)sender;
         startingPointMM = workbench.GetPointMMAtOffset(e.GetPosition((Workbench)sender));
     }
 }
Exemplo n.º 2
0
 private void Workbench_MouseMove(object sender, MouseEventArgs e)
 {
     if (leftPressed)
     {
         Workbench workbench = (Workbench)sender;
         Point     offset    = e.GetPosition(workbench);
         Point     newOffset = workbench.GetOffsetAtPointMM(startingPointMM);
         workbench.Pan(new Vector(newOffset.X - offset.X, newOffset.Y - offset.Y));
     }
 }
Exemplo n.º 3
0
        public WorkbenchInput(Workbench workbench)
        {
            workbench.MouseLeave += Workbench_MouseLeave;

            workbench.MouseDown += Workbench_MouseDown;
            workbench.MouseUp   += Workbench_MouseUp;

            workbench.MouseMove += Workbench_MouseMove;

            workbench.MouseWheel += Workbench_MouseWheel;
        }
Exemplo n.º 4
0
        private static void DocumentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Workbench _this = (Workbench)d;

            if (e.OldValue != null)
            {
                ((Document)e.OldValue).Modified -= _this.Document_Modified;
            }
            if (e.NewValue != null)
            {
                ((Document)e.NewValue).Modified += _this.Document_Modified;
            }
            _this.graphicsStale = true;
        }
Exemplo n.º 5
0
        private void Workbench_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            Workbench workbench = (Workbench)sender;

            Point  offset     = e.GetPosition(workbench);
            Point  originalMM = workbench.GetPointMMAtOffset(offset);
            double newZoom    = workbench.ViewZoom * Math.Pow(2.0, e.Delta / 480.0);

            if (newZoom < Workbench.ZoomMin)
            {
                newZoom = Workbench.ZoomMin;
            }
            if (newZoom > Workbench.ZoomMax)
            {
                newZoom = Workbench.ZoomMax;
            }
            workbench.ViewZoom = newZoom;
            Point newOffset = workbench.GetOffsetAtPointMM(originalMM);

            workbench.Pan(newOffset - offset);
        }