Exemple #1
0
		public BrushSection()
		{
			var layout = new DynamicLayout();
			brush = solidBrush = Brushes.LightSkyBlue;
			gradientBrush = new LinearGradientBrush(Colors.AliceBlue, Colors.Black, new PointF(0, 0), new PointF(100f, 100f));
			//gradientBrush = new LinearGradientBrush (new RectangleF (0, 0, 50, 50), Colors.AliceBlue, Colors.Black, 10);
			gradientBrush.Wrap = GradientWrapMode.Repeat;
			textureBrush = new TextureBrush(image, 0.5f);
			brush = textureBrush;

			ScaleX = 100f;
			ScaleY = 100f;

			drawable = new Drawable { Size = new Size(300, 200) };

			drawable.Paint += (sender, pe) => Draw(pe.Graphics);

			layout.AddSeparateRow(null, BrushControl(), UseBackgroundColorControl(), null);
			if (Platform.Supports<NumericUpDown>())
			{
				matrixRow = layout.AddSeparateRow(null, new Label { Text = "Rot" }, RotationControl(), new Label { Text = "Sx" }, ScaleXControl(), new Label { Text = "Sy" }, ScaleYControl(), new Label { Text = "Ox" }, OffsetXControl(), new Label { Text = "Oy" }, OffsetYControl(), null);
				matrixRow.Table.Visible = false;
			}
			gradientRow = layout.AddSeparateRow(null, GradientWrapControl(), null);
			gradientRow.Table.Visible = false;
			layout.AddSeparateRow(null, drawable, null);
			layout.Add(null);

			this.Content = layout;
		}
			public Box (Size canvasSize, bool useTexturesAndGradients)
			{
				var size = new SizeF(random.Next (50) + 50, random.Next (50) + 50);
				var location = new PointF(random.Next (canvasSize.Width - (int)size.Width), random.Next (canvasSize.Height - (int)size.Height));
				position = new RectangleF(location, size);
				increment = new SizeF (random.Next (3) + 1, random.Next (3) + 1);
				if (random.Next (2) == 1)
					increment.Width = -increment.Width;
				if (random.Next (2) == 1)
					increment.Height = -increment.Height;

				angle = random.Next (360);
				rotation = (random.Next (20) - 10f) / 4f;

				var rect = new RectangleF (size);
				color = GetRandomColor (random);
				switch (random.Next (useTexturesAndGradients ? 4 : 2)) {
				case 0:
					draw = (g) => g.DrawRectangle (color, rect);
					erase = (g) => g.DrawRectangle (Colors.Black, rect);
					break;
				case 1:
					draw = (g) => g.DrawEllipse (color, rect);
					erase = (g) => g.DrawEllipse (Colors.Black, rect);
					break;
				case 2:
					switch (random.Next (2)) {
					case 0:
						fillBrush = new LinearGradientBrush (GetRandomColor (random), GetRandomColor (random), PointF.Empty, new PointF(size.Width, size.Height));
						break;
					case 1:
						fillBrush = new TextureBrush(texture) {
							Transform = Matrix.FromScale (size / 80)
						};
						break;
					}
					draw = (g) => g.FillEllipse (fillBrush, rect);
					erase = (g) => g.FillEllipse (Colors.Black, rect);
					break;
				case 3:
					switch (random.Next (2)) {
					case 0:
						fillBrush = new LinearGradientBrush (GetRandomColor (random), GetRandomColor (random), PointF.Empty, new PointF(size.Width, size.Height));
						break;
					case 1:
						fillBrush = new TextureBrush(texture) {
							Transform = Matrix.FromScale (size / 80)
						};
						break;
					}
					draw = (g) => g.FillRectangle (fillBrush, rect);
					erase = (g) => g.FillRectangle (Colors.Black, rect);
					break;
				}
			}
Exemple #3
0
		public void FillEllipse(Brush brush, float x, float y, float width, float height)
		{
			SetOffset(true);
			StartDrawing();
			/*	if (width == 1 || height == 1)
			{
				DrawLine(color, x, y, x+width-1, y+height-1);
				return;
			}*/
			var rect = new CGRect(x, y, width, height);
			Control.AddEllipseInRect(rect);
			Control.Clip();
			brush.Draw(this, rect.ToEto());
			EndDrawing();
		}
Exemple #4
0
		public void FillRectangle(Brush brush, float x, float y, float width, float height)
		{
			SetOffset(true);
			StartDrawing();
			var rect = new CGRect(x, y, width, height);
			Control.AddRect(rect);
			Control.Clip();
			brush.Draw(this, rect.ToEto());
			EndDrawing();
		}
Exemple #5
0
		void SetItem(BrushItem item)
		{
			brush = item.Brush;
			if (matrixRow != null)
				matrixRow.Table.Visible = item.SupportsMatrix;
			gradientRow.Table.Visible = item.SupportsGradient;
		}
Exemple #6
0
 public void Create(Brush brush)
 {
     throw new NotImplementedException();
 }
Exemple #7
0
		void DrawShapes(Brush brush, PointF location, Size size, Graphics g)
		{
			g.SaveTransform();
			g.TranslateTransform(location);
			g.RotateTransform(20);

			// rectangle
			g.FillRectangle(brush, new RectangleF(size));

			// ellipse
			g.TranslateTransform(0, size.Height + 20);
			g.FillEllipse(brush, new RectangleF(size));

			// pie
			g.TranslateTransform(0, size.Height + 20);
			g.FillPie(brush, new RectangleF(new SizeF(size.Width * 2, size.Height)), 0, 360);

			// polygon
			g.TranslateTransform(0, size.Height + 20);
			var polygon = GetPolygon();
			g.FillPolygon(brush, polygon);

			g.RestoreTransform();
		}
Exemple #8
0
		public void FillPath(Brush brush, IGraphicsPath path)
		{
			throw new NotImplementedException();
		}
Exemple #9
0
		public void FillEllipse(Brush brush, float x, float y, float width, float height)
		{
			throw new NotImplementedException();
		}
Exemple #10
0
		/// <summary>
		/// Fills a pie with the specified <paramref name="brush"/>
		/// </summary>
		/// <param name="brush">Brush to fill the pie</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 (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
		{
			Handler.FillPie (brush, x, y, width, height, startAngle, sweepAngle);
		}
Exemple #11
0
		/// <summary>
		/// Fills a pie with the specified <paramref name="brush"/>
		/// </summary>
		/// <param name="brush">Brush to fill the pie</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 (Brush brush, RectangleF rectangle, float startAngle, float sweepAngle)
		{
			Handler.FillPie (brush, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, startAngle, sweepAngle);
		}
Exemple #12
0
		/// <summary>
		/// Fills an ellipse with the specified <paramref name="brush"/>
		/// </summary>
		/// <param name="brush">Brush to fill the ellipse</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 (Brush brush, float x, float y, float width, float height)
		{
			Handler.FillEllipse (brush, x, y, width, height);
		}
Exemple #13
0
		/// <summary>
		/// Fills an ellipse with the specified <paramref name="brush"/>
		/// </summary>
		/// <param name="brush">Brush to fill the ellipse</param>
		/// <param name="rectangle">Location for the ellipse</param>
		public void FillEllipse (Brush brush, RectangleF rectangle)
		{
			Handler.FillEllipse (brush, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
		}
Exemple #14
0
		/// <summary>
		/// Fills the specified <paramref name="rectangles"/>
		/// </summary>
		/// <param name="brush">Brush to fill the rectangles</param>
		/// <param name="rectangles">Enumeration of rectangles to fill</param>
		public void FillRectangles (Brush brush, IEnumerable<RectangleF> rectangles)
		{
			foreach (var rectangle in rectangles) {
				Handler.FillRectangle (brush, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
			}
		}
Exemple #15
0
		/// <summary>
		/// Fills a rectangle with the specified <paramref name="brush"/>
		/// </summary>
		/// <param name="brush">Brush to fill the rectangle</param>
		/// <param name="x">X co-ordinate</param>
		/// <param name="y">Y co-ordinate</param>
		/// <param name="width">Width of the rectangle</param>
		/// <param name="height">Height of the rectangle</param>
		public void FillRectangle (Brush brush, float x, float y, float width, float height)
		{
			Handler.FillRectangle (brush, x, y, width, height);
		}
Exemple #16
0
		public void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
		{
			SetOffset(true);
			StartDrawing();

			var rect = new CGRect(x, y, width, height);
			Control.SaveState();
			var yscale = rect.Height / rect.Width;
			var centerY = rect.GetMidY();
			var centerX = rect.GetMidX();
			Control.ConcatCTM(new CGAffineTransform(1.0f, 0, 0, yscale, 0, centerY - centerY * yscale));
			Control.MoveTo(centerX, centerY);
			Control.AddArc(centerX, centerY, rect.Width / 2, CGConversions.DegreesToRadians(startAngle), CGConversions.DegreesToRadians(startAngle + sweepAngle), sweepAngle < 0);
			Control.AddLineToPoint(centerX, centerY);
			Control.ClosePath();
			Control.RestoreState();
			Control.Clip();
			brush.Draw(this, rect.ToEto());
			EndDrawing();
		}
Exemple #17
0
		public void FillPath(Brush brush, IGraphicsPath path)
		{
			SetOffset(true);
			StartDrawing();

			Control.BeginPath();
			Control.AddPath(path.ToCG());
			Control.ClosePath();
			switch (path.FillMode)
			{
				case FillMode.Alternate:
					Control.EOClip();
					break;
				case FillMode.Winding:
					Control.Clip();
					break;
				default:
					throw new NotSupportedException();
			}
			brush.Draw(this, path.Bounds);
			EndDrawing();
		}
Exemple #18
0
		/// <summary>
		/// Fills a polygon defined by <paramref name="points"/> with the specified <paramref name="brush"/>
		/// </summary>
		/// <param name="brush">Brush to fill the polygon</param>
		/// <param name="points">Points of the polygon</param>
		public void FillPolygon (Brush brush, params PointF[] points)
		{
			var path = new GraphicsPath (Generator);
			path.AddLines (points);
			FillPath (brush, path);
		}
Exemple #19
0
		public void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
		{
			throw new NotImplementedException();
		}
Exemple #20
0
		/// <summary>
		/// Fills the specified <paramref name="path"/>
		/// </summary>
		/// <param name="brush">Brush to fill the path</param>
		/// <param name="path">Path to fill</param>
		public void FillPath (Brush brush, GraphicsPath path)
		{
			Handler.FillPath (brush, path);
		}
Exemple #21
0
		public abstract ag.Paint GetPaint(Brush brush);
Exemple #22
0
			public Box(Size canvasSize, bool useTexturesAndGradients, DirectDrawingRenderer renderer)
			{
				this.renderer = renderer;
				var size = new SizeF(random.Next(50) + 50, random.Next(50) + 50);
				var location = new PointF(random.Next(canvasSize.Width - (int)size.Width), random.Next(canvasSize.Height - (int)size.Height));
				position = new RectangleF(location, size);
				increment = new SizeF(random.Next(3) + 1, random.Next(3) + 1);
				if (random.Next(2) == 1)
					increment.Width = -increment.Width;
				if (random.Next(2) == 1)
					increment.Height = -increment.Height;

				angle = random.Next(360);
				rotation = (random.Next(20) - 10f) / 4f;

				var rect = new RectangleF(size);
				color = GetRandomColor(random);
				var colorPen = new Pen(color, generator: renderer.Generator);
				var blackPen = Pens.Black(renderer.Generator);
				var blackBrush = Brushes.Black(renderer.Generator);
				switch (random.Next(useTexturesAndGradients ? 4 : 2))
				{
					case 0:
						draw = g => g.DrawRectangle(colorPen, rect);
						erase = g => g.DrawRectangle(blackPen, rect);
						break;
					case 1:
						draw = g => g.DrawEllipse(colorPen, rect);
						erase = g => g.DrawEllipse(blackPen, rect);
						break;
					case 2:
						switch (random.Next(2))
						{
							case 0:
								fillBrush = new LinearGradientBrush(GetRandomColor(random), GetRandomColor(random), PointF.Empty, new PointF(size.Width, size.Height), renderer.Generator);
								break;
							case 1:
								fillBrush = new TextureBrush(renderer.texture, 1f, renderer.Generator)
								{
									Transform = Matrix.FromScale(size / 80, renderer.Generator)
								};
								break;
						}
						draw = g => g.FillEllipse(fillBrush, rect);
						erase = g => g.FillEllipse(blackBrush, rect);
						break;
					case 3:
						switch (random.Next(2))
						{
							case 0:
								fillBrush = new LinearGradientBrush(GetRandomColor(random), GetRandomColor(random), PointF.Empty, new PointF(size.Width, size.Height), renderer.Generator);
								break;
							case 1:
								fillBrush = new TextureBrush(renderer.texture, 1f, renderer.Generator)
								{
									Transform = Matrix.FromScale(size / 80, renderer.Generator)
								};
								break;
						}
						draw = g => g.FillRectangle(fillBrush, rect);
						erase = g => g.FillRectangle(blackBrush, rect);
						break;
				}
			}
Exemple #23
0
        /// <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);
            }
        }
		public override ag.Paint GetPaint(Brush brush)
		{
			return ((BrushObject)brush.ControlObject).Paint;
		}
Exemple #25
0
		void Refresh()
		{
			if (selectedItem != null)
				brush = selectedItem.CreateBrush();
			drawable.Invalidate();
		}
Exemple #26
0
		void SetItem(BrushItem item)
		{
			this.brush = item.Brush;
			matrixRow.Table.Visible = item.SupportsMatrix;
			gradientRow.Table.Visible = item.SupportsGradient;
		}