Draws a straight line between two points with optional arrows on the ends.
Inheritance: ArrowLineBase
Beispiel #1
0
        public Canvas drawKey()
        {
            Canvas canvas = new Canvas();
            TextBlock upDownMovement = new TextBlock();
            upDownMovement.FontSize = 20;
            upDownMovement.Foreground = Brushes.WhiteSmoke;
            upDownMovement.Text = "Move up or down";
            TextBlock sideToSideMovement = new TextBlock();
            sideToSideMovement.FontSize = 20;
            sideToSideMovement.Foreground = Brushes.WhiteSmoke;
            sideToSideMovement.Text = "Move left or right";
            TextBlock forwardBackwardMovement = new TextBlock();
            forwardBackwardMovement.FontSize = 20;
            forwardBackwardMovement.Foreground = Brushes.WhiteSmoke;
            forwardBackwardMovement.Text = "Move front or back";

            Point p1 = new Point(windowWidth - 250, 10);
            Point p2 = new Point(windowWidth - 250, 30);
            ArrowLine downArrow = new ArrowLine() { X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y, Stroke = upDownColor, StrokeThickness = correctionArrowThickness };
            ArrowLine upArrow = new ArrowLine() { X1 = p2.X + 20, Y1 = p2.Y, X2 = p1.X + 20, Y2 = p1.Y, Stroke = upDownColor, StrokeThickness = correctionArrowThickness };
            Point p3 = new Point(windowWidth - 250, 50);
            Point p4 = new Point(windowWidth - 230, 50);
            ArrowLine rightArrow = new ArrowLine() { X1 = p3.X, Y1 = p3.Y, X2 = p4.X, Y2 = p4.Y, Stroke = sideSideColor, StrokeThickness = correctionArrowThickness };
            ArrowLine leftArrow = new ArrowLine() { X1 = p4.X + 30, Y1 = p4.Y, X2 = p3.X + 30, Y2 = p3.Y, Stroke = sideSideColor, StrokeThickness = correctionArrowThickness };
            Point p5 = new Point(windowWidth - 250, 80);
            Point p6 = new Point(windowWidth - 230, 100);
            ArrowLine frontArrow = new ArrowLine() { X1 = p5.X, Y1 = p5.Y, X2 = p6.X, Y2 = p6.Y, Stroke = frontBackColor, StrokeThickness = correctionArrowThickness };
            ArrowLine backArrow = new ArrowLine() { X1 = p6.X + 30, Y1 = p6.Y, X2 = p5.X + 30, Y2 = p5.Y, Stroke = frontBackColor, StrokeThickness = correctionArrowThickness };

            canvas.Children.Add(upDownMovement);
            canvas.Children.Add(sideToSideMovement);
            canvas.Children.Add(forwardBackwardMovement);
            canvas.Children.Add(downArrow);
            canvas.Children.Add(upArrow);
            canvas.Children.Add(rightArrow);
            canvas.Children.Add(leftArrow);
            canvas.Children.Add(frontArrow);
            canvas.Children.Add(backArrow);
            Canvas.SetTop(upDownMovement, 10);
            Canvas.SetLeft(upDownMovement, windowWidth - 190);
            Canvas.SetTop(sideToSideMovement, 40);
            Canvas.SetLeft(sideToSideMovement, windowWidth - 190);
            Canvas.SetTop(forwardBackwardMovement, 80);
            Canvas.SetLeft(forwardBackwardMovement, windowWidth - 190);

            return canvas;
        }
Beispiel #2
0
        void initLine(Color c)
        {
            line = new ArrowLine();
            line.Stroke = new SolidColorBrush(c);
            line.ArrowEnds = ArrowEnds.Start;
            line.ArrowLength = 30;
            line.ArrowAngle = 40;
            line.StrokeThickness = ShapeUtils.LINE_WIDTH;
            line.Effect = ShapeUtils.ShadowProvider();
            line.Tag = this;
           
            selMarker1 = ShapeUtils.MakeMarker();
            selMarker1.Tag = this;

            selMarker2 = ShapeUtils.MakeMarker();
            selMarker2.Tag = this;
        }
Beispiel #3
0
        void initLine(Color c)
        {
            line = new ArrowLine();            
            line.ArrowAngle = 40;            
            line.Stroke = new SolidColorBrush(c);
            line.StrokeThickness = ShapeUtils.LINE_WIDTH;
            line.Effect = ShapeUtils.ShadowProvider();
            line.Tag = this;

            selMarker1 = ShapeUtils.MakeLinkEnd();
            selMarker1.Tag = this;

            selMarker2 = ShapeUtils.MakeLinkEnd();
            selMarker2.Tag = this;

            line.MouseWheel += MouseWheel;
        }
        /// <summary>
        /// The arrow demo is uses an adaption of Chales Petzold's WPF arrow class 
        /// http://charlespetzold.com/blog/2007/04/191200.html to be used as custom MapSape
        /// </summary>
        /// <param name="layer"></param>
        public void AddArrows(ShapeLayer layer)
        {
            // ArrowLine with animated arrow properties.
            ArrowLine aline1 = new ArrowLine();
            aline1.Stroke = Brushes.Red;
            aline1.MapStrokeThickness = 30; // the adaptive stroke thickness
            aline1.ScaleFactor = .25; // the scale factor [0..1]. 0: Don't scale (thickness = pixels); 1: scale linear (thickness = mercator units)
            aline1.ArrowLength = 3; // the arrow length is relative to the arrow stroke thickness
            aline1.X1 = 8.100;
            aline1.Y1 = 49.400;
            aline1.X2 = 8.400;
            aline1.Y2 = 49.100;
            layer.Shapes.Add(aline1);

            DoubleAnimation animaDouble1 = new DoubleAnimation(10, 50, new Duration(new TimeSpan(0, 0, 5)));
            animaDouble1.AutoReverse = true;
            animaDouble1.RepeatBehavior = RepeatBehavior.Forever;
            aline1.BeginAnimation(ArrowLine.ArrowAngleProperty, animaDouble1);

            DoubleAnimation animaDouble2 = new DoubleAnimation(1, 20, new Duration(new TimeSpan(0, 0, 5)));
            animaDouble2.AutoReverse = true;
            animaDouble2.RepeatBehavior = RepeatBehavior.Forever;
            aline1.BeginAnimation(ArrowLine.ArrowLengthProperty, animaDouble2);

            // ArrowLine with animated point properties.
            ArrowLine aline2 = new ArrowLine();
            aline2.ArrowEnds = ArrowEnds.Both;

            aline2.Stroke = Brushes.Blue;
            aline2.MapStrokeThickness = 30;
            aline2.ScaleFactor = .25;
            aline1.ArrowLength = 3;
            aline2.X1 = 8.100;
            aline2.Y1 = 49.100;
            aline2.X2 = 8.200;
            aline2.Y2 = 49.400;
            layer.Shapes.Add(aline2);

            AnimationTimeline animaDouble3 = new DoubleAnimation(8.100, 8.400, new Duration(new TimeSpan(0, 0, 5)));
            animaDouble3.AutoReverse = true;
            animaDouble3.RepeatBehavior = RepeatBehavior.Forever;
            aline2.BeginAnimation(ArrowLine.X1Property, animaDouble3);

            AnimationTimeline animaDouble4 = new DoubleAnimation(49.400, 49.100, new Duration(new TimeSpan(0, 0, 5)));
            animaDouble4.AutoReverse = true;
            animaDouble4.RepeatBehavior = RepeatBehavior.Forever;
            aline2.BeginAnimation(ArrowLine.Y2Property, animaDouble4);

            // ArrowPolyline rotated.
            ArrowPolyline apoly = new ArrowPolyline();
            apoly.ArrowEnds = ArrowEnds.Both;
            apoly.Stroke = Brushes.Green;
            apoly.MapStrokeThickness = 30;
            apoly.ScaleFactor = .25;
            aline1.ArrowLength = 3;

            apoly.Points.Add(new Point(8.25, 49.25));
            apoly.Points.Add(new Point(8.125, 49.25));
            apoly.Points.Add(new Point(8.125, 49.125));
            apoly.Points.Add(new Point(8.25, 49.125));

            layer.Shapes.Add(apoly);

            // the rotation center of the canvas needs to be calculated for a rotate transform
            // only works after the shape has been added to the canvas.
            var rotateCenter = apoly.GeoTransform(new Point(8, 49));
            RotateTransform xform = new RotateTransform(0, rotateCenter.X, rotateCenter.Y);
            apoly.RenderTransform = xform;
            AnimationTimeline animaDouble5 = new DoubleAnimation(0, 360, new Duration(new TimeSpan(0, 0, 10)));
            animaDouble5.RepeatBehavior = RepeatBehavior.Forever;
            xform.BeginAnimation(RotateTransform.AngleProperty, animaDouble5);
        }
        private void DrawLinks()
        {
            // remove all links
            drawnLinks.Clear();
            for (int i = 0; i <= graphCanvas.Children.Count - 1; i++)
            {
                var child = graphCanvas.Children[i];
                if (child is ArrowLineBase)
                {
                    graphCanvas.Children.RemoveAt(i);
                    i--;
                }
            }

            // draw links
            foreach (var node in drawnNodes.Keys)
            {
                Point startPosition = drawnNodes[node].Point;
                foreach (var link in node.Links)
                {
                    if (drawnLinks.ContainsKey(link))
                    {
                        continue;
                    }

                    if (link.IsLoop)
                    {
                        ArrowPolyline apoly = new ArrowPolyline()
                        {
                            Stroke = this.linkColor, StrokeThickness = 0.5, ArrowAngle = 25, ArrowLength = 6
                        };
                        apoly.ArrowEnds = graph.GraphType == GraphType.Undirected ? ArrowEnds.None : ArrowEnds.End;
                        Point nodePosition = drawnNodes[link.Node1].Point;
                        apoly.Points.Add(nodePosition);
                        apoly.Points.Add(new Point(nodePosition.X, nodePosition.Y + nodeRadius * 2));
                        apoly.Points.Add(new Point(nodePosition.X + nodeRadius * 2, nodePosition.Y + nodeRadius * 2));
                        apoly.Points.Add(new Point(nodePosition.X + nodeRadius * 2, nodePosition.Y));
                        apoly.Points.Add(new Point(nodePosition.X + nodeRadius, nodePosition.Y));
                        graphCanvas.Children.Add(apoly);
                        drawnLinks.Add(link, apoly);

                        Label lbl = new Label()
                        {
                            Content = link.Weight.ToString(), Foreground = nodeNameColor, FontWeight = FontWeights.Bold
                        };
                        Canvas.SetLeft(lbl, apoly.Points.Last().X + nodeRadius);
                        Canvas.SetTop(lbl, apoly.Points.Last().Y + nodeRadius);
                        Canvas.SetZIndex(lbl, 101);
                        graphCanvas.Children.Add(lbl);
                    }
                    else
                    {
                        Point endPosition = drawnNodes[link.Node2].Point;
                        if (graph.GraphType == GraphType.Undirected)
                        {
                            if (node == link.Node2)
                            {
                                endPosition = drawnNodes[link.Node1].Point;
                            }
                        }

                        Petzold.Media2D.ArrowLine line = new Petzold.Media2D.ArrowLine()
                        {
                            Stroke = this.linkColor, StrokeThickness = 1, ArrowAngle = 25, ArrowLength = 6
                        };
                        line.ArrowEnds = graph.GraphType == GraphType.Undirected ? ArrowEnds.None : ArrowEnds.End;
                        line.X1        = startPosition.X;
                        line.Y1        = startPosition.Y;

                        Point endPoint = new Point();
                        if (endPosition.X - startPosition.X == 0 || endPosition.Y - startPosition.Y == 0)
                        {
                            endPoint.X = endPosition.X;
                            endPoint.Y = endPosition.Y;
                        }
                        else
                        {
                            double alpha    = Math.Atan(Math.Abs((endPosition.Y - startPosition.Y) / (endPosition.X - startPosition.X)));
                            double sinAlpha = Math.Abs(Math.Sin(alpha));
                            double cosAlpha = Math.Abs(Math.Cos(alpha));

                            if (endPosition.X > startPosition.X && endPosition.Y < startPosition.Y)         //first quarter
                            {
                                endPoint.X = endPosition.X - ((double)nodeRadius) * cosAlpha;
                                endPoint.Y = endPosition.Y + ((double)nodeRadius) * sinAlpha;
                            }
                            else if (endPosition.X > startPosition.X && endPosition.Y > startPosition.Y)    //second quarter
                            {
                                endPoint.X = endPosition.X - ((double)nodeRadius) * cosAlpha;
                                endPoint.Y = endPosition.Y - ((double)nodeRadius) * sinAlpha;
                            }
                            else if (endPosition.X < startPosition.X && endPosition.Y > startPosition.Y)    //third quarter
                            {
                                endPoint.X = endPosition.X + ((double)nodeRadius) * cosAlpha;
                                endPoint.Y = endPosition.Y - ((double)nodeRadius) * sinAlpha;
                            }
                            else if (endPosition.X < startPosition.X && endPosition.Y < startPosition.Y)    //fourth quarter
                            {
                                endPoint.X = endPosition.X + ((double)nodeRadius) * cosAlpha;
                                endPoint.Y = endPosition.Y + ((double)nodeRadius) * sinAlpha;
                            }
                        }

                        line.X2 = endPoint.X;
                        line.Y2 = endPoint.Y;
                        graphCanvas.Children.Add(line);
                        line.MouseDown += Line_MouseDown;
                        line.Tag        = link;
                        drawnLinks.Add(link, line);
                        Canvas.SetZIndex(line, 99);

                        // add link weight to canvas
                        var   p   = new Point((line.X1 + line.X2) / 2, (line.Y1 + line.Y2) / 2);
                        Label lbl = new Label()
                        {
                            Content = link.Weight.ToString(), Foreground = nodeNameColor, FontWeight = FontWeights.Bold
                        };
                        Canvas.SetLeft(lbl, p.X - nodeRadius);
                        Canvas.SetTop(lbl, p.Y - nodeRadius);
                        Canvas.SetZIndex(lbl, 101);
                        graphCanvas.Children.Add(lbl);
                    }
                }
            }
        }
Beispiel #6
0
        private void Text(ArrowLine ln, double x, double y, string text, Color color)
        {
            TextBlock textBlock = new TextBlock();

            textBlock.Text = text;

            textBlock.Foreground = new SolidColorBrush(color);

            Canvas.SetLeft(textBlock, x);

            Canvas.SetTop(textBlock, y);

            gg.textes.Add(ln, textBlock);
            canva.Children.Add(textBlock);
        }
Beispiel #7
0
        // Открыть граф из файла
        private void button7_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog();

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                foreach (Ellipse el in gg.getelipse.Values) {
                    canva.Children.Remove(el);
                }
                foreach (TextBlock tx in gg.textes.Values)
                {
                    canva.Children.Remove(tx);
                }
                foreach (ArrowLine ln in gg.ArrowLines.Keys)
                {
                    canva.Children.Remove(ln);
                }
                gg.direction.Clear();

                gg = new Graph();

                    string Content = System.IO.File.ReadAllText(openFileDialog1.FileName);
                    string[] integersString = Content.Split(new char[] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

                    int[] integers = new int[integersString.Length];
                    int current = 0;
                    foreach(string s in integersString){
                        integers[current++] = int.Parse(s);
                    }
                    //System.IO.StreamReader reader = new System.IO.StreamReader(openFileDialog1.FileName);
                    current = 0;

                    number = integers[current++];

                    for (int i = 0; i < number; i++)
                    {
                        Ellipse el = new Ellipse();

                        int index = integers[current++];
                        int x = integers[current++];
                        int y = integers[current++];
                        gg.nodes.Add(el, index);
                        gg.getelipse.Add(index, el);

                        el.MouseDown += new MouseButtonEventHandler(ellipse_MouseDown);
                        el.Width = 30;
                        el.Height = 30;
                        el.StrokeThickness = 1;
                        el.Stroke = Brushes.Black;
                        el.Fill = Brushes.Blue;

                        canva.Children.Add(el);
                        Canvas.SetLeft(el, x);
                        Canvas.SetTop(el, y);
                    }

                    for (int i = 0; i < number; i++) {
                        gg.graph.Add(new List<int>());
                        for (int j = 0; j < number; j++)
                        {
                            int w = integers[current++];

                            gg.graph[i].Add(w);

                            if (w != 0)
                            {

                                ArrowLine ln = new ArrowLine();

                                ln.StrokeThickness = 2;
                                ln.Stroke = Brushes.Black;
                                ln.Fill = Brushes.Blue;
                                ln.X1 = Canvas.GetLeft(gg.getelipse[i]) + 15;
                                ln.Y1 = Canvas.GetTop(gg.getelipse[i]) + 15;
                                ln.X2 = Canvas.GetLeft(gg.getelipse[j]) + 15;
                                ln.Y2 = Canvas.GetTop(gg.getelipse[j]) + 15;

                                canva.Children.Add(ln);
                                gg.ArrowLines.Add(ln, Tuple.Create(i, j));
                                gg.edges.Add(Tuple.Create(i, j), ln);
                                gg.direction.Add(Tuple.Create(ln, gg.getelipse[i]), 1);
                                gg.direction.Add(Tuple.Create(ln, gg.getelipse[j]), 2);
                                Text(ln, (ln.X1 + ln.X2) / 2, (ln.Y1 + ln.Y2) / 2, w.ToString(), Colors.Black);
                            }

                        }
                    }

            }
        }
Beispiel #8
0
        // Клик мыши по елипсу
        public void ellipse_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (currentAction == Action.addEdge)
            {
                if (minpath != null && minpath.Count > 0)
                {
                    uncolorPath(minpath);
                    minpath.Clear();
                }
                if (diam != null && diam.Count > 0)
                {
                    uncolorPath(diam);
                    diam.Clear();
                }

                if (wedge < 0)
                {
                    MessageBox.Show("Введите корректный вес ребра", "Сообщение", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    if (active == null)
                    {
                        active = (Ellipse)sender;
                        active.Fill = Brushes.Red;
                        ActiveNum.Content = gg.nodes[active].ToString();
                    }
                    else
                    {
                        if ((Ellipse)sender != active)
                        {
                            active2 = (Ellipse)sender;
                            active2.Fill = Brushes.Red;
                            ActiveNum.Content += " / " + gg.nodes[active2].ToString();

                            int w = wedge;
                            if (gg.graph[gg.nodes[active]][gg.nodes[active2]] > 0)
                            {
                                gg.graph[gg.nodes[active]][gg.nodes[active2]] = w;
                                gg.textes[gg.edges[Tuple.Create(gg.nodes[active], gg.nodes[active2])]].Text = w.ToString();
                            }
                            else
                            {
                                gg.graph[gg.nodes[active]][gg.nodes[active2]] = w;

                                ArrowLine ln = new ArrowLine();

                                ln.StrokeThickness = 2;
                                ln.Stroke = Brushes.Black;
                                ln.Fill = Brushes.Blue;
                                ln.X1 = Canvas.GetLeft(active) + 15;
                                ln.Y1 = Canvas.GetTop(active) + 15;
                                ln.X2 = Canvas.GetLeft(active2) + 15;
                                ln.Y2 = Canvas.GetTop(active2) + 15;

                                canva.Children.Add(ln);
                                gg.ArrowLines.Add(ln, Tuple.Create(gg.nodes[active], gg.nodes[active2]));
                                gg.edges.Add(Tuple.Create(gg.nodes[active], gg.nodes[active2]), ln);
                                gg.direction.Add(Tuple.Create(ln, active), 1);
                                gg.direction.Add(Tuple.Create(ln, active2), 2);
                                Text(ln, (ln.X1 + ln.X2) / 2, (ln.Y1 + ln.Y2) / 2, w.ToString(), Colors.Black);

                            }
                            active2.Fill = Brushes.Blue;
                            active.Fill = Brushes.Blue;
                            active = null;
                            active2 = null;
                            currentAction = Action.Moving;
                            Operation.Content = "Перемещение";
                            ActiveNum.Content = "-";
                        }
                    }
                }
            }
            else if(currentAction == Action.Moving)
            {
                active = (Ellipse)sender;
                ActiveNum.Content = gg.nodes[active].ToString();
                active.Fill = Brushes.Red;
                dragging = true;
                oldMouse = e.GetPosition(canva);
            }
            else if (currentAction == Action.DeleteVertex) {
                if (minpath != null && minpath.Count > 0)
                {
                    uncolorPath(minpath);
                    minpath.Clear();
                }
                if (diam != null && diam.Count > 0)
                {
                    uncolorPath(diam);
                    diam.Clear();
                }
                int v = gg.nodes[(Ellipse)sender];

                for (int i = 0; i < number; i++) {
                    if (gg.graph[v][i] != 0)
                    {
                        ArrowLine ln = gg.edges[Tuple.Create(v, i)];
                        List<Tuple<ArrowLine, Ellipse>> keys_dr = new List<Tuple<ArrowLine, Ellipse>>(gg.direction.Keys);
                        for (int p = 0; p < keys_dr.Count; p++)
                        {
                            Tuple<ArrowLine, Ellipse> key = keys_dr[p];
                            if (key.Item1 == ln)
                                gg.direction.Remove(key);

                        }
                        canva.Children.Remove(gg.textes[ln]);
                        gg.textes.Remove(ln);
                        gg.ArrowLines.Remove(ln);
                        canva.Children.Remove(ln);
                        gg.edges.Remove(Tuple.Create(v, i));
                    }
                    if (gg.graph[i][v] != 0)
                    {
                        ArrowLine ln = gg.edges[Tuple.Create(i, v)];
                        List<Tuple<ArrowLine, Ellipse>> keys_dr = new List<Tuple<ArrowLine, Ellipse>>(gg.direction.Keys);
                        for (int p = 0; p < keys_dr.Count; p++)
                        {
                            Tuple<ArrowLine, Ellipse> key = keys_dr[p];
                            if (key.Item1 == ln)
                                gg.direction.Remove(key);

                        }
                        canva.Children.Remove(gg.textes[ln]);
                        gg.textes.Remove(ln);
                        gg.ArrowLines.Remove(ln);
                        canva.Children.Remove(ln);
                        gg.edges.Remove(Tuple.Create(i, v));
                    }
                }

                gg.graph.RemoveAt(v);
                foreach (List<int> l in gg.graph)
                {
                    l.RemoveAt(v);
                }

                List<Ellipse> keys_el = new List<Ellipse>(gg.nodes.Keys);
                for (int i = 0; i < keys_el.Count; i++)
                {
                    Ellipse key = keys_el[i];
                    if (gg.nodes[key] > v)
                        gg.nodes[key]--;
                }

                gg.getelipse.Remove(v);
                gg.nodes.Remove((Ellipse)sender);

                List<int> keys_ge = new List<int>(gg.getelipse.Keys);
                for (int i = 0; i < keys_ge.Count; i++)
                {
                    int key = keys_ge[i];
                    if (key > v)
                    {
                        Ellipse temp = gg.getelipse[key];
                        gg.getelipse.Remove(key);
                        gg.getelipse.Add(key - 1, temp);
                    }
                }

                List<ArrowLine> keys_ln = new List<ArrowLine>(gg.ArrowLines.Keys);
                for (int j = 0; j < keys_ln.Count; j++)
                {
                    ArrowLine key_ln = keys_ln[j];
                    if (gg.ArrowLines[key_ln].Item1 > v)
                    {
                        gg.ArrowLines[key_ln] = Tuple.Create(gg.ArrowLines[key_ln].Item1 - 1, gg.ArrowLines[key_ln].Item2);
                    }
                    if (gg.ArrowLines[key_ln].Item2 > v)
                    {
                        gg.ArrowLines[key_ln] = Tuple.Create(gg.ArrowLines[key_ln].Item1, gg.ArrowLines[key_ln].Item2 - 1);
                    }
                }

                List<Tuple<int, int>> keys_ed = new List<Tuple<int, int>>(gg.edges.Keys);
                for (int k = 0; k < keys_ed.Count; k++)
                {
                    Tuple<int, int> key_ed = keys_ed[k];
                    if (key_ed.Item1 > v && key_ed.Item2 > v)
                    {
                        Tuple<int, int> temp = Tuple.Create(key_ed.Item1 - 1, key_ed.Item2 - 1);
                        ArrowLine ln = gg.edges[key_ed];
                        gg.edges.Remove(key_ed);
                        gg.edges.Add(temp, ln);
                    }
                    else
                    {
                        if (key_ed.Item1 > v)
                        {
                            Tuple<int, int> temp = Tuple.Create(key_ed.Item1 - 1, key_ed.Item2);
                            ArrowLine ln = gg.edges[key_ed];
                            gg.edges.Remove(key_ed);
                            gg.edges.Add(temp, ln);
                        }
                        if (key_ed.Item2 > v)
                        {
                            Tuple<int, int> temp = Tuple.Create(key_ed.Item1, key_ed.Item2 - 1);
                            ArrowLine ln = gg.edges[key_ed];
                            gg.edges.Remove(key_ed);
                            gg.edges.Add(temp, ln);
                        }
                    }
                }

                canva.Children.Remove((Ellipse)sender);
                number--;

                currentAction = Action.Moving;
                Operation.Content = "Перемещение";
                ActiveNum.Content = "-";
            }
        }
Beispiel #9
0
        public void hipAlignmentYAxis()
        {
            Joint leftHip = (skeleton.Joints[JointType.HipLeft]);
            Joint rightHip = (skeleton.Joints[JointType.HipRight]);
            Range range = new Range(leftHip.Position.Y, Range.hipIntermediateRange);

            Point p1 = new Point(rightHip.Position.X * (windowWidth / 2) + (windowWidth / 2), rightHip.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio));
            Point p2 = new Point(leftHip.Position.X * (windowWidth / 2) + (windowWidth / 2), leftHip.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio));
            Line line = new Line() { X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y, Stroke = correctionLineColor, StrokeThickness = correctionLineThickness };
            Point p3;
            ArrowLine directionLine = new ArrowLine();

            if (rightHip.Position.Y < range.minimum)
            {
                p3 = new Point(leftHip.Position.X * (windowWidth / 2) + (windowWidth / 2), leftHip.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio + correctionArrowLength));
                directionLine = new ArrowLine() { X1 = p2.X, Y1 = p2.Y, X2 = p3.X, Y2 = p3.Y, Stroke = upDownColor, StrokeThickness = correctionLineThickness };
                canvas.Children.Add(line);
                canvas.Children.Add(directionLine);
            }
            else if (rightHip.Position.Y > range.maximum)
            {
                p3 = new Point(rightHip.Position.X * (windowWidth / 2) + (windowWidth / 2), rightHip.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio + correctionArrowLength));
                directionLine = new ArrowLine() { X1 = p1.X, Y1 = p1.Y, X2 = p3.X, Y2 = p3.Y, Stroke = upDownColor, StrokeThickness = correctionLineThickness };
                canvas.Children.Add(line);
                canvas.Children.Add(directionLine);
            }
        }
Beispiel #10
0
        public void spineAlignmentYAxis()
        {
            Joint centerHip = skeleton.Joints[JointType.HipCenter];
            Joint centerShoulder = skeleton.Joints[JointType.ShoulderCenter];
            Range hipsRange = new Range(centerShoulder.Position.Z, Range.hipsToShouldersIntermediateRange);

            Point p1 = new Point(centerHip.Position.X * (windowWidth / 2) + (windowWidth / 2), centerHip.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio));
            Point p2 = new Point(centerShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), centerShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio));
            Line line = new Line() { X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y, Stroke = correctionLineColor, StrokeThickness = correctionLineThickness };
            Point p3;
            ArrowLine directionLine = new ArrowLine();

            if (centerHip.Position.Z > hipsRange.maximum)
            {
                p3 = new Point(centerShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), centerShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio - correctionArrowLength));
                directionLine = new ArrowLine() { X1 = p2.X, Y1 = p2.Y, X2 = p3.X, Y2 = p3.Y, Stroke = frontBackColor, StrokeThickness = correctionArrowThickness };
                canvas.Children.Add(line);
                canvas.Children.Add(directionLine);
            }
            else if (centerHip.Position.Z < hipsRange.minimum)
            {
                p3 = new Point(centerShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), centerShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio + correctionArrowLength));
                directionLine = new ArrowLine() { X1 = p2.X, Y1 = p2.Y, X2 = p3.X, Y2 = p3.Y, Stroke = frontBackColor, StrokeThickness = correctionArrowThickness };
                canvas.Children.Add(line);
                canvas.Children.Add(directionLine);
            }
        }
Beispiel #11
0
        public void shoulderAlignmentZAxis()
        {
            Joint leftShoulder = skeleton.Joints[JointType.ShoulderLeft];
            Joint rightShoulder = skeleton.Joints[JointType.ShoulderRight];
            Range range = new Range(leftShoulder.Position.Z, Range.shoulderIntermediateRange);

            Point p1 = new Point(leftShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), leftShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio));
            Point p2 = new Point(rightShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), rightShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio));
            Line line = new Line() { X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y, Stroke = correctionLineColor, StrokeThickness = correctionLineThickness };
            Point p3;
            ArrowLine directionLine = new ArrowLine();

            if (rightShoulder.Position.Z > range.maximum)
            {
                p3 = new Point(leftShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), leftShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio - correctionArrowLength));
                directionLine = new ArrowLine() { X1 = p1.X, Y1 = p1.Y, X2 = p3.X, Y2 = p3.Y, Stroke = frontBackColor, StrokeThickness = correctionArrowThickness };
                canvas.Children.Add(line);
                canvas.Children.Add(directionLine);
            }
            else if (rightShoulder.Position.Z < range.minimum)
            {
                p3 = new Point(rightShoulder.Position.X * (windowWidth / 2) + (windowWidth / 2), rightShoulder.Position.Y * -(windowHeight / 2) + (windowHeight / MainWindow.windowHeightRatio + correctionArrowLength));
                directionLine = new ArrowLine() { X1 = p2.X, Y1 = p2.Y, X2 = p3.X, Y2 = p3.Y, Stroke = frontBackColor, StrokeThickness = correctionArrowThickness };
                canvas.Children.Add(line);
                canvas.Children.Add(directionLine);
            }
        }
Beispiel #12
0
        private void initLine(Color c, LinkHeadType headType)
        {
            line = new ArrowLine();
            line.ArrowAngle = 40;
            line.Stroke = new SolidColorBrush(c);
            switch (headType)
            {
                case LinkHeadType.DoubleHeaded:
                    line.ArrowEnds = ArrowEnds.Both;
                    break;
                case LinkHeadType.SingleHeaded:
                    line.ArrowEnds = ArrowEnds.End;
                    break;
                default:
                    throw new NotSupportedException();
            }
            line.StrokeThickness = ShapeUtils.LINE_WIDTH;
            line.Effect = ShapeUtils.ShadowProvider();
            line.Tag = this;

            selMarker1 = ShapeUtils.MakeLinkEnd();
            selMarker1.Tag = this;

            selMarker2 = ShapeUtils.MakeLinkEnd();
            selMarker2.Tag = this;

            line.MouseWheel += MouseWheel;
        }