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


C# CGContext.DrawLinearGradient方法代码示例

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


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

示例1: Draw

        public override void Draw(RectangleF bounds, CGContext context, UIView view)
        {
            UIColor.White.SetFill ();
            context.FillRect (bounds);

            context.DrawLinearGradient (
                gradient,
                new PointF (bounds.Left, bounds.Top),
                new PointF (bounds.Left, bounds.Bottom),
                CGGradientDrawingOptions.DrawsAfterEndLocation
            );

            UIColor.DarkGray.SetColor ();
            view.DrawString (
                this.Label,
                new RectangleF (10, 10, bounds.Width / 2, 10),
                captionFont,
                UILineBreakMode.TailTruncation
            );

            UIColor.Black.SetColor ();
            view.DrawString (
                this.Number.ToString (),
                new RectangleF (bounds.Width / 2, 10, (bounds.Width / 2) - 10, 10),
                amountFont,
                UILineBreakMode.TailTruncation,
                UITextAlignment.Right
            );
        }
开发者ID:rajeshwarn,项目名称:GhostPractice-iPadRepo,代码行数:29,代码来源:NumberElement.cs

示例2: Draw

		public override void Draw(RectangleF bounds, CGContext context, UIView view)
		{
			UIColor.White.SetFill();
			context.FillRect(bounds);
			
			context.DrawLinearGradient(gradient, new PointF(bounds.Left, bounds.Top), new PointF(bounds.Left, bounds.Bottom), CGGradientDrawingOptions.DrawsAfterEndLocation);
			
			UIColor.DarkGray.SetColor();
			view.DrawString(Caption, new RectangleF(10, 10, bounds.Width - 20, TextHeight(bounds)), _CaptionFont, UILineBreakMode.WordWrap);
		}
开发者ID:briandonahue,项目名称:MonoTouch.MVVM,代码行数:10,代码来源:MovieElement.cs

示例3: DrawGradient

 protected override void DrawGradient(RectangleF rect, CGContext context)
 {
     context.DrawLinearGradient(new CGGradient(CGColorSpace.CreateDeviceRGB(),
                                               new CGColor[] {
         TintColor.CGColor,
         TintColor.Darken(TintDarkenFactor).CGColor
     }),
                                new PointF(0.5f, rect.Top),
                                new PointF(0.5f, rect.Bottom), 0);
 }
开发者ID:abeiderman,项目名称:FrozenHeadersGrid_MonoTouch,代码行数:10,代码来源:GridHeaderRowView.cs

示例4: 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

示例5: Draw

        public override void Draw(RectangleF bounds, CGContext context, UIView view)
        {
            UIColor.White.SetFill ();
            context.FillRect (bounds);

            context.DrawLinearGradient (gradient, new PointF (bounds.Left, bounds.Top), new PointF (bounds.Left, bounds.Bottom), CGGradientDrawingOptions.DrawsAfterEndLocation);

            UIColor.Black.SetColor ();
            view.DrawString("Assigned to: " + this.User, new RectangleF(10, 5, bounds.Width-20, 7), nameFont,UILineBreakMode.TailTruncation);

            UIColor.DarkGray.SetColor();
            view.DrawString(this.Text, new RectangleF(10, 30, bounds.Width - 20, TextHeight(bounds) ), descriptionFont, UILineBreakMode.WordWrap);
        }
开发者ID:GunioRobot,项目名称:AgileZen,代码行数:13,代码来源:StoryDetailElement.cs

示例6: Draw

		public override void Draw (RectangleF bounds, CGContext context, UIView view)
		{
			UIColor.White.SetFill ();
			context.FillRect (bounds);
			
			context.DrawLinearGradient (gradient, new PointF (bounds.Left, bounds.Top), new PointF (bounds.Left, bounds.Bottom), CGGradientDrawingOptions.DrawsAfterEndLocation);
			
			UIColor.Black.SetColor ();
			view.DrawString(this.From, new RectangleF(10, 5, bounds.Width/2, 10 ), fromFont, UILineBreakMode.TailTruncation);
			
			UIColor.Brown.SetColor ();
			view.DrawString(this.Sent, new RectangleF(bounds.Width/2, 5, (bounds.Width/2) - 10, 10 ), dateFont, UILineBreakMode.TailTruncation, UITextAlignment.Right);
			
			UIColor.DarkGray.SetColor();
			view.DrawString(this.Subject, new RectangleF(10, 30, bounds.Width - 20, TextHeight(bounds) ), subjectFont, UILineBreakMode.WordWrap);
		}
开发者ID:21Off,项目名称:21Off,代码行数:16,代码来源:SampleOwnerDrawnElement.cs

示例7: Draw

        public override void Draw(RectangleF bounds, CGContext context, UIView view)
        {
            UIColor.White.SetFill ();
            context.FillRect (bounds);

            context.DrawLinearGradient (
                gradient,
                new PointF (bounds.Left, bounds.Top),
                new PointF (bounds.Left, bounds.Bottom),
                CGGradientDrawingOptions.DrawsAfterEndLocation
            );

            //UIColor.Black.SetColor ();
            ColorHelper.GetGPLightPurple ().SetColor ();
            view.DrawString (
                this.Label,
                new RectangleF (10, 10, bounds.Width, 20),
                captionFont,
                UILineBreakMode.TailTruncation
            );
        }
开发者ID:rajeshwarn,项目名称:GhostPractice-iPadRepo,代码行数:21,代码来源:TitleElement.cs

示例8: Draw

        public override void Draw(RectangleF bounds, CGContext context, UIView view)
        {
            //			string name = CultureInfo.CurrentCulture.Name;
            //			NumberFormatInfo nfi = new CultureInfo (name, true).NumberFormat;
            //			if (name == "en-ZA") {
            //				nfi.CurrencyDecimalSeparator = ",";
            //				nfi.CurrencyGroupSeparator = " ";
            //
            //				nfi.NumberDecimalSeparator = ",";
            //				nfi.NumberGroupSeparator = " ";
            //			}

            UIColor.White.SetFill ();
            context.FillRect (bounds);

            context.DrawLinearGradient (
                gradient,
                new PointF (bounds.Left, bounds.Top),
                new PointF (bounds.Left, bounds.Bottom),
                CGGradientDrawingOptions.DrawsAfterEndLocation
            );

            UIColor.DarkGray.SetColor ();
            view.DrawString (
                this.Label,
                new RectangleF (20, 10, bounds.Width / 2, 10),
                captionFont,
                UILineBreakMode.TailTruncation
            );

            UIColor.Black.SetColor ();
            view.DrawString (
                this.Amount.ToString ("N2"),
                new RectangleF (bounds.Width / 2, 10, (bounds.Width / 2) - 10, 10),
                amountFont,
                UILineBreakMode.TailTruncation,
                UITextAlignment.Right
            );
        }
开发者ID:rajeshwarn,项目名称:GhostPractice-iPadRepo,代码行数:39,代码来源:FinanceElement.cs

示例9: Draw

		public override void Draw (RectangleF bounds, CGContext context, UIView view)
		{
			UIColor.White.SetFill ();
			context.FillRect (bounds);
			
			context.DrawLinearGradient (gradient, new PointF (bounds.Left, bounds.Top), new PointF (bounds.Left, bounds.Bottom), CGGradientDrawingOptions.DrawsAfterEndLocation);
			
			UIColor.Black.SetColor ();
			((NSString) From).DrawString (new RectangleF (10, 5, bounds.Width / 2, 10 ), NSStringDrawingOptions.TruncatesLastVisibleLine | NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes ()
			{
				Font = fromFont,
			}, null);
			
			UIColor.Brown.SetColor ();
			((NSString) Sent).DrawString (new RectangleF (bounds.Width / 2, 5, (bounds.Width / 2) - 10, 10), NSStringDrawingOptions.TruncatesLastVisibleLine | NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes ()
			{
				Font = dateFont,
				ParagraphStyle = new NSMutableParagraphStyle ()
				{
					Alignment = UITextAlignment.Right,
				},
			}, null);
			
			UIColor.DarkGray.SetColor();
			((NSString) Subject).DrawString (new RectangleF (10, 30, bounds.Width - 20, TextHeight (bounds)), NSStringDrawingOptions.TruncatesLastVisibleLine | NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes ()
			{
				Font = subjectFont,
				ParagraphStyle = new NSMutableParagraphStyle ()
				{
					LineBreakMode = UILineBreakMode.WordWrap,
				},
			}, null);
		}
开发者ID:prashantvc,项目名称:MonoTouch.Dialog,代码行数:33,代码来源:DemoOwnerDrawnElement.cs

示例10: DrawElementView

		public void DrawElementView(RectangleF rect, CGContext context, UITableViewElementCell cell)
		{
			context.DrawLinearGradient(gradient, new PointF(rect.Left, rect.Top), new PointF(rect.Left, rect.Bottom), CGGradientDrawingOptions.DrawsBeforeStartLocation);
			cell.ShouldDrawBorder = true;
		}
开发者ID:vknair74,项目名称:MonoMobile.Views,代码行数:5,代码来源:GradientTheme.cs

示例11: DrawShine

        private void DrawShine(CGContext context, RectangleF rect)
        {
            context.SaveState ();

            context.BeginPath ();
            var maxY = MakePath (context, rect);
            context.Clip ();

            /*var locations = new float[] { 0.0f, 0.5f };
            var components = new float[] { 0.92f, 0.92f, 0.92f, 1.0f, 0.82f, 0.82f, 0.82f, 0.4f };*/

            var locations = new float[] { 0f, 0.4f, 0.5f, 0.5f, 0.6f, 1.0f };
            var colors = new UIColor[] {
                UIColor.FromWhiteAlpha (1.0f, 0.885f),
                UIColor.FromWhiteAlpha (1.0f, 0.45f),
                UIColor.FromWhiteAlpha (1.0f, 0.23f),
                UIColor.FromWhiteAlpha (1.0f, 0.10f),
                UIColor.FromRGBA (0f, 0f, 0f, 0.13f),
                UIColor.FromRGBA (0f, 0f, 0f, 0.13f)
            };
            var components = GetComponents (colors);

            var darkLoc = new float[] { 0.5f, 1.0f };
            var darkComp = new float[] { 0.08f, 0.08f, 0.08f, 0.6f, 0.18f, 0.18f, 0.18f, 0.2f };

            using (var cspace = CGColorSpace.CreateDeviceRGB ())
            using (var darkGrad = new CGGradient (cspace, darkComp, darkLoc))
            using (var gradient = new CGGradient (cspace, components, locations)) {

                PointF sPoint = new PointF (0f, 0f),
                    ePoint = new PointF (0f, maxY);
                context.DrawLinearGradient (gradient, sPoint, ePoint, 0);
            }

            context.RestoreState ();
        }
开发者ID:Alxandr,项目名称:CustomBadge,代码行数:36,代码来源:CustomBadgeView.cs

示例12: DrawLinearGradient

        private void DrawLinearGradient(CGContext context, RectangleF rect, CGColor startColor, CGColor  endColor)
        {
            CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB ();
            float [] locations = { 0.0f, 1.0f };

            CGColor [] colors = new CGColor[] { startColor, endColor };

            CGGradient gradient = new CGGradient (colorSpace, colors, locations);

            PointF startPoint = new PointF (rect.GetMidX (), rect.GetMinY ());
            PointF endPoint = new PointF (rect.GetMidX (), rect.GetMaxY ());

            context.SaveState ();
            context.AddPath (UIBezierPath.FromRoundedRect (rect, 10).CGPath);
            context.Clip ();
            context.DrawLinearGradient (gradient, startPoint, endPoint, 0);
            context.RestoreState ();
        }
开发者ID:GonzRu,项目名称:TwitterBot,代码行数:18,代码来源:MoreTweetsTableViewCell.cs

示例13: DrawInContext

        public override void DrawInContext(CGContext ctx)
        {
            base.DrawInContext (ctx);

            var knobFrame = CGRect.Inflate(Bounds, -2.0f, -2.0f);

            UIBezierPath knobPath = UIBezierPath.FromRoundedRect((CGRect)knobFrame, (nfloat)knobFrame.Height / 2.0f);

            // 1) fill - with a subtle shadow
            ctx.SetShadow(new CGSize(0, 1), 1.0f, UIColor.Gray.CGColor);
            ctx.SetFillColor( UIColor.White.CGColor);
            ctx.AddPath( knobPath.CGPath);
            ctx.FillPath ();

            // 2) outline
            ctx.SetStrokeColor(UIColor.Gray.CGColor);
            ctx.SetLineWidth((nfloat)0.5f);
            ctx.AddPath(knobPath.CGPath);
            ctx.StrokePath ();

            // 3) inner gradient
            var rect = CGRect.Inflate(knobFrame, -2.0f, -2.0f);
            var clipPath = UIBezierPath.FromRoundedRect ((CGRect)rect, (nfloat)rect.Height / 2.0f);

            CGGradient myGradient;
            CGColorSpace myColorspace;

            nfloat[] locations = { 0.0f, 1.0f };
            nfloat[] components = { 0.0f, 0.0f, 0.0f , 0.15f,  // Start color
                0.0f, 0.0f, 0.0f, 0.05f }; // End color

            myColorspace = CGColorSpace.CreateDeviceRGB (); // CGColorSpaceCreateDeviceRGB();
            myGradient = new CGGradient( myColorspace, components, locations);

            CGPoint startPoint = new CGPoint((float)rect.GetMidX(), (float)rect.GetMinY());
            CGPoint endPoint = new CGPoint((float)rect.GetMidX(), (float)rect.GetMaxY());

            ctx.SaveState ();
            ctx.AddPath( clipPath.CGPath);
            ctx.Clip ();
            ctx.DrawLinearGradient( (CGGradient)myGradient, (CGPoint)startPoint, (CGPoint)endPoint, (CGGradientDrawingOptions)0);

            myGradient.Dispose ();
            myColorspace.Dispose();
            ctx.RestoreState();

            // 4) highlight
            if (Highlighted)
            {
                // fill
                ctx.SetFillColor(UIColor.FromWhiteAlpha((nfloat)0.0f, (nfloat)0.1f).CGColor);
                ctx.AddPath( knobPath.CGPath);
                ctx.FillPath();
            }
            //
            //			if (Highlighted)
            //				ctx.SetFillColor (UIColor.Yellow.CGColor);
            //			else
            //				ctx.SetFillColor (UIColor.Red.CGColor);
            //
            //			ctx.FillRect (Bounds);
        }
开发者ID:jasallen,项目名称:RangeSliderDemoVideoFiles,代码行数:62,代码来源:RangeSliderKnobLayer.cs

示例14: DrawElementView

		public void DrawElementView(RectangleF rect, CGContext context, UITableViewElementCell cell)
		{
			var gradientFrame = rect;
			
			var shineFrame = gradientFrame;
			shineFrame.Y += 1;
			shineFrame.X += 1;
			shineFrame.Width -= 2;
			shineFrame.Height = (shineFrame.Height / 2);

			CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();

			var gradient = new CGGradient(
			    colorSpace,
			    new float[] { 0f, 0f,0f, 0.70f, 
							  0f, 0f, 0f, 0.40f},
				new float[] { 0, 1 } );

			var shineGradient = new CGGradient(
			    colorSpace,
			    new float[] { 1f, 1f, 1f, 0.80f, 
							  1f, 1f, 1f, 0.10f},
				new float[] { 0, 1 } );
			
			if (Cell != null && Cell.Highlighted)
			{
				context.SetFillColorWithColor(HighlightColor.CGColor);
			}
			else
			{
				context.SetFillColorWithColor(CellBackgroundColor.CGColor);
			}
			context.FillRect(rect);
	
			context.DrawLinearGradient(gradient, new PointF(gradientFrame.Left, gradientFrame.Top), new PointF(gradientFrame.Left, gradientFrame.Bottom), CGGradientDrawingOptions.DrawsAfterEndLocation);		
			context.DrawLinearGradient(shineGradient, new PointF(shineFrame.Left, shineFrame.Top), new PointF(shineFrame.Left, shineFrame.Bottom), CGGradientDrawingOptions.DrawsAfterEndLocation);
		}
开发者ID:vknair74,项目名称:MonoMobile.Views,代码行数:37,代码来源:GlassButtonTheme.cs

示例15: DrawInContext

    public override void DrawInContext(CGContext context)
    {
        // The clipping rects we plan to use, which also defines the location and span of each gradient
        var clips = new RectangleF []
        {
            new RectangleF(10, 30, 60, 90),
            new RectangleF(90, 30, 60, 90),
            new RectangleF(170, 30, 60, 90),
            new RectangleF(250, 30, 60, 90),
            new RectangleF(30, 140, 120, 120),
            new RectangleF(170, 140, 120, 120),
            new RectangleF(30, 280, 120, 120),
            new RectangleF(170, 280, 120, 120),
        };

        // Linear Gradients
        PointF start, end;

        // Clip to area to draw the gradient, and draw it. Since we are clipping, we save the graphics state
        // so that we can revert to the previous larger area.
        context.SaveState();
        context.ClipToRect(clips[0]);

        // A linear gradient requires only a starting & ending point.
        // The colors of the gradient are linearly interpolated along the line segment connecting these two points
        // A gradient location of 0 means that color is expressed fully at the 'start' point
        // a location of 1 means that color is expressed fully at the 'end' point.
        // The gradient fills outwards perpendicular to the line segment connectiong start & end points
        // (which is why we need to clip the context, or the gradient would fill beyond where we want it to).
        // The gradient options (last) parameter determines what how to fill the clip area that is "before" and "after"
        // the line segment connecting start & end.
        start = demoLGStart(clips[0]);
        end = demoLGEnd(clips[0]);
        context.DrawLinearGradient(gradient, start, end, 0);
        context.RestoreState();

        // Same as above for each combination of CGGradientDrawingOptions.DrawsBeforeStartLocation & CGGradientDrawingOptions.DrawsAfterEndLocation

        context.SaveState();
        context.ClipToRect(clips[1]);
        start = demoLGStart(clips[1]);
        end = demoLGEnd(clips[1]);
        context.DrawLinearGradient(gradient, start, end, CGGradientDrawingOptions.DrawsBeforeStartLocation);
        context.RestoreState();

        context.SaveState();
        context.ClipToRect(clips[2]);
        start = demoLGStart(clips[2]);
        end = demoLGEnd(clips[2]);
        context.DrawLinearGradient(gradient, start, end, CGGradientDrawingOptions.DrawsAfterEndLocation);
        context.RestoreState();

        context.SaveState();
        context.ClipToRect(clips[3]);
        start = demoLGStart(clips[3]);
        end = demoLGEnd(clips[3]);
        context.DrawLinearGradient(gradient, start, end, CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
        context.RestoreState();

        // Radial Gradients

        float startRadius, endRadius;

        // Clip to area to draw the gradient, and draw it. Since we are clipping, we save the graphics state
        // so that we can revert to the previous larger area.
        context.SaveState();
        context.ClipToRect(clips[4]);

        // A radial gradient requires a start & end point as well as a start & end radius.
        // Logically a radial gradient is created by linearly interpolating the center, radius and color of each
        // circle using the start and end point for the center, start and end radius for the radius, and the color ramp
        // inherant to the gradient to create a set of stroked circles that fill the area completely.
        // The gradient options specify if this interpolation continues past the start or end points as it does with
        // linear gradients.
        start = end = demoRGCenter(clips[4]);
        startRadius = demoRGInnerRadius(clips[4]);
        endRadius = demoRGOuterRadius(clips[4]);
        context.DrawRadialGradient(gradient, start, startRadius, end, endRadius, 0);
        context.RestoreState();

        // Same as above for each combination of CGGradientDrawingOptions.DrawsBeforeStartLocation & CGGradientDrawingOptions.DrawsAfterEndLocation

        context.SaveState();
        context.ClipToRect(clips[5]);
        start = end = demoRGCenter(clips[5]);
        startRadius = demoRGInnerRadius(clips[5]);
        endRadius = demoRGOuterRadius(clips[5]);
        context.DrawRadialGradient(gradient, start, startRadius, end, endRadius, CGGradientDrawingOptions.DrawsBeforeStartLocation);
        context.RestoreState();

        context.SaveState();
        context.ClipToRect(clips[6]);
        start = end = demoRGCenter(clips[6]);
        startRadius = demoRGInnerRadius(clips[6]);
        endRadius = demoRGOuterRadius(clips[6]);
        context.DrawRadialGradient(gradient, start, startRadius, end, endRadius, CGGradientDrawingOptions.DrawsAfterEndLocation);
        context.RestoreState();

        context.SaveState();
        context.ClipToRect(clips[7]);
//.........这里部分代码省略.........
开发者ID:CVertex,项目名称:monotouch-samples,代码行数:101,代码来源:rendereddrawing.cs


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