Esempio n. 1
0
        public void Draw(Graphics g, Point location, Size mapSize)
        {
            var imageTip = Tip.Scale(mapSize).Translate(location).ToPoint();
            var imageEnd = End.Scale(mapSize).Translate(location).ToPoint();

            // shorten the arrow on one side so it doesn't overlap with the planet
            if (IsArrow && !IsColonyLink)
            {
                Shorten(imageEnd, ref imageTip);
            }

            using (var brush = new LinearGradientBrush(imageTip, imageEnd, TipColor, EndColor))
                //using (var brush = new SolidBrush(Color.Red))
                using (var pen = new Pen(brush, LineWidth * mapSize.Width)) {
                    CustomLineCap cap;
                    if (IsArrow)
                    {
                        if (IsColonyLink)
                        {
                            pen.CustomEndCap = PenCapProvider.GetInheritanceRepresentation();
                            g.DrawLines(pen, new[] { imageTip, imageEnd });
                        }
                        else
                        {
                            cap = new AdjustableArrowCap(10, 12);
                            pen.CustomStartCap = cap;
                            g.DrawLines(pen, new[] { imageTip, imageEnd });
                            cap.Dispose();
                        }
                    }
                    else
                    {
                        g.DrawLines(pen, new[] { imageTip, imageEnd });
                    }
                }
        }