From e67c7fce1de359d17041a601693715e4199f5981 Mon Sep 17 00:00:00 2001 From: Jaex Date: Wed, 26 May 2021 05:05:11 +0300 Subject: [PATCH] Support enter key in filename and url textboxes --- .../Forms/HistoryForm.Designer.cs | 54 ++++++++++--------- ShareX.HistoryLib/Forms/HistoryForm.cs | 22 ++++++++ ShareX.HistoryLib/Forms/HistoryForm.resx | 8 +-- .../Forms/HistoryItemInfoForm.Designer.cs | 1 + .../Forms/HistoryItemInfoForm.cs | 1 - .../Forms/HistoryItemInfoForm.resx | 4 +- ShareX.HistoryLib/HistoryItemManager.cs | 10 ++-- 7 files changed, 62 insertions(+), 38 deletions(-) diff --git a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs index a75b60aa6..692f7ef6f 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.Designer.cs @@ -38,8 +38,10 @@ private void InitializeComponent() this.chDateTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chFilename = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chURL = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.btnShowStats = new System.Windows.Forms.Button(); + this.nudMaxItemCount = new System.Windows.Forms.NumericUpDown(); this.pbThumbnail = new ShareX.HelpersLib.MyPictureBox(); + this.btnShowStats = new System.Windows.Forms.Button(); + this.lblMaxItemCount = new System.Windows.Forms.Label(); this.gbFilters = new System.Windows.Forms.GroupBox(); this.lblURLFilter = new System.Windows.Forms.Label(); this.txtURLFilter = new System.Windows.Forms.TextBox(); @@ -56,15 +58,13 @@ private void InitializeComponent() this.cbDateFilter = new System.Windows.Forms.CheckBox(); this.dtpFilterTo = new System.Windows.Forms.DateTimePicker(); this.txtFilenameFilter = new System.Windows.Forms.TextBox(); - this.lblMaxItemCount = new System.Windows.Forms.Label(); - this.nudMaxItemCount = new System.Windows.Forms.NumericUpDown(); ((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit(); this.scMain.Panel1.SuspendLayout(); this.scMain.Panel2.SuspendLayout(); this.scMain.SuspendLayout(); this.pStats.SuspendLayout(); - this.gbFilters.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudMaxItemCount)).BeginInit(); + this.gbFilters.SuspendLayout(); this.SuspendLayout(); // // scMain @@ -138,12 +138,16 @@ private void InitializeComponent() // resources.ApplyResources(this.chURL, "chURL"); // - // btnShowStats + // nudMaxItemCount // - resources.ApplyResources(this.btnShowStats, "btnShowStats"); - this.btnShowStats.Name = "btnShowStats"; - this.btnShowStats.UseVisualStyleBackColor = true; - this.btnShowStats.Click += new System.EventHandler(this.BtnShowStats_Click); + resources.ApplyResources(this.nudMaxItemCount, "nudMaxItemCount"); + this.nudMaxItemCount.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.nudMaxItemCount.Name = "nudMaxItemCount"; + this.nudMaxItemCount.ValueChanged += new System.EventHandler(this.nudMaxItemCount_ValueChanged); // // pbThumbnail // @@ -156,6 +160,18 @@ private void InitializeComponent() this.pbThumbnail.PictureBoxBackColor = System.Drawing.SystemColors.Control; this.pbThumbnail.ShowImageSizeLabel = true; // + // btnShowStats + // + resources.ApplyResources(this.btnShowStats, "btnShowStats"); + this.btnShowStats.Name = "btnShowStats"; + this.btnShowStats.UseVisualStyleBackColor = true; + this.btnShowStats.Click += new System.EventHandler(this.BtnShowStats_Click); + // + // lblMaxItemCount + // + resources.ApplyResources(this.lblMaxItemCount, "lblMaxItemCount"); + this.lblMaxItemCount.Name = "lblMaxItemCount"; + // // gbFilters // resources.ApplyResources(this.gbFilters, "gbFilters"); @@ -186,6 +202,7 @@ private void InitializeComponent() // resources.ApplyResources(this.txtURLFilter, "txtURLFilter"); this.txtURLFilter.Name = "txtURLFilter"; + this.txtURLFilter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtURLFilter_KeyDown); // // lblFilenameFilter // @@ -261,22 +278,7 @@ private void InitializeComponent() // resources.ApplyResources(this.txtFilenameFilter, "txtFilenameFilter"); this.txtFilenameFilter.Name = "txtFilenameFilter"; - // - // lblMaxItemCount - // - resources.ApplyResources(this.lblMaxItemCount, "lblMaxItemCount"); - this.lblMaxItemCount.Name = "lblMaxItemCount"; - // - // nudMaxItemCount - // - resources.ApplyResources(this.nudMaxItemCount, "nudMaxItemCount"); - this.nudMaxItemCount.Maximum = new decimal(new int[] { - 10000, - 0, - 0, - 0}); - this.nudMaxItemCount.Name = "nudMaxItemCount"; - this.nudMaxItemCount.ValueChanged += new System.EventHandler(this.nudMaxItemCount_ValueChanged); + this.txtFilenameFilter.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtFilenameFilter_KeyDown); // // HistoryForm // @@ -295,9 +297,9 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.scMain)).EndInit(); this.scMain.ResumeLayout(false); this.pStats.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.nudMaxItemCount)).EndInit(); this.gbFilters.ResumeLayout(false); this.gbFilters.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nudMaxItemCount)).EndInit(); this.ResumeLayout(false); } diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index 3971215fa..6025d2541 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -395,6 +395,28 @@ private void scMain_SplitterMoved(object sender, SplitterEventArgs e) Settings.SplitterDistance = scMain.SplitterDistance; } + private void txtFilenameFilter_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + e.Handled = true; + e.SuppressKeyPress = true; + ApplyFiltersAndAdd(); + txtFilenameFilter.Focus(); + } + } + + private void txtURLFilter_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + e.Handled = true; + e.SuppressKeyPress = true; + ApplyFiltersAndAdd(); + txtURLFilter.Focus(); + } + } + private void btnApplyFilters_Click(object sender, EventArgs e) { ApplyFiltersAndAdd(); diff --git a/ShareX.HistoryLib/Forms/HistoryForm.resx b/ShareX.HistoryLib/Forms/HistoryForm.resx index a3dadeb22..2f2852f9b 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.resx +++ b/ShareX.HistoryLib/Forms/HistoryForm.resx @@ -226,7 +226,7 @@ lvHistory - ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=13.2.2.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=13.5.1.0, Culture=neutral, PublicKeyToken=null scMain.Panel1 @@ -283,7 +283,7 @@ 8, 8 - 404, 352 + 402, 352 3 @@ -292,7 +292,7 @@ pbThumbnail - ShareX.HelpersLib.MyPictureBox, ShareX.HelpersLib, Version=13.2.2.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.MyPictureBox, ShareX.HelpersLib, Version=13.5.1.0, Culture=neutral, PublicKeyToken=null scMain.Panel2 @@ -808,7 +808,7 @@ scMain - ShareX.HelpersLib.SplitContainerCustomSplitter, ShareX.HelpersLib, Version=13.2.2.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.SplitContainerCustomSplitter, ShareX.HelpersLib, Version=13.5.1.0, Culture=neutral, PublicKeyToken=null $this diff --git a/ShareX.HistoryLib/Forms/HistoryItemInfoForm.Designer.cs b/ShareX.HistoryLib/Forms/HistoryItemInfoForm.Designer.cs index 4b944062e..b95e36fc2 100644 --- a/ShareX.HistoryLib/Forms/HistoryItemInfoForm.Designer.cs +++ b/ShareX.HistoryLib/Forms/HistoryItemInfoForm.Designer.cs @@ -45,6 +45,7 @@ private void InitializeComponent() this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.Controls.Add(this.pgHistoryItem); this.Name = "HistoryItemInfoForm"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.ResumeLayout(false); } diff --git a/ShareX.HistoryLib/Forms/HistoryItemInfoForm.cs b/ShareX.HistoryLib/Forms/HistoryItemInfoForm.cs index c9407ec0f..f9b344f04 100644 --- a/ShareX.HistoryLib/Forms/HistoryItemInfoForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryItemInfoForm.cs @@ -34,7 +34,6 @@ public HistoryItemInfoForm(HistoryItem hi) { InitializeComponent(); ShareXResources.ApplyTheme(this); - pgHistoryItem.SelectedObject = hi; } } diff --git a/ShareX.HistoryLib/Forms/HistoryItemInfoForm.resx b/ShareX.HistoryLib/Forms/HistoryItemInfoForm.resx index a56c6ea68..f71e99848 100644 --- a/ShareX.HistoryLib/Forms/HistoryItemInfoForm.resx +++ b/ShareX.HistoryLib/Forms/HistoryItemInfoForm.resx @@ -130,7 +130,7 @@ 3, 3 - 448, 405 + 578, 405 0 @@ -154,7 +154,7 @@ 96, 96 - 454, 411 + 584, 411 3, 3, 3, 3 diff --git a/ShareX.HistoryLib/HistoryItemManager.cs b/ShareX.HistoryLib/HistoryItemManager.cs index 00ca9eec8..3556158d1 100644 --- a/ShareX.HistoryLib/HistoryItemManager.cs +++ b/ShareX.HistoryLib/HistoryItemManager.cs @@ -506,11 +506,6 @@ public void ShowImagePreview() if (HistoryItem != null && IsImageFile) ImageViewer.ShowImage(HistoryItem.FilePath); } - public void ShowMoreInfo() - { - new HistoryItemInfoForm(HistoryItem).Show(); - } - public void UploadFile() { if (uploadFile != null && HistoryItem != null && IsFileExist) uploadFile(HistoryItem.FilePath); @@ -520,5 +515,10 @@ public void EditImage() { if (editImage != null && HistoryItem != null && IsImageFile) editImage(HistoryItem.FilePath); } + + public void ShowMoreInfo() + { + new HistoryItemInfoForm(HistoryItem).Show(); + } } } \ No newline at end of file