本文整理汇总了C#中DragDropInfo类的典型用法代码示例。如果您正苦于以下问题:C# DragDropInfo类的具体用法?C# DragDropInfo怎么用?C# DragDropInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DragDropInfo类属于命名空间,在下文中一共展示了DragDropInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleDataDropped
/// <summary>
/// Called when a file is dropped onto the TextView
/// </summary>
/// <param name="dragDropInfo"></param>
/// <returns></returns>
public DragDropPointerEffects HandleDataDropped(DragDropInfo dragDropInfo)
{
// This function is basically doing three things:
// 1. Detects user drop position and on ambiguity asks user if replace current link.
// 2. Detects if user provided file's valid path (in Documentation/Source hierarchy)
// exists. If it does, then asks user if the file should be overwritten and copy
// the file as needed.
// 3. Replaces or appends a valid link.
try
{
var spanToReplace = GetSpanToReplace(dragDropInfo); // 1.
var referenceText = CreateReference(dragDropInfo); // 2.
using (var editTextView = TextView.TextBuffer.CreateEdit())
{
editTextView.Replace(spanToReplace, referenceText);
editTextView.Apply();
}
}
catch (OperationCanceledException)
{
// ignore as it is just stopping the whole operation
}
return DragDropPointerEffects.Link;
}
示例2: GetNodes
public IEnumerable<Node> GetNodes(DragDropInfo dragDropInfo)
{
try
{
if (!dragDropInfo.Data.GetDataPresent(PROJECTITEMFORMAT))
{
_log.Debug("Data not found");
return null;
}
// create nodes from the projectitems
var data = dragDropInfo.Data.GetData(PROJECTITEMFORMAT);
var nodeIsProject = false;
var droppedData = SolutionExplorerNodeData.DecodeProjectItemData(dragDropInfo.Data, nodeIsProject);
// find the nodes in the solution
var solutionItems = findSolutionItems(droppedData);
if (solutionItems != null) return solutionItems;
_log.Debug("FAiled to find items in IVSHierarchy. Generating items based on filename only");
var nodes = droppedData.Select(x => new Node() {Type = getClassNameFromFileName(x.FileName)});
_log.Debug("Found data");
return nodes;
}
catch (Exception e)
{
throw new Exception("GetNodes failed", e);
}
return null;
}
示例3: GetDragDropInfo
private static DragDropInfo GetDragDropInfo(UIElement target, DragEventArgs e,
PokemonDragDropData data)
{
var dragDropInfo = new DragDropInfo();
dragDropInfo.Action = DragDropActions.None;
int folderIndex = DragDropState.GetDraggingOverIndex(target);
var collection = (target as FrameworkElement).DataContext as CollectionViewModel;
if (collection != null && folderIndex != -1)
{
dragDropInfo.TargetFolder = collection.Folders[folderIndex];
if (dragDropInfo.TargetFolder.CanAddPokemon)
{
if (e.KeyStates.HasFlag(DragDropKeyStates.ControlKey))
{
dragDropInfo.Action = DragDropActions.CopyTo;
}
else if (dragDropInfo.TargetFolder != data.SourceFolder)
{
dragDropInfo.Action = DragDropActions.MoveTo;
}
}
}
return dragDropInfo;
}
示例4: HandleDataDropped
public DragDropPointerEffects HandleDataDropped(DragDropInfo dragDropInfo) {
Task.Run(async () => {
var folder = await GetRUserFolder();
_editorShell.DispatchOnUIThread(() => HandleDrop(dragDropInfo, folder));
}).DoNotWait();
return DragDropPointerEffects.None;
}
示例5: CanUnderstand
public bool CanUnderstand(DragDropInfo dragDropInfo)
{
if (!dragDropInfo.Data.GetDataPresent(PROJECTITEMFORMAT))
{
return false;
}
return true;
}
示例6: IsDropEnabled
public bool IsDropEnabled(DragDropInfo dragDropInfo)
{
_filename = FontDropHandler.GetImageFilename(dragDropInfo);
if (string.IsNullOrEmpty(_filename))
return false;
return this._imageExtensions.Contains(Path.GetExtension(_filename));
}
示例7: IsDropEnabled
public bool IsDropEnabled(DragDropInfo dragDropInfo)
{
_draggedFileName = GetImageFilename(dragDropInfo);
string ext = Path.GetExtension(_draggedFileName);
if (!_imageExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase))
return false;
return File.Exists(_draggedFileName) || Directory.Exists(_draggedFileName);
}
示例8: Execute
public override IExecuteResult Execute(IEnumerable<Node> nodes, IWpfTextView textView,
DragDropInfo dragDropInfo)
{
var msg = string.Format("You dropped:\n{0}",
string.Join("\n",
nodes.Select(x => string.Format("{0}.{1}.{2}.{3}", x.Assembly, x.Namespace, x.Type, x.Member))));
_log.Debug(msg);
MessageBox.Show(msg);
return ExecuteResult.None;
}
示例9: HandleDataDropped
/// <summary>
/// See <see cref="IDropHandler.HandleDataDropped"/> for more information.
/// </summary>
/// <param name="dragDropInfo"></param>
/// <returns></returns>
public DragDropPointerEffects HandleDataDropped(DragDropInfo dragDropInfo)
{
try
{
manager.AddImageAdornment(manager.PreviewImageAdornment.VisualElement);
return DragDropPointerEffects.Copy;
}
finally
{
RemovePreviewImage();
}
}
示例10: IsDropEnabled
public bool IsDropEnabled(DragDropInfo dragDropInfo)
{
_imageFilename = dragDropInfo.GetFilePath();
if (string.IsNullOrEmpty(_imageFilename))
return false;
if (_imageExtensions.Contains(Path.GetExtension(_imageFilename)))
return true;
return false;
}
示例11: IsDropEnabled
public bool IsDropEnabled(DragDropInfo dragDropInfo)
{
_fileName = GetImageFilename(dragDropInfo);
if (string.IsNullOrEmpty(_fileName) || !CommandHelpers.IsFileSupported(_fileName) || _dte.ActiveDocument == null)
return false;
string activeFile = Path.GetFileName(_dte.ActiveDocument.FullName);
if (Constants.FILENAME.Equals(activeFile, StringComparison.OrdinalIgnoreCase))
return true;
return false;
}
示例12: IsDropEnabled
public bool IsDropEnabled(DragDropInfo dragDropInfo)
{
_imageFilename = FontDropHandler.GetImageFilename(dragDropInfo);
if (!string.IsNullOrEmpty(_imageFilename))
{
string fileExtension = Path.GetExtension(_imageFilename).ToLowerInvariant();
if (this._imageExtensions.Contains(fileExtension))
{
return true;
}
}
return false;
}
示例13: HandleDataDropped
public DragDropPointerEffects HandleDataDropped(DragDropInfo dragDropInfo)
{
string reference = FileHelpers.RelativePath(EditorExtensionsPackage.DTE.ActiveDocument.FullName, _imageFilename);
if (reference.Contains("://"))
{
int index = reference.IndexOf('/', 12);
if (index > -1)
reference = reference.Substring(index).ToLowerInvariant();
}
_view.TextBuffer.Insert(dragDropInfo.VirtualBufferPosition.Position.Position, string.Format(_background, reference));
return DragDropPointerEffects.Copy;
}
示例14: HandleDataDropped
public DragDropPointerEffects HandleDataDropped(DragDropInfo dragDropInfo)
{
string reference = FileHelpers.RelativePath(ProjectHelpers.GetRootFolder(), _draggedFilename);
if (reference.StartsWith("http://localhost:"))
{
int index = reference.IndexOf('/', 20);
if (index > -1)
reference = reference.Substring(index + 1).ToLowerInvariant();
}
_view.TextBuffer.Insert(dragDropInfo.VirtualBufferPosition.Position.Position, string.Format(_format, reference));
return DragDropPointerEffects.Copy;
}
示例15: HandleDraggingOver
public DragDropPointerEffects HandleDraggingOver(DragDropInfo dragDropInfo)
{
try
{
//set the insertion point to follow the drop location
_tgt.Caret.MoveTo(dragDropInfo.VirtualBufferPosition);
return DragDropPointerEffects.Copy;
}
catch (Exception e)
{
_log.Error("HandleDraggingOver", e );
}
return DragDropPointerEffects.Copy;
}