Exemple #1
0
		public override void TouchesBegan (NSSet touches, UIEvent evt)
		{
			IndexCount++;

			var path = new UIBezierPath
			{
				LineWidth = PenWidth
			};

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

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

			InvokeOnMainThread (SetNeedsDisplay);

			CurrentPath = path;

			var line = new VESLine
			{
				Path = CurrentPath, 
				Color = CurrentLineColor,
				Index = IndexCount 
			};

			Lines.Add (line);
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            imageView = new UIImageView(new CGRect(0, 100, 50, 50));
            image = UIImage.FromFile("Sample.png");
            imageView.Image = image;
            View.AddSubview(imageView);

            pt = imageView.Center;

            UIView.BeginAnimations ("slideAnimation");

            UIView.SetAnimationDuration (2);
            UIView.SetAnimationCurve (UIViewAnimationCurve.EaseInOut);
            UIView.SetAnimationRepeatCount (2);
            UIView.SetAnimationRepeatAutoreverses (true);

            UIView.SetAnimationDelegate (this);
            UIView.SetAnimationDidStopSelector (new Selector ("animationDidStop:finished:context:"));

            var xpos = UIScreen.MainScreen.Bounds.Right - imageView.Frame.Width / 2;
            var ypos = imageView.Center.Y;

            imageView.Center = new CGPoint (xpos, ypos);

            UIView.CommitAnimations ();
        }
		public override void TouchesMoved (Foundation.NSSet touches, UIEvent evt)
		{

			swiped = true;
			UITouch touch = touches.AnyObject as UITouch;

			CGPoint currentPoint= touch.LocationInView (this);

			UIGraphics.BeginImageContext(Frame.Size);
			tempDrawImage.Image.Draw(new CGRect(0, 0, Frame.Size.Width, Frame.Size.Height));

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

				context.MoveTo(lastPoint.X, lastPoint.Y);
				context.AddLineToPoint(currentPoint.X,currentPoint.Y);
				context.SetLineCap (CGLineCap.Round);
				context.SetLineWidth (brush);
				context.SetStrokeColor (PaintColor.CGColor);
				context.SetBlendMode (CGBlendMode.Normal);
				context.StrokePath ();


			}
			tempDrawImage.Image = UIGraphics.GetImageFromCurrentImageContext ();
			tempDrawImage.Alpha = opacity;
			UIGraphics.EndImageContext ();
			lastPoint = currentPoint;
		}
		public OverlayScene (CGSize size) : base (size)
		{
			AnchorPoint = new CGPoint (0.5f, 0.5f);
			ScaleMode = SKSceneScaleMode.ResizeFill;

			float scale = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 1.5f : 1f;

			var myImage = SKSpriteNode.FromImageNamed (ResourceManager.GetResourcePath ("speedGauge.png"));
			myImage.AnchorPoint = new CGPoint (0.5f, 0f);
			myImage.Position = new CGPoint (size.Width * 0.33f, -size.Height * 0.5f);
			myImage.XScale = 0.8f * scale;
			myImage.YScale = 0.8f * scale;
			AddChild (myImage);

			var needleHandle = SKNode.Create ();
			var needle = SKSpriteNode.FromImageNamed (ResourceManager.GetResourcePath ("needle.png"));
			needleHandle.Position = new CGPoint (0f, 16f);
			needle.AnchorPoint = new CGPoint (0.5f, 0f);
			needle.XScale = 0.7f;
			needle.YScale = 0.7f;
			needle.ZRotation = (float)Math.PI / 2f;
			needleHandle.AddChild (needle);
			myImage.AddChild (needleHandle);

			SpeedNeedle = needleHandle;

			var cameraImage = SKSpriteNode.FromImageNamed (ResourceManager.GetResourcePath ("video_camera.png"));
			cameraImage.Position = new CGPoint (-size.Width * 0.4f, -size.Height * 0.4f);
			cameraImage.Name = "camera";
			cameraImage.XScale = 0.6f * scale;
			cameraImage.YScale = 0.6f * scale;
			AddChild (cameraImage);
		}
        public override void Draw(CGRect rect)
        {
            Graphics g = Graphics.FromCurrentContext ();

            g.Clear (Color.Wheat);

            var mainBundle = NSBundle.MainBundle;
            var filePath = mainBundle.PathForResource ("CocoaMono", "png");

            var bitmap = Image.FromFile (filePath);

            filePath = mainBundle.PathForResource ("tiger-Q300", "png");

            var tiger = Image.FromFile (filePath);

            using (var ig = Graphics.FromImage (bitmap)) {
                var pen = new Pen (Brushes.Yellow, 20);
                var rec = new CGSize (200, 200);
                var recp = new CGPoint (bitmap.Width - rec.Width - pen.Width / 2, bitmap.Height - rec.Height - pen.Width / 2);
                ig.DrawEllipse (pen, (RectangleF)new CGRect(recp, rec));
            }

            g.DrawImage (bitmap, 50f, 50f);
            g.DrawImage (tiger, 200f, 200f);

            using (var brush = new SolidBrush (BACKCOLOR)) {
                Image pic = GetCircleImage (); //get circle image
                var newSize = new CGSize (pic.Size.Width * SCALE, pic.Size.Height * SCALE); //calculate new size of circle
                g.FillEllipse (brush, (RectangleF)new CGRect (circleLocation, newSize)); //draw the shape background
                g.DrawImage (pic, (RectangleF)new CGRect (circleLocation, newSize)); //draw the hatch style
            }

            g.Dispose ();
        }
		public override void TouchesBegan (Foundation.NSSet touches, UIKit.UIEvent evt)
		{

			swiped = false;
			UITouch touch = touches.AnyObject as UITouch ;
			lastPoint = touch.LocationInView (this);
		}
 PointF Point2D(CGPoint pt)
 {
     var aPoint = new PointF ();
     aPoint.X = (float)(form1.panel1.Width / 2 + pt.X);
     aPoint.Y = (float)(form1.panel1.Height / 2 - pt.Y);
     return aPoint;
 }
        public void AddAreas(Graphics g, ChartStyle cs, int nSeries, int nPoints)
        {
            float[] ySum = new float[nPoints];
            var pts = new Point[2 * nPoints];
            CGPoint[] pt0 = new CGPoint[nPoints];
            CGPoint[] pt1 = new CGPoint[nPoints];
            for (int i = 0; i < nPoints; i++) {
                ySum [i] = AreaAxis;
            }

            int n = 0;
            foreach (DataSeries ds in DataSeriesList) {
                var aPen = new Pen (ds.LineStyle.LineColor, ds.LineStyle.Thickness);
                aPen.DashStyle = ds.LineStyle.Pattern;
                Color fillColor = Color.FromArgb (CMap [n, 0], CMap [n, 1], CMap [n, 2], CMap [n, 3]);
                var aBrush = new SolidBrush (fillColor);
                // Draw lines and areas:
                if (ds.LineStyle.PlotMethod == LineStyle.PlotLinesMethodEnum.Lines) {
                    for (int i = 0; i < nPoints; i++) {
                        pt0 [i] = new CGPoint (((CGPoint)ds.PointList [i]).X, ySum [i]);
                        ySum [i] = (float)(ySum[i] + ((CGPoint)ds.PointList[i]).Y);
                        pt1 [i] = new CGPoint (((CGPoint)ds.PointList [i]).X, ySum [i]);
                        pts [i] = cs.Point2D (pt0 [i]);
                        pts [2 * nPoints - 1 - i] = cs.Point2D (pt1 [i]);
                    }
                    g.FillPolygon (aBrush, pts);
                    g.DrawPolygon (Pens.Black, pts);
                }
                n++;
            }
        }
        public override void Draw(CGRect dirtyRect)
        {
            Graphics g = Graphics.FromCurrentContext();

            var ClientRectangle = new Rectangle ((int)dirtyRect.X, (int)dirtyRect.Y, (int)dirtyRect.Width, (int)dirtyRect.Height);

            // Calculate the location and size of the drawing area
            // Within which we want to draw the graphics:
            //Rectangle ChartArea = ClientRectangle;
            var ChartArea = new Rectangle (50, 50, ClientRectangle.Width - 70, ClientRectangle.Height - 70);
            g.DrawRectangle (Pens.LightCoral, ChartArea);
            PlotArea = new Rectangle (ChartArea.Location, ChartArea.Size);
            PlotArea.Inflate (-offset, -offset);
            //Draw ClientRectangle and PlotArea using pen:
            g.DrawRectangle (Pens.Black, PlotArea);
            // Generate Sine and Cosine data points to plot:
            CGPoint[] pt1 = new CGPoint[nPoints];
            CGPoint[] pt2 = new CGPoint[nPoints];
            for (int i = 0; i < nPoints; i++) {
                pt1[i] = new CGPoint (i / 5.0f, (float)Math.Sin (i/5.0f));
                pt2[i] = new CGPoint (i / 5.0f, (float)Math.Cos (i/5.0f));
            }

            for (int i = 1; i < nPoints; i++) {
                g.DrawLine (Pens.Blue, Point2D (pt1[i - 1]), Point2D (pt1[i]));
                g.DrawLine (Pens.Red, Point2D (pt2[i - 1]), Point2D (pt2[i]));
            }

            g.Dispose();
        }
		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;
		}
 PointF Point2D(CGPoint ptf)
 {
     var aPoint = new PointF ();
     aPoint.X = (float)(drawingRectangle.X + (ptf.X - xMin) * drawingRectangle.Width / (xMax - xMin));
     aPoint.Y = (float)(drawingRectangle.Bottom - (ptf.Y - yMin) * drawingRectangle.Height / (yMax - yMin));
     return aPoint;
 }
        public UICircleView(CGRect rect, CGPoint center, nfloat radius)
            : base(rect)
        {
            _center = center;
            _radius = radius;

            BackgroundColor = UIColor.Clear;
        }
        PointF Point2D(CGPoint ptf)
        {
            var aPoint = new PointF ();
            if (ptf.X < xMin || ptf.X > xMax || ptf.Y < yMin || ptf.Y > yMax) {
                ptf.X = float.NaN;
                ptf.Y = float.NaN;
            }

            aPoint.X = (float)(PlotArea.X + (ptf.X - xMin) * PlotArea.Width / (xMax - xMin));
            aPoint.Y = (float)(PlotArea.Bottom - (ptf.Y - yMin) * PlotArea.Height / (yMax - yMin));
            return aPoint;
        }
Exemple #14
0
		public unsafe void ShowCGGlyphs (
			short[] /* const CGGlyph* = CGFontIndex* = unsigned short* */ glyphs,
			CGPoint[] /* const CGPoint* */ positions,
			nuint /* NSUInteger */ glyphCount,
			UIFont font,
			CGAffineTransform textMatrix,
			NSDictionary attributes,
			CGContext graphicsContext)
		{
			fixed (short* gl = glyphs) {
				fixed (CGPoint* pos = positions) {
					ShowCGGlyphsInternal ((IntPtr) gl, (IntPtr) pos, glyphCount, font, textMatrix, attributes, graphicsContext);
				}
			}
		}
        public override void Draw(CGRect rect)
        {
            Graphics g = Graphics.FromCurrentContext ();
            // Create a pen object:
            var aPen = new Pen (Color.Blue, 4);

            // Set line caps and dash style:
            aPen.StartCap = LineCap.Flat;
            aPen.EndCap = LineCap.ArrowAnchor;
            aPen.DashStyle = DashStyle.Dot;
            aPen.DashOffset = 50;

            //draw straight line:
            g.DrawLine (aPen, 50, 30, 200, 30);
            // define point array to draw a curve:
            var point1 = new Point (50, 200);
            var point2 = new Point (100, 75);
            var point3 = new Point (150, 60);
            var point4 = new Point (200, 160);
            var point5 = new Point (250, 250);
            Point[] Points = {
                point1, point2, point3, point4, point5
            };
            g.DrawCurve (aPen, Points);

            aPen.Dispose ();

            //Text rotation:
            CGRect ClientRectangle = rect;
            string s = "A simple text string";
            var rectangle = new CGRect ((int)ClientRectangle.X, (int)ClientRectangle.Y, (int)ClientRectangle.Width, (int)ClientRectangle.Height);
            drawingRectangle = new CGRect (rectangle.Location, rectangle.Size);
            var sz = new CGSize (rectangle.Width, rectangle.Height);
            var font = new Font ("Arialss", 14f, FontStyle.Bold | FontStyle.Italic | FontStyle.Underline);
            CGSize stringSize = g.MeasureString (s, font);
            var Middle = new CGPoint (sz.Width / 30, sz.Height / 2 - (int)stringSize.Height / 2);

            g.DrawLine (Pens.Black, new Point (0, (int)(rectangle.Height / 2)), new Point ((int)rectangle.Width, (int)(rectangle.Height / 2)));
            g.DrawLine (Pens.Black, new Point ((int)(rectangle.Width / 2), 0), new Point ((int)(rectangle.Width / 2), (int)rectangle.Height));

            g.TranslateTransform ((float)Middle.X, (float)Middle.Y);
            g.RotateTransform (-90);
            var format = new StringFormat ();
            format.Alignment = StringAlignment.Center;
            g.DrawString (s, font, Brushes.Black, 0, 0, format);

            g.Dispose ();
        }
		private void MoveTrackingHandle(CGPoint lastTouch)
		{
			var circlePoint = new CGPoint (this.Frame.Size.Width/2 , this.Frame.Size.Height / 2 );

			float currentRadians = AngleFromNorth (circlePoint, lastTouch, true);

			var angle = Math.Floor (currentRadians);

			HandlePostionRadians = ((float)360.0 - (float)angle);

			HandlePositionAngle = (float) angle;

			SetNeedsDisplay ();


		}
Exemple #17
0
        public static UIImage ImageFromFont(UIFont font, char character, UIColor fillColor)
        {
            var s = new NSString("" + character);
            var stringSize = s.StringSize(font);
            var maxSize = (nfloat)Math.Max(stringSize.Height, stringSize.Width);
            var size = new CGSize(maxSize, maxSize);

            UIGraphics.BeginImageContextWithOptions(size, false, 0f);
            fillColor.SetFill();

            var drawPoint = new CGPoint((size.Width / 2f) - (stringSize.Width / 2f),
                                (size.Height / 2f) - (stringSize.Height / 2f));
            s.DrawString(drawPoint, font);

            var img = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();
            return img;
        }
Exemple #18
0
		public override void TouchesMoved (NSSet touches, UIEvent evt)
		{
			var touch = (UITouch)touches.AnyObject;
			var currentPoint = touch.LocationInView (this);

			if (Math.Abs (currentPoint.X - PreviousPoint.X) >= 4 ||
				Math.Abs (currentPoint.Y - PreviousPoint.Y) >= 4) {

				var newPoint = new CGPoint ((currentPoint.X + PreviousPoint.X) / 2, (currentPoint.Y + PreviousPoint.Y) / 2);

				CurrentPath.AddQuadCurveToPoint (newPoint, PreviousPoint);
				PreviousPoint = currentPoint;
			} else {
				CurrentPath.AddLineTo (currentPoint);
			}

			InvokeOnMainThread (SetNeedsDisplay);
		}
		public void applyGravity()
		{
			if (firstTime) {
				firstTime = false;

				TKChartVisualPoint[] points1 = chart.VisualPointsForSeries (chart.Series [0]);
				originalValues = new List<CGPoint> ();
				foreach (TKChartVisualPoint p in points1) {
					originalValues.Add (p.CGPoint);
				}
				TKChartVisualPoint point1 = points1 [4];
				originalLocation = point1.Center;
			}

			animator = new UIDynamicAnimator (chart.PlotView);
			TKChartVisualPoint[] points = chart.VisualPointsForSeries (chart.Series [0]);
			TKChartVisualPoint point = points [4];

			for (int i=0; i<originalValues.Count; i++) {
				TKChartVisualPoint pt = points [i];
				if (pt.Animator != null) {
					pt.Animator.RemoveAllBehaviors();
					pt.Animator = null;
				}
				pt.Center = ((CGPoint)originalValues[i]);
			}

			point.Center = new CGPoint (originalLocation.X, 0);

			UICollisionBehavior collision = new UICollisionBehavior (points);
			collision.TranslatesReferenceBoundsIntoBoundary = true;

			UIGravityBehavior gravity = new UIGravityBehavior (points);
			gravity.GravityDirection = new CGVector (0.0f, 2.0f);

			UIDynamicItemBehavior dynamic = new UIDynamicItemBehavior (points);
			dynamic.Elasticity = 0.5f;

			animator.AddBehavior(dynamic);
			animator.AddBehavior(gravity);
			animator.AddBehavior(collision);
		}
        // UIScrollView will check for scrolling and suppress touchesBegan
        // if the user is scrolling. We want to allow our controls to consume it
        // before that.
        public override UIView HitTest(CGPoint point, UIEvent uievent)
        {
            // transform the point into absolute coords (as if there was no scrolling)
            CGPoint absolutePoint = new CGPoint( ( point.X - ContentOffset.X ) + Frame.Left,
                                                 ( point.Y - ContentOffset.Y ) + Frame.Top );

            if ( Frame.Contains( absolutePoint ) )
            {
                // Base OS controls need to know whether to process & consume
                // input or pass it up to the higher level (us.)
                // We decide that based on whether the HitTest intersects any of our controls.
                // By returning true, it can know "Yes, this hits something we need to know about"
                // and it will result in us receiving TouchBegan
                if( Interceptor.HitTest( point ) )
                {
                    return null;
                }
            }
            return base.HitTest(point, uievent);
        }
		public override void ViewWillLayoutSubviews ()
		{
			base.ViewWillLayoutSubviews ();

			CGRect bounds = View.Bounds;
			CGSize imageSize = backgroundView.Image.Size;
			nfloat imageAspectRatio = imageSize.Width / imageSize.Height;
			nfloat viewAspectRatio = bounds.Width / bounds.Height;

			if (viewAspectRatio > imageAspectRatio) {
				// Let the background run off the top and bottom of the screen, so it fills the width
				var scaledSize = new CGSize (bounds.Width, bounds.Width / imageAspectRatio);
				var location = new CGPoint (0, (bounds.Height - scaledSize.Height) / 2f);
				backgroundView.Frame = new CGRect (location, scaledSize);
			} else {
				// Let the background run off the left and right of the screen, so it fills the height
				var scaledSize = new CGSize (imageAspectRatio * bounds.Height, bounds.Height);
				var location = new CGPoint ((bounds.Width - scaledSize.Width) / 2f, 0);
				backgroundView.Frame = new CGRect (location, scaledSize);
			}
		}
 /// <summary>
 /// LateralPan of a viewport between two points
 /// </summary>
 public static void LateralPan(this ViewportInfo viewport, CGPoint fromPoint, CGPoint toPoint, bool flipX, bool flipY)
 {
     double deltaX, deltaY, s;
       Rhino.Geometry.Transform s2c = viewport.GetXform (CoordinateSystem.Screen, CoordinateSystem.Clip);
       Rhino.Geometry.Point3d screenPoint0 = new Rhino.Geometry.Point3d (fromPoint.X, fromPoint.Y, 0.0);
       Rhino.Geometry.Point3d screenPoint1 = new Rhino.Geometry.Point3d (toPoint.X, toPoint.Y, 0.0);
       Rhino.Geometry.Point3d clipPoint0 = s2c * screenPoint0;
       Rhino.Geometry.Point3d clipPoint1 = s2c * screenPoint1;
       deltaX = 0.5 * (clipPoint1.X - clipPoint0.X);
       deltaY = 0.5 * (clipPoint1.Y - clipPoint0.Y);
       deltaX *= (viewport.FrustumRight - viewport.FrustumLeft);
       deltaY *= (viewport.FrustumBottom - viewport.FrustumTop);
       if (viewport.IsPerspectiveProjection) {
     s = viewport.TargetPoint.DistanceTo (viewport.CameraLocation) / viewport.FrustumNear;
     deltaX *= flipX ? -s : s;
     deltaY *= flipY ? -s : s;
       }
       Rhino.Geometry.Vector3d dollyVector = (deltaX * viewport.CameraX) + (deltaY * viewport.CameraY);
       viewport.TargetPoint = viewport.TargetPoint - dollyVector;
       viewport.SetCameraLocation (viewport.CameraLocation - dollyVector);
 }
        public void AddBars(Graphics g, ChartStyle cs, int numberOfDataSeries, int numberOfPoints)
        {
            // Draw bars:
            var temp = new ArrayList ();
            float[] tempy = new float[numberOfPoints];
            var temppt = new CGPoint ();
            int n = 0;
            foreach (DataSeries ds in DataSeriesList) {
                var aPen = new Pen (ds.BarStyle.BorderColor, ds.BarStyle.BorderThickness);
                var aBrush = new SolidBrush (ds.BarStyle.FillColor);
                aPen.DashStyle = ds.BarStyle.BorderPattern;
                var pts = new PointF[4];
                CGPoint pt;
                float width;

                if (cs.BarType == ChartStyle.BarTypeEnum.Vertical) {
                    if (numberOfDataSeries == 1) {
                        // Find the minumum and maximum y values:
                        float ymin = 0;
                        float ymax = 0;
                        for (int i = 0; i < ds.PointList.Count; i++) {
                            pt = (CGPoint)ds.PointList[i];
                            ymin = (float)Math.Min (ymin, pt.Y);
                            ymax = (float)Math.Max (ymax, pt.Y);
                        }

                        width = cs.XTick * ds.BarStyle.BarWidth;
                        for (int i = 0; i < ds.PointList.Count; i++) {
                            pt = (CGPoint)ds.PointList[i];
                            var x = (float)(pt.X - cs.XTick / 2);
                            pts[0] = cs.Point2D (new CGPoint (x - width / 2, 0));
                            pts[1] = cs.Point2D (new CGPoint (x + width / 2, 0));
                            pts[2] = cs.Point2D (new CGPoint (x + width / 2, pt.Y));
                            pts[3] = cs.Point2D (new CGPoint (x - width / 2, pt.Y));
                            if (ds.IsSingleColorMap) {
                                DrawColorMap (g, pts, ds.CMap, ymin, ymax, (float)pt.Y);
                            } else if (ds.IsColorMap) {
                                float dy = (ymax - ymin) / 100;
                                var points = new PointF[4];
                                for (int j = 0; j <= (int)Math.Round(100 * (pt.Y - ymin) / (ymax - ymin)); j++) {
                                    points[0] = cs.Point2D (new CGPoint (x - width / 2, (j - 1) * dy));
                                    points[1] = cs.Point2D (new CGPoint (x + width / 2, (j - 1) * dy));
                                    points[2] = cs.Point2D (new CGPoint (x + width / 2, j * dy));
                                    points[3] = cs.Point2D (new CGPoint (x - width / 2, j * dy));
                                    DrawColorMap (g, points, ds.CMap, ymin, ymax, j * dy);
                                }
                            } else {
                                g.FillPolygon (aBrush, pts);
                            }
                            g.DrawPolygon (aPen, pts);
                        }
                    } else if (numberOfDataSeries > 1) {
                        width = 0.7f * cs.XTick;
                        for (int i = 0; i < ds.PointList.Count; i++) {
                            pt = (CGPoint)ds.PointList[i];
                            float w1 = width / numberOfDataSeries;
                            float w = ds.BarStyle.BarWidth * w1;
                            float space = (w1 - w) / 2;
                            var x = (float)(pt.X - cs.XTick / 2);
                            pts[0] = cs.Point2D (new CGPoint (
                                x - width / 2 + space + n * w1, 0));
                            pts[1] = cs.Point2D (new CGPoint (
                                x - width / 2 + space + n * w1 + w, 0));
                            pts[2] = cs.Point2D (new CGPoint (
                                x - width / 2 + space + n * w1 + w, pt.Y));
                            pts[3] = cs.Point2D (new CGPoint (
                                x - width / 2 + space + n * w1, pt.Y));
                            g.FillPolygon (aBrush, pts);
                            g.DrawPolygon (aPen, pts);
                        }
                    }
                }
                else if (cs.BarType == ChartStyle.BarTypeEnum.VerticalOverlay  && numberOfDataSeries > 1) {
                    width = cs.XTick * ds.BarStyle.BarWidth;
                    width = width / (float)Math.Pow(2, n);
                    for (int i = 0; i < ds.PointList.Count; i++) {
                        pt = (CGPoint)ds.PointList[i];
                        var x = (float)(pt.X - cs.XTick / 2);
                        pts[0] = cs.Point2D (new CGPoint(x - width / 2, 0));
                        pts[1] = cs.Point2D (new CGPoint(x + width / 2, 0));
                        pts[2] = cs.Point2D (new CGPoint(x + width / 2, pt.Y));
                        pts[3] = cs.Point2D (new CGPoint(x - width / 2, pt.Y));
                        g.FillPolygon(aBrush, pts);
                        g.DrawPolygon(aPen, pts);
                    }
                } else if (cs.BarType == ChartStyle.BarTypeEnum.VerticalStack && numberOfDataSeries > 1) {
                    width = cs.XTick * ds.BarStyle.BarWidth;
                    for (int i = 0; i < ds.PointList.Count; i++) {
                        pt = (CGPoint)ds.PointList[i];
                        if (temp.Count > 0)
                            tempy[i] = (float)(tempy[i] + ((CGPoint)temp[i]).Y);
                        var x = (float)(pt.X - cs.XTick / 2);
                        pts[0] = cs.Point2D (new CGPoint (x - width / 2, 0 + tempy[i]));
                        pts[1] = cs.Point2D (new CGPoint (x + width / 2, 0 + tempy[i]));
                        pts[2] = cs.Point2D (new CGPoint (x + width / 2, pt.Y + tempy[i]));
                        pts[3] = cs.Point2D (new CGPoint (x - width / 2, pt.Y + tempy[i]));

                        g.FillPolygon (aBrush, pts);
                        g.DrawPolygon (aPen, pts);
                    }
                    temp = ds.PointList;
                } else if (cs.BarType == ChartStyle.BarTypeEnum.Horizontal) {
                    if (numberOfDataSeries == 1) {
                        width = cs.YTick * ds.BarStyle.BarWidth;
                        for (int i = 0; i < ds.PointList.Count; i++) {
                            temppt = (CGPoint)ds.PointList[i];
                            pt = new CGPoint(temppt.Y, temppt.X);
                            var y = (float)(pt.Y - cs.YTick / 2);
                            pts[0] = cs.Point2D (new CGPoint (0, y - width / 2));
                            pts[1] = cs.Point2D (new CGPoint (0, y + width / 2));
                            pts[2] = cs.Point2D (new CGPoint (pt.X, y + width / 2));
                            pts[3] = cs.Point2D (new CGPoint (pt.X, y - width / 2));
                            g.FillPolygon (aBrush, pts);
                            g.DrawPolygon (aPen, pts);
                        }
                    } else if (numberOfDataSeries > 1) {
                        width = 0.7f * cs.YTick;
                        for (int i = 0; i < ds.PointList.Count; i++) {
                            temppt = (CGPoint)ds.PointList[i];
                            pt = new CGPoint(temppt.Y, temppt.X);
                            float w1 = width / numberOfDataSeries;
                            float w = ds.BarStyle.BarWidth * w1;
                            float space = (w1 - w) / 2;
                            var y = (float)(pt.Y - cs.YTick / 2);
                            pts[0] = cs.Point2D (new CGPoint (0,
                                y - width / 2 + space + n * w1));
                            pts[1] = cs.Point2D (new CGPoint (0,
                                y - width / 2 + space + n * w1 + w));
                            pts[2] = cs.Point2D (new CGPoint (pt.X,
                                y - width / 2 + space + n * w1 + w));
                            pts[3] = cs.Point2D (new CGPoint (pt.X,
                                y - width / 2 + space + n * w1));
                            g.FillPolygon (aBrush, pts);
                            g.DrawPolygon (aPen, pts);
                        }
                    }
                } else if (cs.BarType == ChartStyle.BarTypeEnum.HorizontalOverlay && numberOfDataSeries > 1) {
                    width = cs.YTick * ds.BarStyle.BarWidth;
                    width = width / (float)Math.Pow(2, n);
                    for (int i = 0; i < ds.PointList.Count; i++) {
                        temppt = (CGPoint)ds.PointList[i];
                        pt = new CGPoint(temppt.Y, temppt.X);
                        var y = (float)(pt.Y - cs.YTick / 2);
                        pts[0] = cs.Point2D (new CGPoint (0, y - width / 2));
                        pts[1] = cs.Point2D (new CGPoint (0, y + width / 2));
                        pts[2] = cs.Point2D (new CGPoint (pt.X, y + width / 2));
                        pts[3] = cs.Point2D (new CGPoint (pt.X, y - width / 2));
                        g.FillPolygon (aBrush, pts);
                        g.DrawPolygon (aPen, pts);
                    }
                } else if (cs.BarType == ChartStyle.BarTypeEnum.HorizontalStack && numberOfDataSeries > 1) {
                    width = cs.YTick * ds.BarStyle.BarWidth;
                    for (int i = 0; i < ds.PointList.Count; i++)
                    {
                        temppt = (CGPoint)ds.PointList[i];
                        pt = new CGPoint(temppt.Y, temppt.X);
                        if (temp.Count > 0) {
                            temppt = (CGPoint)temp[i];
                            tempy[i] = (float)(tempy[i] + temppt.Y);
                        }

                        var y = (float)(pt.Y - cs.YTick / 2);
                        pts[0] = cs.Point2D (new CGPoint (0 + tempy[i], y - width / 2));
                        pts[1] = cs.Point2D (new CGPoint (0 + tempy[i], y + width / 2));
                        pts[2] = cs.Point2D (new CGPoint (pt.X + tempy[i], y + width / 2));
                        pts[3] = cs.Point2D (new CGPoint (pt.X + tempy[i], y - width / 2));

                        g.FillPolygon (aBrush, pts);
                        g.DrawPolygon (aPen, pts);
                    }
                    temp = ds.PointList;
                }
                n++;
                aPen.Dispose ();
            }
        }
		public override void TouchesMoved (NSSet touches, UIEvent evt)
		{
			base.TouchesMoved (touches, evt);

			if (selectedPoint == null) {
				return;
			}

			UITouch touch = (UITouch)touches.AnyObject;
			CGPoint touchPoint = touch.LocationInView(chart.PlotView);
			CGPoint delta = new CGPoint(originalLocation.X - touchPoint.X, originalLocation.Y - touchPoint.Y);

			selectedPoint.Center = new CGPoint(originalPosition.X, originalPosition.Y - delta.Y);
		}
		public override void TouchesBegan (NSSet touches, UIEvent evt)
		{
			base.TouchesBegan (touches, evt);

			UITouch touch = (UITouch)touches.AnyObject;
			CGPoint touchPoint = touch.LocationInView(chart.PlotView);
			TKChartSelectionInfo hitTestInfo = chart.HitTestForPoint(touchPoint);
			if (hitTestInfo != null) {
				selectedPoint = chart.VisualPointForSeries (hitTestInfo.Series, hitTestInfo.DataPointIndex);
				originalLocation = touchPoint;
				if (selectedPoint != null) {
					selectedPoint.Animator = null;
					originalPosition = selectedPoint.Center;
				}
			}
		}
			public void ShowTryAgain()
			{
				var center = new CGPoint (Bounds.GetMidX (), Bounds.Height - tryAgain.Frame.Height / 2 - 10);
				tryAgain.Center = center;
				tryAgain.Alpha = 0;
				AddSubview (tryAgain);
				Animate (.3, () => {tryAgain.Alpha = 1;});
			}
 protected virtual void DidScroll(CGPoint p)
 {
 }
		public extern static void void_objc_msgSendSuper_CGPoint (IntPtr receiver, IntPtr selector, CGPoint arg1);
		public extern static void CGPoint_objc_msgSendSuper_stret (out CGPoint retval, IntPtr receiver, IntPtr selector);
Exemple #30
0
		public CGEvent (CGEventSource source, CGEventType mouseType, CGPoint mouseCursorPosition, CGMouseButton mouseButton)
		{
			handle = CGEventCreateMouseEvent (source == null ? IntPtr.Zero : source.Handle, mouseType, mouseCursorPosition, mouseButton);
		}