diff --git a/.vs/DataOrganizer/v16/.suo b/.vs/DataOrganizer/v16/.suo index 608bdce..95abed7 100644 Binary files a/.vs/DataOrganizer/v16/.suo and b/.vs/DataOrganizer/v16/.suo differ diff --git a/DataOrganizer/ProfileManager.Designer.cs b/DataOrganizer/ProfileManager.Designer.cs index 32c5760..c0b116e 100644 --- a/DataOrganizer/ProfileManager.Designer.cs +++ b/DataOrganizer/ProfileManager.Designer.cs @@ -35,8 +35,6 @@ this.ProfileInfoPanel = new System.Windows.Forms.Panel(); this.ProfileInfoGroupBox = new System.Windows.Forms.GroupBox(); this.InsertGroupName = new System.Windows.Forms.Button(); - this.FolderGroupNameTextBox = new System.Windows.Forms.TextBox(); - this.label5 = new System.Windows.Forms.Label(); this.DeleteProfileButton = new System.Windows.Forms.Button(); this.MachineNameTextBox = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); @@ -71,7 +69,7 @@ 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, 85F)); - this.MainLayoutPanel.Size = new System.Drawing.Size(627, 809); + this.MainLayoutPanel.Size = new System.Drawing.Size(627, 741); this.MainLayoutPanel.TabIndex = 0; // // MainPanel @@ -81,7 +79,7 @@ this.MainPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.MainPanel.Location = new System.Drawing.Point(3, 3); this.MainPanel.Name = "MainPanel"; - this.MainPanel.Size = new System.Drawing.Size(621, 115); + this.MainPanel.Size = new System.Drawing.Size(621, 105); this.MainPanel.TabIndex = 0; // // ProfilesComboBox @@ -96,7 +94,7 @@ // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(23, 47); + this.label3.Location = new System.Drawing.Point(16, 47); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(65, 20); this.label3.TabIndex = 7; @@ -106,9 +104,9 @@ // this.ProfileInfoPanel.Controls.Add(this.ProfileInfoGroupBox); this.ProfileInfoPanel.Dock = System.Windows.Forms.DockStyle.Fill; - this.ProfileInfoPanel.Location = new System.Drawing.Point(3, 124); + this.ProfileInfoPanel.Location = new System.Drawing.Point(3, 114); this.ProfileInfoPanel.Name = "ProfileInfoPanel"; - this.ProfileInfoPanel.Size = new System.Drawing.Size(621, 682); + this.ProfileInfoPanel.Size = new System.Drawing.Size(621, 624); this.ProfileInfoPanel.TabIndex = 1; // // ProfileInfoGroupBox @@ -118,8 +116,6 @@ this.ProfileInfoGroupBox.Controls.Add(this.FolderGroupPathTextBox); this.ProfileInfoGroupBox.Controls.Add(this.label6); this.ProfileInfoGroupBox.Controls.Add(this.InsertGroupName); - this.ProfileInfoGroupBox.Controls.Add(this.FolderGroupNameTextBox); - this.ProfileInfoGroupBox.Controls.Add(this.label5); this.ProfileInfoGroupBox.Controls.Add(this.DeleteProfileButton); this.ProfileInfoGroupBox.Controls.Add(this.MachineNameTextBox); this.ProfileInfoGroupBox.Controls.Add(this.label4); @@ -133,7 +129,7 @@ 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, 682); + this.ProfileInfoGroupBox.Size = new System.Drawing.Size(621, 624); this.ProfileInfoGroupBox.TabIndex = 0; this.ProfileInfoGroupBox.TabStop = false; this.ProfileInfoGroupBox.Text = "Profile Information"; @@ -141,7 +137,7 @@ // InsertGroupName // this.InsertGroupName.Enabled = false; - this.InsertGroupName.Location = new System.Drawing.Point(518, 429); + this.InsertGroupName.Location = new System.Drawing.Point(518, 350); this.InsertGroupName.Name = "InsertGroupName"; this.InsertGroupName.Size = new System.Drawing.Size(86, 39); this.InsertGroupName.TabIndex = 8; @@ -149,26 +145,10 @@ this.InsertGroupName.UseVisualStyleBackColor = true; this.InsertGroupName.Click += new System.EventHandler(this.InsertGroupName_Click); // - // FolderGroupNameTextBox - // - this.FolderGroupNameTextBox.Location = new System.Drawing.Point(201, 286); - this.FolderGroupNameTextBox.Name = "FolderGroupNameTextBox"; - this.FolderGroupNameTextBox.Size = new System.Drawing.Size(311, 26); - this.FolderGroupNameTextBox.TabIndex = 5; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(16, 289); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(153, 20); - this.label5.TabIndex = 9; - this.label5.Text = "Folder Group Name:"; - // // DeleteProfileButton // this.DeleteProfileButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.DeleteProfileButton.Location = new System.Drawing.Point(9, 633); + this.DeleteProfileButton.Location = new System.Drawing.Point(20, 575); this.DeleteProfileButton.Name = "DeleteProfileButton"; this.DeleteProfileButton.Size = new System.Drawing.Size(75, 40); this.DeleteProfileButton.TabIndex = 8; @@ -212,7 +192,7 @@ // AddOrUpdateProfileButton // 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, 633); + this.AddOrUpdateProfileButton.Location = new System.Drawing.Point(518, 575); this.AddOrUpdateProfileButton.Name = "AddOrUpdateProfileButton"; this.AddOrUpdateProfileButton.Size = new System.Drawing.Size(86, 40); this.AddOrUpdateProfileButton.TabIndex = 9; @@ -231,7 +211,7 @@ // // SelectNewContentLocationButton // - this.SelectNewContentLocationButton.Location = new System.Drawing.Point(518, 111); + this.SelectNewContentLocationButton.Location = new System.Drawing.Point(518, 109); this.SelectNewContentLocationButton.Name = "SelectNewContentLocationButton"; this.SelectNewContentLocationButton.Size = new System.Drawing.Size(50, 30); this.SelectNewContentLocationButton.TabIndex = 3; @@ -241,7 +221,7 @@ // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(16, 115); + this.label2.Location = new System.Drawing.Point(16, 111); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(170, 20); this.label2.TabIndex = 2; @@ -249,7 +229,7 @@ // // NewContentLocationTextBox // - this.NewContentLocationTextBox.Location = new System.Drawing.Point(201, 113); + this.NewContentLocationTextBox.Location = new System.Drawing.Point(201, 109); this.NewContentLocationTextBox.Name = "NewContentLocationTextBox"; this.NewContentLocationTextBox.Size = new System.Drawing.Size(311, 26); this.NewContentLocationTextBox.TabIndex = 2; @@ -257,7 +237,7 @@ // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(16, 339); + this.label6.Location = new System.Drawing.Point(16, 287); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(144, 20); this.label6.TabIndex = 11; @@ -265,14 +245,14 @@ // // FolderGroupPathTextBox // - this.FolderGroupPathTextBox.Location = new System.Drawing.Point(201, 336); + this.FolderGroupPathTextBox.Location = new System.Drawing.Point(201, 284); this.FolderGroupPathTextBox.Name = "FolderGroupPathTextBox"; this.FolderGroupPathTextBox.Size = new System.Drawing.Size(311, 26); this.FolderGroupPathTextBox.TabIndex = 6; // // FolderGroupPathButton // - this.FolderGroupPathButton.Location = new System.Drawing.Point(518, 334); + this.FolderGroupPathButton.Location = new System.Drawing.Point(518, 284); this.FolderGroupPathButton.Name = "FolderGroupPathButton"; this.FolderGroupPathButton.Size = new System.Drawing.Size(50, 30); this.FolderGroupPathButton.TabIndex = 7; @@ -287,7 +267,7 @@ this.PathColumn}); this.FolderGroupListView.FullRowSelect = true; this.FolderGroupListView.HideSelection = false; - this.FolderGroupListView.Location = new System.Drawing.Point(20, 407); + this.FolderGroupListView.Location = new System.Drawing.Point(20, 350); this.FolderGroupListView.MultiSelect = false; this.FolderGroupListView.Name = "FolderGroupListView"; this.FolderGroupListView.Size = new System.Drawing.Size(492, 220); @@ -310,7 +290,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(627, 809); + this.ClientSize = new System.Drawing.Size(627, 741); this.Controls.Add(this.MainLayoutPanel); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; @@ -348,8 +328,6 @@ private System.Windows.Forms.Label label4; private System.Windows.Forms.Button DeleteProfileButton; private System.Windows.Forms.Button InsertGroupName; - private System.Windows.Forms.TextBox FolderGroupNameTextBox; - private System.Windows.Forms.Label label5; private System.Windows.Forms.Button FolderGroupPathButton; private System.Windows.Forms.TextBox FolderGroupPathTextBox; private System.Windows.Forms.Label label6; diff --git a/DataOrganizer/ProfileManager.cs b/DataOrganizer/ProfileManager.cs index 69d20d4..f604798 100644 --- a/DataOrganizer/ProfileManager.cs +++ b/DataOrganizer/ProfileManager.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Printing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -30,7 +31,6 @@ namespace DataOrganizer NewContentLocationTextBox.TextChanged += ToggleAddOrUpdateButton; MachineNameTextBox.TextChanged += MachineNameTextBox_TextChanged; FolderGroupPathTextBox.TextChanged += ToggleGroupInsertButton; - FolderGroupNameTextBox.TextChanged += ToggleGroupInsertButton; FolderGroupListView.MouseClick += FolderGroupListView_MouseClick; deleteMenuItem.Click += DeleteMenuItem_Click; @@ -90,7 +90,7 @@ namespace DataOrganizer private void ToggleGroupInsertButton(object sender, EventArgs e) { - if (!string.IsNullOrEmpty(FolderGroupNameTextBox.Text) && !string.IsNullOrEmpty(FolderGroupPathTextBox.Text)) + if (!string.IsNullOrEmpty(FolderGroupPathTextBox.Text)) InsertGroupName.Enabled = true; else InsertGroupName.Enabled = false; @@ -207,34 +207,30 @@ namespace DataOrganizer private void InsertGroupName_Click(object sender, EventArgs e) { - var groupName = FolderGroupNameTextBox.Text.Trim(); + var dir = new DirectoryInfo(FolderGroupPathTextBox.Text); + var groupName = dir.Name; - if(!string.IsNullOrEmpty(groupName)) + if (!FolderGroupListView.Items.ContainsKey(groupName))//!FolderGroupsTreeView.Nodes.ContainsKey(groupName)) { - if (!FolderGroupListView.Items.ContainsKey(groupName))//!FolderGroupsTreeView.Nodes.ContainsKey(groupName)) + var item = new ListViewItem(groupName); + item.SubItems.Add(FolderGroupPathTextBox.Text); + + FolderGroupListView.Items.Add(item); + + if (IsUpdating) { - var item = new ListViewItem(groupName); - item.SubItems.Add(FolderGroupPathTextBox.Text); + var db = new DB(); - FolderGroupListView.Items.Add(item); + GetCurrentProfile(out DB.Profile profile); + var newId = db.InsertNewFolderGroup(profile, groupName, FolderGroupPathTextBox.Text); - if (IsUpdating) - { - var db = new DB(); - - GetCurrentProfile(out DB.Profile profile); - - var newId = db.InsertNewFolderGroup(profile, groupName, FolderGroupPathTextBox.Text); - - profile.FolderGroups.Add(new DB.FolderGroup { Name = groupName, Id = newId, Path = FolderGroupPathTextBox.Text }); - } + profile.FolderGroups.Add(new DB.FolderGroup { Name = groupName, Id = newId, Path = FolderGroupPathTextBox.Text }); } } - FolderGroupNameTextBox.Text = string.Empty; FolderGroupPathTextBox.Text = string.Empty; - FolderGroupNameTextBox.Focus(); + FolderGroupPathButton.Focus(); } private bool GetCurrentProfile(out DB.Profile profile)