-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPanelComandCreateDirectory.cs
More file actions
78 lines (71 loc) · 2.81 KB
/
Copy pathPanelComandCreateDirectory.cs
File metadata and controls
78 lines (71 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using netCommander.FileSystemEx;
using System.IO;
namespace netCommander
{
public class PanelComandCreateDirectory : PanelCommandBase
{
public PanelComandCreateDirectory()
{
ToolStripMenuItem menu = new ToolStripMenuItem();
menu.ShortcutKeys = Keys.F7;
menu.ShowShortcutKeys = true;
menu.Text = "Create directory";
CommandMenu = menu;
}
protected override void internal_command_proc()
{
QueryPanelInfoEventArgs e_current = new QueryPanelInfoEventArgs();
QueryPanelInfoEventArgs e_other = new QueryPanelInfoEventArgs();
OnQueryCurrentPanel(e_current);
OnQueryOtherPanel(e_other);
DirectoryList dl_current = (DirectoryList)e_current.ItemCollection;
DirectoryList dl_other = null;
if (e_other.ItemCollection is DirectoryList)
{
dl_other = (DirectoryList)e_other.ItemCollection;
}
//prepare dialog
CreateDirectoryDialog dialog = new CreateDirectoryDialog();
dialog.Text = "Create directory";
dialog.labelParentDir.Text = dl_current.DirectoryPath + Path.DirectorySeparatorChar;
dialog.checkBoxUseTemplate.Checked = false;
dialog.textBoxTemplateDirectory.Enabled = false;
if ((dl_other == null) || (e_other.FocusedIndex <= 0))
{
dialog.checkBoxUseTemplate.Checked = false;
dialog.textBoxTemplateDirectory.Enabled = false;
}
else
{
dialog.textBoxTemplateDirectory.Text = Path.Combine(dl_other.DirectoryPath, dl_other.GetItemDisplayNameLong(e_other.FocusedIndex));
}
if (dialog.ShowDialog() != DialogResult.OK)
{
return;
}
if (dialog.textBoxDirectoryName.Text == string.Empty)
{
Messages.ShowMessage("Directory exists.");
return;
}
string new_directory_name = Path.Combine(dl_current.DirectoryPath, dialog.textBoxDirectoryName.Text);
string template_dir = string.Empty;
if (dialog.checkBoxUseTemplate.Checked)
{
template_dir = dialog.textBoxTemplateDirectory.Text;
}
try
{
Wrapper.CreateDirectoryTree(new_directory_name, template_dir);
}
catch (Exception ex)
{
Messages.ShowException(ex, string.Format("Failed to create directory '{0}'.", new_directory_name));
}
}
}
}