Exemplo n.º 1
0
 /// <summary>
 /// Draws a line.
 /// </summary>
 /// <param name="g"></param>
 /// <param name="l"></param>
 public static void DrawBresenhamLine(this Graphics g, Line l)
 {
     l.LinePoints.ForEach(p =>
     {
         g.DrawRectangle(l.Pen, p.X, p.Y, 1, 1);
     });
     DrawEdgeConstraintIcon(g, l);
     DrawEdgeConstraintText(g, l);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Clears a line.
 /// </summary>
 /// <param name="g"></param>
 /// <param name="l"></param>
 public static void ClearBresenhamLine(this Graphics g, Line l)
 {
     using (var pen = new Pen(l.BackgroudColor, l.Pen.Width))
         l.LinePoints.ForEach(p =>
         {
             g.DrawRectangle(pen, p.X, p.Y, 1, 1);
         });
     ClearEdgeConstraintIcon(g, l);
     ClearEdgeConstraintText(g, l);
 }
Exemplo n.º 3
0
        private static void DrawEdgeConstraintIcon(this Graphics g, Line l)
        {
            Point p = l.LinePoints[l.LinePoints.Count / 2];

            p.X += 4;
            p.Y += 4;
            if (l.Constraint != null && l.Constraint.Icon != null)
            {
                g.DrawImage(l.Constraint.Icon, p.X, p.Y, l.Constraint.PrefferedIconSize.width, l.Constraint.PrefferedIconSize.height);
            }
        }
Exemplo n.º 4
0
        private static void ClearEdgeConstraintIcon(this Graphics g, Line l)
        {
            Point p = l.LinePoints[l.LinePoints.Count / 2];

            p.X += 4;
            p.Y += 4;
            using (var b = new SolidBrush(l.BackgroudColor))
            {
                if (l.Constraint != null && l.Constraint.Icon != null)
                {
                    g.FillRectangle(b, p.X, p.Y, l.Constraint.PrefferedIconSize.width, l.Constraint.PrefferedIconSize.height);
                }
            }
        }
Exemplo n.º 5
0
        private static void ClearEdgeConstraintText(this Graphics g, Line l)
        {
            Point p = l.LinePoints[l.LinePoints.Count / 2];

            p.X += 4;
            p.Y += 4;

            using (var brush = new SolidBrush(l.BackgroudColor))
            {
                using (var font = new Font("Calibri", 10))
                {
                    if (l.Constraint != null && l.Constraint.ConstraintText != null && l.Constraint.ConstraintText != "")
                    {
                        var textSize = TextRenderer.MeasureText(l.Constraint.ConstraintText, font);
                        g.FillRectangle(brush, p.X, p.Y, textSize.Width, textSize.Height);
                    }
                }
            }
        }
Exemplo n.º 6
0
        private static void DrawEdgeConstraintText(this Graphics g, Line l)
        {
            Point p = l.LinePoints[l.LinePoints.Count / 2];

            p.X += 4;
            p.Y += 4;

            using (var brush = new SolidBrush(Color.Beige))
            {
                using (var font = new Font("Calibri", 10))
                {
                    if (l.Constraint != null && l.Constraint.ConstraintText != null && l.Constraint.ConstraintText != "")
                    {
                        var textSize = TextRenderer.MeasureText(l.Constraint.ConstraintText, font);
                        g.FillRectangle(brush, p.X, p.Y, textSize.Width, textSize.Height);
                        g.DrawString(l.Constraint.ConstraintText, new Font("Calibri", 10), Brushes.Red, new Rectangle(p.X, p.Y, textSize.Width, textSize.Height));
                    }
                }
            }
        }