Exemplo n.º 1
0
        void dragBehavior_Dragging(object sender, System.Windows.Input.MouseEventArgs e)
        {
            //Vector diff = e.GetPosition(DisplayArea) - mouseStartPosition;

            MovableLine        line      = e.Source as MovableLine;
            TranslateTransform frotTrans = line.FrontConnector.RenderTransform as TranslateTransform;
            TranslateTransform tailTrans = line.TailConnector.RenderTransform as TranslateTransform;

            //if (frotTrans != null)
            //{
            //    frotTrans.X = diff.X;
            //    frotTrans.Y = diff.Y;
            //}

            //if (tailTrans != null)
            //{
            //    tailTrans.X = diff.X;
            //    tailTrans.Y = diff.Y;
            //}
        }
Exemplo n.º 2
0
        private void displayArea_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (_animationLine == null)
            {
                return;
            }

            MovableLine lineTobeAdded = new MovableLine(DisplayArea)
            {
                Stroke = new SolidColorBrush {
                    Color = Colors.Black
                }, StrokeThickness = 1.5
            };

            lineTobeAdded.X1 = _animationLine.X1;
            lineTobeAdded.Y1 = _animationLine.Y1;

            lineTobeAdded.X2 = _animationLine.X2;
            lineTobeAdded.Y2 = _animationLine.Y2;

            DisplayArea.Children.Add(lineTobeAdded);
            DisplayArea.Children.Remove(_animationLine);
            _animationLine = null;

            lineTobeAdded.VisibleConnectors = true;

            Canvas.SetLeft(lineTobeAdded.FrontConnector, lineTobeAdded.X1);
            Canvas.SetTop(lineTobeAdded.FrontConnector, lineTobeAdded.Y1);

            Canvas.SetLeft(lineTobeAdded.TailConnector, lineTobeAdded.X2);
            Canvas.SetTop(lineTobeAdded.TailConnector, lineTobeAdded.Y2);

            DisplayArea.Children.Add(lineTobeAdded.FrontConnector);
            DisplayArea.Children.Add(lineTobeAdded.TailConnector);

            lineTobeAdded.addToDragList(); //Dragging
        }
Exemplo n.º 3
0
 private void addLineToDragList(MovableLine line)
 {
 }
Exemplo n.º 4
0
        private void displayArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // Retrieve the coordinate of the mouse position.
            mouseStartPosition = e.GetPosition(DisplayArea);
            Point         pt     = e.GetPosition((UIElement)sender);
            HitTestResult result = VisualTreeHelper.HitTest(DisplayArea, pt);

            if (result.VisualHit is Shape)
            {
                _label.Text = getLabelText(pt);
                return;
            }

            // Perform the hit test against a given portion of the visual object tree.
            if (!(result.VisualHit is Canvas))
            {
                return;
            }

            if (_selectedNode == QuadTreeNode.None)
            {
                return;
            }

            if (_selectedNode == QuadTreeNode.Arrow)
            {
                Point P1 = e.GetPosition(DisplayArea);
                _animationLine = new MovableLine(DisplayArea)
                {
                    Stroke = new SolidColorBrush {
                        Color = Colors.Black
                    }, StrokeThickness = 1.5
                };
                _animationLine.X1 = P1.X;
                _animationLine.Y1 = P1.Y;
                DisplayArea.Children.Add(_animationLine);

                return;
            }

            Shape renderShape = new Ellipse()
            {
                Width = NODE_DIMENSION, Height = NODE_DIMENSION
            };
            double pointX = e.GetPosition(DisplayArea).X - NODE_DIMENSION / 2;
            double pointY = e.GetPosition(DisplayArea).Y - NODE_DIMENSION / 2;

            LinearGradientBrush brush = new LinearGradientBrush();

            brush.StartPoint = new Point(0, 1);
            brush.EndPoint   = new Point(1, 1);

            if (_selectedNode == QuadTreeNode.Black || _selectedNode == QuadTreeNode.White)
            {
                Color color = Colors.White;
                if (_selectedNode == QuadTreeNode.Black)
                {
                    color = Colors.Black;
                }

                brush.GradientStops.Add(new GradientStop(color, 1.0));
            }
            else if (_selectedNode == QuadTreeNode.Gray)
            {
                brush.GradientStops.Add(new GradientStop(Colors.White, 0.5));
                brush.GradientStops.Add(new GradientStop(Colors.Black, 0.5));

                Ellipse ellipse = renderShape as Ellipse;
            }
            renderShape.Fill = brush;


            Canvas.SetLeft(renderShape, pointX);
            Canvas.SetTop(renderShape, pointY);
            DisplayArea.Children.Add(renderShape);

            addToDragList(renderShape, new Point(pointX, pointY));

            //string strPosition = "X = " + pointX + " ,Y = " + pointY;
            //MessageBox.Show(strPosition);
        }