Esempio n. 1
0
        public void DrawTriangle(Point corner, double width, double height,
                                 SelectionPosition position)
        {
            double x1, y1, x2, y2, x3, y3;

            x1 = corner.X;
            y1 = corner.Y;

            switch (position)
            {
            case SelectionPosition.Top:
                x2 = x1 + width / 2;
                y2 = y1 + height;
                x3 = x1 - width / 2;
                y3 = y1 + height;
                break;

            case SelectionPosition.Bottom:
            default:
                x2 = x1 + width / 2;
                y2 = y1 - height;
                x3 = x1 - width / 2;
                y3 = y1 - height;
                break;
            }

            SetColor(StrokeColor);
            CContext.MoveTo(x1, y1);
            CContext.LineTo(x2, y2);
            CContext.LineTo(x3, y3);
            CContext.ClosePath();
            StrokeAndFill();
        }
Esempio n. 2
0
        public void DrawRoundedRectangle(Point start, double width, double height, double radius, bool strokeAndFill)
        {
            double x, y;

            x       = start.X + LineWidth / 2;
            y       = start.Y + LineWidth / 2;
            height -= LineWidth;
            width  -= LineWidth;

            if ((radius > height / 2) || (radius > width / 2))
            {
                radius = Math.Min(height / 2, width / 2);
            }

            CContext.MoveTo(x, y + radius);
            CContext.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            CContext.LineTo(x + width - radius, y);
            CContext.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            CContext.LineTo(x + width, y + height - radius);
            CContext.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            CContext.LineTo(x + radius, y + height);
            CContext.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            CContext.ClosePath();
            if (strokeAndFill)
            {
                StrokeAndFill();
            }
        }
Esempio n. 3
0
 public void DrawLine(Point start, Point stop)
 {
     CContext.LineWidth = LineWidth;
     CContext.MoveTo(start.X, start.Y);
     CContext.LineTo(stop.X, stop.Y);
     StrokeAndFill();
 }
Esempio n. 4
0
        public void DrawText(Point point, double width, double height, string text,
                             bool escape = false, bool ellipsize = false)
        {
            Layout layout = null;

            Pango.Rectangle inkRect, logRect;

            if (text == null)
            {
                return;
            }

            if (escape)
            {
                text = GLib.Markup.EscapeText(text);
            }

            if (context is CairoContext)
            {
                layout = (context as CairoContext).PangoLayout;
            }
            if (layout == null)
            {
                layout = Pango.CairoHelper.CreateLayout(CContext);
            }
            if (ellipsize)
            {
                layout.Ellipsize = EllipsizeMode.End;
            }
            else
            {
                layout.Ellipsize = EllipsizeMode.None;
            }

            layout.FontDescription = FontDescription.FromString(
                String.Format("{0} {1}px", FontFamily, FontSize));
            layout.FontDescription.Weight = fWeight;
            layout.FontDescription.Style  = fSlant;
            layout.Width = Units.FromPixels((int)width);
            layout.SetPangoLayoutHeight(Units.FromPixels((int)height));
            layout.Alignment = fAlignment;
            layout.SetMarkup(text);
            SetColor(StrokeColor);
            Pango.CairoHelper.UpdateLayout(CContext, layout);
            layout.GetPixelExtents(out inkRect, out logRect);
            CContext.MoveTo(point.X, point.Y + height / 2 - (double)logRect.Height / 2);
            Pango.CairoHelper.ShowLayout(CContext, layout);
            CContext.NewPath();
        }
Esempio n. 5
0
        public void DrawArea(params Point [] vertices)
        {
            double x1, y1;
            Point  initial_point = vertices [0];

            CContext.MoveTo(initial_point.X, initial_point.Y);
            for (int i = 1; i < vertices.Length; i++)
            {
                x1 = vertices [i].X;
                y1 = vertices [i].Y;
                CContext.LineTo(x1, y1);
            }

            CContext.ClosePath();
            StrokeAndFill();
        }
Esempio n. 6
0
        public void DrawArea(params Point[] vertices)
        {
            for (int i = 0; i < vertices.Length - 1; i++)
            {
                double x1, y1, x2, y2;

                x1 = vertices [i].X;
                y1 = vertices [i].Y;
                x2 = vertices [i + 1].X;
                y2 = vertices [i + 1].Y;

                CContext.MoveTo(x1, y1);
                CContext.LineTo(x2, y2);
            }
            CContext.ClosePath();
            StrokeAndFill();
        }
Esempio n. 7
0
        public void ClipRoundRectangle(Point start, double width, double height, double radius)
        {
            double x, y;

            x = start.X;
            y = start.Y;

            if ((radius > height / 2) || (radius > width / 2))
            {
                radius = Math.Min(height / 2, width / 2);
            }

            CContext.MoveTo(x, y + radius);
            CContext.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            CContext.LineTo(x + width - radius, y);
            CContext.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            CContext.LineTo(x + width, y + height - radius);
            CContext.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            CContext.LineTo(x + radius, y + height);
            CContext.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            CContext.ClosePath();
            CContext.Clip();
        }
Esempio n. 8
0
        public void DrawArrow(Point start, Point stop, int lenght, double radians, bool closed)
        {
            double vx1, vy1, vx2, vy2;
            double angle = Math.Atan2(stop.Y - start.Y, stop.X - start.X) + Math.PI;

            vx1 = stop.X + (lenght + LineWidth) * Math.Cos(angle - radians);
            vy1 = stop.Y + (lenght + LineWidth) * Math.Sin(angle - radians);
            vx2 = stop.X + (lenght + LineWidth) * Math.Cos(angle + radians);
            vy2 = stop.Y + (lenght + LineWidth) * Math.Sin(angle + radians);

            CContext.MoveTo(stop.X, stop.Y);
            CContext.LineTo(vx1, vy1);
            if (!closed)
            {
                CContext.MoveTo(stop.X, stop.Y);
                CContext.LineTo(vx2, vy2);
            }
            else
            {
                CContext.LineTo(vx2, vy2);
                CContext.ClosePath();
            }
            StrokeAndFill(false);
        }