fixed #3756: Added show missing files option to image history

This commit is contained in:
Jaex 2018-12-02 11:48:17 +03:00
parent 71f6d7c738
commit a0297634b7
5 changed files with 56 additions and 11 deletions

View file

@ -27,6 +27,7 @@
using ShareX.HelpersLib;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using View = Manina.Windows.Forms.View;
@ -110,7 +111,8 @@ private IEnumerable<HistoryItem> GetHistoryItems()
HistoryItem hi = historyItems[i];
if (!string.IsNullOrEmpty(hi.Filepath) && Helpers.IsImageFile(hi.Filepath) &&
(string.IsNullOrEmpty(SearchText) || hi.Filename.Contains(SearchText, StringComparison.InvariantCultureIgnoreCase)))
(string.IsNullOrEmpty(SearchText) || hi.Filename.Contains(SearchText, StringComparison.InvariantCultureIgnoreCase)) &&
(Settings.ShowMissingFiles || File.Exists(hi.Filepath)))
{
filteredHistoryItems.Add(hi);

View file

@ -37,6 +37,7 @@ private void InitializeComponent()
this.nudMaximumImageLimit = new System.Windows.Forms.NumericUpDown();
this.lblThumbnailSizeUnit = new System.Windows.Forms.Label();
this.cbRememberSearchText = new System.Windows.Forms.CheckBox();
this.cbShowMissingFiles = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.nudThumbnailSize)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudMaximumImageLimit)).BeginInit();
this.SuspendLayout();
@ -108,11 +109,19 @@ private void InitializeComponent()
this.cbRememberSearchText.UseVisualStyleBackColor = true;
this.cbRememberSearchText.CheckedChanged += new System.EventHandler(this.cbRememberSearchText_CheckedChanged);
//
// cbShowMissingFiles
//
resources.ApplyResources(this.cbShowMissingFiles, "cbShowMissingFiles");
this.cbShowMissingFiles.Name = "cbShowMissingFiles";
this.cbShowMissingFiles.UseVisualStyleBackColor = true;
this.cbShowMissingFiles.CheckedChanged += new System.EventHandler(this.cbShowMissingFiles_CheckedChanged);
//
// ImageHistorySettingsForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Window;
this.Controls.Add(this.cbShowMissingFiles);
this.Controls.Add(this.cbRememberSearchText);
this.Controls.Add(this.lblThumbnailSizeUnit);
this.Controls.Add(this.nudMaximumImageLimit);
@ -141,5 +150,6 @@ private void InitializeComponent()
private System.Windows.Forms.NumericUpDown nudMaximumImageLimit;
private System.Windows.Forms.Label lblThumbnailSizeUnit;
private System.Windows.Forms.CheckBox cbRememberSearchText;
private System.Windows.Forms.CheckBox cbShowMissingFiles;
}
}

View file

@ -44,6 +44,7 @@ public ImageHistorySettingsForm(ImageHistorySettings settings)
cbViewMode.SelectedIndex = Settings.ViewMode;
nudThumbnailSize.SetValue(Settings.ThumbnailSize.Width);
nudMaximumImageLimit.SetValue(Settings.MaxItemCount);
cbShowMissingFiles.Checked = Settings.ShowMissingFiles;
cbRememberSearchText.Checked = Settings.RememberSearchText;
}
@ -62,6 +63,11 @@ private void nudMaximumImageLimit_ValueChanged(object sender, EventArgs e)
Settings.MaxItemCount = (int)nudMaximumImageLimit.Value;
}
private void cbShowMissingFiles_CheckedChanged(object sender, EventArgs e)
{
Settings.ShowMissingFiles = cbShowMissingFiles.Checked;
}
private void cbRememberSearchText_CheckedChanged(object sender, EventArgs e)
{
Settings.RememberSearchText = cbRememberSearchText.Checked;

View file

@ -144,7 +144,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblViewMode.ZOrder" xml:space="preserve">
<value>7</value>
<value>8</value>
</data>
<data name="lblThumbnailSize.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -171,7 +171,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblThumbnailSize.ZOrder" xml:space="preserve">
<value>6</value>
<value>7</value>
</data>
<data name="lblMaximumImageLimit.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -198,7 +198,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblMaximumImageLimit.ZOrder" xml:space="preserve">
<value>5</value>
<value>6</value>
</data>
<data name="cbViewMode.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 24</value>
@ -219,7 +219,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cbViewMode.ZOrder" xml:space="preserve">
<value>4</value>
<value>5</value>
</data>
<data name="nudThumbnailSize.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 72</value>
@ -244,7 +244,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;nudThumbnailSize.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="nudMaximumImageLimit.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 120</value>
@ -268,7 +268,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;nudMaximumImageLimit.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="lblThumbnailSizeUnit.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -284,7 +284,6 @@
</data>
<data name="lblThumbnailSizeUnit.Text" xml:space="preserve">
<value>px</value>
<comment>@Invariant</comment>
</data>
<data name="&gt;&gt;lblThumbnailSizeUnit.Name" xml:space="preserve">
<value>lblThumbnailSizeUnit</value>
@ -296,7 +295,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;lblThumbnailSizeUnit.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="cbRememberSearchText.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -305,10 +304,10 @@
<value>NoControl</value>
</data>
<data name="cbRememberSearchText.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 152</value>
<value>8, 176</value>
</data>
<data name="cbRememberSearchText.Size" type="System.Drawing.Size, System.Drawing">
<value>132, 17</value>
<value>138, 17</value>
</data>
<data name="cbRememberSearchText.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
@ -326,6 +325,33 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cbRememberSearchText.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="cbShowMissingFiles.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="cbShowMissingFiles.Location" type="System.Drawing.Point, System.Drawing">
<value>8, 152</value>
</data>
<data name="cbShowMissingFiles.Size" type="System.Drawing.Size, System.Drawing">
<value>111, 17</value>
</data>
<data name="cbShowMissingFiles.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="cbShowMissingFiles.Text" xml:space="preserve">
<value>Show missing files</value>
</data>
<data name="&gt;&gt;cbShowMissingFiles.Name" xml:space="preserve">
<value>cbShowMissingFiles</value>
</data>
<data name="&gt;&gt;cbShowMissingFiles.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cbShowMissingFiles.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;cbShowMissingFiles.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View file

@ -34,6 +34,7 @@ public class ImageHistorySettings
public int ViewMode { get; set; } = 3;
public Size ThumbnailSize { get; set; } = new Size(150, 150);
public int MaxItemCount { get; set; } = 250;
public bool ShowMissingFiles { get; set; } = true;
public bool RememberSearchText { get; set; } = false;
public string SearchText { get; set; } = "";
}