/// <summary> /// Create a new folder in the treeview /// </summary> public void CreateFolder() { var selectedNode = tv.SelectedNode; var nfd = new NewFolderDialog { StartPosition = FormStartPosition.CenterParent }; if (nfd.ShowDialog(ParentForm) == DialogResult.OK) { var parts = nfd.FolderName.Split('/'); var currentNode = selectedNode; foreach (var part in parts.Where(x => x.Length > 0)) { var node = new TreeNode(part.Trim()) { ImageIndex = 15, SelectedImageIndex = 15 }; currentNode.Nodes.Add(node); tv.SelectedNode = node; currentNode = node; } } tv.TreeViewNodeSorter = new NodeSorter(); tv.Sort(); }
internal static void AddFolder(TreeView tvWebResources, Control mainControl) { var selectedNode = tvWebResources.SelectedNode; var nfd = new NewFolderDialog { StartPosition = FormStartPosition.CenterParent }; if (nfd.ShowDialog(mainControl) == DialogResult.OK) { var parts = nfd.FolderName.Split('/'); var currentNode = selectedNode; foreach (var part in parts.Where(x => x.Length > 0)) { var node = new TreeNode(part.Trim()) { ImageIndex = 1, SelectedImageIndex = 1 }; currentNode.Nodes.Add(node); tvWebResources.SelectedNode = node; currentNode = node; } } tvWebResources.TreeViewNodeSorter = new NodeSorter(); tvWebResources.Sort(); }
public static void Execute(ContentItem selectedItem, string currentFile) { var addFolderForm = new NewFolderDialog(); var curFolder = selectedItem as ContentFolder ?? selectedItem.Parent; if (addFolderForm.ShowDialog() == DialogResult.OK) { var name = addFolderForm.FileName; var itemPath = Path.Combine(Path.GetDirectoryName(currentFile), selectedItem.getPath()); var folderPath = Path.Combine(itemPath, name); //Check if directory already exists if (Directory.Exists(folderPath)) { MessageBox.Show("Directory already exists!", "Directory exists", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { Directory.CreateDirectory(folderPath); curFolder.AddSubFolder(folderPath, folderPath); } catch (Exception e) { MessageBox.Show("An Error occured during the operation.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private static void AddNewFolder(MyPluginControl plugin) { var newFolderDialog = new NewFolderDialog(plugin.ConnectionDetail?.OrganizationMajorVersion ?? -1); if (newFolderDialog.ShowDialog(plugin) == DialogResult.OK) { plugin.tv.AddSingleFolder(plugin.contextFolderNode, newFolderDialog.FolderName); } }
public override void Run() { var wb = Workbench.Instance; var exp = wb.ActiveSiteExplorer; var connMgr = ServiceRegistry.GetService <ServerConnectionManager>(); var conn = connMgr.GetConnection(exp.ConnectionName); if (exp.SelectedItems.Length == 1) { var item = exp.SelectedItems[0]; if (item.IsFolder) { string defaultName = "New Folder"; //NOXLATE string name = defaultName; int counter = -1; while (item.Contains(name)) { counter++; name = defaultName + counter; } List <string> folderNames = new List <string>(); foreach (var child in item.Children) { if (child.IsFolder) { folderNames.Add(child.Name); } } var diag = new NewFolderDialog(name, folderNames.ToArray()); if (diag.ShowDialog() == System.Windows.Forms.DialogResult.OK) { name = diag.FolderName; //conn.ResourceService.CreateFolder(item.ResourceId + name); conn.ResourceService.SetResourceXmlData($"{item.ResourceId + name}/", null); //NOXLATE var path = item.Model.GetPath(item); item.Model.RaiseStructureChanged(new Aga.Controls.Tree.TreeModelEventArgs(path, new object[0])); //Expand so user can see this new folder exp.ExpandNode(conn.DisplayName, item.ResourceId); exp.SelectNode(conn.DisplayName, $"{item.ResourceId + name}/"); //NOXLATE } } } }
private void buttonNewFolder_Click(object sender, RoutedEventArgs e) { NewFolderDialog newDia = new NewFolderDialog(); newDia.ShowDialog(); String folderName = newDia.FolderTitle; String path = null; if (ExplorerTree.SelectedItem != null) { if (!((TreeViewItem)ExplorerTree.SelectedItem).Tag.ToString().EndsWith(".txt")) { path = ((TreeViewItem)ExplorerTree.SelectedItem).Tag.ToString(); } } controller.CreateFolder(folderName, path); }
private void cmsWebresourceTreeview_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem != tsmiAddNewResource) { cmsWebresourceTreeview.Hide(); } if (e.ClickedItem == tsmiProperties) { if (rpd.IsDisposed) { rpd = new ResourcePropertiesDialog(); } rpd.Resource = contextStripResource; rpd.ShowDocked(); } else if (e.ClickedItem == tsmiSetDependencies) { var dialog = new DependencyDialog(contextStripResource, this); if (dialog.ShowDialog(this) == DialogResult.OK) { contextStripResource.DependencyXml = dialog.UpdatedDependencyXml; } } else if (e.ClickedItem == tsmiCopyNameToClipboard) { Clipboard.SetData(DataFormats.StringFormat, contextStripResource.Name); } else if (e.ClickedItem == tsmiOpenInCrm) { if (contextStripResource.Id == Guid.Empty) { MessageBox.Show(this, @"This web resource does not exist on the CRM organization or is not synced", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Process.Start($"{ConnectionDetail.WebApplicationUrl}/main.aspx?id={contextStripResource.Id}&etc=9333&pagetype=webresourceedit"); } else if (e.ClickedItem == tsmiDelete) { ExecuteMethod(DeleteWebresource, contextStripResource); } else if (e.ClickedItem == tsmiUpdate) { var us = new UpdateResourcesSettings { Webresources = new List <Webresource> { contextStripResource }, }; ExecuteMethod(UpdateWebResources, us); } else if (e.ClickedItem == tsmiUpdatePublish) { var us = new UpdateResourcesSettings { Webresources = new List <Webresource> { contextStripResource }, Publish = true }; ExecuteMethod(UpdateWebResources, us); } else if (e.ClickedItem == tsmiUpdatePublishAdd) { var us = new UpdateResourcesSettings { Webresources = new List <Webresource> { contextStripResource }, Publish = true, AddToSolution = true }; ExecuteMethod(UpdateWebResources, us); } else if (e.ClickedItem == tsmiGetLatest) { try { contextStripResource.GetLatestVersion(); } catch (Exception error) { MessageBox.Show(this, error.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (e.ClickedItem == tsmiRefreshFileFromDisk) { if (string.IsNullOrEmpty(contextStripResource.FilePath)) { MessageBox.Show(this, @"This webresource is not synced with a local file", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } contextStripResource.RefreshFromDisk(); } else if (e.ClickedItem == tsmiUpdateFolderFromDisk) { if (string.IsNullOrEmpty(contextFolderNode.FolderPath)) { MessageBox.Show(this, @"This folder node is not synced with a local folder. Cannot refresh from disk", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var invalidFileNames = new List <string>(); tv.RefreshFolderNodeContent(contextFolderNode, invalidFileNames, null); if (invalidFileNames.Any()) { if (ifnd == null || ifnd.IsDisposed) { ifnd = new InvalidFilenamesDialog(); } ifnd.InvalidFiles = invalidFileNames; ifnd.ShowDocked(DockState.DockBottom); } } else if (e.ClickedItem == tsmiRenameWebresource) { var renameDialog = new RenameWebResourceDialog(contextStripResource.Name, ConnectionDetail?.OrganizationMajorVersion ?? -1); if (renameDialog.ShowDialog(this) == DialogResult.OK) { if (contextStripResource.Name != renameDialog.WebResourceName) { ExecuteMethod(RenameWebresource, renameDialog.WebResourceName); } } } else if (e.ClickedItem == tsmiAddNewFolder) { var newFolderDialog = new NewFolderDialog(ConnectionDetail?.OrganizationMajorVersion ?? -1); if (newFolderDialog.ShowDialog(this) == DialogResult.OK) { tv.AddSingleFolder(contextFolderNode, newFolderDialog.FolderName); } } else if (e.ClickedItem == tsmiAddExistingFile) { var ofd = new OpenFileDialog { Multiselect = true, Title = @"Select file(s) to add as webresource(s)" }; if (ofd.ShowDialog(ParentForm) == DialogResult.OK) { var invalidFileNames = new List <string>(); tv.AddFilesAsNodes(contextFolderNode, ofd.FileNames.ToList(), invalidFileNames); if (invalidFileNames.Any()) { if (ifnd == null || ifnd.IsDisposed) { ifnd = new InvalidFilenamesDialog(); } ifnd.InvalidFiles = invalidFileNames; ifnd.ShowDocked(DockState.DockBottom); } } } else if (e.ClickedItem == tsmiNewCss) { tv.AddNewWebresource(contextFolderNode, WebresourceType.Css); } else if (e.ClickedItem == tsmiNewData) { tv.AddNewWebresource(contextFolderNode, WebresourceType.Data); } else if (e.ClickedItem == tsmiNewHtml) { tv.AddNewWebresource(contextFolderNode, WebresourceType.WebPage); } else if (e.ClickedItem == tsmiNewResx) { tv.AddNewWebresource(contextFolderNode, WebresourceType.Resx); } else if (e.ClickedItem == tsmiNewScript) { tv.AddNewWebresource(contextFolderNode, WebresourceType.Script); } else if (e.ClickedItem == tsmiNewXsl) { tv.AddNewWebresource(contextFolderNode, WebresourceType.Xsl); } else if (e.ClickedItem == tsmiExpand) { contextFolderNode.ExpandAll(); } else if (e.ClickedItem == tsmiCollapse) { contextFolderNode.Collapse(false); } }
public void NewFolder() { var nfd = new NewFolderDialog(); if (nfd.ShowDialog() != DialogResult.OK) return; if (_explorer.tvFiles.SelectedNode != null && _explorer.tvFiles.SelectedNode.Tag.GetType().Name == "Project") { bool found = false; foreach (Folder f in Project.Folders) { if (f.Name != nfd.txtFolderName.Text) continue; Util.ShowError(" Folder Already Exists: " + nfd.txtFolderName.Text + " "); found = true; break; } if (!found) { // Try and create the folder on the filesystem try { Directory.CreateDirectory(Project.Path + @"\" + nfd.txtFolderName.Text); } catch { // XXX: Handle this Util.ShowError("Unable to create folder " + Project.Path + @"\" + nfd.txtFolderName.Text); } var folder = new Folder { Name = nfd.txtFolderName.Text, Project = Project, Parent = null, WorkSpace = this }; Project.Folders.Add(folder); AddProjectFolder(folder); } } else if (_explorer.tvFiles.SelectedNode != null && _explorer.tvFiles.SelectedNode.Tag.GetType().Name == "Folder") { bool found = false; foreach (Folder f in ((Folder) _explorer.tvFiles.SelectedNode.Tag).Folders) { if (f.Name != nfd.txtFolderName.Text) continue; Util.ShowError(" Folder Already Exists: " + nfd.txtFolderName.Text + " "); found = true; break; } if (!found) { StringBuilder filepath = new StringBuilder(Project.Path); // Recurse through the folders (parents) until the parent is null, then work our way back through var ff = ((Folder) _explorer.tvFiles.SelectedNode.Tag); var fldrList = new List<Folder>(); while (ff != null) { fldrList.Add(ff); ff = ff.Parent; } for (int i = fldrList.Count - 1; i >= 0; i--) { if (ff == (_explorer.tvFiles.SelectedNode.Tag)) break; ff = fldrList[i]; filepath.Append(@"\" + ff.Name); } filepath.Append(@"\"); // Try and create the folder on the filesystem try { Directory.CreateDirectory(filepath + nfd.txtFolderName.Text); } catch { } var folder = new Folder { Name = nfd.txtFolderName.Text, Project = Project, Parent = ((Folder) _explorer.tvFiles.SelectedNode.Tag), WorkSpace = this }; // WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF WTF //project.Folders.Add( folder ); // This should fix our little issue.. ((Folder) _explorer.tvFiles.SelectedNode.Tag).Folders.Add(folder); AddProjectFolder(folder); } } }