Exemple #1
0
        /// <summary>Draw an arrow on the specified graphics context</summary>
        /// <param name="context">The graphics context to draw on</param>
        /// <param name="start">The start point of the arrow</param>
        /// <param name="end">The end point of the arrow</param>
        private static void DrawArrow(IDrawContext context, Point start, Point end)
        {
            double angle = Math.Atan2(end.Y - start.Y, end.X - start.X) + Math.PI;

            double arrowLenght  = 10;
            double arrowDegrees = 10;
            double x1           = start.X + arrowLenght * Math.Cos(angle - arrowDegrees);
            double y1           = start.Y + arrowLenght * Math.Sin(angle - arrowDegrees);
            double x2           = start.X + arrowLenght * Math.Cos(angle + arrowDegrees);
            double y2           = start.Y + arrowLenght * Math.Sin(angle + arrowDegrees);

            context.NewPath();
            context.MoveTo(x1, y1);
            context.LineTo(x2, y2);
            context.LineTo(end.X, end.Y);
            context.LineTo(x1, y1);
            context.StrokePreserve();
            context.Fill();
        }
Exemple #2
0
        /// <summary>Paint on the graphics context</summary>
        /// <param name="context">The graphics context to draw on</param>
        public override void Paint(IDrawContext context)
        {
            Color outlineColour;

            if (Selected)
            {
                outlineColour = Color.Blue;
            }
            else if (transparent)
            {
                outlineColour = DefaultBackgroundColour;
            }
            else
            {
                outlineColour = DefaultOutlineColour;
            }

            Color backgroundColour = transparent ? DefaultBackgroundColour : Colour;
            Color textColour       = DefaultOutlineColour;

            // Draw circle
            context.SetColour(outlineColour);
            context.SetLineWidth(3);
            context.NewPath();
            context.Arc(Location.X, Location.Y, Width / 2, 0, 2 * Math.PI);
            context.StrokePreserve();
            context.SetColour(backgroundColour);
            context.Fill();

            // Write text
            context.SetLineWidth(1);
            context.SetColour(textColour);
            context.SetFontSize(13);


            DrawCentredText(context, Name, Location);
        }