Esempio n. 1
0
		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;
		}
Esempio n. 2
0
		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;
		}
Esempio n. 3
0
		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));
			});
		}
Esempio n. 4
0
		public void SetColor(SolidBrush widget, Color color)
		{
			var brush = ((SolidBrushData)widget.ControlObject);
			brush.Reset();
			brush.Color = color;
		}
Esempio n. 5
0
		public Color GetColor(SolidBrush widget)
		{
			return ((SolidBrushData)widget.ControlObject).Color;
		}
Esempio n. 6
0
		/// <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);
		}
Esempio n. 7
0
		public Color GetColor (SolidBrush widget)
		{
			return ((Cairo.Color)widget.ControlObject).ToEto ();
		}
Esempio n. 8
0
		/// <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);
		}
Esempio n. 9
0
        /// <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);
            }
        }
Esempio n. 10
0
		/// <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);
		}
Esempio n. 11
0
		/// <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);
		}
Esempio n. 12
0
		/// <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);
		}
Esempio n. 13
0
		/// <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);			
		}
Esempio n. 14
0
		/// <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);
		}
Esempio n. 15
0
		/// <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);
		}
Esempio n. 16
0
		/// <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);
		}
Esempio n. 17
0
		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();
		}
Esempio n. 18
0
		public DirectDrawingRenderer(Generator generator = null)
		{
			Generator = generator ?? Generator.Current;
			texture = TestIcons.Textures(generator);
			font = SystemFonts.Default(generator: generator);
			textBrush = new SolidBrush(Colors.White, generator);
		}
Esempio n. 19
0
		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);
		}
Esempio n. 20
0
		public void Clear(SolidBrush brush)
		{
			throw new NotImplementedException();
		}
Esempio n. 21
0
 /// <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();
 }
Esempio n. 22
0
		public Color GetColor (SolidBrush widget)
		{
			return ((swm.SolidColorBrush)widget.ControlObject).Color.ToEto ();
		}
Esempio n. 23
0
		public void DrawText(Font font, SolidBrush brush, float x, float y, string text)
		{
			throw new NotImplementedException();
		}
Esempio n. 24
0
		/// <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);
		}
Esempio n. 25
0
		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);
			};
		}
Esempio n. 26
0
		public Color GetColor(SolidBrush widget)
		{
			return ((ag.Paint)widget.ControlObject).Color.ToEto();
		}
Esempio n. 27
0
		public void SetColor (SolidBrush widget, Color color)
		{
			((swm.SolidColorBrush)widget.ControlObject).Color = color.ToWpf ();
		}
Esempio n. 28
0
		public void SetColor(SolidBrush widget, Color color)
		{
			throw new NotImplementedException();
		}
Esempio n. 29
0
		public void SetColor (SolidBrush widget, Color color)
		{
			widget.ControlObject = color.ToCairo ();
		}
Esempio n. 30
0
		/// <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);
		}