diff --git a/.gitignore b/.gitignore index 7b25809..b0ccf7f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ bin/ obj/ *.suo *.user +*.DotSettings \ No newline at end of file diff --git a/Eve-O-Preview/ApplicationBase/ExceptionHandler.cs b/Eve-O-Preview/ApplicationBase/ExceptionHandler.cs index 6489202..461370e 100644 --- a/Eve-O-Preview/ApplicationBase/ExceptionHandler.cs +++ b/Eve-O-Preview/ApplicationBase/ExceptionHandler.cs @@ -17,6 +17,11 @@ namespace EveOPreview public void SetupExceptionHandlers() { + if (System.Diagnostics.Debugger.IsAttached) + { + return; + } + Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += delegate (Object sender, ThreadExceptionEventArgs e) { diff --git a/Eve-O-Preview/ApplicationBase/IIocContainer.cs b/Eve-O-Preview/ApplicationBase/IIocContainer.cs index 273de67..e5b694c 100644 --- a/Eve-O-Preview/ApplicationBase/IIocContainer.cs +++ b/Eve-O-Preview/ApplicationBase/IIocContainer.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.Linq.Expressions; +using System.Reflection; namespace EveOPreview { @@ -8,11 +10,17 @@ namespace EveOPreview /// public interface IIocContainer { - void Register() where TImplementation : TService; + void Register() + where TImplementation : TService; + void Register(Type serviceType, Assembly container); void Register(); - void RegisterInstance(T instance); - TService Resolve(); - bool IsRegistered(); + void Register(Expression> factory); void Register(Expression> factory); + void RegisterInstance(TService instance); + TService Resolve(); + IEnumerable ResolveAll(); + object Resolve(Type serviceType); + IEnumerable ResolveAll(Type serviceType); + bool IsRegistered(); } } \ No newline at end of file diff --git a/Eve-O-Preview/ApplicationBase/LightInjectContainer.cs b/Eve-O-Preview/ApplicationBase/LightInjectContainer.cs index 73567c9..3cceb94 100644 --- a/Eve-O-Preview/ApplicationBase/LightInjectContainer.cs +++ b/Eve-O-Preview/ApplicationBase/LightInjectContainer.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.Linq.Expressions; +using System.Reflection; using LightInject; namespace EveOPreview @@ -19,9 +21,38 @@ namespace EveOPreview 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() { - this._container.Register(); + this.Register(typeof(TService), typeof(TService).Assembly); } public void Register() @@ -30,12 +61,17 @@ namespace EveOPreview this._container.Register(); } + public void Register(Expression> factory) + { + this._container.Register(f => factory); + } + public void Register(Expression> factory) { this._container.Register(f => factory); } - public void RegisterInstance(T instance) + public void RegisterInstance(TService instance) { this._container.RegisterInstance(instance); } @@ -44,5 +80,20 @@ namespace EveOPreview { return this._container.GetInstance(); } + + public IEnumerable ResolveAll() + { + return this._container.GetAllInstances(); + } + + public object Resolve(Type serviceType) + { + return this._container.GetInstance(serviceType); + } + + public IEnumerable ResolveAll(Type serviceType) + { + return this._container.GetAllInstances(serviceType); + } } } \ No newline at end of file diff --git a/Eve-O-Preview/Configuration/ClientLayout.cs b/Eve-O-Preview/Configuration/ClientLayout.cs index b3db46c..02266c4 100644 --- a/Eve-O-Preview/Configuration/ClientLayout.cs +++ b/Eve-O-Preview/Configuration/ClientLayout.cs @@ -2,6 +2,18 @@ namespace EveOPreview.Configuration { public class ClientLayout { + public ClientLayout() + { + } + + public ClientLayout(int x, int y, int width, int height) + { + this.X = x; + this.Y = y; + this.Width = width; + this.Height = height; + } + public int X { get; set; } public int Y { get; set; } diff --git a/Eve-O-Preview/Configuration/ConfigurationStorage.cs b/Eve-O-Preview/Configuration/ConfigurationStorage.cs index e378dbf..1593c04 100644 --- a/Eve-O-Preview/Configuration/ConfigurationStorage.cs +++ b/Eve-O-Preview/Configuration/ConfigurationStorage.cs @@ -9,12 +9,12 @@ namespace EveOPreview.Configuration private const string ConfigurationFileName = "EVE-O Preview.json"; 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._thumbnailConfig = thumbnailConfig; + this._thumbnailConfiguration = thumbnailConfiguration; } public void Load() @@ -28,16 +28,20 @@ namespace EveOPreview.Configuration string rawData = File.ReadAllText(filename); - JsonConvert.PopulateObject(rawData, this._thumbnailConfig); + JsonConvert.PopulateObject(rawData, this._thumbnailConfiguration); // Validate data after loading it - this._thumbnailConfig.ApplyRestrictions(); + this._thumbnailConfiguration.ApplyRestrictions(); } public void Save() { +<<<<<<< HEAD string rawData = JsonConvert.SerializeObject(this._thumbnailConfig, Formatting.Indented); string filename = this.GetConfigFileName(); +======= + string rawData = JsonConvert.SerializeObject(this._thumbnailConfiguration, Formatting.Indented); +>>>>>>> develop try { diff --git a/Eve-O-Preview/Configuration/ThumbnailConfig.cs b/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs similarity index 65% rename from Eve-O-Preview/Configuration/ThumbnailConfig.cs rename to Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs index 24c71f2..b22c926 100644 --- a/Eve-O-Preview/Configuration/ThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs @@ -3,12 +3,24 @@ using System.Drawing; using System.Windows.Forms; using Newtonsoft.Json; -namespace EveOPreview.Configuration +namespace EveOPreview.Configuration.Omplementation { - class ThumbnailConfig : IThumbnailConfig + sealed class ThumbnailConfiguration : IThumbnailConfiguration { - public ThumbnailConfig() + #region Private fields + private bool _enablePerClientThumbnailLayouts; + private bool _enableClientLayoutTracking; + #endregion + + public ThumbnailConfiguration() { + this.PerClientLayout = new Dictionary>(); + this.FlatLayout = new Dictionary(); + this.ClientLayout = new Dictionary(); + this.ClientHotkey = new Dictionary(); + this.DisableThumbnail = new Dictionary(); + this.PriorityClients = new List(); + this.MinimizeToTray = false; this.ThumbnailRefreshPeriod = 500; @@ -16,29 +28,27 @@ namespace EveOPreview.Configuration this.EnableClientLayoutTracking = false; this.HideActiveClientThumbnail = false; + this.MinimizeInactiveClients = false; this.ShowThumbnailsAlwaysOnTop = true; this.HideThumbnailsOnLostFocus = false; this.EnablePerClientThumbnailLayouts = false; - this.ThumbnailSize = new Size(250, 150); - this.ThumbnailMinimumSize = new Size(100, 80); - this.ThumbnailMaximumSize = new Size(640, 400); + this.ThumbnailSize = new Size(384, 216); + this.ThumbnailMinimumSize = new Size(192, 108); + this.ThumbnailMaximumSize = new Size(960, 540); + + this.EnableThumbnailSnap = true; this.ThumbnailZoomEnabled = false; this.ThumbnailZoomFactor = 2; this.ThumbnailZoomAnchor = ZoomAnchor.NW; this.ShowThumbnailOverlays = true; - this.ShowThumbnailFrames = true; + this.ShowThumbnailFrames = false; this.EnableActiveClientHighlight = false; this.ActiveClientHighlightColor = Color.GreenYellow; this.ActiveClientHighlightThickness = 3; - - this.PerClientLayout = new Dictionary>(); - this.FlatLayout = new Dictionary(); - this.ClientLayout = new Dictionary(); - this.ClientHotkey = new Dictionary(); } public bool MinimizeToTray { get; set; } @@ -47,16 +57,45 @@ namespace EveOPreview.Configuration [JsonProperty("ThumbnailsOpacity")] public double ThumbnailOpacity { get; set; } - public bool EnableClientLayoutTracking { get; set; } + public bool EnableClientLayoutTracking + { + get => this._enableClientLayoutTracking; + set + { + if (!value) + { + this.ClientLayout.Clear(); + } + + this._enableClientLayoutTracking = value; + } + } + public bool HideActiveClientThumbnail { get; set; } + public bool MinimizeInactiveClients { get; set; } public bool ShowThumbnailsAlwaysOnTop { get; set; } public bool HideThumbnailsOnLostFocus { get; set; } - public bool EnablePerClientThumbnailLayouts { get; set; } + + public bool EnablePerClientThumbnailLayouts + { + get => this._enablePerClientThumbnailLayouts; + set + { + if (!value) + { + this.PerClientLayout.Clear(); + } + + this._enablePerClientThumbnailLayouts = value; + } + } public Size ThumbnailSize { get; set; } public Size ThumbnailMaximumSize { get; set; } public Size ThumbnailMinimumSize { get; set; } + public bool EnableThumbnailSnap { get; set; } + [JsonProperty("EnableThumbnailZoom")] public bool ThumbnailZoomEnabled { get; set; } public int ThumbnailZoomFactor { get; set; } @@ -79,6 +118,10 @@ namespace EveOPreview.Configuration private Dictionary ClientLayout { get; set; } [JsonProperty] private Dictionary ClientHotkey { get; set; } + [JsonProperty] + private Dictionary DisableThumbnail { get; set; } + [JsonProperty] + private List PriorityClients { get; set; } public Point GetDefaultThumbnailLocation() { @@ -168,17 +211,32 @@ namespace EveOPreview.Configuration this.ClientHotkey[currentClient] = (new KeysConverter()).ConvertToInvariantString(hotkey); } + public bool IsPriorityClient(string currentClient) + { + return this.PriorityClients.Contains(currentClient); + } + + public bool IsThumbnailDisabled(string currentClient) + { + return this.DisableThumbnail.TryGetValue(currentClient, out bool isDisabled) && isDisabled; + } + + public void ToggleThumbnail(string currentClient, bool isDisabled) + { + this.DisableThumbnail[currentClient] = isDisabled; + } + /// /// Applies restrictions to different parameters of the config /// public void ApplyRestrictions() { - this.ThumbnailRefreshPeriod = ThumbnailConfig.ApplyRestrictions(this.ThumbnailRefreshPeriod, 300, 1000); - this.ThumbnailSize = new Size(ThumbnailConfig.ApplyRestrictions(this.ThumbnailSize.Width, this.ThumbnailMinimumSize.Width, this.ThumbnailMaximumSize.Width), - ThumbnailConfig.ApplyRestrictions(this.ThumbnailSize.Height, this.ThumbnailMinimumSize.Height, this.ThumbnailMaximumSize.Height)); - this.ThumbnailOpacity = ThumbnailConfig.ApplyRestrictions((int)(this.ThumbnailOpacity * 100.00), 20, 100) / 100.00; - this.ThumbnailZoomFactor = ThumbnailConfig.ApplyRestrictions(this.ThumbnailZoomFactor, 2, 10); - this.ActiveClientHighlightThickness = ThumbnailConfig.ApplyRestrictions(this.ActiveClientHighlightThickness, 1, 6); + this.ThumbnailRefreshPeriod = ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailRefreshPeriod, 300, 1000); + this.ThumbnailSize = new Size(ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailSize.Width, this.ThumbnailMinimumSize.Width, this.ThumbnailMaximumSize.Width), + ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailSize.Height, this.ThumbnailMinimumSize.Height, this.ThumbnailMaximumSize.Height)); + this.ThumbnailOpacity = ThumbnailConfiguration.ApplyRestrictions((int)(this.ThumbnailOpacity * 100.00), 20, 100) / 100.00; + this.ThumbnailZoomFactor = ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailZoomFactor, 2, 10); + this.ActiveClientHighlightThickness = ThumbnailConfiguration.ApplyRestrictions(this.ActiveClientHighlightThickness, 1, 6); } private static int ApplyRestrictions(int value, int minimum, int maximum) diff --git a/Eve-O-Preview/Configuration/IThumbnailConfig.cs b/Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs similarity index 80% rename from Eve-O-Preview/Configuration/IThumbnailConfig.cs rename to Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs index f3571d7..565e395 100644 --- a/Eve-O-Preview/Configuration/IThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs @@ -3,10 +3,7 @@ using System.Windows.Forms; namespace EveOPreview.Configuration { - /// - /// Thumbnails Manager configuration - /// - public interface IThumbnailConfig + public interface IThumbnailConfiguration { bool MinimizeToTray { get; set; } int ThumbnailRefreshPeriod { get; set; } @@ -15,6 +12,7 @@ namespace EveOPreview.Configuration bool EnableClientLayoutTracking { get; set; } bool HideActiveClientThumbnail { get; set; } + bool MinimizeInactiveClients { get; set; } bool ShowThumbnailsAlwaysOnTop { get; set; } bool HideThumbnailsOnLostFocus { get; set; } bool EnablePerClientThumbnailLayouts { get; set; } @@ -23,6 +21,8 @@ namespace EveOPreview.Configuration Size ThumbnailMinimumSize { get; set; } Size ThumbnailMaximumSize { get; set; } + bool EnableThumbnailSnap { get; set; } + bool ThumbnailZoomEnabled { get; set; } int ThumbnailZoomFactor { get; set; } ZoomAnchor ThumbnailZoomAnchor { get; set; } @@ -44,6 +44,11 @@ namespace EveOPreview.Configuration Keys GetClientHotkey(string currentClient); void SetClientHotkey(string currentClient, Keys hotkey); + bool IsPriorityClient(string currentClient); + + bool IsThumbnailDisabled(string currentClient); + void ToggleThumbnail(string currentClient, bool isDisabled); + void ApplyRestrictions(); } } \ No newline at end of file diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index a022820..cf8b4be 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -10,7 +10,7 @@ Properties EveOPreview Eve-O Preview - v4.5.2 + v4.7 @@ -79,13 +79,17 @@ ..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll False - - ..\packages\LightInject.5.1.1\lib\net452\LightInject.dll - - - R:\eve-o-preview\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + + ..\packages\LightInject.5.1.2\lib\net452\LightInject.dll True + + ..\packages\MediatR.4.0.1\lib\net45\MediatR.dll + + + + ..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll + @@ -107,53 +111,79 @@ - + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + - - - - + + + - + Form - + MainForm.cs - - - - + + + + Form - + ThumbnailOverlay.cs - + Designer MainForm.cs - + ThumbnailOverlay.cs @@ -161,7 +191,7 @@ Resources.Designer.cs Designer - + Designer ThumbnailView.cs @@ -170,13 +200,13 @@ Resources.resx True - + Form - + ThumbnailView.cs - + @@ -192,17 +222,15 @@ - 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}. - - + - +