From 9f090b0539ba313028a0536898f0f6ea6ffc5221 Mon Sep 17 00:00:00 2001 From: Admin Date: Mon, 9 Nov 2020 11:41:04 -0600 Subject: [PATCH] Tweaked the profile manager because I just can't leave well enough alone. Now it will name the folder group based on the path chosen, the user has no control over this. --- .vs/DataOrganizer/v16/.suo | Bin 49664 -> 47616 bytes DataOrganizer/ProfileManager.Designer.cs | 56 +++++++---------------- DataOrganizer/ProfileManager.cs | 36 +++++++-------- 3 files changed, 33 insertions(+), 59 deletions(-) diff --git a/.vs/DataOrganizer/v16/.suo b/.vs/DataOrganizer/v16/.suo index 608bdcefdd571e2309e798f3fef5911265bcb1ba..95abed7ce34af5966e0e5f95722251b64913ffc6 100644 GIT binary patch delta 1741 zcmZo@VQ%=sv>}IyufVF~`@U`081)$#7!IgTu41ZUoHqF@Q$3@~7#M;W7#IW@7#Knr z7#Kns7#I{87#KkE|DoXT|NsC0PE4FWi7AJ#VcOd0{oAfF%Hgz{J($sVvL}Z%YcvA` zgZgAe7U9WrI8+!tCm-Z+*KlTFU~pkzU~pw%U~pq#U~p$(VDNxi=f%Ll;LX6m;KRVc zFxh}pM=%2F7O?&Q|Ns9tF>&%Fu7JrI3Ot)x!j>>1vp4aTFfqDME)}R}beQ~Apq|lw za;acFqt)cEg7u6#n@ffMGvkw%_|M3wFu7FfKcoEQQt4)r*%B?b%(42BF03`QW2oKR4(04V?m zJp%)S9aJGm41}E+7#KjI0%F5L1;hs7$qI@FDxeq%V_;wiXJB9eg-9d=149%80|O{{ zV;C41Vi_11HkT+iFfv+i{;E{Z3i5{rvOhGdm_h!~1^Yv{o)hE`^TFy5%LYbPV+IC> zyOV!f{btnL{MA~FiN(#)#Bwsf-Cqf<7+*o5Yv&bx{j{Cbo0i}B^^a9k(ofrI@)=rJ%bykTMhg9q>a|DRm2 z%4YI`SP^Ch2CvDEahj9j{3cI|k(>M`L}YP89OGifEli6dSSB|V-(_K7U|^Z7$Rt0x zAt`L~O(u!S4el(H1!DO&l{zp^epjlu`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2}AnF+d7I zZUzR1G6v_(|7SZgPHvdiFj+ul-Q>KPL5mNpVw^l_uF&LpE_#!LW=Tz+J4Ir0(HcJ* u*ypgAaSO|&nFo-pG@HyZYscmTYaEy+KUx_zxnUODWQExaCe1p4AqD{NP~Rf} 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)