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


C# CGRect.Inflate方法代码示例

本文整理汇总了C#中CGRect.Inflate方法的典型用法代码示例。如果您正苦于以下问题:C# CGRect.Inflate方法的具体用法?C# CGRect.Inflate怎么用?C# CGRect.Inflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGRect的用法示例。


在下文中一共展示了CGRect.Inflate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ChartCanvas

        public ChartCanvas(CGRect rect)
            : base(rect)
        {
            ContentMode = UIViewContentMode.Redraw;
            AutoresizingMask = UIViewAutoresizing.All;
            BackColor = Color.Wheat;

            var panelRect = new CGRect (rect.X,rect.Y,rect.Width,rect.Height-20 / UIScreen.MainScreen.Scale);
            panelRect.Inflate (-20 / UIScreen.MainScreen.Scale,-20 / UIScreen.MainScreen.Scale);
            panel1 = new PlotPanel (panelRect);
            panel1.BackColor = Color.AliceBlue;

            AddSubview (panel1);
            panel1.Paint += PlotPanelPaint;
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:15,代码来源:ChartCanvas.cs

示例2: Initialize

        // Shared initialization code
        void Initialize()
        {
            this.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable;
            BackColor = Color.Wheat;

            var panelRect = new CGRect(Frame.X,Frame.Y,Frame.Width,Frame.Height);
            panelRect.Inflate(-20,-20);
            panel1 = new PlotPanel(panelRect);
            panel1.BackColor = Color.AliceBlue;

            this.AddSubview (panel1);

            // Subscribing to a paint eventhandler to drawingPanel:
            panel1.Paint +=
                new PaintEventHandler (PlotPanelPaint);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:17,代码来源:ChartCanvas.cs

示例3: SCBoxNode

		public static SCNNode SCBoxNode (string title, CGRect frame, NSColor color, float cornerRadius, bool centered)
		{
			NSMutableDictionary titleAttributes = null;
			NSMutableDictionary centeredTitleAttributes = null;

			// create and extrude a bezier path to build the box
			var path = NSBezierPath.FromRoundedRect (frame, cornerRadius, cornerRadius);
			path.Flatness = 0.05f;

			var shape = SCNShape.Create (path, 20);
			shape.ChamferRadius = 0.0f;

			var node = SCNNode.Create ();
			node.Geometry = shape;

			// create an image and fill with the color and text
			var textureSize = new CGSize ();
			textureSize.Width = NMath.Ceiling (frame.Size.Width * 1.5f);
			textureSize.Height = NMath.Ceiling (frame.Size.Height * 1.5f);

			var texture = new NSImage (textureSize);
			texture.LockFocus ();

			var drawFrame = new CGRect (0, 0, textureSize.Width, textureSize.Height);

			nfloat hue, saturation, brightness, alpha;

			(color.UsingColorSpace (NSColorSpace.DeviceRGBColorSpace)).GetHsba (out hue, out saturation, out brightness, out alpha);
			var lightColor = NSColor.FromDeviceHsba (hue, saturation - 0.2f, brightness + 0.3f, alpha);
			lightColor.Set ();

			NSGraphics.RectFill (drawFrame);

			NSBezierPath fillpath = null;

			if (cornerRadius == 0 && centered == false) {
				//special case for the "labs" slide
				drawFrame.Offset (0, -2);
				fillpath = NSBezierPath.FromRoundedRect (drawFrame, cornerRadius, cornerRadius);
			} else {
				drawFrame.Inflate (-3, -3);
				fillpath = NSBezierPath.FromRoundedRect (drawFrame, cornerRadius, cornerRadius);
			}

			color.Set ();
			fillpath.Fill ();

			// draw the title if any
			if (title != null) {
				if (titleAttributes == null) {
					var paraphStyle = new NSMutableParagraphStyle ();
					paraphStyle.LineBreakMode = NSLineBreakMode.ByWordWrapping;
					paraphStyle.Alignment = NSTextAlignment.Center;
					paraphStyle.MinimumLineHeight = 38;
					paraphStyle.MaximumLineHeight = 38;

					var font = NSFont.FromFontName ("Myriad Set Semibold", 34) != null ? NSFont.FromFontName ("Myriad Set Semibold", 34) : NSFont.FromFontName ("Avenir Medium", 34);

					var shadow = new NSShadow ();
					shadow.ShadowOffset = new CGSize (0, -2);
					shadow.ShadowBlurRadius = 4;
					shadow.ShadowColor = NSColor.FromDeviceWhite (0.0f, 0.5f);

					titleAttributes = new NSMutableDictionary ();
					titleAttributes.SetValueForKey (font, NSAttributedString.FontAttributeName);
					titleAttributes.SetValueForKey (NSColor.White, NSAttributedString.ForegroundColorAttributeName);
					titleAttributes.SetValueForKey (shadow, NSAttributedString.ShadowAttributeName);
					titleAttributes.SetValueForKey (paraphStyle, NSAttributedString.ParagraphStyleAttributeName);

					var centeredParaphStyle = (NSMutableParagraphStyle)paraphStyle.MutableCopy ();
					centeredParaphStyle.Alignment = NSTextAlignment.Center;

					centeredTitleAttributes = new NSMutableDictionary ();
					centeredTitleAttributes.SetValueForKey (font, NSAttributedString.FontAttributeName);
					centeredTitleAttributes.SetValueForKey (NSColor.White, NSAttributedString.ForegroundColorAttributeName);
					centeredTitleAttributes.SetValueForKey (shadow, NSAttributedString.ShadowAttributeName);
					centeredTitleAttributes.SetValueForKey (paraphStyle, NSAttributedString.ParagraphStyleAttributeName);
				}

				var attrString = new NSAttributedString (title, centered ? centeredTitleAttributes : titleAttributes);
				var textSize = attrString.Size;

				//check if we need two lines to draw the text
				var twoLines = title.Contains ("\n");
				if (!twoLines)
					twoLines = textSize.Width > frame.Size.Width && title.Contains (" ");

				//if so, we need to adjust the size to center vertically
				if (twoLines)
					textSize.Height += 38;

				if (!centered)
					drawFrame.Inflate (-15, 0);

				//center vertically
				var dy = (drawFrame.Size.Height - textSize.Height) * 0.5f;
				var drawFrameHeight = drawFrame.Size.Height;
				drawFrame.Size = new CGSize (drawFrame.Size.Width, drawFrame.Size.Height - dy);
				attrString.DrawString (drawFrame);
			}
//.........这里部分代码省略.........
开发者ID:shriharipathak,项目名称:mac-samples,代码行数:101,代码来源:Utils.cs


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