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


C# CGRect.GetMidY方法代码示例

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


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

示例1: CalloutAnnotation

        public CalloutAnnotation(int count, CGRect rect, nfloat lineWidth, UIColor color)
        {
            Path = UIBezierPath.FromOval(rect);
            Path.LineWidth = lineWidth;

            var center = new CGPoint (rect.GetMidX(), rect.GetMidY());

            Center = center;

            nfloat startAngle = (nfloat)(Math.PI * 0.75);
            nfloat endAngle = (nfloat)(Math.PI * 0.60);

            Clip = UIBezierPath.FromArc(center, center.X + lineWidth, startAngle, endAngle, true);
            Clip.AddLineTo(center);
            Clip.ClosePath();
            Clip.LineWidth = lineWidth;

            Tail = new UIBezierPath ();
            Tail.MoveTo(new CGPoint (center.X - 11, center.Y + 9));
            Tail.AddLineTo(new CGPoint (center.X - 11, center.Y + 18));
            Tail.AddLineTo(new CGPoint (center.X - 3, center.Y + 13));
            Tail.LineWidth = lineWidth;

            Rect = rect;
            Color = color;
            Count = count;
        }
开发者ID:colbylwilliams,项目名称:bugtrap,代码行数:27,代码来源:CalloutAnnotation.cs

示例2: Draw

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

			// Get current graphics context.
			using (CGContext g = UIGraphics.GetCurrentContext ()) {

				// Overall transforms to shift (0, 0) to center and scale.
				g.TranslateCTM (rect.GetMidX (), rect.GetMidY ());
				nfloat scale = (nfloat)Math.Min(rect.Width, rect.Height) / 2 / 100;
				g.ScaleCTM (scale, scale);

				// Attributes for tick marks
				g.SetStrokeColor (new CGColor (0, 0, 0));
				g.SetLineCap (CGLineCap.Round);

				// Set line dash to draw tick marks for every minute.
				g.SetLineWidth (3);
				g.SetLineDash (0, new nfloat[] { 0, 3 * (nfloat)Math.PI });
				g.AddPath (tickMarks);
				g.DrawPath (CGPathDrawingMode.Stroke);

				// Set line dash to draw tick marks for every hour.
				g.SetLineWidth (6);
				g.SetLineDash(0, new nfloat[] { 0, 15 * (nfloat)Math.PI });
				g.AddPath (tickMarks);
				g.DrawPath (CGPathDrawingMode.Stroke);

				// Set common attributes for clock hands.
				g.SetStrokeColor (new CGColor (0, 0, 0));
				g.SetFillColor(new CGColor(0, 0, 1));
				g.SetLineWidth (2);
				g.SetLineDash (0, null);
				g.SetLineJoin (CGLineJoin.Round);

				// Draw hour hand.
				g.SaveState ();
				g.RotateCTM (hourAngle); // 2 * (float)Math.PI * (dt.Hour + dt.Minute / 60.0f) / 12);
				g.AddPath (hourHand);
				g.DrawPath (CGPathDrawingMode.FillStroke);
				g.RestoreState ();

				// Draw minute hand.
				g.SaveState ();
				g.RotateCTM (minuteAngle); // 2 * (float)Math.PI * (dt.Minute + dt.Second / 60.0f) / 60);
				g.AddPath (minuteHand);
				g.DrawPath (CGPathDrawingMode.FillStroke);
				g.RestoreState ();

				// Draw second hand.
				g.SaveState ();
				g.RotateCTM (secondAngle); // 2 * (float)Math.PI * dt.Second / 60);
				g.AddPath (secondHand);
				g.DrawPath (CGPathDrawingMode.Stroke);
				g.RestoreState ();
			}
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:57,代码来源:ClockView.cs

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

示例4: Draw

 public override void Draw(CGRect rect)
 {
     base.Draw(rect);
     using (var gctx = UIGraphics.GetCurrentContext())
     {
         var pathStatus = new CGPath ();
         pathStatus.AddArc(rect.GetMidX(), rect.GetMidY(), (rect.Width>rect.Height?rect.Height/2:rect.Width/2)/2,
             1.5f* (float)Math.PI, this.angle * (float)Math.PI+1.5f* (float)Math.PI, false);
         gctx.SetLineWidth (rect.Width>rect.Height?rect.Height/2:rect.Width/2);
         gctx.SetStrokeColor (color);
         gctx.AddPath (pathStatus);
         gctx.DrawPath (CGPathDrawingMode.Stroke);
     }
 }
开发者ID:MADMUC,项目名称:TAP5050,代码行数:14,代码来源:CustomCircleView.cs

示例5: Draw

        public override void Draw(CGRect frame)
        {
            var context = UIGraphics.GetCurrentContext();
            var expression = 377.0f - percentage;

            // coverView Drawing
            var coverViewPath =
                UIBezierPath.FromOval(new CGRect(frame.GetMinX() + 5.0f, frame.GetMinY() + 4.0f, frame.Width - 10.0f,
                    frame.Height - 10.0f));
            UIColor.FromRGB(21, 169, 254).SetFill();
            coverViewPath.Fill();

            // completedView Drawing
            context.SaveState();
            context.SaveState();
            context.TranslateCTM(frame.GetMaxX() - 65.0f, frame.GetMinY() + 64.0f);
            context.RotateCTM(-90.0f*NMath.PI/180.0f);

            var completedViewRect = new CGRect(-60.0f, -60.0f, 120.0f, 120.0f);
            var completedViewPath = new UIBezierPath();
            completedViewPath.AddArc(new CGPoint(completedViewRect.GetMidX(), completedViewRect.GetMidY()),
                completedViewRect.Width/2.0f, -360.0f*NMath.PI/180,
                -(expression - 17.0f)*NMath.PI/180.0f, true);
            completedViewPath.AddLineTo(new CGPoint(completedViewRect.GetMidX(), completedViewRect.GetMidY()));
            completedViewPath.ClosePath();

            UIColor.FromRGB(247, 247, 247).SetFill();
            completedViewPath.Fill();
            context.RestoreState();

            // backgroundView Drawing
            var backgroundViewPath =
                UIBezierPath.FromOval(new CGRect(frame.GetMinX() + 12.0f, frame.GetMinY() + 11.0f, frame.Width - 24.0f,
                    frame.Height - 24.0f));
            UIColor.FromRGB(21, 169, 254).SetFill();
            backgroundViewPath.Fill();
        }
开发者ID:Azure-Samples,项目名称:MyDriving,代码行数:37,代码来源:CirclePercentage.cs

示例6: DrawInContext

        public override void DrawInContext(CGContext context, CGRect bounds, TKChartVisualPoint visualPoint)
        {
            UIGraphics.PushContext (context);
            TKFill fill = this.Style.Fill;
            TKStroke stroke = new TKStroke (UIColor.Black);
            TKBalloonShape shape = new TKBalloonShape (TKBalloonShapeArrowPosition.Bottom, bounds.Size);
            shape.DrawInContext (context, new CGPoint (bounds.GetMidX (), bounds.GetMidY ()), new TKDrawing[]{ fill, stroke });
            CGRect textRect = new CGRect (bounds.Left, bounds.Top - this.Style.Insets.Top, bounds.Size.Width, bounds.Size.Height + this.Style.Insets.Bottom);

            NSMutableParagraphStyle paragraphStyle = new NSMutableParagraphStyle ();
            paragraphStyle.Alignment = this.Style.TextAlignment;
            NSDictionary attributes = new NSDictionary (UIStringAttributeKey.Font, UIFont.SystemFontOfSize (18),
                                          UIStringAttributeKey.ForegroundColor, this.Style.TextColor,
                                          UIStringAttributeKey.ParagraphStyle, paragraphStyle);

            NSString text = new NSString (this.Text);
            text.WeakDrawString (textRect, NSStringDrawingOptions.TruncatesLastVisibleLine | NSStringDrawingOptions.UsesLineFragmentOrigin, attributes, null);
            UIGraphics.PopContext ();
        }
开发者ID:sudipnath,项目名称:ios-sdk,代码行数:19,代码来源:MyPointLabel.cs

示例7: Draw

		// Draws a dashed circle in the center of the `rect` with a radius 1/4th of the `rect`'s smallest side.
		public override void Draw (CGRect rect)
		{
			base.Draw (rect);

			var context = UIGraphics.GetCurrentContext ();

			var strokeColor = UIColor.Blue;

			nfloat circleDiameter = NMath.Min (rect.Width, rect.Height) / 2;
			var circleRadius = circleDiameter / 2;
			var cirlceRect = new CGRect (rect.GetMidX () - circleRadius, rect.GetMidY () - circleRadius, circleDiameter, circleDiameter);
			var circlePath = UIBezierPath.FromOval (cirlceRect);

			strokeColor.SetStroke ();
			circlePath.LineWidth = 3;
			context.SaveState ();
			context.SetLineDash (0, new nfloat[] { 6, 6 }, 2);
			circlePath.Stroke ();
			context.RestoreState ();
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:21,代码来源:MapOverlayView.cs

示例8: LayoutSubviews

        public override void LayoutSubviews()
        {
            base.LayoutSubviews ();
            this.TextLabel.Frame = CGRect.Empty;

            var bounds = new CGRect (this.Bounds.X, this.Bounds.Y ,
                this.Bounds.Size.Width,
                this.Bounds.Size.Height);

            var buttonSize = ((NSString)this.ActionButton.TitleLabel.Text).GetSizeUsingAttributes(new UIStringAttributes(new NSDictionary(UIStringAttributeKey.Font, this.ActionButton.TitleLabel.Font,
                UIStringAttributeKey.BackgroundColor, this.ActionButton.TitleLabel.TextColor)));

            this.ActionButton.Frame = new CGRect (Bounds.X - 10 + Bounds.Size.Width + this.Style.EditorOffset.Horizontal - buttonSize.Width,
                (double)Bounds.GetMidY() - buttonSize.Height / 2.0 + this.Style.EditorOffset.Vertical, buttonSize.Width, buttonSize.Height);

            this.textField.Frame = new CGRect (Bounds.X + 15 + this.Style.TextLabelOffset.Horizontal,  Bounds.GetMidY() - bounds.Size.Height / 2.0,
                ActionButton.Frame.X - (Bounds.X + this.Style.TextLabelOffset.Horizontal), Bounds.Size.Height);

            if(this.Style.TextLabelDisplayMode == TKDataFormEditorTextLabelDisplayMode.Hidden){
                textField.Frame = CGRect.Empty;
                ActionButton.Frame = new CGRect(this.Bounds.X + this.Style.EditorOffset.Horizontal,
                    bounds.GetMidY() - buttonSize.Height / 2.0 + this.Style.EditorOffset.Vertical, buttonSize.Width, buttonSize.Height);
            }
        }
开发者ID:brianmed,项目名称:Todo,代码行数:24,代码来源:ActionEditor.cs

示例9: DrawTimer

        //// Drawing Methods
        public static void DrawTimer(CGRect frame, float percentage)
        {
            var context = UIGraphics.GetCurrentContext();

            var expression = 360.0f - percentage;

            var coverViewPath = UIBezierPath.FromOval(new CGRect(frame.GetMinX() + 5.0f, frame.GetMinY() + 4.0f, 230.0f, 230.0f));
            DemoStyleKit.Purple.SetFill();
            coverViewPath.Fill();

            context.SaveState();
            context.TranslateCTM(frame.GetMinX() + 120.0f, frame.GetMinY() + 119.0f);
            context.RotateCTM(-90.0f * NMath.PI / 180.0f);

            var completedViewRect = new CGRect(-115.0f, -115.0f, 230.0f, 230.0f);
            var completedViewPath = new UIBezierPath();
            completedViewPath.AddArc(new CGPoint(completedViewRect.GetMidX(), completedViewRect.GetMidY()), completedViewRect.Width / 2.0f, (nfloat)(-360.0f * NMath.PI/180), (nfloat)(-expression * NMath.PI/180.0f), true);
            completedViewPath.AddLineTo(new CGPoint(completedViewRect.GetMidX(), completedViewRect.GetMidY()));
            completedViewPath.ClosePath();

            DemoStyleKit.Green.SetFill();
            completedViewPath.Fill();

            context.RestoreState();

            var backgroundViewPath = UIBezierPath.FromOval(new CGRect(frame.GetMinX() + 10.0f, frame.GetMinY() + 9.0f, 220.0f, 220.0f));
            DemoStyleKit.Purple.SetFill();
            backgroundViewPath.Fill();
        }
开发者ID:TsukishirOSan,项目名称:PaintCodeDemo,代码行数:30,代码来源:DemoStyleKit.cs

示例10: Draw

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

            _bounds = new CGRect(rect.X + Padding, rect.Y + Padding, rect.Width - 2 * Padding, rect.Height - 2 * Padding);

            using (var ctx = UIGraphics.GetCurrentContext())
            {
                ctx.SaveState();

                UIColor.DarkGray.SetStroke();
                ctx.SetLineWidth(3);
                ctx.StrokeRect(_bounds);

                ctx.RestoreState();

                ctx.SaveState();

                UIColor.DarkGray.SetStroke();
                ctx.SetLineWidth(2);
                ctx.SetLineDash(0, new nfloat[] { 4, 4 });

                ctx.StrokeLineSegments(new []
                    {
                        new CGPoint(_bounds.GetMidX(), _bounds.Top),
                        new CGPoint(_bounds.GetMidX(), _bounds.Bottom)
                    });
                ctx.StrokeLineSegments(new []
                    {
                        new CGPoint(_bounds.Left, _bounds.GetMidY()),
                        new CGPoint(_bounds.Right, _bounds.GetMidY())
                    });

                ctx.RestoreState();

                ctx.SaveState();

                UIColor.DarkGray.SetStroke();
                ctx.SetLineWidth(2);
                ctx.SetLineDash(0, new nfloat[] { 2, 2 });

                ctx.StrokeLineSegments(new []
                    {
                        new CGPoint(_bounds.Left + _bounds.Width / 4f, _bounds.Top),
                        new CGPoint(_bounds.Left + _bounds.Width / 4f, _bounds.Bottom)
                    });
                ctx.StrokeLineSegments(new []
                    {
                        new CGPoint(_bounds.Left + 3f * _bounds.Width / 4f, _bounds.Top),
                        new CGPoint(_bounds.Left + 3f * _bounds.Width / 4f, _bounds.Bottom)
                    });
                ctx.StrokeLineSegments(new []
                    {
                        new CGPoint(_bounds.Left, _bounds.Top + _bounds.Height / 4f),
                        new CGPoint(_bounds.Right, _bounds.Top + _bounds.Height / 4f)
                    });
                ctx.StrokeLineSegments(new []
                    {
                        new CGPoint(_bounds.Left, _bounds.Top + 3f * _bounds.Height / 4f),
                        new CGPoint(_bounds.Right, _bounds.Top + 3f * _bounds.Height / 4f)
                    });

                ctx.RestoreState();

                if (_isActive)
                {
                    ctx.SaveState();

                    UIColor.Blue.SetFill();
                    ctx.FillEllipseInRect(new CGRect(_joystickPositionRaw.X - 20, _joystickPositionRaw.Y - 20, 40, 40));

                    ctx.RestoreState();
                }
            }
        }
开发者ID:milindur,项目名称:MdkControlApp,代码行数:75,代码来源:JoystickView.cs

示例11: DrawRect

		public override void DrawRect (CGRect dirtyRect)
		{
			// Don't draw if we don't have a font or a title.
			if (Font == null || Title == string.Empty)
				return;

			// Initialize the text matrix to a known value
			CGContext context = NSGraphicsContext.CurrentContext.GraphicsPort;
			context.TextMatrix = CGAffineTransform.MakeIdentity ();

			// Draw a white background
			NSColor.White.Set ();
			context.FillRect (dirtyRect);
			CTLine line = new CTLine (AttributedString);

			int glyphCount = (int)line.GlyphCount;
			if (glyphCount == 0)
				return;

			GlyphArcInfo[] glyphArcInfo = new GlyphArcInfo[glyphCount];
			PrepareGlyphArcInfo (line, glyphCount, glyphArcInfo);

			// Move the origin from the lower left of the view nearer to its center.
			context.SaveState ();
			context.TranslateCTM (dirtyRect.GetMidX (), dirtyRect.GetMidY () - Radius / 2);

			// Stroke the arc in red for verification.
			context.BeginPath ();
			context.AddArc (0, 0, Radius, (float)Math.PI, 0, true);
			context.SetStrokeColor (1, 0, 0, 1);
			context.StrokePath ();

			// Rotate the context 90 degrees counterclockwise.
			context.RotateCTM ((float)PI_2);

			/*
			 	Now for the actual drawing. The angle offset for each glyph relative to the previous
				glyph has already been calculated; with that information in hand, draw those glyphs
			 	overstruck and centered over one another, making sure to rotate the context after each
			 	glyph so the glyphs are spread along a semicircular path.
			*/
			CGPoint textPosition = new CGPoint (0, Radius);
			context.TextPosition = textPosition;
			var runArray = line.GetGlyphRuns ();
			var runCount = runArray.Count ();

			var glyphOffset = 0;
			var runIndex = 0;

			for (; runIndex < runCount; runIndex++) {
				var run = runArray [runIndex];
				var runGlyphCount = run.GlyphCount;
				bool drawSubstitutedGlyphsManually = false;
				CTFont runFont = run.GetAttributes ().Font;
                                
				// Determine if we need to draw substituted glyphs manually. Do so if the runFont is not
				//      the same as the overall font.
				var description = NSFontDescriptor.FromNameSize (runFont.FamilyName, runFont.Size);
				NSFont rrunFont = NSFont.FromDescription (description, runFont.Size);
				// used for comparison
				if (DimsSubstitutedGlyphs && Font != rrunFont) {
					drawSubstitutedGlyphsManually = true;
				}
                                
				var runGlyphIndex = 0;
				for (; runGlyphIndex < runGlyphCount; runGlyphIndex++) {
					var glyphRange = new NSRange (runGlyphIndex, 1);
					context.RotateCTM (-(glyphArcInfo [runGlyphIndex + glyphOffset].angle));
                                        
					// Center this glyph by moving left by half its width.
					var glyphWidth = glyphArcInfo [runGlyphIndex + glyphOffset].width;
					var halfGlyphWidth = glyphWidth / 2.0;
					var positionForThisGlyph = new CGPoint (textPosition.X - (float)halfGlyphWidth, textPosition.Y);
                                        
					// Glyphs are positioned relative to the text position for the line, so offset text position leftwards by this glyph's
					//      width in preparation for the next glyph.
					textPosition.X -= glyphWidth;
                                        
					CGAffineTransform textMatrix = run.TextMatrix;
					textMatrix.x0 = positionForThisGlyph.X;
					textMatrix.y0 = positionForThisGlyph.Y;
					context.TextMatrix = textMatrix;
                                        
					if (!drawSubstitutedGlyphsManually) {
						run.Draw (context, glyphRange);
					} else {
						// We need to draw the glyphs manually in this case because we are effectively applying a graphics operation by
						//      setting the context fill color. Normally we would use kCTForegroundColorAttributeName, but this does not apply
						// as we don't know the ranges for the colors in advance, and we wanted demonstrate how to manually draw.
						var cgFont = runFont.ToCGFont ();
						var glyph = run.GetGlyphs (glyphRange);
						var position = run.GetPositions (glyphRange);
						context.SetFont (cgFont);
						context.SetFontSize (runFont.Size);
						context.SetFillColor (0.25f, 0.25f, 0.25f, 1);
						context.ShowGlyphsAtPositions (glyph, position, 1);
					}

					// Draw the glyph bounds
					if (ShowsGlyphBounds) {
//.........这里部分代码省略.........
开发者ID:RangoLee,项目名称:mac-samples,代码行数:101,代码来源:CoreTextArcView.cs

示例12: Draw

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

					var appdel = DocumentAppDelegate.Shared;
					var theme = appdel.Theme;

					var c = UIGraphics.GetCurrentContext ();
					
					var backColor = Praeclarum.Graphics.ColorEx.GetUIColor (appdel.App.GetThumbnailBackgroundColor (theme));
					backColor.SetFill ();
					c.FillRect (rect);

					var b = Bounds;
					
					c.SetLineWidth (2.0f);
					
					var color = Praeclarum.Graphics.ColorEx.GetUIColor (appdel.App.TintColor);
					
					color.SetStroke ();
					
					var size = (nfloat)(Math.Min (b.Width, b.Height) * 0.5);
					var f = new CGRect ((b.Width - size) / 2, (b.Height - size) / 2, size, size);
					f.X = (int)f.X;
					f.Y = (int)f.Y;
					
					c.MoveTo (f.Left, f.GetMidY ());
					c.AddLineToPoint (f.Right, f.GetMidY ());
					c.StrokePath ();
					
					c.MoveTo (f.GetMidX (), f.Top);
					c.AddLineToPoint (f.GetMidX (), f.Bottom);
					c.StrokePath ();
					
					if (Editing) {
						GetNotSelectableColor (theme).SetFill ();
						c.FillRect (b);
					}
				} catch (Exception ex) {
					Log.Error (ex);
				}
			}
开发者ID:praeclarum,项目名称:Praeclarum,代码行数:43,代码来源:DocumentThumbnailsView.cs


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