Beispiel #1
0
        public Line(Dot first, Dot second, LineSet owner, LineContainer container)
        {
            First     = first ?? throw new ArgumentNullException(nameof(first));
            Second    = second ?? throw new ArgumentNullException(nameof(second));
            Owner     = owner ?? throw new ArgumentNullException(nameof(owner));
            Container = container ?? throw new ArgumentNullException(nameof(container));
            first.Lines.Add(this);
            second.Lines.Add(this);
            container.Add(this);
            RectangleF           = first.Point.GetRectangleFromTwoPoint(second.Point);
            first.PointChanged  += DotPointChanged;
            second.PointChanged += DotPointChanged;
            float firstY  = first.Point.Y;
            float secondY = second.Point.Y;

            Direction = firstY <secondY?Direction.Up
                                : firstY> secondY ? Direction.Down
                        : Direction.None;
        }
Beispiel #2
0
 public LineSet(Map mapOwner, int id, LineContainer container, Dot[] dots) :
     this(id, container, dots)
 {
     Map = mapOwner;
 }
Beispiel #3
0
        public LineSet(int id, LineContainer container, IEnumerable <Dot> dots)
        {
            ID        = id;
            this.dots = dots.ToArray();
            //if(dots.Last().NextConnectDot)
            foreach (var item in this.dots)
            {
                item.LineSet       = this;
                item.PointChanged += DotPointChanged;
            }
            List <Dot> pl = new List <Dot>();
            Dot        first, prev;

            prev = first = this.dots.First();
            PointF firstP, prevP = prev.Point;

            firstP = first.Point;
            float minX, maxX, minY, maxY;

            minX = maxX = firstP.X;
            minY = maxY = firstP.Y;
            //PointF first = dots.First().Point;
            //PointF prev = first;
            int counter = 0;
            int length  = this.dots.Length;

            dotDistances  = new float[length];
            dotRectangles = new RectangleF[length];
            lines         = new Line[length];
            Line line;

            foreach (var item in this.dots.Skip(1))
            {
                PointF currentP = item.Point;
                //dotRectangles[counter] = currentP.GetRectangleFromTwoPoint(prevP);
                dotDistances[counter] = (float)currentP.Distance(prevP);
                line                   = new Line(prev, item, this, container);
                lines[counter]         = line;
                dotRectangles[counter] = line.RectangleF;
                prev                   = item;
                prevP                  = prev.Point;
                counter++;

                float x = currentP.X, y = currentP.Y;
                if (x < minX)
                {
                    minX = x;
                }
                else if (x > maxX)
                {
                    maxX = x;
                }

                if (y < minY)
                {
                    minY = y;
                }
                else if (y > maxY)
                {
                    maxY = y;
                }
            }
            dotDistances[counter] = (float)firstP.Distance(prevP);
            line                   = new Line(prev, first, this, container);
            lines[counter]         = line;
            dotRectangles[counter] = line.RectangleF;

            RectangleF = new RectangleF(minX, minY, maxX - minX, maxY - minY);
            Color      = ColorCollections[ID % ColorCollections.Length];
        }