Beispiel #1
0
 private void ButtonZoomMinus_Click(object sender, RoutedEventArgs e)
 {
     if (_graphicMap != null)
     {
         ZoomEvent?.Invoke(_zoomStepper.NextScale(_graphicMap.Scale));
     }
 }
Beispiel #2
0
        /// <summary>
        /// Handler for the "Undo All Zoom/Pan" context menu item.  Restores the scale ranges to the values
        /// before all zoom and pan operations
        /// </summary>
        /// <remarks>
        /// This method differs from the <see cref="RestoreScale" /> method in that it sets the scales
        /// to their initial setting prior to any user actions.  The <see cref="RestoreScale" /> method
        /// sets the scales to full auto mode (regardless of what the initial setting may have been).
        /// </remarks>
        /// <param name="primaryPane">The <see cref="GraphPane" /> object which is to be zoomed out</param>
        public void ZoomOutAll(GraphPane primaryPane)
        {
            if (primaryPane == null || primaryPane.ZoomStack.IsEmpty)
            {
                return;
            }

            var type = primaryPane.ZoomStack.Top.Type;

            var oldState = new ZoomState(primaryPane, type);
            //ZoomState newState = pane.ZoomStack.PopAll( pane );
            ZoomState newState = null;

            if (_isSynchronizeXAxes || _isSynchronizeYAxes)
            {
                foreach (var pane in _masterPane.PaneList.Where(p => p is GraphPane).Cast <GraphPane>())
                {
                    ZoomState state = pane.ZoomStack.PopAll(pane);
                    if (pane == primaryPane)
                    {
                        newState = state;
                    }
                }
            }
            else
            {
                newState = primaryPane.ZoomStack.PopAll(primaryPane);
            }

            // Provide Callback to notify the user of zoom events
            ZoomEvent?.Invoke(this, oldState, newState);

            Refresh();
        }
        ///------------------------------------------------------------------------
        /// <summary>
        /// Zooms the curve.
        /// </summary>
        /// <param name="graphPane">The graph pane.</param>
        /// <param name="lineItem">The line item.</param>
        /// <returns></returns>
        ///------------------------------------------------------------------------
        public bool ZoomCurve(GraphPane graphPane, CurveItem lineItem,
                              double filterMinX = double.MinValue, double filterMaxX = double.MaxValue)
        {
            if (lineItem.Points.Count == 0)
            {
                return(false);
            }
            if (!ZoomCurveOnLegendClick)
            {
                Invalidate();
                return(false);
            }

            // Add the zoom to the zoom stack
            var oldState = new ZoomState(graphPane, ZoomState.StateType.Zoom);

            graphPane.ZoomStack.Push(graphPane, ZoomState.StateType.Zoom);
            ZoomEvent?.Invoke(this, oldState, new ZoomState(graphPane, ZoomState.StateType.Zoom));

            if (!SetZoomScale(graphPane, lineItem, filterMinX, filterMaxX))
            {
                return(false);
            }

            // Update the pane
            graphPane.AxisChange();
            Invalidate();
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Handler for the "Set Scale to Default" context menu item.  Sets the scale ranging to
        /// full auto mode for all axes.
        /// </summary>
        /// <remarks>
        /// This method differs from the <see cref="ZoomOutAll" /> method in that it sets the scales
        /// to full auto mode.  The <see cref="ZoomOutAll" /> method sets the scales to their initial
        /// setting prior to any user actions (which may or may not be full auto mode).
        /// </remarks>
        /// <param name="primaryPane">The <see cref="GraphPane" /> object which is to have the
        /// scale restored</param>
        public void RestoreScale(PaneBase primaryPane)
        {
            if (primaryPane == null || !(primaryPane is GraphPane))
            {
                return;
            }

            var pane = (GraphPane)primaryPane;

            //Go ahead and save the old zoomstates, which provides an "undo"-like capability
            //ZoomState oldState = primaryPane.ZoomStack.Push( primaryPane, ZoomState.StateType.Zoom );
            var oldState = new ZoomState(pane, ZoomState.StateType.Zoom);

            using (var g = CreateGraphics())
            {
                if (_isSynchronizeXAxes || _isSynchronizeYAxes)
                {
                    foreach (var paneBase in _masterPane.PaneList)
                    {
                        var p = (GraphPane)paneBase;
                        p.ZoomStack.Push(p, ZoomState.StateType.Zoom);
                        RestoreAutoScale(p, g);
                    }
                }
                else
                {
                    pane.ZoomStack.Push(pane, ZoomState.StateType.Zoom);
                    RestoreAutoScale(pane, g);
                }

                // Provide Callback to notify the user of zoom events
                ZoomEvent?.Invoke(this, oldState, new ZoomState(pane, ZoomState.StateType.Zoom));
            }
            Refresh();
        }
        private void ActiveUpdate()
        {
            var curpos = HandModel.GetIndexVector();
            var rp     = new Polar3(curpos - _anchor);                  // rp  = relative position
            var rrp    = rp - _lastRp;                                  // rrp = relative relative position

            _lastRp = rp;

            var factor = -150f;

            _zoomEvent.Invoke((float)rrp.R * factor);
        }
Beispiel #6
0
        public void Attach([NotNull] Canvas canvas)
        {
            canvas.MouseLeftButtonDown += (sender, args) => {
                if (!_leftMouseDown)
                {
                    _lastPoint     = args.GetPosition(canvas);
                    MouseDownStart = _lastPoint.X;
                    _leftMouseDown = true;
                }
            };
            canvas.MouseMove += (sender, args) => {
                var now = DateTime.Now.Millisecond;
                if (now - _lastTime <= 100)
                {
                    return;
                }
                var point = args.GetPosition(canvas);
                FollowTraceEvent?.Invoke(_lastPoint, point, _leftMouseDown);
                _lastPoint = point;
            };
            canvas.MouseLeftButtonUp += (sender, args) => {
                if (!_leftMouseDown)
                {
                    return;
                }
                var zoomEnd = args.GetPosition(canvas).X;
                if (zoomEnd < MouseDownStart)
                {
                    var t = zoomEnd;
                    zoomEnd        = MouseDownStart;
                    MouseDownStart = t;
                }

                ZoomEvent?.Invoke(MouseDownStart, zoomEnd, !(zoomEnd - MouseDownStart <= 12));

                _leftMouseDown = false;
            };
            canvas.MouseRightButtonDown += (sender, args) => { UndoEvent?.Invoke(); };
            canvas.MouseDown            += (sender, args) => {
                if (args.ChangedButton == MouseButton.Middle)
                {
                    AdjustYAxisEvent?.Invoke();
                }
            };
        }
Beispiel #7
0
        /// <summary>
        /// Increments the current zoom value.
        /// </summary>
        /// <param name="delta">The amount to adjust the zoom by.</param>
        /// <remarks>
        /// Triggers a <see cref="ZoomEvent"/>.
        /// </remarks>
        private void AdjustZoom(int delta)
        {
            const float SpeedModifier = 1250.0f;

            float oldVal, newVal;

            newVal = zoom + (delta / SpeedModifier);
            if (newVal < MinimumZoom)
            {
                newVal = MinimumZoom;
            }
            else if (newVal > MaximumZoom)
            {
                newVal = MaximumZoom;
            }

            oldVal = Zoom;
            Zoom   = newVal;
            ZoomEvent?.Invoke(this, new ZoomEventArgs(oldVal, newVal));
        }
Beispiel #8
0
 public void ZoomUpdate(float zoomAmount)
 {
     ZoomEvent?.Invoke(zoomAmount);
 }
 public void ZoomView(ZoomType zoomType)
 {
     ZoomEvent?.Invoke(this, new ZoomEventsArg(zoomType));
 }
Beispiel #10
0
 private void Zoom() => ZoomEvent?.Invoke(GetTouchPosition(0), GetTouchPosition(1));
Beispiel #11
0
 private void OnZoom()
 {
     //Debug.Log("OnZoom" + rawInpVec);
     ZoomEvent?.Invoke();
 }