diff --git a/Eve-O-Preview/Configuration/ThumbnailConfiguration.cs b/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs similarity index 89% rename from Eve-O-Preview/Configuration/ThumbnailConfiguration.cs rename to Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs index 9a268c7..c9c2107 100644 --- a/Eve-O-Preview/Configuration/ThumbnailConfiguration.cs +++ b/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs @@ -3,9 +3,9 @@ using System.Drawing; using System.Windows.Forms; using Newtonsoft.Json; -namespace EveOPreview.Configuration +namespace EveOPreview.Configuration.Omplementation { - class ThumbnailConfiguration : IThumbnailConfiguration + sealed class ThumbnailConfiguration : IThumbnailConfiguration { public ThumbnailConfiguration() { @@ -39,6 +39,7 @@ namespace EveOPreview.Configuration this.FlatLayout = new Dictionary(); this.ClientLayout = new Dictionary(); this.ClientHotkey = new Dictionary(); + this.DisableThumbnail = new Dictionary(); } public bool MinimizeToTray { get; set; } @@ -79,6 +80,8 @@ namespace EveOPreview.Configuration private Dictionary ClientLayout { get; set; } [JsonProperty] private Dictionary ClientHotkey { get; set; } + [JsonProperty] + private Dictionary DisableThumbnail { get; set; } public Point GetDefaultThumbnailLocation() { @@ -168,6 +171,16 @@ namespace EveOPreview.Configuration this.ClientHotkey[currentClient] = (new KeysConverter()).ConvertToInvariantString(hotkey); } + public bool IsThumbnailDisabled(string currentClient) + { + return this.DisableThumbnail.TryGetValue(currentClient, out bool isDisabled) && isDisabled; + } + + public void ToggleThumbnail(string currentClient, bool isDisabled) + { + this.DisableThumbnail[currentClient] = isDisabled; + } + /// /// Applies restrictions to different parameters of the config /// diff --git a/Eve-O-Preview/Configuration/IThumbnailConfiguration.cs b/Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs similarity index 90% rename from Eve-O-Preview/Configuration/IThumbnailConfiguration.cs rename to Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs index f5308eb..f7eac67 100644 --- a/Eve-O-Preview/Configuration/IThumbnailConfiguration.cs +++ b/Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs @@ -41,6 +41,9 @@ namespace EveOPreview.Configuration Keys GetClientHotkey(string currentClient); void SetClientHotkey(string currentClient, Keys hotkey); + bool IsThumbnailDisabled(string currentClient); + void ToggleThumbnail(string currentClient, bool isDisabled); + void ApplyRestrictions(); } } \ No newline at end of file diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index 4c05dba..6387f51 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -111,7 +111,7 @@ - + @@ -157,7 +157,7 @@ - + diff --git a/Eve-O-Preview/Presenters/Implementation/MainFormPresenter.cs b/Eve-O-Preview/Presenters/Implementation/MainFormPresenter.cs index e5b5867..27e0b78 100644 --- a/Eve-O-Preview/Presenters/Implementation/MainFormPresenter.cs +++ b/Eve-O-Preview/Presenters/Implementation/MainFormPresenter.cs @@ -199,14 +199,16 @@ namespace EveOPreview.Presenters private IThumbnailDescription CreateThumbnailDescription(string title) { - // TODO Read here persisted value for the IsDisabled parameter - return new ThumbnailDescription(title, false); + bool isDisabled = this._configuration.IsThumbnailDisabled(title); + return new ThumbnailDescription(title, isDisabled); } private void UpdateThumbnailState(String title) { - // TODO This setting doesn't work atm - //this._thumbnailManager.SetThumbnailState(thumbnailId, this._thumbnailDescriptionViews[thumbnailId].IsDisabled); + if (this._descriptionsCache.TryGetValue(title, out IThumbnailDescription description)) + { + this._configuration.ToggleThumbnail(title, description.IsDisabled); + } } public void UpdateThumbnailSize(Size size) diff --git a/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs b/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs index f346e0c..775243a 100644 --- a/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs +++ b/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs @@ -68,29 +68,12 @@ namespace EveOPreview.Services this._thumbnailUpdateTimer.Stop(); } - public void SetThumbnailState(IntPtr thumbnailId, bool hideAlways) - { - if (!this._thumbnailViews.TryGetValue(thumbnailId, out IThumbnailView thumbnail)) - { - return; - } - - thumbnail.IsEnabled = !hideAlways; - } - public void UpdateThumbnailsSize() { - this.InternalSetThumbnailsSize(this._configuration.ThumbnailSize); + this.SetThumbnailsSize(this._configuration.ThumbnailSize); } - public async void SetThumbnailsSize(Size size) - { - this.InternalSetThumbnailsSize(size); - - await this._mediator.Publish(new ThumbnailActiveSizeUpdated(size)); - } - - private void InternalSetThumbnailsSize(Size size) + private void SetThumbnailsSize(Size size) { this.DisableViewEvents(); @@ -115,7 +98,7 @@ namespace EveOPreview.Services { IThumbnailView view = entry.Value; - if (hideAllThumbnails || !view.IsEnabled) + if (hideAllThumbnails || this._configuration.IsThumbnailDisabled(view.Title)) { if (view.IsActive) { @@ -204,7 +187,6 @@ namespace EveOPreview.Services foreach (IProcessInfo process in addedProcesses) { IThumbnailView view = this._thumbnailViewFactory.Create(process.Handle, process.Title, this._configuration.ThumbnailSize); - view.IsEnabled = true; view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays; view.SetFrames(this._configuration.ShowThumbnailFrames); // Max/Min size limitations should be set AFTER the frames are disabled @@ -368,7 +350,7 @@ namespace EveOPreview.Services this.RefreshThumbnails(); } - private void ThumbnailViewResized(IntPtr id) + private async void ThumbnailViewResized(IntPtr id) { if (this._ignoreViewEvents) { @@ -380,6 +362,8 @@ namespace EveOPreview.Services this.SetThumbnailsSize(view.ThumbnailSize); view.Refresh(false); + + await this._mediator.Publish(new ThumbnailActiveSizeUpdated(view.ThumbnailSize)); } private async void ThumbnailViewMoved(IntPtr id) diff --git a/Eve-O-Preview/Services/Interface/IThumbnailManager.cs b/Eve-O-Preview/Services/Interface/IThumbnailManager.cs index 694bcd6..87e464b 100644 --- a/Eve-O-Preview/Services/Interface/IThumbnailManager.cs +++ b/Eve-O-Preview/Services/Interface/IThumbnailManager.cs @@ -1,15 +1,10 @@ -using System; -using System.Drawing; - -namespace EveOPreview.Services +namespace EveOPreview.Services { public interface IThumbnailManager { void Start(); void Stop(); - void SetThumbnailState(IntPtr thumbnailId, bool hideAlways); - void SetThumbnailsSize(Size size); void UpdateThumbnailsSize(); void UpdateThumbnailFrames(); } diff --git a/Eve-O-Preview/View/Implementation/MainForm.Designer.cs b/Eve-O-Preview/View/Implementation/MainForm.Designer.cs index 8222e02..2d77334 100644 --- a/Eve-O-Preview/View/Implementation/MainForm.Designer.cs +++ b/Eve-O-Preview/View/Implementation/MainForm.Designer.cs @@ -708,6 +708,7 @@ namespace EveOPreview.View // this.ThumbnailsList.BackColor = System.Drawing.SystemColors.Window; this.ThumbnailsList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.ThumbnailsList.CheckOnClick = true; this.ThumbnailsList.Dock = System.Windows.Forms.DockStyle.Bottom; this.ThumbnailsList.FormattingEnabled = true; this.ThumbnailsList.IntegralHeight = false; diff --git a/Eve-O-Preview/View/Implementation/MainForm.cs b/Eve-O-Preview/View/Implementation/MainForm.cs index 1e1b78d..78e8f6c 100644 --- a/Eve-O-Preview/View/Implementation/MainForm.cs +++ b/Eve-O-Preview/View/Implementation/MainForm.cs @@ -211,7 +211,7 @@ namespace EveOPreview.View foreach (IThumbnailDescription view in thumbnails) { - this.ThumbnailsList.Items.Add(view); + this.ThumbnailsList.SetItemChecked(this.ThumbnailsList.Items.Add(view), view.IsDisabled); } this.ThumbnailsList.EndUpdate(); diff --git a/Eve-O-Preview/View/Implementation/ThumbnailView.cs b/Eve-O-Preview/View/Implementation/ThumbnailView.cs index 082cf86..2f6664f 100644 --- a/Eve-O-Preview/View/Implementation/ThumbnailView.cs +++ b/Eve-O-Preview/View/Implementation/ThumbnailView.cs @@ -36,7 +36,6 @@ namespace EveOPreview.View { this._windowManager = windowManager; - this.IsEnabled = true; this.IsActive = false; this.IsOverlayEnabled = false; @@ -68,8 +67,6 @@ namespace EveOPreview.View } } - public bool IsEnabled { get; set; } - public bool IsActive { get; set; } public bool IsOverlayEnabled { get; set; } diff --git a/Eve-O-Preview/View/Interface/IThumbnailView.cs b/Eve-O-Preview/View/Interface/IThumbnailView.cs index 6249c9b..3d7e593 100644 --- a/Eve-O-Preview/View/Interface/IThumbnailView.cs +++ b/Eve-O-Preview/View/Interface/IThumbnailView.cs @@ -9,7 +9,6 @@ namespace EveOPreview.View IntPtr Id { get; set; } string Title { get; set; } - bool IsEnabled { get; set; } bool IsActive { get; set; } Point ThumbnailLocation { get; set; } Size ThumbnailSize { get; set; }