Example #1
0
        public override void OnModifierKeyDown(ModifierKeyArgs e)
        {
            base.OnModifierKeyDown(e);

            double factor = 0;

            if ((e.Key == Key.Add || e.Key == Key.OemPlus) && Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
            {
                // On CTRL+, Zoom In
                factor = -ZoomFraction;
            }
            if ((e.Key == Key.Subtract || e.Key == Key.OemMinus) && Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
            {
                // On CTRL-, Zoom Out
                factor = ZoomFraction;
            }

            using (ParentSurface.SuspendUpdates())
            {
                // Zoom the XAxis by the required factor
                XAxis.ZoomBy(factor, factor, TimeSpan.FromMilliseconds(500));

                // Zoom the YAxis by the required factor
                YAxis.ZoomBy(factor, factor, TimeSpan.FromMilliseconds(500));

                // Note.. can be extended for multiple YAxis XAxis, just iterate over all axes on the parent surface
            }
        }
Example #2
0
        public override void OnModifierMouseWheel(ModifierMouseArgs e)
        {
            e.Handled = true;
            var usey   = Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl);
            var usex   = true;
            var factor = 1 - e.Delta * 0.001;

            using (ParentSurface.SuspendUpdates())
            {
                var p = TransformMousePoint(GetPointRelativeTo(e.MousePoint, ParentSurface.RenderSurface));
                if (usex)
                {
                    var vr        = ParentSurface.XAxis.VisibleRange.AsDoubleRange();
                    var leftPart  = p.X - vr.Min;
                    var rightPart = vr.Max - p.X;
                    leftPart  *= factor;
                    rightPart *= factor;
                    ParentSurface.XAxis.VisibleRange = new DoubleRange(p.X - leftPart, p.X + rightPart);
                }
                if (usey)
                {
                    var vr         = ParentSurface.YAxis.VisibleRange.AsDoubleRange();
                    var bottomPart = p.Y - vr.Min;
                    var topPart    = vr.Max - p.Y;
                    bottomPart *= factor;
                    topPart    *= factor;
                    ParentSurface.YAxis.VisibleRange = new DoubleRange(p.Y - bottomPart, p.Y + topPart);
                }
            }
        }
        public void SetTo(NodeControl nodeControl)
        {
            if (nodeControl != null)
            {
                foreach (var arrowCreationSet in ArrowCreationSets)
                {
                    if (arrowCreationSet.NodeControl != null && arrowCreationSet.NodeControl != nodeControl)
                    {
                        if (!ParentSurface.IsArrowExist(arrowCreationSet.NodeControl, nodeControl))
                        {
                            if (nodeControl.CollapseControl.State == CollapseState.None)
                            {
                                nodeControl.CollapseControl.State = CollapseState.Expanded;
                            }
                            else if (nodeControl.CollapseControl.State == CollapseState.Collapsed)
                            {
                                nodeControl.CollapseControl.State = CollapseState.SemiCollapsed;
                            }

                            if (arrowCreationSet.NodeControl.ViewModelNode.IsTranscluded || nodeControl.ViewModelNode.IsTranscluded)
                            {
                                IoC.GetInstance <ISuperGraphRelationshipFactory>().ConnectTranscludedNodes(arrowCreationSet.NodeControl.ViewModelNode, nodeControl.ViewModelNode);
                            }
                            else
                            {
                                IoC.GetInstance <ISuperGraphRelationshipFactory>().ConnectNodes(arrowCreationSet.NodeControl.ViewModelNode, nodeControl.ViewModelNode);
                            }
                        }
                    }
                }
            }
            Reset();
        }
        public override void OnModifierMouseMove(ModifierMouseArgs e)
        {
            base.OnModifierMouseMove(e);
            if (_lastPoint == null)
            {
                return;
            }

            var currentPoint = e.MousePoint;
            var xDelta       = currentPoint.X - _lastPoint.Value.X;
            var yDelta       = _lastPoint.Value.Y - currentPoint.Y;

            using (ParentSurface.SuspendUpdates())
            {
                // Scroll the XAxis by the number of pixels since the last update
                XAxis.Scroll(XAxis.IsHorizontalAxis ? xDelta : -yDelta, ClipMode.None);

                // Scroll the YAxis by the number of pixels since the last update
                YAxis.Scroll(YAxis.IsHorizontalAxis ? -xDelta : yDelta, ClipMode.None);

                // Note.. can be extended for multiple YAxis XAxis, just iterate over all axes on the parent surface
            }

            _lastPoint = currentPoint;
        }
Example #5
0
 public void FlipAxes(AxisCollection axes)
 {
     using (ParentSurface.SuspendUpdates())
     {
         foreach (var axis in axes)
         {
             axis.FlipCoordinates = !axis.FlipCoordinates;
         }
     }
 }
 private void Reset()
 {
     foreach (var arrowCreationSet in ArrowCreationSets)
     {
         ParentSurface.Remove(arrowCreationSet.ArrowControl);
     }
     ArrowCreationSets.Clear();
     InMotion = false;
     _added.Clear();
 }
Example #7
0
        public override void OnModifierDoubleClick(ModifierMouseArgs e)
        {
            if (!e.MouseButtons.HasFlag(MouseButtons.Left))
            {
                return;
            }

            ParentSurface.ZoomExtents();
            e.Handled = true;
        }
        private void ParentSurface_MouseMove(object sender, MouseEventArgs e)
        {
            if (InMotion)
            {
                foreach (var arrowCreationSet in ArrowCreationSets)
                {
                    var location = e.GetPosition((UIElement)ParentSurface);
                    location.Y = location.Y / ParentSurface.Zoom;
                    location.X = location.X / ParentSurface.Zoom;

                    if (!arrowCreationSet.IsAdded)
                    {
                        ParentSurface.Add(arrowCreationSet.ArrowControl);
                        arrowCreationSet.IsAdded = true;
                    }
                    Canvas.SetZIndex(arrowCreationSet.ArrowControl, 1000);
                    arrowCreationSet.To.Centre = location;
                }
            }
        }
        public override void OnModifierMouseWheel(ModifierMouseArgs e)
        {
            foreach (var axis in YAxes)
            {
                // Find the axis under the mouse now
                var axisBounds = axis.GetBoundsRelativeTo(RootGrid);
                if (axis.IsHorizontalAxis && axisBounds.Height < MinTouchArea)
                {
                    axisBounds.Y     -= (MinTouchArea - axisBounds.Height) / 2;
                    axisBounds.Height = MinTouchArea;
                }
                if (!axis.IsHorizontalAxis && axisBounds.Width < MinTouchArea)
                {
                    axisBounds.X    -= (MinTouchArea - axisBounds.Width) / 2;
                    axisBounds.Width = MinTouchArea;
                }

                // Look only for the first axis that has been hit
                if (axisBounds.Contains(e.MousePoint))
                {
                    e.Handled = true;

                    const double mouseWheelDeltaCoef = 120;

                    using (ParentSurface.SuspendUpdates())
                    {
                        double value = -e.Delta / mouseWheelDeltaCoef;

                        var mousePoint = GetPointRelativeTo(e.MousePoint, ModifierSurface);

                        // Do the zoom on the axis
                        const double GrowFactor = 0.1;
                        double       fraction   = GrowFactor * value;
                        GrowBy(mousePoint, axis, fraction);
                    }
                }
            }
        }
        /// <summary>
        /// Called when a Mouse Button is released on the parent <see cref="SciChartSurface" />
        /// </summary>
        /// <param name="e">Arguments detailing the mouse button operation</param>
        public override void OnModifierMouseUp(ModifierMouseArgs e)
        {
            if (!_isDragging)
            {
                return;
            }

            base.OnModifierMouseUp(e);

            // Translate the mouse point (which is in RootGrid coordiantes) relative to the ModifierSurface
            // This accounts for any offset due to left Y-Axis
            var ptTrans = GetPointRelativeTo(e.MousePoint, ModifierSurface);

            _endPoint = SetReticulePosition(_rectangle, _startPoint, ptTrans, e.IsMaster);

            double distanceDragged = PointUtil.Distance(_startPoint, ptTrans);

            if (distanceDragged > 10.0)
            {
                PerformSelection(_startPoint, _endPoint);
                e.Handled = true;
            }
            else
            {
                SelectedPoints = null;
                ParentSurface.InvalidateElement();
            }

            ClearReticule();
            _isDragging = false;

            if (e.IsMaster)
            {
                ModifierSurface.ReleaseMouseCapture();
            }
        }
 public void DecrementSuspend()
 {
     ParentSurface.DecrementSuspend();
 }
 public void ResumeUpdates(IUpdateSuspender suspender)
 {
     ParentSurface.ResumeUpdates(suspender);
 }
 public IUpdateSuspender SuspendUpdates()
 {
     return(ParentSurface.SuspendUpdates());
 }
        public override void OnModifierDoubleClick(ModifierMouseArgs e)
        {
            base.OnModifierDoubleClick(e);

            ParentSurface.ZoomExtentsToVisibleRangeLimit();
        }
Example #15
0
        private void NodeControl_KeyUp(object sender, KeyEventArgs e)
        {
            e.Handled = true;
            if (App.UserStyle == UserStyle.Reader)
            {
                return;
            }
            switch (e.Key)
            {
            case Key.Delete:
                ParentSurface.Selector.DeleteNodes(this);
                ParentSurface.Focus();
                break;

            case Key.C:
                if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                {
                    if (ParentSurface.Selector.IsMultiSelect)
                    {
                        ParentSurface.Selector.Copy();
                    }
                    else
                    {
                        Copy();
                    }
                }
                else if (!ParentSurface.Selector.IsMultiSelect && (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    var location = Centre;
                    location.X += 200;
                    IoC.GetInstance <ISuperGraphNodeFactory>().AddLinkedNode("CompendiumConNode", location, ViewModelNode);
                }
                break;

            case Key.X:
                if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                {
                    if (ParentSurface.Selector.IsMultiSelect)
                    {
                        ParentSurface.Selector.Cut();
                    }
                    else
                    {
                        CutNode();
                    }
                }
                break;

            case Key.P:
                if (!ParentSurface.Selector.IsMultiSelect && (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    var location = Centre;
                    location.X += GlymaParameters.NodeTextWidth + GlymaParameters.Margin * 2;
                    IoC.GetInstance <ISuperGraphNodeFactory>().AddLinkedNode("CompendiumProNode", location, ViewModelNode);
                }
                break;

            case Key.M:
                if (!ParentSurface.Selector.IsMultiSelect && (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    var location = Centre;
                    location.X += GlymaParameters.NodeTextWidth + GlymaParameters.Margin * 2;
                    IoC.GetInstance <ISuperGraphNodeFactory>().AddLinkedNode("CompendiumMapNode", location, ViewModelNode);
                }
                break;

            case Key.I:
                if (!ParentSurface.Selector.IsMultiSelect && (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    var location = Centre;
                    location.X += GlymaParameters.NodeTextWidth + GlymaParameters.Margin * 2;
                    IoC.GetInstance <ISuperGraphNodeFactory>().AddLinkedNode("CompendiumIdeaNode", location, ViewModelNode);
                }
                break;

            case Key.Q:
                if (!ParentSurface.Selector.IsMultiSelect && (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    var location = Centre;
                    location.X += GlymaParameters.NodeTextWidth + GlymaParameters.Margin * 2;
                    IoC.GetInstance <ISuperGraphNodeFactory>().AddLinkedNode("CompendiumQuestionNode", location, ViewModelNode);
                }
                break;

            case Key.N:
                if (!ParentSurface.Selector.IsMultiSelect && (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    var location = Centre;
                    location.X += GlymaParameters.NodeTextWidth + GlymaParameters.Margin * 2;
                    IoC.GetInstance <ISuperGraphNodeFactory>().AddLinkedNode("CompendiumNoteNode", location, ViewModelNode);
                }
                break;

            case Key.D:
                if (!ParentSurface.Selector.IsMultiSelect && (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    var location = Centre;
                    location.X += GlymaParameters.NodeTextWidth + GlymaParameters.Margin * 2;
                    IoC.GetInstance <ISuperGraphNodeFactory>().AddLinkedNode("CompendiumDecisionNode", location, ViewModelNode);
                }
                break;
            }
        }