本文整理汇总了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();
}
示例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 ());
}
示例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;
}
示例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;
}
示例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;
}));
}
示例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;
}
}
}
}
示例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 ());
}
}
示例8: HitTest
public override UIView HitTest(CGPoint point, UIEvent uievent)
{
var hitView = base.HitTest(point, uievent);
if (hitView == RootViewController.View)
hitView = null;
return hitView;
}
示例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());
}
}
示例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();
}
}
示例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"));
}
示例12: Character
public Character(SKTexture texture, CGPoint position)
: base(texture)
{
// standard sprite - there's no parallax
UsesParallaxEffect = false;
Initialize (position);
}
示例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)
};
}
示例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;
}