Working on Thumbnail List Update notifications
This commit is contained in:
@@ -114,6 +114,8 @@
|
||||
<Compile Include="Configuration\IThumbnailConfiguration.cs" />
|
||||
<Compile Include="Configuration\ZoomAnchor.cs" />
|
||||
<Compile Include="Mediator\Handlers\Configuration\SaveConfigurationHandler.cs" />
|
||||
<Compile Include="Mediator\Handlers\Thumbnails\ThumbnailListUpdatedHandler.cs" />
|
||||
<Compile Include="Mediator\Messages\Thumbnails\ThumbnailListUpdated.cs" />
|
||||
<Compile Include="Mediator\Handlers\Thumbnails\ThumbnailLocationUpdatedHandler.cs" />
|
||||
<Compile Include="Mediator\Handlers\Thumbnails\ThumbnailSizeUpdatedHandler.cs" />
|
||||
<Compile Include="Mediator\Handlers\Services\StartServiceHandler.cs" />
|
||||
@@ -145,41 +147,41 @@
|
||||
<Compile Include="Presenters\Implementation\MainFormPresenter.cs" />
|
||||
<Compile Include="Presenters\ViewCloseRequest.cs" />
|
||||
<Compile Include="Presenters\ViewZoomAnchorConverter.cs" />
|
||||
<Compile Include="UI\Interface\IThumbnailViewFactory.cs" />
|
||||
<Compile Include="View\Interface\IThumbnailViewFactory.cs" />
|
||||
<Compile Include="Presenters\IThumbnailManager.cs" />
|
||||
<Compile Include="UI\Implementation\ThumbnailDescriptionView.cs" />
|
||||
<Compile Include="UI\Factory\ThumbnailDescriptionViewFactory.cs" />
|
||||
<Compile Include="UI\Interface\IMainFormView.cs" />
|
||||
<Compile Include="View\Implementation\ThumbnailDescriptionView.cs" />
|
||||
<Compile Include="View\Factory\ThumbnailDescriptionViewFactory.cs" />
|
||||
<Compile Include="View\Interface\IMainFormView.cs" />
|
||||
<Compile Include="ApplicationBase\IView.cs" />
|
||||
<Compile Include="UI\Interface\IThumbnailDescriptionView.cs" />
|
||||
<Compile Include="UI\Interface\IThumbnailDescriptionViewFactory.cs" />
|
||||
<Compile Include="UI\Interface\ViewZoomAnchor.cs" />
|
||||
<Compile Include="View\Interface\IThumbnailDescriptionView.cs" />
|
||||
<Compile Include="View\Interface\IThumbnailDescriptionViewFactory.cs" />
|
||||
<Compile Include="View\Interface\ViewZoomAnchor.cs" />
|
||||
<Compile Include="Configuration\ThumbnailConfiguration.cs" />
|
||||
<Compile Include="Hotkeys\HotkeyHandler.cs" />
|
||||
<Compile Include="Hotkeys\HotkeyHandlerNativeMethods.cs" />
|
||||
<Compile Include="UI\Implementation\MainForm.cs">
|
||||
<Compile Include="View\Implementation\MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\Implementation\MainForm.Designer.cs">
|
||||
<Compile Include="View\Implementation\MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Configuration\IConfigurationStorage.cs" />
|
||||
<Compile Include="UI\Interface\IThumbnailView.cs" />
|
||||
<Compile Include="UI\Factory\ThumbnailViewFactory.cs" />
|
||||
<Compile Include="View\Interface\IThumbnailView.cs" />
|
||||
<Compile Include="View\Factory\ThumbnailViewFactory.cs" />
|
||||
<Compile Include="Presenters\ThumbnailManager.cs" />
|
||||
<Compile Include="UI\Implementation\ThumbnailOverlay.cs">
|
||||
<Compile Include="View\Implementation\ThumbnailOverlay.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\Implementation\ThumbnailOverlay.Designer.cs">
|
||||
<Compile Include="View\Implementation\ThumbnailOverlay.Designer.cs">
|
||||
<DependentUpon>ThumbnailOverlay.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="UI\Implementation\MainForm.resx">
|
||||
<EmbeddedResource Include="View\Implementation\MainForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UI\Implementation\ThumbnailOverlay.resx">
|
||||
<EmbeddedResource Include="View\Implementation\ThumbnailOverlay.resx">
|
||||
<DependentUpon>ThumbnailOverlay.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
@@ -187,7 +189,7 @@
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UI\Implementation\ThumbnailView.resx">
|
||||
<EmbeddedResource Include="View\Implementation\ThumbnailView.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>ThumbnailView.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@@ -196,10 +198,10 @@
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="UI\Implementation\ThumbnailView.cs">
|
||||
<Compile Include="View\Implementation\ThumbnailView.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\Implementation\ThumbnailView.Designer.cs">
|
||||
<Compile Include="View\Implementation\ThumbnailView.Designer.cs">
|
||||
<DependentUpon>ThumbnailView.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Services\Interop\DwmApiNativeMethods.cs" />
|
||||
|
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using EveOPreview.Mediator.Messages;
|
||||
using EveOPreview.Presenters;
|
||||
using MediatR;
|
||||
|
||||
namespace EveOPreview.Mediator.Handlers.Thumbnails
|
||||
{
|
||||
sealed class ThumbnailListUpdatedHandler : INotificationHandler<ThumbnailListUpdated>
|
||||
{
|
||||
#region Private fields
|
||||
private readonly IMainFormPresenter _presenter;
|
||||
#endregion
|
||||
|
||||
public ThumbnailListUpdatedHandler(MainFormPresenter presenter)
|
||||
{
|
||||
this._presenter = presenter;
|
||||
}
|
||||
|
||||
public Task Handle(ThumbnailListUpdated notification, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace EveOPreview.Mediator.Messages
|
||||
{
|
||||
sealed class ThumbnailListUpdated : NotificationBase<IList<string>>
|
||||
{
|
||||
public ThumbnailListUpdated(UpdateKind updateKind, IList<string> list)
|
||||
: base(list)
|
||||
{
|
||||
this.Kind = updateKind;
|
||||
}
|
||||
|
||||
public UpdateKind Kind { get; }
|
||||
|
||||
public enum UpdateKind
|
||||
{
|
||||
Add,
|
||||
Update,
|
||||
Remove
|
||||
}
|
||||
}
|
||||
}
|
@@ -12,9 +12,5 @@ namespace EveOPreview.UI
|
||||
void SetThumbnailState(IntPtr thumbnailId, bool hideAlways);
|
||||
void SetThumbnailsSize(Size size);
|
||||
void SetupThumbnailFrames();
|
||||
|
||||
Action<IList<IThumbnailView>> ThumbnailsAdded { get; set; }
|
||||
Action<IList<IThumbnailView>> ThumbnailsUpdated { get; set; }
|
||||
Action<IList<IThumbnailView>> ThumbnailsRemoved { get; set; }
|
||||
}
|
||||
}
|
@@ -5,6 +5,7 @@ using System.Drawing;
|
||||
using EveOPreview.Configuration;
|
||||
using EveOPreview.Mediator.Messages;
|
||||
using EveOPreview.UI;
|
||||
using EveOPreview.View;
|
||||
using MediatR;
|
||||
|
||||
namespace EveOPreview.Presenters
|
||||
@@ -48,10 +49,6 @@ namespace EveOPreview.Presenters
|
||||
this.View.ThumbnailStateChanged = this.UpdateThumbnailState;
|
||||
this.View.DocumentationLinkActivated = this.OpenDocumentationLink;
|
||||
this.View.ApplicationExitRequested = this.ExitApplication;
|
||||
|
||||
this._thumbnailManager.ThumbnailsAdded = this.ThumbnailsAdded;
|
||||
this._thumbnailManager.ThumbnailsUpdated = this.ThumbnailsUpdated;
|
||||
this._thumbnailManager.ThumbnailsRemoved = this.ThumbnailsRemoved;
|
||||
}
|
||||
|
||||
private void Activate()
|
||||
|
@@ -5,6 +5,7 @@ using System.Windows.Threading;
|
||||
using EveOPreview.Configuration;
|
||||
using EveOPreview.Mediator.Messages;
|
||||
using EveOPreview.Services;
|
||||
using EveOPreview.View;
|
||||
using MediatR;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
@@ -56,12 +57,6 @@ namespace EveOPreview.UI
|
||||
this._thumbnailUpdateTimer.Interval = new TimeSpan(0, 0, 0, 0, configuration.ThumbnailRefreshPeriod);
|
||||
}
|
||||
|
||||
public Action<IList<IThumbnailView>> ThumbnailsAdded { get; set; }
|
||||
|
||||
public Action<IList<IThumbnailView>> ThumbnailsUpdated { get; set; }
|
||||
|
||||
public Action<IList<IThumbnailView>> ThumbnailsRemoved { get; set; }
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
this._thumbnailUpdateTimer.Start();
|
||||
@@ -85,7 +80,7 @@ namespace EveOPreview.UI
|
||||
thumbnail.IsEnabled = !hideAlways;
|
||||
}
|
||||
|
||||
public void SetThumbnailsSize(Size size)
|
||||
public async void SetThumbnailsSize(Size size)
|
||||
{
|
||||
this.DisableViewEvents();
|
||||
|
||||
@@ -95,7 +90,7 @@ namespace EveOPreview.UI
|
||||
entry.Value.Refresh(false);
|
||||
}
|
||||
|
||||
this._mediator.Publish(new ThumbnailSizeUpdated(size)); // This one runs asynchronously
|
||||
await this._mediator.Publish(new ThumbnailSizeUpdated(size));
|
||||
|
||||
this.EnableViewEvents();
|
||||
}
|
||||
@@ -189,15 +184,15 @@ namespace EveOPreview.UI
|
||||
this._ignoreViewEvents = true;
|
||||
}
|
||||
|
||||
private void UpdateThumbnailsList()
|
||||
private async void UpdateThumbnailsList()
|
||||
{
|
||||
this._processMonitor.GetUpdatedProcesses(out ICollection<IProcessInfo> addedProcesses, out ICollection<IProcessInfo> updatedProcesses, out ICollection<IProcessInfo> removedProcesses);
|
||||
|
||||
IntPtr foregroundWindowHandle = this._windowManager.GetForegroundWindowHandle();
|
||||
|
||||
List<IThumbnailView> viewsAdded = new List<IThumbnailView>();
|
||||
List<IThumbnailView> viewsUpdated = new List<IThumbnailView>();
|
||||
List<IThumbnailView> viewsRemoved = new List<IThumbnailView>();
|
||||
List<string> viewsAdded = new List<string>();
|
||||
List<string> viewsUpdated = new List<string>();
|
||||
List<string> viewsRemoved = new List<string>();
|
||||
|
||||
foreach (IProcessInfo process in addedProcesses)
|
||||
{
|
||||
@@ -211,10 +206,10 @@ namespace EveOPreview.UI
|
||||
view.SetTopMost(this._configuration.ShowThumbnailsAlwaysOnTop);
|
||||
|
||||
view.ThumbnailLocation = this.IsManageableThumbnail(view)
|
||||
? this._configuration.GetThumbnailLocation(process.Title, this._activeClientTitle, view.ThumbnailLocation)
|
||||
? this._configuration.GetThumbnailLocation(view.Title, this._activeClientTitle, view.ThumbnailLocation)
|
||||
: this._configuration.GetDefaultThumbnailLocation();
|
||||
|
||||
this._thumbnailViews.Add(process.Handle, view);
|
||||
this._thumbnailViews.Add(view.Id, view);
|
||||
|
||||
view.ThumbnailResized = this.ThumbnailViewResized;
|
||||
view.ThumbnailMoved = this.ThumbnailViewMoved;
|
||||
@@ -223,16 +218,20 @@ namespace EveOPreview.UI
|
||||
view.ThumbnailActivated = this.ThumbnailActivated;
|
||||
view.ThumbnailDeactivated = this.ThumbnailDeactivated;
|
||||
|
||||
view.RegisterHotkey(this._configuration.GetClientHotkey(process.Title));
|
||||
view.RegisterHotkey(this._configuration.GetClientHotkey(view.Title));
|
||||
|
||||
this.ApplyClientLayout(process.Handle, process.Title);
|
||||
this.ApplyClientLayout(view.Id, view.Title);
|
||||
|
||||
viewsAdded.Add(view);
|
||||
// TODO Add extension filter here later
|
||||
if (view.Title != ThumbnailManager.DefaultClientTitle)
|
||||
{
|
||||
viewsAdded.Add(view.Title);
|
||||
}
|
||||
|
||||
if (process.Handle == foregroundWindowHandle)
|
||||
{
|
||||
this._activeClientHandle = process.Handle;
|
||||
this._activeClientTitle = process.Title;
|
||||
this._activeClientHandle = view.Id;
|
||||
this._activeClientTitle = view.Title;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,8 +250,12 @@ namespace EveOPreview.UI
|
||||
view.Title = process.Title;
|
||||
view.RegisterHotkey(this._configuration.GetClientHotkey(process.Title));
|
||||
|
||||
this.ApplyClientLayout(process.Handle, process.Title);
|
||||
viewsUpdated.Add(view);
|
||||
this.ApplyClientLayout(view.Id, view.Title);
|
||||
|
||||
if (view.Title != ThumbnailManager.DefaultClientTitle)
|
||||
{
|
||||
viewsUpdated.Add(view.Title);
|
||||
}
|
||||
}
|
||||
|
||||
if (process.Handle == foregroundWindowHandle)
|
||||
@@ -266,7 +269,7 @@ namespace EveOPreview.UI
|
||||
{
|
||||
IThumbnailView view = this._thumbnailViews[process.Handle];
|
||||
|
||||
this._thumbnailViews.Remove(process.Handle);
|
||||
this._thumbnailViews.Remove(view.Id);
|
||||
|
||||
view.UnregisterHotkey();
|
||||
|
||||
@@ -278,12 +281,26 @@ namespace EveOPreview.UI
|
||||
|
||||
view.Close();
|
||||
|
||||
viewsRemoved.Add(view);
|
||||
if (view.Title != ThumbnailManager.DefaultClientTitle)
|
||||
{
|
||||
viewsRemoved.Add(view.Title);
|
||||
}
|
||||
}
|
||||
|
||||
this.ThumbnailsAdded?.Invoke(viewsAdded);
|
||||
this.ThumbnailsUpdated?.Invoke(viewsUpdated);
|
||||
this.ThumbnailsRemoved?.Invoke(viewsRemoved);
|
||||
if (viewsAdded.Count > 0)
|
||||
{
|
||||
await this._mediator.Publish(new ThumbnailListUpdated(ThumbnailListUpdated.UpdateKind.Add, viewsAdded));
|
||||
}
|
||||
|
||||
if (viewsUpdated.Count > 0)
|
||||
{
|
||||
await this._mediator.Publish(new ThumbnailListUpdated(ThumbnailListUpdated.UpdateKind.Update, viewsUpdated));
|
||||
}
|
||||
|
||||
if (viewsRemoved.Count > 0)
|
||||
{
|
||||
await this._mediator.Publish(new ThumbnailListUpdated(ThumbnailListUpdated.UpdateKind.Remove, viewsRemoved));
|
||||
}
|
||||
}
|
||||
|
||||
private void ThumbnailViewFocused(IntPtr id)
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using EveOPreview.Configuration;
|
||||
using EveOPreview.View;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
{
|
||||
|
@@ -5,6 +5,7 @@ using EveOPreview.Configuration;
|
||||
using EveOPreview.Presenters;
|
||||
using EveOPreview.Services;
|
||||
using EveOPreview.UI;
|
||||
using EveOPreview.View;
|
||||
using MediatR;
|
||||
|
||||
namespace EveOPreview
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using EveOPreview.View;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
{
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using EveOPreview.View;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
@@ -2,8 +2,9 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using EveOPreview.UI;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
public partial class MainForm : Form, IMainFormView
|
||||
{
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using EveOPreview.UI;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
public class ThumbnailDescriptionView : IThumbnailDescriptionView
|
||||
{
|
@@ -4,6 +4,7 @@ using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using EveOPreview.Services;
|
||||
using EveOPreview.UI.Hotkeys;
|
||||
using EveOPreview.View;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
{
|
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using EveOPreview.UI;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
/// <summary>
|
||||
/// Main view interface
|
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
public interface IThumbnailDescriptionView : IView
|
||||
{
|
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using EveOPreview.View;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
{
|
@@ -2,7 +2,7 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
public interface IThumbnailView : IView
|
||||
{
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using EveOPreview.View;
|
||||
|
||||
namespace EveOPreview.UI
|
||||
{
|
@@ -1,4 +1,4 @@
|
||||
namespace EveOPreview.UI
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
public enum ViewZoomAnchor
|
||||
{
|
Reference in New Issue
Block a user