Пример #1
0
        public virtual void DrawToGraphics(Graphics graphics)
        {
            Pen pen = Pens.Black;
            switch (this.CurrentState)
            {
                case ItemState.Free:
                    pen = new Pen(ColorDefinition.GetColorWhenFree());
                    break;

                case ItemState.Hover:
                    pen = new Pen(ColorDefinition.GetColorWhenHover());
                    break;

                case ItemState.Selected:
                    pen = new Pen(ColorDefinition.GetColorWhenSelected());
                    break;

                default:
                    break;
            } // switch

            setLinkKind(pen);

            List<PointF> tempNails = new List<PointF>();
            tempNails.Add(this.GetStartingPoint());
            foreach (NailItem nail in this.nails)
                tempNails.Add(nail.Center());
            tempNails.Add(this.GetEndPoint());

            float R = NailItem.R;
            if (this.CurrentState == ItemState.Free)
                R = NailItem.R + 5;

            PointF[] points = new PointF[3];
            PointF firstNail = PointF.Empty;
            firstNail = tempNails[0];
            for (int i = 0; i < tempNails.Count - 1; i++)
            {
                points[1] = tempNails[i + 1];
                points[0] = GraphUltility.FindPointByDistance(points[1], firstNail, R);
                graphics.DrawLine(pen, firstNail, points[0]);

                if (i + 2 < tempNails.Count)
                {
                    points[2] = GraphUltility.FindPointByDistance(points[1], tempNails[i + 2], R);
                    firstNail = points[2];

                    //Make the intersection curved
                    if (this.CurrentState == ItemState.Free)
                        graphics.DrawBezier(pen, points[0], points[1], points[1], points[2]);
                }
            }

            DrawRouteWithBigArrow(graphics, pen, firstNail, tempNails[tempNails.Count - 1]);
        }