本文整理汇总了C#中EditorContext.Drop方法的典型用法代码示例。如果您正苦于以下问题:C# EditorContext.Drop方法的具体用法?C# EditorContext.Drop怎么用?C# EditorContext.Drop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EditorContext
的用法示例。
在下文中一共展示了EditorContext.Drop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeDrop
/// <summary>
/// Initializes canvas control drag and drop handler.
/// </summary>
/// <param name="context">The editor context instance.</param>
public void InitializeDrop(EditorContext context)
{
canvasControl.AllowDrop = true;
canvasControl.DragEnter +=
(s, e) =>
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop)
&& !e.Data.GetDataPresent(typeof(XGroup))
&& !e.Data.GetDataPresent(typeof(Record))
&& !e.Data.GetDataPresent(typeof(ShapeStyle)))
{
e.Effects = DragDropEffects.None;
e.Handled = true;
}
};
canvasControl.Drop +=
(s, e) =>
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
try
{
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (context.Drop(files))
{
e.Handled = true;
}
}
catch (Exception ex)
{
if (context.Editor.Log != null)
{
context.Editor.Log.LogError("{0}{1}{2}",
ex.Message,
Environment.NewLine,
ex.StackTrace);
}
}
}
if (e.Data.GetDataPresent(typeof(XGroup)))
{
try
{
var group = e.Data.GetData(typeof(XGroup)) as XGroup;
if (group != null)
{
var p = e.GetPosition(canvasControl);
context.DropAsClone(group, p.X, p.Y);
e.Handled = true;
}
}
catch (Exception ex)
{
if (context.Editor.Log != null)
{
context.Editor.Log.LogError("{0}{1}{2}",
ex.Message,
Environment.NewLine,
ex.StackTrace);
}
}
}
if (e.Data.GetDataPresent(typeof(Record)))
{
try
{
var record = e.Data.GetData(typeof(Record)) as Record;
if (record != null)
{
var p = e.GetPosition(canvasControl);
context.Drop(record, p.X, p.Y);
e.Handled = true;
}
}
catch (Exception ex)
{
if (context.Editor.Log != null)
{
context.Editor.Log.LogError("{0}{1}{2}",
ex.Message,
Environment.NewLine,
ex.StackTrace);
}
}
}
if (e.Data.GetDataPresent(typeof(ShapeStyle)))
{
try
{
var style = e.Data.GetData(typeof(ShapeStyle)) as ShapeStyle;
if (style != null)
//.........这里部分代码省略.........