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


C# CGPoint类代码示例

本文整理汇总了C#中CGPoint的典型用法代码示例。如果您正苦于以下问题:C# CGPoint类的具体用法?C# CGPoint怎么用?C# CGPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setPoints

        public void setPoints(CGPoint[] points)
        {
            pathSet = true;
			path.AddLines(points);
            pointsList = points;
            SetNeedsDisplay();
        }
开发者ID:dcbright01,项目名称:Navigator,代码行数:7,代码来源:PathView.cs

示例2: TouchesMoved

		/// <summary>
		///   Called when the fingers move
		/// </summary>
		public override void TouchesMoved (NSSet touches, UIEvent evt)
		{
			base.TouchesMoved (touches, evt);

			// if we haven't already failed
			if (base.State != UIGestureRecognizerState.Failed) {
				// get the current and previous touch point
				CGPoint newPoint = (touches.AnyObject as UITouch).LocationInView (View);
				CGPoint previousPoint = (touches.AnyObject as UITouch).PreviousLocationInView (View);

				// if we're not already on the upstroke
				if (!strokeUp) {
					// if we're moving down, just continue to set the midpoint at 
					// whatever point we're at. when we start to stroke up, it'll stick
					// as the last point before we upticked
					if (newPoint.X >= previousPoint.X && newPoint.Y >= previousPoint.Y) {
						midpoint = newPoint;
					}
                        // if we're stroking up (moving right x and up y [y axis is flipped])
                    else if (newPoint.X >= previousPoint.X && newPoint.Y <= previousPoint.Y) {
						strokeUp = true;
					}
                        // otherwise, we fail the recognizer
                    else {
						base.State = UIGestureRecognizerState.Failed;
					}
				}
			}

			Console.WriteLine (base.State.ToString ());
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:34,代码来源:CheckmarkGestureRecognizer.cs

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

示例4: GetPixelColor

        private UIColor GetPixelColor(CGPoint point, UIImage image)
        {
            var rawData = new byte[4];
            var handle = GCHandle.Alloc(rawData);
            UIColor resultColor = null;

            try
            {
                using (var colorSpace = CGColorSpace.CreateDeviceRGB())
                {
                    using (var context = new CGBitmapContext(rawData, 1, 1, 8, 4, colorSpace, CGImageAlphaInfo.PremultipliedLast))
                    {
                        context.DrawImage(new CGRect(-point.X, point.Y - image.Size.Height, image.Size.Width, image.Size.Height), image.CGImage);

                        float red   = (rawData[0]) / 255.0f;
                        float green = (rawData[1]) / 255.0f;
                        float blue  = (rawData[2]) / 255.0f;
                        float alpha = (rawData[3]) / 255.0f;

                        resultColor = UIColor.FromRGBA(red, green, blue, alpha);
                    }
                }
            }
            finally
            {
                handle.Free();
            }

            return resultColor;
        }
开发者ID:Manne990,项目名称:XamTest,代码行数:30,代码来源:HexagonButtonViewRenderer.cs

示例5: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			var squareCenterPoint = new CGPoint (square.Center.X, square.Center.Y - 100.0f);
			var attachmentOffset = new UIOffset (-25.0f, -25.0f);

			/*
    		 By default, an attachment behavior uses the center of a view. By using a small offset,
    		 we get a more interesting effect which will cause the view to have rotation movement
    		 when dragging the attachment.
    		*/
			var attachmentBehavior = new UIAttachmentBehavior (square, attachmentOffset, squareCenterPoint);

			// Show visually the attachment points
			redSquare.Center = attachmentBehavior.AnchorPoint;
			blueSquare.Center = new CGPoint (25.0f, 25.0f);

			Animator = new UIDynamicAnimator (View);
			Animator.AddBehavior (attachmentBehavior);

			View.AddGestureRecognizer (new UIPanGestureRecognizer ((gesture) => {
				attachmentBehavior.AnchorPoint = gesture.LocationInView (View);
				redSquare.Center = attachmentBehavior.AnchorPoint;
			}));
		}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:26,代码来源:AttachmentsViewController.cs

示例6: Draw

        public override void Draw(CGRect rect)
        {
            using (CGContext context = UIGraphics.GetCurrentContext())
            {
                switch (_Style)
                {
                    case SIAlertViewBackgroundStyle.Gradient:
                        {
                            nfloat[] locations = { 0.0f, 1.0f };
                            nfloat[] colors = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.75f };
                            CGGradient gradient = new CGGradient(CGColorSpace.CreateDeviceRGB(), colors, locations);

                            CGPoint center = new CGPoint(Bounds.Size.Width / 2, Bounds.Size.Height / 2);
                            nfloat radius = (nfloat)Math.Min(Bounds.Size.Width, Bounds.Size.Height);
                            context.DrawRadialGradient(gradient, center, 0, center, radius, CGGradientDrawingOptions.DrawsAfterEndLocation);
                            break;
                        }
                    case SIAlertViewBackgroundStyle.Solid:
                        {
                            UIColor.FromWhiteAlpha(0f, 0.5f).SetColor();
                            context.SetFillColor(UIColor.FromWhiteAlpha(0f, 0.5f).CGColor);
                            context.FillRect(Bounds);
                            break;
                        }
                }
            }
        }
开发者ID:NinZine,项目名称:SIAlertView.Xamarin,代码行数:27,代码来源:SIAlertBackgroundWindow.cs

示例7: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			// set the background color of the view to white
			View.BackgroundColor = UIColor.White;

			// instantiate a new image view that takes up the whole screen and add it to
			// the view hierarchy
			CGRect imageViewFrame = new CGRect (0, -NavigationController.NavigationBar.Frame.Height, View.Frame.Width, View.Frame.Height);
			imageView = new UIImageView (imageViewFrame);
			View.AddSubview (imageView);

			// create our offscreen bitmap context
			// size
			CGSize bitmapSize = new CGSize (View.Frame.Size);
			using (CGBitmapContext context = new CGBitmapContext (IntPtr.Zero,
									      (int)bitmapSize.Width, (int)bitmapSize.Height, 8,
									      (int)(4 * bitmapSize.Width), CGColorSpace.CreateDeviceRGB (),
									      CGImageAlphaInfo.PremultipliedFirst)) {

				// declare vars
				UIImage apressImage = UIImage.FromFile ("icon-114.png");
				CGPoint imageOrigin = new CGPoint ((imageView.Frame.Width / 2) - (apressImage.CGImage.Width / 2), (imageView.Frame.Height / 2) - (apressImage.CGImage.Height / 2));
				CGRect imageRect = new CGRect (imageOrigin.X, imageOrigin.Y, apressImage.CGImage.Width, apressImage.CGImage.Height);

				// draw the image
				context.DrawImage (imageRect, apressImage.CGImage);

				// output the drawing to the view
				imageView.Image = UIImage.FromImage (context.ToImage ());
			}
		}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:33,代码来源:Controller.cs

示例8: HitTest

 public override UIView HitTest(CGPoint point, UIEvent uievent)
 {
     var hitView = base.HitTest(point, uievent);
     if (hitView == RootViewController.View)
         hitView = null;
     return hitView;
 }
开发者ID:NimaGhaedsharafi,项目名称:ToastsRTL.Forms.Plugin,代码行数:7,代码来源:MessageWindow.cs

示例9: AddText

		/// <summary>
		/// Adds the text.
		/// </summary>
		/// <param name="image">The image.</param>
		/// <param name="text">The text.</param>
		/// <param name="point">The point.</param>
		/// <param name="font">The font.</param>
		/// <param name="color">The color.</param>
		/// <param name="alignment">The alignment.</param>
		/// <returns>UIImage.</returns>
		public static UIImage AddText(
			this UIImage image,
			string text,
			CGPoint point,
			UIFont font,
			UIColor color,
			UITextAlignment alignment = UITextAlignment.Left)
		{
			//var labelRect = new RectangleF(point, new SizeF(image.Size.Width - point.X, image.Size.Height - point.Y));
			var h = text.StringHeight(font, image.Size.Width);
			var labelRect = new CGRect(point, new CGSize(image.Size.Width - point.X, h));

			var label = new UILabel(labelRect)
				            {
					            Font = font,
					            Text = text,
					            TextColor = color,
					            TextAlignment = alignment,
					            BackgroundColor = UIColor.Clear
				            };

			var labelImage = label.ToNativeImage();

			using (var context = image.Size.ToBitmapContext())
			{
				var rect = new CGRect(new CGPoint(0, 0), image.Size);
				context.DrawImage(rect, image.CGImage);
				context.DrawImage(labelRect, labelImage.CGImage);
				context.StrokePath();
				return UIImage.FromImage(context.ToImage());
			}
		}
开发者ID:Jaskomal,项目名称:Xamarin-Forms-Labs,代码行数:42,代码来源:UIImageExtensions.cs

示例10: NativeInit

 protected internal override void NativeInit()
 {
     if (Parent != null)
     {
         if (this.NativeUIElement == null)
         {
             var scroll = new UIScrollView();
             scroll.BackgroundColor = UIColor.Clear;
             this.NativeUIElement = scroll;
             this.NativeUIElement.ClipsToBounds = true;
             this.lastContentOfset = CGPoint.Empty;
             scroll.Scrolled += (sender, e) =>
             {
                 this.OnScrollChanged(new ScrollChangedEventArgs
                 {
                     VerticalOffset = scroll.ContentOffset.Y,
                     HorizontalOffset = scroll.ContentOffset.X,
                     VerticalChange = scroll.ContentOffset.Y - this.lastContentOfset.Y,
                     HorizontalChange = scroll.ContentOffset.X - this.lastContentOfset.X,
                 });
                 this.lastContentOfset = scroll.ContentOffset;
             };
         }
         base.NativeInit();
     }
 }
开发者ID:evnik,项目名称:UIFramework,代码行数:26,代码来源:ScrollViewer.iOS.cs

示例11: PlaceFeature

		private void PlaceFeature (string message, CGPoint p, float offset)
		{
			// Create and configure a node with a text geometry, and add it to the scene
			var text = SCNText.Create (message, 5);
			text.Font = Font;
			text.Flatness = 0.4f;
			text.Materials = Materials;

			var textNode = SCNNode.Create ();
			textNode.Geometry = text;
			textNode.Position = new SCNVector3 (p.X, p.Y + Altitude, 0);
			textNode.Scale = new SCNVector3 (0.02f, 0.02f, 0.02f);

			ContentNode.AddChildNode (textNode);

			// Animation the node's position and opacity
			var positionAnimation = CABasicAnimation.FromKeyPath ("position.z");
			positionAnimation.From = NSNumber.FromInt16 (-10);
			positionAnimation.To = NSNumber.FromInt16 (10);
			positionAnimation.Duration = 5.0f;
			positionAnimation.TimeOffset = -offset * positionAnimation.Duration;
			positionAnimation.RepeatCount = float.MaxValue;
			textNode.AddAnimation (positionAnimation, new NSString ("positionAnimation"));

			var opacityAnimation = CAKeyFrameAnimation.GetFromKeyPath ("opacity");
			opacityAnimation.KeyTimes = new NSNumber[] { 0.0f, 0.2f, 0.9f, 1.0f };
			opacityAnimation.Values = new NSNumber[] { 0.0f, 1.0f, 1.0f, 0.0f };
			opacityAnimation.Duration = positionAnimation.Duration;
			opacityAnimation.TimeOffset = positionAnimation.TimeOffset;
			opacityAnimation.RepeatCount = float.MaxValue;
			textNode.AddAnimation (opacityAnimation, new NSString ("opacityAnimation"));
		}
开发者ID:hitchingsh,项目名称:mac-samples,代码行数:32,代码来源:SlideAllNew.cs

示例12: Character

 public Character(SKTexture texture, CGPoint position)
     : base(texture)
 {
     // standard sprite - there's no parallax
     UsesParallaxEffect = false;
     Initialize (position);
 }
开发者ID:W3SS,项目名称:mac-ios-samples,代码行数:7,代码来源:Character.cs

示例13: CheckLimit

		protected override bool CheckLimit (CGPoint contentOffset)
		{
			if (Subviews.Length == 0)
				return false;
			return Math.Abs (contentOffset.X) > Math.Abs (Limit);
			
		}
开发者ID:Florismart,项目名称:Xamarin.ForinfinityAndBeyondView,代码行数:7,代码来源:HorizontalInfiniteAndBeyondView.cs

示例14: SetCenter

		public static NSLayoutConstraint[] SetCenter(UIView refView, UIView view, CGPoint centerPoint)
		{
			return new NSLayoutConstraint[] {
				NSLayoutConstraint.Create (view, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, refView, NSLayoutAttribute.Left, 1, centerPoint.X),
				NSLayoutConstraint.Create (view, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, refView, NSLayoutAttribute.Top, 1, centerPoint.Y)
			};
		}
开发者ID:richardboegli,项目名称:KinderChat,代码行数:7,代码来源:Layout.cs

示例15: GetSlope

 private double GetSlope (CGPoint p1, CGPoint p2)
 {
     if ((p2.Y - p1.Y) != 0)
         return (p1.X - p2.X) / (p2.Y - p1.Y);
     else
         return double.PositiveInfinity;
 }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:7,代码来源:GraphHeaderView.cs


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