本文整理汇总了C#中System.Windows.Forms.DataObject.ContainsFileDropList方法的典型用法代码示例。如果您正苦于以下问题:C# DataObject.ContainsFileDropList方法的具体用法?C# DataObject.ContainsFileDropList怎么用?C# DataObject.ContainsFileDropList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DataObject
的用法示例。
在下文中一共展示了DataObject.ContainsFileDropList方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
示例2: TestAudio
public void TestAudio ()
{
DataObject d = new DataObject ();
byte[] b = new byte[] { 1, 2, 3 };
d.SetAudio (b);
Assert.AreEqual (true, d.ContainsAudio (), "A1");
Assert.AreEqual (false, d.ContainsFileDropList (), "A2");
Assert.AreEqual (false, d.ContainsImage (), "A3");
Assert.AreEqual (false, d.ContainsText (), "A4");
Assert.AreEqual (false, d.ContainsText (TextDataFormat.CommaSeparatedValue), "A5");
Assert.AreEqual (b.Length, d.GetAudioStream ().Length, "A6");
}
示例3: TestImage
public void TestImage ()
{
DataObject d = new DataObject ();
Image i = new Bitmap (16, 16);
d.SetImage (i);
Assert.AreEqual (false, d.ContainsAudio (), "A1");
Assert.AreEqual (false, d.ContainsFileDropList (), "A2");
Assert.AreEqual (true, d.ContainsImage (), "A3");
Assert.AreEqual (false, d.ContainsText (), "A4");
Assert.AreEqual (false, d.ContainsText (TextDataFormat.CommaSeparatedValue), "A5");
Assert.AreSame (i, d.GetImage (), "A6");
}
示例4: TestFileDrop
public void TestFileDrop ()
{
DataObject d = new DataObject ();
StringCollection sc = new StringCollection ();
sc.AddRange (new string[] {"A", "B", "C"});
d.SetFileDropList (sc);
Assert.AreEqual (false, d.ContainsAudio (), "A1");
Assert.AreEqual (true, d.ContainsFileDropList (), "A2");
Assert.AreEqual (false, d.ContainsImage (), "A3");
Assert.AreEqual (false, d.ContainsText (), "A4");
Assert.AreEqual (false, d.ContainsText (TextDataFormat.CommaSeparatedValue), "A5");
Assert.AreEqual (sc.Count, d.GetFileDropList ().Count, "A6");
}
示例5: treeView_DragOver
private void treeView_DragOver(object sender, DragEventArgs e)
{
DataObject o = new DataObject(e.Data);
if (o.ContainsFileDropList()) {
FileTreeNode node = (FileTreeNode)treeView.GetNodeAt(treeView.PointToClient(new Point(e.X, e.Y)));
if (node != null && node.File.Type == FileSystemObjectType.Directory) {
if ((e.AllowedEffect & DragDropEffects.Move) != 0 && (e.KeyState & 8) == 0) // Ctrl is pressed
{
e.Effect = DragDropEffects.Move;
return;
}
else if ((e.AllowedEffect & DragDropEffects.Copy) != 0) {
e.Effect = DragDropEffects.Copy;
return;
}
}
}
e.Effect = DragDropEffects.None;
}
示例6: treeView_DragDrop
private void treeView_DragDrop(object sender, DragEventArgs e)
{
DataObject o = new DataObject(e.Data);
if (o.ContainsFileDropList()) {
FileTreeNode node = (FileTreeNode)treeView.GetNodeAt(treeView.PointToClient(new Point(e.X, e.Y)));
if (node != null && node.File.Type == FileSystemObjectType.Directory) {
StringCollection files = o.GetFileDropList();
Paste(node, files, e.Effect == DragDropEffects.Move ? false : true);
}
}
}
示例7: 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;
}