Ejemplo n.º 1
0
		Control PathClip()
		{
			var control = new Drawable { Size = new Size(350, 250) };
			control.Paint += (sender, e) =>
			{
				var path = new GraphicsPath();
				path.AddEllipse(25, 25, 50, 50);
				path.AddRectangle(125, 25, 50, 50);
				path.AddLines(new PointF(225, 25), new PointF(225, 75), new PointF(275, 50));
				path.CloseFigure();

				e.Graphics.SetClip(path);
				if (ResetClip)
					e.Graphics.ResetClip();
				e.Graphics.FillRectangle(Brushes.Blue, path.Bounds);

				path.Transform(Matrix.FromTranslation(0, 75));
				e.Graphics.SetClip(path);
				if (ResetClip)
					e.Graphics.ResetClip();
				e.Graphics.FillRectangle(Brushes.Red, path.Bounds);

				path.Transform(Matrix.FromTranslation(0, 75));
				e.Graphics.SetClip(path);
				if (ResetClip)
					e.Graphics.ResetClip();
				e.Graphics.FillRectangle(Brushes.Green, path.Bounds);
			};
			PropertyChanged += (sender, e) =>
			{
				if (e.PropertyName == "ResetClip")
					control.Invalidate();
			};
			return control;
		}