예제 #1
0
        public bool InsertLiteStream(Stream stream)
        {
            bool vResult = false;

            DataLoadLiteStream(stream, delegate(ushort fileVersion, HCStyle style)
            {
                this.BeginUpdate();
                try
                {
                    vResult = FData.InsertStream(stream, style, fileVersion);
                }
                finally
                {
                    this.EndUpdate();
                }
            });

            return(vResult);
        }
예제 #2
0
        protected void Paste()
        {
            IDataObject vIData = Clipboard.GetDataObject();

            if (vIData.GetDataPresent(HC.HC_EXT))
            {
                MemoryStream vStream = (MemoryStream)vIData.GetData(HC.HC_EXT);
                try
                {
                    string vFileFormat  = "";
                    ushort vFileVersion = 0;
                    byte   vLan         = 0;

                    vStream.Position = 0;
                    HC._LoadFileFormatAndVersion(vStream, ref vFileFormat, ref vFileVersion, ref vLan);  // 文件格式和版本
                    HCStyle vStyle = new HCStyle();
                    try
                    {
                        vStyle.LoadFromStream(vStream, vFileVersion);
                        this.BeginUpdate();
                        try
                        {
                            FData.InsertStream(vStream, vStyle, vFileVersion);
                        }
                        finally
                        {
                            this.EndUpdate();
                        }
                    }
                    finally
                    {
                        vStyle.Dispose();
                    }
                }
                finally
                {
                    vStream.Close();
                    vStream.Dispose();
                }
            }
            else
            if (vIData.GetDataPresent(DataFormats.Text))
            {
                FData.InsertText(Clipboard.GetText());
            }
            else
            if (vIData.GetDataPresent(DataFormats.Bitmap))
            {
                Image vImage = (Image)vIData.GetData(typeof(Bitmap));

                HCRichData  vTopData   = FData.GetTopLevelData() as HCRichData;
                HCImageItem vImageItem = new HCImageItem(vTopData);

                vImageItem.Image = new Bitmap(vImage);

                vImageItem.Width  = vImageItem.Image.Width;
                vImageItem.Height = vImageItem.Image.Height;


                vImageItem.RestrainSize(vTopData.Width, vImageItem.Height);

                FData.InsertItem(vImageItem);
            }
        }