Example #1
0
		public GetPixelSection()
		{
			var location = new Point(100, 100);
			var image = TestIcons.Textures;
			var drawable = new BufferedDrawable { EnableDoubleBuffering = true };
			this.Content = drawable;

			EventHandler<MouseEventArgs> mouseHandler = (s, e) =>
			{
				location = new Point(e.Location);
				((Control)s).Invalidate();
				e.Handled = true;
			};

			drawable.MouseMove += mouseHandler;
			drawable.MouseDown += mouseHandler;

			var font = SystemFonts.Default();
			drawable.BackgroundColor = Colors.Green;
			drawable.Paint += (s, e) =>
			{
				var graphics = e.Graphics;
				var imageLocation = new PointF(100, 100);
				graphics.DrawText(font, Colors.White, 3, 3, "Move the mouse in this area to read the pixel color.");
				graphics.DrawImage(image, imageLocation);

				var loc = location - (Point)imageLocation;
				loc.Restrict(new Rectangle(image.Size));
				var pixelColor = image.GetPixel(loc.X, loc.Y);
				graphics.DrawText(font, Colors.White, 3, 20, "Color: " + pixelColor);
			};
		}
Example #2
0
        public TextureBrushesSection()
        {
            var image    = TestIcons.Textures;
            var drawable = new BufferedDrawable {
                Size = new Size(image.Size.Width, image.Size.Height * 10)
            };
            var layout = new DynamicLayout {
                DefaultSpacing = new Size(5, 5), Padding = new Padding(10)
            };

            layout.AddSeparateRow(null, drawable.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);
                    graphics.FillRectangle(brush, new RectangleF(image.Size));
                    graphics.TranslateTransform(0, image.Size.Height);
                    brush.Transform = temp;
                });
            }

            drawable.Paint += (s, e) =>
            {
                var graphics = e.Graphics;
                foreach (var renderer in renderers)
                {
                    renderer(graphics);
                }
            };
        }
Example #3
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);
            };
        }
Example #4
0
		public TextureBrushesSection()
		{
			var image = TestIcons.Textures;
			var drawable = new BufferedDrawable { Size = new Size(image.Size.Width, image.Size.Height * 10) };
            var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) };
			layout.AddSeparateRow(null, drawable.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);
					graphics.FillRectangle(brush, new RectangleF(image.Size));
					graphics.TranslateTransform(0, image.Size.Height);
					brush.Transform = temp;
				});
			}

			drawable.Paint += (s, e) =>
			{
				var graphics = e.Graphics;
				foreach (var renderer in renderers)
					renderer(graphics);
			};
		}
Example #5
0
        public GetPixelSection()
        {
            var location = new Point(100, 100);
            var image    = TestIcons.Textures;
            var drawable = new BufferedDrawable {
                EnableDoubleBuffering = true
            };

            this.Content = drawable;

            EventHandler <MouseEventArgs> mouseHandler = (s, e) =>
            {
                location = new Point(e.Location);
                ((Control)s).Invalidate();
                e.Handled = true;
            };

            drawable.MouseMove += mouseHandler;
            drawable.MouseDown += mouseHandler;

            var font = SystemFonts.Default();

            drawable.BackgroundColor = Colors.Green;
            drawable.Paint          += (s, e) =>
            {
                var graphics      = e.Graphics;
                var imageLocation = new PointF(100, 100);
                graphics.DrawText(font, Colors.White, 3, 3, "Move the mouse in this area to read the pixel color.");
                graphics.DrawImage(image, imageLocation);

                var loc = location - (Point)imageLocation;
                loc.Restrict(new Rectangle(image.Size));
                var pixelColor = image.GetPixel(loc.X, loc.Y);
                graphics.DrawText(font, Colors.White, 3, 20, "Color: " + pixelColor);
            };
        }
Example #6
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);
			};
		}