本文整理汇总了C#中DragDropEffects.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# DragDropEffects.ToString方法的具体用法?C# DragDropEffects.ToString怎么用?C# DragDropEffects.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DragDropEffects
的用法示例。
在下文中一共展示了DragDropEffects.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoDragDrop
public override void DoDragDrop(IDataObject dataObject, DragDropEffects effect)
{
if (dataObject.GetDataPresent(typeof(FileNode))) {
// Dragging a file onto another creates a dependency.
FileNode other = (FileNode)dataObject.GetData(typeof(FileNode));
LoggingService.Debug("ProjectBrowser: Dragging file '" + other.FileName + "' onto file '" + this.FileName + "'");
// Copy/move the file to the correct directory
// if the target is in a different directory than the source.
if (!FileUtility.IsEqualFileName(Path.GetDirectoryName(this.FileName), Path.GetDirectoryName(other.FileName))) {
LoggingService.Debug("-> Source file is in different directory, performing " + effect.ToString());
ExtTreeNode p = this;
DirectoryNode parentDirectory;
do {
p = (ExtTreeNode)p.Parent;
parentDirectory = p as DirectoryNode;
} while (parentDirectory == null && p != null);
if (parentDirectory == null) {
throw new InvalidOperationException("File '" + this.FileName + "' does not have a parent directory.");
}
LoggingService.Debug("-> Copying/Moving source file to parent directory of target: " + parentDirectory.Directory);
string otherFileName = Path.GetFileName(other.FileName);
parentDirectory.CopyFileHere(other, effect == DragDropEffects.Move);
// Find the copied or moved file node again
other = parentDirectory.AllNodes.OfType<FileNode>().SingleOrDefault(n => FileUtility.IsEqualFileName(Path.GetFileName(n.FileName), otherFileName));
}
if (other != null) {
other.Remove();
((FileProjectItem)other.ProjectItem).DependentUpon = Path.GetFileName(this.FileName);
other.FileNodeStatus = FileNodeStatus.BehindFile;
other.InsertSorted(this);
LoggingService.Debug("-> Created new dependency, saving solution");
ProjectService.SaveSolution();
} else {
LoggingService.Debug("-> Could not find the copied or moved file node in the new parent directory.");
}
return;
}
((ExtTreeNode)Parent).DoDragDrop(dataObject, effect);
}
示例2: DoDragDrop
public override void DoDragDrop(IDataObject dataObject, DragDropEffects effect)
{
PerformInitialization();
Expand();
try {
if (dataObject.GetDataPresent(typeof(FileNode))) {
FileNode fileNode = (FileNode)dataObject.GetData(typeof(FileNode));
LoggingService.Debug("ProjectBrowser: Dragging file '" + fileNode.FileName + "' onto directory '" + this.Directory + "'");
if (!FileUtility.IsEqualFileName(Directory, fileNode.FileName) && !FileUtility.IsEqualFileName(Directory, Path.GetDirectoryName(fileNode.FileName))
&& !(fileNode.ProjectItem is FileProjectItem && FileUtility.IsEqualFileName(Directory, Path.GetDirectoryName(GetFullVirtualName((FileProjectItem)fileNode.ProjectItem))))) {
LoggingService.Debug("-> Not in same directory, performing " + effect.ToString());
CopyFileHere(fileNode, effect == DragDropEffects.Move);
} else {
// Dragging a dependent file onto its parent directory
// removes the dependency.
LoggingService.Debug("-> In same directory, removing dependency");
((FileProjectItem)fileNode.ProjectItem).DependentUpon = String.Empty;
fileNode.Remove();
if (!File.Exists(fileNode.FileName)) {
fileNode.FileNodeStatus = FileNodeStatus.Missing;
} else {
fileNode.FileNodeStatus = FileNodeStatus.InProject;
}
fileNode.InsertSorted(this);
}
} else if (dataObject.GetDataPresent(typeof(DirectoryNode))) {
DirectoryNode directoryNode = (DirectoryNode)dataObject.GetData(typeof(DirectoryNode));
CopyDirectoryHere(directoryNode, effect == DragDropEffects.Move);
} else if (dataObject.GetDataPresent(DataFormats.FileDrop)) {
string[] files = (string[])dataObject.GetData(DataFormats.FileDrop);
foreach (string fileName in files) {
if (System.IO.Directory.Exists(fileName)) {
if (!FileUtility.IsBaseDirectory(fileName, Directory)) {
CopyDirectoryHere(fileName, false);
}
} else {
CopyFileHere(fileName, false);
}
}
}
ProjectService.SaveSolution();
} catch (Exception e) {
MessageService.ShowException(e);
}
}
示例3: ToNative
private NativeDragDropEffects ToNative(DragDropEffects dragDropEffects)
{
NativeDragDropEffects nativeDragDropEffects;
if (!NativeDragDropEffects.TryParse (dragDropEffects.ToString(), true, out nativeDragDropEffects))
throw new Exception ("Invalid effect");
return nativeDragDropEffects;
}