I believe the profile manager is finally done for now, I hope.... Added regex patterns to the folder groups to have a standard way to format file names in a given group.

This commit is contained in:
Admin
2020-11-09 22:20:19 -06:00
parent 9f090b0539
commit 8abded6731
4 changed files with 447 additions and 172 deletions
Binary file not shown.
+52 -9
View File
@@ -75,7 +75,7 @@ namespace DataOrganizer
reader.Close(); reader.Close();
command.CommandText = "SELECT root_id, name, path FROM folder_root WHERE profile_id = @ID ORDER BY name"; command.CommandText = "SELECT root_id, name, path, pattern_id FROM folder_root WHERE profile_id = @ID ORDER BY name";
foreach(var profile in profiles) foreach(var profile in profiles)
{ {
@@ -90,7 +90,8 @@ namespace DataOrganizer
{ {
Name = reader["name"].ToString(), Name = reader["name"].ToString(),
Id = Convert.ToInt32(reader["root_id"]), Id = Convert.ToInt32(reader["root_id"]),
Path = reader["path"].ToString() Path = reader["path"].ToString(),
PatternId = Convert.ToInt32(reader["pattern_id"])
}); });
} }
@@ -147,7 +148,7 @@ namespace DataOrganizer
id = Convert.ToInt32(command.ExecuteScalar()); id = Convert.ToInt32(command.ExecuteScalar());
command.CommandText = "INSERT INTO main.folder_root (name, path, profile_id) VALUES (@Name, @Path, @ProfileID)"; command.CommandText = "INSERT INTO main.folder_root (name, path, profile_id, pattern_id) VALUES (@Name, @Path, @ProfileID, @Pattern)";
if (profile.FolderGroups != null) if (profile.FolderGroups != null)
{ {
@@ -157,6 +158,7 @@ namespace DataOrganizer
command.Parameters.AddWithValue("Name", group.Name); command.Parameters.AddWithValue("Name", group.Name);
command.Parameters.AddWithValue("Path", group.Path); command.Parameters.AddWithValue("Path", group.Path);
command.Parameters.AddWithValue("ProfileID", id); command.Parameters.AddWithValue("ProfileID", id);
command.Parameters.AddWithValue("Pattern", group.PatternId);
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
@@ -170,9 +172,9 @@ namespace DataOrganizer
return id; return id;
} }
public int InsertNewFolderGroup(Profile profile, string name, string path) public int InsertNewFolderGroup(Profile profile, string name, string path, int pattern_id)
{ {
var query = @"INSERT INTO main.folder_root (name, path, profile_id) VALUES (@Name, @Path, @ProfileID)"; var query = @"INSERT INTO main.folder_root (name, path, profile_id, pattern_id) VALUES (@Name, @Path, @ProfileID, @Pattern)";
var id = -1; var id = -1;
using (var connection = new SqliteConnection(ConnectionString)) using (var connection = new SqliteConnection(ConnectionString))
@@ -182,6 +184,7 @@ namespace DataOrganizer
command.Parameters.AddWithValue("Name", name); command.Parameters.AddWithValue("Name", name);
command.Parameters.AddWithValue("Path", path); command.Parameters.AddWithValue("Path", path);
command.Parameters.AddWithValue("ProfileID", profile.Id); command.Parameters.AddWithValue("ProfileID", profile.Id);
command.Parameters.AddWithValue("Pattern", pattern_id);
connection.Open(); connection.Open();
@@ -196,16 +199,18 @@ namespace DataOrganizer
return id; return id;
} }
public bool UpdateFolderGroup(string newName, string path) public bool UpdateFolderGroup(FolderGroup group)
{ {
var query = @"UPDATE main.folder_root SET name = @Name, path = @Path"; var query = @"UPDATE main.folder_root SET name = @Name, path = @Path, pattern_id = @Pattern WHERE root_id = @ID";
using (var connection = new SqliteConnection(ConnectionString)) using (var connection = new SqliteConnection(ConnectionString))
{ {
using (var command = new SqliteCommand(query, connection)) using (var command = new SqliteCommand(query, connection))
{ {
command.Parameters.AddWithValue("Name", newName); command.Parameters.AddWithValue("Name", group.Name);
command.Parameters.AddWithValue("Path", path); command.Parameters.AddWithValue("Path", group.Path);
command.Parameters.AddWithValue("Pattern", group.PatternId);
command.Parameters.AddWithValue("ID", group.Id);
connection.Open(); connection.Open();
@@ -272,6 +277,35 @@ namespace DataOrganizer
return true; return true;
} }
public List<Namingconvention> GetNamingConventions()
{
var conventions = new List<Namingconvention>();
var query = @"SELECT name, example_text, pattern_id, regex FROM main.naming_pattern";
using (var connection = new SqliteConnection(ConnectionString))
{
using (var command = new SqliteCommand(query, connection))
{
connection.Open();
var reader = command.ExecuteReader();
while (reader.Read())
{
conventions.Add(new Namingconvention
{
Regex = reader["regex"].ToString(),
Name = reader["name"].ToString(),
ExampleText = reader["example_text"].ToString(),
Id = Convert.ToInt32(reader["pattern_id"])
});
}
}
}
return conventions;
}
public struct Profile public struct Profile
{ {
public string Name; public string Name;
@@ -286,6 +320,15 @@ namespace DataOrganizer
public int Id; public int Id;
public string Name; public string Name;
public string Path; public string Path;
public int PatternId;
}
public struct Namingconvention
{
public int Id;
public string Name;
public string ExampleText;
public string Regex;
} }
} }
} }
+136 -68
View File
@@ -33,7 +33,6 @@
this.ProfilesComboBox = new System.Windows.Forms.ComboBox(); this.ProfilesComboBox = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.ProfileInfoPanel = new System.Windows.Forms.Panel(); this.ProfileInfoPanel = new System.Windows.Forms.Panel();
this.ProfileInfoGroupBox = new System.Windows.Forms.GroupBox();
this.InsertGroupName = new System.Windows.Forms.Button(); this.InsertGroupName = new System.Windows.Forms.Button();
this.DeleteProfileButton = new System.Windows.Forms.Button(); this.DeleteProfileButton = new System.Windows.Forms.Button();
this.MachineNameTextBox = new System.Windows.Forms.TextBox(); this.MachineNameTextBox = new System.Windows.Forms.TextBox();
@@ -50,11 +49,18 @@
this.FolderGroupPathButton = new System.Windows.Forms.Button(); this.FolderGroupPathButton = new System.Windows.Forms.Button();
this.FolderGroupListView = new System.Windows.Forms.ListView(); this.FolderGroupListView = new System.Windows.Forms.ListView();
this.NameColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.NameColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.PathColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.label5 = new System.Windows.Forms.Label();
this.NamingConventionComboBox = new System.Windows.Forms.ComboBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label7 = new System.Windows.Forms.Label();
this.FolderNameTextBox = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.MainLayoutPanel.SuspendLayout(); this.MainLayoutPanel.SuspendLayout();
this.MainPanel.SuspendLayout(); this.MainPanel.SuspendLayout();
this.ProfileInfoPanel.SuspendLayout(); this.ProfileInfoPanel.SuspendLayout();
this.ProfileInfoGroupBox.SuspendLayout(); this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// MainLayoutPanel // MainLayoutPanel
@@ -69,7 +75,7 @@
this.MainLayoutPanel.RowCount = 2; this.MainLayoutPanel.RowCount = 2;
this.MainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 15F)); this.MainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 15F));
this.MainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 85F)); this.MainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 85F));
this.MainLayoutPanel.Size = new System.Drawing.Size(627, 741); this.MainLayoutPanel.Size = new System.Drawing.Size(1289, 524);
this.MainLayoutPanel.TabIndex = 0; this.MainLayoutPanel.TabIndex = 0;
// //
// MainPanel // MainPanel
@@ -79,14 +85,14 @@
this.MainPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.MainPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.MainPanel.Location = new System.Drawing.Point(3, 3); this.MainPanel.Location = new System.Drawing.Point(3, 3);
this.MainPanel.Name = "MainPanel"; this.MainPanel.Name = "MainPanel";
this.MainPanel.Size = new System.Drawing.Size(621, 105); this.MainPanel.Size = new System.Drawing.Size(1283, 72);
this.MainPanel.TabIndex = 0; this.MainPanel.TabIndex = 0;
// //
// ProfilesComboBox // ProfilesComboBox
// //
this.ProfilesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.ProfilesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ProfilesComboBox.FormattingEnabled = true; this.ProfilesComboBox.FormattingEnabled = true;
this.ProfilesComboBox.Location = new System.Drawing.Point(201, 44); this.ProfilesComboBox.Location = new System.Drawing.Point(590, 22);
this.ProfilesComboBox.Name = "ProfilesComboBox"; this.ProfilesComboBox.Name = "ProfilesComboBox";
this.ProfilesComboBox.Size = new System.Drawing.Size(311, 28); this.ProfilesComboBox.Size = new System.Drawing.Size(311, 28);
this.ProfilesComboBox.TabIndex = 0; this.ProfilesComboBox.TabIndex = 0;
@@ -94,7 +100,7 @@
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(16, 47); this.label3.Location = new System.Drawing.Point(444, 22);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(65, 20); this.label3.Size = new System.Drawing.Size(65, 20);
this.label3.TabIndex = 7; this.label3.TabIndex = 7;
@@ -102,53 +108,29 @@
// //
// ProfileInfoPanel // ProfileInfoPanel
// //
this.ProfileInfoPanel.Controls.Add(this.ProfileInfoGroupBox); this.ProfileInfoPanel.Controls.Add(this.groupBox2);
this.ProfileInfoPanel.Controls.Add(this.groupBox1);
this.ProfileInfoPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.ProfileInfoPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.ProfileInfoPanel.Location = new System.Drawing.Point(3, 114); this.ProfileInfoPanel.Location = new System.Drawing.Point(3, 81);
this.ProfileInfoPanel.Name = "ProfileInfoPanel"; this.ProfileInfoPanel.Name = "ProfileInfoPanel";
this.ProfileInfoPanel.Size = new System.Drawing.Size(621, 624); this.ProfileInfoPanel.Size = new System.Drawing.Size(1283, 440);
this.ProfileInfoPanel.TabIndex = 1; this.ProfileInfoPanel.TabIndex = 1;
// //
// ProfileInfoGroupBox
//
this.ProfileInfoGroupBox.Controls.Add(this.FolderGroupListView);
this.ProfileInfoGroupBox.Controls.Add(this.FolderGroupPathButton);
this.ProfileInfoGroupBox.Controls.Add(this.FolderGroupPathTextBox);
this.ProfileInfoGroupBox.Controls.Add(this.label6);
this.ProfileInfoGroupBox.Controls.Add(this.InsertGroupName);
this.ProfileInfoGroupBox.Controls.Add(this.DeleteProfileButton);
this.ProfileInfoGroupBox.Controls.Add(this.MachineNameTextBox);
this.ProfileInfoGroupBox.Controls.Add(this.label4);
this.ProfileInfoGroupBox.Controls.Add(this.ProfileNameTextBox);
this.ProfileInfoGroupBox.Controls.Add(this.MachineNameLabel);
this.ProfileInfoGroupBox.Controls.Add(this.AddOrUpdateProfileButton);
this.ProfileInfoGroupBox.Controls.Add(this.label1);
this.ProfileInfoGroupBox.Controls.Add(this.SelectNewContentLocationButton);
this.ProfileInfoGroupBox.Controls.Add(this.label2);
this.ProfileInfoGroupBox.Controls.Add(this.NewContentLocationTextBox);
this.ProfileInfoGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.ProfileInfoGroupBox.Location = new System.Drawing.Point(0, 0);
this.ProfileInfoGroupBox.Name = "ProfileInfoGroupBox";
this.ProfileInfoGroupBox.Size = new System.Drawing.Size(621, 624);
this.ProfileInfoGroupBox.TabIndex = 0;
this.ProfileInfoGroupBox.TabStop = false;
this.ProfileInfoGroupBox.Text = "Profile Information";
//
// InsertGroupName // InsertGroupName
// //
this.InsertGroupName.Enabled = false; this.InsertGroupName.Enabled = false;
this.InsertGroupName.Location = new System.Drawing.Point(518, 350); this.InsertGroupName.Location = new System.Drawing.Point(480, 371);
this.InsertGroupName.Name = "InsertGroupName"; this.InsertGroupName.Name = "InsertGroupName";
this.InsertGroupName.Size = new System.Drawing.Size(86, 39); this.InsertGroupName.Size = new System.Drawing.Size(159, 39);
this.InsertGroupName.TabIndex = 8; this.InsertGroupName.TabIndex = 9;
this.InsertGroupName.Text = "Insert"; this.InsertGroupName.Text = "Insert Folder Group";
this.InsertGroupName.UseVisualStyleBackColor = true; this.InsertGroupName.UseVisualStyleBackColor = true;
this.InsertGroupName.Click += new System.EventHandler(this.InsertGroupName_Click); this.InsertGroupName.Click += new System.EventHandler(this.InsertGroupName_Click);
// //
// DeleteProfileButton // DeleteProfileButton
// //
this.DeleteProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.DeleteProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.DeleteProfileButton.Location = new System.Drawing.Point(20, 575); this.DeleteProfileButton.Location = new System.Drawing.Point(17, 320);
this.DeleteProfileButton.Name = "DeleteProfileButton"; this.DeleteProfileButton.Name = "DeleteProfileButton";
this.DeleteProfileButton.Size = new System.Drawing.Size(75, 40); this.DeleteProfileButton.Size = new System.Drawing.Size(75, 40);
this.DeleteProfileButton.TabIndex = 8; this.DeleteProfileButton.TabIndex = 8;
@@ -159,7 +141,7 @@
// //
// MachineNameTextBox // MachineNameTextBox
// //
this.MachineNameTextBox.Location = new System.Drawing.Point(201, 228); this.MachineNameTextBox.Location = new System.Drawing.Point(195, 253);
this.MachineNameTextBox.Name = "MachineNameTextBox"; this.MachineNameTextBox.Name = "MachineNameTextBox";
this.MachineNameTextBox.Size = new System.Drawing.Size(311, 26); this.MachineNameTextBox.Size = new System.Drawing.Size(311, 26);
this.MachineNameTextBox.TabIndex = 4; this.MachineNameTextBox.TabIndex = 4;
@@ -167,7 +149,7 @@
// label4 // label4
// //
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(16, 231); this.label4.Location = new System.Drawing.Point(10, 256);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(119, 20); this.label4.Size = new System.Drawing.Size(119, 20);
this.label4.TabIndex = 7; this.label4.TabIndex = 7;
@@ -175,7 +157,7 @@
// //
// ProfileNameTextBox // ProfileNameTextBox
// //
this.ProfileNameTextBox.Location = new System.Drawing.Point(201, 54); this.ProfileNameTextBox.Location = new System.Drawing.Point(198, 39);
this.ProfileNameTextBox.Name = "ProfileNameTextBox"; this.ProfileNameTextBox.Name = "ProfileNameTextBox";
this.ProfileNameTextBox.Size = new System.Drawing.Size(311, 26); this.ProfileNameTextBox.Size = new System.Drawing.Size(311, 26);
this.ProfileNameTextBox.TabIndex = 1; this.ProfileNameTextBox.TabIndex = 1;
@@ -183,19 +165,19 @@
// MachineNameLabel // MachineNameLabel
// //
this.MachineNameLabel.AutoSize = true; this.MachineNameLabel.AutoSize = true;
this.MachineNameLabel.Location = new System.Drawing.Point(16, 173); this.MachineNameLabel.Location = new System.Drawing.Point(13, 186);
this.MachineNameLabel.Name = "MachineNameLabel"; this.MachineNameLabel.Name = "MachineNameLabel";
this.MachineNameLabel.Size = new System.Drawing.Size(472, 20); this.MachineNameLabel.Size = new System.Drawing.Size(88, 20);
this.MachineNameLabel.TabIndex = 5; this.MachineNameLabel.TabIndex = 5;
this.MachineNameLabel.Text = "This prfile will be automatically loaded when ran on the machine ...."; this.MachineNameLabel.Text = "profile stuff";
// //
// AddOrUpdateProfileButton // AddOrUpdateProfileButton
// //
this.AddOrUpdateProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.AddOrUpdateProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.AddOrUpdateProfileButton.Location = new System.Drawing.Point(518, 575); this.AddOrUpdateProfileButton.Location = new System.Drawing.Point(479, 320);
this.AddOrUpdateProfileButton.Name = "AddOrUpdateProfileButton"; this.AddOrUpdateProfileButton.Name = "AddOrUpdateProfileButton";
this.AddOrUpdateProfileButton.Size = new System.Drawing.Size(86, 40); this.AddOrUpdateProfileButton.Size = new System.Drawing.Size(86, 40);
this.AddOrUpdateProfileButton.TabIndex = 9; this.AddOrUpdateProfileButton.TabIndex = 10;
this.AddOrUpdateProfileButton.Text = "button1"; this.AddOrUpdateProfileButton.Text = "button1";
this.AddOrUpdateProfileButton.UseVisualStyleBackColor = true; this.AddOrUpdateProfileButton.UseVisualStyleBackColor = true;
this.AddOrUpdateProfileButton.Click += new System.EventHandler(this.AddOrUpdateProfileButton_Click); this.AddOrUpdateProfileButton.Click += new System.EventHandler(this.AddOrUpdateProfileButton_Click);
@@ -203,7 +185,7 @@
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(16, 57); this.label1.Location = new System.Drawing.Point(13, 42);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(103, 20); this.label1.Size = new System.Drawing.Size(103, 20);
this.label1.TabIndex = 0; this.label1.TabIndex = 0;
@@ -211,17 +193,18 @@
// //
// SelectNewContentLocationButton // SelectNewContentLocationButton
// //
this.SelectNewContentLocationButton.Location = new System.Drawing.Point(518, 109); this.SelectNewContentLocationButton.Location = new System.Drawing.Point(512, 119);
this.SelectNewContentLocationButton.Name = "SelectNewContentLocationButton"; this.SelectNewContentLocationButton.Name = "SelectNewContentLocationButton";
this.SelectNewContentLocationButton.Size = new System.Drawing.Size(50, 30); this.SelectNewContentLocationButton.Size = new System.Drawing.Size(50, 30);
this.SelectNewContentLocationButton.TabIndex = 3; this.SelectNewContentLocationButton.TabIndex = 3;
this.SelectNewContentLocationButton.Text = "..."; this.SelectNewContentLocationButton.Text = "...";
this.SelectNewContentLocationButton.UseVisualStyleBackColor = true; this.SelectNewContentLocationButton.UseVisualStyleBackColor = true;
this.SelectNewContentLocationButton.Click += new System.EventHandler(this.SelectNewContentLocationButton_Click);
// //
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(16, 111); this.label2.Location = new System.Drawing.Point(13, 124);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(170, 20); this.label2.Size = new System.Drawing.Size(170, 20);
this.label2.TabIndex = 2; this.label2.TabIndex = 2;
@@ -229,7 +212,7 @@
// //
// NewContentLocationTextBox // NewContentLocationTextBox
// //
this.NewContentLocationTextBox.Location = new System.Drawing.Point(201, 109); this.NewContentLocationTextBox.Location = new System.Drawing.Point(195, 121);
this.NewContentLocationTextBox.Name = "NewContentLocationTextBox"; this.NewContentLocationTextBox.Name = "NewContentLocationTextBox";
this.NewContentLocationTextBox.Size = new System.Drawing.Size(311, 26); this.NewContentLocationTextBox.Size = new System.Drawing.Size(311, 26);
this.NewContentLocationTextBox.TabIndex = 2; this.NewContentLocationTextBox.TabIndex = 2;
@@ -237,7 +220,7 @@
// label6 // label6
// //
this.label6.AutoSize = true; this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(16, 287); this.label6.Location = new System.Drawing.Point(6, 328);
this.label6.Name = "label6"; this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(144, 20); this.label6.Size = new System.Drawing.Size(144, 20);
this.label6.TabIndex = 11; this.label6.TabIndex = 11;
@@ -245,14 +228,14 @@
// //
// FolderGroupPathTextBox // FolderGroupPathTextBox
// //
this.FolderGroupPathTextBox.Location = new System.Drawing.Point(201, 284); this.FolderGroupPathTextBox.Location = new System.Drawing.Point(163, 325);
this.FolderGroupPathTextBox.Name = "FolderGroupPathTextBox"; this.FolderGroupPathTextBox.Name = "FolderGroupPathTextBox";
this.FolderGroupPathTextBox.Size = new System.Drawing.Size(311, 26); this.FolderGroupPathTextBox.Size = new System.Drawing.Size(311, 26);
this.FolderGroupPathTextBox.TabIndex = 6; this.FolderGroupPathTextBox.TabIndex = 6;
// //
// FolderGroupPathButton // FolderGroupPathButton
// //
this.FolderGroupPathButton.Location = new System.Drawing.Point(518, 284); this.FolderGroupPathButton.Location = new System.Drawing.Point(480, 323);
this.FolderGroupPathButton.Name = "FolderGroupPathButton"; this.FolderGroupPathButton.Name = "FolderGroupPathButton";
this.FolderGroupPathButton.Size = new System.Drawing.Size(50, 30); this.FolderGroupPathButton.Size = new System.Drawing.Size(50, 30);
this.FolderGroupPathButton.TabIndex = 7; this.FolderGroupPathButton.TabIndex = 7;
@@ -263,14 +246,15 @@
// FolderGroupListView // FolderGroupListView
// //
this.FolderGroupListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.FolderGroupListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.NameColumn, this.NameColumn});
this.PathColumn});
this.FolderGroupListView.FullRowSelect = true; this.FolderGroupListView.FullRowSelect = true;
this.FolderGroupListView.HideSelection = false; this.FolderGroupListView.HideSelection = false;
this.FolderGroupListView.Location = new System.Drawing.Point(20, 350); this.FolderGroupListView.Location = new System.Drawing.Point(10, 39);
this.FolderGroupListView.MultiSelect = false; this.FolderGroupListView.MultiSelect = false;
this.FolderGroupListView.Name = "FolderGroupListView"; this.FolderGroupListView.Name = "FolderGroupListView";
this.FolderGroupListView.Size = new System.Drawing.Size(492, 220); this.FolderGroupListView.Scrollable = false;
this.FolderGroupListView.Size = new System.Drawing.Size(520, 220);
this.FolderGroupListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.FolderGroupListView.TabIndex = 14; this.FolderGroupListView.TabIndex = 14;
this.FolderGroupListView.TabStop = false; this.FolderGroupListView.TabStop = false;
this.FolderGroupListView.UseCompatibleStateImageBehavior = false; this.FolderGroupListView.UseCompatibleStateImageBehavior = false;
@@ -279,18 +263,95 @@
// NameColumn // NameColumn
// //
this.NameColumn.Text = "Name"; this.NameColumn.Text = "Name";
this.NameColumn.Width = 167; this.NameColumn.Width = 623;
// //
// PathColumn // label5
// //
this.PathColumn.Text = "Path"; this.label5.AutoSize = true;
this.PathColumn.Width = 312; this.label5.Location = new System.Drawing.Point(6, 380);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(151, 20);
this.label5.TabIndex = 15;
this.label5.Text = "Naming Convention:";
//
// NamingConventionComboBox
//
this.NamingConventionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.NamingConventionComboBox.FormattingEnabled = true;
this.NamingConventionComboBox.Location = new System.Drawing.Point(163, 377);
this.NamingConventionComboBox.Name = "NamingConventionComboBox";
this.NamingConventionComboBox.Size = new System.Drawing.Size(311, 28);
this.NamingConventionComboBox.TabIndex = 8;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label8);
this.groupBox1.Controls.Add(this.NewContentLocationTextBox);
this.groupBox1.Controls.Add(this.MachineNameTextBox);
this.groupBox1.Controls.Add(this.AddOrUpdateProfileButton);
this.groupBox1.Controls.Add(this.DeleteProfileButton);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.ProfileNameTextBox);
this.groupBox1.Controls.Add(this.SelectNewContentLocationButton);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.MachineNameLabel);
this.groupBox1.Location = new System.Drawing.Point(3, 3);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(611, 430);
this.groupBox1.TabIndex = 17;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Profile Details";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.FolderNameTextBox);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.NamingConventionComboBox);
this.groupBox2.Controls.Add(this.label5);
this.groupBox2.Controls.Add(this.FolderGroupPathTextBox);
this.groupBox2.Controls.Add(this.InsertGroupName);
this.groupBox2.Controls.Add(this.FolderGroupListView);
this.groupBox2.Controls.Add(this.FolderGroupPathButton);
this.groupBox2.Controls.Add(this.label6);
this.groupBox2.Location = new System.Drawing.Point(620, 3);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(658, 430);
this.groupBox2.TabIndex = 18;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Folder Group Details";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(6, 276);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(104, 20);
this.label7.TabIndex = 15;
this.label7.Text = "Group Name:";
//
// FolderNameTextBox
//
this.FolderNameTextBox.Enabled = false;
this.FolderNameTextBox.Location = new System.Drawing.Point(163, 273);
this.FolderNameTextBox.Name = "FolderNameTextBox";
this.FolderNameTextBox.Size = new System.Drawing.Size(311, 26);
this.FolderNameTextBox.TabIndex = 5;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(13, 83);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(529, 20);
this.label8.TabIndex = 10;
this.label8.Text = "New content location is the default location where you will add new files to.";
// //
// ProfileManager // ProfileManager
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(627, 741); this.ClientSize = new System.Drawing.Size(1289, 524);
this.Controls.Add(this.MainLayoutPanel); this.Controls.Add(this.MainLayoutPanel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false; this.MaximizeBox = false;
@@ -303,8 +364,10 @@
this.MainPanel.ResumeLayout(false); this.MainPanel.ResumeLayout(false);
this.MainPanel.PerformLayout(); this.MainPanel.PerformLayout();
this.ProfileInfoPanel.ResumeLayout(false); this.ProfileInfoPanel.ResumeLayout(false);
this.ProfileInfoGroupBox.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.ProfileInfoGroupBox.PerformLayout(); this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@@ -316,7 +379,6 @@
private System.Windows.Forms.ComboBox ProfilesComboBox; private System.Windows.Forms.ComboBox ProfilesComboBox;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.Panel ProfileInfoPanel; private System.Windows.Forms.Panel ProfileInfoPanel;
private System.Windows.Forms.GroupBox ProfileInfoGroupBox;
private System.Windows.Forms.TextBox ProfileNameTextBox; private System.Windows.Forms.TextBox ProfileNameTextBox;
private System.Windows.Forms.Label MachineNameLabel; private System.Windows.Forms.Label MachineNameLabel;
private System.Windows.Forms.Button AddOrUpdateProfileButton; private System.Windows.Forms.Button AddOrUpdateProfileButton;
@@ -333,6 +395,12 @@
private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label6;
private System.Windows.Forms.ListView FolderGroupListView; private System.Windows.Forms.ListView FolderGroupListView;
private System.Windows.Forms.ColumnHeader NameColumn; private System.Windows.Forms.ColumnHeader NameColumn;
private System.Windows.Forms.ColumnHeader PathColumn; private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox NamingConventionComboBox;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TextBox FolderNameTextBox;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label8;
} }
} }
+258 -94
View File
@@ -6,6 +6,7 @@ using System.Drawing;
using System.Drawing.Printing; using System.Drawing.Printing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Security.AccessControl;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@@ -17,14 +18,25 @@ namespace DataOrganizer
private string MachineNameLabelText { get; } = "The Machine Name property determines what profile will be loaded automatically.\r\nCurrently: '{0}'."; private string MachineNameLabelText { get; } = "The Machine Name property determines what profile will be loaded automatically.\r\nCurrently: '{0}'.";
private bool IsUpdating { get; set; } private bool IsUpdating { get; set; }
private ContextMenu FolderGroupListContextMenu { get; set; } = new ContextMenu(); private ContextMenu FolderGroupListContextMenu { get; set; } = new ContextMenu();
private ListViewItem SelectedItem { get; set; } private List<DB.Namingconvention> NamingConventions { get; }
private Dictionary<string, DB.Profile> Profiles { get; } = new Dictionary<string, DB.Profile>();
private Dictionary<string, DB.FolderGroup> FolderGroups { get; } = new Dictionary<string, DB.FolderGroup>();
public ProfileManager() public ProfileManager()
{ {
InitializeComponent(); InitializeComponent();
var db = new DB();
var deleteMenuItem = new MenuItem("Delete"); var deleteMenuItem = new MenuItem("Delete");
FolderGroupListContextMenu.MenuItems.Add(deleteMenuItem); FolderGroupListContextMenu.MenuItems.Add(deleteMenuItem);
NamingConventions = db.GetNamingConventions();
NamingConventionComboBox.Items.Add("None");
NamingConventionComboBox.SelectedIndex = 0;
foreach(var convention in NamingConventions)
{
NamingConventionComboBox.Items.Add(convention.Name);
}
ProfilesComboBox.SelectedIndexChanged += ProfilesComboBox_SelectedIndexChanged; ProfilesComboBox.SelectedIndexChanged += ProfilesComboBox_SelectedIndexChanged;
ProfileNameTextBox.TextChanged += ToggleAddOrUpdateButton; ProfileNameTextBox.TextChanged += ToggleAddOrUpdateButton;
@@ -34,16 +46,30 @@ namespace DataOrganizer
FolderGroupListView.MouseClick += FolderGroupListView_MouseClick; FolderGroupListView.MouseClick += FolderGroupListView_MouseClick;
deleteMenuItem.Click += DeleteMenuItem_Click; deleteMenuItem.Click += DeleteMenuItem_Click;
UpdateProfileComboBox(); PopulateProfiles();
SetupForNewProfile();
} }
private void FolderGroupListView_MouseClick(object sender, MouseEventArgs e) private void FolderGroupListView_MouseClick(object sender, MouseEventArgs e)
{ {
if (e.Button == MouseButtons.Right) if (e.Button == MouseButtons.Right)
{ {
SelectedItem = FolderGroupListView.GetItemAt(e.X, e.Y);
FolderGroupListContextMenu.Show(FolderGroupListView, e.Location); FolderGroupListContextMenu.Show(FolderGroupListView, e.Location);
} }
else if (e.Button == MouseButtons.Left)
{
GetSelectedFolderGroup(out DB.FolderGroup folderGroup);
FolderGroupPathTextBox.Text = folderGroup.Path;
FolderNameTextBox.Text = folderGroup.Name;
var index = NamingConventions.FindIndex(x => x.Id == folderGroup.PatternId);
if (index != -1)
NamingConventionComboBox.SelectedIndex = index + 1;
else
NamingConventionComboBox.SelectedIndex = 0;
InsertGroupName.Text = "Update Folder Group";
}
} }
private void DeleteMenuItem_Click(object sender, EventArgs e) private void DeleteMenuItem_Click(object sender, EventArgs e)
@@ -55,21 +81,18 @@ namespace DataOrganizer
if(result == DialogResult.Yes) if(result == DialogResult.Yes)
{ {
var db = new DB(); var db = new DB();
var currentIndex = ProfilesComboBox.SelectedIndex;
db.DeleteFolderGroup((DB.FolderGroup) SelectedItem.Tag); GetSelectedFolderGroup(out DB.FolderGroup folderGroup);
UpdateProfileComboBox(); db.DeleteFolderGroup(folderGroup);
ProfilesComboBox.SelectedIndex = currentIndex; RemoveFolderGroup(folderGroup.Id);
} }
} }
else else
{ {
FolderGroupListView.Items.Remove(FolderGroupListView.SelectedItems[0]); FolderGroupListView.Items.Remove(FolderGroupListView.SelectedItems[0]);
} }
SelectedItem = null;
} }
private void MachineNameTextBox_TextChanged(object sender, EventArgs e) private void MachineNameTextBox_TextChanged(object sender, EventArgs e)
@@ -96,33 +119,6 @@ namespace DataOrganizer
InsertGroupName.Enabled = false; InsertGroupName.Enabled = false;
} }
private void UpdateProfileComboBox()
{
var db = new DB();
var profiles = db.GetProfiles();
ProfilesComboBox.Items.Clear();
ProfilesComboBox.Tag = null;
ProfilesComboBox.Items.Add("Add New Profile");
ProfilesComboBox.SelectedIndex = 0;
FolderGroupListView.Items.Clear();
if (profiles.Count == 0)
{
ProfilesComboBox.Enabled = false;
return;
}
ProfilesComboBox.Enabled = true;
foreach (var profile in profiles)
{
ProfilesComboBox.Items.Add(profile.Name);
}
ProfilesComboBox.Tag = profiles;
}
private void AddOrUpdateProfileButton_Click(object sender, EventArgs e) private void AddOrUpdateProfileButton_Click(object sender, EventArgs e)
{ {
var machineName = Environment.MachineName; var machineName = Environment.MachineName;
@@ -136,19 +132,18 @@ namespace DataOrganizer
if (!IsUpdating) if (!IsUpdating)
{ {
var folders = new List<DB.FolderGroup>(); var folders = new List<DB.FolderGroup>();
//TODO: crash
foreach(ListViewItem node in FolderGroupListView.Items) foreach(ListViewItem node in FolderGroupListView.Items)
{ {
folders.Add(new DB.FolderGroup folders.Add(FolderGroups[node.Text]);
{
Name = node.SubItems[0].Text,
Path = node.SubItems[1].Text
});
} }
db.InsertNewProfile(new DB.Profile { Name = ProfileNameTextBox.Text, DefaultNewContentFolder = NewContentLocationTextBox.Text, MachineName = machineName, FolderGroups = folders }); var newProfile = new DB.Profile { Name = ProfileNameTextBox.Text, DefaultNewContentFolder = NewContentLocationTextBox.Text, MachineName = machineName, FolderGroups = folders };
UpdateProfileComboBox(); db.InsertNewProfile(newProfile);
Profiles.Add(newProfile.Name, newProfile);
ProfilesComboBox.Items.Add(newProfile.Name);
} }
else else
{ {
@@ -156,53 +151,21 @@ namespace DataOrganizer
profile.Name = ProfileNameTextBox.Text; profile.Name = ProfileNameTextBox.Text;
profile.DefaultNewContentFolder = NewContentLocationTextBox.Text; profile.DefaultNewContentFolder = NewContentLocationTextBox.Text;
profile.MachineName = MachineNameTextBox.Text; profile.MachineName = MachineNameTextBox.Text;
Profiles[profile.Name] = profile;
db.UpdateProfile(profile); db.UpdateProfile(profile);
} }
UpdateProfileComboBox(); SetupForNewProfile();
} }
private void ProfilesComboBox_SelectedIndexChanged(object sender, EventArgs e) private void ProfilesComboBox_SelectedIndexChanged(object sender, EventArgs e)
{ {
FolderGroupListView.Items.Clear();
if (ProfilesComboBox.SelectedIndex == 0) if (ProfilesComboBox.SelectedIndex == 0)
{ SetupForNewProfile();
ProfileNameTextBox.Text = string.Empty; else
NewContentLocationTextBox.Text = string.Empty; SetUpFormForUpdatingProfile();
MachineNameTextBox.Text = string.Empty;
AddOrUpdateProfileButton.Text = "Add";
AddOrUpdateProfileButton.Enabled = false;
MachineNameLabel.Text = string.Format(MachineNameLabelText, Environment.MachineName);
IsUpdating = false;
DeleteProfileButton.Enabled = false;
return;
}
IsUpdating = true;
GetCurrentProfile(out DB.Profile profile);
ProfileNameTextBox.Text = profile.Name;
NewContentLocationTextBox.Text = profile.DefaultNewContentFolder;
MachineNameTextBox.Text = profile.MachineName;
DeleteProfileButton.Enabled = true;
MachineNameLabel.Text = string.Format(MachineNameLabelText, profile.MachineName);
AddOrUpdateProfileButton.Text = "Update";
if(profile.FolderGroups != null)
{
foreach(var group in profile.FolderGroups)
{
var item = new ListViewItem(group.Name);
item.SubItems.Add(group.Path);
item.Tag = group;
FolderGroupListView.Items.Add(item);
}
}
} }
private void InsertGroupName_Click(object sender, EventArgs e) private void InsertGroupName_Click(object sender, EventArgs e)
@@ -210,26 +173,55 @@ namespace DataOrganizer
var dir = new DirectoryInfo(FolderGroupPathTextBox.Text); var dir = new DirectoryInfo(FolderGroupPathTextBox.Text);
var groupName = dir.Name; var groupName = dir.Name;
if (!FolderGroupListView.Items.ContainsKey(groupName))//!FolderGroupsTreeView.Nodes.ContainsKey(groupName)) if (!FolderGroups.ContainsKey(groupName))
{ {
var item = new ListViewItem(groupName); GetCurrentNamingConvention(out DB.Namingconvention convention);
item.SubItems.Add(FolderGroupPathTextBox.Text); GetCurrentProfile(out DB.Profile profile);
var newFolder = new DB.FolderGroup { Name = groupName, Path = FolderGroupPathTextBox.Text, PatternId = convention.Id};
FolderGroupListView.Items.Add(item); FolderGroupListView.Items.Add(groupName);
if (IsUpdating) if (IsUpdating)
{ {
var db = new DB(); var db = new DB();
GetCurrentProfile(out DB.Profile profile); var newId = db.InsertNewFolderGroup(profile, groupName, FolderGroupPathTextBox.Text, convention.Id);
newFolder.Id = newId;
var newId = db.InsertNewFolderGroup(profile, groupName, FolderGroupPathTextBox.Text); profile.FolderGroups.Add(newFolder);
profile.FolderGroups.Add(new DB.FolderGroup { Name = groupName, Id = newId, Path = FolderGroupPathTextBox.Text }); Profiles[profile.Name] = profile;
}
} }
FolderGroups.Add(newFolder.Name, newFolder);
FolderNameTextBox.Text = string.Empty;
FolderGroupPathTextBox.Text = string.Empty; FolderGroupPathTextBox.Text = string.Empty;
InsertGroupName.Enabled = false;
}
else
{
var folderGroup = FolderGroups[groupName];//(DB.FolderGroup) FolderGroupListView.Items.Find(groupName, true)[0].Tag;
folderGroup.Path = FolderGroupPathTextBox.Text;
folderGroup.Name = groupName;
GetCurrentNamingConvention(out DB.Namingconvention convention);
folderGroup.PatternId = convention.Id;
InsertGroupName.Text = "Insert Folder Group";
if (IsUpdating)
{
var db = new DB();
db.UpdateFolderGroup(folderGroup);
}
FolderGroups[groupName] = folderGroup;
NamingConventionComboBox.SelectedIndex = 0;
FolderNameTextBox.Text = string.Empty;
FolderGroupPathTextBox.Text = string.Empty;
InsertGroupName.Enabled = false;
}
FolderGroupPathButton.Focus(); FolderGroupPathButton.Focus();
} }
@@ -239,11 +231,35 @@ namespace DataOrganizer
if (!IsUpdating) return false; if (!IsUpdating) return false;
profile = ((List<DB.Profile>)ProfilesComboBox.Tag)[ProfilesComboBox.SelectedIndex - 1]; profile = Profiles[ProfilesComboBox.Text];
return true; return true;
} }
private bool GetCurrentNamingConvention(out DB.Namingconvention namingconvention)
{
namingconvention = new DB.Namingconvention();
if (NamingConventions.Count == 0 || NamingConventionComboBox.SelectedIndex == 0) return false;
namingconvention = NamingConventions[NamingConventionComboBox.SelectedIndex - 1];
return true;
}
private bool GetSelectedFolderGroup(out DB.FolderGroup folderGroup)
{
folderGroup = new DB.FolderGroup();
if(FolderGroupListView.SelectedItems.Count == 1)
{
folderGroup = FolderGroups[FolderGroupListView.SelectedItems[0].Text];
return true;
}
return false;
}
private void DeleteProfileButton_Click(object sender, EventArgs e) private void DeleteProfileButton_Click(object sender, EventArgs e)
{ {
var result = MessageBox.Show("Are you sure? This will delete all file records (not files on disk), groups and any customization data set in this profile.", "Wipe Profile", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); var result = MessageBox.Show("Are you sure? This will delete all file records (not files on disk), groups and any customization data set in this profile.", "Wipe Profile", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
@@ -255,17 +271,165 @@ namespace DataOrganizer
db.DeleteProfile(profile); db.DeleteProfile(profile);
UpdateProfileComboBox(); PopulateProfiles();
SetupForNewProfile();
} }
} }
private void FolderGroupPathButton_Click(object sender, EventArgs e) private void FolderGroupPathButton_Click(object sender, EventArgs e)
{ {
var dialog = new FolderBrowserDialog(); var dialog = new FolderBrowserDialog() { Description = "Select a root folder that holds like content." };
if(dialog.ShowDialog() == DialogResult.OK) if(dialog.ShowDialog() == DialogResult.OK)
{ {
FolderGroupPathTextBox.Text = dialog.SelectedPath; FolderGroupPathTextBox.Text = dialog.SelectedPath;
InsertGroupName.Text = "Insert Folder Group";
}
}
private void RemoveFolderGroup(int folderId)
{
GetCurrentProfile(out DB.Profile profile);
profile.FolderGroups.RemoveAll(x => x.Id == folderId);
ClearFolderGroupControls();
foreach(var folder in profile.FolderGroups)
{
var item = new ListViewItem(folder.Name);
item.Tag = folder;
FolderGroupListView.Items.Add(item);
}
}
private void ClearForm()
{
ClearProfileDataControls();
ClearFolderGroupControls();
}
private void ClearFolderGroupControls()
{
FolderGroupListView.Items.Clear();
NamingConventionComboBox.SelectedIndex = 0;
FolderNameTextBox.Text = string.Empty;
FolderGroupPathTextBox.Text = string.Empty;
InsertGroupName.Enabled = false;
}
private void ClearProfileDataControls()
{
ProfileNameTextBox.Text = string.Empty;
NewContentLocationTextBox.Text = string.Empty;
MachineNameTextBox.Text = string.Empty;
DeleteProfileButton.Enabled = false;
AddOrUpdateProfileButton.Enabled = false;
AddOrUpdateProfileButton.Text = "Add";
}
private void PopulateProfiles()
{
ProfilesComboBox.SelectedIndexChanged -= ProfilesComboBox_SelectedIndexChanged;
var db = new DB();
Profiles.Clear();
var profiles = db.GetProfiles();
foreach(var profile in profiles)
{
Profiles.Add(profile.Name, profile);
}
ProfilesComboBox.Items.Clear();
ProfilesComboBox.Items.Add("Add New Profile");
ProfilesComboBox.SelectedIndex = 0;
if (Profiles.Count == 0)
ProfilesComboBox.Enabled = false;
else
{
ProfilesComboBox.Enabled = true;
foreach (var profile in Profiles)
{
ProfilesComboBox.Items.Add(profile.Value.Name);
}
}
ProfilesComboBox.SelectedIndexChanged += ProfilesComboBox_SelectedIndexChanged;
}
private void RefreshProfileComboBox()
{
ProfilesComboBox.SelectedIndexChanged -= ProfilesComboBox_SelectedIndexChanged;
ProfilesComboBox.Items.Clear();
ProfilesComboBox.Items.Add("Add New Profile");
ProfilesComboBox.SelectedIndex = 0;
if (Profiles.Count == 0)
ProfilesComboBox.Enabled = false;
else
{
ProfilesComboBox.Enabled = true;
foreach (var profile in Profiles)
{
ProfilesComboBox.Items.Add(profile.Value.Name);
}
}
ProfilesComboBox.SelectedIndexChanged += ProfilesComboBox_SelectedIndexChanged;
}
private void SetupForNewProfile()
{
ClearForm();
RefreshProfileComboBox();
IsUpdating = false;
FolderGroups.Clear();
MachineNameLabel.Text = string.Format(MachineNameLabelText, Environment.MachineName);
AddOrUpdateProfileButton.Text = "Add";
ProfileNameTextBox.Focus();
}
private void SetUpFormForUpdatingProfile()
{
ClearForm();
IsUpdating = true;
GetCurrentProfile(out DB.Profile profile);
ProfileNameTextBox.Text = profile.Name;
NewContentLocationTextBox.Text = profile.DefaultNewContentFolder;
MachineNameTextBox.Text = profile.MachineName;
MachineNameLabel.Text = string.Format(MachineNameLabelText, profile.MachineName);
FolderGroups.Clear();
if (profile.FolderGroups != null)
{
foreach (var group in profile.FolderGroups)
{
FolderGroupListView.Items.Add(group.Name);
FolderGroups.Add(group.Name, group);
}
}
AddOrUpdateProfileButton.Text = "Update";
AddOrUpdateProfileButton.Enabled = true;
DeleteProfileButton.Enabled = true;
}
private void SelectNewContentLocationButton_Click(object sender, EventArgs e)
{
var dialog = new FolderBrowserDialog() { Description = "Select the default location to look for new content." };
if (dialog.ShowDialog() == DialogResult.OK)
{
NewContentLocationTextBox.Text = dialog.SelectedPath;
} }
} }
} }