Пример #1
0
        private void rerouteLine()
        {
            Point from = new Point(this.FromX, this.FromY);
            Point to   = new Point(this.ToX, this.ToY);

            this.mLine.Points.Clear();
            this.mLine.Points.Add(from);

            if (this.FromOrientation != this.ToOrientation)
            {
                // Fine, we'll just do a two-piece line, then.
                if (this.FromOrientation == Orientation.Horizontal)
                {
                    this.mLine.Points.Add(new Point(to.X, from.Y));
                }
                else
                {
                    this.mLine.Points.Add(new Point(from.X, to.Y));
                }
            }
            else if (this.FromOrientation /* == ToOrientation */ == Orientation.Horizontal)
            {
                double mid = from.X + ((to.X - from.X) / 2);

                this.mLine.Points.Add(new Point(mid, from.Y));
                this.mLine.Points.Add(new Point(mid, to.Y));
            }
            else /* FromOrientation == ToOrientation == Orientation.Vertical */
            {
                double mid = from.Y + ((to.Y - from.Y) / 2);

                this.mLine.Points.Add(new Point(from.X, mid));
                this.mLine.Points.Add(new Point(to.X, mid));
            }

            this.mLine.Points.Add(to);

            Vector firstSegment = from - this.mLine.Points[1];
            Vector lastSegment  = to - this.mLine.Points[this.mLine.Points.Count() - 2];

            this.mFromAngleInDegrees = FrameworkUtilities.RadiansToDegrees(firstSegment.GetAngularCoordinate());
            this.mToAngleInDegrees   = FrameworkUtilities.RadiansToDegrees(lastSegment.GetAngularCoordinate());

            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs("FromAngleInDegrees"));
                this.PropertyChanged(this, new PropertyChangedEventArgs("ToAngleInDegrees"));
            }

            this.NotifySnapTargetUpdate(new SnapTargetUpdateEventArgs());
        }