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;
		}
Example #2
0
		public void Restrict(RectangleF rectangle)
		{
			if (Left < rectangle.Left) Left = rectangle.Left;
			if (Top < rectangle.Top) Top = rectangle.Top;
			if (Right > rectangle.Right) Right = rectangle.Right;
			if (Bottom > rectangle.Bottom) Bottom = rectangle.Bottom;
		}
Example #3
0
        public RectangleF ToImageCoordinate(RectangleF pictureBoxRect)
        {
            var upperLeft = ToPictureBoxCoordinate(pictureBoxRect.Location);
            var bottomRight = ToPictureBoxCoordinate(new PointF(pictureBoxRect.Right, pictureBoxRect.Bottom));

            return RectangleF.FromSides(upperLeft.X, upperLeft.Y, bottomRight.X, bottomRight.Y);
        }
			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;
				}
			}
		public object Create (RectangleF rectangle, Color startColor, Color endColor, float angle)
		{
			var matrix = swm.Matrix.Identity;
			var startPoint = rectangle.Location.ToWpf ();
			matrix.RotateAtPrepend (angle - 45, startPoint.X, startPoint.Y);
			var endPoint = matrix.Transform (rectangle.EndLocation.ToWpf ());
			return new swm.LinearGradientBrush (startColor.ToWpf (), endColor.ToWpf (), startPoint, endPoint) {
				MappingMode = swm.BrushMappingMode.Absolute,
				SpreadMethod = swm.GradientSpreadMethod.Repeat
			};
		}
Example #6
0
		public static void Draw(Graphics graphics)
		{
			var generator = graphics.Generator;
			var image = TestIcons.TestImage(generator);
			// lines
			var whitePen = Pens.White(generator);
			graphics.DrawLine(whitePen, 1, 1, 99, 99);
			graphics.DrawLine(whitePen, 50, 1, 50, 99);
			graphics.DrawLine(whitePen, 1, 51, 99, 51);

			graphics.DrawRectangle(Pens.White(generator), 101, 1, 100, 100);
			graphics.DrawRectangle(Pens.White(generator), 101, 1, 10, 10);

			graphics.DrawEllipse(Pens.Green(generator), 101, 1, 100, 100);

			graphics.DrawPolygon(Pens.White(generator), new PointF(203, 1), new PointF(253, 51), new Point(203, 101), new PointF(203, 1), new PointF(253, 1), new PointF(253, 101), new PointF(203, 101));

			var rect = new RectangleF(255, 1, 100, 100);
			graphics.DrawArc(Pens.LightGreen(generator), rect, 180, 90);
			graphics.DrawArc(Pens.SkyBlue(generator), rect, 0, 90);
			rect.Inflate(-15, 0);
			graphics.DrawArc(Pens.FloralWhite(generator), rect, -45, 90);
			rect.Inflate(-5, -20);
			graphics.DrawArc(Pens.SlateGray(generator), rect, -45, 270);
			rect.Inflate(-10, -10);
			graphics.DrawArc(Pens.SteelBlue(generator), rect, 180 + 45, 270);

			graphics.DrawImage(image, 100, 1, 100, 100);

			graphics.DrawText(Fonts.Sans(12 * graphics.PointsPerPixel, generator: generator), Colors.White, 0, 104, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");

			// filled
			graphics.FillRectangle(Brushes.White(generator), 101, 120, 100, 100);
			graphics.FillRectangle(Brushes.Gray(generator), 101, 120, 10, 10);

			graphics.FillEllipse(Brushes.Green(generator), 101, 120, 100, 100);

			graphics.FillPolygon(Brushes.White(generator), new PointF(202, 120), new PointF(252, 170), new Point(202, 220), new PointF(202, 120));

			rect = new RectangleF(255, 120, 100, 100);
			graphics.FillPie(Brushes.LightGreen(generator), rect, 180, 90);
			graphics.FillPie(Brushes.SkyBlue(generator), rect, 0, 90);
			rect.Inflate(-15, 0);
			graphics.FillPie(Brushes.FloralWhite(generator), rect, -45, 90);
			rect.Inflate(-5, -20);
			graphics.FillPie(Brushes.SlateGray(generator), rect, -45, 270);
			rect.Inflate(-10, -10);
			graphics.FillPie(Brushes.SteelBlue(generator), rect, 180 + 45, 270);


			graphics.DrawImage(image, 101, 120, 100, 100);
		}
		public object Create(RectangleF rectangle, Color startColor, Color endColor, float angle)
		{
			var matrix = new MatrixHandler();
			var startPoint = rectangle.Location;
			matrix.RotateAt(angle - 45, startPoint.X, startPoint.Y);
			var endPoint = matrix.TransformPoint(rectangle.EndLocation);
			return new LinearBrushData
			{
				StartColor = startColor,
				EndColor = endColor,
				StartPoint = rectangle.Location,
				EndPoint = rectangle.EndLocation
			};
		}
Example #8
0
		public void ClipTest()
		{
			Assert.AreEqual("Verifying clipbounds size", (Size)Graphics.ClipBounds.Size, Drawable.ClientSize);
			
			// Clip to the upper-left quadrant
			var clipTo = Drawable.ClientSize / 2;
			Graphics.SetClip(new RectangleF(PointF.Empty, clipTo));

			// Translate to the bottom-right quadrant
			Graphics.TranslateTransform(new Point(clipTo));
						
			// Check that the clip region was correctly translated
			var clip = Graphics.ClipBounds;
			var expectedClip = new RectangleF(-new Point(clipTo), clipTo);
			Assert.AreEqual("Verifying clip after translation ", expectedClip, clip);
		}
Example #9
0
			public void Draw(GraphicsHandler graphics, RectangleF rect)
			{
				var context = graphics.Control;

				context.SaveState();
				context.ConcatCTM(transform);
				context.ConcatCTM(new CGAffineTransform(1, 0, 0, -1, 0, Image.Height));
				//transform.ToEto().TransformRectangle(rect);

				if (Opacity < 1f)
				{
					context.SetBlendMode(CGBlendMode.Normal);
					context.SetAlpha(Opacity);
				}
				context.DrawTiledImage(new CGRect(0, 0, Image.Width, Image.Height), Image);
				context.RestoreState();
			}
Example #10
0
		public void ClipRectangleShouldTranslate()
		{
			TestUtils.Paint((drawable, e) =>
			{
				var graphics = e.Graphics;
				// Clip to the upper-left quadrant
				var clipTo = drawable.ClientSize / 2;
				graphics.SetClip(new RectangleF(PointF.Empty, clipTo));

				// Translate to the bottom-right quadrant
				graphics.TranslateTransform(new Point(clipTo));

				// Check that the clip region was correctly translated
				var clip = graphics.ClipBounds;
				var expectedClip = new RectangleF(-new Point(clipTo), clipTo);
				Assert.AreEqual(Rectangle.Round(expectedClip), Rectangle.Round(clip), "Clip rectangle wasn't translated properly");
			});
		}
        private void PictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (!isDrawing || control.Image == null) return;

            var ptSecond = control.ToImageCoordinate(e.Location);

            rect = new RectangleF
            {
                X      = Math.Min(ptFirst.X, ptSecond.X),
                Y      = Math.Min(ptFirst.Y, ptSecond.Y),
                Width  = Math.Abs(ptFirst.X - ptSecond.X),
                Height = Math.Abs(ptFirst.Y - ptSecond.Y)
            };

            rect.Width = Math.Max(MIN_RECT_SIZE, rect.Width);
            rect.Height = Math.Max(MIN_RECT_SIZE, rect.Height);

            control.Invalidate();
        }
Example #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="style"></param>
        /// <param name="rect"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        private PointF GetTextOrigin(ShapeStyle style, ref RectangleF rect, ref SizeF size)
        {
            float ox, oy;

            switch (style.TextStyle.TextHAlignment)
            {
                case TextHAlignment.Left:
                    ox = rect.X;
                    break;
                case TextHAlignment.Right:
                    ox = rect.Right - size.Width;
                    break;
                case TextHAlignment.Center:
                default:
                    ox = (rect.Left + rect.Width / 2f) - (size.Width / 2f);
                    break;
            }

            switch (style.TextStyle.TextVAlignment)
            {
                case TextVAlignment.Top:
                    oy = rect.TopLeft.Y;
                    break;
                case TextVAlignment.Bottom:
                    oy = rect.Bottom - size.Height;
                    break;
                case TextVAlignment.Center:
                default:
                    oy = (rect.Bottom - rect.Height / 2f) - (size.Height / 2f);
                    break;
            }

            return new PointF(ox, oy);
        }
Example #13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="image"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="db"></param>
        /// <param name="r"></param>
        public void Draw(object gfx, XImage image, double dx, double dy, ImmutableArray<ShapeProperty> db, Record r)
        {
            var _gfx = gfx as Graphics;

            var rect = CreateRect(
                image.TopLeft,
                image.BottomRight,
                dx, dy);

            var srect = new RectangleF(
                _scaleToPage(rect.X),
                _scaleToPage(rect.Y),
                _scaleToPage(rect.Width),
                _scaleToPage(rect.Height));

            if (image.IsFilled)
            {
                Brush brush = ToSolidBrush(image.Style.Fill);
                _gfx.FillRectangle(
                    brush,
                    srect);
                brush.Dispose();
            }

            if (image.IsStroked)
            {
                Pen pen = ToPen(image.Style, _scaleToPage);
                _gfx.DrawRectangle(
                    pen,
                    srect);
                pen.Dispose();
            }

            if (_enableImageCache
                && _biCache.ContainsKey(image.Path))
            {
                _gfx.DrawImage(_biCache[image.Path], srect);
            }
            else
            {
                if (_state.ImageCache == null || string.IsNullOrEmpty(image.Path))
                    return;

                var bytes = _state.ImageCache.GetImage(image.Path);
                if (bytes != null)
                {
                    var bi = new Bitmap(bytes);

                    if (_enableImageCache)
                        _biCache[image.Path] = bi;

                    _gfx.DrawImage(bi, srect);

                    if (!_enableImageCache)
                        bi.Dispose();
                }
            }
        }
Example #14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="text"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="db"></param>
        /// <param name="r"></param>
        public void Draw(object gfx, XText text, double dx, double dy, ImmutableArray<ShapeProperty> db, Record r)
        {
            var _gfx = gfx as Graphics;

            var tbind = text.BindToTextProperty(db, r);
            if (string.IsNullOrEmpty(tbind))
                return;

            var brush = ToSolidBrush(text.Style.Stroke);

            var fontStyle = Eto.Drawing.FontStyle.None;
            if (text.Style.TextStyle.FontStyle.Flags.HasFlag(Test2d.FontStyleFlags.Bold))
            {
                fontStyle |= Eto.Drawing.FontStyle.Bold;
            }

            if (text.Style.TextStyle.FontStyle.Flags.HasFlag(Test2d.FontStyleFlags.Italic))
            {
                fontStyle |= Eto.Drawing.FontStyle.Italic;
            }

            var fontDecoration = Eto.Drawing.FontDecoration.None;
            if (text.Style.TextStyle.FontStyle.Flags.HasFlag(Test2d.FontStyleFlags.Underline))
            {
                fontDecoration |= Eto.Drawing.FontDecoration.Underline;
            }

            if (text.Style.TextStyle.FontStyle.Flags.HasFlag(Test2d.FontStyleFlags.Strikeout))
            {
                fontDecoration |= Eto.Drawing.FontDecoration.Strikethrough;
            }

            var font = new Font(
                text.Style.TextStyle.FontName,
                (float)(text.Style.TextStyle.FontSize * _textScaleFactor),
                fontStyle,
                fontDecoration);

            var rect = CreateRect(
                text.TopLeft,
                text.BottomRight,
                dx, dy);

            var srect = new RectangleF(
                _scaleToPage(rect.X),
                _scaleToPage(rect.Y),
                _scaleToPage(rect.Width),
                _scaleToPage(rect.Height));

            var size = _gfx.MeasureString(font, tbind);
            var origin = GetTextOrigin(text.Style, ref srect, ref size);

            _gfx.DrawText(
                font,
                brush,
                origin,
                tbind);

            brush.Dispose();
            font.Dispose();
        }
Example #15
0
		public override void Draw(object control, GraphicsHandler graphics, RectangleF rect)
		{
			graphics.Control.SetFillColor((CGColor)control);

			graphics.Control.FillRect(rect.ToNS());
		}
Example #16
0
		public static IGraphicsPath GetRoundRect (RectangleF rectangle, float nwRadius, float neRadius, float seRadius, float swRadius, Generator generator)
		{
			return GetRoundRect(rectangle, nwRadius, neRadius, seRadius, swRadius);
		}
Example #17
0
		public void DrawImage(Image image, RectangleF source, RectangleF destination)
		{
			throw new NotImplementedException();
		}
Example #18
0
 public void Create(RectangleF rectangle, Color c1, Color c2, float angle)
 {
     throw new NotImplementedException();
 }
Example #19
0
		public static void Draw(Graphics graphics)
		{
			var image = TestIcons.TestImage;
			// lines
			var whitePen = new Pen(Colors.White, 1);
			graphics.DrawLine(whitePen, 1, 1, 99, 99);
			graphics.DrawLine(whitePen, 50, 1, 50, 99);
			graphics.DrawLine(whitePen, 1, 51, 99, 51);

			graphics.DrawRectangle(whitePen, 101, 1, 100, 100);
			graphics.DrawRectangle(whitePen, 101, 1, 10, 10);

			graphics.DrawEllipse(Pens.Green, 101, 1, 100, 100);

			graphics.DrawPolygon(whitePen, new PointF(203, 1), new PointF(253, 51), new Point(203, 101), new PointF(203, 1), new PointF(253, 1), new PointF(253, 101), new PointF(203, 101));

			var rect = new RectangleF(255, 1, 100, 100);
			graphics.DrawArc(Pens.LightGreen, rect, 180, 90);
			graphics.DrawArc(Pens.SkyBlue, rect, 0, 90);
			rect.Inflate(-15, 0);
			graphics.DrawArc(Pens.FloralWhite, rect, -45, 90);
			rect.Inflate(-5, -20);
			graphics.DrawArc(Pens.SlateGray, rect, -45, 270);
			rect.Inflate(-10, -10);
			graphics.DrawArc(Pens.SteelBlue, rect, 180 + 45, 270);

			graphics.DrawImage(image, 100, 1, 100, 100);

			graphics.DrawText(Fonts.Sans(12 * graphics.PointsPerPixel), Colors.White, 0, 104, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");

			// filled
			graphics.FillRectangle(Brushes.White, 101, 120, 100, 100);
			graphics.FillRectangle(Brushes.Gray, 101, 120, 10, 10);

			graphics.FillEllipse(Brushes.Green, 101, 120, 100, 100);

			graphics.FillPolygon(Brushes.White, new PointF(202, 120), new PointF(252, 170), new Point(202, 220), new PointF(202, 120));

			rect = new RectangleF(255, 120, 100, 100);
			graphics.FillPie(Brushes.LightGreen, rect, 180, 90);
			graphics.FillPie(Brushes.SkyBlue, rect, 0, 90);
			rect.Inflate(-15, 0);
			graphics.FillPie(Brushes.FloralWhite, rect, -45, 90);
			rect.Inflate(-5, -20);
			graphics.FillPie(Brushes.SlateGray, rect, -45, 270);
			rect.Inflate(-10, -10);
			graphics.FillPie(Brushes.SteelBlue, rect, 180 + 45, 270);


			graphics.DrawImage(image, 101, 120, 100, 100);

			const int offset = 440;
			var xoffset = offset;
			var yoffset = 112;
			for (int i = 1; i < 14; i++)
			{
				var pen = new Pen(Colors.White, i);
				pen.LineCap = PenLineCap.Butt;
				graphics.DrawLine(pen, xoffset, 1, xoffset, 110);

				graphics.DrawLine(pen, offset, yoffset, offset + 100, yoffset);

				xoffset += i + 2;
				yoffset += i + 2;
			}

		}
Example #20
0
			public void Draw(GraphicsHandler graphics, RectangleF rect)
			{
				var outerRadius = Radius.Width;
				var yscale = Radius.Height / Radius.Width;
				var center = Center;
				var origin = GradientOrigin;
				var scale = 1f;

				if (wrap != GradientWrapMode.Pad)
				{
					// use eto's transformrectangle as it'll make the rect encompass the resulting transformed area
					var boundRect = transform.Invert().ToEto().TransformRectangle(rect);

					// find max number of iterations we need to fill the bounding rectangle
					scale = GradientHelper.GetRadialScale(Center, Radius, GradientOrigin, boundRect);
				}

				if (Gradient == null || scale > lastScale)
				{
					var stops = GradientHelper.GetGradientStops(StartColor.ToCG(), EndColor.ToCG(), scale, wrap).ToList();
					lastScale = scale;
					Gradient = new CGGradient(CGColorSpace.CreateDeviceRGB(), stops.Select(r => r.Item2).ToArray(), stops.Select(r => (nfloat)r.Item1).ToArray());
				}
				else
				{
					scale = lastScale;
				}
				
				var scaledRect = new RectangleF(GradientOrigin - (GradientOrigin - Center + Radius) * scale, GradientOrigin + (Center + Radius - GradientOrigin) * scale);
				center = scaledRect.Center;
				outerRadius *= scale;

				// adjust center based on ellipse scale from gradient origin
				center.Y = origin.Y - (origin.Y - center.Y) / yscale;

				// scale to draw elliptical gradient
				var t = new CGAffineTransform(1, 0f, 0f, yscale, 0, origin.Y - origin.Y * yscale);
				t.Multiply(transform);

				graphics.Control.SaveState();
				graphics.Control.ConcatCTM(t);
				graphics.Control.DrawRadialGradient(Gradient, origin.ToNS(), 0, center.ToNS(), outerRadius, CGGradientDrawingOptions.DrawsAfterEndLocation | CGGradientDrawingOptions.DrawsBeforeStartLocation);
				graphics.Control.RestoreState();
			}
Example #21
0
 public ImageBridge(ed.RectangleF rec) : this(width : (int)rec.Width, height : (int)rec.Height)
 {
 }
Example #22
0
		public void ResetClip()
		{
			if (drawable != null)
				clipBounds = new RectangleF(drawable.Size);
		}
Example #23
0
		public void SetClip(RectangleF rectangle)
		{
			clipBounds = rectangle;
		}
Example #24
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Drawing.LinearGradientBrush"/> class with a given <paramref name="rectangle"/> and <paramref name="angle"/>
		/// </summary>
		/// <param name="rectangle">Rectangle to define the area of the gradient</param>
		/// <param name="startColor">Start color for the gradient</param>
		/// <param name="endColor">End color for the gradient</param>
		/// <param name="angle">Angle of the gradient</param>
		/// <param name="generator">Generator to create the brush, or null to use the current generator</param>
		public LinearGradientBrush(RectangleF rectangle, Color startColor, Color endColor, float angle, Generator generator)
		{
			handler = generator.CreateShared<IHandler>();
			ControlObject = handler.Create(rectangle, startColor, endColor, angle);
		}
Example #25
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Forms.PaintEventArgs"/> class.
		/// </summary>
		/// <param name="graphics">Graphics for the paint event</param>
		/// <param name="clipRectangle">Rectangle of the region being painted</param>
		public PaintEventArgs(Graphics graphics, RectangleF clipRectangle)
		{
			ClipRectangle = clipRectangle;
			Graphics = graphics;
		}
Example #26
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Drawing.LinearGradientBrush"/> class with a given <paramref name="rectangle"/> and <paramref name="angle"/>
		/// </summary>
		/// <param name="rectangle">Rectangle to define the area of the gradient</param>
		/// <param name="startColor">Start color for the gradient</param>
		/// <param name="endColor">End color for the gradient</param>
		/// <param name="angle">Angle of the gradient</param>
		public LinearGradientBrush(RectangleF rectangle, Color startColor, Color endColor, float angle)
		{
			handler = Platform.Instance.CreateShared<IHandler> ();
			ControlObject = handler.Create (rectangle, startColor, endColor, angle);
		}
Example #27
0
File: Screen.cs Project: mhusen/Eto
		/// <summary>
		/// Gets the screen that encompases the biggest part of the specified <paramref name="rectangle"/>,
		/// or the closest screen to the rectangle if it is outside the bounds of all screens..
		/// </summary>
		/// <returns>The screen encompassing or closest to the specified rectangle.</returns>
		/// <param name="rectangle">Rectangle to find the screen.</param>
		public static Screen FromRectangle(RectangleF rectangle)
		{
			Screen foundScreen = null;
			float foundArea = 0;
			var screens = Screens.ToArray();
			foreach (var screen in screens)
			{
				var rect = rectangle;
				rect.Intersect(screen.Bounds);
				var area = rect.Size.Width * rect.Size.Height;
				if (area > foundArea)
				{
					foundScreen = screen;
					foundArea = area;
				}
			}
			if (foundScreen != null)
				return foundScreen;

			// find by distance
			float foundDistance = float.MaxValue;
			foreach (var screen in screens)
			{
				var diff = RectangleF.Distance(rectangle, screen.Bounds);
				var distance = (float)Math.Sqrt(diff.Width * diff.Width + diff.Height * diff.Height);
				if (distance < foundDistance)
				{
					foundScreen = screen;
					foundDistance = distance;
				}
			}
			return foundScreen ?? PrimaryScreen;
		}
Example #28
0
		public abstract void Draw(object control, GraphicsHandler graphics, RectangleF rect);
		public object Create (RectangleF rectangle, Color startColor, Color endColor, float angle)
		{
			throw new NotImplementedException ();
		}
Example #30
0
		void Draw(Graphics g)
		{
			if (brush == null)
				return;
			var rect = new RectangleF(0, 0, 200, 100);
			/**/
			//g.FillRectangle(brush, rect);
			g.FillEllipse(brush, rect);
			g.DrawEllipse(Colors.Black, rect);
			/**/
			rect = new RectangleF(0, 110, 200, 80);
			g.FillRectangle(brush, rect);
			g.DrawRectangle(Colors.Black, rect);
			/**/
			rect = new RectangleF(0, 200, 200, 80);
			g.FillPie(brush, rect, 100, 240);
			g.DrawArc(Colors.Black, rect, 100, 240);
			/**/
			var points = new[] { new PointF(300, 0), new PointF(350, 20), new PointF(400, 80), new PointF(320, 90) };
			g.FillPolygon(brush, points);
			g.DrawPolygon(Colors.Black, points);
			/**/
		}
Example #31
0
		public override void Draw(object control, GraphicsHandler graphics, RectangleF rect)
		{
			((BrushObject)control).Draw(graphics, rect);
		}