当前位置: 首页>>代码示例>>C#>>正文


C# DataObject.GetData方法代码示例

本文整理汇总了C#中System.Windows.Forms.DataObject.GetData方法的典型用法代码示例。如果您正苦于以下问题:C# DataObject.GetData方法的具体用法?C# DataObject.GetData怎么用?C# DataObject.GetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.DataObject的用法示例。


在下文中一共展示了DataObject.GetData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DisplayClipboardData

        protected void DisplayClipboardData()
        {
            if (!skipFirst)
            {
                skipFirst = true;
                return;
            }
            try
            {
                IDataObject iData = new DataObject();
                iData = Clipboard.GetDataObject();

                if (iData.GetDataPresent(DataFormats.Text))
                {
                    string text = (string)iData.GetData(DataFormats.Text);
                    txtClipBoard.Text = text;
                    int next = clipBoardTextService.process(text);
                    txtStartNumber.Text = next.ToString();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
开发者ID:holyman2k,项目名称:ClipBoardDownloader,代码行数:25,代码来源:Main.cs

示例2: HandleCopy

        internal void HandleCopy()
        {

            if (SelectedState.Self.SelectedFrame != null)
            {
                Clipboard.Clear();
                DataObject dataObject = new DataObject("frame", FileManager.CloneObject(SelectedState.Self.SelectedFrame));
                var item = dataObject.GetData("frame");
                Clipboard.SetDataObject(
                    dataObject, false, 10, 40);
            }
            else if (SelectedState.Self.SelectedChain != null)
            {
                Clipboard.Clear();
                var toAdd = FileManager.CloneObject(SelectedState.Self.SelectedChain);
                DataObject dataObject = new DataObject("chain", toAdd);
                Clipboard.SetDataObject(
                    dataObject, false, 10, 40);
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:20,代码来源:CopyManager.cs

示例3: GetTextFromDataObject

 protected override string GetTextFromDataObject(IDataObject dataObject, IServiceProvider provider)
 {
     IDataObjectMapper dataObjectMapper = ((IDataObjectMappingService) provider.GetService(typeof(IDataObjectMappingService))).GetDataObjectMapper(dataObject, DataFormats.Text);
     if (dataObjectMapper != null)
     {
         DataObject mappedDataObject = new DataObject();
         dataObjectMapper.PerformMapping(provider, dataObject, mappedDataObject);
         if (mappedDataObject.GetDataPresent(DataFormats.Text))
         {
             return (string) mappedDataObject.GetData(DataFormats.Text);
         }
     }
     if (dataObject.GetDataPresent(CodeWizard.CodeWizardDataFormat))
     {
         ITextLanguage codeLanguage = this.GetCodeLanguage(provider);
         if (codeLanguage != null)
         {
             return codeLanguage.GetTextFromDataObject(dataObject, provider);
         }
     }
     return base.GetTextFromDataObject(dataObject, provider);
 }
开发者ID:ikvm,项目名称:webmatrix,代码行数:22,代码来源:WebFormsDocumentLanguage.cs

示例4: DisplayClipboardData

        private void DisplayClipboardData()
        {
            try
            {
                IDataObject iData = new DataObject();
                iData = Clipboard.GetDataObject();

                MessageBox.Show(iData.GetData(DataFormats.UnicodeText).ToString());
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
开发者ID:GhostCamel,项目名称:StockTrader,代码行数:14,代码来源:Form1.cs

示例5: OnToolboxDataItemPicked

 public virtual void OnToolboxDataItemPicked(ToolboxDataItem dataItem)
 {
     IDesignerHost service = (IDesignerHost) this.ServiceProvider.GetService(typeof(IDesignerHost));
     IDataObject dataObject = dataItem.GetDataObject(service);
     string html = string.Empty;
     if (dataObject != null)
     {
         if (dataObject.GetDataPresent(DataFormats.Html))
         {
             html = dataObject.GetData(DataFormats.Html).ToString();
         }
         else if (dataObject.GetDataPresent(DataFormats.Text))
         {
             html = dataObject.GetData(DataFormats.Text).ToString();
         }
         else if (this.DataObjectConverter.CanConvertToHtml(dataObject) == DataObjectConverterInfo.CanConvert)
         {
             DataObject newDataObject = new DataObject();
             if (this.DataObjectConverter.ConvertToHtml(dataObject, newDataObject))
             {
                 html = (string) newDataObject.GetData(DataFormats.Html);
             }
         }
         BatchedUndoUnit unit = this._editor.OpenBatchUndo("Toolbox");
         try
         {
             this._editor.Document.InsertHtml(html);
         }
         finally
         {
             unit.Close();
         }
     }
 }
开发者ID:ikvm,项目名称:webmatrix,代码行数:34,代码来源:HtmlDesignView.cs

示例6: DisplayClipboardData

        private void DisplayClipboardData()
        {
            IDataObject iData = new DataObject();
            iData = Clipboard.GetDataObject();

            if (iData.GetDataPresent(DataFormats.Rtf))
                this.richTextBox1.Rtf = (string)iData.GetData(DataFormats.Rtf);
            else if (iData.GetDataPresent(DataFormats.Text))
                this.richTextBox1.Text = (string)iData.GetData(DataFormats.Text);
            else
                this.richTextBox1.Text = "[Clipboard data is not RTF or ASCII Text]";
        }
开发者ID:kingzone,项目名称:ClipboardViewer,代码行数:12,代码来源:FormMain.cs

示例7: GetCellClipboardContent

		//-------------------------------------------------------------------------------------
		/// <summary>
		///  опирует в clipboard текущую ¤чейку. ”дал¤ет формат html представлени¤.
		/// </summary>
		/// <returns></returns>
		public DataObject GetCellClipboardContent()
		{
			DataObject obj = new DataObject(CurrentCell.FormattedValue);
			DataObject newObj = new DataObject();

			//this.Sele

			string[] types = obj.GetFormats();
			foreach(String type in types)
			{
				if(type != DataFormats.Html)
					newObj.SetData(type, obj.GetData(type));
			}
			return newObj;
		}
开发者ID:GoldMax,项目名称:Pulsar.NET,代码行数:20,代码来源:SimDataGridView.cs

示例8: theSite_drop

        /// <summary>
        /// This method needs heavy revision.
        /// 
        /// Since element on which was module dropped is COM interface IHTMLElement
        /// and that seems like it's not supporting own module tag (it gets removed on whatever operation),
        /// this method adds id to IHTMLElement(if needed), to be able to identify it in HtmlAgilityPack HtmlDocument
        /// then adds preview output as end to that element, then converts document back to COM IHTMLDocument2
        /// 
        /// Doh.
        /// 
        /// TODO: Could use hard refactoring, probably own customized html editor
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void theSite_drop(DataObject sender, DragEventArgs e)
        {
            CFormController.Instance.mainForm.setStatus("Module(s) Added");
            if (sender.GetData("System.Windows.Forms.ListView+SelectedListViewItemCollection", false) != null)
            {
                // Get module preview (multiple modules can be dragged)
                String input = String.Empty;
                ListView.SelectedListViewItemCollection listViewItemModules = (ListView.SelectedListViewItemCollection)sender.GetData("System.Windows.Forms.ListView+SelectedListViewItemCollection", false);
                foreach (ListViewItem listViewItemModule in listViewItemModules)
                {
                    input += CXMLParser.Instance.GetPreviewFromProjectXML(CXMLParser.Instance.GetNodeFromModule(CModuleReader.Instance.GetModuleInstanceFromName(listViewItemModule.Text)).OuterHtml);
                }

                // Get relative drop location
                Point htmlEditorCorner = htmlEditor1.PointToScreen(new Point(0, 0));
                int X = e.X - htmlEditorCorner.X;
                int Y = e.Y - htmlEditorCorner.Y;

                // Get element on which module was dropped
                IHTMLElement hoverElem = htmlEditor1.HtmlDocument2.ElementFromPoint(X, Y);
                IHTMLElement moduleElem = null;

                // If it gets dropped on module, pass its parent element instead
                if(CRestrictedEditDesigner.isModule(hoverElem, out moduleElem))
                {
                    hoverElem = moduleElem;
                }

                if (hoverElem.tagName.Equals("BODY"))
                {
                    Debug.WriteLine("dropped on body");
                    if (hoverElem.innerText == null && hoverElem.innerHTML == null)
                        htmlEditor1.LoadDocument("<body>" + input + "</body>");
                    else
                        htmlEditor1.LoadDocument("<body>" + hoverElem.innerHTML + input + "</body>");
                }
                else
                {
                    Debug.WriteLine("dropped on " + hoverElem.tagName);

                    //Mshtml deletes <module> in element load,
                    //uhm so it has to be converted to HtmlAgilityPack.HtmlDocument
                    //and then back
                    String guid = Guid.NewGuid().ToString();
                    Boolean idChanged;
                    if (hoverElem.id == null)
                    {
                        hoverElem.id = guid;
                        idChanged = true;
                    }
                    else
                    {
                        guid = hoverElem.id;
                        idChanged = false;
                    }

                    // Get wanted element and modify its content
                    HtmlAgilityPack.HtmlDocument htmlDoc = HTMLDocumentConverter.mshtmlDocToAgilityPackDoc(htmlEditor1.HtmlDocument2);
                    HtmlAgilityPack.HtmlNode node = htmlDoc.GetElementbyId(guid);

                    // Dont remove id if it was there before
                    if(idChanged)
                        node.Attributes.Remove("id");

                    // Need to create element, because HtmlNode dont have OuterHtml settable
                    HtmlNode addedModulesNode = htmlDoc.CreateElement("div");
                    addedModulesNode.InnerHtml = input;

                    try
                    {
                        // Well, this sometimes fails.. god knows why
                        htmlDoc.DocumentNode.InsertAfter(addedModulesNode, node);
                    }
                    catch (Exception)
                    {
                        // So if it fails, add module in the end of parent module
                        node.ParentNode.InnerHtml += input;
                    }

                    // And back to IHTMLDocument
                    htmlEditor1.LoadDocument("<body>" + htmlDoc.DocumentNode.InnerHtml + "</body>");
                }
            }
        }
开发者ID:artmachinez,项目名称:bc,代码行数:98,代码来源:CanvasTabPage.cs

示例9: DisplayClipboardData

        private void DisplayClipboardData()
        {
            if (iniciarToolStripMenuItem.Checked)
            {

                try
                {
                    IDataObject iData = new DataObject();
                    iData = Clipboard.GetDataObject();
                    //if (iData.GetDataPresent(DataFormats.Rtf))
                       // richTextBox1.Rtf = (string)iData.GetData(DataFormats.Rtf);
                   // else if (iData.GetDataPresent(DataFormats.Text))
                        //richTextBox1.Text = (string)iData.GetData(DataFormats.Text);
                    //else
                        if (iData.GetDataPresent(DataFormats.Bitmap))
                        {

                            if (original)
                                img = (Image)iData.GetData(DataFormats.Bitmap);
                            else
                                img = Redimensionar((Image)iData.GetData(DataFormats.Bitmap), width, height, 90);

                            //pictureBox1.Image = Redimensionar((Image)iData.GetData(DataFormats.Bitmap), 160, 120, 90);

                            if (defaultRoute)
                            {

                                ruta = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\imagen" + numImage + ".jpg";

                                //ruta = Application.StartupPath+"\\imagen" + numImage + ".jpg";

                                img.Save(ruta, formato);
                            }
                            else

                                if (!defaultRoute)
                                {

                                    do
                                    {

                                        ruta = folderBrowserDialog1.SelectedPath + @"\imagen" + numImage + ".jpg";
                                        numImage++;
                                    } while (File.Exists(ruta));

                                    FileIOPermission f3 = new FileIOPermission(FileIOPermissionAccess.Write, ruta);

                                    try
                                    {
                                        f3.Demand();
                                    }
                                    catch (SecurityException s)
                                    {
                                        Console.WriteLine(s.Message);
                                    }
                                    img.Save(ruta, formato);
                                }
                            toolStripStatusLabel2.Text = ruta;
                            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                            pictureBox1.ImageLocation = ruta;

                            numImage++;
                            txtruta.Text = ruta;
                            if (notificacionesToolStripMenuItem.Checked)

                            if (!original)
                                notifyIcon1.ShowBalloonTip(1, "Imagen Guardada " + width + "x" + height, ruta, ToolTipIcon.None);
                            else
                                notifyIcon1.ShowBalloonTip(1, "Imagen Guardada " + img.Width + "x" + img.Height, ruta, ToolTipIcon.None);

                        }

                }
                catch (Exception e)
                {

                    MessageBox.Show(e.ToString());
                }
            }
        }
开发者ID:EduardoOrtiz89,项目名称:ClipSaveImage,代码行数:80,代码来源:Form1.cs

示例10: Main

		public static void Main ()
		{
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Bitmap));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.CommaSeparatedValue));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Dib));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Dif));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.EnhancedMetafile));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.FileDrop));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Html));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Locale));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.MetafilePict));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.OemText));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Palette));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.PenData));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Riff));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Rtf));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Serializable));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.StringFormat));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.SymbolicLink));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Text));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.Tiff));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.UnicodeText));
			PrintFormatInfo(DataFormats.GetFormat(DataFormats.WaveAudio));

			// Add our own format
			PrintFormatInfo(DataFormats.GetFormat("Birthday"));

			// Test some basic stuff
			DataObject	dobj;
			Control		c;
			string		rtf;

			c = new Control();
			rtf = "\\r\\t\\f  string";

			// Load the data object
			dobj = new DataObject(DataFormats.Text, "I am text");
			dobj.SetData(c.GetType(), c);
			dobj.SetData(DataFormats.Rtf, rtf);

			PrintFormats("GetFormats(): ", dobj.GetFormats());		// Count should be 5
			PrintFormats("GetFormats(true): ", dobj.GetFormats(true));	// Count should be 5
			PrintFormats("GetFormats(false): ", dobj.GetFormats(false));	// Count should be 3

			Console.WriteLine("GetDataPresent(typeof(string)): {0}", dobj.GetDataPresent(typeof(string)));			// We expect true
			Console.WriteLine("GetDataPresent(DataFormats.Text): {0}", dobj.GetDataPresent(DataFormats.Text));		// We expect true
			Console.WriteLine("GetDataPresent(DataFormats.WaveAudio): {0}", dobj.GetDataPresent(DataFormats.WaveAudio));	// We expect false

			Console.WriteLine("GetData(DataFormats.Rtf): {0}", dobj.GetData(DataFormats.Rtf));				// We expect "\r\t\f  string"

			clipboard clip = new clipboard ();

			PrintClipboardContents();

			IDataObject data;

			data = Clipboard.GetDataObject();

			if (data != null && data.GetDataPresent(DataFormats.Bitmap)) {
				image = (Image)Clipboard.GetDataObject().GetData(DataFormats.Bitmap);
			}

			Bitmap i = new Bitmap("test.bmp");
			string s = "bummerä";

			Clipboard.SetDataObject(s);

			Application.Run (clip);
		}
开发者ID:hitswa,项目名称:winforms,代码行数:69,代码来源:clipboard.cs

示例11: GetClipboardData

        private void GetClipboardData()
        {
            //
            // Data on the clipboard uses the
            // IDataObject interface
            //
            IDataObject iData = new DataObject();

            try
            {
                iData = Clipboard.GetDataObject();
            }
            catch (System.Runtime.InteropServices.ExternalException externEx)
            {
                // Copying a field definition in Access 2002 causes this sometimes?
                //Debug.WriteLine("InteropServices.ExternalException: {0}", externEx.Message);
                return;
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
                return;
            }

            //
            // Get Text if it is present
            //
            if (iData.GetDataPresent(DataFormats.UnicodeText))
            {
                if (_EnableClipboardSearch)
                {
                    _SearchedWord = (string)iData.GetData(DataFormats.UnicodeText);
                    textBoxSearchKeyWord.Text = _SearchedWord;
                    searchWord(_SearchedWord, _EnableClipboardSearch);
                }
                //ctlClipboardText.Text = (string)iData.GetData(DataFormats.Text);

                //strText = "Text";

                //Debug.WriteLine((string)iData.GetData(DataFormats.Text));
            }
        }
开发者ID:raihan2006i,项目名称:Abhidhan,代码行数:42,代码来源:Abhidhan.cs

示例12: GetClipboardData

        private void GetClipboardData()
        {
            //
            // Data on the clipboard uses the 
            // IDataObject interface
            //
            IDataObject dataObject = new DataObject();
            
            try
            {
                dataObject = Clipboard.GetDataObject();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Clip2Web Error: " + ex.ToString());
                return;
            }

            var formats = dataObject.GetFormats();
            
            if(formats.Contains(INTERESTING_FORMAT) || dataObject.GetDataPresent(DataFormats.Bitmap))
            {
                m_imageData = (System.Drawing.Bitmap)dataObject.GetData(DataFormats.Bitmap);
                m_trayIcon.ShowBalloonTip(1000, "Clip Saved!", "Click to copy path", ToolTipIcon.Info);
            }
        }
开发者ID:bageshwar,项目名称:Clip2Web,代码行数:26,代码来源:Drawer.cs

示例13: ShellTreeView_GiveFeedback

		private void ShellTreeView_GiveFeedback(object sender, GiveFeedbackEventArgs e) {
			e.UseDefaultCursors = true;
			var doo = new System.Windows.Forms.DataObject(this._DataObject);
			if (doo.GetDataPresent("DragWindow")) {
				IntPtr hwnd = ShellView.GetIntPtrFromData(doo.GetData("DragWindow"));
				User32.PostMessage(hwnd, 0x403, IntPtr.Zero, IntPtr.Zero);
			} else {
				e.UseDefaultCursors = true;
			}

			if (ShellView.IsDropDescriptionValid(this._DataObject)) {
				e.UseDefaultCursors = false;
				Cursor.Current = Cursors.Arrow;
			} else {
				e.UseDefaultCursors = true;
			}

			if (ShellView.IsShowingLayered(doo)) {
				e.UseDefaultCursors = false;
				Cursor.Current = Cursors.Arrow;
			} else {
				e.UseDefaultCursors = true;
			}

			base.OnGiveFeedback(e);
		}
开发者ID:Gainedge,项目名称:BetterExplorer,代码行数:26,代码来源:ShellTreeViewEx.cs

示例14: GetSampleCsDragData

 /// <summary>
 /// Extract SampleCsDragDropData from DataObject
 /// </summary>
 public SampleCsDragData GetSampleCsDragData(DataObject data)
 {
     if (null != data && data.GetDataPresent(typeof(SampleCsDragData)))
     return data.GetData(typeof(SampleCsDragData)) as SampleCsDragData;
       return null;
 }
开发者ID:mcneel,项目名称:Rhino4Samples_DotNet,代码行数:9,代码来源:SampleCsDropTarget.cs

示例15: TestText

		public void TestText ()
		{
			DataObject d = new DataObject ();

			d.SetText ("yo");

			Assert.AreEqual (false, d.ContainsAudio (), "A1");
			Assert.AreEqual (false, d.ContainsFileDropList (), "A2");
			Assert.AreEqual (false, d.ContainsImage (), "A3");
			Assert.AreEqual (true, d.ContainsText (), "A4");
			Assert.AreEqual (false, d.ContainsText (TextDataFormat.CommaSeparatedValue), "A5");

			Assert.AreEqual ("yo", d.GetText (), "A6");
			Assert.AreEqual ("yo", d.GetData (DataFormats.StringFormat), "A6-1");
			
			d.SetText ("<html></html>", TextDataFormat.Html);
			Assert.AreEqual (true, d.ContainsText (), "A7");
			Assert.AreEqual (false, d.ContainsText (TextDataFormat.CommaSeparatedValue), "A8");
			Assert.AreEqual (true, d.ContainsText (TextDataFormat.Html), "A9");
			Assert.AreEqual (false, d.ContainsText (TextDataFormat.Rtf), "A10");
			Assert.AreEqual (true, d.ContainsText (TextDataFormat.Text), "A11");
			Assert.AreEqual (true, d.ContainsText (TextDataFormat.UnicodeText), "A12");

			// directly put a string
			d.SetData ("yo");

			Assert.AreEqual (true, d.ContainsText (TextDataFormat.Text), "A13");
			Assert.AreEqual (true, d.ContainsText (TextDataFormat.UnicodeText), "A14");

			Assert.AreEqual ("yo", d.GetData (DataFormats.StringFormat), "A15");
			Assert.AreEqual ("yo", d.GetData (DataFormats.Text), "A16");
			Assert.AreEqual ("yo", d.GetData (DataFormats.UnicodeText), "A17");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:33,代码来源:DataObjectTest.cs


注:本文中的System.Windows.Forms.DataObject.GetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。