示例#1
0
        public async void AddNewFolder()
        {
            // Expand the project node before adding the file to the project. This fixes a problem where if the
            // project node is collapsed and Refresh was used the project node would not expand and the new folder
            // node would not be selected.
            CurrentNode.Expanded = true;

            var    project        = CurrentNode.GetParentDataItem(typeof(Project), true) as Project;
            string baseFolderPath = GetFolderPath(CurrentNode.DataItem);

            FilePath folder = await NewFolderDialog.Open(baseFolderPath);

            if (folder.IsNull)
            {
                return;
            }

            var newFolder = new ProjectFile(folder);

            newFolder.Subtype = Subtype.Directory;
            project.Files.Add(newFolder);

            Tree.AddNodeInsertCallback(new ProjectFolder(folder, project), new TreeNodeCallback(OnFileInserted));

            await IdeApp.ProjectOperations.SaveAsync(project);
        }
示例#2
0
        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();
        }
示例#3
0
        /// <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();
        }
示例#4
0
        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);
                }
            }
        }
示例#5
0
        private void buttonNewFolder_Click(object sender, RoutedEventArgs e)
        {
            NewFolderDialog newfDia = new NewFolderDialog();

            newfDia.Closed      += new EventHandler(newfDia_Closed);
            newfDia.SelectedItem = (TreeViewItem)ExplorerTree.SelectedItem;
            newfDia.Show();
        }
        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);
            }
        }
示例#7
0
 public void Rename()
 {
     var           newFileDialog = new NewFolderDialog();
     ContentDialog contentDialog = new ContentDialog()
     {
         Title               = "重命名",
         Content             = newFileDialog,
         PrimaryButtonText   = "确定",
         SecondaryButtonText = "取消"
     };
 }
示例#8
0
        private static void AddCreateFolderToTreeViewItem(TreeViewItem treeViewItem, string path)
        {
            if (treeViewItem.ContextMenu == null)
            {
                treeViewItem.ContextMenu = new ContextMenu();
            }
            var createItem = new MenuItem();

            createItem.Header = "New Folder";
            createItem.Click += (sender, args) =>
            {
                var dialog = new NewFolderDialog(path);
                dialog.Show();
            };
            treeViewItem.ContextMenu.Items.Add(createItem);
        }
示例#9
0
        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
                    }
                }
            }
        }
示例#10
0
        private void newfDia_Closed(object sender, EventArgs args)
        {
            NewFolderDialog newfDia        = (NewFolderDialog)sender;
            int             parentFolderId = -1;

            if (newfDia.SelectedItem != null) //an item is  chosen
            {
                TreeViewItem item = (TreeViewItem)newfDia.SelectedItem;

                //it is a folder, and not a file
                if ((bool)((object[])item.Tag)[2] == true)
                {
                    parentFolderId = int.Parse(((object[])item.Tag)[0].ToString());
                }
            }

            controller.CreateFolder(newfDia.FolderTitle, parentFolderId);
        }
示例#11
0
        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);
        }
示例#12
0
        public async void NewFolder()
        {
            NewFolderDialog newFolderDialog = new NewFolderDialog();

            ContentDialog contentDialog = new ContentDialog()
            {
                Content             = newFolderDialog,
                PrimaryButtonText   = "确定",
                SecondaryButtonText = "取消"
            };

            contentDialog.PrimaryButtonClick += (sender, e) =>
            {
                string str = AreFolderName(newFolderDialog.FolderName).Trim();
                if (!string.IsNullOrEmpty(str))
                {
                    newFolderDialog.Reminder = str;
                }
                else
                {
                    try
                    {
                        Folder.NewFolder(newFolderDialog.FolderName);
                        ListVirtualStorage();
                        newFolderDialog.Complete = true;
                    }
                    catch (Exception)
                    {
                        newFolderDialog.Reminder = "文件夹存在";
                    }
                }
            };

            contentDialog.SecondaryButtonClick += (sender, e) =>
            {
                newFolderDialog.Complete = true;
            };

            while (!newFolderDialog.Complete)
            {
                await contentDialog.ShowAsync();
            }
        }
        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);
            }
        }
示例#14
0
文件: Workspace.cs 项目: itsbth/GLuaR
        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);
                }
            }
        }