예제 #1
0
        public void UpdateObjects(int pos)
        {
            REOBJECT lpreobject = new REOBJECT();

            this.IRichEditOle.GetObject(pos, lpreobject, GETOBJECTOPTIONS.REO_GETOBJ_ALL_INTERFACES);
            this.UpdateObjects(lpreobject);
        }
예제 #2
0
 public void InsertControl(Control control, int position, uint dwUser)
 {
     if (control != null)
     {
         global::CJBasic.Widget.Internals.ILockBytes     bytes;
         global::CJBasic.Widget.Internals.IStorage       storage;
         global::CJBasic.Widget.Internals.IOleClientSite site;
         Guid guid = Marshal.GenerateGuidForType(control.GetType());
         global::CJBasic.Widget.Internals.NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out bytes);
         global::CJBasic.Widget.Internals.NativeMethods.StgCreateDocfileOnILockBytes(bytes, 0x1012, 0, out storage);
         this.IRichEditOle.GetClientSite(out site);
         REOBJECT lpreobject = new REOBJECT();
         lpreobject.posistion = position;
         lpreobject.clsid     = guid;
         lpreobject.pstg      = storage;
         lpreobject.poleobj   = Marshal.GetIUnknownForObject(control);
         lpreobject.polesite  = site;
         lpreobject.dvAspect  = 1;
         lpreobject.dwFlags   = 2;
         lpreobject.dwUser    = dwUser;
         this.IRichEditOle.InsertObject(lpreobject);
         Marshal.ReleaseComObject(bytes);
         Marshal.ReleaseComObject(site);
         Marshal.ReleaseComObject(storage);
     }
 }
예제 #3
0
        public REOBJECT InsertOleObject(global::CJBasic.Widget.Internals.IOleObject oleObject, int index, int pos)
        {
            global::CJBasic.Widget.Internals.ILockBytes     bytes;
            global::CJBasic.Widget.Internals.IStorage       storage;
            global::CJBasic.Widget.Internals.IOleClientSite site;
            if (oleObject == null)
            {
                return(null);
            }
            global::CJBasic.Widget.Internals.NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out bytes);
            global::CJBasic.Widget.Internals.NativeMethods.StgCreateDocfileOnILockBytes(bytes, 0x1012, 0, out storage);
            this.IRichEditOle.GetClientSite(out site);
            Guid pClsid = new Guid();

            oleObject.GetUserClassID(ref pClsid);
            global::CJBasic.Widget.Internals.NativeMethods.OleSetContainedObject(oleObject, true);
            REOBJECT lpreobject = new REOBJECT();

            lpreobject.posistion = pos;
            lpreobject.clsid     = pClsid;
            lpreobject.pstg      = storage;
            lpreobject.poleobj   = Marshal.GetIUnknownForObject(oleObject);
            lpreobject.polesite  = site;
            lpreobject.dvAspect  = 1;
            lpreobject.dwFlags   = 2;
            lpreobject.dwUser    = (uint)index;
            this.IRichEditOle.InsertObject(lpreobject);
            Marshal.ReleaseComObject(bytes);
            Marshal.ReleaseComObject(site);
            Marshal.ReleaseComObject(storage);
            return(lpreobject);
        }
예제 #4
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);
        }
예제 #5
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]));
     }
 }
예제 #6
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);
        }
예제 #7
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);
            }
        }
예제 #8
0
        public bool InsertImageFromFile(string strFilename, int position)
        {
            global::CJBasic.Widget.Internals.ILockBytes     bytes;
            global::CJBasic.Widget.Internals.IStorage       storage;
            global::CJBasic.Widget.Internals.IOleClientSite site;
            object obj2;

            global::CJBasic.Widget.Internals.NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out bytes);
            global::CJBasic.Widget.Internals.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}");

            global::CJBasic.Widget.Internals.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);
            }
            global::CJBasic.Widget.Internals.IOleObject pUnk = (global::CJBasic.Widget.Internals.IOleObject)obj2;
            Guid pClsid = new Guid();

            pUnk.GetUserClassID(ref pClsid);
            global::CJBasic.Widget.Internals.NativeMethods.OleSetContainedObject(pUnk, true);
            REOBJECT lpreobject = new REOBJECT();

            lpreobject.posistion = position;
            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);
        }