コード例 #1
0
 private void PanStartCommand_Execute(MouseButtonEventArgs e)
 {
     if (!IsPlotArea((DependencyObject)e.OriginalSource, out EdgePanel edgePanel))
     {
         return;
     }
     if (e.ChangedButton == MouseButton.Left && e.ButtonState == MouseButtonState.Pressed)
     {
         panStartPoint = e.GetPosition(edgePanel);
         if (YMaximum == null)
         {
             YMaximum = ActualYMaximum;
         }
         panStartX      = XMinimum.ToBinary();
         panStartY      = YMinimum.Value;
         panStartHeight = YMaximum.Value - YMinimum.Value;
         panStartWidth  = XMaximum.ToBinary() - XMinimum.ToBinary();
         isPanning      = true;
     }
 }
コード例 #2
0
        private void ZoomCommand_Execute(MouseWheelEventArgs e)
        {
            if (!IsPlotArea((DependencyObject)e.OriginalSource, out EdgePanel edgePanel))
            {
                return;
            }
            if (YMaximum == null)
            {
                YMaximum = ActualYMaximum;
            }
            var  pos     = e.GetPosition(edgePanel);
            var  ratio   = new Point(pos.X / edgePanel.ActualWidth, 1 - pos.Y / edgePanel.ActualHeight);
            int  h       = YMaximum.Value - YMinimum.Value;
            long w       = XMaximum.ToBinary() - XMinimum.ToBinary();
            int  centerY = YMinimum.Value + (int)(h * ratio.Y);
            long centerX = XMinimum.ToBinary() + (long)(w * ratio.X);

            if (Math.Sign(e.Delta) > 0)
            {
                XMinimum = ClipDate(DateTime.FromBinary(centerX - w / 4));
                XMaximum = ClipDate(DateTime.FromBinary(centerX + w / 4));
                YMinimum = ClipScore(centerY - h / 4);
                YMaximum = ClipScore(centerY + h / 4);
            }
            else
            {
                if (w == 0)
                {
                    w = 1;
                }
                XMinimum = ClipDate(DateTime.FromBinary(centerX - w));
                XMaximum = ClipDate(DateTime.FromBinary(centerX + w));
                if (h == 0)
                {
                    h = 1;
                }
                YMinimum = ClipScore(centerY - h);
                YMaximum = ClipScore(centerY + h);
            }
        }