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


C# DataObject.GetFormats方法代码示例

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


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

示例1: TestConvertible

		public void TestConvertible ()
		{
			DataObject o = new DataObject ();
			o.SetData (DataFormats.Text, false, "abc");

			Assert.AreEqual (new string [] { DataFormats.Text }, o.GetFormats (), "#01");
			Assert.AreEqual (new string [] { DataFormats.Text }, o.GetFormats (true), "#02");
			Assert.AreEqual (new string [] { DataFormats.Text }, o.GetFormats (false), "#03");

			o = new DataObject ();
			o.SetData (DataFormats.Text, true, "abc");

			Assert.AreEqual (new string [] { DataFormats.StringFormat, DataFormats.UnicodeText, DataFormats.Text }, o.GetFormats (), "#B1");
			Assert.AreEqual (new string [] { DataFormats.StringFormat, DataFormats.UnicodeText, DataFormats.Text }, o.GetFormats (), "#B2");
			Assert.AreEqual (new string [] { DataFormats.Text }, o.GetFormats (false), "#B3");


			o = new DataObject ();
			o.SetData (DataFormats.UnicodeText, true, "abc");

			Assert.AreEqual (new string [] { DataFormats.StringFormat, DataFormats.UnicodeText, DataFormats.Text }, o.GetFormats (), "#C1");
			Assert.AreEqual (new string [] { DataFormats.StringFormat, DataFormats.UnicodeText, DataFormats.Text }, o.GetFormats (), "#C2");
			Assert.AreEqual (new string [] { DataFormats.UnicodeText }, o.GetFormats (false), "#C3");

			o = new DataObject ();
			o.SetData (DataFormats.UnicodeText, false, "abc");

			Assert.AreEqual (new string [] { DataFormats.UnicodeText }, o.GetFormats (), "#D1");
			Assert.AreEqual (new string [] { DataFormats.UnicodeText}, o.GetFormats (), "#D2");
			Assert.AreEqual (new string [] { DataFormats.UnicodeText }, o.GetFormats (false), "#D3");

			o = new DataObject ();
			o.SetData (DataFormats.StringFormat, true, "abc");

			Assert.AreEqual (new string [] { DataFormats.StringFormat, DataFormats.UnicodeText, DataFormats.Text }, o.GetFormats (), "#C1");
			Assert.AreEqual (new string [] { DataFormats.StringFormat, DataFormats.UnicodeText, DataFormats.Text }, o.GetFormats (), "#C2");
			Assert.AreEqual (new string [] { DataFormats.StringFormat }, o.GetFormats (false), "#C3");

			o = new DataObject ();
			o.SetData (DataFormats.StringFormat, false, "abc");

			Assert.AreEqual (new string [] { DataFormats.StringFormat }, o.GetFormats (), "#D1");
			Assert.AreEqual (new string [] { DataFormats.StringFormat }, o.GetFormats (), "#D2");
			Assert.AreEqual (new string [] { DataFormats.StringFormat }, o.GetFormats (false), "#D3");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:45,代码来源:DataObjectTest.cs

示例2: AddToClipboard

        /// <summary>
        /// Adds the specified data to the clipboard
        /// </summary>
        public static void AddToClipboard(params ClipboardData[] data)
        {
            Forms.IDataObject dataObject = new Forms.DataObject();
            foreach (var clipboardData in data)
            {
                if (clipboardData.Data != null)
                    dataObject.SetData(Clipboard.FormatToString(clipboardData.Format), clipboardData.Data);
            }

            if (dataObject.GetFormats().Length > 1)
            {
                Forms.Clipboard.SetDataObject(dataObject, copy: true);
            }
        }
开发者ID:ramarag,项目名称:XTask,代码行数:17,代码来源:Clipboard.cs

示例3: AddToClipboard

        /// <summary>
        /// Adds the specified data to the clipboard
        /// </summary>
        /// <exception cref="ArgumentNullException">Thrown if <param name="nameof(data)"/> is null.</exception>
        public static void AddToClipboard(params ClipboardData[] data)
        {
            if (data == null) throw new ArgumentNullException(nameof(data));

            Forms.IDataObject dataObject = new Forms.DataObject();
            foreach (var clipboardData in data)
            {
                if (clipboardData.Data != null)
                    dataObject.SetData(GetDataObjectFormatString(clipboardData.Format), clipboardData.Data);
            }

            if (dataObject.GetFormats().Length > 1)
            {
                Forms.Clipboard.SetDataObject(dataObject, copy: true);
            }
        }
开发者ID:JeremyKuhne,项目名称:XTask,代码行数:20,代码来源:Clipboard.cs

示例4: IsFormatValid

 private static bool IsFormatValid(DataObject data)
 {
     return IsFormatValid(data.GetFormats());
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:Clipboard.cs

示例5: ProcessesTreeViewDragDrop

        private void ProcessesTreeViewDragDrop(object sender, DragEventArgs e)
        {
            var data = new DataObject(new TreeNodeAdv(new Node()));

            if (!e.Data.GetDataPresent(data.GetFormats()[0])) return;

            var draggedTreeNode = (TreeNodeAdv)e.Data.GetData(data.GetFormats()[0]);
            var draggedNode = (DeviareNode)draggedTreeNode.Tag;

            var targetTreeNode = _processesTreeView.DropPosition.Node;
            var targetNode = (DeviareNode)targetTreeNode.Tag;

            var processCollector = new Collector();
            targetNode.Accept(processCollector);

            var hookCollector = new Collector();
            draggedNode.Accept(hookCollector);

            _presenter.ReplicateHooks(processCollector.CollectedProcesses, hookCollector.CollectedHooks);
        }
开发者ID:subTee,项目名称:Deviare2,代码行数:20,代码来源:DeviareConsoleForm.cs

示例6: SetDragDropMode

        private static void SetDragDropMode(DragEventArgs e)
        {
            var data = new DataObject(new TreeNodeAdv(new Node()));

            if (e.Data.GetDataPresent(data.GetFormats()[0]))
            {
                e.Effect = DragDropEffects.Link;
                return;
            }

            e.Effect = DragDropEffects.None;
        }
开发者ID:subTee,项目名称:Deviare2,代码行数:12,代码来源:DeviareConsoleForm.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: 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 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


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