public TextureBrushesSection()
		{
			var layout = new DynamicLayout();
			for (var i = 0; i < 10; ++i)
			{
				var w = image.Size.Width / 3; // same as height
				var img = image;
				if (i > 0)
					img = img.Clone(new Rectangle((i - 1) % 3 * w, (i - 1) / 3 * w, w, w));

				var brush = new TextureBrush(img);
				var drawable = new Drawable { Size = image.Size * 2 };

				drawable.Paint += (s, e) => {
					var destRect = new RectangleF(new PointF(100, 100), image.Size);
					var temp = brush.Transform; // save state
					brush.Transform = Matrix.FromRotation(90);
					e.Graphics.TranslateTransform(destRect.Location);
					e.Graphics.FillRectangle(brush, new RectangleF(destRect.Size));
					brush.Transform = temp;
				};
				layout.AddRow(drawable);
			}
			layout.Add(null);
			Content = layout;
		}
		public TextureBrushesSection()
		{
			var image = TestIcons.Textures();
			var drawable = new Drawable { Size = new Size(image.Size.Width, image.Size.Height * 10) };
			var drawableTarget = new DrawableTarget(drawable);
			var layout = new DynamicLayout(new Padding(10));
			layout.AddSeparateRow(null, drawableTarget.Checkbox(), null);
			layout.Add(new Scrollable { Content = drawable });
			Content = layout;

			var renderers = new List<Action<Graphics>>();

			for (var i = 0; i < 10; ++i)
			{
				var w = image.Size.Width / 3; // same as height
				var img = image;
				if (i > 0)
					img = img.Clone(new Rectangle((i - 1) % 3 * w, (i - 1) / 3 * w, w, w));

				var brush = new TextureBrush(img);

				renderers.Add(graphics =>
				{
					var temp = brush.Transform; // save state
					brush.Transform = Matrix.FromRotation(90, Generator);
					graphics.FillRectangle(brush, new RectangleF(image.Size));
					graphics.TranslateTransform(0, image.Size.Height);
					brush.Transform = temp;
				});
			}

			drawable.Paint += (s, e) =>
			{
				var graphics = drawableTarget.BeginDraw(e);
				foreach (var renderer in renderers)
					renderer(graphics);
				drawableTarget.EndDraw(e);
			};
		}
		public TextureBrushesSection2()
		{
			var w = image.Size.Width / 3; // same as height
			var img = image.Clone(new Rectangle(w, w, w, w));
			var brush = new TextureBrush(img);
			var drawable = new Drawable();
			var font = new Font(SystemFont.Default);
			this.Content = drawable;
			var location = new PointF(100, 100);
			drawable.BackgroundColor = Colors.Green;
			drawable.MouseMove += (s, e) => {
				location = e.Location;
				drawable.Invalidate(); };
			drawable.Paint += (s, e) => {
				e.Graphics.DrawText(font, Colors.White, 3, 3, "Move the mouse in this area to move the image.");

				var temp = brush.Transform; // save state					
				brush.Transform = Matrix.FromTranslation(location);
				e.Graphics.FillRectangle(brush, new RectangleF(location, img.Size));
				brush.Transform = temp;
			};
		}
		public void SetOpacity (TextureBrush widget, float opacity)
		{
			((swm.ImageBrush)widget.ControlObject).Opacity = opacity;
		}
		public void SetTransform (TextureBrush widget, IMatrix transform)
		{
			((swm.ImageBrush)widget.ControlObject).Transform = transform.ToWpfTransform ();
		}
		public IMatrix GetTransform (TextureBrush widget)
		{
			return ((swm.ImageBrush)widget.ControlObject).Transform.ToEtoMatrix ();
		}
Beispiel #7
0
		public void SetOpacity(TextureBrush widget, float opacity)
		{
			var brush = (TextureBrushData)widget.ControlObject;
			brush.Alpha = opacity;
		}
Beispiel #8
0
		public void SetTransform(TextureBrush widget, IMatrix transform)
		{
			var brush = (TextureBrushData)widget.ControlObject;
			brush.Transform = transform;
		}
Beispiel #9
0
		public IMatrix GetTransform(TextureBrush widget)
		{
			var brush = (TextureBrushData)widget.ControlObject;
			return brush.Transform;
		}
Beispiel #10
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);
			};
		}
		public float GetOpacity (TextureBrush widget)
		{
			return ((TextureBrushObject)widget.ControlObject).Opacity;
		}
		public void SetTransform (TextureBrush widget, IMatrix transform)
		{
			((TextureBrushObject)widget.ControlObject).Transform = transform.ToCairo ();
		}
		public IMatrix GetTransform (TextureBrush widget)
		{
			return ((TextureBrushObject)widget.ControlObject).Transform.ToEto ();
		}