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


C# NGraphics.Rect类代码示例

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


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


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