예제 #1
0
파일: CGPath.cs 프로젝트: jorik041/maccore
        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);
        }
예제 #2
0
파일: CGPath.cs 프로젝트: kangaroo/maccore
		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);
		}