Working on Thumbnail List Update notifications - Disabled the old system
This commit is contained in:
@@ -146,15 +146,13 @@
|
||||
<Compile Include="Services\Interop\User32NativeMethods.cs" />
|
||||
<Compile Include="Presenters\Implementation\MainFormPresenter.cs" />
|
||||
<Compile Include="Presenters\ViewCloseRequest.cs" />
|
||||
<Compile Include="Presenters\ViewZoomAnchorConverter.cs" />
|
||||
<Compile Include="Presenters\Implementation\ViewZoomAnchorConverter.cs" />
|
||||
<Compile Include="View\Interface\IThumbnailViewFactory.cs" />
|
||||
<Compile Include="Presenters\IThumbnailManager.cs" />
|
||||
<Compile Include="View\Implementation\ThumbnailDescriptionView.cs" />
|
||||
<Compile Include="View\Factory\ThumbnailDescriptionViewFactory.cs" />
|
||||
<Compile Include="Services\Interface\IThumbnailManager.cs" />
|
||||
<Compile Include="View\Implementation\ThumbnailDescription.cs" />
|
||||
<Compile Include="View\Interface\IMainFormView.cs" />
|
||||
<Compile Include="ApplicationBase\IView.cs" />
|
||||
<Compile Include="View\Interface\IThumbnailDescriptionView.cs" />
|
||||
<Compile Include="View\Interface\IThumbnailDescriptionViewFactory.cs" />
|
||||
<Compile Include="View\Interface\IThumbnailDescription.cs" />
|
||||
<Compile Include="View\Interface\ViewZoomAnchor.cs" />
|
||||
<Compile Include="Configuration\ThumbnailConfiguration.cs" />
|
||||
<Compile Include="Hotkeys\HotkeyHandler.cs" />
|
||||
@@ -167,8 +165,8 @@
|
||||
</Compile>
|
||||
<Compile Include="Configuration\IConfigurationStorage.cs" />
|
||||
<Compile Include="View\Interface\IThumbnailView.cs" />
|
||||
<Compile Include="View\Factory\ThumbnailViewFactory.cs" />
|
||||
<Compile Include="Presenters\ThumbnailManager.cs" />
|
||||
<Compile Include="View\Implementation\ThumbnailViewFactory.cs" />
|
||||
<Compile Include="Services\Implementation\ThumbnailManager.cs" />
|
||||
<Compile Include="View\Implementation\ThumbnailOverlay.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using EveOPreview.Configuration;
|
||||
using EveOPreview.Mediator.Messages;
|
||||
using EveOPreview.Services;
|
||||
using EveOPreview.UI;
|
||||
using EveOPreview.View;
|
||||
using MediatR;
|
||||
@@ -20,25 +21,21 @@ namespace EveOPreview.Presenters
|
||||
private readonly IMediator _mediator;
|
||||
private readonly IThumbnailConfiguration _configuration;
|
||||
private readonly IConfigurationStorage _configurationStorage;
|
||||
private readonly IThumbnailDescriptionViewFactory _thumbnailDescriptionViewFactory;
|
||||
private readonly IDictionary<IntPtr, IThumbnailDescriptionView> _thumbnailDescriptionViews;
|
||||
private readonly IThumbnailManager _thumbnailManager;
|
||||
|
||||
private bool _exitApplication;
|
||||
#endregion
|
||||
|
||||
public MainFormPresenter(IApplicationController controller, IMainFormView view, IMediator mediator, IThumbnailConfiguration configuration, IConfigurationStorage configurationStorage,
|
||||
IThumbnailManager thumbnailManager, IThumbnailDescriptionViewFactory thumbnailDescriptionViewFactory)
|
||||
IThumbnailManager thumbnailManager)
|
||||
: base(controller, view)
|
||||
{
|
||||
this._mediator = mediator;
|
||||
this._configuration = configuration;
|
||||
this._configurationStorage = configurationStorage;
|
||||
|
||||
this._thumbnailDescriptionViewFactory = thumbnailDescriptionViewFactory;
|
||||
this._thumbnailManager = thumbnailManager;
|
||||
|
||||
this._thumbnailDescriptionViews = new Dictionary<IntPtr, IThumbnailDescriptionView>();
|
||||
this._exitApplication = false;
|
||||
|
||||
this.View.FormActivated = this.Activate;
|
||||
@@ -155,64 +152,64 @@ namespace EveOPreview.Presenters
|
||||
|
||||
private void ThumbnailsAdded(IList<IThumbnailView> thumbnails)
|
||||
{
|
||||
this.View.AddThumbnails(this.GetThumbnailViews(thumbnails, false));
|
||||
//this.View.AddThumbnails(this.GetThumbnailViews(thumbnails, false));
|
||||
}
|
||||
|
||||
private void ThumbnailsUpdated(IList<IThumbnailView> thumbnails)
|
||||
{
|
||||
this.View.UpdateThumbnails(this.GetThumbnailViews(thumbnails, false));
|
||||
//this.View.UpdateThumbnails(this.GetThumbnailViews(thumbnails, false));
|
||||
}
|
||||
|
||||
private void ThumbnailsRemoved(IList<IThumbnailView> thumbnails)
|
||||
{
|
||||
this.View.RemoveThumbnails(this.GetThumbnailViews(thumbnails, true));
|
||||
//this.View.RemoveThumbnails(this.GetThumbnailViews(thumbnails, true));
|
||||
}
|
||||
|
||||
private IList<IThumbnailDescriptionView> GetThumbnailViews(IList<IThumbnailView> thumbnails, bool removeFromCache)
|
||||
//private IList<IThumbnailDescriptionView> GetThumbnailViews(IList<IThumbnailView> thumbnails, bool removeFromCache)
|
||||
//{
|
||||
// IList<IThumbnailDescriptionView> thumbnailViews = new List<IThumbnailDescriptionView>(thumbnails.Count);
|
||||
|
||||
// // Time for some thread safety
|
||||
// lock (this._thumbnailDescriptionViews)
|
||||
// {
|
||||
// foreach (IThumbnailView thumbnail in thumbnails)
|
||||
// {
|
||||
// IThumbnailDescriptionView thumbnailView;
|
||||
// bool foundInCache = this._thumbnailDescriptionViews.TryGetValue(thumbnail.Id, out thumbnailView);
|
||||
|
||||
// if (!foundInCache)
|
||||
// {
|
||||
// if (removeFromCache)
|
||||
// {
|
||||
// // This item was not even cached
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// thumbnailView = this._thumbnailDescriptionViewFactory.Create(thumbnail.Id, thumbnail.Title, !thumbnail.IsEnabled);
|
||||
// this._thumbnailDescriptionViews.Add(thumbnail.Id, thumbnailView);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (removeFromCache)
|
||||
// {
|
||||
// this._thumbnailDescriptionViews.Remove(thumbnail.Id);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// thumbnailView.Title = thumbnail.Title;
|
||||
// }
|
||||
// }
|
||||
|
||||
// thumbnailViews.Add(thumbnailView);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return thumbnailViews;
|
||||
//}
|
||||
|
||||
private void UpdateThumbnailState(String title)
|
||||
{
|
||||
IList<IThumbnailDescriptionView> thumbnailViews = new List<IThumbnailDescriptionView>(thumbnails.Count);
|
||||
|
||||
// Time for some thread safety
|
||||
lock (this._thumbnailDescriptionViews)
|
||||
{
|
||||
foreach (IThumbnailView thumbnail in thumbnails)
|
||||
{
|
||||
IThumbnailDescriptionView thumbnailView;
|
||||
bool foundInCache = this._thumbnailDescriptionViews.TryGetValue(thumbnail.Id, out thumbnailView);
|
||||
|
||||
if (!foundInCache)
|
||||
{
|
||||
if (removeFromCache)
|
||||
{
|
||||
// This item was not even cached
|
||||
continue;
|
||||
}
|
||||
|
||||
thumbnailView = this._thumbnailDescriptionViewFactory.Create(thumbnail.Id, thumbnail.Title, !thumbnail.IsEnabled);
|
||||
this._thumbnailDescriptionViews.Add(thumbnail.Id, thumbnailView);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (removeFromCache)
|
||||
{
|
||||
this._thumbnailDescriptionViews.Remove(thumbnail.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
thumbnailView.Title = thumbnail.Title;
|
||||
}
|
||||
}
|
||||
|
||||
thumbnailViews.Add(thumbnailView);
|
||||
}
|
||||
}
|
||||
|
||||
return thumbnailViews;
|
||||
}
|
||||
|
||||
private void UpdateThumbnailState(IntPtr thumbnailId)
|
||||
{
|
||||
this._thumbnailManager.SetThumbnailState(thumbnailId, this._thumbnailDescriptionViews[thumbnailId].IsDisabled);
|
||||
//this._thumbnailManager.SetThumbnailState(thumbnailId, this._thumbnailDescriptionViews[thumbnailId].IsDisabled);
|
||||
}
|
||||
|
||||
private void OpenDocumentationLink()
|
||||
@@ -224,7 +221,7 @@ namespace EveOPreview.Presenters
|
||||
private string GetApplicationVersion()
|
||||
{
|
||||
Version version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version;
|
||||
return String.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Revision);
|
||||
return $"{version.Major}.{version.Minor}.{version.Revision}";
|
||||
}
|
||||
|
||||
private void ExitApplication()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using EveOPreview.Configuration;
|
||||
using EveOPreview.View;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
static class ViewZoomAnchorConverter
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
public class ViewCloseRequest
|
||||
{
|
||||
@@ -94,14 +94,13 @@ namespace EveOPreview
|
||||
// Application services
|
||||
container.Register<IThumbnailManager>();
|
||||
container.Register<IThumbnailViewFactory>();
|
||||
container.Register<IThumbnailDescriptionViewFactory>();
|
||||
container.Register<IThumbnailDescription>();
|
||||
|
||||
IApplicationController controller = new ApplicationController(container);
|
||||
|
||||
// UI classes
|
||||
controller.RegisterView<IMainFormView, MainForm>()
|
||||
.RegisterView<IThumbnailView, ThumbnailView>()
|
||||
.RegisterView<IThumbnailDescriptionView, ThumbnailDescriptionView>()
|
||||
.RegisterInstance(new ApplicationContext());
|
||||
|
||||
return controller;
|
||||
|
||||
@@ -8,7 +8,7 @@ using EveOPreview.Services;
|
||||
using EveOPreview.View;
|
||||
using MediatR;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.Services
|
||||
{
|
||||
class ThumbnailManager : IThumbnailManager
|
||||
{
|
||||
@@ -1,8 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.Services
|
||||
{
|
||||
public interface IThumbnailManager
|
||||
{
|
||||
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using EveOPreview.View;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
{
|
||||
public class ThumbnailDescriptionViewFactory : IThumbnailDescriptionViewFactory
|
||||
{
|
||||
private readonly IApplicationController _controller;
|
||||
|
||||
public ThumbnailDescriptionViewFactory(IApplicationController controller)
|
||||
{
|
||||
this._controller = controller;
|
||||
}
|
||||
|
||||
public IThumbnailDescriptionView Create(IntPtr id, string title, bool isDisabled)
|
||||
{
|
||||
IThumbnailDescriptionView view = this._controller.Create<IThumbnailDescriptionView>();
|
||||
|
||||
view.Id = id;
|
||||
view.Title = title;
|
||||
view.IsDisabled = isDisabled;
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,7 +206,7 @@ namespace EveOPreview.View
|
||||
this.DocumentationLink.Text = url;
|
||||
}
|
||||
|
||||
public void AddThumbnails(IList<IThumbnailDescriptionView> thumbnails)
|
||||
public void AddThumbnails(IList<IThumbnailDescription> thumbnails)
|
||||
{
|
||||
if (thumbnails.Count == 0)
|
||||
{
|
||||
@@ -215,7 +215,7 @@ namespace EveOPreview.View
|
||||
|
||||
this.ThumbnailsList.BeginUpdate();
|
||||
|
||||
foreach (IThumbnailDescriptionView view in thumbnails)
|
||||
foreach (IThumbnailDescription view in thumbnails)
|
||||
{
|
||||
this.ThumbnailsList.Items.Add(view);
|
||||
}
|
||||
@@ -223,7 +223,7 @@ namespace EveOPreview.View
|
||||
this.ThumbnailsList.EndUpdate();
|
||||
}
|
||||
|
||||
public void UpdateThumbnails(IList<IThumbnailDescriptionView> thumbnails)
|
||||
public void UpdateThumbnails(IList<IThumbnailDescription> thumbnails)
|
||||
{
|
||||
// Just trigger redraw
|
||||
if (thumbnails.Count > 0)
|
||||
@@ -232,7 +232,7 @@ namespace EveOPreview.View
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveThumbnails(IList<IThumbnailDescriptionView> thumbnails)
|
||||
public void RemoveThumbnails(IList<IThumbnailDescription> thumbnails)
|
||||
{
|
||||
if (thumbnails.Count == 0)
|
||||
{
|
||||
@@ -241,7 +241,7 @@ namespace EveOPreview.View
|
||||
|
||||
this.ThumbnailsList.BeginUpdate();
|
||||
|
||||
foreach (IThumbnailDescriptionView view in thumbnails)
|
||||
foreach (IThumbnailDescription view in thumbnails)
|
||||
{
|
||||
this.ThumbnailsList.Items.Remove(view);
|
||||
}
|
||||
@@ -268,7 +268,7 @@ namespace EveOPreview.View
|
||||
|
||||
public Action ThumbnailsSizeChanged { get; set; }
|
||||
|
||||
public Action<IntPtr> ThumbnailStateChanged { get; set; }
|
||||
public Action<string> ThumbnailStateChanged { get; set; }
|
||||
|
||||
public Action DocumentationLinkActivated { get; set; }
|
||||
|
||||
@@ -345,14 +345,14 @@ namespace EveOPreview.View
|
||||
|
||||
private void ThumbnailsList_ItemCheck_Handler(object sender, ItemCheckEventArgs e)
|
||||
{
|
||||
IThumbnailDescriptionView selectedItem = this.ThumbnailsList.Items[e.Index] as IThumbnailDescriptionView;
|
||||
if (selectedItem == null)
|
||||
if (!(this.ThumbnailsList.Items[e.Index] is IThumbnailDescription selectedItem))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
selectedItem.IsDisabled = (e.NewValue == CheckState.Checked);
|
||||
|
||||
this.ThumbnailStateChanged?.Invoke(selectedItem.Id);
|
||||
this.ThumbnailStateChanged?.Invoke(selectedItem.Title);
|
||||
}
|
||||
|
||||
private void DocumentationLinkClicked_Handler(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
|
||||
14
Eve-O-Preview/View/Implementation/ThumbnailDescription.cs
Normal file
14
Eve-O-Preview/View/Implementation/ThumbnailDescription.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
sealed class ThumbnailDescription
|
||||
{
|
||||
public ThumbnailDescription(string title, bool isDisabled)
|
||||
{
|
||||
this.Title = title;
|
||||
this.IsDisabled = isDisabled;
|
||||
}
|
||||
|
||||
public string Title { get; set; }
|
||||
public bool IsDisabled { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using EveOPreview.UI;
|
||||
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
public class ThumbnailDescriptionView : IThumbnailDescriptionView
|
||||
{
|
||||
public IntPtr Id { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public bool IsDisabled { get; set; }
|
||||
|
||||
public void Show()
|
||||
{
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using EveOPreview.View;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
public class ThumbnailViewFactory : IThumbnailViewFactory
|
||||
sealed class ThumbnailViewFactory : IThumbnailViewFactory
|
||||
{
|
||||
private readonly IApplicationController _controller;
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace EveOPreview.View
|
||||
|
||||
void Minimize();
|
||||
|
||||
void AddThumbnails(IList<IThumbnailDescriptionView> thumbnails);
|
||||
void UpdateThumbnails(IList<IThumbnailDescriptionView> thumbnails);
|
||||
void RemoveThumbnails(IList<IThumbnailDescriptionView> thumbnails);
|
||||
void AddThumbnails(IList<IThumbnailDescription> thumbnails);
|
||||
void UpdateThumbnails(IList<IThumbnailDescription> thumbnails);
|
||||
void RemoveThumbnails(IList<IThumbnailDescription> thumbnails);
|
||||
void RefreshZoomSettings();
|
||||
|
||||
Action ApplicationExitRequested { get; set; }
|
||||
@@ -50,7 +50,7 @@ namespace EveOPreview.View
|
||||
Action<ViewCloseRequest> FormCloseRequested { get; set; }
|
||||
Action ApplicationSettingsChanged { get; set; }
|
||||
Action ThumbnailsSizeChanged { get; set; }
|
||||
Action<IntPtr> ThumbnailStateChanged { get; set; }
|
||||
Action<string> ThumbnailStateChanged { get; set; }
|
||||
Action DocumentationLinkActivated { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
public interface IThumbnailDescriptionView : IView
|
||||
public interface IThumbnailDescription
|
||||
{
|
||||
IntPtr Id { get; set; }
|
||||
string Title { get; set; }
|
||||
bool IsDisabled { get; set; }
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using EveOPreview.View;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
{
|
||||
public interface IThumbnailDescriptionViewFactory
|
||||
{
|
||||
IThumbnailDescriptionView Create(IntPtr id, string title, bool isDisabled);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using EveOPreview.View;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
public interface IThumbnailViewFactory
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user