public void InsertControl(Control control)
 {
     if (control != null)
     {
         CCWin.SkinControl.ILockBytes bytes;
         CCWin.SkinControl.IStorage storage;
         CCWin.SkinControl.IOleClientSite site;
         Guid guid = Marshal.GenerateGuidForType(control.GetType());
         CCWin.Win32.NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out bytes);
         CCWin.Win32.NativeMethods.StgCreateDocfileOnILockBytes(bytes, 0x1012, 0, out storage);
         this.IRichEditOle.GetClientSite(out site);
         REOBJECT lpreobject = new REOBJECT();
         lpreobject.cp = this._richEdit.TextLength;
         lpreobject.clsid = guid;
         lpreobject.pstg = storage;
         lpreobject.poleobj = Marshal.GetIUnknownForObject(control);
         lpreobject.polesite = site;
         lpreobject.dvAspect = 1;
         lpreobject.dwFlags = 2;
         lpreobject.dwUser = 1;
         this.IRichEditOle.InsertObject(lpreobject);
         Marshal.ReleaseComObject(bytes);
         Marshal.ReleaseComObject(site);
         Marshal.ReleaseComObject(storage);
     }
 }
Exemplo n.º 2
0
        public REOBJECT InsertOleObject(IOleObject oleObject, int index, int pos)
        {
            ILockBytes     bytes;
            IStorage       storage;
            IOleClientSite site;

            if (oleObject == null)
            {
                return(null);
            }
            NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out bytes);
            NativeMethods.StgCreateDocfileOnILockBytes(bytes, 0x1012, 0, out storage);
            this.IRichEditOle.GetClientSite(out site);
            Guid pClsid = new Guid();

            oleObject.GetUserClassID(ref pClsid);
            NativeMethods.OleSetContainedObject(oleObject, true);
            REOBJECT lpreobject = new REOBJECT {
                posistion = pos,
                clsid     = pClsid,
                pstg      = storage,
                poleobj   = Marshal.GetIUnknownForObject(oleObject),
                polesite  = site,
                dvAspect  = 1,
                dwFlags   = 2,
                dwUser    = (uint)index
            };

            this.IRichEditOle.InsertObject(lpreobject);
            Marshal.ReleaseComObject(bytes);
            Marshal.ReleaseComObject(site);
            Marshal.ReleaseComObject(storage);
            return(lpreobject);
        }
Exemplo n.º 3
0
 public void InsertControl(Control control)
 {
     if (control != null)
     {
         ILockBytes     bytes;
         IStorage       storage;
         IOleClientSite site;
         Guid           guid = Marshal.GenerateGuidForType(control.GetType());
         NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out bytes);
         NativeMethods.StgCreateDocfileOnILockBytes(bytes, 0x1012, 0, out storage);
         IRichEditOle.GetClientSite(out site);
         REOBJECT lpreobject = new REOBJECT();
         lpreobject.cp       = _richEdit.TextLength;
         lpreobject.clsid    = guid;
         lpreobject.pstg     = storage;
         lpreobject.poleobj  = Marshal.GetIUnknownForObject(control);
         lpreobject.polesite = site;
         lpreobject.dvAspect = 1;
         lpreobject.dwFlags  = 2;
         lpreobject.dwUser   = 1;
         IRichEditOle.InsertObject(lpreobject);
         Marshal.ReleaseComObject(bytes);
         Marshal.ReleaseComObject(site);
         Marshal.ReleaseComObject(storage);
     }
 }
Exemplo n.º 4
0
 public void InsertControl(Control control, int position, uint dwUser)
 {
     if (control != null)
     {
         ILockBytes     bytes;
         IStorage       storage;
         IOleClientSite site;
         Guid           guid = Marshal.GenerateGuidForType(control.GetType());
         NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out bytes);
         NativeMethods.StgCreateDocfileOnILockBytes(bytes, 0x1012, 0, out storage);
         this.IRichEditOle.GetClientSite(out site);
         REOBJECT lpreobject = new REOBJECT {
             posistion = position,
             clsid     = guid,
             pstg      = storage,
             poleobj   = Marshal.GetIUnknownForObject(control),
             polesite  = site,
             dvAspect  = 1,
             dwFlags   = 0x00000002,
             dwUser    = dwUser
         };
         this.IRichEditOle.InsertObject(lpreobject);
         Marshal.ReleaseComObject(bytes);
         Marshal.ReleaseComObject(site);
         Marshal.ReleaseComObject(storage);
     }
 }
Exemplo n.º 5
0
        public void UpdateObjects(int pos)
        {
            REOBJECT lpreobject = new REOBJECT();

            this.IRichEditOle.GetObject(pos, lpreobject, GETOBJECTOPTIONS.REO_GETOBJ_ALL_INTERFACES);
            this.UpdateObjects(lpreobject);
        }
Exemplo n.º 6
0
        public void UpdateObjects(REOBJECT reObj)
        {
            Point     positionFromCharIndex = this.agileRichTextBox.GetPositionFromCharIndex(reObj.posistion);
            Size      sizeFromMillimeter    = this.GetSizeFromMillimeter(reObj);
            Rectangle rc = new Rectangle(positionFromCharIndex, sizeFromMillimeter);

            this.agileRichTextBox.Invalidate(rc, false);
        }
Exemplo n.º 7
0
        public void UpdateObjects(REOBJECT reObj)
        {
            Point positionFromCharIndex = _richEdit.GetPositionFromCharIndex(
                reObj.cp);
            Size      size = GetSizeFromMillimeter(reObj);
            Rectangle rc   = new Rectangle(positionFromCharIndex, size);

            _richEdit.Invalidate(rc, false);
        }
Exemplo n.º 8
0
 private Size GetSizeFromMillimeter(REOBJECT lpreobject)
 {
     using (Graphics graphics = Graphics.FromHwnd(this.agileRichTextBox.Handle))
     {
         Point[] pts = new Point[1];
         graphics.PageUnit = GraphicsUnit.Millimeter;
         pts[0]            = new Point(lpreobject.sizel.Width / 100, lpreobject.sizel.Height / 100);
         graphics.TransformPoints(CoordinateSpace.Device, CoordinateSpace.Page, pts);
         return(new Size(pts[0]));
     }
 }
Exemplo n.º 9
0
        public void UpdateObjects()
        {
            int objectCount = this.IRichEditOle.GetObjectCount();

            for (int i = 0; i < objectCount; i++)
            {
                REOBJECT lpreobject = new REOBJECT();
                this.IRichEditOle.GetObject(i, lpreobject, GETOBJECTOPTIONS.REO_GETOBJ_ALL_INTERFACES);
                Point     positionFromCharIndex = this.agileRichTextBox.GetPositionFromCharIndex(lpreobject.posistion);
                Rectangle rc = new Rectangle(positionFromCharIndex.X, positionFromCharIndex.Y, 50, 50);
                this.agileRichTextBox.Invalidate(rc, false);
            }
        }
Exemplo n.º 10
0
        public List <REOBJECT> GetAllREOBJECT()
        {
            List <REOBJECT> list        = new List <REOBJECT>();
            int             objectCount = this.IRichEditOle.GetObjectCount();

            for (int i = 0; i < objectCount; i++)
            {
                REOBJECT lpreobject = new REOBJECT();
                this.IRichEditOle.GetObject(i, lpreobject, GETOBJECTOPTIONS.REO_GETOBJ_ALL_INTERFACES);
                list.Add(lpreobject);
            }
            return(list);
        }
Exemplo n.º 11
0
        public bool InsertImageFromFile(string strFilename, int position)
        {
            ILockBytes     bytes;
            IStorage       storage;
            IOleClientSite site;
            object         obj2;

            NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out bytes);
            NativeMethods.StgCreateDocfileOnILockBytes(bytes, 0x1012, 0, out storage);
            this.IRichEditOle.GetClientSite(out site);
            FORMATETC pFormatEtc = new FORMATETC {
                cfFormat = (CLIPFORMAT)0,
                ptd      = IntPtr.Zero,
                dwAspect = DVASPECT.DVASPECT_CONTENT,
                lindex   = -1,
                tymed    = TYMED.TYMED_NULL
            };
            Guid riid   = new Guid("{00000112-0000-0000-C000-000000000046}");
            Guid rclsid = new Guid("{00000000-0000-0000-0000-000000000000}");

            NativeMethods.OleCreateFromFile(ref rclsid, strFilename, ref riid, 1, ref pFormatEtc, site, storage, out obj2);
            if (obj2 == null)
            {
                Marshal.ReleaseComObject(bytes);
                Marshal.ReleaseComObject(site);
                Marshal.ReleaseComObject(storage);
                return(false);
            }
            IOleObject pUnk   = (IOleObject)obj2;
            Guid       pClsid = new Guid();

            pUnk.GetUserClassID(ref pClsid);
            NativeMethods.OleSetContainedObject(pUnk, true);
            REOBJECT lpreobject = new REOBJECT {
                posistion = position,
                clsid     = pClsid,
                pstg      = storage,
                poleobj   = Marshal.GetIUnknownForObject(pUnk),
                polesite  = site,
                dvAspect  = 1,
                dwFlags   = 2,
                dwUser    = 0
            };

            this.IRichEditOle.InsertObject(lpreobject);
            Marshal.ReleaseComObject(bytes);
            Marshal.ReleaseComObject(site);
            Marshal.ReleaseComObject(storage);
            Marshal.ReleaseComObject(pUnk);
            return(true);
        }
Exemplo n.º 12
0
        public REOBJECT InsertOleObject(
            IOleObject oleObject,
            int index)
        {
            if (oleObject == null)
            {
                return(null);
            }

            ILockBytes pLockBytes;

            NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out pLockBytes);

            IStorage pStorage;

            NativeMethods.StgCreateDocfileOnILockBytes(
                pLockBytes,
                (uint)(STGM.STGM_SHARE_EXCLUSIVE | STGM.STGM_CREATE | STGM.STGM_READWRITE),
                0,
                out pStorage);

            IOleClientSite pOleClientSite;

            IRichEditOle.GetClientSite(out pOleClientSite);

            Guid guid = new Guid();

            oleObject.GetUserClassID(ref guid);
            NativeMethods.OleSetContainedObject(oleObject, true);

            REOBJECT reoObject = new REOBJECT();

            reoObject.cp       = _richEdit.TextLength;
            reoObject.clsid    = guid;
            reoObject.pstg     = pStorage;
            reoObject.poleobj  = Marshal.GetIUnknownForObject(oleObject);
            reoObject.polesite = pOleClientSite;
            reoObject.dvAspect = (uint)DVASPECT.DVASPECT_CONTENT;
            reoObject.dwFlags  = (uint)REOOBJECTFLAGS.REO_BELOWBASELINE;
            reoObject.dwUser   = (uint)index;

            IRichEditOle.InsertObject(reoObject);

            Marshal.ReleaseComObject(pLockBytes);
            Marshal.ReleaseComObject(pOleClientSite);
            Marshal.ReleaseComObject(pStorage);

            return(reoObject);
        }
Exemplo n.º 13
0
 private System.Drawing.Size GetSizeFromMillimeter(REOBJECT lpreobject)
 {
     using (Graphics graphics = Graphics.FromHwnd(this._richEdit.Handle))
     {
         System.Drawing.Point[] pts = new System.Drawing.Point[1];
         graphics.PageUnit = GraphicsUnit.Millimeter;
         pts[0] = new System.Drawing.Point(lpreobject.sizel.Width / 100, lpreobject.sizel.Height / 100);
         graphics.TransformPoints(CoordinateSpace.Device, CoordinateSpace.Page, pts);
         return new System.Drawing.Size(pts[0]);
     }
 }
Exemplo n.º 14
0
 public void UpdateObjects(int pos)
 {
     REOBJECT lpreobject = new REOBJECT();
     this.IRichEditOle.GetObject(pos, lpreobject, GETOBJECTOPTIONS.REO_GETOBJ_ALL_INTERFACES);
     this.UpdateObjects(lpreobject);
 }
Exemplo n.º 15
0
 public void UpdateObjects(REOBJECT reObj)
 {
     System.Drawing.Point positionFromCharIndex = this._richEdit.GetPositionFromCharIndex(reObj.cp);
     System.Drawing.Size size = this.GetSizeFromMillimeter(reObj);
     Rectangle rc = new Rectangle(positionFromCharIndex, size);
     this._richEdit.Invalidate(rc, false);
 }
Exemplo n.º 16
0
 public void UpdateObjects()
 {
     int objectCount = this.IRichEditOle.GetObjectCount();
     for (int i = 0; i < objectCount; i++)
     {
         REOBJECT lpreobject = new REOBJECT();
         this.IRichEditOle.GetObject(i, lpreobject, GETOBJECTOPTIONS.REO_GETOBJ_ALL_INTERFACES);
         System.Drawing.Point positionFromCharIndex = this._richEdit.GetPositionFromCharIndex(lpreobject.cp);
         Rectangle rc = new Rectangle(positionFromCharIndex.X, positionFromCharIndex.Y, 50, 50);
         this._richEdit.Invalidate(rc, false);
     }
 }
Exemplo n.º 17
0
 public REOBJECT InsertOleObject(CCWin.SkinControl.IOleObject oleObject, int index)
 {
     CCWin.SkinControl.ILockBytes pLockBytes;
     CCWin.SkinControl.IStorage pStorage;
     CCWin.SkinControl.IOleClientSite pOleClientSite;
     if (oleObject == null)
     {
         return null;
     }
     CCWin.Win32.NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out pLockBytes);
     CCWin.Win32.NativeMethods.StgCreateDocfileOnILockBytes(pLockBytes, 0x1012, 0, out pStorage);
     this.IRichEditOle.GetClientSite(out pOleClientSite);
     Guid guid = new Guid();
     oleObject.GetUserClassID(ref guid);
     CCWin.Win32.NativeMethods.OleSetContainedObject(oleObject, true);
     REOBJECT reoObject = new REOBJECT();
     reoObject.cp = this._richEdit.TextLength;
     reoObject.clsid = guid;
     reoObject.pstg = pStorage;
     reoObject.poleobj = Marshal.GetIUnknownForObject(oleObject);
     reoObject.polesite = pOleClientSite;
     reoObject.dvAspect = 1;
     reoObject.dwFlags = 2;
     reoObject.dwUser = (uint) index;
     this.IRichEditOle.InsertObject(reoObject);
     Marshal.ReleaseComObject(pLockBytes);
     Marshal.ReleaseComObject(pOleClientSite);
     Marshal.ReleaseComObject(pStorage);
     return reoObject;
 }
Exemplo n.º 18
0
 public void UpdateObjects(REOBJECT reObj)
 {
     Point positionFromCharIndex = _richEdit.GetPositionFromCharIndex(
             reObj.cp);
     Size size = GetSizeFromMillimeter(reObj);
     Rectangle rc = new Rectangle(positionFromCharIndex, size);
     _richEdit.Invalidate(rc, false);
 }
Exemplo n.º 19
0
 public bool InsertImageFromFile(string strFilename)
 {
     CCWin.SkinControl.ILockBytes bytes;
     CCWin.SkinControl.IStorage storage;
     CCWin.SkinControl.IOleClientSite site;
     object obj2;
     CCWin.Win32.NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out bytes);
     CCWin.Win32.NativeMethods.StgCreateDocfileOnILockBytes(bytes, 0x1012, 0, out storage);
     this.IRichEditOle.GetClientSite(out site);
     FORMATETC pFormatEtc = new FORMATETC();
     pFormatEtc.cfFormat = (CLIPFORMAT) 0;
     pFormatEtc.ptd = IntPtr.Zero;
     pFormatEtc.dwAspect = DVASPECT.DVASPECT_CONTENT;
     pFormatEtc.lindex = -1;
     pFormatEtc.tymed = TYMED.TYMED_NULL;
     Guid riid = new Guid("{00000112-0000-0000-C000-000000000046}");
     Guid rclsid = new Guid("{00000000-0000-0000-0000-000000000000}");
     CCWin.Win32.NativeMethods.OleCreateFromFile(ref rclsid, strFilename, ref riid, 1, ref pFormatEtc, site, storage, out obj2);
     if (obj2 == null)
     {
         Marshal.ReleaseComObject(bytes);
         Marshal.ReleaseComObject(site);
         Marshal.ReleaseComObject(storage);
         return false;
     }
     CCWin.SkinControl.IOleObject pUnk = (CCWin.SkinControl.IOleObject) obj2;
     Guid pClsid = new Guid();
     pUnk.GetUserClassID(ref pClsid);
     CCWin.Win32.NativeMethods.OleSetContainedObject(pUnk, true);
     REOBJECT lpreobject = new REOBJECT();
     lpreobject.cp = this._richEdit.TextLength;
     lpreobject.clsid = pClsid;
     lpreobject.pstg = storage;
     lpreobject.poleobj = Marshal.GetIUnknownForObject(pUnk);
     lpreobject.polesite = site;
     lpreobject.dvAspect = 1;
     lpreobject.dwFlags = 2;
     lpreobject.dwUser = 0;
     this.IRichEditOle.InsertObject(lpreobject);
     Marshal.ReleaseComObject(bytes);
     Marshal.ReleaseComObject(site);
     Marshal.ReleaseComObject(storage);
     Marshal.ReleaseComObject(pUnk);
     return true;
 }
Exemplo n.º 20
0
        public REOBJECT InsertOleObject(
            IOleObject oleObject,
            int index)
        {
            if (oleObject == null)
            {
                return null;
            }

            ILockBytes pLockBytes;
            NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out pLockBytes);

            IStorage pStorage;
            NativeMethods.StgCreateDocfileOnILockBytes(
                pLockBytes,
                (uint)(STGM.STGM_SHARE_EXCLUSIVE | STGM.STGM_CREATE | STGM.STGM_READWRITE),
                0,
                out pStorage);

            IOleClientSite pOleClientSite;
            IRichEditOle.GetClientSite(out pOleClientSite);

            Guid guid = new Guid();

            oleObject.GetUserClassID(ref guid);
            NativeMethods.OleSetContainedObject(oleObject, true);

            REOBJECT reoObject = new REOBJECT();

            reoObject.cp = _richEdit.TextLength;
            reoObject.clsid = guid;
            reoObject.pstg = pStorage;
            reoObject.poleobj = Marshal.GetIUnknownForObject(oleObject);
            reoObject.polesite = pOleClientSite;
            reoObject.dvAspect = (uint)DVASPECT.DVASPECT_CONTENT;
            reoObject.dwFlags = (uint)REOOBJECTFLAGS.REO_BELOWBASELINE;
            reoObject.dwUser = (uint)index;

            IRichEditOle.InsertObject(reoObject);

            Marshal.ReleaseComObject(pLockBytes);
            Marshal.ReleaseComObject(pOleClientSite);
            Marshal.ReleaseComObject(pStorage);

            return reoObject;
        }