Пример #1
0
        /// <summary>
        /// Inserts image at the given position
        /// </summary>
        /// <param name="image"></param>
        /// <param name="position"></param>
        public void InsertImage(Image image, int position)
        {
            ImageDataObject ido = new ImageDataObject();

            ido.SetImage(image);
            InsertImageDataObject(ido, position);
        }
Пример #2
0
        /// <summary>
        /// Inserts given image at the cursor position
        /// </summary>
        /// <param name="image"></param>
        public void InsertImage(Image image)
        {
            ImageDataObject ido = new ImageDataObject();

            ido.SetImage(image);
            InsertImageDataObject(ido);
        }
Пример #3
0
 void tsmiCopy_Click(object sender, EventArgs e)
 {
     if (this.Bitmap != null)
     {
         var dataObj = new ImageDataObject(this.Bitmap, this.ImageFileName);
         Clipboard.SetDataObject(dataObj, false);
     }
 }
Пример #4
0
 void OwnerControl_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && OwnerControl.Image != null &&
         this.dragBox != Rectangle.Empty && !this.dragBox.Contains(e.Location))
     {
         string          fileName = Convert.ToString(OwnerControl.Tag);
         ImageDataObject dataObj  = new ImageDataObject(OwnerControl.Image, fileName);
         var             dragEff  = this.OwnerControl.DoDragDrop(dataObj, DragDropEffects.Copy);
     }
 }
Пример #5
0
            public void InsertImageDataObject(ImageDataObject ido, int position)
            {
                if (ido == null)
                {
                    return;
                }

                ILockBytes pLockBytes;
                int        sc = CreateILockBytesOnHGlobal(IntPtr.Zero, true, out pLockBytes);

                IStorage pStorage;

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

                IOleClientSite pOleClientSite;

                IRichEditOle.GetClientSite(out pOleClientSite);

                Guid guid = Marshal.GenerateGuidForType(ido.GetType());

                Guid IID_IOleObject  = new Guid("{00000112-0000-0000-C000-000000000046}");
                Guid IID_IDataObject = new Guid("{0000010e-0000-0000-C000-000000000046}");
                Guid IID_IUnknown    = new Guid("{00000000-0000-0000-C000-000000000046}");

                object pOleObject;

                int hr = OleCreateStaticFromData(ido, ref IID_IOleObject, (uint)OLERENDER.OLERENDER_FORMAT,
                                                 ref ido._Formatetc, pOleClientSite, pStorage, out pOleObject);

                if (pOleObject == null)
                {
                    return;
                }
                OleSetContainedObject(pOleObject, true);

                REOBJECT reoObject = new REOBJECT();

                reoObject.cp = position;

                reoObject.clsid    = guid;
                reoObject.pstg     = pStorage;
                reoObject.poleobj  = Marshal.GetIUnknownForObject(pOleObject);
                reoObject.polesite = pOleClientSite;
                reoObject.dvAspect = (uint)(DVASPECT.DVASPECT_CONTENT);
                reoObject.dwFlags  = (uint)(REOOBJECTFLAGS.REO_BELOWBASELINE);
                reoObject.dwUser   = 0;

                this.IRichEditOle.InsertObject(reoObject);

                Marshal.ReleaseComObject(pLockBytes);
                Marshal.ReleaseComObject(pOleClientSite);
                Marshal.ReleaseComObject(pStorage);
                Marshal.ReleaseComObject(pOleObject);
            }
Пример #6
0
        protected override void OnItemDragSave(AnimationItemEventArgs e)
        {
            var fileName = Path.GetTempFileName();

            if ((e.Item as FrameAnimator)?.Data.Frames.Count == 1)
            {
                using (var bmp = (e.Item as FrameAnimator).Data.Frames[0].Png.ExtractPng())
                {
                    bmp.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
                }
            }
            else
            {
                this.SaveAsGif(e.Item, fileName, ImageHandlerConfig.Default);
            }

            var imgObj = new ImageDataObject(null, fileName);

            this.DoDragDrop(imgObj, System.Windows.Forms.DragDropEffects.Copy);
            e.Handled = true;
        }
Пример #7
0
 public void InsertImageDataObject(ImageDataObject ido)
 {
     InsertImageDataObject(ido, rtf.SelectionStart);
 }
Пример #8
0
        /// <summary>
        /// Inserts image data object at the given position
        /// </summary>
        /// <param name="ido"></param>
        /// <param name="position"></param>
        public void InsertImageDataObject(ImageDataObject ido, int position)
        {
            RichEditOle ole = new RichEditOle(this);

            ole.InsertImageDataObject(ido, position);
        }
Пример #9
0
        /// <summary>
        /// Inserts image data object at the current cursor position
        /// </summary>
        /// <param name="ido"></param>
        public void InsertImageDataObject(ImageDataObject ido)
        {
            RichEditOle ole = new RichEditOle(this);

            ole.InsertImageDataObject(ido);
        }