public override void Rotate(float angle) { using (DeviceContextHandler dch = GetDeviceContextHandler()) { dch.DrawingSurface.RotateTransform(angle); } }
public override void PopMatrix() { using (DeviceContextHandler dch = GetDeviceContextHandler()) { dch.DrawingSurface.EndContainer(_matrixStack.Pop()); } }
public override void Translate(float x, float y, float z) { using (DeviceContextHandler dch = GetDeviceContextHandler()) { dch.DrawingSurface.TranslateTransform(x, y); } }
public override void Rotate(float angle) { using (DeviceContextHandler dch = GetDeviceContextHandler()) { dch.DrawingSurface.RotateTransform(Functions.AngleMode == AngleMode.Degrees ? angle : Functions.Degrees(angle)); } }
//public override void DrawQuad(QuadParameters parms) //{ // using (DeviceContextHandler dch = GetDeviceContextHandler()) // using (GraphicsPath path = new GraphicsPath()) // { // PointF[] points = new PointF[] // { // new PointF(parms.X1, parms.Y1), // new PointF(parms.X2, parms.Y2), // new PointF(parms.X3, parms.Y3), // new PointF(parms.X4, parms.Y4) // }; // path.AddPolygon(points); // if (!Style.FillParameters.Disabled) // { // dch.DrawingSurface.FillPath(Style.FillParameters.ToBrush(), path); // } // if (!Style.StrokeParameters.Disabled) // { // dch.DrawingSurface.DrawPath(Style.StrokeParameters.ToPen(), path); // } // } //} //public override void DrawRectangle(RectangleParameters parms) //{ // using (DeviceContextHandler dch = GetDeviceContextHandler()) // { // RectangleF rect = Style.GetAdjustedRectangle(parms); // if (!Style.FillParameters.Disabled) // { // dch.DrawingSurface.FillRectangle(Style.FillParameters.ToBrush(), rect.X, rect.Y, rect.Width, rect.Height); // } // if (!Style.StrokeParameters.Disabled) // { // dch.DrawingSurface.DrawRectangle(Style.StrokeParameters.ToPen(), rect.X, rect.Y, rect.Width, rect.Height); // } // } //} public override void DrawShape(ShapeParameters parms) { using (DeviceContextHandler dch = GetDeviceContextHandler()) using (GraphicsPath path = GetShapePath(parms.Shape)) { PushMatrix(); Translate(parms.X, parms.Y); if (!Style.FillParameters.Disabled) { dch.DrawingSurface.FillPath(Style.FillParameters.ToBrush(), path); } if (!Style.StrokeParameters.Disabled) { dch.DrawingSurface.DrawPath(Style.StrokeParameters.ToPen(), path); } if (parms.Shape.Texture != null) { PointF tl = new PointF(path.PathPoints[0].X, path.PathPoints[0].Y); PointF tr = new PointF(path.PathPoints[1].X, path.PathPoints[1].Y); PointF bl = new PointF(path.PathPoints[3].X, path.PathPoints[3].Y); PointF br = new PointF(path.PathPoints[2].X, path.PathPoints[2].Y); using (Image texture = ((Image)parms.Shape.Texture).ToTrapezoid(tl, tr, bl, br)) { dch.DrawingSurface.DrawImage(texture.Bitmap, new PointF()); } } PopMatrix(); } }
public override void Scale(float x, float y) { using (DeviceContextHandler dch = GetDeviceContextHandler()) { dch.DrawingSurface.ScaleTransform(x, y); } }
public override void ResetMatrix() { using (DeviceContextHandler dch = GetDeviceContextHandler()) { dch.DrawingSurface.ResetTransform(); } }
public override void PushMatrix() { using (DeviceContextHandler dch = GetDeviceContextHandler()) { _matrixStack.Push(dch.DrawingSurface.BeginContainer()); SetGraphicsOptions(); } }
public override void Clear() { //_graphics.ClearPixles(); //return; using (DeviceContextHandler dch = GetDeviceContextHandler()) { dch.DrawingSurface.Clear(System.Drawing.Color.Transparent); } }
public override void Clear() { base.Clear(); return; using (DeviceContextHandler dch = GetDeviceContextHandler()) { dch.DrawingSurface.Clear(System.Drawing.Color.Transparent); } }
public override void DrawBezier(BezierParameters parms) { using (DeviceContextHandler dch = GetDeviceContextHandler()) { if (!Style.FillParameters.Disabled) { dch.DrawingSurface.DrawBezier(Style.StrokeParameters.ToPen(), parms.X1, parms.Y1, parms.X2, parms.Y2, parms.X3, parms.Y3, parms.X4, parms.Y4); } } }
//public override void DrawLine(LineParameters parms) //{ // if (!Style.StrokeParameters.Disabled) // { // using (DeviceContextHandler dch = GetDeviceContextHandler()) // { // dch.DrawingSurface.DrawLine(Style.StrokeParameters.ToPen(), parms.X1, parms.Y1, parms.X2, parms.Y2); // } // } //} public override void DrawPoint(PointParameters parms) { if (!Style.StrokeParameters.Disabled) { float w = Style.StrokeParameters.PenWidth; float x = parms.X; float y = parms.Y; using (DeviceContextHandler dch = GetDeviceContextHandler()) { dch.DrawingSurface.FillEllipse(Style.StrokeParameters.ToBrush(), x - w / 2, y - w / 2, w, w); } } }
public override void DrawBackground(BackgroundParameters parms) { using (DeviceContextHandler dch = GetDeviceContextHandler()) { if (parms.Image != null) { dch.DrawingSurface.DrawImage(parms.Image.Bitmap, 0, 0, Canvas.Width, Canvas.Height); } else { //dch.Graphics.FillRectangle(parms.ToBrush(), 0, 0, _graphics.Width, _graphics.Height); dch.DrawingSurface.Clear(parms.Color.ToSystemColor()); } } }
public override void DrawEllipse(EllipseParameters parms) { using (DeviceContextHandler dch = GetDeviceContextHandler()) { Rectangle rect = Style.GetAdjustedRectangle(parms); if (!Style.FillParameters.Disabled) { dch.DrawingSurface.FillEllipse(Style.FillParameters.ToBrush(), rect.X, rect.Y, rect.Width, rect.Height); } if (!Style.StrokeParameters.Disabled) { dch.DrawingSurface.DrawEllipse(Style.StrokeParameters.ToPen(), rect.X, rect.Y, rect.Width, rect.Height); } } }
public override void DrawCurve(CurveParameters parms) { using (DeviceContextHandler dch = GetDeviceContextHandler()) { if (!Style.FillParameters.Disabled) { List <PointF> pts = new List <PointF>(); foreach (Point pt in parms.Points) { pts.Add(pt.ToSystemPointF()); } dch.DrawingSurface.DrawCurve(Style.StrokeParameters.ToPen(), pts.ToArray()); } } }
public override void DrawImage(ImageParameters parms) { using (DeviceContextHandler dch = GetDeviceContextHandler()) { try { Rectangle rect = Style.GetAdjustedRectangle(parms); if (!Style.TintParameters.Disabled) { dch.DrawingSurface.DrawImage(parms.Image.Bitmap, rect.SystemRectangle, 0, 0, parms.Image.Width, parms.Image.Height, GraphicsUnit.Pixel, Style.TintParameters.ImageAttributes); } else { dch.DrawingSurface.DrawImage(parms.Image.Bitmap, rect.SystemRectangleF); } } catch (Exception e) { Console.WriteLine(e.Message + Environment.NewLine + e.StackTrace); } } }
public override void DrawText(TextParameters parms) { if (!Style.StrokeParameters.Disabled) { using (DeviceContextHandler dch = GetDeviceContextHandler()) { Rectangle rect = new Rectangle(parms.X, parms.Y, parms.Width, parms.Height); //TextFormatFlags tff = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.WordBreak; //TextRenderer.DrawText(_graphics, parms.Text, _currentFont, rect, _currentStroke.Color, tff); StringFormat sf = new StringFormat(); sf.LineAlignment = Style.TextVerticalAlignment == VerticalAlignment.Bottom ? StringAlignment.Far : Style.TextVerticalAlignment == VerticalAlignment.Top ? StringAlignment.Near : StringAlignment.Center; sf.Alignment = Style.TextHorizontalAlignment == HorizontalAlignment.Right ? StringAlignment.Far : Style.TextHorizontalAlignment == HorizontalAlignment.Left ? StringAlignment.Near : StringAlignment.Center; dch.DrawingSurface.DrawString(parms.Text, Style.Font, Style.StrokeParameters.ToBrush(), rect.SystemRectangleF, sf); } } }
//public override void DrawQuad(QuadParameters parms) //{ // using (DeviceContextHandler dch = GetDeviceContextHandler()) // using (GraphicsPath path = new GraphicsPath()) // { // PointF[] points = new PointF[] // { // new PointF(parms.X1, parms.Y1), // new PointF(parms.X2, parms.Y2), // new PointF(parms.X3, parms.Y3), // new PointF(parms.X4, parms.Y4) // }; // path.AddPolygon(points); // if (!Style.FillParameters.Disabled) // { // dch.DrawingSurface.FillPath(Style.FillParameters.ToBrush(), path); // } // if (!Style.StrokeParameters.Disabled) // { // dch.DrawingSurface.DrawPath(Style.StrokeParameters.ToPen(), path); // } // } //} //public override void DrawRectangle(RectangleParameters parms) //{ // using (DeviceContextHandler dch = GetDeviceContextHandler()) // { // RectangleF rect = Style.GetAdjustedRectangle(parms); // if (!Style.FillParameters.Disabled) // { // dch.DrawingSurface.FillRectangle(Style.FillParameters.ToBrush(), rect.X, rect.Y, rect.Width, rect.Height); // } // if (!Style.StrokeParameters.Disabled) // { // dch.DrawingSurface.DrawRectangle(Style.StrokeParameters.ToPen(), rect.X, rect.Y, rect.Width, rect.Height); // } // } //} public override void DrawShape(ShapeParameters parms) { using (DeviceContextHandler dch = GetDeviceContextHandler()) using (GraphicsPath path = GetShapePath(parms.Shape)) { PushMatrix(); Translate(parms.X, parms.Y); if (!Style.FillParameters.Disabled) { RectangleF bounds = path.GetBounds(); Brush b = Style.FillParameters.ToBrush(bounds); dch.DrawingSurface.FillPath(b, path); //dch.DrawingSurface.FillPath(Style.FillParameters.ToBrush(path.GetBounds().Size), path); } if (!Style.StrokeParameters.Disabled) { dch.DrawingSurface.DrawPath(Style.StrokeParameters.ToPen(), path); } PopMatrix(); } }