Exemplo n.º 1
0
        private void renameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedFile == null)
            {
                return;
            }

            EnterValueDialog enterValue = new EnterValueDialog
            {
                Label = "Enter new name :"
            };

            enterValue.SetValue(SelectedFile.Name);
            if (enterValue.ShowDialog() == DialogResult.OK)
            {
                string newName     = enterValue.GetEnteredValue();
                string newFullName = Path.Combine(SelectedFile.DirectoryName, $"{newName}");
                if (Path.GetExtension(newFullName) == null || Path.GetExtension(newFullName) != SelectedFile.Extension)
                {
                    newFullName = newFullName + SelectedFile.Extension;
                }
                SelectedFile.CopyTo(newFullName);
                SelectedFile.Delete();
                BuildTreeView();
            }
        }
Exemplo n.º 2
0
        private void SaveAs(ControlConfigUI control)
        {
            EnterValueDialog dialog = new EnterValueDialog
            {
                Label = "Enter filename :"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string defaultFilename = control.GetDefaultWorkspaceFilename();
                string newFilename     = Path.Combine(Path.GetDirectoryName(defaultFilename),
                                                      $"{Path.GetFileNameWithoutExtension(defaultFilename)}{dialog.GetEnteredValue()}{Path.GetExtension(defaultFilename)}");

                control.Text = Path.GetFileNameWithoutExtension(newFilename);
                control.Tag  = newFilename;

                control.SetWorkspaceFilename(newFilename);
                control.SaveWorkspace();
                FileSysTree.BuildTreeView();
            }
        }