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


C# DataObject.GetDataPresent方法代码示例

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


在下文中一共展示了DataObject.GetDataPresent方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: QueryAcceptData

 public int QueryAcceptData(System.Runtime.InteropServices.ComTypes.IDataObject lpdataobj, IntPtr lpcfFormat, int reco, int fReally, IntPtr hMetaPict)
 {
     if (reco != 0)
     {
         return -2147467263;
     }
     DataObject obj2 = new DataObject(lpdataobj);
     if ((obj2 == null) || (!obj2.GetDataPresent(DataFormats.Text) && !obj2.GetDataPresent(DataFormats.UnicodeText)))
     {
         return -2147467259;
     }
     return 0;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:MultilineStringEditor.cs

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: OnGiveFeedback

    protected override void OnGiveFeedback(F.GiveFeedbackEventArgs e) {
      e.UseDefaultCursors = true;
      var doo = new F.DataObject(_DataObject);

      if (doo.GetDataPresent("DragWindow")) {
        IntPtr hwnd = GetIntPtrFromData(doo.GetData("DragWindow"));
        User32.PostMessage(hwnd, 0x403, IntPtr.Zero, IntPtr.Zero);
      } else {
        e.UseDefaultCursors = true;
      }
      if (IsDropDescriptionValid(_DataObject)) {
        e.UseDefaultCursors = false;
        Cursor.Current = Cursors.Arrow;
      } else {
        e.UseDefaultCursors = true;
      }

      if (IsShowingLayered(doo)) {
        e.UseDefaultCursors = false;
        Cursor.Current = Cursors.Arrow;
      } else {
        e.UseDefaultCursors = true;
      }
    }
开发者ID:Gainedge,项目名称:BetterExplorer,代码行数:24,代码来源:ShellViewEx.cs


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