Exemplo n.º 1
0
        private double DistanceBetweenWpfPoints(System.Windows.Point a, System.Windows.Point b)
        {
            var dx = a.X - b.X;
            var dy = a.Y - b.Y;

            return(Math.Sqrt(dx * dx + dy * dy));
        }
Exemplo n.º 2
0
        void PanDrawingNodeToMousePosition(Node drawingNode, System.Windows.Point mousePosition)
        {
            PlaneTransformation transform = graphViewer.Transform;
            var nodeCenterOnScreen        = transform * drawingNode.GeometryNode.Center;

            transform[0, 2]      += mousePosition.X - nodeCenterOnScreen.X;
            transform[1, 2]      += mousePosition.Y - nodeCenterOnScreen.Y;
            graphViewer.Transform = transform;
        }
Exemplo n.º 3
0
        void PanToNode()
        {
            System.Windows.Point mousePosition = Mouse.GetPosition(MainWindow);
            Node drawingNode = FindNodeByUsingDialog();

            if (drawingNode != null)
            {
                PanDrawingNodeToMousePosition(drawingNode, mousePosition);
            }
        }
        public void MouseMove(MsaglMouseEventArgs e) {
            if (currentPath == null) return;
            var point = scroller.GetWpfPosition(e);

            if (DistanceBetweenWpfPoints(point, pathEnd) < 3 * currentPath.StrokeThickness) return;

            pathEnd = point;

            pathSegmentCollection.Add(new LineSegment(point, true));
            var pathFigure = new PathFigure(pathStart, pathSegmentCollection, true);
            var pathFigureCollection = new PathFigureCollection { pathFigure };
            var pathGeometry = new PathGeometry(pathFigureCollection);
            currentPath.Data = pathGeometry;
        }
Exemplo n.º 5
0
        void StartNewPath(System.Windows.Point point)
        {
            var color = new System.Windows.Media.Color();

            color.A = 255;
            color.R = 255;

            currentPath = new Path
            {
                Stroke             = new SolidColorBrush(color),
                StrokeEndLineCap   = PenLineCap.Round,
                StrokeStartLineCap = PenLineCap.Round,
                StrokeLineJoin     = PenLineJoin.Round,
                StrokeThickness    = scroller.GetScale()
            };
            pathSegmentCollection = new PathSegmentCollection();
            pathEnd = pathStart = point;
            diagram.Canvas.Children.Add(currentPath);
        }
        void GraphCanvasMouseLeftButtonDown(object sender, MouseEventArgs e)
        {
            if (MouseDown != null)
            {
                MouseDown(this, CreateMouseEventArgs(e));
            }

            if (e.Handled)
            {
                return;
            }

            if (!LayoutEditingEnabled || selectedObject == null)
            {
                panning = true;
                mouseDownPointInSource = Mouse.GetPosition(graphCanvas);
                graphCanvas.CaptureMouse();
            }
        }
Exemplo n.º 7
0
        public void MouseMove(MsaglMouseEventArgs e)
        {
            if (currentPath == null)
            {
                return;
            }
            var point = scroller.GetWpfPosition(e);

            if (DistanceBetweenWpfPoints(point, pathEnd) < 3 * currentPath.StrokeThickness)
            {
                return;
            }

            pathEnd = point;

            pathSegmentCollection.Add(new LineSegment(point, true));
            var pathFigure           = new PathFigure(pathStart, pathSegmentCollection, true);
            var pathFigureCollection = new PathFigureCollection {
                pathFigure
            };
            var pathGeometry = new PathGeometry(pathFigureCollection);

            currentPath.Data = pathGeometry;
        }
 internal static void PositionFrameworkElement(FrameworkElement frameworkElement, System.Windows.Point center, double scale)
 {
     PositionFrameworkElement(frameworkElement, center.X, center.Y, scale);
 }
 internal static Point MsaglPoint(System.Windows.Point p)
 {
     return(new Point(p.X, p.Y));
 }
Exemplo n.º 10
0
        void GraphCanvasMouseLeftButtonDown(object sender, MouseEventArgs e)
        {
            if (MouseDown != null)
                MouseDown(this, CreateMouseEventArgs(e));

            if (e.Handled) return;

            if (!LayoutEditingEnabled || selectedObject == null) {
                panning = true;
                mouseDownPointInSource = Mouse.GetPosition(graphCanvas);
                graphCanvas.CaptureMouse();
            }
        }
        void StartNewPath(System.Windows.Point point) {
            var color=new System.Windows.Media.Color();
            color.A=255;
            color.R=255;

            currentPath = new Path
            {
                Stroke = new SolidColorBrush(color),
                StrokeEndLineCap = PenLineCap.Round,
                StrokeStartLineCap = PenLineCap.Round,
                StrokeLineJoin = PenLineJoin.Round,
                StrokeThickness = scroller.GetScale()
            };
            pathSegmentCollection = new PathSegmentCollection();
            pathEnd = pathStart = point;
            diagram.Canvas.Children.Add(currentPath);
        }
Exemplo n.º 12
0
 static Point P2(System.Windows.Point p)
 {
     return(new Point(p.X, p.Y));
 }