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


C# DataObject.GetText方法代码示例

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


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

示例1: GetFilePath

        /// <summary>
        /// Get the file path from a drag & drop operation info.
        /// Return null if it was not possibile to retrieve a file path (for instance 
        /// if the data format is not handled).
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static string GetFilePath(this DragDropInfo info)
        {
            var data = new DataObject(info.Data);

            if (info.Data.GetDataPresent("FileDrop"))
            {
                // The drag and drop operation came from the file system
                var files = data.GetFileDropList();

                if (files != null && files.Count == 1)
                    return files[0];
            }
            else if (info.Data.GetDataPresent("CF_VSSTGPROJECTITEMS"))
                return data.GetText(); // The drag and drop operation came from the VS solution explorer
            else if (info.Data.GetDataPresent("MultiURL"))
                return data.GetText();

            return null;
        }
开发者ID:GProulx,项目名称:WebEssentials2013,代码行数:26,代码来源:DragDropExtensions.cs

示例2: GetImageFilename

        public static string GetImageFilename(DragDropInfo info)
        {
            DataObject data = new DataObject(info.Data);

            if (info.Data.GetDataPresent("FileDrop"))
            {
                // The drag and drop operation came from the file system
                StringCollection files = data.GetFileDropList();

                if (files != null && files.Count == 1)
                {
                    return files[0];
                }
            }
            else if (info.Data.GetDataPresent("CF_VSSTGPROJECTITEMS"))
            {
                // The drag and drop operation came from the VS solution explorer
                return data.GetText();
            }

            return null;
        }
开发者ID:Russe11,项目名称:WebEssentials2013,代码行数:22,代码来源:FontDrop.cs

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

示例4: checkObjectType


//.........这里部分代码省略.........
                            {
                                System.Console.Write(e.ToString());
                            }
                            try
                            {
                                string mapSourceId = string.Empty;
                                if (pEvtObj.SrcElement.getAttribute("mapSourceId", 0) != null && !string.IsNullOrEmpty((String)pEvtObj.SrcElement.getAttribute("mapSourceId", 0)))
                                {
                                    mapSourceId = (String)pEvtObj.SrcElement.getAttribute("mapSourceId", 0);
                                    if (!string.IsNullOrEmpty(mapSourceId))
                                        editMaplinkPropertiesToolStripMenuItem.Visible = true;
                                }
                            }
                            catch (Exception e)
                            {
                                System.Console.Write(e.ToString());
                            }
                            

                        }
                        //else if ((pEvtObj.SrcElement.tagName == "P") ||
                        //        (pEvtObj.SrcElement.tagName == "BODY"))
                        //{
                        //}
                    }
                    ctxMnuHTMLEditor.Show(pEvtObj.ScreenX, pEvtObj.ScreenY);
                }
            }
            else if (EventDispId == HTMLEventDispIds.ID_ONDRAG) //fires
            {
                AllForms.m_frmLog.AppendToLog("ID_ONDRAG");
            }
            else if (EventDispId == HTMLEventDispIds.ID_ONDRAGSTART) //fires
            {
                //this is the element that started the drag
                if ((pEvtObj != null) && (pEvtObj.SrcElement != null) ) 
                    AllForms.m_frmLog.AppendToLog("HTMLEvent_ONDRAGSTART==>pEvtObj.SrcElement.tagName\r\n" + pEvtObj.SrcElement.tagName);
                else
                    AllForms.m_frmLog.AppendToLog("ID_ONDRAGSTART");
            }
            else if (EventDispId == HTMLEventDispIds.ID_ONDRAGEND) //fires
            {
                /*
                 * IHTMLEventObj2::dataTransfer
                 * The IHTMLDataTransfer interface retrieved by this method also provides 
                 * access to IDataObject. Call QueryInterface on the IHTMLDataTransfer
                 * interface pointer to obtain an IServiceProvider interface pointer.
                 * Then call IServiceProvider::QueryService, using IID_IDataObject
                 * for the service and interface identifiers, to obtain an IDataObject
                 * interface pointer.
                 * 
                 * IHTMLEventObj2::reason
                 */
                //this is the element which data was dropped on
                
                if ((pEvtObj != null) && (pEvtObj.SrcElement != null))
                {
                    IHTMLEventObj2 eveobj2 = pEvtObj as IHTMLEventObj2;
                    if( (eveobj2 != null) && (eveobj2.dataTransfer != null) )
                    {
                        IfacesEnumsStructsClasses.IServiceProvider pSP = eveobj2.dataTransfer as IfacesEnumsStructsClasses.IServiceProvider;
                        if (pSP != null)
                        {
                            IntPtr pdataobj = IntPtr.Zero;
                            int iret = pSP.QueryService(ref Iid_Clsids.IID_IDataObject, ref Iid_Clsids.IID_IDataObject, out pdataobj);
                            object obj = Marshal.GetObjectForIUnknown(pdataobj);
                            System.Runtime.InteropServices.ComTypes.IDataObject idataobj = obj as System.Runtime.InteropServices.ComTypes.IDataObject;
                            DataObject obja = new DataObject(idataobj);
                            //string[] formats = obja.GetFormats(false);
                            //foreach (string str in formats)
                            //{
                            //    AllForms.m_frmLog.AppendToLog("format ==> " + str);
                            //}
                            AllForms.m_frmLog.AppendToLog("HTMLEvent_ONDRAGEND==> " + obja.GetText(TextDataFormat.Html) );
                        }
                    }
                }
                else
                    AllForms.m_frmLog.AppendToLog("ID_ONDRAGEND");
            }
            //Do not fire
            //else if (EventDispId == HTMLEventDispIds.ID_ONDROP)
            //{
            //    AllForms.m_frmLog.AppendToLog("ID_ONDROP");
            //}
            //else if (EventDispId == HTMLEventDispIds.ID_ONDRAGOVER)
            //{
            //    AllForms.m_frmLog.AppendToLog("ID_ONDRAGOVER");
            //}
            //else if (EventDispId == HTMLEventDispIds.ID_ONDRAGENTER)
            //{
            //    AllForms.m_frmLog.AppendToLog("ID_ONDRAGENTER");
            //}
            //else if (EventDispId == HTMLEventDispIds.ID_ONDRAGLEAVE)
            //{
            //    AllForms.m_frmLog.AppendToLog("ID_ONDRAGLEAVE");
            //}

            return bret;
        }
开发者ID:blacklensama,项目名称:1709,代码行数:101,代码来源:frmHTMLeditor.cs

示例5: LoadDataObject

        public bool LoadDataObject(object Src)
        {
            try
            {
                DataObject d = new DataObject(Src);

                if (d.ContainsImage())
                {
                    if (LoadImage(d.GetImage()))
                        return true;
                }

                if (d.ContainsFileDropList())
                {
                    foreach (string FName in d.GetFileDropList())
                    {
                        try
                        {
                            if (LoadImage(FName))
                                return true;

                        }
                        catch
                        {
                        }
                    }
                }

                if (d.ContainsText())
                {
                    string FName = d.GetText().Trim();

                    if ((FName.IndexOf("http://") == 0) ||
                        (FName.IndexOf("https://") == 0))
                    {
                        if (LoadImageFromUrl(FName))
                            return true;

                    }
                    else
                    {
                        if (File.Exists(FName))
                        {
                            if (LoadImage(FName))
                                return true;
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString());

            }
            return false;
        }
开发者ID:metropolian,项目名称:DmScrCap,代码行数:56,代码来源:FormEditor.cs

示例6: m_docelemevents_elemondragend

 void m_docelemevents_elemondragend(object sender, csExWB.HTMLElementEventArgs e)
 {
     /*
      * IHTMLEventObj2::dataTransfer
      * The IHTMLDataTransfer interface retrieved by this method also provides
      * access to IDataObject. Call QueryInterface on the IHTMLDataTransfer
      * interface pointer to obtain an IServiceProvider interface pointer.
      * Then call IServiceProvider::QueryService, using IID_IDataObject
      * for the service and interface identifiers, to obtain an IDataObject
      * interface pointer.
      *
      * IHTMLEventObj2::reason
      */
     //this is the element which data was dropped on
     if ((e.EventObj != null) && (e.EventObj.SrcElement != null))
     {
         IHTMLEventObj2 eveobj2 = e.EventObj as IHTMLEventObj2;
         if ((eveobj2 != null) && (eveobj2.dataTransfer != null))
         {
             IfacesEnumsStructsClasses.IServiceProvider pSP = eveobj2.dataTransfer as IfacesEnumsStructsClasses.IServiceProvider;
             if (pSP != null)
             {
                 IntPtr pdataobj = IntPtr.Zero;
                 int iret = pSP.QueryService(ref Iid_Clsids.IID_IDataObject, ref Iid_Clsids.IID_IDataObject, out pdataobj);
                 object obj = Marshal.GetObjectForIUnknown(pdataobj);
                 System.Runtime.InteropServices.ComTypes.IDataObject idataobj = obj as System.Runtime.InteropServices.ComTypes.IDataObject;
                 DataObject obja = new DataObject(idataobj);
                 //string[] formats = obja.GetFormats(false);
                 //foreach (string str in formats)
                 //{
                 //    AllForms.m_frmLog.AppendToLog("format ==> " + str);
                 //}
                 AllForms.m_frmLog.AppendToLog("HTMLEvent_ONDRAGEND==> " + obja.GetText(TextDataFormat.Html));
             }
         }
     }
     else
         AllForms.m_frmLog.AppendToLog("ID_ONDRAGEND");
 }
开发者ID:aldoblack,项目名称:webknowledge,代码行数:39,代码来源:frmHTMLeditor.cs


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