• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CGPoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ViewDidLoad

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

			var gravityBehavior = new UIGravityBehavior (square);

			var collisionBehavior = new UICollisionBehavior (square) {
				TranslatesReferenceBoundsIntoBoundary = true
			};
			collisionBehavior.BeganBoundaryContact += (sender, e) => {
				((UIView)e.DynamicItem).BackgroundColor = UIColor.LightGray;
			};
			collisionBehavior.EndedBoundaryContact += (sender, e) => {
				((UIView)e.DynamicItem).BackgroundColor = UIColor.Gray;
			};

			var squareCenterPoint = new CGPoint (square.Center.X, square.Center.Y - 100);

			var attachmentBehavior = new UIAttachmentBehavior (square, squareCenterPoint) {
				Frequency = 1.0f,
				Damping = 0.1f
			};

			redSquare.Center = attachmentBehavior.AnchorPoint;
			blueSquare.Center = new CGPoint (50.0f, 50.0f);

			Animator = new UIDynamicAnimator (View);
			Animator.AddBehaviors (attachmentBehavior, gravityBehavior, collisionBehavior);

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


示例17: Reset

		/// <summary>
		///   Called when the touches end or the recognizer state fails
		/// </summary>
		public override void Reset ()
		{
			base.Reset ();

			strokeUp = false;
			midpoint = CGPoint.Empty;
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:10,代码来源:CheckmarkGestureRecognizer.cs


示例18: BMarkerImageView

        public BMarkerImageView(WeakReference parentView, CGPoint location)
        {
            WeakParent = parentView;
             _location = location;

             UserInteractionEnabled = true;

             Frame = new CGRect (Location.X - 22, Location.Y - 22, 44, 44);
             using (var image = UIImage.FromFile ("Images/icon_marker.png"))
             {
            Image = image;
             }

             _pan = new UIPanGestureRecognizer (() =>
             {
            if ((_pan.State == UIGestureRecognizerState.Began || _pan.State == UIGestureRecognizerState.Changed) && (_pan.NumberOfTouches == 1))
            {
               Center = _pan.LocationInView (_parent);
               Location = Center;
               _parent.SetNeedsDisplay ();
            }
            else if (_pan.State == UIGestureRecognizerState.Ended)
            {
            }
             });

             _doubleTap = new UITapGestureRecognizer ((gesture) => Crop ()) {
            NumberOfTapsRequired = 2, NumberOfTouchesRequired = 1
             };

             AddGestureRecognizer (_pan);
             AddGestureRecognizer (_doubleTap);
        }
开发者ID:bkmza,项目名称:XamCropBkmzaSampleIOS,代码行数:33,代码来源:BMarkerImageView.cs


示例19: HandlePanGesture

		void HandlePanGesture (UIPanGestureRecognizer gesture)
		{
			if (gesture.State == UIGestureRecognizerState.Began) {
				gestureStartingPoint = gesture.TranslationInView (textView);
				gestureStartingCenter = imageView.Center;
			}
			else if (gesture.State == UIGestureRecognizerState.Changed) {
				CGPoint currentPoint = gesture.TranslationInView(textView);
				nfloat distanceX = currentPoint.X - gestureStartingPoint.X;
				nfloat distanceY = currentPoint.Y - gestureStartingPoint.Y;

				CGPoint newCenter = gestureStartingCenter;

				newCenter.X += distanceX;
				newCenter.Y += distanceY;

				imageView.Center = newCenter;

				textView.TextContainer.ExclusionPaths = TranslatedBezierPath ();
			}
			else if (gesture.State == UIGestureRecognizerState.Ended) {
				gestureStartingPoint  = new CGPoint (0, 0);
				gestureStartingCenter = new CGPoint (0, 0);
			}
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:25,代码来源:ExclusionPathsViewController.cs


示例20: AnimateTransition

		public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext)
		{
			_transitionContext = transitionContext;

			var containerView = transitionContext.ContainerView;

			FlashCardViewController toViewController;
			UIViewController fromViewController;

			if (Presenting) {
				fromViewController = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey) as UIViewController;
				toViewController = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) as FlashCardViewController;
			} else {
				toViewController = transitionContext.GetViewControllerForKey (UITransitionContext.FromViewControllerKey) as FlashCardViewController;
				fromViewController = transitionContext.GetViewControllerForKey (UITransitionContext.ToViewControllerKey) as UIViewController;
			}

			if(Presenting)
				containerView.AddSubview(toViewController.View);

			var originRect = toViewController.SourceFrame;

			var circleRect = new CGRect (originRect.GetMidX(), originRect.GetMidY(), 10, 10);

			var circleMaskPathInitial = UIBezierPath.FromOval(circleRect); //(ovalInRect: button.frame);
			var extremePoint = new CGPoint(circleRect.X - toViewController.View.Bounds.Width, circleRect.Y - toViewController.View.Bounds.Height ); //CGRect.GetHeight (toViewController.view.bounds));
			var radius = (float)Math.Sqrt((extremePoint.X * extremePoint.X) + (extremePoint.Y * extremePoint.Y));
			var largeCircleRect = circleRect.Inset (-radius, -radius);
			var circleMaskPathFinal = UIBezierPath.FromOval (largeCircleRect);

			CGPath fromPath;
			CGPath toPath;

			if (Presenting) {
				fromPath = circleMaskPathInitial.CGPath;
				toPath = circleMaskPathFinal.CGPath;
			} else {
				var path = new CGPath ();
				fromPath = circleMaskPathFinal.CGPath;
				toPath = circleMaskPathInitial.CGPath;
			}

			var maskLayer = new CAShapeLayer();
			maskLayer.Path = fromPath;
			if (Presenting) {
				toViewController.View.Layer.Mask = maskLayer;
			} else {
				toViewController.View.Layer.Mask = maskLayer;
			}

			var maskLayerAnimation = CABasicAnimation.FromKeyPath("path");
			maskLayerAnimation.From = ObjCRuntime.Runtime.GetNSObject(fromPath.Handle);
			maskLayerAnimation.To = ObjCRuntime.Runtime.GetNSObject(toPath.Handle);
			maskLayerAnimation.Duration = this.TransitionDuration(transitionContext);
			_animDoneDelegate = new AnimDoneDelegate (transitionContext);
			maskLayerAnimation.Delegate = _animDoneDelegate;
			maskLayer.AddAnimation(maskLayerAnimation, "path");

		}
开发者ID:funhead,项目名称:baby-flashcard-app,代码行数:59,代码来源:FlashCardViewControllerAnimatedTransitioning.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CGRect类代码示例发布时间:2022-05-24
下一篇:
C# CGPath类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap