static Brush GetBrush (Color color, Generator generator) { var cache = generator.Cache<BrushKey, Brush>(cacheKey); Brush brush; lock (cache) { var key = new BrushKey (color.ToArgb ()); if (!cache.TryGetValue (key, out brush)) { brush = new SolidBrush (color, generator); cache.Add (key, brush); } } return brush; }
static SolidBrush GetBrush (Color color) { var cache = Platform.Instance.Cache<BrushKey, SolidBrush>(cacheKey); SolidBrush brush; lock (cache) { var key = new BrushKey (color.ToArgb ()); if (!cache.TryGetValue (key, out brush)) { brush = new SolidBrush (color); cache.Add (key, brush); } } return brush; }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { if (graphics == null) return; var clipRect = e.ClipRectangle.ToEto(); graphicsHandler.PerformDrawing(clipRect, () => { // clear to control's background color if (backgroundColor == null) backgroundColor = new SolidBrush(base.BackgroundColor, Generator); graphics.Clear(backgroundColor); // perform user painting Widget.OnPaint(new PaintEventArgs(graphics, clipRect)); }); }
public void SetColor(SolidBrush widget, Color color) { var brush = ((SolidBrushData)widget.ControlObject); brush.Reset(); brush.Color = color; }
public Color GetColor(SolidBrush widget) { return ((SolidBrushData)widget.ControlObject).Color; }
/// <summary> /// Fills an ellipse with the specified <paramref name="color"/> /// </summary> /// <param name="color">Fill color</param> /// <param name="rectangle">Location for the ellipse</param> public void FillEllipse (Color color, RectangleF rectangle) { using (var brush = new SolidBrush (color, Generator)) Handler.FillEllipse (brush, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); }
public Color GetColor (SolidBrush widget) { return ((Cairo.Color)widget.ControlObject).ToEto (); }
/// <summary> /// Fills a pie with the specified <paramref name="color"/> /// </summary> /// <param name="color">Fill color</param> /// <param name="rectangle">Location of the pie</param> /// <param name="startAngle">Elliptical (skewed) angle in degrees from the x-axis to the starting point of the pie</param> /// <param name="sweepAngle">Angle in degrees from the <paramref name="startAngle"/> to the ending point of the pie</param> public void FillPie (Color color, RectangleF rectangle, float startAngle, float sweepAngle) { using (var brush = new SolidBrush (color, Generator)) Handler.FillPie (brush, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, startAngle, sweepAngle); }
/// <summary> /// /// </summary> /// <param name="g"></param> private void Draw(Graphics g) { g.AntiAlias = false; g.PixelOffsetMode = PixelOffsetMode.Half; g.TranslateTransform(_state.PanX, _state.PanY); g.ScaleTransform(_state.Zoom); var brush = new SolidBrush(_background); g.Clear(brush); brush.Dispose(); var renderer = _context.Editor.Renderers[0]; if (_context.Editor.Project == null) return; var container = _context.Editor.Project.CurrentContainer; if (container.Template != null) { DrawBackground( g, container.Template.Background, container.Width, container.Height); renderer.Draw( g, container.Template, container.Properties, null); } DrawBackground( g, container.Background, container.Width, container.Height); renderer.Draw( g, container, container.Properties, null); if (container.WorkingLayer != null) { renderer.Draw( g, container.WorkingLayer, container.Properties, null); } if (container.HelperLayer != null) { renderer.Draw( g, container.HelperLayer, container.Properties, null); } }
/// <summary> /// Draws text with the specified <paramref name="font"/>, <paramref name="brush"/> and location /// </summary> /// <param name="font">Font to draw the text with</param> /// <param name="brush">Brush to stroke the text</param> /// <param name="location">Location of where to start drawing the text</param> /// <param name="text">Text string to draw</param> public void DrawText (Font font, SolidBrush brush, PointF location, string text) { Handler.DrawText (font, brush, location.X, location.Y, text); }
/// <summary> /// Draws text with the specified <paramref name="font"/>, <paramref name="color"/> and location /// </summary> /// <param name="font">Font to draw the text with</param> /// <param name="color">Color of the text</param> /// <param name="location">Location of where to start drawing the text</param> /// <param name="text">Text string to draw</param> public void DrawText(Font font, Color color, PointF location, string text) { using (var brush = new SolidBrush(color, Generator)) Handler.DrawText(font, brush, location.X, location.Y, text); }
/// <summary> /// Draws text with the specified <paramref name="font"/>, <paramref name="brush"/> and location /// </summary> /// <param name="font">Font to draw the text with</param> /// <param name="brush">Brush to stroke the text</param> /// <param name="x">X co-ordinate of where to start drawing the text</param> /// <param name="y">Y co-ordinate of where to start drawing the text</param> /// <param name="text">Text string to draw</param> public void DrawText (Font font, SolidBrush brush, float x, float y, string text) { Handler.DrawText (font, brush, x, y, text); }
/// <summary> /// Draws text with the specified <paramref name="font"/>, <paramref name="color"/> and location /// </summary> /// <param name="font">Font to draw the text with</param> /// <param name="color">Color of the text</param> /// <param name="x">X co-ordinate of where to start drawing the text</param> /// <param name="y">Y co-ordinate of where to start drawing the text</param> /// <param name="text">Text string to draw</param> public void DrawText(Font font, Color color, float x, float y, string text) { using (var brush = new SolidBrush(color, Generator)) Handler.DrawText(font, brush, x, y, text); }
/// <summary> /// Fills the specified <paramref name="path"/> /// </summary> /// <param name="color">Fill color</param> /// <param name="path">Path to fill</param> public void FillPath (Color color, GraphicsPath path) { using (var brush = new SolidBrush (color, Generator)) Handler.FillPath (brush, path); }
/// <summary> /// Fills a polygon defined by <paramref name="points"/> with the specified <paramref name="color"/> /// </summary> /// <param name="color">Fill color</param> /// <param name="points">Points of the polygon</param> public void FillPolygon (Color color, params PointF[] points) { var path = new GraphicsPath (Generator); path.AddLines (points); using (var brush = new SolidBrush (color, Generator)) FillPath (brush, path); }
/// <summary> /// Fills a pie with the specified <paramref name="color"/> /// </summary> /// <param name="color">Fill color</param> /// <param name="x">X co-ordinate of the upper left corner of the pie</param> /// <param name="y">Y co-ordinate of the upper left corner of the pie</param> /// <param name="width">Width of the pie</param> /// <param name="height">Height of the pie</param> /// <param name="startAngle">Elliptical (skewed) angle in degrees from the x-axis to the starting point of the pie</param> /// <param name="sweepAngle">Angle in degrees from the <paramref name="startAngle"/> to the ending point of the pie</param> public void FillPie (Color color, float x, float y, float width, float height, float startAngle, float sweepAngle) { using (var brush = new SolidBrush (color, Generator)) Handler.FillPie (brush, x, y, width, height, startAngle, sweepAngle); }
public void DrawText(Font font, SolidBrush brush, float x, float y, string text) { SetOffset(true); if (string.IsNullOrEmpty(text)) return; StartDrawing(); FontExtensions.DrawString(text, new PointF(x, y), brush.Color, font); EndDrawing(); }
public DirectDrawingRenderer(Generator generator = null) { Generator = generator ?? Generator.Current; texture = TestIcons.Textures(generator); font = SystemFonts.Default(generator: generator); textBrush = new SolidBrush(Colors.White, generator); }
public void Clear(SolidBrush brush) { var rect = Control.GetClipBoundingBox(); Control.ClearRect(rect); if (brush != null) FillRectangle(brush, (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); }
public void Clear(SolidBrush brush) { throw new NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="g"></param> /// <param name="c"></param> /// <param name="width"></param> /// <param name="height"></param> private void DrawBackground(Graphics g, Test2d.ArgbColor c, double width, double height) { var color = Color.FromArgb(c.R, c.G, c.B, c.A); var brush = new SolidBrush(color); var rect = Test2d.Rect2.Create(0, 0, width, height); g.FillRectangle( brush, (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); brush.Dispose(); }
public Color GetColor (SolidBrush widget) { return ((swm.SolidColorBrush)widget.ControlObject).Color.ToEto (); }
public void DrawText(Font font, SolidBrush brush, float x, float y, string text) { throw new NotImplementedException(); }
/// <summary> /// Fills an ellipse with the specified <paramref name="color"/> /// </summary> /// <param name="color">Fill color</param> /// <param name="x">X co-ordinate</param> /// <param name="y">Y co-ordinate</param> /// <param name="width">Width of the ellipse</param> /// <param name="height">Height of the ellipse</param> public void FillEllipse (Color color, float x, float y, float width, float height) { using (var brush = new SolidBrush (color, Generator)) Handler.FillEllipse (brush, x, y, width, height); }
public TextureBrushesSection2() { image = TestIcons.Textures; var drawable = new BufferedDrawable(); var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; layout.AddSeparateRow(null, drawable.Checkbox(), null); layout.Add(drawable); this.Content = layout; var w = image.Size.Width / 3; // same as height var img = image.Clone(new Rectangle(w, w, w, w)); var textureBrush = new TextureBrush(img); var solidBrush = new SolidBrush(Colors.Blue); var linearGradientBrush = new LinearGradientBrush(Colors.White, Colors.Black, PointF.Empty, new PointF(0, 100)); var font = SystemFonts.Default(); drawable.BackgroundColor = Colors.Green; drawable.MouseMove += HandleMouseMove; drawable.MouseDown += HandleMouseMove; drawable.Paint += (s, e) => { var graphics = e.Graphics; graphics.DrawText(font, Colors.White, 3, 3, "Move the mouse in this area to move the shapes."); // texture brushes var temp = location; DrawShapes(textureBrush, temp, img.Size, graphics); // solid brushes temp = temp + new PointF(200, 0); DrawShapes(solidBrush, temp, img.Size, graphics); // linear gradient brushes temp = temp + new PointF(200, 0); DrawShapes(linearGradientBrush, temp, img.Size, graphics); }; }
public Color GetColor(SolidBrush widget) { return ((ag.Paint)widget.ControlObject).Color.ToEto(); }
public void SetColor (SolidBrush widget, Color color) { ((swm.SolidColorBrush)widget.ControlObject).Color = color.ToWpf (); }
public void SetColor(SolidBrush widget, Color color) { throw new NotImplementedException(); }
public void SetColor (SolidBrush widget, Color color) { widget.ControlObject = color.ToCairo (); }
/// <summary> /// Fills the specified <paramref name="rectangles"/> /// </summary> /// <param name="color">Color to fill the rectangles</param> /// <param name="rectangles">Enumeration of rectangles to fill</param> public void FillRectangles (Color color, IEnumerable<RectangleF> rectangles) { using (var brush = new SolidBrush (color, Generator)) FillRectangles (brush, rectangles); }