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


C# CGContext.BeginPath方法代码示例

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


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

示例1: DrawMapRect

 /// <summary>
 /// Draws the map rectangle.
 /// </summary>
 /// <param name="mapRect">Map rectangle.</param>
 /// <param name="zoomScale">Zoom scale.</param>
 /// <param name="context"> Graphics context.</param>
 public override void DrawMapRect(MKMapRect mapRect, nfloat zoomScale, CGContext context)
 {
     base.DrawMapRect(mapRect, zoomScale, context);
     var multiPolygons = (MultiPolygon)this.polygonOverlay;
     foreach (var item in multiPolygons.Polygons)
     {
         var path = new CGPath();
         this.InvokeOnMainThread(() =>
             {
                 path = PolyPath(item.Polygon);
             });
         if (path != null)
         {
             context.SetFillColor(item.FillColor);
             context.BeginPath();
             context.AddPath(path);
             context.DrawPath(CGPathDrawingMode.EOFill);
             if (item.DrawOutlines)
             {
                 context.BeginPath();
                 context.AddPath(path);
                 context.StrokePath();
             }
         }
     }
 }
开发者ID:MilenPavlov,项目名称:treewatch,代码行数:32,代码来源:MultiPolygonView.cs

示例2: DrawPolyline

 public void DrawPolyline(MKPolyline polygon,MKMapRect mapRect, float zoomScale, CGContext context)
 {
     CGPath path = this.polyPath (polygon,mapRect,zoomScale,context);
     if (path != null)
     {
         this.ApplyFillProperties (context, zoomScale);
         context.BeginPath ();
         context.AddPath (path);
         context.DrawPath (CGPathDrawingMode.Stroke);
         this.ApplyStrokeProperties (context, zoomScale);
         context.BeginPath ();
         context.AddPath (path);
         context.StrokePath ();
     }
 }
开发者ID:Clancey,项目名称:ClanceyLib,代码行数:15,代码来源:PolylineOverlay.cs

示例3: Draw

        public override void Draw(CGRect bounds, CGContext context, UIView view)
        {
            var width = 0.5f / UIScreen.MainScreen.Scale;
            context.BeginPath();
            context.SetLineWidth(width);
            context.SetStrokeColor(UIColor.FromRGB(150, 150, 154).CGColor);
            var x = bounds.Width / 2f - width;
			context.MoveTo(x, 0f);
			context.AddLineToPoint(x, bounds.Height);
            context.StrokePath();

            var row = Value;
            var half = bounds.Height / 2;
            var halfText = _font.LineHeight / 2 + 1;

            row.Image1.Draw(new CGRect(15, half - 8f, 16f, 16f));

            if (!string.IsNullOrEmpty(row.Text1))
            {
                UIColor.Gray.SetColor();
                new NSString(row.Text1).DrawString(new CGRect(36,  half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation);
            }

            row.Image2.Draw(new CGRect(bounds.Width / 2 + 15, half - 8f, 16f, 16f));

            if (!string.IsNullOrEmpty(row.Text2))
            {
                UIColor.Gray.SetColor();
                new NSString(row.Text2).DrawString(new CGRect(bounds.Width / 2 + 36,  half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation);
            }
        }
开发者ID:Jeff-Lewis,项目名称:CodeBucket,代码行数:31,代码来源:SplitElement.cs

示例4: DrawInContext

		public override void DrawInContext (CGContext ctx)
		{
			base.DrawInContext (ctx);
			
			var bounds = Bounds;
			var c = new PointF (bounds.GetMidX (), bounds.GetMidY ());
			
			ctx.BeginPath ();
			ctx.MoveTo (c.X, c.Y);
			ctx.AddLineToPoint (bounds.Right, c.Y);
			ctx.AddArc (c.X, c.Y, bounds.Width/2, (float)0, (float)Angle, false);
			ctx.AddLineToPoint (c.X, c.Y);
			ctx.SetFillColor (otherColor);
			ctx.FillPath ();
			
			ctx.BeginPath ();
			ctx.MoveTo (c.X, c.Y);
			ctx.AddLineToPoint (bounds.Right, c.Y);
			ctx.AddArc (c.X, c.Y, bounds.Width/2, (float)0, (float)(1e-7 + Angle), true);
			ctx.AddLineToPoint (c.X, c.Y);
			ctx.SetFillColor (color);
			ctx.FillPath ();
			
		}
开发者ID:GSerjo,项目名称:Seminars,代码行数:24,代码来源:PieChartLayer.cs

示例5: Draw

        public override void Draw(RectangleF bounds, CGContext context, UIView view)
        {
            context.BeginPath();
			context.SetLineWidth(1.0f);
			context.SetStrokeColor(UIColor.FromRGB(199, 199, 205).CGColor);
			var x = (int)System.Math.Ceiling(bounds.Width / 2 - 0.5f);
			context.MoveTo(x, 0f);
			context.AddLineToPoint(x, bounds.Height);
            context.StrokePath();

            /*
            context.BeginPath();
            context.SetStrokeColor(UIColor.FromRGBA(250, 250, 250, 128).CGColor);
            context.MoveTo(bounds.Width / 2 + 0.5f, 0);
            context.AddLineToPoint(bounds.Width / 2 + 0.5f, bounds.Height);
            context.StrokePath();
            */

            var row = Value;
            var half = bounds.Height / 2;
            var halfText = _font.LineHeight / 2 + 1;

            row.Image1.Draw(new RectangleF(15, half - 8f, 16f, 16f));

            if (!string.IsNullOrEmpty(row.Text1))
            {
                UIColor.Gray.SetColor();
                view.DrawString(row.Text1, new RectangleF(36,  half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation);
            }

            row.Image2.Draw(new RectangleF(bounds.Width / 2 + 15, half - 8f, 16f, 16f));

            if (!string.IsNullOrEmpty(row.Text2))
            {
                UIColor.Gray.SetColor();
                view.DrawString(row.Text2, new RectangleF(bounds.Width / 2 + 36,  half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation);
            }
        }
开发者ID:rcaratchuk,项目名称:MonoTouch.Dialog,代码行数:38,代码来源:SplitElement.cs

示例6: DrawInContext

		public void DrawInContext (CGContext context, bool isDebuggingEnabled, bool usePreciseLocation)
		{
			LinePoint maybePriorPoint = null;

			foreach (var point in points) {
				if (maybePriorPoint == null) {
					maybePriorPoint = point;
					continue;
				}

				var priorPoint = maybePriorPoint;

				var color = UIColor.Black;

				if (isDebuggingEnabled) {
					if (point.Properties.Contains (PointType.Cancelled))
						color = UIColor.Red;
					else if (point.Properties.Contains (PointType.NeedsUpdate))
						color = UIColor.Orange;
					else if (point.Properties.Contains (PointType.Finger))
						color = UIColor.Purple;
					else if (point.Properties.Contains (PointType.Coalesced))
						color = UIColor.Green;
					else if (point.Properties.Contains (PointType.Predicted))
						color = UIColor.Blue;
				} else {
					if (point.Properties.Contains (PointType.Cancelled))
						color = UIColor.Clear;
					else if (point.Properties.Contains (PointType.Finger))
						color = UIColor.Purple;
					if (point.Properties.Contains (PointType.Predicted) && !point.Properties.Contains (PointType.Cancelled))
						color = color.ColorWithAlpha (0.5f);
				}

				var location = usePreciseLocation ? point.PreciseLocation : point.Location;
				var priorLocation = usePreciseLocation ? priorPoint.PreciseLocation : priorPoint.Location;

				context.SetStrokeColor (color.CGColor);
				context.BeginPath ();
				context.MoveTo (priorLocation.X, priorLocation.Y);
				context.AddLineToPoint (location.X, location.Y);
				context.SetLineWidth (point.Magnitude);
				context.StrokePath ();

				maybePriorPoint = point;
			}
		}
开发者ID:russellharvey,项目名称:monotouch-samples,代码行数:47,代码来源:Line.cs

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

示例8: DrawRoundedRect

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

            context.BeginPath ();
            context.SetFillColor (badgeColor.CGColor);
            MakePath (context, rect);
            context.SetShadowWithColor (new SizeF (1.0f, 1.0f), 3, UIColor.Black.CGColor);
            context.FillPath ();

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

示例9: DrawBorder

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

            context.BeginPath ();
            float lineSize = 2f;
            if (this.scaleFactor > 1) {
                lineSize += this.scaleFactor * .25f;
            }
            context.SetLineWidth (lineSize);
            context.SetStrokeColor (this.borderColor.CGColor);
            MakePath (context, rect);
            context.ClosePath ();
            context.StrokePath ();

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

示例10: DrawRectangle

        private void DrawRectangle(CGContext g, PinboardData.RectangleInfo rectInfo)
        {
            g.SetFillColor(rectInfo.Color);
            g.FillRect(rectInfo.Rectangle);

            float pw = 0.5f;
            CGColor rectBorderColor = new CGColor(0f, rectInfo.Color.Alpha);

            g.SetLineWidth(pw);
            g.SetStrokeColor(rectBorderColor);
            g.SetFillColor(rectInfo.Color);
            g.SetLineJoin(CGLineJoin.Miter);
            g.BeginPath();
            g.StrokeRect(rectInfo.Rectangle);

            int margin = 5;
            // TODO: Make the font configurable
            NSFont font = NSFont.FromFontName("Helvetica", 12f);
            NSObject[] objects = new NSObject[] { font, (NSNumber)0 };
            NSObject[] keys = new NSObject[] { NSAttributedString.FontAttributeName, NSAttributedString.LigatureAttributeName };
            NSDictionary attributes = NSDictionary.FromObjectsAndKeys(objects, keys);
            NSAttributedString attrString = new NSAttributedString(rectInfo.Name, attributes);

            attrString.DrawString(new RectangleF(rectInfo.X + margin, rectInfo.Y + margin, rectInfo.Width - 2 * margin, rectInfo.Height - 2 * margin));
        }
开发者ID:jlyonsmith,项目名称:Pinboard,代码行数:25,代码来源:PinboardView.cs

示例11: drawSlicesWithRadius

        void drawSlicesWithRadius(float radius, PointF center, CGContext contextRef)
        {
            bool cgClockwise = !Clockwise;

            uint startingSlice = StartingSlice - 1;

            if (ProgressCounter == 0 && Theme.DrawIncompleteArcIfNoProgress)
            {
                DrawArcInContext(contextRef, center, radius, 0, M_PI * 2, Theme.IncompletedColor.CGColor, cgClockwise);
                return;
            }

            if (!Theme.SliceDividerHidden && Theme.SliceDividerThickness > 0)
            {
                float sliceAngle = (2 * M_PI) / ProgressTotal;

                for (int i =0; i < ProgressTotal; i++) {
                    float startValue = (sliceAngle * i) + sliceAngle * startingSlice;
                    float startAngle, endAngle;
                    if (Clockwise)
                    {
                        startAngle = -M_PI_2 + startValue;
                        endAngle = startAngle + sliceAngle;
                    }
                    else
                    {
                        startAngle = -M_PI_2 - startValue;
                        endAngle = startAngle - sliceAngle;
                    }

                    contextRef.BeginPath();
                    contextRef.MoveTo(center.X, center.Y);
                    contextRef.AddArc(center.X, center.Y, radius, startAngle, endAngle, cgClockwise);

                    CGColor color = Theme.IncompletedColor.CGColor;

                    if (i < ProgressCounter)
                    {
                        color = Theme.CompletedColor.CGColor;
                    }

                    contextRef.SetFillColor(color);
                    contextRef.FillPath();
                }
            }
            else
            {
                double originAngle, endAngle;
                double sliceAngle = (2 * M_PI) / ProgressTotal;
                double startingAngle = sliceAngle * startingSlice;
                double progressAngle = sliceAngle * ProgressCounter;

                if (Clockwise) {
                    originAngle = - M_PI_2 + startingAngle;
                    endAngle = originAngle + progressAngle;
                } else {
                    originAngle = - M_PI_2 - startingAngle;
                    endAngle = originAngle - progressAngle;
                }

                DrawArcInContext(contextRef, center, radius, (float)originAngle, (float)endAngle, Theme.CompletedColor.CGColor, cgClockwise);

                if (ProgressCounter < ProgressTotal)
                {
                    DrawArcInContext(contextRef, center, radius, (float)endAngle, (float)originAngle, Theme.IncompletedColor.CGColor, cgClockwise);
                }
            }
        }
开发者ID:ChristianJaspers,项目名称:saapp-ios,代码行数:68,代码来源:MDRadialProgressView.cs

示例12: drawSlicesSeparators

        void drawSlicesSeparators(CGContext contextRef, SizeF viewSize, PointF center)
        {
            int outerDiameter = (int)Math.Min(viewSize.Width, viewSize.Height);

            double outerRadius = outerDiameter / 2.0 - internalPadding;
            int innerDiameter = (int)(outerDiameter - Theme.Thickness);
            double innerRadius = innerDiameter / 2.0;
            int sliceCount = (int)ProgressTotal;
            double sliceAngle = (2 * M_PI) / sliceCount;

            contextRef.SetLineWidth(Theme.SliceDividerThickness);
            contextRef.SetStrokeColor(Theme.SliceDividerColor.CGColor);
            contextRef.MoveTo(center.X, center.Y);

            for (int i = 0; i < sliceCount; i++) {
                contextRef.BeginPath();

                double startAngle = sliceAngle * i - M_PI_2;
                double endAngle = sliceAngle * (i + 1) - M_PI_2;

                contextRef.AddArc(center.X, center.Y, (float)outerRadius, (float)startAngle, (float)endAngle, false);
                contextRef.AddArc(center.X, center.Y, (float)innerRadius, (float)endAngle, (float)startAngle, true);
                contextRef.StrokePath();
            }
        }
开发者ID:ChristianJaspers,项目名称:saapp-ios,代码行数:25,代码来源:MDRadialProgressView.cs

示例13: DrawArcInContext

 void DrawArcInContext(CGContext context, PointF center, float radius, float startAngle, float endAngle, CGColor color, bool cgClockwise)
 {
     context.BeginPath();
     context.MoveTo(center.X, center.Y);
     context.AddArc(center.X, center.Y, radius, startAngle, endAngle, cgClockwise);
     context.SetFillColor(color);
     context.FillPath();
 }
开发者ID:ChristianJaspers,项目名称:saapp-ios,代码行数:8,代码来源:MDRadialProgressView.cs

示例14: DrawPoints

        //does the actual coloring
        void DrawPoints(CGContext dctx)
        {
            var swatches = Swatches;
            var swatchslider = swatchSlider;

            dctx.BeginPath ();
            dctx.MoveTo (Points.First().X, Points.First().Y);
            dctx.SetLineWidth (swatchslider.Value);
            dctx.SetBlendMode (CGBlendMode.Normal);

            foreach (var crayon in Crayons) {
                if(crayon.Selected) {
                    if (crayon.Name == "Eraser") {
                        dctx.SetBlendMode (CGBlendMode.Clear);
                        dctx.SetStrokeColor (UIColor.Clear.CGColor);
                    } else {
                        dctx.SetBlendMode (CGBlendMode.Normal);
                        var swatchImg = colorSwatch (swatches[0], crayon.R / 255f, crayon.G / 255f, crayon.B / 255f, 1f);

                        UIColor pattern = UIColor.FromPatternImage(swatchImg);
                        dctx.SetStrokeColor(pattern.CGColor);
                    }
                    dctx.SetLineCap (CGLineCap.Round);
                    dctx.SetLineJoin (CGLineJoin.Round);
                }
            }
            //set fill color with current crayons
            foreach (var point in Points) {
                dctx.AddLineToPoint(point.X, point.Y);
            }
            dctx.StrokePath();
        }
开发者ID:chkn,项目名称:CrayonCamelot,代码行数:33,代码来源:Canvas.cs

示例15: DrawInContext

        public void DrawInContext(CGContext context, bool isDebuggingEnabled, bool usePreciseLocation)
        {
            LinePoint maybePriorPoint = null;

            foreach (var point in Points) {
                if (maybePriorPoint == null) {
                    maybePriorPoint = point;
                    continue;
                }

                var priorPoint = maybePriorPoint;

                var color = UIColor.Black;
                var pointType = point.PointType;

                if (isDebuggingEnabled) {
                    if (pointType.Has (PointType.Cancelled))
                        color = UIColor.Red;
                    else if (pointType.Has (PointType.NeedsUpdate))
                        color = UIColor.Orange;
                    else if (pointType.Has (PointType.Finger))
                        color = UIColor.Purple;
                    else if (pointType.Has (PointType.Coalesced))
                        color = UIColor.Green;
                    else if (pointType.Has (PointType.Predicted))
                        color = UIColor.Blue;
                } else {
                    if (pointType.Has (PointType.Cancelled))
                        color = UIColor.Red;
                    else if (pointType.Has (PointType.Finger))
                        color = UIColor.Purple;

                    if (pointType.Has (PointType.Predicted) && !pointType.Has (PointType.Cancelled))
                        color = color.ColorWithAlpha (.5f);
                }

                var location = usePreciseLocation ? point.PreciseLocation : point.Location;
                var priorLocation = usePreciseLocation ? priorPoint.PreciseLocation : priorPoint.Location;

                context.SetStrokeColor (color.CGColor);
                context.BeginPath ();
                context.MoveTo (priorLocation.X, priorLocation.Y);
                context.AddLineToPoint (location.X, location.Y);
                context.SetLineWidth (point.Magnitude);
                context.StrokePath ();

                // Draw azimuith and elevation on all non-coalesced points when debugging.
                if (isDebuggingEnabled &&
                    !point.PointType.Has (PointType.Coalesced) &&
                    !point.PointType.Has (PointType.Predicted) &&
                    !point.PointType.Has (PointType.Finger)) {
                    context.BeginPath ();
                    context.SetStrokeColor (UIColor.Red.CGColor);
                    context.SetLineWidth (.5f);
                    context.MoveTo (location.X, location.Y);
                    var targetPoint = new CGPoint (.5f + 10f * NMath.Cos (point.AltitudeAngle), 0f);
                    targetPoint = CGAffineTransform.MakeRotation (point.AzimuthAngle).TransformPoint (targetPoint);
                    targetPoint.X += location.X;
                    targetPoint.Y += location.Y;
                    context.AddLineToPoint (targetPoint.X, targetPoint.Y);
                    context.StrokePath ();
                }

                maybePriorPoint = point;
            }
        }
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:66,代码来源:Line.cs


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