コード例 #1
0
ファイル: Form1.cs プロジェクト: benncarroll/text-editor-2016
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            // Make file dialog and set it's settings
            FileDialog openFile1 = new OpenFileDialog();

            openFile1.CheckFileExists  = true;
            openFile1.CheckPathExists  = true;
            openFile1.RestoreDirectory = true;
            openFile1.Title            = "Choose file to import";

            // If the user returned OK, convert the image to Bitmap and set it to clipboard
            if (openFile1.ShowDialog() == DialogResult.OK)
            {
                string originalFile = openFile1.FileName;
                Bitmap myBitmap     = new Bitmap(originalFile);
                Clipboard.SetDataObject(myBitmap);
                DataFormats.Format format = DataFormats.GetFormat(DataFormats.Bitmap);

                // Check if bitmaps can be pasted and then paste it
                if (this.richTextBox1.CanPaste(format))
                {
                    richTextBox1.Paste(format);
                }
            }
        }
コード例 #2
0
 public void DataFormats_GetFormat_InvokeId_ReturnsExpected(int id, string expectedName)
 {
     DataFormats.Format result = DataFormats.GetFormat(id);
     Assert.Same(result, DataFormats.GetFormat(id));
     Assert.Equal(expectedName, result.Name);
     Assert.Equal(id & 0xFFFF, result.Id);
 }
コード例 #3
0
        public void Copy()
        {
            if (this.Initialized)
            {
                if (EditorEngine.Instance.StateMachine.State == EntityEditorState.Instance)
                {
                    //DataObject obj = new DataObject("aeon_entities", null);
                    DataFormats.Format f   = DataFormats.GetFormat("aeon_entities");
                    IDataObject        obj = new DataObject();

                    MemoryStream stream = new MemoryStream();
                    BinaryOutput bin    = new BinaryOutput(stream);

                    bin.Write(EntitySelectionTool.Instance.SelectedEntities.Count);
                    //write Template index and positions, no actual Entities :>
                    EntitySelectionTool.Instance.SelectedEntities.ForEach(e => {
                        bin.Write(e.TemplateID);
                        bin.Write(e.Position.X);
                        bin.Write(e.Position.Y);
                    });

                    obj.SetData(f.Name, false, stream);
                    Clipboard.SetDataObject(obj);
                }
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: Adamsmith6300/WaveEditor
        /// <summary>Cuts out a section from the raw samples array.</summary>
        /// <param name="posXStart">The position in the rawSamples array to start the cut.</param>
        /// <param name="posXFinish">The position in the rawSamples array to end the cut.</param>
        private void cutRawSamples(int posXStart, int posXFinish)
        {
            //cut & save raw samples
            int length = (int)Math.Abs(posXFinish - posXStart);

            cutSamples = new double[length];
            Array.Copy(rawSamples, posXStart, cutSamples, 0, length);
            //make new arr for raw samples minus the cut
            double[] newRawSamples = new double[rawSamples.Length - length];
            //copy left side of cut into new arr
            Array.Copy(rawSamples, 0, newRawSamples, 0, posXStart);
            //copy right side of cut int arr
            Array.Copy(rawSamples, posXFinish, newRawSamples, posXStart, (rawSamples.Length - (posXStart + length)));
            //reinitialize rawsamples
            rawSamples = new double[newRawSamples.Length];
            //copy new raw samples into old raw samples variable
            Array.Copy(newRawSamples, 0, rawSamples, 0, newRawSamples.Length);
            dataSize = rawSamples.Length / numChannels;
            DataFormats.Format myFormat = DataFormats.GetFormat("cutData");
            ClipboardData      cd       = new ClipboardData();

            cd.Sr = this.sampleRate;
            cd.Cs = cutSamples;
            DataObject myDataObject = new DataObject(myFormat.Name, cd);

            Clipboard.SetDataObject(myDataObject);
            refreshChart();
        }
        private void lstSoup_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtSoupIngredients.Clear();
            txtSoupRecipes.Clear();
            txtImgSoupList.Clear();
            string ingredients = "";
            string recipe      = "";
            int    sentenceCounterIngredient = fileNameAndContentIngredientCollector[lstSoup.SelectedItem.ToString()].Count;
            int    sentenceCounterRecipe     = fileNameAndContentRecipeCollector[lstSoup.SelectedItem.ToString()].Count;


            for (int i = 0; i < sentenceCounterIngredient; ++i)
            {
                ingredients += fileNameAndContentIngredientCollector[lstSoup.SelectedItem.ToString()][i];
            }

            for (int j = 0; j < sentenceCounterRecipe; ++j)
            {
                recipe += fileNameAndContentRecipeCollector[lstSoup.SelectedItem.ToString()][j];
            }


            txtSoupIngredients.Text = ingredients;
            txtSoupRecipes.Text     = recipe;
            DataFormats.Format dataFormat = DataFormats.GetFormat(DataFormats.Bitmap);
            Clipboard.SetImage(Image.FromFile(@"..\..\Menu\Soups\Img\" + lstSoup.SelectedItem.ToString() + ".jpg"));
            txtImgSoupList.Paste(dataFormat);
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: zzl1010/LswCodes
        //截图按钮点击事件的处理程序

        private void btnCutter_Click(object sender, EventArgs e)
        {
            //根据屏幕大小创建一个相同大小的图片
            Bitmap catchBmp = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);
            //创建画板
            Graphics g = Graphics.FromImage(catchBmp);

            //把屏幕图片复制到创建的空白图片中
            g.CopyFromScreen(new Point(0, 0), new Point(0, 0),
                             new Size(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height));

            cutter = new Cutter
            {
                BackgroundImage = catchBmp,
                Width           = Screen.AllScreens[0].Bounds.Width,
                Height          = Screen.AllScreens[0].Bounds.Height
            }; //截图窗体
               //窗体设置与屏幕一样大小

            if (cutter.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            IDataObject idata = Clipboard.GetDataObject();

            DataFormats.Format format = DataFormats.GetFormat(DataFormats.Bitmap);

            if (idata != null && idata.GetDataPresent(DataFormats.Bitmap))
            {
                richTextBox1.Paste(format);
                Clipboard.Clear();//清除剪切板的图片
            }
        }
コード例 #7
0
ファイル: MemberSendEmail.cs プロジェクト: eploentham/thahr30
        public void InsertImage()
        {
            openFileDialog.ShowDialog();
            string lstrFile = openFileDialog.FileName;

            filebody = lstrFile;
            Bitmap myBitmap = new Bitmap(lstrFile);

            // Copy the bitmap to the clipboard.

            Clipboard.SetDataObject(myBitmap);
            // Get the format for the object type.

            DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap);
            // After verifying that the data can be pasted, paste

            if (Txt.CanPaste(myFormat))
            {
                Txt.Paste(myFormat);
            }
            else
            {
                MessageBox.Show("The data format that you attempted site" +
                                " is not supportedby this control.");
            }
        }
コード例 #8
0
ファイル: FrmMain.cs プロジェクト: zmm623/IKendeLib
 private void AddFace()
 {
     for (int i = 0; i < imglstFace.Images.Count; i++)
     {
         PictureBox pb = new PictureBox();
         pb.Width       = 24;
         pb.Height      = 24;
         pb.Tag         = i;
         pb.Image       = imglstFace.Images[i];
         pb.MouseEnter += (o, e1) =>
         {
             ((PictureBox)o).BorderStyle = BorderStyle.FixedSingle;
             if (mTmpImg != null)
             {
                 mTmpImg.BorderStyle = BorderStyle.None;
             }
             mTmpImg = (PictureBox)o;
         };
         pb.MouseLeave += (o, e1) =>
         {
             ((PictureBox)o).BorderStyle = BorderStyle.None;
         };
         pb.Click += (o, e1) =>
         {
             int SelectIndex = (int)((PictureBox)o).Tag;
             Clipboard.SetDataObject(imglstFace.Images[SelectIndex]);
             DataFormats.Format format = DataFormats.GetFormat(DataFormats.Bitmap);
             if (richSay.CanPaste(format))
             {
                 richSay.Paste(format);
             }
         };
         flowLayoutPanel1.Controls.Add(pb);
     }
 }
コード例 #9
0
        private void BaoCao()
        {
            rtxt_baocao.AppendText(" Có hai chế độ xem báo cáo: báo cáo ngày va báo cáo sử dụng thuốc.\u2028");
            rtxt_baocao.AppendText("    * Báo cáo ngày:\u2028");
            rtxt_baocao.AppendText("        - Chọn tháng cần báo cáo tại ô 'Tháng'.\u2028");
            rtxt_baocao.AppendText("        - Nháy vào nút 'Xem báo cáo' để xem báo cáo tháng vừa chọn.\u2028");
            rtxt_baocao.AppendText("        - Chọn vị trí lưu báo cáo (có hình minh họa).\u2028");
            rtxt_baocao.AppendText("        - Nháy vào nút 'Xuất PDF' để in báo cáo.\u2028");
            Bitmap mybitmap = new Bitmap(Properties.Resources.pic12);

            Clipboard.SetDataObject(mybitmap);
            DataFormats.Format myformat = DataFormats.GetFormat(DataFormats.Bitmap);
            rtxt_baocao.Paste(myformat);
            rtxt_baocao.AppendText("\u2028");
            rtxt_baocao.AppendText("                                                                                                                             (Báo cáo ngày)\u2028");
            rtxt_baocao.AppendText("\u2028");
            rtxt_baocao.AppendText("    * Báo cáo sử dụng thuốc: các bước thực hiện tương tự báo cáo ngày.\u2028");
            rtxt_baocao.AppendText("\u2028");
            Bitmap mybitmap1 = new Bitmap(Properties.Resources.pic13);

            Clipboard.SetDataObject(mybitmap1);
            DataFormats.Format myformat1 = DataFormats.GetFormat(DataFormats.Bitmap);
            rtxt_baocao.Paste(myformat1);
            rtxt_baocao.AppendText("\u2028");
            rtxt_baocao.AppendText("                                                                                                                       (Báo cáo sử dụng thuốc)\u2028");
        }
コード例 #10
0
        public void Paste()
        {
            const int pasteStep = 20;

            undo.Enabled = false;
            IDataObject iData = Clipboard.GetDataObject();

            DataFormats.Format format = DataFormats.GetFormat("Diagram.NET Element Collection");
            if (iData.GetDataPresent(format.Name))
            {
                IFormatter    formatter = new BinaryFormatter();
                Stream        stream    = (MemoryStream)iData.GetData(format.Name);
                BaseElement[] elCol     = (BaseElement[])formatter.Deserialize(stream);
                stream.Close();

                foreach (BaseElement el in elCol)
                {
                    el.Location = new Point(el.Location.X + pasteStep, el.Location.Y + pasteStep);
                }

                document.AddElements(elCol);
                document.ClearSelection();
                document.SelectElements(elCol);
            }
            undo.Enabled = true;

            AddUndo();
            EndGeneralAction();
        }
コード例 #11
0
        private void insertChildItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openImageDlg = new OpenFileDialog();

            openImageDlg.Filter = "所有图片(*.bmp,*.gif,*.jpg)|*.bmp;*.gif;*jpg";
            openImageDlg.Title  = "选择图片";
            if (openImageDlg.ShowDialog() == DialogResult.OK)
            {
                string fileName = openImageDlg.FileName;
                if (null == fileName || fileName.Trim().Length == 0)
                {
                    return;
                }
                try
                {
                    Bitmap bmp = new Bitmap(fileName);
                    Clipboard.SetDataObject(bmp);
                    DataFormats.Format dataFormat = DataFormats.GetFormat(DataFormats.Bitmap);
                    if (textEditor.CanPaste(dataFormat))
                    {
                        textEditor.Paste(dataFormat);
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show("图片插入失败。" + exc.Message, "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
コード例 #12
0
 void FullPaste()
 {
     DataFormats.Format format = DataFormats.GetFormat("mhdEffectBIN");
     if (!Clipboard.ContainsData(format.Name))
     {
         Interaction.MsgBox("No effect data on the clipboard!", MsgBoxStyle.Information, "Unable to Paste");
     }
     else
     {
         using (MemoryStream memoryStream = new MemoryStream((byte[])Clipboard.GetDataObject()?.GetData(format.Name) ?? throw new InvalidOperationException()))
             using (BinaryReader reader = new BinaryReader(memoryStream))
             {
                 string       powerFullName = myFX.PowerFullName;
                 IPower       power         = myFX.GetPower();
                 IEnhancement enhancement   = myFX.Enhancement;
                 myFX = new Effect(reader)
                 {
                     PowerFullName = powerFullName
                 };
                 myFX.SetPower(power);
                 myFX.Enhancement = enhancement;
                 DisplayEffectData();
             }
     }
 }
コード例 #13
0
        private void btnCutter_Click(object sender, EventArgs e)
        {
            // 新建一个和屏幕大小相同的图片
            Bitmap CatchBmp = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);

            // 创建一个画板,让我们可以在画板上画图
            // 这个画板也就是和屏幕大小一样大的图片
            // 我们可以通过Graphics这个类在这个空白图片上画图
            Graphics g = Graphics.FromImage(CatchBmp);

            // 把屏幕图片拷贝到我们创建的空白图片 CatchBmp中
            g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height));

            // 创建截图窗体
            cutter = new Cutter();

            // 指示窗体的背景图片为屏幕图片
            cutter.BackgroundImage = CatchBmp;
            // 显示窗体
            //cutter.Show();
            // 如果Cutter窗体结束,则从剪切板获得截取的图片,并显示在聊天窗体的发送框中
            if (cutter.ShowDialog() == DialogResult.OK)
            {
                IDataObject        iData  = Clipboard.GetDataObject();
                DataFormats.Format format = DataFormats.GetFormat(DataFormats.Bitmap);
                if (iData.GetDataPresent(DataFormats.Bitmap))
                {
                    WriteRichTextBox.Paste(format);

                    // 清楚剪贴板的图片
                    //  Clipboard.Clear();
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// Called when the tool is activated.
        /// </summary>
        protected override void OnActivateTool()
        {
            if (Selection.SelectedItems.Count == 0)
            {
                return;
            }

            try
            {
                //Clear the Anchors otherwise subsequent Copy operations will raise an exception due to the fact that the Anchors class is a static helper class
                Anchors.Clear();
                //this will create a volatile collection of entities, they need to be unwrapped!
                //I never managed to get things working by putting the serialized collection directly onto the Clipboad. Thanks to Leppie's suggestion it works by
                //putting the Stream onto the Clipboard, which is weird but it works.
                MemoryStream       copy       = Selection.SelectedItems.ToStream();
                DataFormats.Format format     = DataFormats.GetFormat(typeof(CopyTool).FullName);
                IDataObject        dataObject = new DataObject();
                dataObject.SetData(format.Name, false, copy);
                Clipboard.SetDataObject(dataObject, false);
            }
            catch (Exception exc)
            {
                throw new InconsistencyException("The Copy operation failed.", exc);
            }
            finally
            {
                DeactivateTool();
            }
        }
コード例 #15
0
 public static void CopyToClipboard(T objectToCopy)
 {
     DataFormats.Format format = DataFormats.GetFormat(typeof(T).FullName);
     System.Windows.Forms.IDataObject dataObj = new DataObject();
     dataObj.SetData(format.Name, false, objectToCopy);
     Clipboard.SetDataObject(dataObj, false);
 }
コード例 #16
0
        /// <summary>
        /// Copies the current node and its children to the clipboard in text and graphic formats
        /// </summary>
        /// <param name="arg"></param>
        public void copyToClipboard(Argument arg)
        {
            DataObject myDataObject;

            Node     n;
            DrawTree d;
            Bitmap   b;

            n = (Node)tv.SelectedNode.Tag;

            System.Text.StringBuilder sb;

            // builds a string which is the AXL (XML) for the current node
            sb = arg.writeArgumentXMLstring(n, false);
            // Creates a new data format.
            DataFormats.Format myFormat = DataFormats.GetFormat("AXL");
            myDataObject = new DataObject(myFormat.Name, sb.ToString());
            // Add the text format
            myDataObject.SetData(copySelectedTreeNodeAsText());
            // add graphic
            d = new DrawTree(0, 0, 1F);           // no offset or zoom
            b = d.drawTree(n);                    // create image
            myDataObject.SetData(b);

            Clipboard.SetDataObject(myDataObject, true);
        }
コード例 #17
0
        /// <summary>
        /// Paste clipboard data as an Asn1Node. It try to get data from
        /// Asn1NodeDataFormat first, then try Text data format.
        /// </summary>
        /// <returns>Asn1Node</returns>
        public static Asn1Node Paste()
        {
            DataFormats.Format asn1Format   = DataFormats.GetFormat(asn1FormatName);
            Asn1Node           retval       = new Asn1Node();
            IDataObject        aRetrieveObj = Clipboard.GetDataObject();

            byte[] aData = (byte[])aRetrieveObj.GetData(asn1FormatName);
            if (aData != null)
            {
                MemoryStream ms = new MemoryStream(aData);
                ms.Position = 0;
                retval.LoadData(ms);
            }
            else
            {
                string   dataStr = (string)aRetrieveObj.GetData(DataFormats.Text);
                Asn1Node tmpNode = new Asn1Node();
                if (Asn1Util.IsAsn1EncodedHexStr(dataStr))
                {
                    byte[] data = Asn1Util.HexStrToBytes(dataStr);
                    retval.LoadData(data);
                }
            }
            return(retval);
        }
コード例 #18
0
 private void image_Click(object sender, EventArgs e)
 {
     try
     {
         fileSelect.Filter           = "Pictures (PNG,JPG,GIF,BMP)|*.png;*.jpg;*.jpeg;*.gif;*.bmp";
         fileSelect.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
         if (fileSelect.ShowDialog() == DialogResult.Cancel)
         {
             return;
         }
         IDataObject oldData = Clipboard.GetDataObject();
         Clipboard.SetDataObject(new Bitmap(Image.FromFile(fileSelect.FileName)));
         DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap);
         if (text.CanPaste(myFormat))
         {
             text.Paste(myFormat);
             Clipboard.SetDataObject(oldData);
         }
         else
         {
             MessageBox.Show("The data format that you attempted to paste is not supported by this control.");
         }
     }
     catch (Exception exp)
     {
         MessageBox.Show("Image Insert failed. let's try again ,hell we ? \n" + exp.Message, "image insert error", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #19
0
ファイル: Form1.cs プロジェクト: ghwlchlaks/ChattingProgram
 //private void ImageDisplay(MemoryStream ms, string user_name)
 private void ImageDisplay(Bitmap imageBitmap, string user_name)
 {
     if (richTextBox1.InvokeRequired)
     {
         richTextBox1.BeginInvoke(new MethodInvoker(delegate
         {
             //Image returnImage = Image.FromStream(ms);
             //Bitmap myBitmap = new Bitmap(returnImage, new Size(50, 50));
             //Clipboard.SetDataObject(myBitmap);
             Clipboard.SetDataObject(imageBitmap);
             DataFormats.Format format = DataFormats.GetFormat(DataFormats.Bitmap);
             if (richTextBox1.CanPaste(format))
             {
                 richTextBox1.Paste(format);
                 richTextBox1.AppendText("\n");
                 richTextBox1.ScrollToCaret();
             }
             else
             {
                 MessageBox.Show("x");
             }
         }
                                                    ));
     }
 }
コード例 #20
0
        /// <summary>
        /// Given a toolbox item "unique ID" and a data format identifier, returns the content of
        /// the data format.
        /// </summary>
        /// <param name="itemId">The unique ToolboxItem to retrieve data for</param>
        /// <param name="format">The desired format of the resulting data</param>
        protected override object GetToolboxItemData(string itemId, DataFormats.Format format)
        {
            Debug.Assert(toolboxHelper != null, "Toolbox helper is not initialized");

            // Retrieve the specified ToolboxItem from the DSL
            return(toolboxHelper.GetToolboxItemData(itemId, format));
        }
コード例 #21
0
        //private void GetImage()
        //{
        //    while(true)
        //    {
        //        try
        //        {
        //            stream = clientSocket.GetStream();
        //            int BUFFERSIZE = clientSocket.ReceiveBufferSize;
        //            byte[] buffer = new byte[BUFFERSIZE];
        //            int bytes = stream.Read(buffer, 0, buffer.Length);
        //            TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
        //            Bitmap b = (Bitmap)tc.ConvertFrom(buffer);
        //            Clipboard.SetDataObject(b);
        //            DataFormats.Format format = DataFormats.GetFormat(DataFormats.Bitmap);
        //            if (richText.CanPaste(format))
        //            {

        //                richText.Paste(format);
        //                richText.AppendText("\n");
        //            }
        //            else { MessageBox.Show("x"); }

        //        }
        //        catch
        //        {
        //            break;
        //        }
        //    }
        //}
        private void ImageDisplay(Bitmap imageBitmap)
        {
            if (richText.InvokeRequired)
            {
                richText.BeginInvoke(new MethodInvoker(delegate
                {
                    richText.SelectionAlignment = HorizontalAlignment.Left;
                    //Image returnImage = Image.FromStream(ms);
                    //Bitmap myBitmap = new Bitmap(returnImage, new Size(50, 50));
                    //Clipboard.SetDataObject(myBitmap);
                    Clipboard.SetDataObject(imageBitmap);
                    DataFormats.Format format = DataFormats.GetFormat(DataFormats.Bitmap);
                    if (richText.CanPaste(format))
                    {
                        richText.AppendText("\n");
                        richText.Paste(format);
                        richText.AppendText("\n\n");
                    }
                    else
                    {
                        MessageBox.Show("x");
                    }

                    richText.ScrollToCaret();
                }
                                                       ));
            }
        }
コード例 #22
0
        /// <summary>
        /// Given a toolbox item "unique ID" and a data format identifier, returns the content of
        /// the data format.
        /// </summary>
        /// <param name="itemId">The unique ToolboxItem to retrieve data for</param>
        /// <param name="format">The desired format of the resulting data</param>
        public virtual object GetToolboxItemData(string itemId, DataFormats.Format format)
        {
            DslDesign::ModelingToolboxItem item = null;

            global::System.Resources.ResourceManager resourceManager = global::Microsoft.Data.Entity.Design.EntityDesigner.MicrosoftDataEntityDesignDomainModel.SingletonResourceManager;
            global::System.Globalization.CultureInfo resourceCulture = global::System.Globalization.CultureInfo.CurrentUICulture;

            System.Windows.Forms.IDataObject tbxDataObj;

            //get the toolbox item
            item = GetToolboxItem(itemId);

            if (item != null)
            {
                ToolboxItemContainer container = new ToolboxItemContainer(item);
                tbxDataObj = container.ToolboxData;

                if (tbxDataObj.GetDataPresent(format.Name))
                {
                    return(tbxDataObj.GetData(format.Name));
                }
                else
                {
                    string invalidFormatString = resourceManager.GetString("UnsupportedToolboxFormat", resourceCulture);
                    throw new InvalidOperationException(string.Format(resourceCulture, invalidFormatString, format.Name));
                }
            }

            string errorFormatString = resourceManager.GetString("UnresolvedToolboxItem", resourceCulture);

            throw new InvalidOperationException(string.Format(resourceCulture, errorFormatString, itemId));
        }
コード例 #23
0
ファイル: SubRichFormat.cs プロジェクト: lijunqia/Artifact
        public override void SetFormat(RichTextBox rtbInfo)
        {
            OpenFileDialog o = new OpenFileDialog();

            o.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
            o.Title            = "请选择图片";
            o.Filter           = "jpg|*.jpg|jpeg|*.jpeg|png|*.png|gif|*.gif";
            if (o.ShowDialog() == DialogResult.OK)
            {
                string fileName = o.FileName;
                try
                {
                    Image bmp = Image.FromFile(fileName);
                    Clipboard.SetDataObject(bmp);

                    DataFormats.Format dataFormat = DataFormats.GetFormat(DataFormats.Bitmap);
                    if (rtbInfo.CanPaste(dataFormat))
                    {
                        rtbInfo.Paste(dataFormat);
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show("图片插入失败。" + exc.Message, "提示",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            rtbInfo.Focus();
        }
コード例 #24
0
        public override void Copy2Clipboard()
        {
            // List<DrawObject> SelectedDrawObject = new List<DrawObject>();
            // Construct data format for Slide collection
            DataFormats.Format dataFormat = DataFormats.GetFormat(typeof(List <DrawObject>).FullName);

            // Construct data object from selected slides
            IDataObject dataObject = new DataObject();

            List <DrawObject> dataToCopy = new List <DrawObject>();

            for (int i = 0; i < Pages().ActivePageGraphicList.Count; i++)
            {
                if (Pages().ActivePageGraphicList[i].Selected)
                {
                    if (Common.IsSerializable(Pages().ActivePageGraphicList[i]))
                    {
                        dataToCopy.Add(Pages().ActivePageGraphicList[i]);
                    }
                }
            }
            dataObject.SetData(dataFormat.Name, false, dataToCopy);

            // Put data into clipboard
            Clipboard.SetDataObject(dataObject, false);
        }
コード例 #25
0
        //release mouse to complete this operation
        //change the method from right-click event to clipboard.
        private void PasteImage()
        {
            //if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (Clipboard.ContainsImage())
                {
                    //var confirmRes = MessageBox.Show("Sure to paste?", "Confirm paste!", MessageBoxButtons.YesNo);
                    //if (confirmRes == DialogResult.Yes)
                    {
                        DataFormats.Format dataFormat = DataFormats.GetFormat(DataFormats.Bitmap);
                        if (richTextBox.CanPaste(dataFormat))
                        {
                            richTextBox.Paste(dataFormat);
                        }

                        //clear the clip board after paste
                        Clipboard.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("No image on the clip board!");
                }
            }
        }
コード例 #26
0
ファイル: Form1.cs プロジェクト: AndriiAleksandrov/Notepad
 private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DataFormats.Format myformat = DataFormats.GetFormat(DataFormats.Text);
     if (richTextBox1.CanPaste(myformat))
     {
         richTextBox1.Paste(myformat);
     }
 }
コード例 #27
0
 /// <summary>
 /// Pastes the contents of the Clipboard in the specified Clipboard format.
 /// </summary>
 /// <param name="clipFormat">The Clipboard format in which the data should be obtained from the Clipboard.</param>
 public void Paste(DataFormats.Format clipFormat)
 {
     if (T == null)
     {
         return;
     }
     T.Paste(clipFormat);
 }
コード例 #28
0
// <Snippet1>
    private void CreateMyFormat2()
    {
        DataFormats.Format myFormat = new DataFormats.Format("AnotherNewFormat", 20916);

        // Displays the contents of myFormat.
        textBox1.Text = "ID value: " + myFormat.Id + '\n' +
                        "Format name: " + myFormat.Name;
    }
コード例 #29
0
        public void CopyToClipboard()
        {
            DataFormats.Format format  = DataFormats.GetFormat(typeof(MyItem).FullName);
            IDataObject        dataObj = new DataObject();

            dataObj.SetData(format.Name, false, this);
            Clipboard.SetDataObject(dataObj, false);
        }
コード例 #30
0
        public static void Main(string[] argv)
        {
            // Creates a new data format.
            DataFormats.Format environmentVariableFormat = DataFormats.GetFormat("EnvironmentVariable");

            ClipboardSetDataObject(environmentVariableFormat);
            ClipboardGetDataObject(environmentVariableFormat);
        }