本文整理汇总了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;
}
示例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;
}
示例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");
}
示例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;
}
示例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;
}
示例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");
}