本文整理汇总了C#中System.Windows.DragEventArgs.CanHandleOutlookAttachment方法的典型用法代码示例。如果您正苦于以下问题:C# DragEventArgs.CanHandleOutlookAttachment方法的具体用法?C# DragEventArgs.CanHandleOutlookAttachment怎么用?C# DragEventArgs.CanHandleOutlookAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.DragEventArgs
的用法示例。
在下文中一共展示了DragEventArgs.CanHandleOutlookAttachment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fileLine_Drop
private void fileLine_Drop(object sender, DragEventArgs e)
{
if (!DropFile)
return;
string[] files = null;
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files == null || files.IsEmpty())
return;
if (files.Length != 1)
throw new ApplicationException(FileMessage.OnlyOneFileIsSupported.NiceToString());
}
else if (e.CanHandleOutlookAttachment())
{
var tuples = e.DropOutlookAttachment();
if (tuples.Count != 1)
throw new ApplicationException(FileMessage.OnlyOneFileIsSupported.NiceToString());
var tuple = tuples.SingleEx();
int i = 0;
var tPath = System.IO.Path.GetTempPath();
while (File.Exists(System.IO.Path.Combine(tPath, tuple.Item1)))
{
tPath = System.IO.Path.Combine(tPath, i.ToString());
if (!Directory.Exists(tPath))
Directory.CreateDirectory(tPath);
i++;
}
string fileName = System.IO.Path.Combine(tPath, tuple.Item1);
File.WriteAllBytes(fileName, tuple.Item2);
files = new[] { fileName };
}
else
{
return;
}
object file = CreateFile(files.Single());
if (file != null)
this.Entity = file;
}
示例2: fileLine_DragEnter
private void fileLine_DragEnter(object sender, DragEventArgs e)
{
if (!DropFile)
return;
if (!e.Data.GetDataPresent(DataFormats.FileDrop) && !e.CanHandleOutlookAttachment())
{
e.Effects = DragDropEffects.None;
e.Handled = true;
}
}