当前位置: 首页>>代码示例>>C#>>正文


C# DragDropEffects.ToString方法代码示例

本文整理汇总了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);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:46,代码来源:FileNode.cs

示例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);
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:46,代码来源:DirectoryNode.cs

示例3: ToNative

 private NativeDragDropEffects ToNative(DragDropEffects dragDropEffects)
 {
     NativeDragDropEffects nativeDragDropEffects;
       if (!NativeDragDropEffects.TryParse (dragDropEffects.ToString(), true, out nativeDragDropEffects))
     throw new Exception ("Invalid effect");
       return nativeDragDropEffects;
 }
开发者ID:rubicon-oss,项目名称:DesktopGap,代码行数:7,代码来源:DocumentHostUIHandler.cs


注:本文中的DragDropEffects.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。