Merge branch 'develop-mediatr' into develop
This commit is contained in:
@@ -17,6 +17,11 @@ namespace EveOPreview
|
|||||||
|
|
||||||
public void SetupExceptionHandlers()
|
public void SetupExceptionHandlers()
|
||||||
{
|
{
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
||||||
Application.ThreadException += delegate (Object sender, ThreadExceptionEventArgs e)
|
Application.ThreadException += delegate (Object sender, ThreadExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace EveOPreview
|
namespace EveOPreview
|
||||||
{
|
{
|
||||||
@@ -8,11 +10,17 @@ namespace EveOPreview
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IIocContainer
|
public interface IIocContainer
|
||||||
{
|
{
|
||||||
void Register<TService, TImplementation>() where TImplementation : TService;
|
void Register<TService, TImplementation>()
|
||||||
|
where TImplementation : TService;
|
||||||
|
void Register(Type serviceType, Assembly container);
|
||||||
void Register<TService>();
|
void Register<TService>();
|
||||||
void RegisterInstance<T>(T instance);
|
void Register<TService>(Expression<Func<TService>> factory);
|
||||||
TService Resolve<TService>();
|
|
||||||
bool IsRegistered<TService>();
|
|
||||||
void Register<TService, TArgument>(Expression<Func<TArgument, TService>> factory);
|
void Register<TService, TArgument>(Expression<Func<TArgument, TService>> factory);
|
||||||
|
void RegisterInstance<TService>(TService instance);
|
||||||
|
TService Resolve<TService>();
|
||||||
|
IEnumerable<TService> ResolveAll<TService>();
|
||||||
|
object Resolve(Type serviceType);
|
||||||
|
IEnumerable<object> ResolveAll(Type serviceType);
|
||||||
|
bool IsRegistered<TService>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Reflection;
|
||||||
using LightInject;
|
using LightInject;
|
||||||
|
|
||||||
namespace EveOPreview
|
namespace EveOPreview
|
||||||
@@ -19,9 +21,38 @@ namespace EveOPreview
|
|||||||
return this._container.CanGetInstance(typeof(TService), "");
|
return this._container.CanGetInstance(typeof(TService), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Register(Type serviceType, Assembly container)
|
||||||
|
{
|
||||||
|
if (!serviceType.IsInterface)
|
||||||
|
{
|
||||||
|
this._container.Register(serviceType, new PerContainerLifetime());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serviceType.IsInterface && serviceType.IsGenericType)
|
||||||
|
{
|
||||||
|
this._container.RegisterAssembly(container, (st, it) => st.IsConstructedGenericType && st.GetGenericTypeDefinition() == serviceType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (TypeInfo implementationType in container.DefinedTypes)
|
||||||
|
{
|
||||||
|
if (!implementationType.IsClass || implementationType.IsAbstract)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serviceType.IsAssignableFrom(implementationType))
|
||||||
|
{
|
||||||
|
this._container.Register(serviceType, implementationType, new PerContainerLifetime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Register<TService>()
|
public void Register<TService>()
|
||||||
{
|
{
|
||||||
this._container.Register<TService>();
|
this.Register(typeof(TService), typeof(TService).Assembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Register<TService, TImplementation>()
|
public void Register<TService, TImplementation>()
|
||||||
@@ -30,12 +61,17 @@ namespace EveOPreview
|
|||||||
this._container.Register<TService, TImplementation>();
|
this._container.Register<TService, TImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Register<TService>(Expression<Func<TService>> factory)
|
||||||
|
{
|
||||||
|
this._container.Register(f => factory);
|
||||||
|
}
|
||||||
|
|
||||||
public void Register<TService, TArgument>(Expression<Func<TArgument, TService>> factory)
|
public void Register<TService, TArgument>(Expression<Func<TArgument, TService>> factory)
|
||||||
{
|
{
|
||||||
this._container.Register(f => factory);
|
this._container.Register(f => factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterInstance<T>(T instance)
|
public void RegisterInstance<TService>(TService instance)
|
||||||
{
|
{
|
||||||
this._container.RegisterInstance(instance);
|
this._container.RegisterInstance(instance);
|
||||||
}
|
}
|
||||||
@@ -44,5 +80,20 @@ namespace EveOPreview
|
|||||||
{
|
{
|
||||||
return this._container.GetInstance<TService>();
|
return this._container.GetInstance<TService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<TService> ResolveAll<TService>()
|
||||||
|
{
|
||||||
|
return this._container.GetAllInstances<TService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Resolve(Type serviceType)
|
||||||
|
{
|
||||||
|
return this._container.GetInstance(serviceType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<object> ResolveAll(Type serviceType)
|
||||||
|
{
|
||||||
|
return this._container.GetAllInstances(serviceType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,12 +8,12 @@ namespace EveOPreview.Configuration
|
|||||||
private const string ConfigurationFileName = "EVE-O Preview.json";
|
private const string ConfigurationFileName = "EVE-O Preview.json";
|
||||||
|
|
||||||
private readonly IAppConfig _appConfig;
|
private readonly IAppConfig _appConfig;
|
||||||
private readonly IThumbnailConfig _thumbnailConfig;
|
private readonly IThumbnailConfiguration _thumbnailConfiguration;
|
||||||
|
|
||||||
public ConfigurationStorage(IAppConfig appConfig, IThumbnailConfig thumbnailConfig)
|
public ConfigurationStorage(IAppConfig appConfig, IThumbnailConfiguration thumbnailConfiguration)
|
||||||
{
|
{
|
||||||
this._appConfig = appConfig;
|
this._appConfig = appConfig;
|
||||||
this._thumbnailConfig = thumbnailConfig;
|
this._thumbnailConfiguration = thumbnailConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Load()
|
public void Load()
|
||||||
@@ -27,15 +27,15 @@ namespace EveOPreview.Configuration
|
|||||||
|
|
||||||
string rawData = File.ReadAllText(filename);
|
string rawData = File.ReadAllText(filename);
|
||||||
|
|
||||||
JsonConvert.PopulateObject(rawData, this._thumbnailConfig);
|
JsonConvert.PopulateObject(rawData, this._thumbnailConfiguration);
|
||||||
|
|
||||||
// Validate data after loading it
|
// Validate data after loading it
|
||||||
this._thumbnailConfig.ApplyRestrictions();
|
this._thumbnailConfiguration.ApplyRestrictions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
string rawData = JsonConvert.SerializeObject(this._thumbnailConfig, Formatting.Indented);
|
string rawData = JsonConvert.SerializeObject(this._thumbnailConfiguration, Formatting.Indented);
|
||||||
|
|
||||||
File.WriteAllText(this.GetConfigFileName(), rawData);
|
File.WriteAllText(this.GetConfigFileName(), rawData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace EveOPreview.Configuration
|
namespace EveOPreview.Configuration
|
||||||
{
|
{
|
||||||
/// <summary>
|
public interface IThumbnailConfiguration
|
||||||
/// Thumbnails Manager configuration
|
|
||||||
/// </summary>
|
|
||||||
public interface IThumbnailConfig
|
|
||||||
{
|
{
|
||||||
bool MinimizeToTray { get; set; }
|
bool MinimizeToTray { get; set; }
|
||||||
int ThumbnailRefreshPeriod { get; set; }
|
int ThumbnailRefreshPeriod { get; set; }
|
||||||
@@ -5,9 +5,9 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace EveOPreview.Configuration
|
namespace EveOPreview.Configuration
|
||||||
{
|
{
|
||||||
class ThumbnailConfig : IThumbnailConfig
|
class ThumbnailConfiguration : IThumbnailConfiguration
|
||||||
{
|
{
|
||||||
public ThumbnailConfig()
|
public ThumbnailConfiguration()
|
||||||
{
|
{
|
||||||
this.MinimizeToTray = false;
|
this.MinimizeToTray = false;
|
||||||
this.ThumbnailRefreshPeriod = 500;
|
this.ThumbnailRefreshPeriod = 500;
|
||||||
@@ -173,12 +173,12 @@ namespace EveOPreview.Configuration
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ApplyRestrictions()
|
public void ApplyRestrictions()
|
||||||
{
|
{
|
||||||
this.ThumbnailRefreshPeriod = ThumbnailConfig.ApplyRestrictions(this.ThumbnailRefreshPeriod, 300, 1000);
|
this.ThumbnailRefreshPeriod = ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailRefreshPeriod, 300, 1000);
|
||||||
this.ThumbnailSize = new Size(ThumbnailConfig.ApplyRestrictions(this.ThumbnailSize.Width, this.ThumbnailMinimumSize.Width, this.ThumbnailMaximumSize.Width),
|
this.ThumbnailSize = new Size(ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailSize.Width, this.ThumbnailMinimumSize.Width, this.ThumbnailMaximumSize.Width),
|
||||||
ThumbnailConfig.ApplyRestrictions(this.ThumbnailSize.Height, this.ThumbnailMinimumSize.Height, this.ThumbnailMaximumSize.Height));
|
ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailSize.Height, this.ThumbnailMinimumSize.Height, this.ThumbnailMaximumSize.Height));
|
||||||
this.ThumbnailOpacity = ThumbnailConfig.ApplyRestrictions((int)(this.ThumbnailOpacity * 100.00), 20, 100) / 100.00;
|
this.ThumbnailOpacity = ThumbnailConfiguration.ApplyRestrictions((int)(this.ThumbnailOpacity * 100.00), 20, 100) / 100.00;
|
||||||
this.ThumbnailZoomFactor = ThumbnailConfig.ApplyRestrictions(this.ThumbnailZoomFactor, 2, 10);
|
this.ThumbnailZoomFactor = ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailZoomFactor, 2, 10);
|
||||||
this.ActiveClientHighlightThickness = ThumbnailConfig.ApplyRestrictions(this.ActiveClientHighlightThickness, 1, 6);
|
this.ActiveClientHighlightThickness = ThumbnailConfiguration.ApplyRestrictions(this.ActiveClientHighlightThickness, 1, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int ApplyRestrictions(int value, int minimum, int maximum)
|
private static int ApplyRestrictions(int value, int minimum, int maximum)
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>EveOPreview</RootNamespace>
|
<RootNamespace>EveOPreview</RootNamespace>
|
||||||
<AssemblyName>Eve-O Preview</AssemblyName>
|
<AssemblyName>Eve-O Preview</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
<NuGetPackageImportStamp>
|
<NuGetPackageImportStamp>
|
||||||
</NuGetPackageImportStamp>
|
</NuGetPackageImportStamp>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
@@ -83,9 +83,12 @@
|
|||||||
<HintPath>..\packages\LightInject.5.1.2\lib\net452\LightInject.dll</HintPath>
|
<HintPath>..\packages\LightInject.5.1.2\lib\net452\LightInject.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json">
|
<Reference Include="MediatR, Version=4.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>R:\eve-o-preview\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\MediatR.4.0.1\lib\net45\MediatR.dll</HintPath>
|
||||||
<Private>True</Private>
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Deployment" />
|
<Reference Include="System.Deployment" />
|
||||||
@@ -108,59 +111,75 @@
|
|||||||
<Compile Include="Configuration\AppConfig.cs" />
|
<Compile Include="Configuration\AppConfig.cs" />
|
||||||
<Compile Include="Configuration\ConfigurationStorage.cs" />
|
<Compile Include="Configuration\ConfigurationStorage.cs" />
|
||||||
<Compile Include="Configuration\IAppConfig.cs" />
|
<Compile Include="Configuration\IAppConfig.cs" />
|
||||||
<Compile Include="Configuration\IThumbnailConfig.cs" />
|
<Compile Include="Configuration\IThumbnailConfiguration.cs" />
|
||||||
<Compile Include="Configuration\ZoomAnchor.cs" />
|
<Compile Include="Configuration\ZoomAnchor.cs" />
|
||||||
<Compile Include="DwmAPI\Implementation\DwmThumbnail.cs" />
|
<Compile Include="Mediator\Handlers\Configuration\SaveConfigurationHandler.cs" />
|
||||||
<Compile Include="DwmAPI\Interface\IDwmThumbnail.cs" />
|
<Compile Include="Mediator\Handlers\Thumbnails\ThumbnailListUpdatedHandler.cs" />
|
||||||
<Compile Include="DwmAPI\Interface\InteropConstants.cs" />
|
<Compile Include="Mediator\Messages\Thumbnails\ThumbnailListUpdated.cs" />
|
||||||
<Compile Include="DwmAPI\Interop\DWM_BLURBEHIND.cs" />
|
<Compile Include="Mediator\Handlers\Thumbnails\ThumbnailLocationUpdatedHandler.cs" />
|
||||||
<Compile Include="DwmAPI\Interop\DWM_THUMBNAIL_PROPERTIES.cs" />
|
<Compile Include="Mediator\Handlers\Thumbnails\ThumbnailSizeUpdatedHandler.cs" />
|
||||||
<Compile Include="DwmAPI\Interop\DWM_TNP_CONSTANTS.cs" />
|
<Compile Include="Mediator\Handlers\Services\StartServiceHandler.cs" />
|
||||||
<Compile Include="DwmAPI\Interface\IWindowManager.cs" />
|
<Compile Include="Mediator\Handlers\Services\StopServiceHandler.cs" />
|
||||||
<Compile Include="DwmAPI\Interop\MARGINS.cs" />
|
<Compile Include="Mediator\Messages\Base\NotificationBase.cs" />
|
||||||
<Compile Include="DwmAPI\Interop\RECT.cs" />
|
<Compile Include="Mediator\Messages\Configuration\SaveConfiguration.cs" />
|
||||||
|
<Compile Include="Mediator\Messages\Services\StartService.cs" />
|
||||||
|
<Compile Include="Mediator\Messages\Services\StopService.cs" />
|
||||||
|
<Compile Include="Mediator\Messages\Thumbnails\ThumbnailLocationUpdated.cs" />
|
||||||
|
<Compile Include="Mediator\Messages\Thumbnails\ThumbnailSizeUpdated.cs" />
|
||||||
|
<Compile Include="Presenters\Interface\IMainFormPresenter.cs" />
|
||||||
|
<Compile Include="Services\Implementation\ProcessInfo.cs" />
|
||||||
|
<Compile Include="Services\Implementation\ProcessMonitor.cs" />
|
||||||
|
<Compile Include="Services\Interface\IProcessInfo.cs" />
|
||||||
|
<Compile Include="Services\Interface\IProcessMonitor.cs" />
|
||||||
|
<Compile Include="Services\Implementation\DwmThumbnail.cs" />
|
||||||
|
<Compile Include="Services\Interface\IDwmThumbnail.cs" />
|
||||||
|
<Compile Include="Services\Interface\InteropConstants.cs" />
|
||||||
|
<Compile Include="Services\Interop\DWM_BLURBEHIND.cs" />
|
||||||
|
<Compile Include="Services\Interop\DWM_THUMBNAIL_PROPERTIES.cs" />
|
||||||
|
<Compile Include="Services\Interop\DWM_TNP_CONSTANTS.cs" />
|
||||||
|
<Compile Include="Services\Interface\IWindowManager.cs" />
|
||||||
|
<Compile Include="Services\Interop\MARGINS.cs" />
|
||||||
|
<Compile Include="Services\Interop\RECT.cs" />
|
||||||
<Compile Include="Configuration\ClientLayout.cs" />
|
<Compile Include="Configuration\ClientLayout.cs" />
|
||||||
<Compile Include="ApplicationBase\IPresenter.cs" />
|
<Compile Include="ApplicationBase\IPresenter.cs" />
|
||||||
<Compile Include="DwmAPI\Implementation\WindowManager.cs" />
|
<Compile Include="Services\Implementation\WindowManager.cs" />
|
||||||
<Compile Include="DwmAPI\Interop\User32NativeMethods.cs" />
|
<Compile Include="Services\Interop\User32NativeMethods.cs" />
|
||||||
<Compile Include="Presentation\MainPresenter.cs" />
|
<Compile Include="Presenters\Implementation\MainFormPresenter.cs" />
|
||||||
<Compile Include="Presentation\ViewCloseRequest.cs" />
|
<Compile Include="Presenters\Interface\ViewCloseRequest.cs" />
|
||||||
<Compile Include="Presentation\ViewZoomAnchorConverter.cs" />
|
<Compile Include="Presenters\Implementation\ViewZoomAnchorConverter.cs" />
|
||||||
<Compile Include="UI\Interface\IThumbnailViewFactory.cs" />
|
<Compile Include="View\Interface\IThumbnailViewFactory.cs" />
|
||||||
<Compile Include="Presentation\IThumbnailManager.cs" />
|
<Compile Include="Services\Interface\IThumbnailManager.cs" />
|
||||||
<Compile Include="UI\Implementation\ThumbnailDescriptionView.cs" />
|
<Compile Include="View\Implementation\ThumbnailDescription.cs" />
|
||||||
<Compile Include="UI\Factory\ThumbnailDescriptionViewFactory.cs" />
|
<Compile Include="View\Interface\IMainFormView.cs" />
|
||||||
<Compile Include="UI\Interface\IMainView.cs" />
|
|
||||||
<Compile Include="ApplicationBase\IView.cs" />
|
<Compile Include="ApplicationBase\IView.cs" />
|
||||||
<Compile Include="UI\Interface\IThumbnailDescriptionView.cs" />
|
<Compile Include="View\Interface\IThumbnailDescription.cs" />
|
||||||
<Compile Include="UI\Interface\IThumbnailDescriptionViewFactory.cs" />
|
<Compile Include="View\Interface\ViewZoomAnchor.cs" />
|
||||||
<Compile Include="UI\Interface\ViewZoomAnchor.cs" />
|
<Compile Include="Configuration\ThumbnailConfiguration.cs" />
|
||||||
<Compile Include="Configuration\ThumbnailConfig.cs" />
|
|
||||||
<Compile Include="Hotkeys\HotkeyHandler.cs" />
|
<Compile Include="Hotkeys\HotkeyHandler.cs" />
|
||||||
<Compile Include="Hotkeys\HotkeyHandlerNativeMethods.cs" />
|
<Compile Include="Hotkeys\HotkeyHandlerNativeMethods.cs" />
|
||||||
<Compile Include="UI\Implementation\MainForm.cs">
|
<Compile Include="View\Implementation\MainForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="UI\Implementation\MainForm.Designer.cs">
|
<Compile Include="View\Implementation\MainForm.Designer.cs">
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Configuration\IConfigurationStorage.cs" />
|
<Compile Include="Configuration\IConfigurationStorage.cs" />
|
||||||
<Compile Include="UI\Interface\IThumbnailView.cs" />
|
<Compile Include="View\Interface\IThumbnailView.cs" />
|
||||||
<Compile Include="UI\Factory\ThumbnailViewFactory.cs" />
|
<Compile Include="View\Implementation\ThumbnailViewFactory.cs" />
|
||||||
<Compile Include="Presentation\ThumbnailManager.cs" />
|
<Compile Include="Services\Implementation\ThumbnailManager.cs" />
|
||||||
<Compile Include="UI\Implementation\ThumbnailOverlay.cs">
|
<Compile Include="View\Implementation\ThumbnailOverlay.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="UI\Implementation\ThumbnailOverlay.Designer.cs">
|
<Compile Include="View\Implementation\ThumbnailOverlay.Designer.cs">
|
||||||
<DependentUpon>ThumbnailOverlay.cs</DependentUpon>
|
<DependentUpon>ThumbnailOverlay.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<EmbeddedResource Include="UI\Implementation\MainForm.resx">
|
<EmbeddedResource Include="View\Implementation\MainForm.resx">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="UI\Implementation\ThumbnailOverlay.resx">
|
<EmbeddedResource Include="View\Implementation\ThumbnailOverlay.resx">
|
||||||
<DependentUpon>ThumbnailOverlay.cs</DependentUpon>
|
<DependentUpon>ThumbnailOverlay.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
@@ -168,7 +187,7 @@
|
|||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="UI\Implementation\ThumbnailView.resx">
|
<EmbeddedResource Include="View\Implementation\ThumbnailView.resx">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<DependentUpon>ThumbnailView.cs</DependentUpon>
|
<DependentUpon>ThumbnailView.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
@@ -177,13 +196,13 @@
|
|||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="UI\Implementation\ThumbnailView.cs">
|
<Compile Include="View\Implementation\ThumbnailView.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="UI\Implementation\ThumbnailView.Designer.cs">
|
<Compile Include="View\Implementation\ThumbnailView.Designer.cs">
|
||||||
<DependentUpon>ThumbnailView.cs</DependentUpon>
|
<DependentUpon>ThumbnailView.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="DwmAPI\Interop\DwmApiNativeMethods.cs" />
|
<Compile Include="Services\Interop\DwmApiNativeMethods.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
@@ -203,11 +222,11 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Error Condition="!Exists('..\packages\Fody.2.3.23\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'R:\eve-o-preview\packages\Fody.2.3.23\build\Fody.targets'))" />
|
|
||||||
<Error Condition="!Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets'))" />
|
<Error Condition="!Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\Fody.2.4.1\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.2.4.1\build\Fody.targets'))" />
|
||||||
</Target>
|
</Target>
|
||||||
<Import Project="..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" />
|
<Import Project="..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" />
|
||||||
<Import Project="..\packages\Fody.2.3.23\build\Fody.targets" Condition="Exists('..\packages\Fody.2.3.23\build\Fody.targets')" />
|
<Import Project="..\packages\Fody.2.4.1\build\Fody.targets" Condition="Exists('..\packages\Fody.2.4.1\build\Fody.targets')" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.UI.Hotkeys
|
||||||
{
|
{
|
||||||
class HotkeyHandler : IMessageFilter, IDisposable
|
class HotkeyHandler : IMessageFilter, IDisposable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.UI.Hotkeys
|
||||||
{
|
{
|
||||||
static class HotkeyHandlerNativeMethods
|
static class HotkeyHandlerNativeMethods
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using EveOPreview.Configuration;
|
||||||
|
using EveOPreview.Mediator.Messages;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EveOPreview.Mediator.Handlers.Configuration
|
||||||
|
{
|
||||||
|
sealed class SaveConfigurationHandler : IRequestHandler<SaveConfiguration>
|
||||||
|
{
|
||||||
|
private readonly IConfigurationStorage _storage;
|
||||||
|
|
||||||
|
public SaveConfigurationHandler(IConfigurationStorage storage)
|
||||||
|
{
|
||||||
|
this._storage = storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(SaveConfiguration message, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
this._storage.Save();
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using EveOPreview.Mediator.Messages;
|
||||||
|
using EveOPreview.Services;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EveOPreview.Mediator.Handlers.Services
|
||||||
|
{
|
||||||
|
sealed class StartServiceHandler : IRequestHandler<StartService>
|
||||||
|
{
|
||||||
|
private readonly IThumbnailManager _manager;
|
||||||
|
|
||||||
|
public StartServiceHandler(IThumbnailManager manager)
|
||||||
|
{
|
||||||
|
this._manager = manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(StartService message, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
this._manager.Start();
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using EveOPreview.Mediator.Messages;
|
||||||
|
using EveOPreview.Services;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EveOPreview.Mediator.Handlers.Services
|
||||||
|
{
|
||||||
|
sealed class StopServiceHandler : IRequestHandler<StopService>
|
||||||
|
{
|
||||||
|
private readonly IThumbnailManager _manager;
|
||||||
|
|
||||||
|
public StopServiceHandler(IThumbnailManager manager)
|
||||||
|
{
|
||||||
|
this._manager = manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(StopService message, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
this._manager.Stop();
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
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)
|
||||||
|
{
|
||||||
|
if (notification.Added.Count > 0)
|
||||||
|
{
|
||||||
|
this._presenter.AddThumbnails(notification.Added);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notification.Removed.Count > 0)
|
||||||
|
{
|
||||||
|
this._presenter.RemoveThumbnails(notification.Removed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using EveOPreview.Configuration;
|
||||||
|
using EveOPreview.Mediator.Messages;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EveOPreview.Mediator.Handlers.Thumbnails
|
||||||
|
{
|
||||||
|
sealed class ThumbnailLocationUpdatedHandler : INotificationHandler<ThumbnailLocationUpdated>
|
||||||
|
{
|
||||||
|
private readonly IMediator _mediator;
|
||||||
|
private readonly IThumbnailConfiguration _configuration;
|
||||||
|
|
||||||
|
public ThumbnailLocationUpdatedHandler(IMediator mediator, IThumbnailConfiguration configuration)
|
||||||
|
{
|
||||||
|
this._mediator = mediator;
|
||||||
|
this._configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(ThumbnailLocationUpdated notification, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
this._configuration.SetThumbnailLocation(notification.ThumbnailName, notification.ActiveClientName, notification.Location);
|
||||||
|
|
||||||
|
return this._mediator.Send(new SaveConfiguration(), cancellationToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using EveOPreview.Mediator.Messages;
|
||||||
|
using EveOPreview.Presenters;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EveOPreview.Mediator.Handlers.Thumbnails
|
||||||
|
{
|
||||||
|
sealed class ThumbnailSizeUpdatedHandler : INotificationHandler<ThumbnailSizeUpdated>
|
||||||
|
{
|
||||||
|
private readonly IMainFormPresenter _presenter;
|
||||||
|
|
||||||
|
public ThumbnailSizeUpdatedHandler(MainFormPresenter presenter)
|
||||||
|
{
|
||||||
|
this._presenter = presenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(ThumbnailSizeUpdated notification, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
this._presenter.UpdateThumbnailSize(notification.Value);
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Eve-O-Preview/Mediator/Messages/Base/NotificationBase.cs
Normal file
14
Eve-O-Preview/Mediator/Messages/Base/NotificationBase.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EveOPreview.Mediator.Messages
|
||||||
|
{
|
||||||
|
abstract class NotificationBase<TValue> : INotification
|
||||||
|
{
|
||||||
|
protected NotificationBase(TValue value)
|
||||||
|
{
|
||||||
|
this.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TValue Value { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EveOPreview.Mediator.Messages
|
||||||
|
{
|
||||||
|
sealed class SaveConfiguration : IRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
8
Eve-O-Preview/Mediator/Messages/Services/StartService.cs
Normal file
8
Eve-O-Preview/Mediator/Messages/Services/StartService.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EveOPreview.Mediator.Messages
|
||||||
|
{
|
||||||
|
sealed class StartService : IRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
8
Eve-O-Preview/Mediator/Messages/Services/StopService.cs
Normal file
8
Eve-O-Preview/Mediator/Messages/Services/StopService.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EveOPreview.Mediator.Messages
|
||||||
|
{
|
||||||
|
sealed class StopService : IRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EveOPreview.Mediator.Messages
|
||||||
|
{
|
||||||
|
sealed class ThumbnailListUpdated : INotification
|
||||||
|
{
|
||||||
|
public ThumbnailListUpdated(IList<string> addedThumbnails, IList<string> removedThumbnails)
|
||||||
|
{
|
||||||
|
this.Added = addedThumbnails;
|
||||||
|
this.Removed = removedThumbnails;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<string> Added { get; }
|
||||||
|
public IList<string> Removed { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System.Drawing;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EveOPreview.Mediator.Messages
|
||||||
|
{
|
||||||
|
sealed class ThumbnailLocationUpdated : INotification
|
||||||
|
{
|
||||||
|
public ThumbnailLocationUpdated(string thumbnailName, string activeClientName, Point location)
|
||||||
|
{
|
||||||
|
this.ThumbnailName = thumbnailName;
|
||||||
|
this.ActiveClientName = activeClientName;
|
||||||
|
this.Location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ThumbnailName { get; }
|
||||||
|
|
||||||
|
public string ActiveClientName { get; }
|
||||||
|
|
||||||
|
public Point Location { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace EveOPreview.Mediator.Messages
|
||||||
|
{
|
||||||
|
sealed class ThumbnailSizeUpdated : NotificationBase<Size>
|
||||||
|
{
|
||||||
|
public ThumbnailSizeUpdated(Size size)
|
||||||
|
: base(size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
|
||||||
{
|
|
||||||
public interface IThumbnailManager
|
|
||||||
{
|
|
||||||
void Activate();
|
|
||||||
void Deactivate();
|
|
||||||
|
|
||||||
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; }
|
|
||||||
|
|
||||||
Action<String, String, Point> ThumbnailPositionChanged { get; set; }
|
|
||||||
Action<Size> ThumbnailSizeChanged { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,36 +3,41 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using EveOPreview.Configuration;
|
using EveOPreview.Configuration;
|
||||||
|
using EveOPreview.Mediator.Messages;
|
||||||
|
using EveOPreview.Services;
|
||||||
|
using EveOPreview.View;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.Presenters
|
||||||
{
|
{
|
||||||
public class MainPresenter : Presenter<IMainView>
|
public class MainFormPresenter : Presenter<IMainFormView>, IMainFormPresenter
|
||||||
{
|
{
|
||||||
#region Private constants
|
#region Private constants
|
||||||
private const string ForumUrl = @"https://meta.eveonline.com/t/4202";
|
private const string ForumUrl = @"https://meta.eveonline.com/t/4202";
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private fields
|
#region Private fields
|
||||||
private readonly IThumbnailConfig _configuration;
|
private readonly IMediator _mediator;
|
||||||
|
private readonly IThumbnailConfiguration _configuration;
|
||||||
private readonly IConfigurationStorage _configurationStorage;
|
private readonly IConfigurationStorage _configurationStorage;
|
||||||
private readonly IThumbnailDescriptionViewFactory _thumbnailDescriptionViewFactory;
|
|
||||||
private readonly IDictionary<IntPtr, IThumbnailDescriptionView> _thumbnailDescriptionViews;
|
|
||||||
private readonly IThumbnailManager _thumbnailManager;
|
private readonly IThumbnailManager _thumbnailManager;
|
||||||
|
|
||||||
|
private readonly IDictionary<string, IThumbnailDescription> _descriptionsCache;
|
||||||
|
|
||||||
private bool _exitApplication;
|
private bool _exitApplication;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public MainPresenter(IApplicationController controller, IMainView view, IThumbnailConfig configuration, IConfigurationStorage configurationStorage,
|
public MainFormPresenter(IApplicationController controller, IMainFormView view, IMediator mediator, IThumbnailConfiguration configuration, IConfigurationStorage configurationStorage,
|
||||||
IThumbnailManager thumbnailManager, IThumbnailDescriptionViewFactory thumbnailDescriptionViewFactory)
|
IThumbnailManager thumbnailManager)
|
||||||
: base(controller, view)
|
: base(controller, view)
|
||||||
{
|
{
|
||||||
|
this._mediator = mediator;
|
||||||
this._configuration = configuration;
|
this._configuration = configuration;
|
||||||
this._configurationStorage = configurationStorage;
|
this._configurationStorage = configurationStorage;
|
||||||
|
|
||||||
this._thumbnailDescriptionViewFactory = thumbnailDescriptionViewFactory;
|
|
||||||
this._thumbnailManager = thumbnailManager;
|
this._thumbnailManager = thumbnailManager;
|
||||||
|
|
||||||
this._thumbnailDescriptionViews = new Dictionary<IntPtr, IThumbnailDescriptionView>();
|
this._descriptionsCache = new Dictionary<string, IThumbnailDescription>();
|
||||||
|
|
||||||
this._exitApplication = false;
|
this._exitApplication = false;
|
||||||
|
|
||||||
this.View.FormActivated = this.Activate;
|
this.View.FormActivated = this.Activate;
|
||||||
@@ -43,26 +48,19 @@ namespace EveOPreview.UI
|
|||||||
this.View.ThumbnailStateChanged = this.UpdateThumbnailState;
|
this.View.ThumbnailStateChanged = this.UpdateThumbnailState;
|
||||||
this.View.DocumentationLinkActivated = this.OpenDocumentationLink;
|
this.View.DocumentationLinkActivated = this.OpenDocumentationLink;
|
||||||
this.View.ApplicationExitRequested = this.ExitApplication;
|
this.View.ApplicationExitRequested = this.ExitApplication;
|
||||||
|
|
||||||
this._thumbnailManager.ThumbnailsAdded = this.ThumbnailsAdded;
|
|
||||||
this._thumbnailManager.ThumbnailsUpdated = this.ThumbnailsUpdated;
|
|
||||||
this._thumbnailManager.ThumbnailsRemoved = this.ThumbnailsRemoved;
|
|
||||||
|
|
||||||
this._thumbnailManager.ThumbnailPositionChanged = this.ThumbnailPositionChanged;
|
|
||||||
this._thumbnailManager.ThumbnailSizeChanged = this.ThumbnailSizeChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Activate()
|
private void Activate()
|
||||||
{
|
{
|
||||||
this.LoadApplicationSettings();
|
this.LoadApplicationSettings();
|
||||||
this.View.SetDocumentationUrl(MainPresenter.ForumUrl);
|
this.View.SetDocumentationUrl(MainFormPresenter.ForumUrl);
|
||||||
this.View.SetVersionInfo(this.GetApplicationVersion());
|
this.View.SetVersionInfo(this.GetApplicationVersion());
|
||||||
if (this._configuration.MinimizeToTray)
|
if (this._configuration.MinimizeToTray)
|
||||||
{
|
{
|
||||||
this.View.Minimize();
|
this.View.Minimize();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._thumbnailManager.Activate();
|
this._mediator.Send(new StartService());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Minimize()
|
private void Minimize()
|
||||||
@@ -79,7 +77,9 @@ namespace EveOPreview.UI
|
|||||||
{
|
{
|
||||||
if (this._exitApplication || !this.View.MinimizeToTray)
|
if (this._exitApplication || !this.View.MinimizeToTray)
|
||||||
{
|
{
|
||||||
this._thumbnailManager.Deactivate();
|
this._mediator.Send(new StopService()).Wait();
|
||||||
|
|
||||||
|
this._thumbnailManager.Stop();
|
||||||
this._configurationStorage.Save();
|
this._configurationStorage.Save();
|
||||||
request.Allow = true;
|
request.Allow = true;
|
||||||
return;
|
return;
|
||||||
@@ -152,89 +152,73 @@ namespace EveOPreview.UI
|
|||||||
this._thumbnailManager.SetupThumbnailFrames();
|
this._thumbnailManager.SetupThumbnailFrames();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThumbnailsAdded(IList<IThumbnailView> thumbnails)
|
|
||||||
|
public void AddThumbnails(IList<string> thumbnailTitles)
|
||||||
{
|
{
|
||||||
this.View.AddThumbnails(this.GetThumbnailViews(thumbnails, false));
|
IList<IThumbnailDescription> descriptions = new List<IThumbnailDescription>(thumbnailTitles.Count);
|
||||||
|
|
||||||
|
lock (this._descriptionsCache)
|
||||||
|
{
|
||||||
|
foreach (string title in thumbnailTitles)
|
||||||
|
{
|
||||||
|
IThumbnailDescription description = this.CreateThumbnailDescription(title);
|
||||||
|
this._descriptionsCache[title] = description;
|
||||||
|
|
||||||
|
descriptions.Add(description);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThumbnailsUpdated(IList<IThumbnailView> thumbnails)
|
this.View.AddThumbnails(descriptions);
|
||||||
{
|
|
||||||
this.View.UpdateThumbnails(this.GetThumbnailViews(thumbnails, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThumbnailsRemoved(IList<IThumbnailView> thumbnails)
|
public void RemoveThumbnails(IList<string> thumbnailTitles)
|
||||||
{
|
{
|
||||||
this.View.RemoveThumbnails(this.GetThumbnailViews(thumbnails, true));
|
IList<IThumbnailDescription> descriptions = new List<IThumbnailDescription>(thumbnailTitles.Count);
|
||||||
}
|
|
||||||
|
|
||||||
private IList<IThumbnailDescriptionView> GetThumbnailViews(IList<IThumbnailView> thumbnails, bool removeFromCache)
|
lock (this._descriptionsCache)
|
||||||
{
|
{
|
||||||
IList<IThumbnailDescriptionView> thumbnailViews = new List<IThumbnailDescriptionView>(thumbnails.Count);
|
foreach (string title in thumbnailTitles)
|
||||||
|
|
||||||
// Time for some thread safety
|
|
||||||
lock (this._thumbnailDescriptionViews)
|
|
||||||
{
|
{
|
||||||
foreach (IThumbnailView thumbnail in thumbnails)
|
if (!this._descriptionsCache.TryGetValue(title, out IThumbnailDescription description))
|
||||||
{
|
{
|
||||||
IThumbnailDescriptionView thumbnailView;
|
|
||||||
bool foundInCache = this._thumbnailDescriptionViews.TryGetValue(thumbnail.Id, out thumbnailView);
|
|
||||||
|
|
||||||
if (!foundInCache)
|
|
||||||
{
|
|
||||||
if (removeFromCache)
|
|
||||||
{
|
|
||||||
// This item was not even cached
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
thumbnailView = this._thumbnailDescriptionViewFactory.Create(thumbnail.Id, thumbnail.Title, !thumbnail.IsEnabled);
|
this._descriptionsCache.Remove(title);
|
||||||
this._thumbnailDescriptionViews.Add(thumbnail.Id, thumbnailView);
|
descriptions.Add(description);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (removeFromCache)
|
|
||||||
{
|
|
||||||
this._thumbnailDescriptionViews.Remove(thumbnail.Id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
thumbnailView.Title = thumbnail.Title;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
thumbnailViews.Add(thumbnailView);
|
this.View.RemoveThumbnails(descriptions);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return thumbnailViews;
|
private IThumbnailDescription CreateThumbnailDescription(string title)
|
||||||
}
|
|
||||||
|
|
||||||
private void ThumbnailPositionChanged(String thumbnailName, String activeClientName, Point location)
|
|
||||||
{
|
{
|
||||||
this._configuration.SetThumbnailLocation(thumbnailName, activeClientName, location);
|
// TODO Read here persisted value for the IsDisabled parameter
|
||||||
this._configurationStorage.Save();
|
return new ThumbnailDescription(title, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThumbnailSizeChanged(Size size)
|
private void UpdateThumbnailState(String title)
|
||||||
|
{
|
||||||
|
//this._thumbnailManager.SetThumbnailState(thumbnailId, this._thumbnailDescriptionViews[thumbnailId].IsDisabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateThumbnailSize(Size size)
|
||||||
{
|
{
|
||||||
this.View.ThumbnailSize = size;
|
this.View.ThumbnailSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateThumbnailState(IntPtr thumbnailId)
|
|
||||||
{
|
|
||||||
this._thumbnailManager.SetThumbnailState(thumbnailId, this._thumbnailDescriptionViews[thumbnailId].IsDisabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OpenDocumentationLink()
|
private void OpenDocumentationLink()
|
||||||
{
|
{
|
||||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(new Uri(MainPresenter.ForumUrl).AbsoluteUri);
|
// TODO Move out
|
||||||
|
ProcessStartInfo processStartInfo = new ProcessStartInfo(new Uri(MainFormPresenter.ForumUrl).AbsoluteUri);
|
||||||
Process.Start(processStartInfo);
|
Process.Start(processStartInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetApplicationVersion()
|
private string GetApplicationVersion()
|
||||||
{
|
{
|
||||||
Version version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version;
|
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()
|
private void ExitApplication()
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using EveOPreview.Configuration;
|
using EveOPreview.Configuration;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
static class ViewZoomAnchorConverter
|
static class ViewZoomAnchorConverter
|
||||||
{
|
{
|
||||||
13
Eve-O-Preview/Presenters/Interface/IMainFormPresenter.cs
Normal file
13
Eve-O-Preview/Presenters/Interface/IMainFormPresenter.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace EveOPreview.Presenters
|
||||||
|
{
|
||||||
|
interface IMainFormPresenter
|
||||||
|
{
|
||||||
|
void AddThumbnails(IList<string> thumbnailTitles);
|
||||||
|
void RemoveThumbnails(IList<string> thumbnailTitles);
|
||||||
|
|
||||||
|
void UpdateThumbnailSize(Size size);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
public class ViewCloseRequest
|
public class ViewCloseRequest
|
||||||
{
|
{
|
||||||
@@ -2,18 +2,21 @@ using System;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using EveOPreview.Configuration;
|
using EveOPreview.Configuration;
|
||||||
|
using EveOPreview.Presenters;
|
||||||
|
using EveOPreview.Services;
|
||||||
using EveOPreview.UI;
|
using EveOPreview.UI;
|
||||||
|
using EveOPreview.View;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
namespace EveOPreview
|
namespace EveOPreview
|
||||||
{
|
{
|
||||||
static class Program
|
static class Program
|
||||||
{
|
{
|
||||||
private static string MutexName = "EVE-O Preview Single Instance Mutex";
|
private static string MutexName = "EVE-O Preview Single Instance Mutex";
|
||||||
private static string ConfigParameterName = "--config:";
|
|
||||||
|
|
||||||
/// <summary>The main entry point for the application.</summary>
|
/// <summary>The main entry point for the application.</summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main(string[] args)
|
static void Main()
|
||||||
{
|
{
|
||||||
// The very usual Mutex-based single-instance screening
|
// The very usual Mutex-based single-instance screening
|
||||||
// 'token' variable is used to store reference to the instance Mutex
|
// 'token' variable is used to store reference to the instance Mutex
|
||||||
@@ -30,55 +33,23 @@ namespace EveOPreview
|
|||||||
ExceptionHandler handler = new ExceptionHandler();
|
ExceptionHandler handler = new ExceptionHandler();
|
||||||
handler.SetupExceptionHandlers();
|
handler.SetupExceptionHandlers();
|
||||||
|
|
||||||
Program.InitializeWinFormsGui();
|
|
||||||
|
|
||||||
IApplicationController controller = Program.InitializeApplicationController();
|
IApplicationController controller = Program.InitializeApplicationController();
|
||||||
Program.SetupApplicationConttroller(controller, Program.GetCustomConfigFile(args));
|
|
||||||
|
|
||||||
controller.Run<MainPresenter>();
|
Program.InitializeWinForms();
|
||||||
}
|
controller.Run<MainFormPresenter>();
|
||||||
|
|
||||||
private static string GetCustomConfigFile(string[] args)
|
|
||||||
{
|
|
||||||
// Parse startup parameters
|
|
||||||
// Simple approach is used because something like NParams would be an overkill here
|
|
||||||
string configFile = null;
|
|
||||||
foreach (string arg in args)
|
|
||||||
{
|
|
||||||
if ((arg.Length <= Program.ConfigParameterName.Length) || !arg.StartsWith(Program.ConfigParameterName, StringComparison.Ordinal))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
configFile = arg.Substring(Program.ConfigParameterName.Length);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(configFile))
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// One more check to drop trailing "
|
|
||||||
if ((configFile.Length > 3) && (configFile[0] == '"') && (configFile[configFile.Length - 1] == '"'))
|
|
||||||
{
|
|
||||||
configFile = configFile.Substring(1, configFile.Length - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return configFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static object GetInstanceToken()
|
private static object GetInstanceToken()
|
||||||
{
|
{
|
||||||
// The code might look overcomplicated here for a single Mutex operation
|
// The code might look overcomplicated here for a single Mutex operation
|
||||||
// Yet we had already experienced a Windows-level issue
|
// Yet we had already experienced a Windows-level issue
|
||||||
// where .NET finalizer theread was literally paralyzed by
|
// where .NET finalizer thread was literally paralyzed by
|
||||||
// a failed Mutex operation. That did lead to weird OutOfMemory
|
// a failed Mutex operation. That did lead to weird OutOfMemory
|
||||||
// exceptions later
|
// exceptions later
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Mutex mutex = Mutex.OpenExisting(Program.MutexName);
|
Mutex.OpenExisting(Program.MutexName);
|
||||||
// if that didn't fail then anotherinstance is already running
|
// if that didn't fail then another instance is already running
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (UnauthorizedAccessException)
|
catch (UnauthorizedAccessException)
|
||||||
@@ -92,7 +63,7 @@ namespace EveOPreview
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void InitializeWinFormsGui()
|
private static void InitializeWinForms()
|
||||||
{
|
{
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
@@ -102,28 +73,37 @@ namespace EveOPreview
|
|||||||
{
|
{
|
||||||
IIocContainer container = new LightInjectContainer();
|
IIocContainer container = new LightInjectContainer();
|
||||||
|
|
||||||
// UI classes
|
// Singleton registration is used for services
|
||||||
IApplicationController controller = new ApplicationController(container)
|
// Low-level services
|
||||||
.RegisterView<IMainView, MainForm>()
|
container.Register<IWindowManager>();
|
||||||
.RegisterView<IThumbnailView, ThumbnailView>()
|
container.Register<IProcessMonitor>();
|
||||||
.RegisterView<IThumbnailDescriptionView, ThumbnailDescriptionView>()
|
|
||||||
.RegisterInstance(new ApplicationContext());
|
// MediatR
|
||||||
|
container.Register<IMediator, MediatR.Mediator>();
|
||||||
|
container.RegisterInstance<SingleInstanceFactory>(t => container.Resolve(t));
|
||||||
|
container.RegisterInstance<MultiInstanceFactory>(t => container.ResolveAll(t));
|
||||||
|
container.Register(typeof(INotificationHandler<>), typeof(Program).Assembly);
|
||||||
|
container.Register(typeof(IRequestHandler<>), typeof(Program).Assembly);
|
||||||
|
container.Register(typeof(IRequestHandler<,>), typeof(Program).Assembly);
|
||||||
|
|
||||||
|
// Configuration services
|
||||||
|
container.Register<IConfigurationStorage>();
|
||||||
|
container.Register<IAppConfig>();
|
||||||
|
container.Register<IThumbnailConfiguration>();
|
||||||
|
|
||||||
// Application services
|
// Application services
|
||||||
controller.RegisterService<IThumbnailManager, ThumbnailManager>()
|
container.Register<IThumbnailManager>();
|
||||||
.RegisterService<IThumbnailViewFactory, ThumbnailViewFactory>()
|
container.Register<IThumbnailViewFactory>();
|
||||||
.RegisterService<IThumbnailDescriptionViewFactory, ThumbnailDescriptionViewFactory>()
|
container.Register<IThumbnailDescription>();
|
||||||
.RegisterService<IConfigurationStorage, ConfigurationStorage>()
|
|
||||||
.RegisterService<IWindowManager, EveOPreview.DwmAPI.WindowManager>()
|
IApplicationController controller = new ApplicationController(container);
|
||||||
.RegisterInstance<IAppConfig>(new AppConfig())
|
|
||||||
.RegisterInstance<IThumbnailConfig>(new ThumbnailConfig());
|
// UI classes
|
||||||
|
controller.RegisterView<IMainFormView, MainForm>()
|
||||||
|
.RegisterView<IThumbnailView, ThumbnailView>()
|
||||||
|
.RegisterInstance(new ApplicationContext());
|
||||||
|
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetupApplicationConttroller(IApplicationController controller, string configFile)
|
|
||||||
{
|
|
||||||
controller.Create<IAppConfig>().ConfigFileName = configFile;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,4 +15,4 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyVersion("4.0.0.0")]
|
[assembly: AssemblyVersion("4.0.0.0")]
|
||||||
[assembly: AssemblyFileVersion("4.0.0.0")]
|
[assembly: AssemblyFileVersion("4.0.0.0")]
|
||||||
|
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(false)]
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using EveOPreview.DwmInterop;
|
using EveOPreview.Services.Interop;
|
||||||
|
|
||||||
namespace EveOPreview.DwmAPI
|
namespace EveOPreview.Services.Implementation
|
||||||
{
|
{
|
||||||
class DwmThumbnail : IDwmThumbnail
|
class DwmThumbnail : IDwmThumbnail
|
||||||
{
|
{
|
||||||
16
Eve-O-Preview/Services/Implementation/ProcessInfo.cs
Normal file
16
Eve-O-Preview/Services/Implementation/ProcessInfo.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace EveOPreview.Services.Implementation
|
||||||
|
{
|
||||||
|
sealed class ProcessInfo : IProcessInfo
|
||||||
|
{
|
||||||
|
public ProcessInfo(IntPtr handle, string title)
|
||||||
|
{
|
||||||
|
this.Handle = handle;
|
||||||
|
this.Title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr Handle { get; }
|
||||||
|
public string Title { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
93
Eve-O-Preview/Services/Implementation/ProcessMonitor.cs
Normal file
93
Eve-O-Preview/Services/Implementation/ProcessMonitor.cs
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace EveOPreview.Services.Implementation
|
||||||
|
{
|
||||||
|
sealed class ProcessMonitor : IProcessMonitor
|
||||||
|
{
|
||||||
|
#region Private constants
|
||||||
|
private const string DefaultProcessName = "ExeFile";
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private fields
|
||||||
|
private readonly IDictionary<IntPtr, string> _processCache;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public ProcessMonitor()
|
||||||
|
{
|
||||||
|
this._processCache = new Dictionary<IntPtr, string>(512);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsMonitoredProcess(string processName)
|
||||||
|
{
|
||||||
|
// This is a possible extension point
|
||||||
|
return String.Equals(processName, ProcessMonitor.DefaultProcessName, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetUpdatedProcesses(out ICollection<IProcessInfo> addedProcesses, out ICollection<IProcessInfo> updatedProcesses, out ICollection<IProcessInfo> removedProcesses)
|
||||||
|
{
|
||||||
|
addedProcesses = new List<IProcessInfo>(16);
|
||||||
|
updatedProcesses = new List<IProcessInfo>(16);
|
||||||
|
removedProcesses = new List<IProcessInfo>(16);
|
||||||
|
|
||||||
|
IList<IntPtr> knownProcesses = new List<IntPtr>(this._processCache.Keys);
|
||||||
|
foreach (Process process in Process.GetProcesses())
|
||||||
|
{
|
||||||
|
string processName = process.ProcessName;
|
||||||
|
|
||||||
|
if (!this.IsMonitoredProcess(processName))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
IntPtr mainWindowHandle = process.MainWindowHandle;
|
||||||
|
if (mainWindowHandle == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
continue; // No need to monitor non-visual processes
|
||||||
|
}
|
||||||
|
|
||||||
|
string mainWindowTitle = process.MainWindowTitle;
|
||||||
|
this._processCache.TryGetValue(mainWindowHandle, out string cachedTitle);
|
||||||
|
|
||||||
|
if (cachedTitle == null)
|
||||||
|
{
|
||||||
|
// This is a new process in the list
|
||||||
|
this._processCache.Add(mainWindowHandle, mainWindowTitle);
|
||||||
|
addedProcesses.Add(new ProcessInfo(mainWindowHandle, mainWindowTitle));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// This is an already known process
|
||||||
|
if (cachedTitle != mainWindowTitle)
|
||||||
|
{
|
||||||
|
this._processCache[mainWindowHandle] = mainWindowTitle;
|
||||||
|
updatedProcesses.Add((IProcessInfo)new ProcessInfo(mainWindowHandle, mainWindowTitle));
|
||||||
|
}
|
||||||
|
|
||||||
|
knownProcesses.Remove(mainWindowHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (IntPtr index in knownProcesses)
|
||||||
|
{
|
||||||
|
string title = this._processCache[index];
|
||||||
|
removedProcesses.Add(new ProcessInfo(index, title));
|
||||||
|
this._processCache.Remove(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICollection<IProcessInfo> GetAllProcesses()
|
||||||
|
{
|
||||||
|
ICollection<IProcessInfo> result = new List<IProcessInfo>(this._processCache.Count);
|
||||||
|
|
||||||
|
// TODO Lock list here just in case
|
||||||
|
foreach (KeyValuePair<IntPtr, string> entry in this._processCache)
|
||||||
|
{
|
||||||
|
result.Add(new ProcessInfo(entry.Key, entry.Value));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,25 +1,28 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using EveOPreview.Configuration;
|
using EveOPreview.Configuration;
|
||||||
|
using EveOPreview.Mediator.Messages;
|
||||||
|
using EveOPreview.View;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.Services
|
||||||
{
|
{
|
||||||
public class ThumbnailManager : IThumbnailManager
|
class ThumbnailManager : IThumbnailManager
|
||||||
{
|
{
|
||||||
#region Private constants
|
#region Private constants
|
||||||
private const int WindowPositionThreshold = -5000;
|
private const int WindowPositionThreshold = -5000;
|
||||||
private const int WindowSizeThreshold = -5000;
|
private const int WindowSizeThreshold = -5000;
|
||||||
|
|
||||||
private const string ClientProcessName = "ExeFile";
|
|
||||||
private const string DefaultClientTitle = "EVE";
|
private const string DefaultClientTitle = "EVE";
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private fields
|
#region Private fields
|
||||||
|
private readonly IMediator _mediator;
|
||||||
|
private readonly IProcessMonitor _processMonitor;
|
||||||
private readonly IWindowManager _windowManager;
|
private readonly IWindowManager _windowManager;
|
||||||
private readonly IThumbnailConfig _configuration;
|
private readonly IThumbnailConfiguration _configuration;
|
||||||
private readonly DispatcherTimer _thumbnailUpdateTimer;
|
private readonly DispatcherTimer _thumbnailUpdateTimer;
|
||||||
private readonly IThumbnailViewFactory _thumbnailViewFactory;
|
private readonly IThumbnailViewFactory _thumbnailViewFactory;
|
||||||
private readonly Dictionary<IntPtr, IThumbnailView> _thumbnailViews;
|
private readonly Dictionary<IntPtr, IThumbnailView> _thumbnailViews;
|
||||||
@@ -31,8 +34,10 @@ namespace EveOPreview.UI
|
|||||||
private bool _isHoverEffectActive;
|
private bool _isHoverEffectActive;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public ThumbnailManager(IWindowManager windowManager, IThumbnailConfig configuration, IThumbnailViewFactory factory)
|
public ThumbnailManager(IMediator mediator, IThumbnailConfiguration configuration, IProcessMonitor processMonitor, IWindowManager windowManager, IThumbnailViewFactory factory)
|
||||||
{
|
{
|
||||||
|
this._mediator = mediator;
|
||||||
|
this._processMonitor = processMonitor;
|
||||||
this._windowManager = windowManager;
|
this._windowManager = windowManager;
|
||||||
this._configuration = configuration;
|
this._configuration = configuration;
|
||||||
this._thumbnailViewFactory = factory;
|
this._thumbnailViewFactory = factory;
|
||||||
@@ -51,32 +56,21 @@ namespace EveOPreview.UI
|
|||||||
this._thumbnailUpdateTimer.Interval = new TimeSpan(0, 0, 0, 0, configuration.ThumbnailRefreshPeriod);
|
this._thumbnailUpdateTimer.Interval = new TimeSpan(0, 0, 0, 0, configuration.ThumbnailRefreshPeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action<IList<IThumbnailView>> ThumbnailsAdded { get; set; }
|
public void Start()
|
||||||
|
|
||||||
public Action<IList<IThumbnailView>> ThumbnailsUpdated { get; set; }
|
|
||||||
|
|
||||||
public Action<IList<IThumbnailView>> ThumbnailsRemoved { get; set; }
|
|
||||||
|
|
||||||
public Action<String, String, Point> ThumbnailPositionChanged { get; set; }
|
|
||||||
|
|
||||||
public Action<Size> ThumbnailSizeChanged { get; set; }
|
|
||||||
|
|
||||||
public void Activate()
|
|
||||||
{
|
{
|
||||||
this._thumbnailUpdateTimer.Start();
|
this._thumbnailUpdateTimer.Start();
|
||||||
|
|
||||||
this.RefreshThumbnails();
|
this.RefreshThumbnails();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deactivate()
|
public void Stop()
|
||||||
{
|
{
|
||||||
this._thumbnailUpdateTimer.Stop();
|
this._thumbnailUpdateTimer.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetThumbnailState(IntPtr thumbnailId, bool hideAlways)
|
public void SetThumbnailState(IntPtr thumbnailId, bool hideAlways)
|
||||||
{
|
{
|
||||||
IThumbnailView thumbnail;
|
if (!this._thumbnailViews.TryGetValue(thumbnailId, out IThumbnailView thumbnail))
|
||||||
if (!this._thumbnailViews.TryGetValue(thumbnailId, out thumbnail))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -84,7 +78,7 @@ namespace EveOPreview.UI
|
|||||||
thumbnail.IsEnabled = !hideAlways;
|
thumbnail.IsEnabled = !hideAlways;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetThumbnailsSize(Size size)
|
public async void SetThumbnailsSize(Size size)
|
||||||
{
|
{
|
||||||
this.DisableViewEvents();
|
this.DisableViewEvents();
|
||||||
|
|
||||||
@@ -94,7 +88,7 @@ namespace EveOPreview.UI
|
|||||||
entry.Value.Refresh(false);
|
entry.Value.Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ThumbnailSizeChanged?.Invoke(size);
|
await this._mediator.Publish(new ThumbnailSizeUpdated(size));
|
||||||
|
|
||||||
this.EnableViewEvents();
|
this.EnableViewEvents();
|
||||||
}
|
}
|
||||||
@@ -188,34 +182,18 @@ namespace EveOPreview.UI
|
|||||||
this._ignoreViewEvents = true;
|
this._ignoreViewEvents = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Process[] GetClientProcesses()
|
private async void UpdateThumbnailsList()
|
||||||
{
|
{
|
||||||
return Process.GetProcessesByName(ThumbnailManager.ClientProcessName);
|
this._processMonitor.GetUpdatedProcesses(out ICollection<IProcessInfo> addedProcesses, out ICollection<IProcessInfo> updatedProcesses, out ICollection<IProcessInfo> removedProcesses);
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateThumbnailsList()
|
|
||||||
{
|
|
||||||
Process[] clientProcesses = ThumbnailManager.GetClientProcesses();
|
|
||||||
List<IntPtr> processHandles = new List<IntPtr>(clientProcesses.Length);
|
|
||||||
|
|
||||||
IntPtr foregroundWindowHandle = this._windowManager.GetForegroundWindowHandle();
|
IntPtr foregroundWindowHandle = this._windowManager.GetForegroundWindowHandle();
|
||||||
|
|
||||||
List<IThumbnailView> viewsAdded = new List<IThumbnailView>();
|
List<string> viewsAdded = new List<string>();
|
||||||
List<IThumbnailView> viewsUpdated = new List<IThumbnailView>();
|
List<string> viewsRemoved = new List<string>();
|
||||||
List<IThumbnailView> viewsRemoved = new List<IThumbnailView>();
|
|
||||||
|
|
||||||
foreach (Process process in clientProcesses)
|
foreach (IProcessInfo process in addedProcesses)
|
||||||
{
|
{
|
||||||
IntPtr processHandle = process.MainWindowHandle;
|
IThumbnailView view = this._thumbnailViewFactory.Create(process.Handle, process.Title, this._configuration.ThumbnailSize);
|
||||||
string processTitle = process.MainWindowTitle;
|
|
||||||
processHandles.Add(processHandle);
|
|
||||||
|
|
||||||
IThumbnailView view;
|
|
||||||
this._thumbnailViews.TryGetValue(processHandle, out view);
|
|
||||||
|
|
||||||
if ((view == null) && (processTitle != ""))
|
|
||||||
{
|
|
||||||
view = this._thumbnailViewFactory.Create(processHandle, processTitle, this._configuration.ThumbnailSize);
|
|
||||||
view.IsEnabled = true;
|
view.IsEnabled = true;
|
||||||
view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays;
|
view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays;
|
||||||
view.SetFrames(this._configuration.ShowThumbnailFrames);
|
view.SetFrames(this._configuration.ShowThumbnailFrames);
|
||||||
@@ -225,10 +203,10 @@ namespace EveOPreview.UI
|
|||||||
view.SetTopMost(this._configuration.ShowThumbnailsAlwaysOnTop);
|
view.SetTopMost(this._configuration.ShowThumbnailsAlwaysOnTop);
|
||||||
|
|
||||||
view.ThumbnailLocation = this.IsManageableThumbnail(view)
|
view.ThumbnailLocation = this.IsManageableThumbnail(view)
|
||||||
? this._configuration.GetThumbnailLocation(processTitle, this._activeClientTitle, view.ThumbnailLocation)
|
? this._configuration.GetThumbnailLocation(view.Title, this._activeClientTitle, view.ThumbnailLocation)
|
||||||
: this._configuration.GetDefaultThumbnailLocation();
|
: this._configuration.GetDefaultThumbnailLocation();
|
||||||
|
|
||||||
this._thumbnailViews.Add(processHandle, view);
|
this._thumbnailViews.Add(view.Id, view);
|
||||||
|
|
||||||
view.ThumbnailResized = this.ThumbnailViewResized;
|
view.ThumbnailResized = this.ThumbnailViewResized;
|
||||||
view.ThumbnailMoved = this.ThumbnailViewMoved;
|
view.ThumbnailMoved = this.ThumbnailViewMoved;
|
||||||
@@ -237,45 +215,60 @@ namespace EveOPreview.UI
|
|||||||
view.ThumbnailActivated = this.ThumbnailActivated;
|
view.ThumbnailActivated = this.ThumbnailActivated;
|
||||||
view.ThumbnailDeactivated = this.ThumbnailDeactivated;
|
view.ThumbnailDeactivated = this.ThumbnailDeactivated;
|
||||||
|
|
||||||
view.RegisterHotkey(this._configuration.GetClientHotkey(processTitle));
|
view.RegisterHotkey(this._configuration.GetClientHotkey(view.Title));
|
||||||
|
|
||||||
this.ApplyClientLayout(processHandle, processTitle);
|
this.ApplyClientLayout(view.Id, view.Title);
|
||||||
|
|
||||||
viewsAdded.Add(view);
|
// TODO Add extension filter here later
|
||||||
}
|
if (view.Title != ThumbnailManager.DefaultClientTitle)
|
||||||
else if ((view != null) && (processTitle != view.Title)) // update thumbnail title
|
|
||||||
{
|
{
|
||||||
view.Title = processTitle;
|
viewsAdded.Add(view.Title);
|
||||||
view.RegisterHotkey(this._configuration.GetClientHotkey(processTitle));
|
|
||||||
|
|
||||||
this.ApplyClientLayout(processHandle, processTitle);
|
|
||||||
|
|
||||||
viewsUpdated.Add(view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.MainWindowHandle == foregroundWindowHandle)
|
if (process.Handle == foregroundWindowHandle)
|
||||||
{
|
{
|
||||||
this._activeClientHandle = process.MainWindowHandle;
|
this._activeClientHandle = view.Id;
|
||||||
this._activeClientTitle = process.MainWindowTitle;
|
this._activeClientTitle = view.Title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
foreach (IProcessInfo process in updatedProcesses)
|
||||||
IList<IntPtr> obsoleteThumbnails = new List<IntPtr>();
|
|
||||||
|
|
||||||
foreach (IntPtr processHandle in this._thumbnailViews.Keys)
|
|
||||||
{
|
{
|
||||||
if (!processHandles.Contains(processHandle))
|
this._thumbnailViews.TryGetValue(process.Handle, out IThumbnailView view);
|
||||||
|
|
||||||
|
if (view == null)
|
||||||
{
|
{
|
||||||
obsoleteThumbnails.Add(processHandle);
|
// Something went terribly wrong
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.Title != view.Title) // update thumbnail title
|
||||||
|
{
|
||||||
|
viewsRemoved.Add(view.Title);
|
||||||
|
view.Title = process.Title;
|
||||||
|
viewsAdded.Add(view.Title);
|
||||||
|
|
||||||
|
view.RegisterHotkey(this._configuration.GetClientHotkey(process.Title));
|
||||||
|
|
||||||
|
this.ApplyClientLayout(view.Id, view.Title);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.Handle == foregroundWindowHandle)
|
||||||
|
{
|
||||||
|
this._activeClientHandle = process.Handle;
|
||||||
|
this._activeClientTitle = process.Title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (IntPtr processHandle in obsoleteThumbnails)
|
foreach (IProcessInfo process in removedProcesses)
|
||||||
{
|
{
|
||||||
IThumbnailView view = this._thumbnailViews[processHandle];
|
IThumbnailView view = this._thumbnailViews[process.Handle];
|
||||||
|
|
||||||
this._thumbnailViews.Remove(processHandle);
|
this._thumbnailViews.Remove(view.Id);
|
||||||
|
if (view.Title != ThumbnailManager.DefaultClientTitle)
|
||||||
|
{
|
||||||
|
viewsRemoved.Add(view.Title);
|
||||||
|
}
|
||||||
|
|
||||||
view.UnregisterHotkey();
|
view.UnregisterHotkey();
|
||||||
|
|
||||||
@@ -286,13 +279,12 @@ namespace EveOPreview.UI
|
|||||||
view.ThumbnailActivated = null;
|
view.ThumbnailActivated = null;
|
||||||
|
|
||||||
view.Close();
|
view.Close();
|
||||||
|
|
||||||
viewsRemoved.Add(view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ThumbnailsAdded?.Invoke(viewsAdded);
|
if ((viewsAdded.Count > 0) || (viewsRemoved.Count > 0))
|
||||||
this.ThumbnailsUpdated?.Invoke(viewsUpdated);
|
{
|
||||||
this.ThumbnailsRemoved?.Invoke(viewsRemoved);
|
await this._mediator.Publish(new ThumbnailListUpdated(viewsAdded, viewsRemoved));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThumbnailViewFocused(IntPtr id)
|
private void ThumbnailViewFocused(IntPtr id)
|
||||||
@@ -380,7 +372,7 @@ namespace EveOPreview.UI
|
|||||||
view.Refresh(false);
|
view.Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThumbnailViewMoved(IntPtr id)
|
private async void ThumbnailViewMoved(IntPtr id)
|
||||||
{
|
{
|
||||||
if (this._ignoreViewEvents)
|
if (this._ignoreViewEvents)
|
||||||
{
|
{
|
||||||
@@ -391,7 +383,7 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
if (this.IsManageableThumbnail(view))
|
if (this.IsManageableThumbnail(view))
|
||||||
{
|
{
|
||||||
this.ThumbnailPositionChanged?.Invoke(view.Title, this._activeClientTitle, view.ThumbnailLocation);
|
await this._mediator.Publish(new ThumbnailLocationUpdated(view.Title, this._activeClientTitle, view.ThumbnailLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
view.Refresh(false);
|
view.Refresh(false);
|
||||||
@@ -452,11 +444,11 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
private void UpdateClientLayouts()
|
private void UpdateClientLayouts()
|
||||||
{
|
{
|
||||||
Process[] clientProcesses = ThumbnailManager.GetClientProcesses();
|
ICollection<IProcessInfo> processes = this._processMonitor.GetAllProcesses();
|
||||||
|
|
||||||
foreach (Process process in clientProcesses)
|
foreach (IProcessInfo process in processes)
|
||||||
{
|
{
|
||||||
this._windowManager.GetWindowCoordinates(process.MainWindowHandle, out int left, out int top, out int right, out int bottom);
|
this._windowManager.GetWindowCoordinates(process.Handle, out int left, out int top, out int right, out int bottom);
|
||||||
|
|
||||||
int width = Math.Abs(right - left);
|
int width = Math.Abs(right - left);
|
||||||
int height = Math.Abs(bottom - top);
|
int height = Math.Abs(bottom - top);
|
||||||
@@ -466,7 +458,7 @@ namespace EveOPreview.UI
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._configuration.SetClientLayout(process.MainWindowTitle, new ClientLayout(left, top, width, height));
|
this._configuration.SetClientLayout(process.Title, new ClientLayout(left, top, width, height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using EveOPreview.DwmInterop;
|
using EveOPreview.Services.Interop;
|
||||||
|
|
||||||
namespace EveOPreview.DwmAPI
|
namespace EveOPreview.Services.Implementation
|
||||||
{
|
{
|
||||||
class WindowManager : IWindowManager
|
class WindowManager : IWindowManager
|
||||||
{
|
{
|
||||||
@@ -48,5 +48,18 @@ namespace EveOPreview.DwmAPI
|
|||||||
right = windowRectangle.Right;
|
right = windowRectangle.Right;
|
||||||
bottom = windowRectangle.Bottom;
|
bottom = windowRectangle.Bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsWindowMinimized(IntPtr handle)
|
||||||
|
{
|
||||||
|
return User32NativeMethods.IsIconic(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDwmThumbnail RegisterThumbnail(IntPtr destination, IntPtr source)
|
||||||
|
{
|
||||||
|
IDwmThumbnail thumbnail = new DwmThumbnail(this);
|
||||||
|
thumbnail.Register(destination, source);
|
||||||
|
|
||||||
|
return thumbnail;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace EveOPreview
|
namespace EveOPreview.Services
|
||||||
{
|
{
|
||||||
public interface IDwmThumbnail
|
public interface IDwmThumbnail
|
||||||
{
|
{
|
||||||
10
Eve-O-Preview/Services/Interface/IProcessInfo.cs
Normal file
10
Eve-O-Preview/Services/Interface/IProcessInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace EveOPreview.Services
|
||||||
|
{
|
||||||
|
public interface IProcessInfo
|
||||||
|
{
|
||||||
|
IntPtr Handle { get; }
|
||||||
|
string Title { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
10
Eve-O-Preview/Services/Interface/IProcessMonitor.cs
Normal file
10
Eve-O-Preview/Services/Interface/IProcessMonitor.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace EveOPreview.Services
|
||||||
|
{
|
||||||
|
public interface IProcessMonitor
|
||||||
|
{
|
||||||
|
ICollection<IProcessInfo> GetAllProcesses();
|
||||||
|
void GetUpdatedProcesses(out ICollection<IProcessInfo> addedProcesses, out ICollection<IProcessInfo> updatedProcesses, out ICollection<IProcessInfo> removedProcesses);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
Eve-O-Preview/Services/Interface/IThumbnailManager.cs
Normal file
15
Eve-O-Preview/Services/Interface/IThumbnailManager.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace EveOPreview.Services
|
||||||
|
{
|
||||||
|
public interface IThumbnailManager
|
||||||
|
{
|
||||||
|
void Start();
|
||||||
|
void Stop();
|
||||||
|
|
||||||
|
void SetThumbnailState(IntPtr thumbnailId, bool hideAlways);
|
||||||
|
void SetThumbnailsSize(Size size);
|
||||||
|
void SetupThumbnailFrames();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace EveOPreview
|
namespace EveOPreview.Services
|
||||||
{
|
{
|
||||||
public interface IWindowManager
|
public interface IWindowManager
|
||||||
{
|
{
|
||||||
@@ -13,5 +13,8 @@ namespace EveOPreview
|
|||||||
|
|
||||||
void MoveWindow(IntPtr handle, int left, int top, int width, int height);
|
void MoveWindow(IntPtr handle, int left, int top, int width, int height);
|
||||||
void GetWindowCoordinates(IntPtr handle, out int left, out int top, out int right, out int bottom);
|
void GetWindowCoordinates(IntPtr handle, out int left, out int top, out int right, out int bottom);
|
||||||
|
bool IsWindowMinimized(IntPtr handle);
|
||||||
|
|
||||||
|
IDwmThumbnail RegisterThumbnail(IntPtr destination, IntPtr source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace EveOPreview
|
namespace EveOPreview.Services
|
||||||
{
|
{
|
||||||
public static class InteropConstants
|
public static class InteropConstants
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace EveOPreview.DwmInterop
|
namespace EveOPreview.Services.Interop
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
class DWM_BLURBEHIND
|
class DWM_BLURBEHIND
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace EveOPreview.DwmInterop
|
namespace EveOPreview.Services.Interop
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
class DWM_THUMBNAIL_PROPERTIES
|
class DWM_THUMBNAIL_PROPERTIES
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace EveOPreview.DwmInterop
|
namespace EveOPreview.Services.Interop
|
||||||
{
|
{
|
||||||
static class DWM_TNP_CONSTANTS
|
static class DWM_TNP_CONSTANTS
|
||||||
{
|
{
|
||||||
@@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace EveOPreview.DwmInterop
|
namespace EveOPreview.Services.Interop
|
||||||
{
|
{
|
||||||
static class DwmApiNativeMethods
|
static class DwmApiNativeMethods
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace EveOPreview.DwmInterop
|
namespace EveOPreview.Services.Interop
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
class MARGINS
|
class MARGINS
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace EveOPreview.DwmInterop
|
namespace EveOPreview.Services.Interop
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
struct RECT
|
struct RECT
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace EveOPreview.DwmInterop
|
namespace EveOPreview.Services.Interop
|
||||||
{
|
{
|
||||||
static class User32NativeMethods
|
static class User32NativeMethods
|
||||||
{
|
{
|
||||||
@@ -28,5 +28,12 @@ namespace EveOPreview.DwmInterop
|
|||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
|
public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool IsIconic(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern bool IsZoomed(IntPtr hWnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
|
||||||
{
|
|
||||||
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,11 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
|
||||||
{
|
|
||||||
public interface IThumbnailDescriptionView : IView
|
|
||||||
{
|
|
||||||
IntPtr Id { get; set; }
|
|
||||||
string Title { get; set; }
|
|
||||||
bool IsDisabled { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
|
||||||
{
|
|
||||||
public interface IThumbnailDescriptionViewFactory
|
|
||||||
{
|
|
||||||
IThumbnailDescriptionView Create(IntPtr id, string title, bool isDisabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
partial class MainForm
|
partial class MainForm
|
||||||
{
|
{
|
||||||
@@ -3,9 +3,9 @@ using System.Collections.Generic;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form, IMainView
|
public partial class MainForm : Form, IMainFormView
|
||||||
{
|
{
|
||||||
#region Private fields
|
#region Private fields
|
||||||
private readonly ApplicationContext _context;
|
private readonly ApplicationContext _context;
|
||||||
@@ -205,16 +205,11 @@ namespace EveOPreview.UI
|
|||||||
this.DocumentationLink.Text = url;
|
this.DocumentationLink.Text = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddThumbnails(IList<IThumbnailDescriptionView> thumbnails)
|
public void AddThumbnails(IList<IThumbnailDescription> thumbnails)
|
||||||
{
|
{
|
||||||
if (thumbnails.Count == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ThumbnailsList.BeginUpdate();
|
this.ThumbnailsList.BeginUpdate();
|
||||||
|
|
||||||
foreach (IThumbnailDescriptionView view in thumbnails)
|
foreach (IThumbnailDescription view in thumbnails)
|
||||||
{
|
{
|
||||||
this.ThumbnailsList.Items.Add(view);
|
this.ThumbnailsList.Items.Add(view);
|
||||||
}
|
}
|
||||||
@@ -222,25 +217,11 @@ namespace EveOPreview.UI
|
|||||||
this.ThumbnailsList.EndUpdate();
|
this.ThumbnailsList.EndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateThumbnails(IList<IThumbnailDescriptionView> thumbnails)
|
public void RemoveThumbnails(IList<IThumbnailDescription> thumbnails)
|
||||||
{
|
{
|
||||||
// Just trigger redraw
|
|
||||||
if (thumbnails.Count > 0)
|
|
||||||
{
|
|
||||||
this.ThumbnailsList.Invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveThumbnails(IList<IThumbnailDescriptionView> thumbnails)
|
|
||||||
{
|
|
||||||
if (thumbnails.Count == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ThumbnailsList.BeginUpdate();
|
this.ThumbnailsList.BeginUpdate();
|
||||||
|
|
||||||
foreach (IThumbnailDescriptionView view in thumbnails)
|
foreach (IThumbnailDescription view in thumbnails)
|
||||||
{
|
{
|
||||||
this.ThumbnailsList.Items.Remove(view);
|
this.ThumbnailsList.Items.Remove(view);
|
||||||
}
|
}
|
||||||
@@ -267,7 +248,7 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
public Action ThumbnailsSizeChanged { get; set; }
|
public Action ThumbnailsSizeChanged { get; set; }
|
||||||
|
|
||||||
public Action<IntPtr> ThumbnailStateChanged { get; set; }
|
public Action<string> ThumbnailStateChanged { get; set; }
|
||||||
|
|
||||||
public Action DocumentationLinkActivated { get; set; }
|
public Action DocumentationLinkActivated { get; set; }
|
||||||
|
|
||||||
@@ -344,14 +325,14 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
private void ThumbnailsList_ItemCheck_Handler(object sender, ItemCheckEventArgs e)
|
private void ThumbnailsList_ItemCheck_Handler(object sender, ItemCheckEventArgs e)
|
||||||
{
|
{
|
||||||
IThumbnailDescriptionView selectedItem = this.ThumbnailsList.Items[e.Index] as IThumbnailDescriptionView;
|
if (!(this.ThumbnailsList.Items[e.Index] is IThumbnailDescription selectedItem))
|
||||||
if (selectedItem == null)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedItem.IsDisabled = (e.NewValue == CheckState.Checked);
|
selectedItem.IsDisabled = (e.NewValue == CheckState.Checked);
|
||||||
|
|
||||||
this.ThumbnailStateChanged?.Invoke(selectedItem.Id);
|
this.ThumbnailStateChanged?.Invoke(selectedItem.Title);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DocumentationLinkClicked_Handler(object sender, LinkLabelLinkClickedEventArgs e)
|
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 : IThumbnailDescription
|
||||||
|
{
|
||||||
|
public ThumbnailDescription(string title, bool isDisabled)
|
||||||
|
{
|
||||||
|
this.Title = title;
|
||||||
|
this.IsDisabled = isDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Title { get; set; }
|
||||||
|
public bool IsDisabled { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
partial class ThumbnailOverlay
|
partial class ThumbnailOverlay
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using EveOPreview.Services;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
public partial class ThumbnailOverlay : Form
|
public partial class ThumbnailOverlay : Form
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
partial class ThumbnailView
|
partial class ThumbnailView
|
||||||
{
|
{
|
||||||
@@ -2,9 +2,10 @@ using System;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using EveOPreview.DwmAPI;
|
using EveOPreview.Services;
|
||||||
|
using EveOPreview.UI.Hotkeys;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
public partial class ThumbnailView : Form, IThumbnailView
|
public partial class ThumbnailView : Form, IThumbnailView
|
||||||
{
|
{
|
||||||
@@ -475,8 +476,7 @@ namespace EveOPreview.UI
|
|||||||
#region Thumbnail management
|
#region Thumbnail management
|
||||||
private void RegisterThumbnail()
|
private void RegisterThumbnail()
|
||||||
{
|
{
|
||||||
this._thumbnail = new DwmThumbnail(this._windowManager);
|
this._thumbnail = this._windowManager.RegisterThumbnail(this.Handle, this.Id);
|
||||||
this._thumbnail.Register(this.Handle, this.Id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateThumbnail()
|
private void UpdateThumbnail()
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
public class ThumbnailViewFactory : IThumbnailViewFactory
|
sealed class ThumbnailViewFactory : IThumbnailViewFactory
|
||||||
{
|
{
|
||||||
private readonly IApplicationController _controller;
|
private readonly IApplicationController _controller;
|
||||||
|
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using EveOPreview.UI;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Main view interface
|
/// Main view interface
|
||||||
/// Presenter uses it to access GUI properties
|
/// Presenter uses it to access GUI properties
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMainView : IView
|
public interface IMainFormView : IView
|
||||||
{
|
{
|
||||||
bool MinimizeToTray { get; set; }
|
bool MinimizeToTray { get; set; }
|
||||||
|
|
||||||
@@ -38,9 +39,8 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
void Minimize();
|
void Minimize();
|
||||||
|
|
||||||
void AddThumbnails(IList<IThumbnailDescriptionView> thumbnails);
|
void AddThumbnails(IList<IThumbnailDescription> thumbnails);
|
||||||
void UpdateThumbnails(IList<IThumbnailDescriptionView> thumbnails);
|
void RemoveThumbnails(IList<IThumbnailDescription> thumbnails);
|
||||||
void RemoveThumbnails(IList<IThumbnailDescriptionView> thumbnails);
|
|
||||||
void RefreshZoomSettings();
|
void RefreshZoomSettings();
|
||||||
|
|
||||||
Action ApplicationExitRequested { get; set; }
|
Action ApplicationExitRequested { get; set; }
|
||||||
@@ -49,7 +49,7 @@ namespace EveOPreview.UI
|
|||||||
Action<ViewCloseRequest> FormCloseRequested { get; set; }
|
Action<ViewCloseRequest> FormCloseRequested { get; set; }
|
||||||
Action ApplicationSettingsChanged { get; set; }
|
Action ApplicationSettingsChanged { get; set; }
|
||||||
Action ThumbnailsSizeChanged { get; set; }
|
Action ThumbnailsSizeChanged { get; set; }
|
||||||
Action<IntPtr> ThumbnailStateChanged { get; set; }
|
Action<string> ThumbnailStateChanged { get; set; }
|
||||||
Action DocumentationLinkActivated { get; set; }
|
Action DocumentationLinkActivated { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
8
Eve-O-Preview/View/Interface/IThumbnailDescription.cs
Normal file
8
Eve-O-Preview/View/Interface/IThumbnailDescription.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace EveOPreview.View
|
||||||
|
{
|
||||||
|
public interface IThumbnailDescription
|
||||||
|
{
|
||||||
|
string Title { get; set; }
|
||||||
|
bool IsDisabled { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
public interface IThumbnailView : IView
|
public interface IThumbnailView : IView
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
public interface IThumbnailViewFactory
|
public interface IThumbnailViewFactory
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace EveOPreview.UI
|
namespace EveOPreview.View
|
||||||
{
|
{
|
||||||
public enum ViewZoomAnchor
|
public enum ViewZoomAnchor
|
||||||
{
|
{
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration>
|
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/></startup></configuration>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Costura.Fody" version="1.6.2" targetFramework="net46" developmentDependency="true" />
|
<package id="Costura.Fody" version="1.6.2" targetFramework="net46" developmentDependency="true" />
|
||||||
<package id="Fody" version="2.3.23" targetFramework="net452" developmentDependency="true" />
|
<package id="Fody" version="2.4.1" targetFramework="net46" developmentDependency="true" />
|
||||||
<package id="LightInject" version="5.1.2" targetFramework="net452" />
|
<package id="LightInject" version="5.1.2" targetFramework="net452" requireReinstallation="true" />
|
||||||
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
|
<package id="MediatR" version="4.0.1" targetFramework="net452" />
|
||||||
|
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net46" />
|
||||||
</packages>
|
</packages>
|
||||||
Reference in New Issue
Block a user