static void ApplierCallback(IntPtr info, IntPtr element_ptr) { GCHandle gch = GCHandle.FromIntPtr(info); CGPathElement element = new CGPathElement(Marshal.ReadInt32(element_ptr, 0)); ApplierFunction func = (ApplierFunction)gch.Target; IntPtr ptr = Marshal.ReadIntPtr(element_ptr, 4); int ptsize = Marshal.SizeOf(typeof(PointF)); switch (element.Type) { case CGPathElementType.CloseSubpath: break; case CGPathElementType.MoveToPoint: case CGPathElementType.AddLineToPoint: element.Point1 = (PointF)Marshal.PtrToStructure(ptr, typeof(PointF)); break; case CGPathElementType.AddQuadCurveToPoint: element.Point1 = (PointF)Marshal.PtrToStructure(ptr, typeof(PointF)); element.Point2 = (PointF)Marshal.PtrToStructure(((IntPtr)(((long)ptr) + ptsize)), typeof(PointF)); break; case CGPathElementType.AddCurveToPoint: element.Point1 = (PointF)Marshal.PtrToStructure(ptr, typeof(PointF)); element.Point2 = (PointF)Marshal.PtrToStructure(((IntPtr)(((long)ptr) + ptsize)), typeof(PointF)); element.Point3 = (PointF)Marshal.PtrToStructure(((IntPtr)(((long)ptr) + (2 * ptsize))), typeof(PointF)); break; } func(element); }
static void ApplierCallback (IntPtr info, IntPtr element_ptr) { GCHandle gch = GCHandle.FromIntPtr (info); CGPathElement element = new CGPathElement (Marshal.ReadInt32 (element_ptr, 0)); ApplierFunction func = (ApplierFunction) gch.Target; IntPtr ptr = Marshal.ReadIntPtr (element_ptr, 4); int ptsize = Marshal.SizeOf (typeof (PointF)); switch (element.Type){ case CGPathElementType.CloseSubpath: break; case CGPathElementType.MoveToPoint: case CGPathElementType.AddLineToPoint: element.Point1 = (PointF) Marshal.PtrToStructure (ptr, typeof (PointF)); break; case CGPathElementType.AddQuadCurveToPoint: element.Point1 = (PointF) Marshal.PtrToStructure (ptr, typeof (PointF)); element.Point2 = (PointF) Marshal.PtrToStructure (((IntPtr) (((long)ptr) + ptsize)), typeof (PointF)); break; case CGPathElementType.AddCurveToPoint: element.Point1 = (PointF) Marshal.PtrToStructure (ptr, typeof (PointF)); element.Point2 = (PointF) Marshal.PtrToStructure (((IntPtr) (((long)ptr) + ptsize)), typeof (PointF)); element.Point3 = (PointF) Marshal.PtrToStructure (((IntPtr) (((long)ptr) + (2*ptsize))), typeof (PointF)); break; } func (element); }