Пример #1
0
 public override void Draw(DrawParams param)
 {
     using (Pen pen = OutlineStyle.CreatePen(param))
     {
         param.Graphics.DrawLine(pen, X1, Y1, X2, Y2);
     }
 }
Пример #2
0
 public override void Draw(DrawParams param)
 {
     using (Brush brush = FillStyle.CreateBrush(param))
     {
         param.Graphics.FillEllipse(brush, Math.Min(X1, X2), Math.Min(Y1, Y2), Width, Height);
     }
     using (Pen pen = OutlineStyle.CreatePen(param))
     {
         param.Graphics.DrawEllipse(pen, Math.Min(X1, X2), Math.Min(Y1, Y2), Width, Height);
     }
 }
Пример #3
0
 public override void Draw(DrawParams param)
 {
     PointF[] points = new PointF[3];
     points[0] = new PointF(X1, Y1);
     points[1] = new PointF(X2, Y2);
     points[2] = new PointF(X3, Y3);
     using (Brush brush = FillStyle.CreateBrush(param))
     {
         param.Graphics.FillPolygon(brush, points);
     }
     using (Pen pen = OutlineStyle.CreatePen(param))
     {
         param.Graphics.DrawPolygon(pen, points);
     }
 }
Пример #4
0
        public override void Draw(DrawParams param)
        {
            PointF[] points = new PointF[Points.Length];
            for (int i = 0; i < Points.Length; i++)
            {
                points[i] = new PointF(Points[i].X, Points[i].Y);
            }

            using (Brush brush = FillStyle.CreateBrush(param))
            {
                param.Graphics.FillPolygon(brush, points);
            }

            using (Pen pen = OutlineStyle.CreatePen(param))
            {
                param.Graphics.DrawPolygon(pen, points);
            }
        }
Пример #5
0
        public override void Draw(DrawParams param)
        {
            float height = param.ModelToView(Height);
            using (Brush brush = new SolidBrush(OutlineStyle.Color))
            using (Brush back = new SolidBrush(FillStyle.Color))
            using (Font font = new Font(FontFamily, height, FontStyle, GraphicsUnit.Pixel))
            {
                // Convert the text alignment point (x, y) to pixel coordinates
                PointF[] pt = new PointF[] { new PointF(X, Y) };
                param.Graphics.TransformPoints(CoordinateSpace.Device, CoordinateSpace.World, pt);
                float x = pt[0].X;
                float y = pt[0].Y;

                // Revert transformation to identity while drawing text
                System.Drawing.Drawing2D.Matrix oldMatrix = param.Graphics.Transform;
                param.Graphics.ResetTransform();

                // Calculate alignment in pixel coordinates
                float thWidth = 0;
                foreach (string line in Lines)
                {
                    thWidth = Math.Max(thWidth, param.Graphics.MeasureString(Lines[0], font).Width);
                }
                float dy = param.Graphics.MeasureString(Lines[0], font).Height;
                float thHeight = dy * Lines.Length;

                param.Graphics.RotateTransform(-Rotation, MatrixOrder.Append);
                param.Graphics.TranslateTransform(x, y, MatrixOrder.Append);

                // Fill background
                param.Graphics.FillRectangle(back, 0, 0, thWidth, thHeight);
                float yy = 0;
                foreach (string line in Lines)
                {
                    param.Graphics.DrawString(line, font, brush, 0, yy);
                    yy += dy;
                }

                // Restore old transformation
                param.Graphics.Transform = oldMatrix;
            }
        }
Пример #6
0
 public Pen CreatePen(DrawParams param)
 {
     Pen pen = new Pen(Color, param.GetScaledLineWeight(LineWeight));
     pen.DashStyle = DashStyle;
     return pen;
 }
Пример #7
0
 public abstract void Draw(DrawParams param);
Пример #8
0
 public abstract void Draw(DrawParams param);
Пример #9
0
        public override void Draw(DrawParams param)
        {
            float tickSize = 0.5f * TextHeight;

            Vector2D dir = P2 - P1;
            float angle = dir.Angle;
            float len = dir.Length;

            Matrix2D trans = Matrix2D.Transformation(1, 1, angle, P1.X, P1.Y);

            // Dimension line
            Line dim = new Line(0, Offset, len, Offset);
            dim.OutlineStyle = OutlineStyle;
            dim.TransformBy(trans);
            dim.Draw(param);

            // Left tick
            Line tick1 = new Line(0, -tickSize + Offset, 0, tickSize + Offset);
            tick1.OutlineStyle = OutlineStyle;
            tick1.TransformBy(trans);
            tick1.Draw(param);

            // Right tick
            Line tick2 = new Line(len, -tickSize + Offset, len, tickSize + Offset);
            tick2.OutlineStyle = OutlineStyle;
            tick2.TransformBy(trans);
            tick2.Draw(param);

            // Text
            Text textObj = new Text(len / 2, Offset, String, TextHeight);
            textObj.FontFamily = FontFamily;
            textObj.FontStyle = FontStyle;
            textObj.HorizontalAlignment = StringAlignment.Center;
            textObj.VerticalAlignment = StringAlignment.Center;
            textObj.FillStyle = FillStyle;
            textObj.OutlineStyle = OutlineStyle;
            textObj.TransformBy(trans);
            textObj.Draw(param);
        }
Пример #10
0
        public override void Draw(DrawParams param)
        {
            float height = param.ModelToView(Height);
            using (Brush brush = new SolidBrush(OutlineStyle.Color))
            using (Brush back = new SolidBrush(FillStyle.Color))
            using (Font font = new Font(FontFamily, height, FontStyle, GraphicsUnit.Pixel))
            {
                // Convert the text alignment point (x, y) to pixel coordinates
                PointF[] pt = new PointF[] { new PointF(X, Y) };
                param.Graphics.TransformPoints(CoordinateSpace.Device, CoordinateSpace.World, pt);
                float x = pt[0].X;
                float y = pt[0].Y;

                // Revert transformation to identity while drawing text
                System.Drawing.Drawing2D.Matrix oldMatrix = param.Graphics.Transform;
                param.Graphics.ResetTransform();

                // Calculate alignment in pixel coordinates
                float dx = 0;
                float dy = 0;
                SizeF sz = param.Graphics.MeasureString(String, font);
                if (HorizontalAlignment == StringAlignment.Far)
                    dx = -sz.Width;
                else if (HorizontalAlignment == StringAlignment.Center)
                    dx = -sz.Width / 2;
                if (VerticalAlignment == StringAlignment.Near)
                    dy = -sz.Height;
                else if (VerticalAlignment == StringAlignment.Center)
                    dy = -sz.Height / 2;

                param.Graphics.TranslateTransform(dx, dy, MatrixOrder.Append);
                param.Graphics.RotateTransform(-Rotation, MatrixOrder.Append);
                param.Graphics.TranslateTransform(x, y, MatrixOrder.Append);

                // Fill background
                param.Graphics.FillRectangle(back, 0, 0, sz.Width, sz.Height);
                param.Graphics.DrawString(String, font, brush, 0, 0);

                // Restore old transformation
                param.Graphics.Transform = oldMatrix;
            }
        }
Пример #11
0
        public void Render(Graphics graphics)
        {
            DrawParams param = new DrawParams(graphics, false, ZoomFactor);

            // Set an orthogonal projection matrix
            ScaleGraphics(graphics);

            // Render drawing objects
            foreach (Drawable item in Model)
            {
                item.Draw(param);
            }
        }