static void ApplierCallback(IntPtr info, IntPtr element_ptr) { GCHandle gch = GCHandle.FromIntPtr(info); // note: CGPathElementType is an untyped enum, always 32bits CGPathElement element = new CGPathElement(Marshal.ReadInt32(element_ptr, 0)); ApplierFunction func = (ApplierFunction)gch.Target; IntPtr ptr = Marshal.ReadIntPtr(element_ptr, IntPtr.Size); int ptsize = Marshal.SizeOf(typeof(CGPoint)); switch (element.Type) { case CGPathElementType.CloseSubpath: break; case CGPathElementType.MoveToPoint: case CGPathElementType.AddLineToPoint: element.Point1 = (CGPoint)Marshal.PtrToStructure(ptr, typeof(CGPoint)); break; case CGPathElementType.AddQuadCurveToPoint: element.Point1 = (CGPoint)Marshal.PtrToStructure(ptr, typeof(CGPoint)); element.Point2 = (CGPoint)Marshal.PtrToStructure(((IntPtr)(((long)ptr) + ptsize)), typeof(CGPoint)); break; case CGPathElementType.AddCurveToPoint: element.Point1 = (CGPoint)Marshal.PtrToStructure(ptr, typeof(CGPoint)); element.Point2 = (CGPoint)Marshal.PtrToStructure(((IntPtr)(((long)ptr) + ptsize)), typeof(CGPoint)); element.Point3 = (CGPoint)Marshal.PtrToStructure(((IntPtr)(((long)ptr) + (2 * ptsize))), typeof(CGPoint)); break; } func(element); }
public void Apply(ApplierFunction func) { GCHandle gch = GCHandle.Alloc(func); CGPathApply(handle, GCHandle.ToIntPtr(gch), ApplierCallback); gch.Free(); }
extern static void CGPDFDictionaryApplyFunction (/* CGPDFDictionaryRef */ IntPtr dic, ApplierFunction function, /* void* */ IntPtr info);
public void Apply (ApplierFunction func) { GCHandle gch = GCHandle.Alloc (func); CGPathApply (handle, GCHandle.ToIntPtr (gch), ApplierCallback); gch.Free (); }
extern static void CGPDFDictionaryApplyFunction (IntPtr dictRef, ApplierFunction function, IntPtr info);
extern static void CGPDFDictionaryApplyFunction(/* CGPDFDictionaryRef */ IntPtr dic, ApplierFunction function, /* void* */ IntPtr info);
extern static void CGPDFDictionaryApplyFunction(IntPtr dictRef, ApplierFunction function, IntPtr info);