当前位置: 首页>>代码示例>>C#>>正文


C# Drawing.RectangleF类代码示例

本文整理汇总了C#中Eto.Drawing.RectangleF的典型用法代码示例。如果您正苦于以下问题:C# RectangleF类的具体用法?C# RectangleF怎么用?C# RectangleF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RectangleF类属于Eto.Drawing命名空间,在下文中一共展示了RectangleF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TextureBrushesSection

		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;
		}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:26,代码来源:TextureBrushesSection.cs

示例2: Restrict

		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;
		}
开发者ID:hultqvist,项目名称:Eto,代码行数:7,代码来源:RectangleF.cs

示例3: ToImageCoordinate

        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);
        }
开发者ID:gitter-badger,项目名称:dot-imaging,代码行数:7,代码来源:PictureBox.cs

示例4: Box

			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;
				}
			}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:55,代码来源:DirectDrawingSection.cs

示例5: Create

		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
			};
		}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:11,代码来源:LinearGradientBrushHandler.cs

示例6: Draw

		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);
		}
开发者ID:Exe0,项目名称:Eto,代码行数:52,代码来源:PixelOffsetSection.cs

示例7: Create

		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
			};
		}
开发者ID:alexandrebaker,项目名称:Eto,代码行数:14,代码来源:LinearGradientBrushHandler.cs

示例8: ClipTest

		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);
		}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:16,代码来源:UnitTestSection.cs

示例9: Draw

			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();
			}
开发者ID:mhusen,项目名称:Eto,代码行数:17,代码来源:TextureBrushHandler.cs

示例10: ClipRectangleShouldTranslate

		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");
			});
		}
开发者ID:gene-l-thomas,项目名称:Eto,代码行数:18,代码来源:ClipTests.cs

示例11: PictureBox_MouseMove

        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();
        }
开发者ID:gitter-badger,项目名称:dot-imaging,代码行数:19,代码来源:DrawingRectangleAdorner.cs

示例12: LinearGradientBrush

		/// <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);
		}
开发者ID:gene-l-thomas,项目名称:Eto,代码行数:13,代码来源:LinearGradientBrush.cs

示例13: GetTextOrigin

        /// <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);
        }
开发者ID:gitter-badger,项目名称:Test2d,代码行数:41,代码来源:EtoRenderer.cs

示例14: Draw

        /// <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();
                }
            }
        }
开发者ID:gitter-badger,项目名称:Test2d,代码行数:67,代码来源:EtoRenderer.cs

示例15: Draw

		public override void Draw(object control, GraphicsHandler graphics, RectangleF rect)
		{
			graphics.Control.SetFillColor((CGColor)control);

			graphics.Control.FillRect(rect.ToNS());
		}
开发者ID:mhusen,项目名称:Eto,代码行数:6,代码来源:SolidBrushHandler.cs


注:本文中的Eto.Drawing.RectangleF类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。