• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# NGraphics.Rect类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: DrawImage

		public void DrawImage (IImage image, Rect frame, double alpha = 1.0)
		{
			var ch = GetChild (ChildType.Image);
			var s = (Shapes.Rectangle)ch.Shape;
			s.Width = frame.Width;
			s.Height = frame.Height;
		}
开发者ID:michaelstonis,项目名称:NGraphics,代码行数:7,代码来源:CanvasCanvas.cs


示例2: Text

 public Text(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
     : base(pen, brush)
 {
     String = text;
     Frame = frame;
     Font = font;
     Alignment = alignment;
 }
开发者ID:sami1971,项目名称:NGraphics,代码行数:8,代码来源:Text.cs


示例3: DrawEllipse

		public void DrawEllipse (Rect frame, Pen pen = null, Brush brush = null)
		{
			var ch = GetChild (ChildType.Ellipse);
			var s = (Shapes.Rectangle)ch.Shape;
			s.Width = frame.Width;
			s.Height = frame.Height;
			FormatShape (s, pen, brush);
		}
开发者ID:michaelstonis,项目名称:NGraphics,代码行数:8,代码来源:CanvasCanvas.cs


示例4: Text

		public Text (Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
			: base (pen, brush)
		{
			Frame = frame;
			Font = font;
			Alignment = alignment;
			Spans = new List<TextSpan> ();
		}
开发者ID:michaelstonis,项目名称:NGraphics,代码行数:8,代码来源:Text.cs


示例5: TransformRect

		public Rect TransformRect (Rect rect)
		{
			var bbb = new BoundingBoxBuilder ();
			bbb.Add (TransformPoint (rect.TopLeft));
			bbb.Add (TransformPoint (rect.BottomLeft));
			bbb.Add (TransformPoint (rect.BottomRight));
			bbb.Add (TransformPoint (rect.TopRight));
			return bbb.BoundingBox;
		}
开发者ID:michaelstonis,项目名称:NGraphics,代码行数:9,代码来源:Transform.cs


示例6: Draw

		public override void Draw(ICanvas canvas, Rect rect)
		{
			if(DrawingFunction != null)
			{
				base.Draw(canvas, rect);
				return;
			}

			var borderColro = NGraphics.Color.FromHSL(
				                  BorderColor.Hue,
				                  BorderColor.Saturation,
				                  BorderColor.Luminosity,
				                  BorderColor.A);
			var pen = new Pen(borderColro, BorderWidth);
			var fillColor = NGraphics.Color.FromHSL(
				                BackColor.Hue,
				                BackColor.Saturation,
				                BackColor.Luminosity,
				                BackColor.A);
			var brush = new SolidBrush(fillColor);

			var padding = BorderWidth <= 0 ? 0.0 : BorderWidth;
			var newRect = rect.GetInflated(-padding);
			var curveSize = newRect.Height / 2;

			canvas.DrawPath(new PathOp []{ 
				new MoveTo(newRect.Left+curveSize, newRect.Top),
				new LineTo(newRect.Right-curveSize, newRect.Top),
				new CurveTo(
					new NGraphics.Point(newRect.Right-curveSize, newRect.Top),
					newRect.TopRight,
					new NGraphics.Point(newRect.Right, newRect.Top+curveSize)
				),
				new CurveTo(
					new NGraphics.Point(newRect.Right, newRect.Bottom-curveSize),
					newRect.BottomRight,
					new NGraphics.Point(newRect.Right-curveSize, newRect.Bottom)
				),
				new LineTo(newRect.Left+curveSize, newRect.Bottom),
				new CurveTo(
					new NGraphics.Point(newRect.Left+curveSize, newRect.Bottom),
					newRect.BottomLeft,
					new NGraphics.Point(newRect.Left, newRect.Bottom-curveSize)
				),
				new CurveTo(
					new NGraphics.Point(newRect.Left, newRect.Top+curveSize),
					newRect.TopLeft,
					new NGraphics.Point(newRect.Left+curveSize, newRect.Top)
				),
				new ClosePath()
			}, pen, brush);
		}
开发者ID:P3PPP,项目名称:XFAedSearch,代码行数:52,代码来源:RoundedButton.cs


示例7: Read

		void Read (XDocument doc)
		{
			var svg = doc.Root;
			var ns = svg.Name.Namespace;

			//
			// Find the defs (gradients)
			//
			foreach (var d in svg.Descendants ()) {
				var idA = d.Attribute ("id");
				if (idA != null) {
					defs [ReadString (idA).Trim ()] = d;
				}
			}

			//
			// Get the dimensions
			//
			var widthA = svg.Attribute ("width");
			var heightA = svg.Attribute ("height");
			var width = ReadNumber (widthA);
			var height = ReadNumber (heightA);
			var size = new Size (width, height);

			var viewBox = new Rect (size);
			var viewBoxA = svg.Attribute ("viewBox") ?? svg.Attribute ("viewPort");
			if (viewBoxA != null) {
				viewBox = ReadRectangle (viewBoxA.Value);
			}

			if (widthA != null && widthA.Value.Contains ("%")) {
				size.Width *= viewBox.Width;
			}
			if (heightA != null && heightA.Value.Contains ("%")) {
				size.Height *= viewBox.Height;
			}

			//
			// Add the elements
			//
			Graphic = new Graphic (size, viewBox);

			AddElements (Graphic.Children, svg.Elements (), null, Brushes.Black);
		}
开发者ID:superlloyd,项目名称:NGraphics,代码行数:44,代码来源:SvgReader.cs


示例8: DrawEllipse

 public void DrawEllipse(Rect frame, Pen pen = null, Brush brush = null)
 {
 }
开发者ID:xamarin-libraries,项目名称:xamarin-libraries,代码行数:3,代码来源:NullPlatform.cs


示例9: DrawRectangle

 public void DrawRectangle(Rect frame, Pen pen = null, Brush brush = null)
 {
 }
开发者ID:xamarin-libraries,项目名称:xamarin-libraries,代码行数:3,代码来源:NullPlatform.cs


示例10: GetAbsoluteFocus

 public Point GetAbsoluteFocus(Rect frame)
 {
     if (Absolute) return Focus;
     return frame.TopLeft + Focus * frame.Size;
 }
开发者ID:xamarin-libraries,项目名称:xamarin-libraries,代码行数:5,代码来源:Brush.cs


示例11: GetAbsoluteStart

 public Point GetAbsoluteStart(Rect frame)
 {
     if (Absolute) return Start;
     return frame.TopLeft + Start * frame.Size;
 }
开发者ID:xamarin-libraries,项目名称:xamarin-libraries,代码行数:5,代码来源:Brush.cs


示例12: RenderSectionToImage

		static IImage RenderSectionToImage (/*this*/ Graphic graphics, Rect sourceFrame, Rect outputFrame, double finalScale, Func<Size, double, IImageCanvas> createPlatformImageCanvas)
		{
			var originalSize = graphics.Size;
			var sectionCanvas = createPlatformImageCanvas (outputFrame.Size, finalScale);

			// Redraw into final version with any scaling between the original and the output slice.
			var sliceVerticalScale = outputFrame.Height / sourceFrame.Height;
			var sliceHorizontalScale = outputFrame.Width / sourceFrame.Width;
			// Potentially setting ViewBox size smaller to enlarge result.
			graphics.ViewBox = new Rect (sourceFrame.Position, new Size (originalSize.Width / sliceHorizontalScale, originalSize.Height / sliceVerticalScale));

			graphics.Draw (sectionCanvas);
			return sectionCanvas.GetImage ();
		}
开发者ID:patridge,项目名称:TwinTechsFormsLib,代码行数:14,代码来源:SvgImageView.cs


示例13: DrawEllipse

        /// <summary>
        /// Draws an ellipse
        /// </summary>
        /// <param name="frame"></param>
        /// <param name="pen"></param>
        /// <param name="brush"></param>
        public void DrawEllipse(Rect frame, Pen pen = null, NGraphics.Brush brush = null)
        {
            var ellipseEl = new System.Windows.Shapes.Ellipse();
            var offset = pen != null ? pen.Width : 0.0;

            ellipseEl.Width = frame.Width + offset;
            ellipseEl.Height = frame.Height + offset;

            if (brush != null)
                ellipseEl.Fill = GetBrush(brush);

            if (pen != null)
            {
                ellipseEl.Stroke = GetStroke(pen);
                ellipseEl.StrokeThickness = pen.Width;
            }

            ellipseEl.RenderTransform = Conversions.GetTransform(CurrentTransform);
            _canvas.Children.Add(ellipseEl);
            Canvas.SetLeft(ellipseEl, frame.X - offset / 2.0);
            Canvas.SetTop(ellipseEl, frame.Y - offset / 2.0);
        }
开发者ID:rmawani,项目名称:NControl,代码行数:28,代码来源:PhoneSilverlightPlatform.cs


示例14: DrawEllipse

 public void DrawEllipse(Rect frame, Pen pen = null, Brush brush = null)
 {
     var p = GetBrush (pen);
     var b = GetBrush (frame, brush);
     var c = frame.Center;
     var s = new D2D1.Ellipse (new Vector2 ((float)c.X, (float)c.Y), (float)(frame.Width / 2.0), (float)(frame.Height / 2.0));
     if (b != null) {
         renderTarget.FillEllipse (s, b);
     }
     if (p != null) {
         renderTarget.DrawEllipse (s, p, (float)pen.Width, GetStrokeStyle (pen));
     }
 }
开发者ID:rbrian,项目名称:NGraphics,代码行数:13,代码来源:Direct2DCanvas.cs


示例15: DrawText

        public void DrawText(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
        {
            if (string.IsNullOrEmpty (text))
                return;
            if (font == null)
                throw new ArgumentNullException ("font");

            SetBrush (brush);

            //			string fontName = font.Name;
            //			context.SelectFont (font.Name, (nfloat)font.Size, CGTextEncoding.MacRoman);
            //
            //			context.ShowTextAtPoint ((nfloat)frame.X, (nfloat)frame.Y, text);

            var pt = frame.TopLeft;

            using (var atext = new NSMutableAttributedString (text)) {

                atext.AddAttributes (new CTStringAttributes {
                    ForegroundColorFromContext = true,
                    Font = font.GetCTFont (),
                }, new NSRange (0, text.Length));

                using (var l = new CTLine (atext)) {
                    nfloat asc, desc, lead;
                    var width = l.GetTypographicBounds (out asc, out desc, out lead);
                    context.SaveState ();
                    context.TranslateCTM ((nfloat)(pt.X - width / 2), (nfloat)(pt.Y + desc));
                    context.TextPosition = CGPoint.Empty;
                    l.Draw (context);
                    context.RestoreState ();
                }
            }
        }
开发者ID:nakijun,项目名称:NGraphics,代码行数:34,代码来源:ApplePlatform.cs


示例16: DrawText

        /// <summary>
        /// Draws text
        /// </summary>
        /// <param name="text"></param>
        /// <param name="frame"></param>
        /// <param name="font"></param>
        /// <param name="alignment"></param>
        /// <param name="pen"></param>
        /// <param name="brush"></param>
        public void DrawText(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left,
            Pen pen = null, NGraphics.Brush brush = null)
        {
            var textBlock = new TextBlock();
            textBlock.Text = text;
            textBlock.Width = frame.Width;
            textBlock.Height = frame.Height;
            Canvas.SetLeft(textBlock, frame.X);
            Canvas.SetTop(textBlock, frame.Y);

            textBlock.FontFamily = new FontFamily(font.Family);
            textBlock.FontSize = font.Size;

            switch (alignment)
            {
                case TextAlignment.Left:
                    textBlock.TextAlignment = System.Windows.TextAlignment.Left;
                    break;
                case TextAlignment.Center:
                    textBlock.TextAlignment = System.Windows.TextAlignment.Center;
                    break;
                case TextAlignment.Right:
                    textBlock.TextAlignment = System.Windows.TextAlignment.Right;
                    break;
            }

            if (pen != null)
                textBlock.Foreground = new SolidColorBrush(new System.Windows.Media.Color
                {
                    A = pen.Color.A,
                    R = pen.Color.R,
                    G = pen.Color.G,
                    B = pen.Color.B
                });

            textBlock.RenderTransform = Conversions.GetTransform(CurrentTransform);
            _canvas.Children.Add(textBlock);
        }
开发者ID:rmawani,项目名称:NControl,代码行数:47,代码来源:PhoneSilverlightPlatform.cs


示例17: DrawImage

 public void DrawImage(IImage image, Rect frame, double alpha = 1.0)
 {
     var i = GetImage (image);
     renderTarget.DrawBitmap (i, frame.ToRectangleF (), (float)alpha, D2D1.BitmapInterpolationMode.Linear);
 }
开发者ID:rbrian,项目名称:NGraphics,代码行数:5,代码来源:Direct2DCanvas.cs


示例18: DrawImage

        /// <summary>
        /// Draws an image
        /// </summary>
        /// <param name="image"></param>
        /// <param name="frame"></param>
        /// <param name="alpha"></param>
        public void DrawImage(IImage image, Rect frame, double alpha = 1.0)
        {
            var ii = image as BitmapImageImage;
            if (ii != null)
            {
                var imageEl = new Image();
                imageEl.Source = ii.Bitmap;
                imageEl.Width = frame.Width;
                imageEl.Height = frame.Height;

                imageEl.RenderTransform = Conversions.GetTransform(CurrentTransform);
                _canvas.Children.Add(imageEl);
                Canvas.SetLeft(imageEl, frame.X);
                Canvas.SetTop(imageEl, frame.Y);
            }
        }
开发者ID:rmawani,项目名称:NControl,代码行数:22,代码来源:PhoneSilverlightPlatform.cs


示例19: DrawRectangle

 public void DrawRectangle(Rect frame, Pen pen = null, Brush brush = null)
 {
     var p = GetBrush (pen);
     var b = GetBrush (frame, brush);
     if (b != null) {
         renderTarget.FillRectangle (frame.ToRectangleF (), b);
     }
     if (p != null) {
         renderTarget.DrawRectangle (frame.ToRectangleF (), p, (float)pen.Width, GetStrokeStyle (pen));
     }
 }
开发者ID:rbrian,项目名称:NGraphics,代码行数:11,代码来源:Direct2DCanvas.cs


示例20: GetAbsoluteEnd

 public Point GetAbsoluteEnd(Rect frame)
 {
     if (Absolute) return End;
     return frame.TopLeft + End * frame.Size;
 }
开发者ID:xamarin-libraries,项目名称:xamarin-libraries,代码行数:5,代码来源:Brush.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NGraphics.Size类代码示例发布时间:2022-05-26
下一篇:
C# NGraphics.Pen类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap