private void trvResources_DragOver(object sender, DragEventArgs e) { var data = e.Data.GetData(typeof(RepositoryHandle[])) as RepositoryHandle[]; if (data == null) { SiteExplorerDragDropHandler.OnDragEnter(this, e); } else { //See if the mouse is currently over a node var node = trvResources.GetNodeAt(trvResources.PointToClient(new Point(e.X, e.Y))); if (node == null) { e.Effect = DragDropEffects.None; return; } //Is it a folder? var item = node.Tag as RepositoryItem; if (item != null && item.IsFolder) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } } }
private void trvResources_DragDrop(object sender, DragEventArgs e) { var data = e.Data.GetData(typeof(RepositoryHandle[])) as RepositoryHandle[]; if (data == null) { //See if the mouse is currently over a node var node = trvResources.GetNodeAt(trvResources.PointToClient(new Point(e.X, e.Y))); SiteExplorerDragDropHandler.OnDragDrop(this, e, node); } else { //See if the mouse is currently over a node var node = trvResources.GetNodeAt(trvResources.PointToClient(new Point(e.X, e.Y))); if (node == null) { return; } //Can only drop in a folder var item = node.Tag as RepositoryItem; if (item != null && item.IsFolder) { string connectionName = RepositoryTreeModel.GetParentConnectionName(item); string folderId = item.ResourceId; if (data.Length < 0) { return; } if (data.First().Connection.DisplayName == connectionName) { //I think it's nice to ask for confirmation if (data.Length > 0) { if (!MessageService.AskQuestion(Strings.ConfirmMove)) { return; } } string[] folders = MoveResourcesWithinConnection(connectionName, data.Select(x => x.ResourceId.ToString()).ToArray(), folderId); foreach (var fid in folders) { LoggingService.Info($"Refreshing: {fid} on {connectionName}"); //NOXLATE RefreshModel(connectionName, fid); } } else { /* * Consider the following layout: * * ConnectionA (Root): * Samples * Sheboygan * Data * *.FeatureSource * Layers * *.LayerDefinition * Maps * *.MapDefinition * * ConnectionB (Root): * Foo * Bar * Snafu * * These are the possible scenarios and outcomes: * * Case 1 - Copy folder Samples/Sheboygan/Data into ConnectionB root: * * Expect: * * ConnectionB (Root): * Data * *.FeatureSource * Foo * Bar * Snafu * * Case 2 - Copy Samples/Sheboygan/Data/*.FeatureSource into ConnectionB root: * * Expect: * * ConnectionB (Root): * *.FeatureSource * Foo * Bar * Snafu * * Case 3 - Copy Samples/Sheboygan/Data/*.FeatureSource into Connection B/Foo: * * Expect: * * ConnectionB (Root): * Foo * *.FeatureSource * Bar * Snafu * * Case 4 - Copy Samples/Sheboygan/Data into Connection B/Foo: * * Expect: * * ConnectionB (Root): * Foo * Data * *.FeatureSource * Bar * Snafu * * Case 5 - Copy Samples/Sheboygan/Data into Connection B/Bar/Snafu: * * Expect: * * ConnectionB (Root): * Foo * Bar * Snafu * Data * *.FeatureSource * * Case 6 - Copy Samples/Sheboygan/Data/*.FeatureSource into Connection B/Bar/Snafu: * * ConnectionB (Root): * Foo * Bar * Snafu * *.FeatureSource * */ if (data.All(x => x.ResourceId.IsFolder)) { if (data.Length > 1) { //folderId = GetCommonParent(data); CopyResourcesToFolder(data, connectionName, folderId); } else { folderId += data.First().ResourceId.Name + "/"; CopyResourcesToFolder(data, connectionName, folderId); } } else { CopyResourcesToFolder(data, connectionName, folderId); } } } } }