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


C# CGContext.RestoreState方法代码示例

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


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

示例1: FillRect

 public static void FillRect(CGContext context, RectangleF rect, CGColor color)
 {
     context.SaveState();
     context.AddRect(rect);
     context.Clip();
     context.SetFillColor(color);
     context.FillRect(rect);
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:9,代码来源:CoreGraphicsHelper.cs

示例2: DrawEllipsis

 public static void DrawEllipsis(CGContext context, RectangleF rect, CGColor color, float lineWidth)
 {
     context.SaveState();
     context.SetStrokeColor(color);
     context.SetLineWidth(lineWidth);
     context.AddEllipseInRect(rect);
     context.StrokePath();
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:9,代码来源:CoreGraphicsHelper.cs

示例3: DrawLayer

 public override void DrawLayer(CALayer layer, CGContext context)
 {
     context.SaveState ();
     context.SetFillColor (1.0f, 1.0f, 1.0f, 1.0f);
     context.FillRect (context.GetClipBoundingBox ());
     context.TranslateCTM (0.0f, layer.Bounds.Size.Height);
     context.ScaleCTM (1.0f, -1.0f);
     context.ConcatCTM (this.oParentController.currentPDFPage.GetDrawingTransform (CGPDFBox.Crop, layer.Bounds, 0, true));
     context.DrawPDFPage (this.oParentController.currentPDFPage);
     context.RestoreState ();
 }
开发者ID:Emasoft,项目名称:IpaziaPDFReader,代码行数:11,代码来源:TiledLayerDelegate.cs

示例4: DrawStars

		protected void DrawStars (CGContext context)
		{
			// HACK: Change SetRGBColor to SetFillColor
			context.SetFillColor (1f, 0f, 0f, 1f);

			// save state so that as we translate (move the origin around,
			// it goes back to normal when we restore)
			context.SetFillColor (0f, 0f, 0.329f, 1.0f);
			context.SaveState ();
			context.TranslateCTM (30, 300);
			DrawStar (context, 30);
			context.RestoreState ();

			context.SetFillColor (1f, 0f, 0f, 1f);
			context.SaveState ();
			context.TranslateCTM (120, 200);
			DrawStar (context, 30);
			context.RestoreState ();

		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:20,代码来源:CameraOverlayView.cs

示例5: DrawContentView

		public void DrawContentView(RectangleF rect, CGContext context, UITableViewElementCell cell)
		{
			context.SaveState();
			float r = 0;
			float g = 0;
			float b = 0;

			var gradient = new CGGradient(CGColorSpace.CreateDeviceRGB(), new float[] { r, g, b, 0.20f, r, g, b, 0.40f }, new float[] { 0, 1 });			
			context.DrawLinearGradient(gradient, new PointF(rect.Left, rect.Top), new PointF(rect.Left, rect.Bottom), CGGradientDrawingOptions.DrawsBeforeStartLocation);

			context.RestoreState();
		}
开发者ID:anujb,项目名称:MonoMobile.MVVM,代码行数:12,代码来源:SmokeyTheme.cs

示例6: DrawLayer

        public void DrawLayer(CALayer layer, CGContext context)
        {
            // fill with white background
            context.SetFillColor (1f, 1f, 1f, 1f);
            context.FillRect (Bounds);
            context.SaveState ();

            // flip page so we render it as it's meant to be read
            context.TranslateCTM (0f, Bounds.Height);
            context.ScaleCTM (1f, -1f);

            // scale page at the view-zoom level
            context.ScaleCTM (MyScale, MyScale);
            context.DrawPDFPage (Page);
            context.RestoreState ();
        }
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:16,代码来源:TiledPdfView.cs

示例7: DrawContentView

		public void DrawContentView(RectangleF rect, CGContext context, UITableViewElementCell cell)
		{
			context.SaveState();
			
			var backgroundColor = CellBackgroundColor;
			if (backgroundColor != null)
			{
				if (backgroundColor == UIColor.Clear)
					backgroundColor = UIColor.White;
				
				context.SetFillColorWithColor(backgroundColor.ColorWithAlpha(0.4f).CGColor);
				context.SetBlendMode(CGBlendMode.Overlay);
				context.FillRect(rect);
			}
			
			context.RestoreState();
		}
开发者ID:CartBlanche,项目名称:MonoMobile.MVVM,代码行数:17,代码来源:SampleTheme.cs

示例8: MeasureStringWidth

        // TODO: Cannot use NSAttributedString in iOS5, only iOS6+
//        public static RectangleF MeasureString(SizeF sizeConstraint, string text, string fontName, float fontSize)
//        {
//            NSMutableDictionary dict = new NSMutableDictionary();
//            dict.Add(NSAttributedString.FontAttributeName, NSFont.FromFontName(fontName, fontSize));
//            NSString nsstr = new NSString(text);
//            RectangleF rect = nsstr.BoundingRectWithSize(sizeConstraint, NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin, dict);
//            return rect;
//        }
        
        public static float MeasureStringWidth(CGContext context, string text, string fontName, float fontSize)
        {
			if (string.IsNullOrEmpty(text))
				return 0;

            context.SaveState();
            PointF pos = context.TextPosition;
            context.SelectFont(fontName, fontSize, CGTextEncoding.MacRoman);
            context.TextMatrix = CGAffineTransform.MakeScale(1.0f, -1.0f);
            //context.TranslateCTM(0, 20);
            context.ScaleCTM(1, -1);
            context.SetTextDrawingMode(CGTextDrawingMode.Invisible);
            context.ShowTextAtPoint(pos.X, pos.Y, text);
            PointF pos2 = context.TextPosition;
            context.RestoreState();
            
            return pos2.X - pos.X;
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:28,代码来源:CoreGraphicsHelper.cs

示例9: DrawLayer

		public override void DrawLayer (CALayer layer, CGContext context)
		{
			// keep a copy since (a) it's a _virtual_ property and (b) it could change between filling and flipping
			RectangleF bounds = view.Bounds;
			
			// fill with white background
			context.SetFillColor (1.0f, 1.0f, 1.0f, 1.0f);
			context.FillRect (bounds);
			context.SaveState ();

			// flip page so we render it as it's meant to be read
			context.TranslateCTM (0.0f, bounds.Height);
			context.ScaleCTM (1.0f, -1.0f);
	
			// scale page at the view-zoom level
			context.ScaleCTM (view.Scale, view.Scale);
			context.DrawPDFPage (view.Page);
			context.RestoreState ();
		}
开发者ID:rojepp,项目名称:monotouch-samples,代码行数:19,代码来源:TiledPdfView.cs

示例10: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		// Drawing with a white stroke color
		context.SetRGBStrokeColor (1, 1, 1, 1);
		// And drawing with a blue fill color
		context.SetRGBFillColor (0, 0, 1, 1);
		// Draw them with a 2 stroke width so they are a bit more visible.
		context.SetLineWidth (2);
		
		// Add Rect to the current path, then stroke it
		context.AddRect (new RectangleF (30, 30, 60, 60));
		context.StrokePath ();
		
		// Stroke Rect convenience that is equivalent to above
		context.StrokeRect (new RectangleF (30, 120, 60, 60));
		
		// Stroke rect convenience equivalent to the above, plus a call to context.SetLineWidth ().
		context.StrokeRectWithWidth (new RectangleF (30, 210, 60, 60), 10);
		// Demonstate the stroke is on both sides of the path.
		context.SaveState ();
		context.SetRGBStrokeColor (1, 0, 0, 1);
		context.StrokeRectWithWidth (new RectangleF (30, 210, 60, 60), 2);
		context.RestoreState ();
		
		var rects = new RectangleF []
		{
			new RectangleF (120, 30, 60, 60),
			new RectangleF (120, 120, 60, 60),
			new RectangleF (120, 210, 60, 60),
		};
		// Bulk call to add rects to the current path.
		context.AddRects (rects);
		context.StrokePath ();
		
		// Create filled rectangles via two different paths.
		// Add/Fill path
		context.AddRect (new RectangleF (210, 30, 60, 60));
		context.FillPath ();
		// Fill convienience.
		context.FillRect (new RectangleF (210, 120, 60, 60));
	}	
开发者ID:BoogieMAN2K,项目名称:monotouch-samples,代码行数:41,代码来源:PolyDrawing.cs

示例11: Draw

        public override void Draw(RectangleF bounds, CGContext context, UIView view)
        {
            var leftMargin = LeftRightPadding;

            // Superview is the container, its superview the uitableviewcell
            var uiTableViewCell = view.Superview.Superview as UITableViewCell;
            bool highlighted = uiTableViewCell != null && uiTableViewCell.Highlighted & IsTappedAssigned;
            var timeColor = highlighted ? UIColor.White : UIColor.Gray;
            var textColor = highlighted ? UIColor.White : UIColor.FromRGB(41, 41, 41);
            var nameColor = highlighted ? UIColor.White : UIColor.FromRGB(0, 64, 128);

            if (Image != null)
            {
                var imageRect = new RectangleF(LeftRightPadding, TopBottomPadding, 32f, 32f);
                UIColor.White.SetColor ();

                context.SaveState ();
                //context.TranslateCTM (imageRect.X, imageRect.Y);
                context.SetLineWidth (1);

                // On device, the shadow is painted in the opposite direction!
                context.SetShadowWithColor (new SizeF (0, 0), 3, UIColor.DarkGray.CGColor);
                context.AddPath (UIBezierPath.FromRect(imageRect).CGPath);
                context.FillPath ();
                context.RestoreState ();

                Image.Draw(imageRect);
                leftMargin += LeftRightPadding + imageRect.Width + 3f;
            }

            var contentWidth = bounds.Width - LeftRightPadding  - leftMargin;

            var daysAgo = Time.ToDaysAgo();
            timeColor.SetColor();
            var daysWidth = daysAgo.MonoStringLength(DateFont);
            RectangleF timeRect;

            timeRect = Image != null ? new RectangleF(leftMargin, TopBottomPadding + UserFont.LineHeight, daysWidth, DateFont.LineHeight) :
                                       new RectangleF(bounds.Width - LeftRightPadding - daysWidth,  TopBottomPadding + 1f, daysWidth, DateFont.LineHeight);

            view.DrawString(daysAgo, timeRect, DateFont, UILineBreakMode.TailTruncation);

            nameColor.SetColor();
            view.DrawString(Name,
                new RectangleF(leftMargin, TopBottomPadding, contentWidth, UserFont.LineHeight),
                UserFont, UILineBreakMode.TailTruncation
            );

            if (!string.IsNullOrEmpty(String))
            {
                UIColor.Black.SetColor();
                var top = TopBottomPadding + UserFont.LineHeight + 3f;
                if (Image != null)
                    top += DateFont.LineHeight;

                textColor.SetColor();

                if (Image == null)
                {
                    view.DrawString(String,
                                    new RectangleF(LeftRightPadding, top, bounds.Width - LeftRightPadding * 2, bounds.Height - TopBottomPadding - top),
                                    DescFont, UILineBreakMode.TailTruncation
                                    );
                }
                else
                {
                    view.DrawString(String,
                                    new RectangleF(leftMargin, top, contentWidth, bounds.Height - TopBottomPadding - top),
                                    DescFont, UILineBreakMode.TailTruncation
                                    );
                }
            }
        }
开发者ID:sergii-tkachenko,项目名称:Gistacular,代码行数:73,代码来源:NameTimeStringElement.cs

示例12: DrawAddPhotoButton

        void DrawAddPhotoButton(CGContext ctx)
        {
            UIColor background = pressed ? HighlightedButtonColor : NormalButtonColor;
            RectangleF bounds = PhotoRect;
            float alpha = 1.0f;

            ctx.SaveState ();
            ctx.AddPath (PhotoBorder);
            ctx.Clip ();

            using (var cs = CGColorSpace.CreateDeviceRGB ()) {
                var bottomCenter = new PointF (bounds.GetMidX (), bounds.GetMaxY ());
                var topCenter = new PointF (bounds.GetMidX (), bounds.Y);
                float[] gradColors;
                CGPath container;

                gradColors = new [] { 0.23f, 0.23f, 0.23f, alpha, 0.67f, 0.67f, 0.67f, alpha };
                using (var gradient = new CGGradient (cs, gradColors, new [] { 0.0f, 1.0f })) {
                    ctx.DrawLinearGradient (gradient, topCenter, bottomCenter, 0);
                }

                var bg = bounds.Inset (1.0f, 1.0f);
                container = GraphicsUtil.MakeRoundedRectPath (bg, 13.5f);
                ctx.AddPath (container);
                ctx.Clip ();

                background.SetFill ();
                ctx.FillRect (bg);

                gradColors = new [] {
                    0.0f, 0.0f, 0.0f, 0.75f,
                    0.0f, 0.0f, 0.0f, 0.65f,
                    0.0f, 0.0f, 0.0f, 0.35f,
                    0.0f, 0.0f, 0.0f, 0.05f
                };

                using (var gradient = new CGGradient (cs, gradColors, new float [] { 0.0f, 0.1f, 0.4f, 1.0f })) {
                    ctx.DrawLinearGradient (gradient, topCenter, bottomCenter, 0);
                }
            }

            //ctx.AddPath (PhotoBorder);
            //ctx.SetStrokeColor (0.5f, 0.5f, 0.5f, 1.0f);
            //ctx.SetLineWidth (0.5f);
            //ctx.StrokePath ();

            ctx.RestoreState ();
        }
开发者ID:pahlot,项目名称:FlightLog,代码行数:48,代码来源:EditAircraftProfileView.cs

示例13: FillEllipsis

 public static void FillEllipsis(CGContext context, RectangleF rect, CGColor color)
 {
     context.SaveState();
     context.SetFillColor(color);
     context.FillEllipseInRect(rect);
     context.FillPath();
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:8,代码来源:CoreGraphicsHelper.cs

示例14: DrawTextInRect

 public static SizeF DrawTextInRect(CGContext context, RectangleF rect, string text, string fontName, float fontSize, CGColor fontColor, UILineBreakMode breakMode, UITextAlignment alignment)
 {
     context.SaveState();
     context.SetFillColor(fontColor);
     NSString str = new NSString(text);
     SizeF size = str.DrawString(rect, UIFont.FromName(fontName, fontSize), breakMode, alignment);
     context.RestoreState();
     return size;
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:9,代码来源:CoreGraphicsHelper.cs

示例15: DrawTextAtPoint

 public static SizeF DrawTextAtPoint(CGContext context, PointF pt, string text, string fontName, float fontSize, CGColor fontColor)
 {
     context.SaveState();
     context.SetFillColor(fontColor);
     NSString str = new NSString(text);
     SizeF size = str.DrawString(pt, UIFont.FromName(fontName, fontSize));
     context.RestoreState();
     return size;
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:9,代码来源:CoreGraphicsHelper.cs


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