From a684a680c6d284175aa1f7b4562b8ea0d810efa7 Mon Sep 17 00:00:00 2001 From: Aaron Date: Fri, 10 Feb 2023 02:24:52 -0600 Subject: [PATCH 1/8] Added new UI elements --- Form1.Designer.cs | 124 +++++++++++++++++++++++++++++++++++++------- Form1.cs | 38 ++++++++++++-- photo_sorter.csproj | 4 +- 3 files changed, 143 insertions(+), 23 deletions(-) diff --git a/Form1.Designer.cs b/Form1.Designer.cs index 182b6fc..769d55a 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -65,7 +65,6 @@ namespace photo_sorter this.gbox_copybool = new System.Windows.Forms.GroupBox(); this.rad_sort_move = new System.Windows.Forms.RadioButton(); this.rad_sort_copy = new System.Windows.Forms.RadioButton(); - this.tbox_sort_secondary = new System.Windows.Forms.TextBox(); this.lbl_sort_secondary = new System.Windows.Forms.Label(); this.tbox_sort_primary = new System.Windows.Forms.TextBox(); this.lbl_sort_primary = new System.Windows.Forms.Label(); @@ -77,6 +76,13 @@ namespace photo_sorter this.split_container_main = new System.Windows.Forms.SplitContainer(); this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); this.btn_delete = new System.Windows.Forms.Button(); + this.btn_prerender = new System.Windows.Forms.Button(); + this.cbox_sort_secondary = new System.Windows.Forms.ComboBox(); + this.lbox_secondary_sortlist = new System.Windows.Forms.ListBox(); + this.tabctrl_sort_dir = new System.Windows.Forms.TabControl(); + this.tab_secondsort = new System.Windows.Forms.TabPage(); + this.tab_primesort = new System.Windows.Forms.TabPage(); + this.lbox_primary_sortlist = new System.Windows.Forms.ListBox(); this.menuStrip1.SuspendLayout(); this.gbox_preview.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.img_preview)).BeginInit(); @@ -88,6 +94,9 @@ namespace photo_sorter this.split_container_main.Panel1.SuspendLayout(); this.split_container_main.Panel2.SuspendLayout(); this.split_container_main.SuspendLayout(); + this.tabctrl_sort_dir.SuspendLayout(); + this.tab_secondsort.SuspendLayout(); + this.tab_primesort.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 @@ -271,6 +280,9 @@ namespace photo_sorter this.gbox_info.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.gbox_info.Controls.Add(this.tabctrl_sort_dir); + this.gbox_info.Controls.Add(this.cbox_sort_secondary); + this.gbox_info.Controls.Add(this.btn_prerender); this.gbox_info.Controls.Add(this.gbox_photo_type); this.gbox_info.Controls.Add(this.btn_reload_src); this.gbox_info.Controls.Add(this.btn_open_src_dir); @@ -280,12 +292,11 @@ namespace photo_sorter this.gbox_info.Controls.Add(this.tbox_dest_dir); this.gbox_info.Controls.Add(this.lbl_dest_dir); this.gbox_info.Controls.Add(this.gbox_copybool); - this.gbox_info.Controls.Add(this.tbox_sort_secondary); this.gbox_info.Controls.Add(this.lbl_sort_secondary); this.gbox_info.Controls.Add(this.tbox_sort_primary); this.gbox_info.Controls.Add(this.lbl_sort_primary); this.gbox_info.Location = new System.Drawing.Point(3, 3); - this.gbox_info.MinimumSize = new System.Drawing.Size(280, 320); + this.gbox_info.MinimumSize = new System.Drawing.Size(346, 540); this.gbox_info.Name = "gbox_info"; this.gbox_info.Size = new System.Drawing.Size(354, 540); this.gbox_info.TabIndex = 2; @@ -301,7 +312,7 @@ namespace photo_sorter this.gbox_photo_type.Controls.Add(this.rad_cr2); this.gbox_photo_type.Location = new System.Drawing.Point(7, 151); this.gbox_photo_type.Name = "gbox_photo_type"; - this.gbox_photo_type.Size = new System.Drawing.Size(142, 137); + this.gbox_photo_type.Size = new System.Drawing.Size(211, 89); this.gbox_photo_type.TabIndex = 4; this.gbox_photo_type.TabStop = false; this.gbox_photo_type.Text = "File Type"; @@ -319,7 +330,7 @@ namespace photo_sorter // rad_png // this.rad_png.AutoSize = true; - this.rad_png.Location = new System.Drawing.Point(6, 111); + this.rad_png.Location = new System.Drawing.Point(156, 42); this.rad_png.Name = "rad_png"; this.rad_png.Size = new System.Drawing.Size(48, 17); this.rad_png.TabIndex = 8; @@ -329,7 +340,7 @@ namespace photo_sorter // rad_jpeg // this.rad_jpeg.AutoSize = true; - this.rad_jpeg.Location = new System.Drawing.Point(6, 88); + this.rad_jpeg.Location = new System.Drawing.Point(156, 19); this.rad_jpeg.Name = "rad_jpeg"; this.rad_jpeg.Size = new System.Drawing.Size(45, 17); this.rad_jpeg.TabIndex = 7; @@ -466,15 +477,6 @@ namespace photo_sorter this.rad_sort_copy.Text = "Copy"; this.rad_sort_copy.UseVisualStyleBackColor = true; // - // tbox_sort_secondary - // - this.tbox_sort_secondary.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbox_sort_secondary.Location = new System.Drawing.Point(6, 123); - this.tbox_sort_secondary.Name = "tbox_sort_secondary"; - this.tbox_sort_secondary.Size = new System.Drawing.Size(342, 20); - this.tbox_sort_secondary.TabIndex = 3; - // // lbl_sort_secondary // this.lbl_sort_secondary.AutoSize = true; @@ -553,7 +555,7 @@ namespace photo_sorter // split_container_main.Panel1 // this.split_container_main.Panel1.Controls.Add(this.gbox_info); - this.split_container_main.Panel1MinSize = 320; + this.split_container_main.Panel1MinSize = 350; // // split_container_main.Panel2 // @@ -572,7 +574,84 @@ namespace photo_sorter this.btn_delete.TabIndex = 9; this.btn_delete.Text = "&Delete (!)"; this.btn_delete.UseVisualStyleBackColor = true; - this.btn_delete.Visible = false; + this.btn_delete.Click += new System.EventHandler(this.btn_delete_Click); + // + // btn_prerender + // + this.btn_prerender.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btn_prerender.Enabled = false; + this.btn_prerender.Location = new System.Drawing.Point(183, 488); + this.btn_prerender.Name = "btn_prerender"; + this.btn_prerender.Size = new System.Drawing.Size(75, 23); + this.btn_prerender.TabIndex = 903; + this.btn_prerender.Text = "Pre-R&ender"; + this.btn_prerender.UseVisualStyleBackColor = true; + this.btn_prerender.Click += new System.EventHandler(this.btn_prerender_Click); + // + // cbox_sort_secondary + // + this.cbox_sort_secondary.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cbox_sort_secondary.FormattingEnabled = true; + this.cbox_sort_secondary.Location = new System.Drawing.Point(6, 125); + this.cbox_sort_secondary.Name = "cbox_sort_secondary"; + this.cbox_sort_secondary.Size = new System.Drawing.Size(342, 21); + this.cbox_sort_secondary.TabIndex = 904; + // + // lbox_secondary_sortlist + // + this.lbox_secondary_sortlist.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbox_secondary_sortlist.FormattingEnabled = true; + this.lbox_secondary_sortlist.Location = new System.Drawing.Point(5, 6); + this.lbox_secondary_sortlist.Name = "lbox_secondary_sortlist"; + this.lbox_secondary_sortlist.Size = new System.Drawing.Size(323, 199); + this.lbox_secondary_sortlist.TabIndex = 0; + // + // tabctrl_sort_dir + // + this.tabctrl_sort_dir.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabctrl_sort_dir.Controls.Add(this.tab_primesort); + this.tabctrl_sort_dir.Controls.Add(this.tab_secondsort); + this.tabctrl_sort_dir.Location = new System.Drawing.Point(6, 246); + this.tabctrl_sort_dir.Name = "tabctrl_sort_dir"; + this.tabctrl_sort_dir.SelectedIndex = 0; + this.tabctrl_sort_dir.Size = new System.Drawing.Size(340, 236); + this.tabctrl_sort_dir.TabIndex = 0; + // + // tab_secondsort + // + this.tab_secondsort.Controls.Add(this.lbox_secondary_sortlist); + this.tab_secondsort.Location = new System.Drawing.Point(4, 22); + this.tab_secondsort.Name = "tab_secondsort"; + this.tab_secondsort.Padding = new System.Windows.Forms.Padding(3); + this.tab_secondsort.Size = new System.Drawing.Size(332, 210); + this.tab_secondsort.TabIndex = 1; + this.tab_secondsort.Text = "Secondary Sort Directories"; + // + // tab_primesort + // + this.tab_primesort.Controls.Add(this.lbox_primary_sortlist); + this.tab_primesort.Location = new System.Drawing.Point(4, 22); + this.tab_primesort.Name = "tab_primesort"; + this.tab_primesort.Padding = new System.Windows.Forms.Padding(3); + this.tab_primesort.Size = new System.Drawing.Size(332, 210); + this.tab_primesort.TabIndex = 0; + this.tab_primesort.Text = "Primary Sort Directories"; + // + // lbox_primary_sortlist + // + this.lbox_primary_sortlist.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbox_primary_sortlist.FormattingEnabled = true; + this.lbox_primary_sortlist.Location = new System.Drawing.Point(5, 6); + this.lbox_primary_sortlist.Name = "lbox_primary_sortlist"; + this.lbox_primary_sortlist.Size = new System.Drawing.Size(323, 199); + this.lbox_primary_sortlist.TabIndex = 1; // // form_main // @@ -604,6 +683,9 @@ namespace photo_sorter this.split_container_main.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.split_container_main)).EndInit(); this.split_container_main.ResumeLayout(false); + this.tabctrl_sort_dir.ResumeLayout(false); + this.tab_secondsort.ResumeLayout(false); + this.tab_primesort.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -628,7 +710,6 @@ namespace photo_sorter private System.Windows.Forms.GroupBox gbox_copybool; private System.Windows.Forms.RadioButton rad_sort_move; private System.Windows.Forms.RadioButton rad_sort_copy; - private System.Windows.Forms.TextBox tbox_sort_secondary; private System.Windows.Forms.Label lbl_sort_secondary; private System.Windows.Forms.TextBox tbox_sort_primary; private System.Windows.Forms.Label lbl_sort_primary; @@ -658,6 +739,13 @@ namespace photo_sorter private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.Button btn_delete; + private System.Windows.Forms.Button btn_prerender; + private System.Windows.Forms.ComboBox cbox_sort_secondary; + private System.Windows.Forms.ListBox lbox_secondary_sortlist; + private System.Windows.Forms.TabControl tabctrl_sort_dir; + private System.Windows.Forms.TabPage tab_primesort; + private System.Windows.Forms.ListBox lbox_primary_sortlist; + private System.Windows.Forms.TabPage tab_secondsort; } } diff --git a/Form1.cs b/Form1.cs index 8d495ea..6b0697a 100644 --- a/Form1.cs +++ b/Form1.cs @@ -349,7 +349,7 @@ namespace photo_sorter public void sort_image() { string prim_dir = global.dest + '\\' + tbox_sort_primary.Text; - string sec_dir = prim_dir + '\\' + tbox_sort_secondary.Text; + string sec_dir = prim_dir + '\\' + cbox_sort_secondary.Text; string dpath; if (global.dest == "") @@ -367,7 +367,7 @@ namespace photo_sorter //MessageBox.Show("Primary sort directory name is required!", "Error: Primary Sort", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (tbox_sort_secondary.Text == "") + if (cbox_sort_secondary.Text == "") { dpath = prim_dir; } @@ -455,6 +455,28 @@ namespace photo_sorter } } } + public void delete_image() + { + if (MessageBox.Show("Are you sure you want to delete this photo?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + MessageBox.Show("Poof! The photo would normally get deleted here if this function's code were completed, but alas, it is not, so this photo you have deemed to be subpar is still existing."); + } + else + { + MessageBox.Show("Forsooth! This photo is a keeper after all and would not have been deleted!"); + } + } + public void prerender_init() + { + if (MessageBox.Show("WARNING: Pre-rendering your photos may take a long time, and the preview image quality will be lower than normal.\n\nWould you like to proceed?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + MessageBox.Show("Pre-rendering would normally have started, but instead, nothing interesting happens."); + } + else + { + MessageBox.Show("You've chickened out and abandoned the pre-render process. Nothing interesting happens."); + } + } // // UI Interactions @@ -485,7 +507,7 @@ namespace photo_sorter private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("Photo Sorter v1.0.1\n\nThis application is Copyright \u00A9 Skyfall Tech, 2022-2023.\n\nPlease visit https://www.skyfall.tech/ for more information."); + MessageBox.Show("Photo Sorter v1.0.2\n\nThis application is Copyright \u00A9 Aaron Johnson, 2023.\n\nPlease visit https://www.skyfall.tech/ for more information."); } private void btn_open_src_dir_Click(object sender, EventArgs e) @@ -527,6 +549,16 @@ namespace photo_sorter Properties.Settings.Default.Save(); } + private void btn_delete_Click(object sender, EventArgs e) + { + delete_image(); + } + + private void btn_prerender_Click(object sender, EventArgs e) + { + prerender_init(); + } + /*private void Form1_FormClosing(Object sender, FormClosingEventArgs e) { diff --git a/photo_sorter.csproj b/photo_sorter.csproj index 3efbb7c..774a521 100644 --- a/photo_sorter.csproj +++ b/photo_sorter.csproj @@ -25,8 +25,8 @@ false false true - 2 - 1.0.1.2 + 0 + 1.0.1.0 false true From 802d2ea2e3c3ae4f888b193f1bccac43714bf260 Mon Sep 17 00:00:00 2001 From: Aaron Date: Fri, 10 Feb 2023 20:43:06 -0600 Subject: [PATCH 2/8] Rewrote hotkeys handling --- Form1.Designer.cs | 1 + Form1.cs | 75 +++++++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Form1.Designer.cs b/Form1.Designer.cs index 769d55a..e559d7a 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -662,6 +662,7 @@ namespace photo_sorter this.Controls.Add(this.menuStrip1); this.Controls.Add(this.split_container_main); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.KeyPreview = true; this.MainMenuStrip = this.menuStrip1; this.MinimumSize = new System.Drawing.Size(1024, 480); this.Name = "form_main"; diff --git a/Form1.cs b/Form1.cs index 6b0697a..2cf638d 100644 --- a/Form1.cs +++ b/Form1.cs @@ -273,52 +273,51 @@ namespace photo_sorter } } - protected override bool ProcessCmdKey(ref Message msg, Keys keyData) + protected override bool ProcessCmdKey(ref Message msg, Keys key_data) { if (tsi_enableGlobalHotkeys.Checked) { - if (keyData == Keys.Enter) + switch (key_data) { - sort_image(); - return true; - } - if (keyData == Keys.PageUp) - { - if (global.filecount > 1) - prev_image(); - return true; - } - if (keyData == Keys.PageDown) - { - if (global.filecount > 1) - next_image(); - return true; - } - if (keyData == Keys.Home) - { - if (global.filecount > 1) - { - status_msg("Loading first image..."); - global.position = 0; - update_image(); - } - return true; - } - if (keyData == Keys.End) - { - if (global.filecount > 1) - { - status_msg("Loading final image..."); - global.position = global.filecount - 1; - update_image(); - } - return true; + case Keys.PageUp: + if (global.filecount > 1) + prev_image(); + return true; + case Keys.PageDown: + if (global.filecount > 1) + next_image(); + return true; + case Keys.Shift | Keys.Home: + if (global.filecount > 1) + { + status_msg("Loading first image..."); + global.position = 0; + update_image(); + } + return true; + case Keys.Shift | Keys.End: + if (global.filecount > 1) + { + status_msg("Loading final image..."); + global.position = global.filecount - 1; + update_image(); + } + return true; + case Keys.Enter: + sort_image(); + return true; + case Keys.Delete: + delete_image(); + return true; + case Keys.Shift | Keys.Enter: + delete_image(); + return true; } } - return base.ProcessCmdKey(ref msg, keyData); + return base.ProcessCmdKey(ref msg, key_data); } - public void next_image() + public void next_image() { status_msg("Loading next image..."); if (global.position < global.filecount - 1) From ba8d8f0cd0a47065de9b8e5daa3019fed73b8c26 Mon Sep 17 00:00:00 2001 From: Aaron Date: Fri, 10 Feb 2023 20:59:09 -0600 Subject: [PATCH 3/8] Delete functionality added --- Form1.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Form1.cs b/Form1.cs index 2cf638d..c697767 100644 --- a/Form1.cs +++ b/Form1.cs @@ -458,11 +458,19 @@ namespace photo_sorter { if (MessageBox.Show("Are you sure you want to delete this photo?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - MessageBox.Show("Poof! The photo would normally get deleted here if this function's code were completed, but alas, it is not, so this photo you have deemed to be subpar is still existing."); - } - else - { - MessageBox.Show("Forsooth! This photo is a keeper after all and would not have been deleted!"); + string src_fname = global.filenames[global.position]; + try + { + File.Delete(src_fname); + status_msg("Deleted file: " + src_fname, 2); + remove_index(global.position); + update_image(); + } + catch (IOException ex) + { + status_msg("Unable to delete " + src_fname + "!", 4); + MessageBox.Show(ex.ToString(), "Critical: IO Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } } public void prerender_init() From 68861b3247cb841cf2ae18f81a9c7ece587bb9cf Mon Sep 17 00:00:00 2001 From: Aaron Date: Sat, 11 Feb 2023 00:16:20 -0600 Subject: [PATCH 4/8] Added sort autocomplete and dir lists --- Form1.Designer.cs | 243 +++++++++++++++++--------------- Form1.cs | 107 +++++++++++++- Properties/Settings.Designer.cs | 22 +++ Properties/Settings.settings | 6 + photo_sorter.csproj | 2 +- 5 files changed, 258 insertions(+), 122 deletions(-) diff --git a/Form1.Designer.cs b/Form1.Designer.cs index e559d7a..b644226 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -42,6 +42,7 @@ namespace photo_sorter this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.tsi_about = new System.Windows.Forms.ToolStripMenuItem(); this.gbox_preview = new System.Windows.Forms.GroupBox(); + this.btn_delete = new System.Windows.Forms.Button(); this.lbl_counter = new System.Windows.Forms.Label(); this.lbl_current_fname = new System.Windows.Forms.Label(); this.btn_next = new System.Windows.Forms.Button(); @@ -49,6 +50,14 @@ namespace photo_sorter this.btn_sort = new System.Windows.Forms.Button(); this.img_preview = new System.Windows.Forms.PictureBox(); this.gbox_info = new System.Windows.Forms.GroupBox(); + this.cbox_sort_primary = new System.Windows.Forms.ComboBox(); + this.tabctrl_sort_dir = new System.Windows.Forms.TabControl(); + this.tab_primesort = new System.Windows.Forms.TabPage(); + this.lbox_primary_sortlist = new System.Windows.Forms.ListBox(); + this.tab_secondsort = new System.Windows.Forms.TabPage(); + this.lbox_secondary_sortlist = new System.Windows.Forms.ListBox(); + this.cbox_sort_secondary = new System.Windows.Forms.ComboBox(); + this.btn_prerender = new System.Windows.Forms.Button(); this.gbox_photo_type = new System.Windows.Forms.GroupBox(); this.rad_dng = new System.Windows.Forms.RadioButton(); this.rad_png = new System.Windows.Forms.RadioButton(); @@ -66,7 +75,6 @@ namespace photo_sorter this.rad_sort_move = new System.Windows.Forms.RadioButton(); this.rad_sort_copy = new System.Windows.Forms.RadioButton(); this.lbl_sort_secondary = new System.Windows.Forms.Label(); - this.tbox_sort_primary = new System.Windows.Forms.TextBox(); this.lbl_sort_primary = new System.Windows.Forms.Label(); this.status_bar = new System.Windows.Forms.StatusStrip(); this.stat_last_action = new System.Windows.Forms.ToolStripStatusLabel(); @@ -75,18 +83,13 @@ namespace photo_sorter this.pbar = new System.Windows.Forms.ToolStripProgressBar(); this.split_container_main = new System.Windows.Forms.SplitContainer(); this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); - this.btn_delete = new System.Windows.Forms.Button(); - this.btn_prerender = new System.Windows.Forms.Button(); - this.cbox_sort_secondary = new System.Windows.Forms.ComboBox(); - this.lbox_secondary_sortlist = new System.Windows.Forms.ListBox(); - this.tabctrl_sort_dir = new System.Windows.Forms.TabControl(); - this.tab_secondsort = new System.Windows.Forms.TabPage(); - this.tab_primesort = new System.Windows.Forms.TabPage(); - this.lbox_primary_sortlist = new System.Windows.Forms.ListBox(); this.menuStrip1.SuspendLayout(); this.gbox_preview.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.img_preview)).BeginInit(); this.gbox_info.SuspendLayout(); + this.tabctrl_sort_dir.SuspendLayout(); + this.tab_primesort.SuspendLayout(); + this.tab_secondsort.SuspendLayout(); this.gbox_photo_type.SuspendLayout(); this.gbox_copybool.SuspendLayout(); this.status_bar.SuspendLayout(); @@ -94,9 +97,6 @@ namespace photo_sorter this.split_container_main.Panel1.SuspendLayout(); this.split_container_main.Panel2.SuspendLayout(); this.split_container_main.SuspendLayout(); - this.tabctrl_sort_dir.SuspendLayout(); - this.tab_secondsort.SuspendLayout(); - this.tab_primesort.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 @@ -208,6 +208,17 @@ namespace photo_sorter this.gbox_preview.TabStop = false; this.gbox_preview.Text = "Preview"; // + // btn_delete + // + this.btn_delete.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.btn_delete.Location = new System.Drawing.Point(528, 13); + this.btn_delete.Name = "btn_delete"; + this.btn_delete.Size = new System.Drawing.Size(75, 23); + this.btn_delete.TabIndex = 9; + this.btn_delete.Text = "&Delete (!)"; + this.btn_delete.UseVisualStyleBackColor = true; + this.btn_delete.Click += new System.EventHandler(this.btn_delete_Click); + // // lbl_counter // this.lbl_counter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -280,6 +291,7 @@ namespace photo_sorter this.gbox_info.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.gbox_info.Controls.Add(this.cbox_sort_primary); this.gbox_info.Controls.Add(this.tabctrl_sort_dir); this.gbox_info.Controls.Add(this.cbox_sort_secondary); this.gbox_info.Controls.Add(this.btn_prerender); @@ -293,7 +305,6 @@ namespace photo_sorter this.gbox_info.Controls.Add(this.lbl_dest_dir); this.gbox_info.Controls.Add(this.gbox_copybool); this.gbox_info.Controls.Add(this.lbl_sort_secondary); - this.gbox_info.Controls.Add(this.tbox_sort_primary); this.gbox_info.Controls.Add(this.lbl_sort_primary); this.gbox_info.Location = new System.Drawing.Point(3, 3); this.gbox_info.MinimumSize = new System.Drawing.Size(346, 540); @@ -303,6 +314,104 @@ namespace photo_sorter this.gbox_info.TabStop = false; this.gbox_info.Text = "Sorting Info"; // + // cbox_sort_primary + // + this.cbox_sort_primary.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cbox_sort_primary.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Append; + this.cbox_sort_primary.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.cbox_sort_primary.FormattingEnabled = true; + this.cbox_sort_primary.Location = new System.Drawing.Point(5, 81); + this.cbox_sort_primary.Name = "cbox_sort_primary"; + this.cbox_sort_primary.Size = new System.Drawing.Size(343, 21); + this.cbox_sort_primary.TabIndex = 2; + this.cbox_sort_primary.Enter += new System.EventHandler(this.cbox_sort_primary_Enter); + this.cbox_sort_primary.Leave += new System.EventHandler(this.cbox_sortfields_Leave); + // + // tabctrl_sort_dir + // + this.tabctrl_sort_dir.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabctrl_sort_dir.Controls.Add(this.tab_primesort); + this.tabctrl_sort_dir.Controls.Add(this.tab_secondsort); + this.tabctrl_sort_dir.Location = new System.Drawing.Point(6, 246); + this.tabctrl_sort_dir.Name = "tabctrl_sort_dir"; + this.tabctrl_sort_dir.SelectedIndex = 0; + this.tabctrl_sort_dir.Size = new System.Drawing.Size(340, 236); + this.tabctrl_sort_dir.TabIndex = 0; + // + // tab_primesort + // + this.tab_primesort.Controls.Add(this.lbox_primary_sortlist); + this.tab_primesort.Location = new System.Drawing.Point(4, 22); + this.tab_primesort.Name = "tab_primesort"; + this.tab_primesort.Padding = new System.Windows.Forms.Padding(3); + this.tab_primesort.Size = new System.Drawing.Size(332, 210); + this.tab_primesort.TabIndex = 0; + this.tab_primesort.Text = "Primary Sort Directories"; + // + // lbox_primary_sortlist + // + this.lbox_primary_sortlist.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbox_primary_sortlist.FormattingEnabled = true; + this.lbox_primary_sortlist.Location = new System.Drawing.Point(5, 6); + this.lbox_primary_sortlist.Name = "lbox_primary_sortlist"; + this.lbox_primary_sortlist.Size = new System.Drawing.Size(323, 199); + this.lbox_primary_sortlist.TabIndex = 1; + this.lbox_primary_sortlist.DoubleClick += new System.EventHandler(this.lbox_primary_sortlist_SelectItem); + // + // tab_secondsort + // + this.tab_secondsort.Controls.Add(this.lbox_secondary_sortlist); + this.tab_secondsort.Location = new System.Drawing.Point(4, 22); + this.tab_secondsort.Name = "tab_secondsort"; + this.tab_secondsort.Padding = new System.Windows.Forms.Padding(3); + this.tab_secondsort.Size = new System.Drawing.Size(332, 210); + this.tab_secondsort.TabIndex = 1; + this.tab_secondsort.Text = "Secondary Sort Directories"; + // + // lbox_secondary_sortlist + // + this.lbox_secondary_sortlist.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbox_secondary_sortlist.FormattingEnabled = true; + this.lbox_secondary_sortlist.Location = new System.Drawing.Point(5, 6); + this.lbox_secondary_sortlist.Name = "lbox_secondary_sortlist"; + this.lbox_secondary_sortlist.Size = new System.Drawing.Size(323, 199); + this.lbox_secondary_sortlist.TabIndex = 0; + this.lbox_secondary_sortlist.DoubleClick += new System.EventHandler(this.lbox_secondary_sortlist_SelectItem); + // + // cbox_sort_secondary + // + this.cbox_sort_secondary.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cbox_sort_secondary.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Append; + this.cbox_sort_secondary.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + this.cbox_sort_secondary.FormattingEnabled = true; + this.cbox_sort_secondary.Location = new System.Drawing.Point(5, 125); + this.cbox_sort_secondary.Name = "cbox_sort_secondary"; + this.cbox_sort_secondary.Size = new System.Drawing.Size(343, 21); + this.cbox_sort_secondary.TabIndex = 3; + this.cbox_sort_secondary.Enter += new System.EventHandler(this.cbox_sort_secondary_Enter); + this.cbox_sort_secondary.Leave += new System.EventHandler(this.cbox_sortfields_Leave); + // + // btn_prerender + // + this.btn_prerender.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btn_prerender.Enabled = false; + this.btn_prerender.Location = new System.Drawing.Point(183, 488); + this.btn_prerender.Name = "btn_prerender"; + this.btn_prerender.Size = new System.Drawing.Size(75, 23); + this.btn_prerender.TabIndex = 903; + this.btn_prerender.Text = "Pre-R&ender"; + this.btn_prerender.UseVisualStyleBackColor = true; + this.btn_prerender.Visible = false; + this.btn_prerender.Click += new System.EventHandler(this.btn_prerender_Click); + // // gbox_photo_type // this.gbox_photo_type.Controls.Add(this.rad_dng); @@ -486,15 +595,6 @@ namespace photo_sorter this.lbl_sort_secondary.TabIndex = 2; this.lbl_sort_secondary.Text = "Secondary Sort (e.g. Subject Name):"; // - // tbox_sort_primary - // - this.tbox_sort_primary.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbox_sort_primary.Location = new System.Drawing.Point(6, 79); - this.tbox_sort_primary.Name = "tbox_sort_primary"; - this.tbox_sort_primary.Size = new System.Drawing.Size(342, 20); - this.tbox_sort_primary.TabIndex = 2; - // // lbl_sort_primary // this.lbl_sort_primary.AutoSize = true; @@ -565,94 +665,6 @@ namespace photo_sorter this.split_container_main.SplitterDistance = 360; this.split_container_main.TabIndex = 4; // - // btn_delete - // - this.btn_delete.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.btn_delete.Location = new System.Drawing.Point(528, 13); - this.btn_delete.Name = "btn_delete"; - this.btn_delete.Size = new System.Drawing.Size(75, 23); - this.btn_delete.TabIndex = 9; - this.btn_delete.Text = "&Delete (!)"; - this.btn_delete.UseVisualStyleBackColor = true; - this.btn_delete.Click += new System.EventHandler(this.btn_delete_Click); - // - // btn_prerender - // - this.btn_prerender.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btn_prerender.Enabled = false; - this.btn_prerender.Location = new System.Drawing.Point(183, 488); - this.btn_prerender.Name = "btn_prerender"; - this.btn_prerender.Size = new System.Drawing.Size(75, 23); - this.btn_prerender.TabIndex = 903; - this.btn_prerender.Text = "Pre-R&ender"; - this.btn_prerender.UseVisualStyleBackColor = true; - this.btn_prerender.Click += new System.EventHandler(this.btn_prerender_Click); - // - // cbox_sort_secondary - // - this.cbox_sort_secondary.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.cbox_sort_secondary.FormattingEnabled = true; - this.cbox_sort_secondary.Location = new System.Drawing.Point(6, 125); - this.cbox_sort_secondary.Name = "cbox_sort_secondary"; - this.cbox_sort_secondary.Size = new System.Drawing.Size(342, 21); - this.cbox_sort_secondary.TabIndex = 904; - // - // lbox_secondary_sortlist - // - this.lbox_secondary_sortlist.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lbox_secondary_sortlist.FormattingEnabled = true; - this.lbox_secondary_sortlist.Location = new System.Drawing.Point(5, 6); - this.lbox_secondary_sortlist.Name = "lbox_secondary_sortlist"; - this.lbox_secondary_sortlist.Size = new System.Drawing.Size(323, 199); - this.lbox_secondary_sortlist.TabIndex = 0; - // - // tabctrl_sort_dir - // - this.tabctrl_sort_dir.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tabctrl_sort_dir.Controls.Add(this.tab_primesort); - this.tabctrl_sort_dir.Controls.Add(this.tab_secondsort); - this.tabctrl_sort_dir.Location = new System.Drawing.Point(6, 246); - this.tabctrl_sort_dir.Name = "tabctrl_sort_dir"; - this.tabctrl_sort_dir.SelectedIndex = 0; - this.tabctrl_sort_dir.Size = new System.Drawing.Size(340, 236); - this.tabctrl_sort_dir.TabIndex = 0; - // - // tab_secondsort - // - this.tab_secondsort.Controls.Add(this.lbox_secondary_sortlist); - this.tab_secondsort.Location = new System.Drawing.Point(4, 22); - this.tab_secondsort.Name = "tab_secondsort"; - this.tab_secondsort.Padding = new System.Windows.Forms.Padding(3); - this.tab_secondsort.Size = new System.Drawing.Size(332, 210); - this.tab_secondsort.TabIndex = 1; - this.tab_secondsort.Text = "Secondary Sort Directories"; - // - // tab_primesort - // - this.tab_primesort.Controls.Add(this.lbox_primary_sortlist); - this.tab_primesort.Location = new System.Drawing.Point(4, 22); - this.tab_primesort.Name = "tab_primesort"; - this.tab_primesort.Padding = new System.Windows.Forms.Padding(3); - this.tab_primesort.Size = new System.Drawing.Size(332, 210); - this.tab_primesort.TabIndex = 0; - this.tab_primesort.Text = "Primary Sort Directories"; - // - // lbox_primary_sortlist - // - this.lbox_primary_sortlist.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lbox_primary_sortlist.FormattingEnabled = true; - this.lbox_primary_sortlist.Location = new System.Drawing.Point(5, 6); - this.lbox_primary_sortlist.Name = "lbox_primary_sortlist"; - this.lbox_primary_sortlist.Size = new System.Drawing.Size(323, 199); - this.lbox_primary_sortlist.TabIndex = 1; - // // form_main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -664,9 +676,10 @@ namespace photo_sorter this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.KeyPreview = true; this.MainMenuStrip = this.menuStrip1; - this.MinimumSize = new System.Drawing.Size(1024, 480); + this.MinimumSize = new System.Drawing.Size(1040, 640); this.Name = "form_main"; this.Text = "Skyfall Photo Sorter"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.gbox_preview.ResumeLayout(false); @@ -674,6 +687,9 @@ namespace photo_sorter ((System.ComponentModel.ISupportInitialize)(this.img_preview)).EndInit(); this.gbox_info.ResumeLayout(false); this.gbox_info.PerformLayout(); + this.tabctrl_sort_dir.ResumeLayout(false); + this.tab_primesort.ResumeLayout(false); + this.tab_secondsort.ResumeLayout(false); this.gbox_photo_type.ResumeLayout(false); this.gbox_photo_type.PerformLayout(); this.gbox_copybool.ResumeLayout(false); @@ -684,9 +700,6 @@ namespace photo_sorter this.split_container_main.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.split_container_main)).EndInit(); this.split_container_main.ResumeLayout(false); - this.tabctrl_sort_dir.ResumeLayout(false); - this.tab_secondsort.ResumeLayout(false); - this.tab_primesort.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -712,7 +725,6 @@ namespace photo_sorter private System.Windows.Forms.RadioButton rad_sort_move; private System.Windows.Forms.RadioButton rad_sort_copy; private System.Windows.Forms.Label lbl_sort_secondary; - private System.Windows.Forms.TextBox tbox_sort_primary; private System.Windows.Forms.Label lbl_sort_primary; private System.Windows.Forms.StatusStrip status_bar; private System.Windows.Forms.ToolStripStatusLabel stat_last_action; @@ -747,6 +759,7 @@ namespace photo_sorter private System.Windows.Forms.TabPage tab_primesort; private System.Windows.Forms.ListBox lbox_primary_sortlist; private System.Windows.Forms.TabPage tab_secondsort; + private System.Windows.Forms.ComboBox cbox_sort_primary; } } diff --git a/Form1.cs b/Form1.cs index c697767..ccf22c6 100644 --- a/Form1.cs +++ b/Form1.cs @@ -9,6 +9,7 @@ using System.Drawing; //using System.Text; //using System.Threading.Tasks; using System.Windows.Forms; +using System.Collections;//.ArrayList; using System.IO; using ImageMagick; @@ -50,6 +51,10 @@ namespace photo_sorter { rad_sort_copy.Checked = true; } + else + { + rad_sort_move.Checked = true; + } tbox_dest_dir.Text = Properties.Settings.Default.dest_dir; tbox_source_dir.Text = Properties.Settings.Default.src_dir; @@ -58,6 +63,14 @@ namespace photo_sorter btn_reload_src.Enabled = true; reload_source(); } + if (Properties.Settings.Default.cbi_primary != null) + { + cbox_sort_primary.Items.AddRange(Properties.Settings.Default.cbi_primary.ToArray()); + } + if (Properties.Settings.Default.cbi_secondary != null) + { + cbox_sort_secondary.Items.AddRange(Properties.Settings.Default.cbi_secondary.ToArray()); + } } static class global @@ -122,6 +135,31 @@ namespace photo_sorter } } + private void populate_directory_lists() + { + //string[] pdir = Directory.GetDirectories(global.dest); + //string[] sdir = Directory.GetDirectories(global.dest + "\\" + cbox_sort_primary.Text); + + lbox_primary_sortlist.Items.Clear(); + foreach (var d in Directory.GetDirectories(global.dest)) + { + var dir = new DirectoryInfo(d).Name; + lbox_primary_sortlist.Items.Add(dir); + } + if (cbox_sort_primary.Text.Length > 0) + { + if (Directory.Exists(global.dest + "\\" + cbox_sort_primary.Text)) + { + lbox_secondary_sortlist.Items.Clear(); + foreach (var d in Directory.GetDirectories(global.dest + "\\" + cbox_sort_primary.Text)) + { + var dir = new DirectoryInfo(d).Name; + lbox_secondary_sortlist.Items.Add(dir); + } + } + } + } + private void select_source_dir() { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) @@ -235,6 +273,7 @@ namespace photo_sorter status_msg("Loaded image: " + lbl_current_fname.Text); update_counter(); pbar.Value = 0; + populate_directory_lists(); } public string[] populate_file_names() @@ -347,7 +386,7 @@ namespace photo_sorter public void sort_image() { - string prim_dir = global.dest + '\\' + tbox_sort_primary.Text; + string prim_dir = global.dest + '\\' + cbox_sort_primary.Text; string sec_dir = prim_dir + '\\' + cbox_sort_secondary.Text; string dpath; @@ -359,7 +398,7 @@ namespace photo_sorter return; } - if (tbox_sort_primary.Text == "") + if (cbox_sort_primary.Text == "") { status_msg("Primary sort field required to sort!", 3); //System.Media.SystemSounds.Exclamation.Play(); @@ -403,7 +442,6 @@ namespace photo_sorter } } File.Move(@src_fname, @dst_fname); - //status_msg("Moved " + lbl_current_fname.Text + " to " + dpath); status_msg("Moved " + global.filenames[global.position] + " to " + dpath); remove_index(global.position); update_image(); @@ -447,6 +485,31 @@ namespace photo_sorter status_msg("Unable to copy " + global.filenames[global.position] + " to " + dpath + "!", 4); MessageBox.Show(ex.ToString(), "Critical: IO Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } + // Begin Update comboboxes + if (cbox_sort_primary.Items.Contains(cbox_sort_primary.Text)) + { + //Remove and re-add, to put it at the new end of the list + cbox_sort_primary.Items.Remove(cbox_sort_primary.Text); + cbox_sort_primary.Items.Add(cbox_sort_primary.Text); + } + else + { + cbox_sort_primary.Items.Add(cbox_sort_primary.Text); + } + if (cbox_sort_secondary.Text.Length > 0) + { + if (cbox_sort_secondary.Items.Contains(cbox_sort_secondary.Text)) + { + //Remove and re-add, to put it at the new end of the list + cbox_sort_secondary.Items.Remove(cbox_sort_secondary.Text); + cbox_sort_secondary.Items.Add(cbox_sort_secondary.Text); + } + else + { + cbox_sort_secondary.Items.Add(cbox_sort_secondary.Text); + } + } + // End combobox updating if (!Properties.Settings.Default.copy_on_sort) { Properties.Settings.Default.copy_on_sort = true; @@ -566,17 +629,49 @@ namespace photo_sorter prerender_init(); } + private void cbox_sortfields_Leave(object sender, EventArgs e) + { + populate_directory_lists(); + } + private void cbox_sort_primary_Enter(object sender, EventArgs e) + { + populate_directory_lists(); + tabctrl_sort_dir.SelectedTab = tabctrl_sort_dir.TabPages["tab_primesort"]; + cbox_sort_primary.Focus(); + } + private void cbox_sort_secondary_Enter(object sender, EventArgs e) + { + if (cbox_sort_primary.Text.Length > 0) + { + populate_directory_lists(); + tabctrl_sort_dir.SelectedTab = tabctrl_sort_dir.TabPages["tab_secondsort"]; + cbox_sort_secondary.Focus(); + } + } + private void lbox_primary_sortlist_SelectItem(object sender, EventArgs e) + { + cbox_sort_primary.Text = lbox_primary_sortlist.SelectedItem.ToString(); + populate_directory_lists(); + } + private void lbox_secondary_sortlist_SelectItem(object sender, EventArgs e) + { + cbox_sort_secondary.Text = lbox_secondary_sortlist.SelectedItem.ToString(); + } - /*private void Form1_FormClosing(Object sender, FormClosingEventArgs e) + private void Form1_FormClosing(Object sender, FormClosingEventArgs e) { if (MessageBox.Show("Are you sure you want to quit the Photo Sorter application?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - this.Close(); + ArrayList cbi_primary = new ArrayList(this.cbox_sort_primary.Items); + ArrayList cbi_secondary = new ArrayList(this.cbox_sort_secondary.Items); + Properties.Settings.Default.cbi_primary = cbi_primary; + Properties.Settings.Default.cbi_secondary = cbi_secondary; + Properties.Settings.Default.Save(); } else { e.Cancel = true; } - }*/ + } } } diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index c8b35e6..63f2a69 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -82,5 +82,27 @@ namespace photo_sorter.Properties { this["img_format"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Collections.ArrayList cbi_primary { + get { + return ((global::System.Collections.ArrayList)(this["cbi_primary"])); + } + set { + this["cbi_primary"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Collections.ArrayList cbi_secondary { + get { + return ((global::System.Collections.ArrayList)(this["cbi_secondary"])); + } + set { + this["cbi_secondary"] = value; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index 01ef709..aff7b3c 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -17,5 +17,11 @@ nef + + + + + + \ No newline at end of file diff --git a/photo_sorter.csproj b/photo_sorter.csproj index 774a521..bd5e482 100644 --- a/photo_sorter.csproj +++ b/photo_sorter.csproj @@ -26,7 +26,7 @@ false true 0 - 1.0.1.0 + 1.0.2.0 false true From 894b22cff5e3059499145848d4cf4c66c4a10889 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sat, 11 Feb 2023 01:13:32 -0600 Subject: [PATCH 5/8] Added list pruning and fine tuning --- Form1.Designer.cs | 20 +++++++------- Form1.cs | 66 +++++++++++++++++++++++++++++++---------------- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/Form1.Designer.cs b/Form1.Designer.cs index b644226..008a7ba 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -214,7 +214,7 @@ namespace photo_sorter this.btn_delete.Location = new System.Drawing.Point(528, 13); this.btn_delete.Name = "btn_delete"; this.btn_delete.Size = new System.Drawing.Size(75, 23); - this.btn_delete.TabIndex = 9; + this.btn_delete.TabIndex = 33; this.btn_delete.Text = "&Delete (!)"; this.btn_delete.UseVisualStyleBackColor = true; this.btn_delete.Click += new System.EventHandler(this.btn_delete_Click); @@ -245,7 +245,7 @@ namespace photo_sorter this.btn_next.Location = new System.Drawing.Point(398, 13); this.btn_next.Name = "btn_next"; this.btn_next.Size = new System.Drawing.Size(75, 23); - this.btn_next.TabIndex = 8; + this.btn_next.TabIndex = 32; this.btn_next.Text = "&Next >>"; this.btn_next.UseVisualStyleBackColor = true; this.btn_next.Click += new System.EventHandler(this.btn_next_Click); @@ -256,7 +256,7 @@ namespace photo_sorter this.btn_prev.Location = new System.Drawing.Point(236, 13); this.btn_prev.Name = "btn_prev"; this.btn_prev.Size = new System.Drawing.Size(75, 23); - this.btn_prev.TabIndex = 6; + this.btn_prev.TabIndex = 30; this.btn_prev.Text = "<< &Previous"; this.btn_prev.UseVisualStyleBackColor = true; this.btn_prev.Click += new System.EventHandler(this.btn_prev_Click); @@ -267,7 +267,7 @@ namespace photo_sorter this.btn_sort.Location = new System.Drawing.Point(317, 13); this.btn_sort.Name = "btn_sort"; this.btn_sort.Size = new System.Drawing.Size(75, 23); - this.btn_sort.TabIndex = 7; + this.btn_sort.TabIndex = 31; this.btn_sort.Text = "&Sort"; this.btn_sort.UseVisualStyleBackColor = true; this.btn_sort.Click += new System.EventHandler(this.btn_sort_Click); @@ -339,7 +339,7 @@ namespace photo_sorter this.tabctrl_sort_dir.Name = "tabctrl_sort_dir"; this.tabctrl_sort_dir.SelectedIndex = 0; this.tabctrl_sort_dir.Size = new System.Drawing.Size(340, 236); - this.tabctrl_sort_dir.TabIndex = 0; + this.tabctrl_sort_dir.TabIndex = 13; // // tab_primesort // @@ -360,7 +360,7 @@ namespace photo_sorter this.lbox_primary_sortlist.Location = new System.Drawing.Point(5, 6); this.lbox_primary_sortlist.Name = "lbox_primary_sortlist"; this.lbox_primary_sortlist.Size = new System.Drawing.Size(323, 199); - this.lbox_primary_sortlist.TabIndex = 1; + this.lbox_primary_sortlist.TabIndex = 14; this.lbox_primary_sortlist.DoubleClick += new System.EventHandler(this.lbox_primary_sortlist_SelectItem); // // tab_secondsort @@ -382,7 +382,7 @@ namespace photo_sorter this.lbox_secondary_sortlist.Location = new System.Drawing.Point(5, 6); this.lbox_secondary_sortlist.Name = "lbox_secondary_sortlist"; this.lbox_secondary_sortlist.Size = new System.Drawing.Size(323, 199); - this.lbox_secondary_sortlist.TabIndex = 0; + this.lbox_secondary_sortlist.TabIndex = 15; this.lbox_secondary_sortlist.DoubleClick += new System.EventHandler(this.lbox_secondary_sortlist_SelectItem); // // cbox_sort_secondary @@ -406,7 +406,7 @@ namespace photo_sorter this.btn_prerender.Location = new System.Drawing.Point(183, 488); this.btn_prerender.Name = "btn_prerender"; this.btn_prerender.Size = new System.Drawing.Size(75, 23); - this.btn_prerender.TabIndex = 903; + this.btn_prerender.TabIndex = 16; this.btn_prerender.Text = "Pre-R&ender"; this.btn_prerender.UseVisualStyleBackColor = true; this.btn_prerender.Visible = false; @@ -485,7 +485,7 @@ namespace photo_sorter this.btn_reload_src.Location = new System.Drawing.Point(274, 488); this.btn_reload_src.Name = "btn_reload_src"; this.btn_reload_src.Size = new System.Drawing.Size(75, 23); - this.btn_reload_src.TabIndex = 901; + this.btn_reload_src.TabIndex = 17; this.btn_reload_src.Text = "&Reload"; this.btn_reload_src.UseVisualStyleBackColor = true; this.btn_reload_src.Click += new System.EventHandler(this.btn_reload_src_Click); @@ -496,7 +496,7 @@ namespace photo_sorter this.btn_open_src_dir.Location = new System.Drawing.Point(323, 512); this.btn_open_src_dir.Name = "btn_open_src_dir"; this.btn_open_src_dir.Size = new System.Drawing.Size(26, 23); - this.btn_open_src_dir.TabIndex = 902; + this.btn_open_src_dir.TabIndex = 18; this.btn_open_src_dir.Text = "..."; this.btn_open_src_dir.UseVisualStyleBackColor = true; this.btn_open_src_dir.Click += new System.EventHandler(this.btn_open_src_dir_Click); diff --git a/Form1.cs b/Form1.cs index ccf22c6..ed89978 100644 --- a/Form1.cs +++ b/Form1.cs @@ -31,7 +31,7 @@ namespace photo_sorter case "dng": rad_dng.Checked = true; break; - case "jpeg": + case "jpg": rad_jpeg.Checked = true; break; case "png": @@ -79,7 +79,8 @@ namespace photo_sorter public static string src = Properties.Settings.Default.src_dir; public static string[] filenames; public static int filecount; - public static int position = 0; + public static int position = 0; //File position index + public const int cbox_size = 8; //Number of entries allowed in cbox lists } public void status_msg(string msg, int lvl = 1) @@ -171,7 +172,7 @@ namespace photo_sorter if (Properties.Settings.Default.src_dir != global.src) { Properties.Settings.Default.src_dir = global.src; - Properties.Settings.Default.Save(); + //Properties.Settings.Default.Save(); } reload_source(); } @@ -186,7 +187,7 @@ namespace photo_sorter if (Properties.Settings.Default.dest_dir != global.dest) { Properties.Settings.Default.dest_dir = global.dest; - Properties.Settings.Default.Save(); + //Properties.Settings.Default.Save(); } status_msg("Destination directory updated"); } @@ -290,11 +291,6 @@ namespace photo_sorter if (rad_png.Checked) ext = "png"; string[] files = Directory.GetFiles(global.src, "*." + ext); - if (Properties.Settings.Default.img_format != ext) - { - Properties.Settings.Default.img_format = ext; - Properties.Settings.Default.Save(); - } return files; } @@ -451,11 +447,6 @@ namespace photo_sorter status_msg("Unable to move " + global.filenames[global.position] + " to " + dpath + "!", 4); MessageBox.Show(ex.ToString(), "Critical: IO Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } - if (Properties.Settings.Default.copy_on_sort) - { - Properties.Settings.Default.copy_on_sort = false; - Properties.Settings.Default.Save(); - } } else { @@ -489,8 +480,10 @@ namespace photo_sorter if (cbox_sort_primary.Items.Contains(cbox_sort_primary.Text)) { //Remove and re-add, to put it at the new end of the list - cbox_sort_primary.Items.Remove(cbox_sort_primary.Text); - cbox_sort_primary.Items.Add(cbox_sort_primary.Text); + string t = cbox_sort_primary.Text; + cbox_sort_primary.Items.Remove(t); + cbox_sort_primary.Items.Add(t); + cbox_sort_primary.Text = t; } else { @@ -501,20 +494,26 @@ namespace photo_sorter if (cbox_sort_secondary.Items.Contains(cbox_sort_secondary.Text)) { //Remove and re-add, to put it at the new end of the list - cbox_sort_secondary.Items.Remove(cbox_sort_secondary.Text); - cbox_sort_secondary.Items.Add(cbox_sort_secondary.Text); + string t = cbox_sort_secondary.Text; + cbox_sort_secondary.Items.Remove(t); + cbox_sort_secondary.Items.Add(t); + cbox_sort_secondary.Text = t; } else { cbox_sort_secondary.Items.Add(cbox_sort_secondary.Text); } } - // End combobox updating - if (!Properties.Settings.Default.copy_on_sort) + //Prune the lists + while (cbox_sort_primary.Items.Count > global.cbox_size) { - Properties.Settings.Default.copy_on_sort = true; - Properties.Settings.Default.Save(); + cbox_sort_primary.Items.RemoveAt(0); } + while (cbox_sort_secondary.Items.Count > global.cbox_size) + { + cbox_sort_secondary.Items.RemoveAt(0); + } + // End combobox updating } } public void delete_image() @@ -666,6 +665,29 @@ namespace photo_sorter ArrayList cbi_secondary = new ArrayList(this.cbox_sort_secondary.Items); Properties.Settings.Default.cbi_primary = cbi_primary; Properties.Settings.Default.cbi_secondary = cbi_secondary; + + if (rad_sort_copy.Checked) + { + Properties.Settings.Default.copy_on_sort = true; + } + else + { + Properties.Settings.Default.copy_on_sort = false; + } + + string ext = ""; + if (rad_nef.Checked) + ext = "nef"; + if (rad_cr2.Checked) + ext = "cr2"; + if (rad_dng.Checked) + ext = "dng"; + if (rad_jpeg.Checked) + ext = "jpg"; + if (rad_png.Checked) + ext = "png"; + Properties.Settings.Default.img_format = ext; + Properties.Settings.Default.Save(); } else From 9170a6ed095fe6bfc44dab5108c66e8af228df18 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sat, 11 Feb 2023 01:18:36 -0600 Subject: [PATCH 6/8] Updated hotkeys --- Form1.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Form1.cs b/Form1.cs index ed89978..258cf1d 100644 --- a/Form1.cs +++ b/Form1.cs @@ -322,7 +322,7 @@ namespace photo_sorter if (global.filecount > 1) next_image(); return true; - case Keys.Shift | Keys.Home: + case Keys.Control | Keys.Home: if (global.filecount > 1) { status_msg("Loading first image..."); @@ -330,7 +330,7 @@ namespace photo_sorter update_image(); } return true; - case Keys.Shift | Keys.End: + case Keys.Control | Keys.End: if (global.filecount > 1) { status_msg("Loading final image..."); @@ -606,7 +606,7 @@ namespace photo_sorter private void globalHotkeysListToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox .Show("Global Hotkeys\n\nPgUp == Previous image\nPgDn == Next image\nHome == Go to first unsorted image\nEnd == Go to final unsorted image\n\nEnter == Sort photo to current options\n"); + MessageBox .Show("Global Hotkeys\n\nPgUp == Previous image\nPgDn == Next image\nCtrl + Home == Go to first unsorted image\nCtrl + End == Go to final unsorted image\n\nEnter == Sort photo to current options\n\nDelete OR Shift + Enter == Delete image\n"); } private void tsi_enableGlobalHotkeys_Click(object sender, EventArgs e) From 221f1ff937e5b2730165c18390e905bea667c658 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sat, 11 Feb 2023 01:31:58 -0600 Subject: [PATCH 7/8] Made secondary dir list more intuitive when primary sort field empty --- Form1.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Form1.cs b/Form1.cs index 258cf1d..55dccef 100644 --- a/Form1.cs +++ b/Form1.cs @@ -158,6 +158,13 @@ namespace photo_sorter lbox_secondary_sortlist.Items.Add(dir); } } + lbox_secondary_sortlist.Enabled = true; + } + else + { + lbox_secondary_sortlist.Items.Clear(); + lbox_secondary_sortlist.Items.Add("-- Select Primary Sort --"); + lbox_secondary_sortlist.Enabled = false; } } @@ -640,12 +647,12 @@ namespace photo_sorter } private void cbox_sort_secondary_Enter(object sender, EventArgs e) { - if (cbox_sort_primary.Text.Length > 0) - { + //if (cbox_sort_primary.Text.Length > 0) + //{ populate_directory_lists(); tabctrl_sort_dir.SelectedTab = tabctrl_sort_dir.TabPages["tab_secondsort"]; cbox_sort_secondary.Focus(); - } + //} } private void lbox_primary_sortlist_SelectItem(object sender, EventArgs e) { From 696f0a37b859f9232fbd2c195011e522d3a2f5c3 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sat, 11 Feb 2023 01:33:58 -0600 Subject: [PATCH 8/8] Updated hotkey to --- Form1.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Form1.cs b/Form1.cs index 55dccef..935077c 100644 --- a/Form1.cs +++ b/Form1.cs @@ -348,7 +348,7 @@ namespace photo_sorter case Keys.Enter: sort_image(); return true; - case Keys.Delete: + case Keys.Shift | Keys.Delete: delete_image(); return true; case Keys.Shift | Keys.Enter: @@ -613,7 +613,7 @@ namespace photo_sorter private void globalHotkeysListToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox .Show("Global Hotkeys\n\nPgUp == Previous image\nPgDn == Next image\nCtrl + Home == Go to first unsorted image\nCtrl + End == Go to final unsorted image\n\nEnter == Sort photo to current options\n\nDelete OR Shift + Enter == Delete image\n"); + MessageBox .Show("Global Hotkeys\n\nPgUp == Previous image\nPgDn == Next image\nCtrl + Home == Go to first unsorted image\nCtrl + End == Go to final unsorted image\n\nEnter == Sort photo to current options\n\nShift + Delete OR Shift + Enter == Delete image\n"); } private void tsi_enableGlobalHotkeys_Click(object sender, EventArgs e)