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


C# CGRect.Inset方法代码示例

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


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

示例1: DrawWithFrame

			public override void DrawWithFrame (CGRect cellFrame, NSView inView)
			{
				if (IdeApp.Preferences.UserInterfaceTheme == Theme.Dark) {
					var inset = cellFrame.Inset (0.25f, 0.25f);
					inset = new CGRect (inset.X, inset.Y + 2, inset.Width, inset.Height - 2);

					var path = NSBezierPath.FromRoundedRect (inset, 3, 3);
					path.LineWidth = 0.5f;
					Styles.DarkBorderColor.ToNSColor ().SetStroke ();
					path.Stroke ();

					inset = new CGRect (inset.X + 3, inset.Y, inset.Width, inset.Height);
					DrawInteriorWithFrame (inset, inView);

					path = new NSBezierPath ();

					// Draw the separators
					for (int segment = 1; segment < SegmentCount; segment++) {
						nfloat x = inset.X + (33 * segment);
						path.MoveTo (new CGPoint (x, 0));
						path.LineTo (new CGPoint (x, inset.Y + inset.Height));
					}
					path.LineWidth = 0.5f;
					path.Stroke ();
				} else {
					base.DrawWithFrame (cellFrame, inView);
				}
			}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:28,代码来源:ButtonBar.cs

示例2: TimedAnimation

		public TimedAnimation (CGRect frame) : base(frame)
		{
			nfloat xInset = frame.Width / 3;
			nfloat yInset = frame.Height / 3;
			
			CGRect aniFrame = frame.Inset (xInset, yInset);
			
			// photo1 starts and the left edge
			CGPoint origin = frame.Location;
			origin.X = 0.0f;
			origin.Y = Bounds.GetMidY () - aniFrame.Height / 2;
			aniFrame.Location = origin;
			
			photo1 = new NSImageView (aniFrame);
			photo1.ImageScaling = NSImageScale.AxesIndependently;
			photo1.Image = NSImage.ImageNamed ("photo1.jpg");
			AddSubview (photo1);
			
			// photo2 starts in the center
			origin.X = Bounds.GetMidX () - aniFrame.Width / 2;
			aniFrame.Location = origin;
			photo2 = new NSImageView (aniFrame);
			photo2.ImageScaling = NSImageScale.AxesIndependently;
			photo2.Image = NSImage.ImageNamed ("photo2.jpg");
			AddSubview (photo2);
		}
开发者ID:RangoLee,项目名称:mac-samples,代码行数:26,代码来源:TimedAnimation.cs

示例3: GetMaskShape

		CAShapeLayer GetMaskShape (ViewMaskerType maskType, Xamarin.Forms.Size size)
		{
			var layer = new CAShapeLayer ();
			layer.FillColor = UIColor.White.CGColor;
			layer.StrokeColor = UIColor.White.CGColor;
			layer.LineWidth = 0;
			UIBezierPath path = null;
			var bounds = new CGRect (0, 0, size.Width, size.Height);

			switch (maskType) {
			case ViewMaskerType.Circle:
				path = UIBezierPath.FromRoundedRect (bounds, (nfloat)Math.Max (size.Width, size.Height));
				break;
			case ViewMaskerType.Triangle:
				var point1 = new CGPoint (0, size.Height);
				var point2 = new CGPoint (size.Width, size.Height);
				var point3 = new CGPoint (size.Width / 2, 0);
				path = new UIBezierPath ();
				path.MoveTo (point1);
				path.AddLineTo (point2);
				path.AddLineTo (point3);
				path.AddLineTo (point1);
				path.ClosePath ();
				path.Fill ();
				break;
			case ViewMaskerType.Square:
				var smallRectangle = UIBezierPath.FromRect (bounds.Inset (50, 50));
				path = UIBezierPath.FromRoundedRect (bounds, 20);
				break;
			default:
				throw new ArgumentOutOfRangeException ();
			}
			layer.Path = path.CGPath;
			return layer;
		}
开发者ID:DevinvN,项目名称:TwinTechsFormsLib,代码行数:35,代码来源:ViewMaskExtensionProvider.cs

示例4: AnimateTransition

		public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
		{
			_transitionContext = transitionContext;

			var containerView = transitionContext.ContainerView;

			FlashCardViewController toViewController;
			UIViewController fromViewController;

			if (Presenting) {
				fromViewController = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey) as UIViewController;
				toViewController = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) as FlashCardViewController;
			} else {
				toViewController = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey) as FlashCardViewController;
				fromViewController = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) as UIViewController;
			}

			if(Presenting)
				containerView.AddSubview(toViewController.View);

			var originRect = toViewController.SourceFrame;

			var circleRect = new CGRect (originRect.GetMidX(), originRect.GetMidY(), 10, 10);

			var circleMaskPathInitial = UIBezierPath.FromOval(circleRect); //(ovalInRect: button.frame);
			var extremePoint = new CGPoint(circleRect.X - toViewController.View.Bounds.Width, circleRect.Y - toViewController.View.Bounds.Height ); //CGRect.GetHeight (toViewController.view.bounds));
			var radius = (float)Math.Sqrt((extremePoint.X * extremePoint.X) + (extremePoint.Y * extremePoint.Y));
			var largeCircleRect = circleRect.Inset (-radius, -radius);
			var circleMaskPathFinal = UIBezierPath.FromOval (largeCircleRect);

			CGPath fromPath;
			CGPath toPath;

			if (Presenting) {
				fromPath = circleMaskPathInitial.CGPath;
				toPath = circleMaskPathFinal.CGPath;
			} else {
				var path = new CGPath ();
				fromPath = circleMaskPathFinal.CGPath;
				toPath = circleMaskPathInitial.CGPath;
			}

			var maskLayer = new CAShapeLayer();
			maskLayer.Path = fromPath;
			if (Presenting) {
				toViewController.View.Layer.Mask = maskLayer;
			} else {
				toViewController.View.Layer.Mask = maskLayer;
			}

			var maskLayerAnimation = CABasicAnimation.FromKeyPath("path");
			maskLayerAnimation.From = ObjCRuntime.Runtime.GetNSObject(fromPath.Handle);
			maskLayerAnimation.To = ObjCRuntime.Runtime.GetNSObject(toPath.Handle);
			maskLayerAnimation.Duration = this.TransitionDuration(transitionContext);
			_animDoneDelegate = new AnimDoneDelegate (transitionContext);
			maskLayerAnimation.Delegate = _animDoneDelegate;
			maskLayer.AddAnimation(maskLayerAnimation, "path");

		}
开发者ID:funhead,项目名称:baby-flashcard-app,代码行数:59,代码来源:FlashCardViewControllerAnimatedTransitioning.cs

示例5: DrawWithFrame

			public override void DrawWithFrame (CGRect cellFrame, NSView inView)
			{
				if (IdeApp.Preferences.UserInterfaceSkin == Skin.Dark) {
					var inset = cellFrame.Inset (0.25f, 0.25f);
					if (!ShowsFirstResponder) {
						var path = NSBezierPath.FromRoundedRect (inset, 3, 3);
						path.LineWidth = 0.5f;

						Styles.DarkBorderColor.ToNSColor ().SetStroke ();
						path.Stroke ();
					}

					// Can't just call base.DrawInteriorWithFrame because it draws the placeholder text
					// with a strange emboss effect when it the view is not first responder.
					// Again, probably because the NSSearchField handles the not first responder state itself
					// rather than using NSSearchFieldCell
					//base.DrawInteriorWithFrame (inset, inView);

					// So instead, draw the various extra cells and text in the correct places
					SearchButtonCell.DrawWithFrame (SearchButtonRectForBounds (inset), inView);

					if (!ShowsFirstResponder) {
						PlaceholderAttributedString.DrawInRect (SearchTextRectForBounds (inset));
					}

					if (!string.IsNullOrEmpty (StringValue)) {
						CancelButtonCell.DrawWithFrame (CancelButtonRectForBounds (inset), inView);
					}
				} else {
					if (inView.Window.Screen.BackingScaleFactor == 2) {
						nfloat yOffset = 0f;
						nfloat hOffset = 0f;

						if (MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan) {
							if (inView.Window.IsKeyWindow) {
								yOffset = 0.5f;
								hOffset = -0.5f;
							} else {
								yOffset = 0f;
								hOffset = 1.0f;
							}
						} else {
							yOffset = 1f;
							hOffset = -1f;
						}
						cellFrame = new CGRect (cellFrame.X, cellFrame.Y + yOffset, cellFrame.Width, cellFrame.Height + hOffset);
					} else {
						nfloat yOffset = 0f;
						nfloat hOffset = 0f;

						cellFrame = new CGRect (cellFrame.X, cellFrame.Y + yOffset, cellFrame.Width, cellFrame.Height + hOffset);
					}
					base.DrawWithFrame (cellFrame, inView);
				}
			}
开发者ID:powerumc,项目名称:monodevelop_korean,代码行数:55,代码来源:SearchBar.cs

示例6: Draw

			public override void Draw (CGRect rect)
			{
				rect = rect.Inset (2, 2);
				float bodyWidth = (float)rect.Size.Width / 2;
				UIBezierPath path = UIBezierPath.FromRoundedRect (new CGRect ((rect.Size.Width - bodyWidth) / 2, 0, bodyWidth, rect.Size.Height), UIRectCorner.TopLeft | UIRectCorner.TopRight, new CGSize (8, 8));
				UIColor.Black.SetStroke ();
				UIColor.White.SetFill ();
				path.Fill ();
				path.LineWidth = 2;
				path.Stroke ();
			}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:11,代码来源:WalkingDead.cs

示例7: DrawImage

 public override void DrawImage(NSImage image, CGRect frame, NSView controlView)
 {
     NSGraphicsContext.GlobalSaveGraphicsState ();
     {
         this.shadow.Set ();
         CGRect imgRect = frame.Inset ((frame.Size.Width - image.Size.Width) / 2.0f, (frame.Size.Height - image.Size.Height) / 2.0f);
         image.Flipped = true;
         image.DrawInRect (imgRect, CGRect.Empty, NSCompositingOperation.SourceOver, 1.0f);
     }
     NSGraphicsContext.GlobalRestoreGraphicsState ();
 }
开发者ID:ThanosSiopoudis,项目名称:ACSidebar,代码行数:11,代码来源:ACSidebarItemCell.cs

示例8: Draw

		public override void Draw (CGRect rect)
		{
			rect = rect.Inset (4, 4);
			UIBezierPath path = UIBezierPath.FromArc (new CGPoint (rect.GetMidX (), rect.GetMidY ()), rect.Size.Width / 2, 0, 180, true);
			path.LineWidth = 8;

			UIColor.White.SetFill ();
			path.Fill ();

			UIColor.Black.SetStroke ();
			path.Stroke ();
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:12,代码来源:SymbolMarkView.cs

示例9: frameAnimation

		private CAAnimation frameAnimation (CGRect aniFrame)
		{
			CAKeyFrameAnimation frameAni = new CAKeyFrameAnimation ();
			
			frameAni.KeyPath = "frame";
			CGRect start = aniFrame;
			CGRect end = aniFrame.Inset (-start.Width * .5f, -start.Height * 0.5f);
			frameAni.Values = new NSObject[] { 
				NSValue.FromCGRect (start),
				NSValue.FromCGRect (end)
			};
			return frameAni;
		}
开发者ID:RangoLee,项目名称:mac-samples,代码行数:13,代码来源:GroupAnimationView.cs

示例10: KeyFrameView

		public KeyFrameView(CGRect frame) : base(frame)
		{
			nfloat xInset = 3 * (frame.Width / 8);
			nfloat yInset = 3 * (frame.Height / 8);
			
			CGRect moverFrame = frame.Inset (xInset, yInset);

			mover = new NSImageView (moverFrame);
			
			mover.ImageScaling = NSImageScale.AxesIndependently;
			mover.Image = NSImage.ImageNamed ("photo.jpg");
			AddSubview (mover);
			addBounceAnimation ();
		}
开发者ID:RangoLee,项目名称:mac-samples,代码行数:14,代码来源:KeyFrameView.cs

示例11: RenderPage

		/*
		 * Render the page here: we assume we are already in a normalized coordinate system which maps
		 * 	our standard aspect ratio (3:4) to (1:1)
		 * The reason why we do this is to reuse the same drawing code for both the preview and the
		 * 	full screen; for full screen rendering, we map the whole view, whereas the preview maps
		 * 	the whole preview image to a quarter of the page.
		 * */
		public CGRect [] RenderPage (Page page, CGSize size, bool unstyledDrawing)
		{
			var pageRect = new CGRect (0, 0, size.Width, size.Height);
			var paragraphBounds = new CGRect [page.Paragraphs.Count];

			using (var ctxt = UIGraphics.GetCurrentContext ()) {
				// fill background
				ctxt.SetFillColor (UIColor.FromHSBA (0.11f, 0.2f, 1, 1).CGColor);
				ctxt.FillRect (pageRect);

				pageRect = pageRect.Inset (20, 20);

				int i = 0;
				foreach (var p in page.Paragraphs) {
					var bounds = new CGRect (pageRect.X, pageRect.Y, 0, 0);

					if (UnstyledDrawing) {

						var text = new NSString (page.StringForParagraph (p));

						var font = UIFont.FromName ("HoeflerText-Regular", 24);

						// draw text with the old legacy path, setting the font color to black.
						ctxt.SetFillColor (UIColor.Black.CGColor);
						bounds.Size = text.DrawString (pageRect, font);

					} else {

						// TODO: draw attributed text with new string drawing
						var text = page.AttributedStringForParagraph (p);
						var textContext = new NSStringDrawingContext ();

						text.DrawString (pageRect, NSStringDrawingOptions.UsesLineFragmentOrigin, textContext);

						bounds = textContext.TotalBounds;
						bounds.Offset (pageRect.X, pageRect.Y);
					}

					paragraphBounds [i++] = bounds;

					pageRect.Y += bounds.Height;
				}

				return paragraphBounds;
			}
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:53,代码来源:PageView.cs

示例12: Draw

        public override void Draw(CGRect rect)
        {
            base.Draw (rect);

            float margins = 4;
            var drawRect = new CGRect(rect.X + margins, rect.Y + margins, rect.Width - margins*2, rect.Height - margins*2);

            CGContext context = UIGraphics.GetCurrentContext();
            context.AddEllipseInRect(drawRect);
            context.AddEllipseInRect(drawRect.Inset(4,4));
            context.SetFillColor(UIColor.Black.CGColor);
            context.SetStrokeColor(UIColor.White.CGColor);
            context.SetLineWidth(0.5f);
            context.ClosePath();
            context.SetShadow(new SizeF(1,2),4);
            context.DrawPath(CGPathDrawingMode.EOFillStroke);
        }
开发者ID:mubold,项目名称:AdvancedColorPicker,代码行数:17,代码来源:SatBrightIndicatorView.cs

示例13: GroupAnimationView

		public GroupAnimationView(CGRect frame) : base(frame)
		{
			nfloat xInset = 3 * (frame.Width / 8);
			nfloat yInset = 3 * (frame.Height / 8);
			
			CGRect moverFrame = frame.Inset (xInset, yInset);
		
			CGPoint location = moverFrame.Location;
			location.X = this.Bounds.GetMidX () - moverFrame.Width / 2;
			location.Y = this.Bounds.GetMidY () - moverFrame.Height / 2;
			moverFrame.Location = location;
			mover = new NSImageView (moverFrame);
			
			mover.ImageScaling = NSImageScale.AxesIndependently;
			mover.Image = NSImage.ImageNamed ("photo.jpg");
			
			NSDictionary animations = NSDictionary.FromObjectsAndKeys (
				new object[] {GroupAnimation(moverFrame)},
				new object[] {"frameRotation"});
			mover.Animations = animations;	
			
			AddSubview (mover);
		}
开发者ID:RangoLee,项目名称:mac-samples,代码行数:23,代码来源:GroupAnimationView.cs

示例14: CreatePieChart

        void CreatePieChart(CGRect frame)
        {
            // Create the chart
            pieChart = new ShinobiChart (frame.Inset(40)) {
                AutoresizingMask = ~UIViewAutoresizing.None,
                LicenseKey = "", // TODO: add your trail licence key here!
                DataSource = pieChartDataSource
            };
            UpdatePieTitle ();
            pieChart.Legend.Hidden = false;

            View.AddSubview (pieChart);
        }
开发者ID:bocoop,项目名称:MichelinMD,代码行数:13,代码来源:HandlingSelectionViewController.cs

示例15: CreateColumnChart

        void CreateColumnChart(CGRect frame)
        {
            // Create the chart
            columnChart = new ShinobiChart (frame.Inset(40)) {
                Title = "Grocery Sales Figures",
                AutoresizingMask = ~UIViewAutoresizing.None,
                LicenseKey = "" //TODO: add your trail licence key here!
            };

            // Add a pair of axes
            var xAxis = new SChartCategoryAxis ();
            xAxis.Style.InterSeriesPadding = 0;
            columnChart.XAxis = xAxis;

            var yAxis = new SChartNumberAxis {
                Title = "Sales (1000s)",
                RangePaddingHigh = new NSNumber(1)
            };
            columnChart.YAxis = yAxis;

            // Add to the view
            View.AddSubview (columnChart);

            var columnChartDelegate = new ColumnChartDelegate();
            columnChartDelegate.ToggledSelection += ColumnChartToggledSelection;

            columnChart.DataSource = columnChartDataSource;
            columnChart.Delegate = columnChartDelegate;

            // Show the legend
            columnChart.Legend.Hidden = false;
            columnChart.Legend.Placement = SChartLegendPlacement.InsidePlotArea;
        }
开发者ID:bocoop,项目名称:MichelinMD,代码行数:33,代码来源:HandlingSelectionViewController.cs


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