public DrawingRectangleAdorner(PictureBox pictureBox) { pictureBox.MouseDown += PictureBox_MouseDown; pictureBox.MouseMove += PictureBox_MouseMove; pictureBox.MouseUp += PictureBox_MouseUp; pictureBox.Paint += PictureBox_Paint; control = pictureBox; rect = RectangleF.Empty; Pen = new Pen(Colors.Green, 5); }
static Pen GetPen (Generator generator, Color color, float thickness = 1f, DashStyle dashStyle = null) { var cache = generator.Cache<PenKey, Pen> (cacheKey); Pen pen; lock (cache) { var key = new PenKey (color.ToArgb (), thickness, dashStyle); if (!cache.TryGetValue (key, out pen)) { pen = new Pen (color, thickness, generator); if (dashStyle != null) pen.DashStyle = dashStyle; cache.Add (key, pen); } } return pen; }
public DrawingPenAdorner(PictureBox pictureBox) { pictureBox.MouseDown += PictureBox_MouseDown; pictureBox.MouseMove += PictureBox_MouseMove; pictureBox.MouseUp += PictureBox_MouseUp; pictureBox.Paint += PictureBox_Paint; control = pictureBox; Paths = new List<Path>(); Pen = new Pen(Colors.Green, 10); Pen.LineCap = PenLineCap.Round; Pen.LineJoin = PenLineJoin.Round; }
public void SetMiterLimit(Pen widget, float miterLimit) { throw new NotImplementedException(); }
public void SetLineCap(Pen widget, PenLineCap lineCap) { throw new NotImplementedException(); }
public void SetLineJoin(Pen widget, PenLineJoin lineJoin) { throw new NotImplementedException(); }
public void SetThickness(Pen widget, float thickness) { throw new NotImplementedException(); }
public void SetColor(Pen widget, Color color) { throw new NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="style"></param> /// <param name="scale"></param> /// <returns></returns> private Pen ToPen(BaseStyle style, Func<double, float> scale) { var pen = new Pen( ToColor(style.Stroke), scale(style.Thickness / _state.Zoom)); switch (style.LineCap) { case Test2d.LineCap.Flat: pen.LineCap = PenLineCap.Butt; break; case Test2d.LineCap.Square: pen.LineCap = PenLineCap.Square; break; case Test2d.LineCap.Round: pen.LineCap = PenLineCap.Round; break; } if (style.Dashes != null) { pen.DashStyle = new DashStyle( (float)style.DashOffset, style.Dashes.Select(x => (float)x).ToArray()); } return pen; }
public PenLineJoin GetLineJoin(Pen widget) { return widget.ToAndroid().StrokeJoin.ToEto(); }
public void SetThickness(Pen widget, float thickness) { widget.ToAndroid().StrokeWidth = thickness; }
public float GetThickness(Pen widget) { return widget.ToAndroid().StrokeWidth; }
public void SetColor(Pen widget, Color color) { widget.ToAndroid().Color = color.ToAndroid(); }
public Color GetColor(Pen widget) { return widget.ToAndroid().Color.ToEto(); }
void Draw(Graphics g, Action<Pen> action) { var path = new GraphicsPath(); path.AddLines(new PointF(0, 0), new PointF(100, 40), new PointF(0, 30), new PointF(50, 70)); for (int i = 0; i < 4; i++) { float thickness = 1f + i * PenThickness; var pen = new Pen(Colors.Black, thickness); pen.LineCap = this.LineCap; pen.LineJoin = this.LineJoin; pen.DashStyle = this.DashStyle; if (action != null) action(pen); var y = i * 20; g.DrawLine(pen, 10, y, 110, y); y = 80 + i * 50; g.DrawRectangle(pen, 10, y, 100, 30); y = i * 70; g.DrawArc(pen, 140, y, 100, 80, 160, 160); y = i * 70; g.DrawEllipse(pen, 260, y, 100, 50); g.SaveTransform(); y = i * 70; g.TranslateTransform(400, y); g.DrawPath(pen, path); g.RestoreTransform(); } }
/// <summary> /// /// </summary> /// <param name="gfx"></param> /// <param name="brush"></param> /// <param name="pen"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="rect"></param> private static void DrawRectangleInternal( Graphics gfx, Brush brush, Pen pen, bool isStroked, bool isFilled, ref Rect2 rect) { if (isFilled) { gfx.FillRectangle( brush, (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); } if (isStroked) { gfx.DrawRectangle( pen, (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); } }
/// <summary> /// /// </summary> /// <param name="gfx"></param> /// <param name="stroke"></param> /// <param name="rect"></param> /// <param name="offsetX"></param> /// <param name="offsetY"></param> /// <param name="cellWidth"></param> /// <param name="cellHeight"></param> /// <param name="isStroked"></param> private void DrawGridInternal( Graphics gfx, Pen stroke, ref Rect2 rect, double offsetX, double offsetY, double cellWidth, double cellHeight, bool isStroked) { double ox = rect.X; double oy = rect.Y; double sx = ox + offsetX; double sy = oy + offsetY; double ex = ox + rect.Width; double ey = oy + rect.Height; for (double x = sx; x < ex; x += cellWidth) { var p0 = new PointF( _scaleToPage(x), _scaleToPage(oy)); var p1 = new PointF( _scaleToPage(x), _scaleToPage(ey)); DrawLineInternal(gfx, stroke, isStroked, ref p0, ref p1); } for (double y = sy; y < ey; y += cellHeight) { var p0 = new PointF( _scaleToPage(ox), _scaleToPage(y)); var p1 = new PointF( _scaleToPage(ex), _scaleToPage(y)); DrawLineInternal(gfx, stroke, isStroked, ref p0, ref p1); } }
public void SetLineJoin(Pen widget, PenLineJoin lineJoin) { widget.ToAndroid().StrokeJoin = lineJoin.ToAndroid(); }
public Color GetColor(Pen widget) { throw new NotImplementedException(); }
public PenLineCap GetLineCap(Pen widget) { return widget.ToAndroid().StrokeCap.ToEto(); }
public float GetThickness(Pen widget) { throw new NotImplementedException(); }
public void SetLineCap(Pen widget, PenLineCap lineCap) { var pen = widget.ToAndroid(); pen.StrokeCap = lineCap.ToSD(); SetDashStyle(widget, widget.DashStyle); }
public PenLineJoin GetLineJoin(Pen widget) { throw new NotImplementedException(); }
public float GetMiterLimit(Pen widget) { return widget.ToAndroid().StrokeMiter; }
public PenLineCap GetLineCap(Pen widget) { throw new NotImplementedException(); }
public void SetMiterLimit(Pen widget, float miterLimit) { widget.ToAndroid().StrokeMiter = miterLimit; }
public float GetMiterLimit(Pen widget) { throw new NotImplementedException(); }
public void SetDashStyle(Pen widget, DashStyle dashStyle) { var pen = widget.ToAndroid(); if (dashStyle == null || dashStyle.IsSolid) pen.SetPathEffect(null); else { // TODO: create a new ag.DashPathEffect with the appropriate intervals throw new NotImplementedException(); } }
public void SetDashStyle(Pen widget, DashStyle dashStyle) { throw new NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="gfx"></param> /// <param name="pen"></param> /// <param name="isStroked"></param> /// <param name="p0"></param> /// <param name="p1"></param> private static void DrawLineInternal( Graphics gfx, Pen pen, bool isStroked, ref PointF p0, ref PointF p1) { if (isStroked) { gfx.DrawLine(pen, p0, p1); } }