Exemplo n.º 1
0
 public static DxfOle.Type OleItemType(DxfOle ole)
 {
     try
     {
         object o = OleHelper.smethod_0(ole);
         if (o == null)
         {
             return(DxfOle.Type.Unknown);
         }
         IntPtr iunknownForObject = Marshal.GetIUnknownForObject(o);
         if (iunknownForObject != IntPtr.Zero)
         {
             Guid   iid = new Guid("0000011d-0000-0000-C000-000000000046");
             IntPtr ppv;
             Marshal.QueryInterface(iunknownForObject, ref iid, out ppv);
             if (ppv != IntPtr.Zero)
             {
                 Marshal.Release(ppv);
                 Marshal.Release(iunknownForObject);
                 return(DxfOle.Type.Link);
             }
             OleHelper.Interface20 objectForIunknown = Marshal.GetObjectForIUnknown(iunknownForObject) as OleHelper.Interface20;
             Marshal.Release(iunknownForObject);
             uint dwStatus = 0;
             return(objectForIunknown.imethod_19(1U, ref dwStatus) == 0 && ((int)dwStatus & 8) == 0 ? DxfOle.Type.Embedded : DxfOle.Type.Static);
         }
     }
     catch (Exception ex)
     {
     }
     return(DxfOle.Type.Unknown);
 }
Exemplo n.º 2
0
        public static Bitmap Preview(DxfOle ole, int width, int height)
        {
            object obj = OleHelper.smethod_0(ole);

            if (obj == null || width <= 0 || height <= 0)
            {
                return((Bitmap)null);
            }
            Rectangle lprcBounds = new Rectangle(0, 0, width, height);
            Bitmap    bitmap     = new Bitmap(width, height);
            int       num;

            using (Graphics graphics = Graphics.FromImage((Image)bitmap))
            {
                IntPtr hdc = graphics.GetHdc();
                try
                {
                    num = OleHelper.OleDraw(obj, (uint)ole.DrawAspect, hdc, ref lprcBounds);
                }
                finally
                {
                    Marshal.FinalReleaseComObject(obj);
                    graphics.ReleaseHdc(hdc);
                }
            }
            if (num == 0)
            {
                return(bitmap);
            }
            bitmap.Dispose();
            return((Bitmap)null);
        }
Exemplo n.º 3
0
        public static string OleUserType(DxfOle ole)
        {
            object o = OleHelper.smethod_0(ole);

            if (o != null)
            {
                IntPtr iunknownForObject = Marshal.GetIUnknownForObject(o);
                if (iunknownForObject != IntPtr.Zero)
                {
                    OleHelper.Interface20 objectForIunknown = Marshal.GetObjectForIUnknown(iunknownForObject) as OleHelper.Interface20;
                    Marshal.Release(iunknownForObject);
                    if (objectForIunknown == null)
                    {
                        return((string)null);
                    }
                    string str = (string)null;
                    try
                    {
                        str = objectForIunknown.imethod_13(1U);
                    }
                    catch (COMException ex)
                    {
                    }
                    return(str);
                }
            }
            return((string)null);
        }
Exemplo n.º 4
0
        public static void FinishCreate(DxfOle ole)
        {
            object pUnk = OleHelper.smethod_0(ole);

            if (pUnk == null)
            {
                return;
            }
            OleHelper.OleSetContainedObject(pUnk, true);
        }
Exemplo n.º 5
0
        public static string OleLinkPath(DxfOle ole)
        {
            object o = OleHelper.smethod_0(ole);

            if (o != null)
            {
                IntPtr iunknownForObject = Marshal.GetIUnknownForObject(o);
                if (iunknownForObject != IntPtr.Zero)
                {
                    OleHelper.Interface21 objectForIunknown = Marshal.GetObjectForIUnknown(iunknownForObject) as OleHelper.Interface21;
                    Marshal.Release(iunknownForObject);
                    return(objectForIunknown?.imethod_5());
                }
            }
            return((string)null);
        }
Exemplo n.º 6
0
        public static void OleHiMetrics(DxfOle ole, out int width, out int height)
        {
            width  = 1000;
            height = 1000;
            object o = OleHelper.smethod_0(ole);

            if (o == null)
            {
                return;
            }
            IntPtr iunknownForObject = Marshal.GetIUnknownForObject(o);

            if (!(iunknownForObject != IntPtr.Zero))
            {
                return;
            }
            OleHelper.Interface20 objectForIunknown = Marshal.GetObjectForIUnknown(iunknownForObject) as OleHelper.Interface20;
            Marshal.Release(iunknownForObject);
            if (objectForIunknown == null)
            {
                return;
            }
            if (ole.OleObjectType == DxfOle.Type.Link && objectForIunknown.imethod_11() == 0U)
            {
                objectForIunknown.imethod_10();
            }
            if (ole.OleObjectType == DxfOle.Type.Static)
            {
                return;
            }
            Size psizel = new Size();

            objectForIunknown.imethod_15((uint)ole.DrawAspect, ref psizel);
            width  = psizel.Width;
            height = psizel.Height;
        }