예제 #1
0
		public override void TouchesBegan (NSSet touches, UIEvent evt)
		{
			this.ExclusiveTouch = true;
			IndexCount++;

			var path = new UIBezierPath
			{
				LineWidth = PenWidth
			}  ;

			var touch = (UITouch)touches.AnyObject;
			PreviousPoint = (PointF)touch.PreviousLocationInView (this);

			var newPoint = touch.LocationInView (this);
			path.MoveTo (newPoint);

			InvokeOnMainThread (SetNeedsDisplay);

			CurrentPath = path;


			var line = new VESLine
			{
				Path = CurrentPath, 
				Color = UIColor.Black,
				Index = IndexCount 
			}  ;

			Lines.Add (line);

		}
		CAShapeLayer GetMaskShape (ViewMaskerType maskType, Xamarin.Forms.Size size)
		{
			var layer = new CAShapeLayer ();
			layer.FillColor = UIColor.White.CGColor;
			layer.StrokeColor = UIColor.White.CGColor;
			layer.LineWidth = 0;
			UIBezierPath path = null;
			var bounds = new CGRect (0, 0, size.Width, size.Height);

			switch (maskType) {
			case ViewMaskerType.Circle:
				path = UIBezierPath.FromRoundedRect (bounds, (nfloat)Math.Max (size.Width, size.Height));
				break;
			case ViewMaskerType.Triangle:
				var point1 = new CGPoint (0, size.Height);
				var point2 = new CGPoint (size.Width, size.Height);
				var point3 = new CGPoint (size.Width / 2, 0);
				path = new UIBezierPath ();
				path.MoveTo (point1);
				path.AddLineTo (point2);
				path.AddLineTo (point3);
				path.AddLineTo (point1);
				path.ClosePath ();
				path.Fill ();
				break;
			case ViewMaskerType.Square:
				var smallRectangle = UIBezierPath.FromRect (bounds.Inset (50, 50));
				path = UIBezierPath.FromRoundedRect (bounds, 20);
				break;
			default:
				throw new ArgumentOutOfRangeException ();
			}
			layer.Path = path.CGPath;
			return layer;
		}
예제 #3
0
		public override void Draw (CGRect rect)
		{
			TintColor.SetColor ();
			CGRect bounds = Bounds;
			float x = (float)bounds.Right - LineWidth;

			for (int n = 0; n < Count; n++) {
				x -= LineMargin;
				if ((n + 1) % LineGroupCount == 0) {
					UIBezierPath path = new UIBezierPath ();
					path.MoveTo (
						new CGPoint (x + 0.5f * LineWidth,
					             bounds.Top + 0.5f * LineWidth));
					path.AddLineTo (
						new CGPoint (x + 0.5f * LineWidth + LineGroupCount * LineMargin,
					             bounds.Bottom - 0.5f * LineWidth));
					path.Stroke ();
				} else {
					CGRect lineRect = bounds;
					lineRect.X = x;
					lineRect.Width = LineWidth;
					UIGraphics.RectFill (lineRect);
				}
			}
		}
예제 #4
0
		public static UIBezierPath ToUIKit(this IEnumerable<LinearRing> linearRings, IViewport viewport)
		{
			var pathGeometry = new UIBezierPath();
			foreach (var linearRing in linearRings)
				pathGeometry.AppendPath(CreatePathFigure(linearRing, viewport));
			return pathGeometry;
		}
예제 #5
0
        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;
        }
예제 #6
0
		public static UIBezierPath ToUIKit(this MultiLineString multiLineString, IViewport viewport)
		{
			var group = new UIBezierPath();
			foreach (LineString lineString in multiLineString)
				group.AppendPath(ToUIKit(lineString, viewport));
			return group;
		}
		UIBezierPath[] TranslatedBezierPath ()
		{
			CGRect butterflyImageRect = textView.ConvertRectFromView (imageView.Frame, View);
			UIBezierPath[] newButterflyPath = new UIBezierPath[1];
			newButterflyPath [0] = (UIBezierPath)((NSObject)originalButterflyPath).Copy ();
			newButterflyPath [0].ApplyTransform (CGAffineTransform.MakeTranslation (butterflyImageRect.X, butterflyImageRect.Y));
			return newButterflyPath;
		}
예제 #8
0
		public static UIBezierPath ToUIKit(this MultiPolygon geometry, IViewport viewport)
		{
			var group = new UIBezierPath();
			foreach(var polygon in geometry.Polygons)
				group.AppendPath(ToUIKit(polygon, viewport));

			return group;
		}
예제 #9
0
		public static UIBezierPath ToUIKit(this Polygon polygon,IViewport viewport)
		{
			var group = new UIBezierPath();
			group.UsesEvenOddFillRule = true;
			group.AppendPath(ToUIKit(polygon.ExteriorRing, viewport));
			group.AppendPath(ToUIKit(polygon.InteriorRings, viewport));
			return group;
		}
예제 #10
0
 /* Returns a CABasicAnimation which animates between two paths.
  * @param fromPath The path to transform (morph) from.
  * @param toPath The path to transform (morph) to.
  * @return Returns the CABasicAnimation object.
  */
 public CABasicAnimation MorphAnimationFromPath(UIBezierPath fromPath, UIBezierPath toPath)
 {
     CABasicAnimation animation = CABasicAnimation.FromKeyPath("path");
     animation.Duration = AnimationDuration;
     animation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
     animation.SetFrom(fromPath.CGPath);
     animation.SetTo(toPath.CGPath);
     return animation;
 }
예제 #11
0
    public void Start ()
    {
      waveBoundaryPath = new UIBezierPath ();

      waveLayer = new CAShapeLayer ();
      waveLayer.FillColor = new CGColor (0, 0, 0, 1);
      Layer.AddSublayer (waveLayer);
      waveDisplaylink = CADisplayLink.Create (() => GetCurrentWave (waveDisplaylink));
	  waveDisplaylink.AddToRunLoop (NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
    }
예제 #12
0
        public PathAnnotation(Annotate.Tool tool, UIBezierPath path, UIColor color)
        {
            Tool = tool;

            var bzPath = UIBezierPath.FromPath(path.CGPath);
            bzPath.LineWidth = path.LineWidth;

            Path = bzPath;

            Color = color;
        }
예제 #13
0
        public SignatureView(RectangleF rect)
            : base(rect)
        {
            this.MultipleTouchEnabled = false;

            this.BackgroundColor = UIColor.Clear;

            path = new UIBezierPath();

            path.LineWidth = 2;
        }
예제 #14
0
        public SignatureView(NSCoder coder)
            : base(coder)
        {
            this.MultipleTouchEnabled = false;

            this.BackgroundColor = UIColor.Clear;

            path = new UIBezierPath();

            path.LineWidth = 2;
        }
예제 #15
0
        public static CGPath ToCGPath(this  _BezierPath nSBezierPath)
        {
#if __IOS__
            return(nSBezierPath.CGPath);
#elif __MACOS__
            // Then draw the path elements.
            var numElements = nSBezierPath.ElementCount;

            if (numElements > 0)
            {
                var path         = new CGPath();
                var points       = new CGPoint[3];
                var didClosePath = true;

                for (var i = 0; i < numElements; i++)
                {
                    switch (nSBezierPath.ElementAt(i, out points))
                    {
                    case NSBezierPathElement.MoveTo:
                        path.MoveToPoint(points[0].X, points[0].Y);
                        break;

                    case NSBezierPathElement.LineTo:
                        path.AddLineToPoint(points[0].X, points[0].Y);
                        didClosePath = false;
                        break;

                    case NSBezierPathElement.CurveTo:
                        path.AddCurveToPoint(points[0].X, points[0].Y,
                                             points[1].X, points[1].Y,
                                             points[2].X, points[2].Y);
                        didClosePath = false;
                        break;

                    case NSBezierPathElement.ClosePath:
                        path.CloseSubpath();
                        didClosePath = true;
                        break;
                    }
                }

                // Be sure the path is closed or Quartz may not do valid hit detection.
                if (!didClosePath)
                {
                    path.CloseSubpath();
                }

                return(path);
            }

            return(new CGPath());
#endif
        }
예제 #16
0
 void CardSetup()
 {
     this.CardView.Alpha =1;
     this.CardView.Layer.MasksToBounds = false;
     this.CardView.Layer.CornerRadius = 1;
     this.CardView.Layer.ShadowOffset = new CoreGraphics.CGSize(- .2f, .2f);
     this.CardView.Layer.ShadowRadius = 1;
     this.CardView.Layer.ShadowOpacity = 0.2;
     UIBezierPath path = new UIBezierPath(this.CardView.Bounds);
     this.CardView.Layer.ShadowPath = path.CGPath;
     this.BackgroundColor = new UIColor( .9, .9, .9, 1);
 }
		async Task animateView(UIView view)
		{
			var size = view.Frame.Size;
			var grow = new SizeF((float)size.Width * 1.7f, (float)size.Height * 1.7f);
			var shrink = new SizeF((float)size.Width * .4f, (float)size.Height * .4f);
			TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool> ();
			//Set the animation path
			var pathAnimation = CAKeyFrameAnimation.GetFromKeyPath("position");	
			pathAnimation.CalculationMode = CAAnimation.AnimationPaced;
			pathAnimation.FillMode = CAFillMode.Forwards;
			pathAnimation.RemovedOnCompletion = false;
			pathAnimation.Duration = .5;

			UIBezierPath path = new UIBezierPath ();
			path.MoveTo (view.Center);
			path.AddQuadCurveToPoint (new CGPoint (290, 34), new CGPoint(view.Center.X,View.Center.Y));
			pathAnimation.Path = path.CGPath;

			//Set size change
			var growAnimation = CABasicAnimation.FromKeyPath("bounds.size");
			growAnimation.To = NSValue.FromSizeF (grow);
			growAnimation.FillMode = CAFillMode.Forwards;
			growAnimation.Duration = .1;
			growAnimation.RemovedOnCompletion = false;



			var shrinkAnimation = CABasicAnimation.FromKeyPath("bounds.size");
			shrinkAnimation.To = NSValue.FromSizeF (shrink);
			shrinkAnimation.FillMode = CAFillMode.Forwards;
			shrinkAnimation.Duration = .4;
			shrinkAnimation.RemovedOnCompletion = false;
			shrinkAnimation.BeginTime = .1;


			CAAnimationGroup animations = new CAAnimationGroup ();
			animations.FillMode = CAFillMode.Forwards;
			animations.RemovedOnCompletion = false;
			animations.Animations = new CAAnimation[] {
				pathAnimation,
				growAnimation,
				shrinkAnimation,
			};
			animations.Duration = .5;
			animations.AnimationStopped += (sender, e) => {
				tcs.TrySetResult(true);
			};
			view.Layer.AddAnimation (animations,"movetocart");
			NSTimer.CreateScheduledTimer (.5, (timer) => view.RemoveFromSuperview ());
			await tcs.Task;

		}
예제 #18
0
        //// Drawing Methods
        public static void DrawRefreshIcon(UIColor strokeColor)
        {
            //// Group 2
            {
                //// Bezier Drawing
                UIBezierPath bezierPath = new UIBezierPath();
                bezierPath.MoveTo(new CGPoint(22.65f, 2.0f));
                bezierPath.AddCurveToPoint(new CGPoint(36.33f, 7.67f), new CGPoint(27.6f, 2.0f), new CGPoint(32.55f, 3.89f));
                bezierPath.AddCurveToPoint(new CGPoint(38.13f, 32.97f), new CGPoint(43.23f, 14.57f), new CGPoint(43.83f, 25.39f));
                bezierPath.AddLineTo(new CGPoint(34.26f, 36.84f));
                strokeColor.SetStroke();
                bezierPath.LineWidth = 1.0f;
                bezierPath.Stroke();

                //// Bezier 2 Drawing
                UIBezierPath bezier2Path = new UIBezierPath();
                bezier2Path.MoveTo(new CGPoint(21.35f, 42.0f));
                bezier2Path.AddCurveToPoint(new CGPoint(7.67f, 36.33f), new CGPoint(16.4f, 42.0f), new CGPoint(11.45f, 40.11f));
                bezier2Path.AddCurveToPoint(new CGPoint(5.87f, 11.03f), new CGPoint(0.77f, 29.43f), new CGPoint(0.17f, 18.61f));
                bezier2Path.AddLineTo(new CGPoint(9.74f, 7.16f));
                strokeColor.SetStroke();
                bezier2Path.LineWidth = 1.0f;
                bezier2Path.Stroke();

                //// Bezier 3 Drawing
                UIBezierPath bezier3Path = new UIBezierPath();
                bezier3Path.MoveTo(new CGPoint(34.26f, 29.74f));
                bezier3Path.AddLineTo(new CGPoint(34.26f, 36.84f));
                bezier3Path.AddLineTo(new CGPoint(41.35f, 36.84f));
                bezier3Path.LineJoinStyle = CGLineJoin.Bevel;

                strokeColor.SetStroke();
                bezier3Path.LineWidth = 1.0f;
                bezier3Path.Stroke();

                //// Bezier 4 Drawing
                UIBezierPath bezier4Path = new UIBezierPath();
                bezier4Path.MoveTo(new CGPoint(9.74f, 14.26f));
                bezier4Path.AddLineTo(new CGPoint(9.74f, 7.16f));
                bezier4Path.AddLineTo(new CGPoint(2.65f, 7.16f));
                bezier4Path.LineJoinStyle = CGLineJoin.Bevel;

                strokeColor.SetStroke();
                bezier4Path.LineWidth = 1.0f;
                bezier4Path.Stroke();
            }
        }
예제 #19
0
		public override void Draw (CGRect rect)
		{
			base.Draw (rect);

			var drawPath = new UIBezierPath ();

			drawPath.LineCapStyle = CGLineCap.Round;

			foreach (var line in Lines) {
				drawPath.MoveTo (line.Start);
				drawPath.AddLineTo (line.End);
			}

			drawPath.LineWidth = LineWidth;
			Color.SetColor ();
			drawPath.Stroke ();
		}
예제 #20
0
        public override void Draw(CGRect frame)
        {
            // General Declarations
            var context = UIGraphics.GetCurrentContext();

            // Color Declarations
            var color4 = UIColor.FromRGBA(1.000f, 1.000f, 1.000f, 1.000f);
            var color5 = UIColor.FromRGBA(0.793f, 0.793f, 0.793f, 1.000f);

            // Shadow Declarations
            var shadow = new NSShadow();
            shadow.ShadowColor = UIColor.Black.ColorWithAlpha(0.28f);
            shadow.ShadowOffset = new CGSize(3.1f, 3.1f);
            shadow.ShadowBlurRadius = 5.0f;

            // Rectangle Drawing
            var rectanglePath =
                UIBezierPath.FromRoundedRect(
                    new CGRect(frame.GetMinX() + 10.5f, frame.GetMinY() + 7.5f, frame.Width - 20.0f, 76.0f), 4.0f);
            context.SaveState();
            context.SetShadow(shadow.ShadowOffset, shadow.ShadowBlurRadius, shadow.ShadowColor.CGColor);
            color4.SetFill();
            rectanglePath.Fill();
            context.RestoreState();

            color5.SetStroke();
            rectanglePath.LineWidth = 1.0f;
            rectanglePath.Stroke();


            // Bezier 2 Drawing
            var bezier2Path = new UIBezierPath();
            bezier2Path.MoveTo(new CGPoint(frame.GetMinX() + 0.02386f*frame.Width,
                frame.GetMinY() + 0.50543f*frame.Height));
            bezier2Path.AddLineTo(new CGPoint(frame.GetMinX() + 0.97841f*frame.Width,
                frame.GetMinY() + 0.50543f*frame.Height));
            context.SaveState();
            context.SetShadow(shadow.ShadowOffset, shadow.ShadowBlurRadius, shadow.ShadowColor.CGColor);
            color4.SetFill();
            bezier2Path.Fill();
            context.RestoreState();

            color5.SetStroke();
            bezier2Path.LineWidth = 1.0f;
            bezier2Path.Stroke();
        }
예제 #21
0
        public override void Draw (CGRect rect)
        {
            base.Draw (rect);

            using (var context = UIGraphics.GetCurrentContext ()) {

                UIBezierPath mainAxis = UIBezierPath.FromRoundedRect ( new CGRect (xAxisMargin, 0.0f, 2.0f, rect.Height), 2.0f);
                UIColor.FromRGB ( 203, 203, 203).SetFill();
                mainAxis.Fill();

                nfloat sepInterval = (nfloat)Math.Floor ((rect.Width - xAxisMargin - xTextMargin)/ 5);
                for (int i = 1; i < 6; i++) {
                    var separatorAxis = new UIBezierPath();
                    separatorAxis.MoveTo (new CGPoint (xAxisMargin + sepInterval * i, 0));
                    separatorAxis.AddLineTo (new CGPoint ( xAxisMargin + sepInterval * i, rect.Height - yAxisMargin));
                    UIColor.FromRGB ( 203, 203, 203).SetStroke();
                    separatorAxis.LineWidth = 1.0f;
                    separatorAxis.SetLineDash ( new nfloat[] {1.0f,1.0f}, 1);
                    separatorAxis.Stroke ();

                    var textLayer = new CATextLayer ();
                    textLayer.ContentsScale = UIScreen.MainScreen.Scale;
                    CGFont font = CGFont.CreateWithFontName (LabelFont.Name);

                    if (font != null) {
                        textLayer.SetFont (font);
                        font.Dispose ();
                    }

                    textLayer.FontSize = LabelFont.PointSize;
                    textLayer.AnchorPoint = new CGPoint ( 0.5f, 0.0f);
                    textLayer.AlignmentMode = CATextLayer.AlignmentCenter;
                    textLayer.BackgroundColor = UIColor.Clear.CGColor;
                    textLayer.ForegroundColor = LabelColor.CGColor;

                    CGSize size = ((NSString)"0000 h").StringSize (LabelFont);
                    textLayer.String = "00 h";
                    textLayer.Bounds = new CGRect (0, 0, size.Width, size.Height);
                    textLayer.Position = new CGPoint ( xAxisMargin + sepInterval * i, rect.Height - yAxisMargin + 5.0f);
                    Layer.AddSublayer (textLayer);
                    xAxisText [i - 1] = textLayer;
                }
            }
        }
예제 #22
0
		public static UIBezierPath ToUIKit(this IEnumerable<Point> points, IViewport viewport)
		{
			var pathGeometry = new UIBezierPath ();
		    points = points.ToList();
			if (points.Any()) {

				var first = points.FirstOrDefault ();
				var start = viewport.WorldToScreen (first);

				pathGeometry.MoveTo(ToUIKit (start));

				for (int i = 1; i < points.Count (); i++) {
					var point = points.ElementAt (i);
					var p = viewport.WorldToScreen (point);
					pathGeometry.AddLineTo (new CGPoint ((float)p.X, (float)p.Y));
				}
			}
			return pathGeometry;
		}
예제 #23
0
		public override void ViewDidLayoutSubviews ()
		{
			var button = columnButtons [0];
			nfloat lenght = NMath.Min (button.Frame.Width - 10, button.Frame.Height / 6 - 10);
			var rect = new CGRect (0f, 0f, lenght, lenght);
			chipPath = UIBezierPath.FromOval (rect);

			for (int i = 0; i < chipLayers.Length; i++) {
				for (int j = 0; j < chipLayers [i].Length; j++) {
					CAShapeLayer chip = chipLayers [i] [j];

					if (chip == null)
						continue;

					chip.Path = chipPath.CGPath;
					chip.Frame = chipPath.Bounds;
					chip.Position = PositionForChipLayerAtColumnRow (i, j);
				}
			}
		}
예제 #24
0
        public static void DrawArrowIcon(UIColor strokeColor)
        {
            //// Group
            {
                //// Oval Drawing
                var ovalPath = UIBezierPath.FromOval(new CGRect(2.0f, 2.0f, 40.0f, 40.0f));
                strokeColor.SetStroke();
                ovalPath.LineWidth = 1.0f;
                ovalPath.Stroke();

                //// Bezier Drawing
                UIBezierPath bezierPath = new UIBezierPath();
                bezierPath.MoveTo(new CGPoint(18.77f, 11.03f));
                bezierPath.AddLineTo(new CGPoint(29.74f, 22.0f));
                bezierPath.AddLineTo(new CGPoint(18.77f, 32.97f));
                bezierPath.LineJoinStyle = CGLineJoin.Bevel;

                strokeColor.SetStroke();
                bezierPath.LineWidth = 1.0f;
                bezierPath.Stroke();
            }
        }
예제 #25
0
        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();
        }
예제 #26
0
			public override void Draw (CGRect rect)
			{
				rect = rect.Inset (4, 4);

				rect = new CGRect ((rect.Size.Width - rect.Size.Height) / 2 + 4, 8, rect.Size.Height, rect.Size.Height);
				UIBezierPath path = UIBezierPath.FromOval (rect);
				UIColor.Black.SetStroke ();
				UIColor.White.SetFill ();
				path.LineWidth = 2;
				path.Fill ();
				path.Stroke ();

				UIBezierPath rightEye, leftEye, mouth = new UIBezierPath ();
				if (MovingRight) {
					rightEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () - 5, rect.Y + 15), 4, 0, 180, true);
					leftEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () + 10, rect.Y + 15), 4, 0, 180, true);

					mouth.MoveTo (new CGPoint (rect.GetMidX (), rect.Y + 30));
					mouth.AddLineTo (new CGPoint (rect.GetMidX () + 13, rect.Y + 30));
				} else {
					rightEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () - 10, rect.Y + 15), 4, 0, 180, true);
					leftEye = UIBezierPath.FromArc (new CGPoint (rect.GetMidX () + 5, rect.Y + 15), 4, 0, 180, true);

					mouth.MoveTo (new CGPoint (rect.GetMidX (), rect.Y + 30));
					mouth.AddLineTo (new CGPoint (rect.GetMidX () - 13, rect.Y + 30));

				}
				rightEye.LineWidth = 2;
				rightEye.Stroke ();

				leftEye.LineWidth = 2;
				leftEye.Stroke ();

				mouth.LineWidth = 2;
				mouth.Stroke ();
			}
예제 #27
0
 public virtual void AddBoundaryWithIdentifier(NSCopying identifier, UIBezierPath forPath)
 {
 }
예제 #28
0
 internal void Close(Path bezierPath_)
 {
     bezierPath = bezierPath_;
 }
예제 #29
0
        //Allow the user to import an array of points to be used to draw a signature in the view, with new
        //lines indicated by a CGPoint.Empty in the array.
        public void LoadPoints(CGPoint[] loadedPoints)
        {
            if (loadedPoints == null || loadedPoints.Count () == 0)
                return;

            var startIndex = 0;
            var emptyIndex = loadedPoints.ToList ().IndexOf (CGPoint.Empty);

            if (emptyIndex == -1)
                emptyIndex = loadedPoints.Count ();

            //Clear any existing paths or points.
            paths = new List<UIBezierPath> ();
            points = new List<CGPoint[]> ();

            do {
                //Create a new path and set the line options
                currentPath = UIBezierPath.Create ();
                currentPath.LineWidth = StrokeWidth;
                currentPath.LineJoinStyle = CGLineJoin.Round;

                currentPoints = new List<CGPoint> ();

                //Move to the first point and add that point to the current_points array.
                currentPath.MoveTo (loadedPoints [startIndex]);
                currentPoints.Add (loadedPoints [startIndex]);

                //Iterate through the array until an empty point (or the end of the array) is reached,
                //adding each point to the current_path and to the current_points array.
                for (var i = startIndex + 1; i < emptyIndex; i++) {
                    currentPath.AddLineTo (loadedPoints [i]);
                    currentPoints.Add (loadedPoints [i]);
                }

                //Add the current_path and current_points list to their respective Lists before
                //starting on the next line to be drawn.
                paths.Add (currentPath);
                points.Add (currentPoints.ToArray ());

                //Obtain the indices for the next line to be drawn.
                startIndex = emptyIndex + 1;
                if (startIndex < loadedPoints.Count () - 1) {
                    emptyIndex = loadedPoints.ToList ().IndexOf (CGPoint.Empty, startIndex);

                    if (emptyIndex == -1)
                        emptyIndex = loadedPoints.Count ();
                } else
                    emptyIndex = startIndex;
            } while (startIndex < emptyIndex);

            //Obtain the image for the imported signature and display it in the image view.
                    LoadNewImage();
            //Display the clear button.
            btnClear.Hidden = false;
            SetNeedsDisplay ();
        }
        void DrawCanvas(CGRect frame)
        {
            //// General Declarations
            var context = UIGraphics.GetCurrentContext();

            //// Color Declarations
            var color = UIColor.FromRGBA(0.851f, 0.851f, 0.851f, 1.000f);
            var fillColor3 = UIColor.FromRGBA(0.333f, 0.333f, 0.333f, 1.000f);
            var fillColor4 = UIColor.FromRGBA(0.000f, 0.000f, 0.000f, 1.000f);
            var fillColor5 = UIColor.FromRGBA(0.867f, 0.867f, 0.863f, 1.000f);
            var fillColor6 = UIColor.FromRGBA(0.671f, 0.671f, 0.671f, 1.000f);
            var fillColor7 = UIColor.FromRGBA(0.467f, 0.467f, 0.467f, 1.000f);
            var fillColor8 = UIColor.FromRGBA(0.918f, 0.478f, 0.149f, 1.000f);
            var fillColor9 = UIColor.FromRGBA(0.529f, 0.529f, 0.529f, 1.000f);
            var fillColor10 = UIColor.FromRGBA(0.271f, 0.271f, 0.271f, 1.000f);
            var color2 = UIColor.FromRGBA(0.941f, 0.941f, 0.941f, 1.000f);
            var color5 = UIColor.FromRGBA(0.275f, 0.275f, 0.275f, 1.000f);

            //// Rectangle Drawing
            var rectanglePath = UIBezierPath.FromRoundedRect(new CGRect(frame.GetMinX(), frame.GetMinY() + NMath.Floor((frame.Height) * 0.00000f + 0.5f), frame.Width - 0.5f, frame.Height - NMath.Floor((frame.Height) * 0.00000f + 0.5f)), 4.0f);
            color2.SetFill();
            rectanglePath.Fill();
            color.SetStroke();
            rectanglePath.LineWidth = 1.0f;
            rectanglePath.Stroke();


            //// Group 2
            {
                context.SaveState();
                context.TranslateCTM(frame.GetMinX() + 0.43716f * frame.Width, frame.GetMinY() + 0.12195f * frame.Height);
                context.ScaleCTM(0.4f, 0.4f);



                //// Rectangle 2 Drawing
                var rectangle2Path = UIBezierPath.FromRect(new CGRect(0.0f, 36.0f, 112.0f, 36.0f));
                fillColor3.SetFill();
                rectangle2Path.Fill();


                //// Rectangle 3 Drawing
                var rectangle3Path = UIBezierPath.FromRect(new CGRect(0.0f, 72.0f, 112.0f, 8.0f));
                fillColor4.SetFill();
                rectangle3Path.Fill();


                //// Bezier Drawing
                UIBezierPath bezierPath = new UIBezierPath();
                bezierPath.MoveTo(new CGPoint(0.0f, 80.0f));
                bezierPath.AddCurveToPoint(new CGPoint(8.0f, 88.0f), new CGPoint(0.0f, 84.42f), new CGPoint(3.58f, 88.0f));
                bezierPath.AddLineTo(new CGPoint(104.0f, 88.0f));
                bezierPath.AddCurveToPoint(new CGPoint(112.0f, 80.0f), new CGPoint(108.42f, 88.0f), new CGPoint(112.0f, 84.42f));
                bezierPath.AddLineTo(new CGPoint(0.0f, 80.0f));
                bezierPath.AddLineTo(new CGPoint(0.0f, 80.0f));
                bezierPath.ClosePath();
                bezierPath.UsesEvenOddFillRule = true;

                fillColor5.SetFill();
                bezierPath.Fill();


                //// Bezier 2 Drawing
                UIBezierPath bezier2Path = new UIBezierPath();
                bezier2Path.MoveTo(new CGPoint(56.3f, 88.0f));
                bezier2Path.AddLineTo(new CGPoint(104.0f, 88.0f));
                bezier2Path.AddCurveToPoint(new CGPoint(112.0f, 80.0f), new CGPoint(108.42f, 88.0f), new CGPoint(112.0f, 84.42f));
                bezier2Path.AddLineTo(new CGPoint(48.3f, 80.0f));
                bezier2Path.AddLineTo(new CGPoint(56.3f, 88.0f));
                bezier2Path.AddLineTo(new CGPoint(56.3f, 88.0f));
                bezier2Path.ClosePath();
                bezier2Path.UsesEvenOddFillRule = true;

                fillColor6.SetFill();
                bezier2Path.Fill();


                //// Rectangle 4 Drawing
                var rectangle4Path = UIBezierPath.FromRect(new CGRect(0.0f, 28.0f, 112.0f, 8.0f));
                fillColor4.SetFill();
                rectangle4Path.Fill();


                //// Bezier 3 Drawing
                UIBezierPath bezier3Path = new UIBezierPath();
                bezier3Path.MoveTo(new CGPoint(104.0f, 8.0f));
                bezier3Path.AddLineTo(new CGPoint(76.0f, 8.0f));
                bezier3Path.AddLineTo(new CGPoint(68.0f, 0.0f));
                bezier3Path.AddLineTo(new CGPoint(44.0f, 0.0f));
                bezier3Path.AddLineTo(new CGPoint(36.0f, 8.0f));
                bezier3Path.AddLineTo(new CGPoint(8.0f, 8.0f));
                bezier3Path.AddCurveToPoint(new CGPoint(0.0f, 16.0f), new CGPoint(3.6f, 8.0f), new CGPoint(0.0f, 11.6f));
                bezier3Path.AddLineTo(new CGPoint(0.0f, 28.0f));
                bezier3Path.AddLineTo(new CGPoint(112.0f, 28.0f));
                bezier3Path.AddLineTo(new CGPoint(112.0f, 16.0f));
                bezier3Path.AddCurveToPoint(new CGPoint(104.0f, 8.0f), new CGPoint(112.0f, 11.58f), new CGPoint(108.42f, 8.0f));
                bezier3Path.AddLineTo(new CGPoint(104.0f, 8.0f));
                bezier3Path.ClosePath();
                bezier3Path.UsesEvenOddFillRule = true;

                fillColor5.SetFill();
                bezier3Path.Fill();


                //// Oval Drawing
                var ovalPath = UIBezierPath.FromOval(new CGRect(28.0f, 20.0f, 56.0f, 56.0f));
                fillColor7.SetFill();
                ovalPath.Fill();


                //// Oval 2 Drawing
                var oval2Path = UIBezierPath.FromOval(new CGRect(32.0f, 24.0f, 48.0f, 48.0f));
                fillColor4.SetFill();
                oval2Path.Fill();


                //// Oval 3 Drawing
                var oval3Path = UIBezierPath.FromOval(new CGRect(8.0f, 16.0f, 8.0f, 8.0f));
                fillColor8.SetFill();
                oval3Path.Fill();


                //// Group 3
                {
                    context.SaveState();
                    context.SetAlpha(0.4f);
                    context.BeginTransparencyLayer();


                    //// Bezier 4 Drawing
                    UIBezierPath bezier4Path = new UIBezierPath();
                    bezier4Path.MoveTo(new CGPoint(104.0f, 24.0f));
                    bezier4Path.AddLineTo(new CGPoint(96.0f, 24.0f));
                    bezier4Path.AddLineTo(new CGPoint(104.0f, 16.0f));
                    bezier4Path.AddLineTo(new CGPoint(104.0f, 24.0f));
                    bezier4Path.ClosePath();
                    bezier4Path.UsesEvenOddFillRule = true;

                    fillColor3.SetFill();
                    bezier4Path.Fill();


                    context.EndTransparencyLayer();
                    context.RestoreState();
                }


                //// Bezier 5 Drawing
                UIBezierPath bezier5Path = new UIBezierPath();
                bezier5Path.MoveTo(new CGPoint(96.0f, 24.0f));
                bezier5Path.AddLineTo(new CGPoint(96.0f, 16.0f));
                bezier5Path.AddLineTo(new CGPoint(104.0f, 16.0f));
                bezier5Path.AddLineTo(new CGPoint(96.0f, 24.0f));
                bezier5Path.ClosePath();
                bezier5Path.UsesEvenOddFillRule = true;

                fillColor9.SetFill();
                bezier5Path.Fill();


                //// Oval 4 Drawing
                var oval4Path = UIBezierPath.FromOval(new CGRect(40.0f, 32.0f, 32.0f, 32.0f));
                fillColor3.SetFill();
                oval4Path.Fill();


                //// Bezier 6 Drawing
                UIBezierPath bezier6Path = new UIBezierPath();
                bezier6Path.MoveTo(new CGPoint(60.0f, 36.0f));
                bezier6Path.AddCurveToPoint(new CGPoint(44.0f, 52.0f), new CGPoint(51.16f, 36.0f), new CGPoint(44.0f, 43.16f));
                bezier6Path.AddCurveToPoint(new CGPoint(46.88f, 61.12f), new CGPoint(44.0f, 55.4f), new CGPoint(45.07f, 58.53f));
                bezier6Path.AddCurveToPoint(new CGPoint(56.0f, 64.0f), new CGPoint(49.47f, 62.93f), new CGPoint(52.6f, 64.0f));
                bezier6Path.AddCurveToPoint(new CGPoint(72.0f, 48.0f), new CGPoint(64.84f, 64.0f), new CGPoint(72.0f, 56.84f));
                bezier6Path.AddCurveToPoint(new CGPoint(69.12f, 38.88f), new CGPoint(72.0f, 44.6f), new CGPoint(70.93f, 41.47f));
                bezier6Path.AddCurveToPoint(new CGPoint(60.0f, 36.0f), new CGPoint(66.53f, 37.07f), new CGPoint(63.4f, 36.0f));
                bezier6Path.AddLineTo(new CGPoint(60.0f, 36.0f));
                bezier6Path.ClosePath();
                bezier6Path.UsesEvenOddFillRule = true;

                fillColor7.SetFill();
                bezier6Path.Fill();


                //// Oval 5 Drawing
                var oval5Path = UIBezierPath.FromOval(new CGRect(48.0f, 40.0f, 12.0f, 12.0f));
                fillColor6.SetFill();
                oval5Path.Fill();


                //// Oval 6 Drawing
                var oval6Path = UIBezierPath.FromOval(new CGRect(60.0f, 48.0f, 8.0f, 8.0f));
                fillColor5.SetFill();
                oval6Path.Fill();


                //// Group 4
                {
                    context.SaveState();
                    context.SetAlpha(0.4f);
                    context.BeginTransparencyLayer();


                    //// Bezier 7 Drawing
                    UIBezierPath bezier7Path = new UIBezierPath();
                    bezier7Path.MoveTo(new CGPoint(41.65f, 72.0f));
                    bezier7Path.AddCurveToPoint(new CGPoint(35.96f, 67.54f), new CGPoint(39.57f, 70.75f), new CGPoint(37.65f, 69.26f));
                    bezier7Path.AddLineTo(new CGPoint(35.9f, 67.6f));
                    bezier7Path.AddLineTo(new CGPoint(40.3f, 72.0f));
                    bezier7Path.AddLineTo(new CGPoint(41.65f, 72.0f));
                    bezier7Path.AddLineTo(new CGPoint(41.65f, 72.0f));
                    bezier7Path.ClosePath();
                    bezier7Path.UsesEvenOddFillRule = true;

                    fillColor3.SetFill();
                    bezier7Path.Fill();


                    context.EndTransparencyLayer();
                    context.RestoreState();
                }


                //// Bezier 8 Drawing
                UIBezierPath bezier8Path = new UIBezierPath();
                bezier8Path.MoveTo(new CGPoint(81.26f, 36.0f));
                bezier8Path.AddCurveToPoint(new CGPoint(84.0f, 48.0f), new CGPoint(83.0f, 39.64f), new CGPoint(84.0f, 43.7f));
                bezier8Path.AddCurveToPoint(new CGPoint(70.36f, 72.0f), new CGPoint(84.0f, 58.2f), new CGPoint(78.52f, 67.1f));
                bezier8Path.AddLineTo(new CGPoint(112.0f, 72.0f));
                bezier8Path.AddLineTo(new CGPoint(112.0f, 64.5f));
                bezier8Path.AddLineTo(new CGPoint(83.5f, 36.0f));
                bezier8Path.AddLineTo(new CGPoint(81.26f, 36.0f));
                bezier8Path.AddLineTo(new CGPoint(81.26f, 36.0f));
                bezier8Path.ClosePath();
                bezier8Path.UsesEvenOddFillRule = true;

                fillColor10.SetFill();
                bezier8Path.Fill();



                context.RestoreState();
            }


            //// Text Drawing
            CGRect textRect = new CGRect(frame.GetMinX() + 7.0f, frame.GetMinY() + NMath.Floor((frame.Height - 8.0f) * 0.67568f + 0.5f), frame.Width - 14.0f, frame.Height - 8.0f - NMath.Floor((frame.Height - 8.0f) * 0.67568f + 0.5f));
            {
                var textContent = "Picture Search";
                color5.SetFill();
                var textStyle = new NSMutableParagraphStyle();
                textStyle.Alignment = UITextAlignment.Center;

                var textFontAttributes = new UIStringAttributes() { Font = UIFont.FromName("Avenir-Medium", UIFont.ButtonFontSize), ForegroundColor = color5, ParagraphStyle = textStyle };
                var textTextHeight = new NSString(textContent).GetBoundingRect(new CGSize(textRect.Width, nfloat.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, textFontAttributes, null).Height;
                context.SaveState();
                context.ClipToRect(textRect);
                new NSString(textContent).DrawString(new CGRect(textRect.GetMinX(), textRect.GetMinY() + (textRect.Height - textTextHeight) / 2.0f, textRect.Width, textTextHeight), UIFont.FromName("Avenir-Medium", UIFont.ButtonFontSize), UILineBreakMode.WordWrap, UITextAlignment.Center);
                context.RestoreState();
            }
        }
예제 #31
0
        UIBezierPath CreateCirclePath(CGPoint center, float radius, int sampleCount)
        {
            var smoothedPath = new UIBezierPath ();
            CGPoint startPoint = PointOnCircle (center, radius, -90);

            smoothedPath.MoveTo (startPoint);

            float delta = 360 / sampleCount;
            float angleInDegrees = -90;
            for (int i = 1; i < sampleCount; i++) {
                angleInDegrees += delta;
                var point = PointOnCircle (center, radius, angleInDegrees);
                smoothedPath.AddLineTo (point);
            }
            smoothedPath.AddLineTo (startPoint);
            return smoothedPath;
        }
예제 #32
0
        public override void TouchesBegan(Foundation.NSSet touches, UIEvent evt)
        {
            //Create a new path and set the options.
            currentPath = UIBezierPath.Create ();
            currentPath.LineWidth = StrokeWidth;
            currentPath.LineJoinStyle = CGLineJoin.Round;

            currentPoints.Clear ();

            UITouch touch = touches.AnyObject as UITouch;

            //Obtain the location of the touch, move the path to that position and add it to the
            //current_points array.
            CGPoint touchLocation = touch.LocationInView (this);
            currentPath.MoveTo (touchLocation);
            currentPoints.Add (touchLocation);

            resetBounds (touchLocation);

            btnClear.Hidden = false;
        }
예제 #33
0
 public virtual void AppendPath(UIBezierPath bezierPath)
 {
 }
예제 #34
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            UITouch touch = touches.AnyObject as UITouch;

            //Obtain the location of the touch and add it to the current path and current_points array.
            CGPoint touchLocation = touch.LocationInView (this);
            currentPath.AddLineTo (touchLocation);
            currentPoints.Add (touchLocation);

            //Obtain the smoothed path and the points array for that path.
            currentPath = smoothedPathWithGranularity (40, out currentPoints);
            //Add the smoothed path and points array to their Lists.
            paths.Add (currentPath);
            points.Add (currentPoints.ToArray ());

            //Obtain the image for the imported signature and display it in the image view.
                    LoadNewImage();
            updateBounds (touchLocation);
            SetNeedsDisplay ();
        }