Пример #1
0
        private void sourceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (selectedNode != null)
            {
                var dialog = new EnterNameDialog(selectedNode.IsDir ? selectedNode.AbsolutePath : workingFolder.Path)
                {
                    Text = "Enter name of a new file"
                };

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        File.Create(dialog.Value).Close();
                    }
                    catch
                    {
                        MessageBox.Show("Unable to create file");
                        return;
                    }

                    workingFolder.SetTreeView(treeView1);
                    treeView1.ExpandAll();
                }
            }
        }
Пример #2
0
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            if (selectedNode != null && !selectedNode.isRoot)
            {
                var dialog = new EnterNameDialog(selectedNode.AbsolutePath)
                {
                    Text = $"Enter new {(selectedNode.IsDir ? "directory" : "file")} name"
                };

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        if (selectedNode.IsDir)
                        {
                            Directory.Move(selectedNode.AbsolutePath, dialog.Value);
                        }
                        else
                        {
                            foreach (TextEditor editor in tabControl1.TabPages)
                            {
                                if (editor.Path == selectedNode.AbsolutePath)
                                {
                                    if (!editor.Close())
                                    {
                                        return;
                                    }

                                    UpdateOpenedTabs();
                                }
                            }

                            File.Move(selectedNode.AbsolutePath, dialog.Value);
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Unable to rename");
                        return;
                    }

                    workingFolder.SetTreeView(treeView1);
                    treeView1.ExpandAll();
                }
            }
        }