From 1e59163ce7d24cdafbe5071195e4b5ab1f8ea443 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Thu, 6 Oct 2016 22:46:18 +0300 Subject: [PATCH 01/20] Fix for possible race condition in ThumbnailManager --- Eve-O-Preview/Presentation/ThumbnailManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Eve-O-Preview/Presentation/ThumbnailManager.cs b/Eve-O-Preview/Presentation/ThumbnailManager.cs index b8533ce..b5d7876 100644 --- a/Eve-O-Preview/Presentation/ThumbnailManager.cs +++ b/Eve-O-Preview/Presentation/ThumbnailManager.cs @@ -215,6 +215,8 @@ namespace EveOPreview.UI view.SetFrames(this._configuration.ShowThumbnailFrames); view.ThumbnailLocation = this._configuration.GetThumbnailLocation(processTitle, this._activeClientTitle, view.ThumbnailLocation); + this._thumbnailViews.Add(processHandle, view); + view.ThumbnailResized = this.ThumbnailViewResized; view.ThumbnailMoved = this.ThumbnailViewMoved; view.ThumbnailFocused = this.ThumbnailViewFocused; @@ -223,8 +225,6 @@ namespace EveOPreview.UI view.RegisterHotkey(this._configuration.GetClientHotkey(processTitle)); - this._thumbnailViews.Add(processHandle, view); - this.ApplyClientLayout(processHandle, processTitle); viewsAdded.Add(view); From 278ab215926f7f22d528067a28ee0e409bf7d728 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Sat, 15 Oct 2016 21:21:48 +0300 Subject: [PATCH 02/20] Allow users to have multiple configuration files --- .../Configuration/ConfigurationStorage.cs | 17 ++++++--- .../{IAppConfig.cs => IThumbnailConfig.cs} | 4 +- .../{AppConfig.cs => ThumbnailConfig.cs} | 19 ++++++---- Eve-O-Preview/Eve-O-Preview.csproj | 4 +- Eve-O-Preview/Presentation/MainPresenter.cs | 4 +- .../Presentation/ThumbnailManager.cs | 4 +- Eve-O-Preview/Program.cs | 38 ++++++++++++++++++- 7 files changed, 69 insertions(+), 21 deletions(-) rename Eve-O-Preview/Configuration/{IAppConfig.cs => IThumbnailConfig.cs} (91%) rename Eve-O-Preview/Configuration/{AppConfig.cs => ThumbnailConfig.cs} (83%) diff --git a/Eve-O-Preview/Configuration/ConfigurationStorage.cs b/Eve-O-Preview/Configuration/ConfigurationStorage.cs index 513b73e..be5b229 100644 --- a/Eve-O-Preview/Configuration/ConfigurationStorage.cs +++ b/Eve-O-Preview/Configuration/ConfigurationStorage.cs @@ -7,21 +7,23 @@ namespace EveOPreview.Configuration { private const string ConfigurationFileName = "EVE-O Preview.json"; - private readonly IAppConfig _configuration; + private readonly IThumbnailConfig _configuration; - public ConfigurationStorage(IAppConfig configuration) + public ConfigurationStorage(IThumbnailConfig configuration) { this._configuration = configuration; } public void Load() { - if (!File.Exists(ConfigurationStorage.ConfigurationFileName)) + string filename = this.GetConfigFileName(); + + if (!File.Exists(filename)) { return; } - string rawData = File.ReadAllText(ConfigurationStorage.ConfigurationFileName); + string rawData = File.ReadAllText(filename); JsonConvert.PopulateObject(rawData, this._configuration); @@ -33,7 +35,12 @@ namespace EveOPreview.Configuration { string rawData = JsonConvert.SerializeObject(this._configuration, Formatting.Indented); - File.WriteAllText(ConfigurationStorage.ConfigurationFileName, rawData); + File.WriteAllText(this.GetConfigFileName(), rawData); + } + + private string GetConfigFileName() + { + return string.IsNullOrEmpty(this._configuration.ConfigFileName) ? ConfigurationStorage.ConfigurationFileName : this._configuration.ConfigFileName; } } } \ No newline at end of file diff --git a/Eve-O-Preview/Configuration/IAppConfig.cs b/Eve-O-Preview/Configuration/IThumbnailConfig.cs similarity index 91% rename from Eve-O-Preview/Configuration/IAppConfig.cs rename to Eve-O-Preview/Configuration/IThumbnailConfig.cs index 5e2cd81..88a75c1 100644 --- a/Eve-O-Preview/Configuration/IAppConfig.cs +++ b/Eve-O-Preview/Configuration/IThumbnailConfig.cs @@ -3,8 +3,10 @@ using System.Windows.Forms; namespace EveOPreview.Configuration { - public interface IAppConfig + public interface IThumbnailConfig { + string ConfigFileName { get; set; } + bool MinimizeToTray { get; set; } int ThumbnailRefreshPeriod { get; set; } diff --git a/Eve-O-Preview/Configuration/AppConfig.cs b/Eve-O-Preview/Configuration/ThumbnailConfig.cs similarity index 83% rename from Eve-O-Preview/Configuration/AppConfig.cs rename to Eve-O-Preview/Configuration/ThumbnailConfig.cs index f78f891..337dd30 100644 --- a/Eve-O-Preview/Configuration/AppConfig.cs +++ b/Eve-O-Preview/Configuration/ThumbnailConfig.cs @@ -5,11 +5,13 @@ using Newtonsoft.Json; namespace EveOPreview.Configuration { - public class AppConfig : IAppConfig + public class ThumbnailConfig : IThumbnailConfig { - public AppConfig() + public ThumbnailConfig() { // Default values + this.ConfigFileName = null; + this.MinimizeToTray = false; this.ThumbnailRefreshPeriod = 500; @@ -41,6 +43,9 @@ namespace EveOPreview.Configuration this.ClientHotkey = new Dictionary(); } + [JsonIgnore] + public string ConfigFileName { get; set; } + public bool MinimizeToTray { get; set; } public int ThumbnailRefreshPeriod { get; set; } @@ -163,11 +168,11 @@ namespace EveOPreview.Configuration /// public void ApplyRestrictions() { - this.ThumbnailRefreshPeriod = AppConfig.ApplyRestrictions(this.ThumbnailRefreshPeriod, 300, 1000); - this.ThumbnailSize = new Size(AppConfig.ApplyRestrictions(this.ThumbnailSize.Width, this.ThumbnailMinimumSize.Width, this.ThumbnailMaximumSize.Width), - AppConfig.ApplyRestrictions(this.ThumbnailSize.Height, this.ThumbnailMinimumSize.Height, this.ThumbnailMaximumSize.Height)); - this.ThumbnailOpacity = AppConfig.ApplyRestrictions((int)(this.ThumbnailOpacity * 100.00), 20, 100) / 100.00; - this.ThumbnailZoomFactor = AppConfig.ApplyRestrictions(this.ThumbnailZoomFactor, 2, 10); + 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); } private static int ApplyRestrictions(int value, int minimum, int maximum) diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index ca46da0..84b350d 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -97,7 +97,7 @@ - + @@ -118,7 +118,7 @@ - + diff --git a/Eve-O-Preview/Presentation/MainPresenter.cs b/Eve-O-Preview/Presentation/MainPresenter.cs index 12dad20..71b9d68 100644 --- a/Eve-O-Preview/Presentation/MainPresenter.cs +++ b/Eve-O-Preview/Presentation/MainPresenter.cs @@ -13,7 +13,7 @@ namespace EveOPreview.UI #endregion #region Private fields - private readonly IAppConfig _configuration; + private readonly IThumbnailConfig _configuration; private readonly IConfigurationStorage _configurationStorage; private readonly IThumbnailDescriptionViewFactory _thumbnailDescriptionViewFactory; private readonly IDictionary _thumbnailDescriptionViews; @@ -22,7 +22,7 @@ namespace EveOPreview.UI private bool _exitApplication; #endregion - public MainPresenter(IApplicationController controller, IMainView view, IAppConfig configuration, IConfigurationStorage configurationStorage, + public MainPresenter(IApplicationController controller, IMainView view, IThumbnailConfig configuration, IConfigurationStorage configurationStorage, IThumbnailManager thumbnailManager, IThumbnailDescriptionViewFactory thumbnailDescriptionViewFactory) : base(controller, view) { diff --git a/Eve-O-Preview/Presentation/ThumbnailManager.cs b/Eve-O-Preview/Presentation/ThumbnailManager.cs index b5d7876..7d513e4 100644 --- a/Eve-O-Preview/Presentation/ThumbnailManager.cs +++ b/Eve-O-Preview/Presentation/ThumbnailManager.cs @@ -15,7 +15,7 @@ namespace EveOPreview.UI #endregion #region Private fields - private readonly IAppConfig _configuration; + private readonly IThumbnailConfig _configuration; private readonly DispatcherTimer _thumbnailUpdateTimer; private readonly IThumbnailViewFactory _thumbnailViewFactory; private readonly Dictionary _thumbnailViews; @@ -27,7 +27,7 @@ namespace EveOPreview.UI private bool _isHoverEffectActive; #endregion - public ThumbnailManager(IAppConfig configuration, IThumbnailViewFactory factory) + public ThumbnailManager(IThumbnailConfig configuration, IThumbnailViewFactory factory) { this._configuration = configuration; this._thumbnailViewFactory = factory; diff --git a/Eve-O-Preview/Program.cs b/Eve-O-Preview/Program.cs index da22a50..574e80d 100644 --- a/Eve-O-Preview/Program.cs +++ b/Eve-O-Preview/Program.cs @@ -7,9 +7,11 @@ namespace EveOPreview { static class Program { + private static string ConfigParameterName = "--config:"; + /// The main entry point for the application. [STAThread] - static void Main() + static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); @@ -29,9 +31,41 @@ namespace EveOPreview .RegisterService() .RegisterService() .RegisterService() - .RegisterInstance(new AppConfig()); + .RegisterInstance(new ThumbnailConfig()); + + controller.Create().ConfigFileName = Program.GetCustomConfigFile(args); controller.Run(); } + + // Parse startup parameters + // Simple approach is used because something like NParams would be an overkill here + private static string GetCustomConfigFile(string[] args) + { + 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; + } } } \ No newline at end of file From 5e87beadd1fa419a8ab7f6e543423e3328fd5c12 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Sat, 15 Oct 2016 21:37:18 +0300 Subject: [PATCH 03/20] Allow users to have multiple configuration files --- Eve-O-Preview/Configuration/AppConfig.cs | 13 +++++++++++++ .../Configuration/ConfigurationStorage.cs | 18 ++++++++++-------- Eve-O-Preview/Configuration/IAppConfig.cs | 10 ++++++++++ .../Configuration/IThumbnailConfig.cs | 5 +++-- Eve-O-Preview/Configuration/ThumbnailConfig.cs | 8 +------- Eve-O-Preview/Eve-O-Preview.csproj | 2 ++ Eve-O-Preview/Program.cs | 3 ++- 7 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 Eve-O-Preview/Configuration/AppConfig.cs create mode 100644 Eve-O-Preview/Configuration/IAppConfig.cs diff --git a/Eve-O-Preview/Configuration/AppConfig.cs b/Eve-O-Preview/Configuration/AppConfig.cs new file mode 100644 index 0000000..c059d39 --- /dev/null +++ b/Eve-O-Preview/Configuration/AppConfig.cs @@ -0,0 +1,13 @@ +namespace EveOPreview.Configuration +{ + class AppConfig : IAppConfig + { + public AppConfig() + { + // Default values + this.ConfigFileName = null; + } + + public string ConfigFileName { get; set; } + } +} diff --git a/Eve-O-Preview/Configuration/ConfigurationStorage.cs b/Eve-O-Preview/Configuration/ConfigurationStorage.cs index be5b229..f6452db 100644 --- a/Eve-O-Preview/Configuration/ConfigurationStorage.cs +++ b/Eve-O-Preview/Configuration/ConfigurationStorage.cs @@ -3,15 +3,17 @@ using Newtonsoft.Json; namespace EveOPreview.Configuration { - public class ConfigurationStorage : IConfigurationStorage + class ConfigurationStorage : IConfigurationStorage { private const string ConfigurationFileName = "EVE-O Preview.json"; - private readonly IThumbnailConfig _configuration; + private readonly IAppConfig _appConfig; + private readonly IThumbnailConfig _thumbnailConfig; - public ConfigurationStorage(IThumbnailConfig configuration) + public ConfigurationStorage(IAppConfig appConfig, IThumbnailConfig thumbnailConfig) { - this._configuration = configuration; + this._appConfig = appConfig; + this._thumbnailConfig = thumbnailConfig; } public void Load() @@ -25,22 +27,22 @@ namespace EveOPreview.Configuration string rawData = File.ReadAllText(filename); - JsonConvert.PopulateObject(rawData, this._configuration); + JsonConvert.PopulateObject(rawData, this._thumbnailConfig); // Validate data after loading it - this._configuration.ApplyRestrictions(); + this._thumbnailConfig.ApplyRestrictions(); } public void Save() { - string rawData = JsonConvert.SerializeObject(this._configuration, Formatting.Indented); + string rawData = JsonConvert.SerializeObject(this._thumbnailConfig, Formatting.Indented); File.WriteAllText(this.GetConfigFileName(), rawData); } private string GetConfigFileName() { - return string.IsNullOrEmpty(this._configuration.ConfigFileName) ? ConfigurationStorage.ConfigurationFileName : this._configuration.ConfigFileName; + return string.IsNullOrEmpty(this._appConfig.ConfigFileName) ? ConfigurationStorage.ConfigurationFileName : this._appConfig.ConfigFileName; } } } \ No newline at end of file diff --git a/Eve-O-Preview/Configuration/IAppConfig.cs b/Eve-O-Preview/Configuration/IAppConfig.cs new file mode 100644 index 0000000..f5ba6bf --- /dev/null +++ b/Eve-O-Preview/Configuration/IAppConfig.cs @@ -0,0 +1,10 @@ +namespace EveOPreview.Configuration +{ + /// + /// Application configuration + /// + public interface IAppConfig + { + string ConfigFileName { get; set; } + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Configuration/IThumbnailConfig.cs b/Eve-O-Preview/Configuration/IThumbnailConfig.cs index 88a75c1..0bb27fa 100644 --- a/Eve-O-Preview/Configuration/IThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/IThumbnailConfig.cs @@ -3,10 +3,11 @@ using System.Windows.Forms; namespace EveOPreview.Configuration { + /// + /// Thumbnails Manager configuration + /// public interface IThumbnailConfig { - string ConfigFileName { get; set; } - bool MinimizeToTray { get; set; } int ThumbnailRefreshPeriod { get; set; } diff --git a/Eve-O-Preview/Configuration/ThumbnailConfig.cs b/Eve-O-Preview/Configuration/ThumbnailConfig.cs index 337dd30..160ea80 100644 --- a/Eve-O-Preview/Configuration/ThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/ThumbnailConfig.cs @@ -5,13 +5,10 @@ using Newtonsoft.Json; namespace EveOPreview.Configuration { - public class ThumbnailConfig : IThumbnailConfig + class ThumbnailConfig : IThumbnailConfig { public ThumbnailConfig() { - // Default values - this.ConfigFileName = null; - this.MinimizeToTray = false; this.ThumbnailRefreshPeriod = 500; @@ -43,9 +40,6 @@ namespace EveOPreview.Configuration this.ClientHotkey = new Dictionary(); } - [JsonIgnore] - public string ConfigFileName { get; set; } - public bool MinimizeToTray { get; set; } public int ThumbnailRefreshPeriod { get; set; } diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index 84b350d..59948ff 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -96,7 +96,9 @@ + + diff --git a/Eve-O-Preview/Program.cs b/Eve-O-Preview/Program.cs index 574e80d..e0090bc 100644 --- a/Eve-O-Preview/Program.cs +++ b/Eve-O-Preview/Program.cs @@ -31,9 +31,10 @@ namespace EveOPreview .RegisterService() .RegisterService() .RegisterService() + .RegisterInstance(new AppConfig()) .RegisterInstance(new ThumbnailConfig()); - controller.Create().ConfigFileName = Program.GetCustomConfigFile(args); + controller.Create().ConfigFileName = Program.GetCustomConfigFile(args); controller.Run(); } From 89519fe473b0c35c7e56b05ca32942e09f4b059c Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Sat, 15 Oct 2016 21:39:35 +0300 Subject: [PATCH 04/20] Update version info to 2.2.0 --- Eve-O-Preview/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Eve-O-Preview/Properties/AssemblyInfo.cs b/Eve-O-Preview/Properties/AssemblyInfo.cs index b479f9f..c3d1535 100644 --- a/Eve-O-Preview/Properties/AssemblyInfo.cs +++ b/Eve-O-Preview/Properties/AssemblyInfo.cs @@ -12,7 +12,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("04f08f8d-9e98-423b-acdb-4effb31c0d35")] -[assembly: AssemblyVersion("2.1.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] [assembly: CLSCompliant(true)] \ No newline at end of file From 5a9e6722c846bed8a9c40350f8d54c830bca30fb Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Sat, 15 Oct 2016 22:31:52 +0300 Subject: [PATCH 05/20] Use thumbnail position from FLAT layout if there is no corresponding entry in the PER CLIENT layouts --- .../Configuration/ThumbnailConfig.cs | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Eve-O-Preview/Configuration/ThumbnailConfig.cs b/Eve-O-Preview/Configuration/ThumbnailConfig.cs index 160ea80..31acfd1 100644 --- a/Eve-O-Preview/Configuration/ThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/ThumbnailConfig.cs @@ -78,27 +78,26 @@ namespace EveOPreview.Configuration public Point GetThumbnailLocation(string currentClient, string activeClient, Point defaultLocation) { - Dictionary layoutSource = null; + Point location; - if (this.EnablePerClientThumbnailLayouts) + // What this code does: + // If Per-Client layouts are enabled + // and client name is known + // and there is a separate thumbnails layout for this client + // and this layout contains an entry for the current client + // then return that entry + // otherwise try to get client layout from the flat all-clients layout + // If there is no layout too then use the default one + if (this.EnablePerClientThumbnailLayouts && !string.IsNullOrEmpty(activeClient)) { - if (!string.IsNullOrEmpty(activeClient)) + Dictionary layoutSource; + if (this.PerClientLayout.TryGetValue(activeClient, out layoutSource) && layoutSource.TryGetValue(currentClient, out location)) { - this.PerClientLayout.TryGetValue(activeClient, out layoutSource); + return location; } } - else - { - layoutSource = this.FlatLayout; - } - if (layoutSource == null) - { - return defaultLocation; - } - - Point location; - return layoutSource.TryGetValue(currentClient, out location) ? location : defaultLocation; + return this.FlatLayout.TryGetValue(currentClient, out location) ? location : defaultLocation; } public void SetThumbnailLocation(string currentClient, string activeClient, Point location) From fcf29a4b139e23d81fa066e878df7d85c31e25e5 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Sat, 15 Oct 2016 22:50:13 +0300 Subject: [PATCH 06/20] Add a single-instance check on application startup --- Eve-O-Preview/Program.cs | 42 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/Eve-O-Preview/Program.cs b/Eve-O-Preview/Program.cs index e0090bc..3203ca7 100644 --- a/Eve-O-Preview/Program.cs +++ b/Eve-O-Preview/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using System.Windows.Forms; using EveOPreview.Configuration; using EveOPreview.UI; @@ -7,16 +8,28 @@ namespace EveOPreview { static class Program { + private static string MutexName = "EVE-O Preview Single Instance Mutex"; private static string ConfigParameterName = "--config:"; /// The main entry point for the application. [STAThread] static void Main(string[] args) { + // The very usual Mutex-based single-instance screening + // 'token' variable is used to store reference to the instance Mutex + // during the app lifetime + object token = Program.GetInstanceToken(); + + // If it was not possible to aquite the app token then another app instance is already running + // Nothing to do here + if (token == null) + { + return; + } + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - // TODO Switch to another container that provides signed assemblies IIocContainer container = new LightInjectContainer(); // UI classes @@ -37,6 +50,8 @@ namespace EveOPreview controller.Create().ConfigFileName = Program.GetCustomConfigFile(args); controller.Run(); + + token = null; } // Parse startup parameters @@ -68,5 +83,30 @@ namespace EveOPreview return configFile; } + + private static object GetInstanceToken() + { + // The code might look overcomplicated here for a single Mutex operation + // Yet we had already experienced a Windows-level issue + // where .NET finalizer theread was literally paralyzed by + // a failed Mutex operation. That did lead to weird OutOfMemory + // exceptions later + try + { + Mutex mutex = Mutex.OpenExisting(Program.MutexName); + // if that didn't fail then anotherinstance is already running + return null; + } + catch (UnauthorizedAccessException) + { + return null; + } + catch (Exception) + { + bool result; + Mutex token = new Mutex(true, Program.MutexName, out result); + return result ? token : null; + } + } } } \ No newline at end of file From 7bbcc24a1db85f3e399c9b269a688ee04c927c9d Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Sat, 15 Oct 2016 22:58:11 +0300 Subject: [PATCH 07/20] Refactor the program startup code --- Eve-O-Preview/Program.cs | 59 ++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/Eve-O-Preview/Program.cs b/Eve-O-Preview/Program.cs index 3203ca7..c25e9c4 100644 --- a/Eve-O-Preview/Program.cs +++ b/Eve-O-Preview/Program.cs @@ -27,37 +27,21 @@ namespace EveOPreview return; } - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); + Program.InitializeWinFormsGui(); - IIocContainer container = new LightInjectContainer(); + IApplicationController controller = Program.InitializeApplicationController(); - // UI classes - IApplicationController controller = new ApplicationController(container) - .RegisterView() - .RegisterView() - .RegisterView() - .RegisterInstance(new ApplicationContext()); - - // Application services - controller.RegisterService() - .RegisterService() - .RegisterService() - .RegisterService() - .RegisterInstance(new AppConfig()) - .RegisterInstance(new ThumbnailConfig()); - - controller.Create().ConfigFileName = Program.GetCustomConfigFile(args); + Program.SetupApplicationConttroller(controller, Program.GetCustomConfigFile(args)); controller.Run(); token = null; } - // Parse startup parameters - // Simple approach is used because something like NParams would be an overkill here 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) { @@ -108,5 +92,38 @@ namespace EveOPreview return result ? token : null; } } + + private static void InitializeWinFormsGui() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + } + + private static IApplicationController InitializeApplicationController() + { + IIocContainer container = new LightInjectContainer(); + + // UI classes + IApplicationController controller = new ApplicationController(container) + .RegisterView() + .RegisterView() + .RegisterView() + .RegisterInstance(new ApplicationContext()); + + // Application services + controller.RegisterService() + .RegisterService() + .RegisterService() + .RegisterService() + .RegisterInstance(new AppConfig()) + .RegisterInstance(new ThumbnailConfig()); + + return controller; + } + + private static void SetupApplicationConttroller(IApplicationController controller, string configFile) + { + controller.Create().ConfigFileName = configFile; + } } } \ No newline at end of file From 765c35ac0b10efe64c7c7bb5fad448b097de2ccd Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Tue, 18 Oct 2016 21:00:25 +0300 Subject: [PATCH 08/20] Setting borderless thumbnail to maximum possible size rusults in incorrect thumbnails sizs on the next application run --- Eve-O-Preview/Presentation/ThumbnailManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Eve-O-Preview/Presentation/ThumbnailManager.cs b/Eve-O-Preview/Presentation/ThumbnailManager.cs index 7d513e4..1e813d4 100644 --- a/Eve-O-Preview/Presentation/ThumbnailManager.cs +++ b/Eve-O-Preview/Presentation/ThumbnailManager.cs @@ -210,9 +210,11 @@ namespace EveOPreview.UI view = this._thumbnailViewFactory.Create(processHandle, processTitle, this._configuration.ThumbnailSize); view.IsEnabled = true; view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays; + view.SetFrames(this._configuration.ShowThumbnailFrames); + // Max/Min size limitations should be set AFTER the frames are disabled + // Otherwise thumbnail window will be unnecessary resized view.SetSizeLimitations(this._configuration.ThumbnailMinimumSize, this._configuration.ThumbnailMaximumSize); view.SetTopMost(this._configuration.ShowThumbnailsAlwaysOnTop); - view.SetFrames(this._configuration.ShowThumbnailFrames); view.ThumbnailLocation = this._configuration.GetThumbnailLocation(processTitle, this._activeClientTitle, view.ThumbnailLocation); this._thumbnailViews.Add(processHandle, view); From 7ed8ade1ebc8d0f1f144f6252922940921520134 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Wed, 19 Oct 2016 23:40:48 +0300 Subject: [PATCH 09/20] True Black (0,0,0) cannot be used as a highlight color --- Eve-O-Preview/Configuration/ThumbnailConfig.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Eve-O-Preview/Configuration/ThumbnailConfig.cs b/Eve-O-Preview/Configuration/ThumbnailConfig.cs index 31acfd1..1a56251 100644 --- a/Eve-O-Preview/Configuration/ThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/ThumbnailConfig.cs @@ -65,7 +65,22 @@ namespace EveOPreview.Configuration public bool ShowThumbnailFrames { get; set; } public bool EnableActiveClientHighlight { get; set; } - public Color ActiveClientHighlightColor { get; set; } + + public Color ActiveClientHighlightColor + { + get + { + return this._activeClientHighlightColor; + } + set + { + // Some WinForms magic + // True Black color cannot be used as highlight frame color + // So a somewhat less-Black one is used + this._activeClientHighlightColor = (value != Color.Black) ? value : Color.FromArgb(1, 1, 1); + } + } + private Color _activeClientHighlightColor; [JsonProperty] private Dictionary> PerClientLayout { get; set; } From c56e173738204ce0974a45026dd533f0d01eebf1 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Wed, 19 Oct 2016 23:42:43 +0300 Subject: [PATCH 10/20] Ensure that thumbnail borders do NOT overlap with the EVE client window image --- .../Presentation/ThumbnailManager.cs | 2 +- .../UI/Implementation/ThumbnailOverlay.cs | 30 +++++++++++----- .../UI/Implementation/ThumbnailView.cs | 34 +++++++++++++++++-- Eve-O-Preview/UI/Interface/IThumbnailView.cs | 2 +- 4 files changed, 55 insertions(+), 13 deletions(-) diff --git a/Eve-O-Preview/Presentation/ThumbnailManager.cs b/Eve-O-Preview/Presentation/ThumbnailManager.cs index 1e813d4..5ba49e2 100644 --- a/Eve-O-Preview/Presentation/ThumbnailManager.cs +++ b/Eve-O-Preview/Presentation/ThumbnailManager.cs @@ -137,7 +137,7 @@ namespace EveOPreview.UI view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays; - view.SetHighlight(this._configuration.EnableActiveClientHighlight && (view.Id == this._activeClientHandle), this._configuration.ActiveClientHighlightColor); + view.SetHighlight(this._configuration.EnableActiveClientHighlight && (view.Id == this._activeClientHandle), this._configuration.ActiveClientHighlightColor, 3); if (!view.IsActive) { diff --git a/Eve-O-Preview/UI/Implementation/ThumbnailOverlay.cs b/Eve-O-Preview/UI/Implementation/ThumbnailOverlay.cs index 16b3f3d..8b507ae 100644 --- a/Eve-O-Preview/UI/Implementation/ThumbnailOverlay.cs +++ b/Eve-O-Preview/UI/Implementation/ThumbnailOverlay.cs @@ -8,8 +8,12 @@ namespace EveOPreview.UI { #region Private fields private readonly Action _areaClickAction; - private bool _highlightEnabled; + private bool _isHighlightEnabled; private Color _highlightColor; + private int _highlightWidthLeft; + private int _highlightWidthTop; + private int _highlightWidthRight; + private int _highlightWidthBottom; #endregion public ThumbnailOverlay(Form owner, Action areaClickAction) @@ -17,7 +21,7 @@ namespace EveOPreview.UI this.Owner = owner; this._areaClickAction = areaClickAction; - this._highlightEnabled = false; + this._isHighlightEnabled = false; this._highlightColor = Color.Red; InitializeComponent(); @@ -38,15 +42,23 @@ namespace EveOPreview.UI this.OverlayLabel.Visible = enable; } + public void SetHighlightWidth(int left, int top, int right, int bottom) + { + this._highlightWidthLeft = left; + this._highlightWidthTop = top; + this._highlightWidthRight = right; + this._highlightWidthBottom = bottom; + } + public void EnableHighlight(bool enabled, Color color) { - if (enabled == this._highlightEnabled) + if (enabled == this._isHighlightEnabled) { // Nothing to do here return; } - this._highlightEnabled = enabled; + this._isHighlightEnabled = enabled; this._highlightColor = color; this.Refresh(); } @@ -65,13 +77,13 @@ namespace EveOPreview.UI { base.OnPaint(e); - if (this._highlightEnabled) + if (this._isHighlightEnabled) { ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, - this._highlightColor, 4, ButtonBorderStyle.Solid, - this._highlightColor, 4, ButtonBorderStyle.Solid, - this._highlightColor, 4, ButtonBorderStyle.Solid, - this._highlightColor, 4, ButtonBorderStyle.Solid); + this._highlightColor, this._highlightWidthLeft, ButtonBorderStyle.Solid, + this._highlightColor, this._highlightWidthTop, ButtonBorderStyle.Solid, + this._highlightColor, this._highlightWidthRight, ButtonBorderStyle.Solid, + this._highlightColor, this._highlightWidthBottom, ButtonBorderStyle.Solid); } } } diff --git a/Eve-O-Preview/UI/Implementation/ThumbnailView.cs b/Eve-O-Preview/UI/Implementation/ThumbnailView.cs index 1dc3da9..cde6534 100644 --- a/Eve-O-Preview/UI/Implementation/ThumbnailView.cs +++ b/Eve-O-Preview/UI/Implementation/ThumbnailView.cs @@ -18,6 +18,8 @@ namespace EveOPreview.UI private bool _isPositionChanged; private bool _isSizeChanged; private bool _isCustomMouseModeActive; + private bool _isHighlightEnabled; + private int _highlightWidth; private DateTime _suppressResizeEventsTimestamp; private DWM_THUMBNAIL_PROPERTIES _thumbnail; private IntPtr _thumbnailHandle; @@ -43,6 +45,8 @@ namespace EveOPreview.UI this._isSizeChanged = true; this._isCustomMouseModeActive = false; + this._isHighlightEnabled = false; + this._suppressResizeEventsTimestamp = DateTime.UtcNow; InitializeComponent(); @@ -197,8 +201,11 @@ namespace EveOPreview.UI this._isTopMost = enableTopmost; } - public void SetHighlight(bool enabled, Color color) + public void SetHighlight(bool enabled, Color color, int width) { + this._isSizeChanged = this._isSizeChanged || (this._isHighlightEnabled != enabled); + this._isHighlightEnabled = enabled; + this._highlightWidth = width; this._overlay.EnableHighlight(enabled, color); } @@ -310,7 +317,30 @@ namespace EveOPreview.UI if (sizeChanged) { - this._thumbnail.rcDestination = new RECT(0, 0, this.ClientSize.Width, this.ClientSize.Height); + // This approach would work only for square-shaped thumbnail window + // To get PROPER results we have to do some crazy math + //int delta = this._isHighlightEnabled ? this._highlightWidth : 0; + //this._thumbnail.rcDestination = new RECT(0 + delta, 0 + delta, this.ClientSize.Width - delta, this.ClientSize.Height - delta); + if (this._isHighlightEnabled) + { + int baseWidth = this.ClientSize.Width; + int baseHeight = this.ClientSize.Height; + double baseAspectRatio = ((double)baseWidth) / baseHeight; + + int actualHeight = baseHeight - 2 * this._highlightWidth; + double desiredWidth = actualHeight * baseAspectRatio; + int actualWidth = (int)Math.Round(desiredWidth); + int highlightWidthLeft = Math.Min(5, (baseWidth - actualWidth) / 2); + int highlightWidthRight = Math.Min(5, baseWidth - actualWidth - highlightWidthLeft); + + this._overlay.SetHighlightWidth(highlightWidthLeft, this._highlightWidth, highlightWidthRight, this._highlightWidth); + this._thumbnail.rcDestination = new RECT(0 + highlightWidthLeft, 0 + this._highlightWidth, actualWidth + highlightWidthLeft, actualHeight + this._highlightWidth); + } + else + { + //No highlighting enables, so no odd math required + this._thumbnail.rcDestination = new RECT(0, 0, this.ClientSize.Width, this.ClientSize.Height); + } try { WindowManagerNativeMethods.DwmUpdateThumbnailProperties(this._thumbnailHandle, this._thumbnail); diff --git a/Eve-O-Preview/UI/Interface/IThumbnailView.cs b/Eve-O-Preview/UI/Interface/IThumbnailView.cs index 21b5cfd..20f5b41 100644 --- a/Eve-O-Preview/UI/Interface/IThumbnailView.cs +++ b/Eve-O-Preview/UI/Interface/IThumbnailView.cs @@ -21,7 +21,7 @@ namespace EveOPreview.UI void SetOpacity(double opacity); void SetFrames(bool enable); void SetTopMost(bool enableTopmost); - void SetHighlight(bool enabled, Color color); + void SetHighlight(bool enabled, Color color, int width); void ZoomIn(ViewZoomAnchor anchor, int zoomFactor); void ZoomOut(); From b4a0e7d31dcb01d1d0ec1c12a7988a121e9ad40e Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Thu, 20 Oct 2016 21:47:20 +0300 Subject: [PATCH 11/20] Allow to setup the highlight border thickness --- Eve-O-Preview/Configuration/IThumbnailConfig.cs | 1 + Eve-O-Preview/Configuration/ThumbnailConfig.cs | 6 +++++- Eve-O-Preview/Presentation/ThumbnailManager.cs | 3 ++- Eve-O-Preview/UI/Implementation/ThumbnailView.cs | 6 +++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Eve-O-Preview/Configuration/IThumbnailConfig.cs b/Eve-O-Preview/Configuration/IThumbnailConfig.cs index 0bb27fa..d563629 100644 --- a/Eve-O-Preview/Configuration/IThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/IThumbnailConfig.cs @@ -32,6 +32,7 @@ namespace EveOPreview.Configuration bool EnableActiveClientHighlight { get; set; } Color ActiveClientHighlightColor { get; set; } + int ActiveClientHighlightThickness { get; set; } Point GetThumbnailLocation(string currentClient, string activeClient, Point defaultLocation); void SetThumbnailLocation(string currentClient, string activeClient, Point location); diff --git a/Eve-O-Preview/Configuration/ThumbnailConfig.cs b/Eve-O-Preview/Configuration/ThumbnailConfig.cs index 1a56251..dd53fbf 100644 --- a/Eve-O-Preview/Configuration/ThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/ThumbnailConfig.cs @@ -32,7 +32,8 @@ namespace EveOPreview.Configuration this.ShowThumbnailFrames = true; this.EnableActiveClientHighlight = false; - this.ActiveClientHighlightColor = Color.Yellow; + this.ActiveClientHighlightColor = Color.GreenYellow; + this.ActiveClientHighlightThickness = 3; this.PerClientLayout = new Dictionary>(); this.FlatLayout = new Dictionary(); @@ -82,6 +83,8 @@ namespace EveOPreview.Configuration } private Color _activeClientHighlightColor; + public int ActiveClientHighlightThickness { get; set; } + [JsonProperty] private Dictionary> PerClientLayout { get; set; } [JsonProperty] @@ -181,6 +184,7 @@ namespace EveOPreview.Configuration 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, 3); } private static int ApplyRestrictions(int value, int minimum, int maximum) diff --git a/Eve-O-Preview/Presentation/ThumbnailManager.cs b/Eve-O-Preview/Presentation/ThumbnailManager.cs index 5ba49e2..9888953 100644 --- a/Eve-O-Preview/Presentation/ThumbnailManager.cs +++ b/Eve-O-Preview/Presentation/ThumbnailManager.cs @@ -137,7 +137,8 @@ namespace EveOPreview.UI view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays; - view.SetHighlight(this._configuration.EnableActiveClientHighlight && (view.Id == this._activeClientHandle), this._configuration.ActiveClientHighlightColor, 3); + view.SetHighlight(this._configuration.EnableActiveClientHighlight && (view.Id == this._activeClientHandle), + this._configuration.ActiveClientHighlightColor, this._configuration.ActiveClientHighlightThickness); if (!view.IsActive) { diff --git a/Eve-O-Preview/UI/Implementation/ThumbnailView.cs b/Eve-O-Preview/UI/Implementation/ThumbnailView.cs index cde6534..4c8c2be 100644 --- a/Eve-O-Preview/UI/Implementation/ThumbnailView.cs +++ b/Eve-O-Preview/UI/Implementation/ThumbnailView.cs @@ -329,9 +329,9 @@ namespace EveOPreview.UI int actualHeight = baseHeight - 2 * this._highlightWidth; double desiredWidth = actualHeight * baseAspectRatio; - int actualWidth = (int)Math.Round(desiredWidth); - int highlightWidthLeft = Math.Min(5, (baseWidth - actualWidth) / 2); - int highlightWidthRight = Math.Min(5, baseWidth - actualWidth - highlightWidthLeft); + int actualWidth = (int)Math.Round(desiredWidth, MidpointRounding.AwayFromZero); + int highlightWidthLeft = Math.Min(4, (baseWidth - actualWidth) / 2); + int highlightWidthRight = Math.Min(4, baseWidth - actualWidth - highlightWidthLeft); this._overlay.SetHighlightWidth(highlightWidthLeft, this._highlightWidth, highlightWidthRight, this._highlightWidth); this._thumbnail.rcDestination = new RECT(0 + highlightWidthLeft, 0 + this._highlightWidth, actualWidth + highlightWidthLeft, actualHeight + this._highlightWidth); From 49fb4d0c768afa78c4c935247e36e7e63b1d9a16 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Thu, 20 Oct 2016 22:05:06 +0300 Subject: [PATCH 12/20] Move all documentation to the Readme file --- README.md | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 08fd713..fef5652 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The program does NOT (and will NOT ever) do the following things: 1. Download and extract the contents of the .zip archive to a location of your choice (ie: Desktop, CCP folder, etc) ..* **Note**: Please do not install the program into the *Program Files* or *Program files (x86)* folders. These folders in general do not allow applications to write anything there while EVE-O Preview now stores its configuration file next to its executable, thus requiring the write access to the folder it is installed into. 2. Start up both EVE-O Preview and your EVE Clients (the order does not matter) -3. Adjust settings as you see fit. Program options are described [here](https://github.com/Phrynohyas/eve-o-preview/wiki/EVE-O-Preview-Program-Options) +3. Adjust settings as you see fit. Program options are described below *** @@ -40,6 +40,47 @@ CCP FoxFour wrote: > interact with it. *** +--- + +**Startup Parameters** + +_Left Blank_ + +**Program options** + +| Option | Description | +| --- | --- | +| Minimize to System Tray | Determines whether the main window form be minimized to windows tray when it is closed | +| Opacity | Determines the inactive EVE thumbnails opacity (from almost invisible 20% to 100% solid) | +| Track client locations | Determines whether the client's window position should be restored when it is activated or started | +| Hide preview of active EVE client | Determines whether the thumbnail corresponding to the active EVE client is not displayed | +| Previews always on top | Determines whether EVE client thumbnails should stay on top of all other windows | +| Hide previews when EVE client is not active | Determines whether all thumbnails should be visible only when an EVE client is active | +| Unique layout for each EVE client | Determines whether thumbnails positions are different depending on the EVE client being active (f.e. links char have thumbnails of the Falcon and DPS char in the right bottom corner while DPS and Falcon alts have them placed at the top of the main EVE window ) | +| Thumbnail width | Thumbnails width. Can be set to any value from **100** to **640** points | +| Thumbnail height | Thumbnails Height. Can be set to any value from **80** to **400** points | +| Zoom on hover | Determines whether a thumbnail should be zoomed when the mouse pointer is over it | +| Zoom factor | Thumbnail zoom factor. Can be set to any value from **2** to **10** | +| Zoom anchor | Sets the starting point of the thumbnail zoom | +| Show overlay | Determines whether a name of the corresponding EVE cliet should be displayed on the thumbnail | +| Show frames | Determines whether thumbnails should be displayd with window caption and borders | +| Highlight active client | Determines whether the thumbnail of the active EVE client should be highlighted with a bright border | +| Color | Color used to highlight the active client's thumbnail in case the corresponding option is set | +| Thumbnails list | List of currently active EVE client thumbnails. Checking an element in this list will hide the corresponding thumbnail. However these checks are not persisted and on the next EVE client or EVE-O Preview run the thumbnail will be visible again | + +**Mouse Gestures** + +_Left Blank_ + +**Configuration File Options** + +_Left Blank_ + +**Hotkey Setup** + +_Left Blank_ + +--- **Created by** @@ -48,22 +89,24 @@ CCP FoxFour wrote: **Maintained by** -* StinkRay +* Phrynohyas Tig-Rah * Makari Aeron -* Phrynohyas Tig-Rah +* StinkRay **With contributions from** * CCP FoxFour + **Original threads** https://forums.eveonline.com/default.aspx?g=posts&t=389086 https://forums.eveonline.com/default.aspx?g=posts&t=246157 + **Original repository** https://bitbucket.org/ulph/eve-o-preview-git From eca324f7c79ffe00b4ff64c1b95cfdcdb00035e2 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Thu, 20 Oct 2016 22:30:59 +0300 Subject: [PATCH 13/20] Add documentation for the 'several configuration files' feature --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fef5652..4c34696 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -The purpose of this tool is to provide a simple way to keep an eye on several simultaneously running EVE Online clients and to easily switch between them. While running it shows a set of live thumbnails for each of the active EVE Online clients. These thumbnails allow fast switch to the corresponding EVE Online client either using mouse or a configurable hotkey. +The purpose of this application is to provide a simple way to keep an eye on several simultaneously running EVE Online clients and to easily switch between them. While running it shows a set of live thumbnails for each of the active EVE Online clients. These thumbnails allow fast switch to the corresponding EVE Online client either using mouse or a configurable hotkey. It's essentially a task switcher, it does not relay any keyboard/mouse events and suchlike. The app works with EVE, EVE through Steam, or any combination thereof. @@ -44,7 +44,9 @@ CCP FoxFour wrote: **Startup Parameters** -_Left Blank_ +| Parameter | Description | +| --- | --- | +| **config** | This option allows to start the application with a custom configuration file. If the provided file doesn't exists it will be created with default values.
For example **"Eve-O Preview.exe" --config:TestSetup.json** | **Program options** From 4ce8bf758b7450f8b81bc457e7e94d1a5ca3db6a Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Thu, 20 Oct 2016 22:38:55 +0300 Subject: [PATCH 14/20] Mouse gestures description --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c34696..565bae8 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,13 @@ CCP FoxFour wrote: **Mouse Gestures** -_Left Blank_ +Mouse gestures are applied to the thumbnail window currently being hovered over. + +| Action | Gesture | +| --- | --- | +| Move thumbnail to a new position | Press right mouse button and move the mouse | +| Adjust thumbnail height | Press both left and right mouse buttons and move the mouse up or down | +| Adjust thumbnail width | Press both left and right mouse buttons and move the mouse left or right | **Configuration File Options** From cfd516d303df2a4bca73c5ba227763cd6516805b Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Thu, 20 Oct 2016 22:53:56 +0300 Subject: [PATCH 15/20] Add documentation for the 'highlight border thickness' feature --- README.md | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 565bae8..31edaea 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +#Overview + The purpose of this application is to provide a simple way to keep an eye on several simultaneously running EVE Online clients and to easily switch between them. While running it shows a set of live thumbnails for each of the active EVE Online clients. These thumbnails allow fast switch to the corresponding EVE Online client either using mouse or a configurable hotkey. It's essentially a task switcher, it does not relay any keyboard/mouse events and suchlike. The app works with EVE, EVE through Steam, or any combination thereof. @@ -9,21 +11,21 @@ The program does NOT (and will NOT ever) do the following things: * anyhow interact with EVE Online except of bringing its main window to foreground or resizing it -**System Requirements** +#System Requirements * Windows Vista, Windows 7, Windows 8/8.1, Windows 10 * Windows Aero Enabled * Microsoft .NET Framework 4.5+ -**How To Install & Use** +#How To Install & Use 1. Download and extract the contents of the .zip archive to a location of your choice (ie: Desktop, CCP folder, etc) ..* **Note**: Please do not install the program into the *Program Files* or *Program files (x86)* folders. These folders in general do not allow applications to write anything there while EVE-O Preview now stores its configuration file next to its executable, thus requiring the write access to the folder it is installed into. 2. Start up both EVE-O Preview and your EVE Clients (the order does not matter) 3. Adjust settings as you see fit. Program options are described below -*** +#EULA/ToS This program is legal under the EULA/ToS: @@ -39,16 +41,15 @@ CCP FoxFour wrote: > to bring the respective EVE Client to the front/put the window focus on it, in order to > interact with it. -*** ---- +#Application Options -**Startup Parameters** +##Startup Parameters | Parameter | Description | | --- | --- | | **config** | This option allows to start the application with a custom configuration file. If the provided file doesn't exists it will be created with default values.
For example **"Eve-O Preview.exe" --config:TestSetup.json** | -**Program options** +##Application Options Available Via GUI | Option | Description | | --- | --- | @@ -70,7 +71,7 @@ CCP FoxFour wrote: | Color | Color used to highlight the active client's thumbnail in case the corresponding option is set | | Thumbnails list | List of currently active EVE client thumbnails. Checking an element in this list will hide the corresponding thumbnail. However these checks are not persisted and on the next EVE client or EVE-O Preview run the thumbnail will be visible again | -**Mouse Gestures** +##Mouse Gestures Mouse gestures are applied to the thumbnail window currently being hovered over. @@ -80,22 +81,32 @@ Mouse gestures are applied to the thumbnail window currently being hovered over. | Adjust thumbnail height | Press both left and right mouse buttons and move the mouse up or down | | Adjust thumbnail width | Press both left and right mouse buttons and move the mouse left or right | -**Configuration File Options** +##Configuration File-Only Options -_Left Blank_ +Some of the application options are not exposed in the GUI. They can be ajusted directly in the configuration file. -**Hotkey Setup** +**Note:** Do any changes to the configuration file only while the EVE-O Preview itself is closed. Otherwise the changes you made might be lost. + +| Option | Description | +| --- | --- | +| **ActiveClientHighlightThickness** | Thickness of the border used to highlight the active client's thumbnail.
Allowed values are **1**, **2**, **3**.
The default value is **3**
For example: **"ActiveClientHighlightThickness": 3,** | +| **ThumbnailMinimumSize** | Minimum thumbnail size that can be set either via GUI or by resizing a thumbnail window. Value is witten in the form "width, height"
The default value is **"100, 80"**.
For example: **"ThumbnailMinimumSize": "100, 80",** | +| **ThumbnailMaximumSize** | Maximum thumbnail size that can be set either via GUI or by resizing a thumbnail window. Value is witten in the form "width, height"
The default value is **"640, 400"**.
For example: **"ThumbnailMaximumSize": "640, 400",** | + +##Hotkey Setup _Left Blank_ --- -**Created by** +#Credits + +##Created by * StinkRay -**Maintained by** +##Maintained by * Phrynohyas Tig-Rah @@ -104,17 +115,17 @@ _Left Blank_ * StinkRay -**With contributions from** +##With contributions from * CCP FoxFour -**Original threads** +##Original threads https://forums.eveonline.com/default.aspx?g=posts&t=389086 https://forums.eveonline.com/default.aspx?g=posts&t=246157 -**Original repository** +##Original repository https://bitbucket.org/ulph/eve-o-preview-git From 0e06a3a9cf7cf9466a9bf4c7b242ad9aa9e23c22 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Thu, 20 Oct 2016 23:22:44 +0300 Subject: [PATCH 16/20] Provide support of HotKeys to manage thumbnails and corresponding EVE clients --- README.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 31edaea..0a3919a 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,32 @@ Some of the application options are not exposed in the GUI. They can be ajusted ##Hotkey Setup -_Left Blank_ +It is possible to set a key kombinations to immediately jump to cetrain EVE window. However currently EVE-O Preview doesn't provide any GUI to set the these hotkeys. It should be done via editind the configuration file directly. Don't forget to make a backup copy of the file before editing it. + +**Note**: Don't forget to make a backup copy of the file before editing it. + +Open the file using any text editor. find the entry **ClientHotkey**. Most probably it will look like + + "ClientHotkey": {}, + +This means that no hotkeys are defined. Edit it to be like + + "ClientHotkey": { + "EVE - Phrynohyas Tig-Rah": "F1", + "EVE - Ondatra Patrouette": "F2" + } + +This simple edit will assign **F1** as a hotkey for Phrynohyas Tig-Rah and **F2** as a hotkey for Ondatra Patrouette, so pressing F1 anywhere in Windows will immediately open EVE client for Phrynohyas Tig-Rah if he is logged on. + +The following hotkey is described as `modifier+key` where `modifier` can be **Control**, **Alt**, **Shift**, or their combination. F.e. it is possible to setup the hotkey as + + "ClientHotkey": { + "EVE - Phrynohyas Tig-Rah": "F1", + "EVE - Ondatra Patrouette": "Control+Shift+F4" + } + +**Note:** Do not set hotkeys to use the key combinations already used by EVE. It won't work as "_I set hotkey for my DPS char to F1 and when I'll press F1 it will automatically open the DPS char's window and activate guns_". Key combination will be swallowed by EVE-O Preview and NOT retranslated to EVE window. So it will be only "_it will automatically open the DPS char's window_". + --- From 902ee7e9a0f2647f3993fd7a45756060e3d7acf0 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Thu, 20 Oct 2016 23:30:38 +0300 Subject: [PATCH 17/20] Edit New issue Add notice explicity forbiding to use EOP for any EULA/TOS breaking activity --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 0a3919a..df58ba9 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ The program does NOT (and will NOT ever) do the following things: * broadcast any keyboard or mouse events * anyhow interact with EVE Online except of bringing its main window to foreground or resizing it +Under any conditions you should NOT use EVE-O Preview for any actions that break EULA or ToS of EVE Online. + +If you have find out that some of the features or their combination of EVE-O Preview might cause actions that can be considered as breaking EULA or ToS of EVE Online you should consider them as a bug and immediately notify the Developer ( Phrynohyas Tig-Rah ) via in-game mail. #System Requirements From 21201b7c7872c1df1161f25f9d6f7c1ac014bd90 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Thu, 20 Oct 2016 23:31:15 +0300 Subject: [PATCH 18/20] Add notice explicity forbiding to use EOP for any EULA/TOS breaking activity --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index df58ba9..37ab0e9 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ If you have find out that some of the features or their combination of EVE-O Pre 2. Start up both EVE-O Preview and your EVE Clients (the order does not matter) 3. Adjust settings as you see fit. Program options are described below -#EULA/ToS +#EVE Online EULA/ToS This program is legal under the EULA/ToS: From 47de7a89c2c8187c87045ecbb45fe069dbdd8c27 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Tue, 25 Oct 2016 20:49:00 +0300 Subject: [PATCH 19/20] Minor docs update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37ab0e9..bc84715 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ Some of the application options are not exposed in the GUI. They can be ajusted | Option | Description | | --- | --- | -| **ActiveClientHighlightThickness** | Thickness of the border used to highlight the active client's thumbnail.
Allowed values are **1**, **2**, **3**.
The default value is **3**
For example: **"ActiveClientHighlightThickness": 3,** | +| **ActiveClientHighlightThickness** | Thickness of the border used to highlight the active client's thumbnail.
Allowed values are **1**...**6**.
The default value is **3**
For example: **"ActiveClientHighlightThickness": 3,** | | **ThumbnailMinimumSize** | Minimum thumbnail size that can be set either via GUI or by resizing a thumbnail window. Value is witten in the form "width, height"
The default value is **"100, 80"**.
For example: **"ThumbnailMinimumSize": "100, 80",** | | **ThumbnailMaximumSize** | Maximum thumbnail size that can be set either via GUI or by resizing a thumbnail window. Value is witten in the form "width, height"
The default value is **"640, 400"**.
For example: **"ThumbnailMaximumSize": "640, 400",** | From 13efa153750cb01cf33c6901b2dfa0f550da73c9 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Tue, 25 Oct 2016 20:51:41 +0300 Subject: [PATCH 20/20] Improve performance of the code used to display active thumbnail's borders --- .../Configuration/ThumbnailConfig.cs | 18 +------- .../UI/Implementation/ThumbnailOverlay.cs | 45 ------------------- .../UI/Implementation/ThumbnailView.cs | 34 +++++++++----- 3 files changed, 26 insertions(+), 71 deletions(-) diff --git a/Eve-O-Preview/Configuration/ThumbnailConfig.cs b/Eve-O-Preview/Configuration/ThumbnailConfig.cs index dd53fbf..73b9104 100644 --- a/Eve-O-Preview/Configuration/ThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/ThumbnailConfig.cs @@ -67,21 +67,7 @@ namespace EveOPreview.Configuration public bool EnableActiveClientHighlight { get; set; } - public Color ActiveClientHighlightColor - { - get - { - return this._activeClientHighlightColor; - } - set - { - // Some WinForms magic - // True Black color cannot be used as highlight frame color - // So a somewhat less-Black one is used - this._activeClientHighlightColor = (value != Color.Black) ? value : Color.FromArgb(1, 1, 1); - } - } - private Color _activeClientHighlightColor; + public Color ActiveClientHighlightColor { get; set; } public int ActiveClientHighlightThickness { get; set; } @@ -184,7 +170,7 @@ namespace EveOPreview.Configuration 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, 3); + this.ActiveClientHighlightThickness = ThumbnailConfig.ApplyRestrictions(this.ActiveClientHighlightThickness, 1, 6); } private static int ApplyRestrictions(int value, int minimum, int maximum) diff --git a/Eve-O-Preview/UI/Implementation/ThumbnailOverlay.cs b/Eve-O-Preview/UI/Implementation/ThumbnailOverlay.cs index 8b507ae..49a757c 100644 --- a/Eve-O-Preview/UI/Implementation/ThumbnailOverlay.cs +++ b/Eve-O-Preview/UI/Implementation/ThumbnailOverlay.cs @@ -1,5 +1,4 @@ using System; -using System.Drawing; using System.Windows.Forms; namespace EveOPreview.UI @@ -8,12 +7,6 @@ namespace EveOPreview.UI { #region Private fields private readonly Action _areaClickAction; - private bool _isHighlightEnabled; - private Color _highlightColor; - private int _highlightWidthLeft; - private int _highlightWidthTop; - private int _highlightWidthRight; - private int _highlightWidthBottom; #endregion public ThumbnailOverlay(Form owner, Action areaClickAction) @@ -21,9 +14,6 @@ namespace EveOPreview.UI this.Owner = owner; this._areaClickAction = areaClickAction; - this._isHighlightEnabled = false; - this._highlightColor = Color.Red; - InitializeComponent(); } @@ -42,27 +32,6 @@ namespace EveOPreview.UI this.OverlayLabel.Visible = enable; } - public void SetHighlightWidth(int left, int top, int right, int bottom) - { - this._highlightWidthLeft = left; - this._highlightWidthTop = top; - this._highlightWidthRight = right; - this._highlightWidthBottom = bottom; - } - - public void EnableHighlight(bool enabled, Color color) - { - if (enabled == this._isHighlightEnabled) - { - // Nothing to do here - return; - } - - this._isHighlightEnabled = enabled; - this._highlightColor = color; - this.Refresh(); - } - protected override CreateParams CreateParams { get @@ -72,19 +41,5 @@ namespace EveOPreview.UI return Params; } } - - protected override void OnPaint(PaintEventArgs e) - { - base.OnPaint(e); - - if (this._isHighlightEnabled) - { - ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, - this._highlightColor, this._highlightWidthLeft, ButtonBorderStyle.Solid, - this._highlightColor, this._highlightWidthTop, ButtonBorderStyle.Solid, - this._highlightColor, this._highlightWidthRight, ButtonBorderStyle.Solid, - this._highlightColor, this._highlightWidthBottom, ButtonBorderStyle.Solid); - } - } } } diff --git a/Eve-O-Preview/UI/Implementation/ThumbnailView.cs b/Eve-O-Preview/UI/Implementation/ThumbnailView.cs index 4c8c2be..fd9e606 100644 --- a/Eve-O-Preview/UI/Implementation/ThumbnailView.cs +++ b/Eve-O-Preview/UI/Implementation/ThumbnailView.cs @@ -203,10 +203,24 @@ namespace EveOPreview.UI public void SetHighlight(bool enabled, Color color, int width) { - this._isSizeChanged = this._isSizeChanged || (this._isHighlightEnabled != enabled); - this._isHighlightEnabled = enabled; - this._highlightWidth = width; - this._overlay.EnableHighlight(enabled, color); + if (this._isHighlightEnabled == enabled) + { + return; + } + + if (enabled) + { + this._isHighlightEnabled = true; + this._highlightWidth = width; + this.BackColor = color; + } + else + { + this._isHighlightEnabled = false; + this.BackColor = SystemColors.Control; + } + + this._isSizeChanged = true; } public void ZoomIn(ViewZoomAnchor anchor, int zoomFactor) @@ -330,11 +344,10 @@ namespace EveOPreview.UI int actualHeight = baseHeight - 2 * this._highlightWidth; double desiredWidth = actualHeight * baseAspectRatio; int actualWidth = (int)Math.Round(desiredWidth, MidpointRounding.AwayFromZero); - int highlightWidthLeft = Math.Min(4, (baseWidth - actualWidth) / 2); - int highlightWidthRight = Math.Min(4, baseWidth - actualWidth - highlightWidthLeft); + int highlightWidthLeft = (baseWidth - actualWidth) / 2; + int highlightWidthRight = baseWidth - actualWidth - highlightWidthLeft; - this._overlay.SetHighlightWidth(highlightWidthLeft, this._highlightWidth, highlightWidthRight, this._highlightWidth); - this._thumbnail.rcDestination = new RECT(0 + highlightWidthLeft, 0 + this._highlightWidth, actualWidth + highlightWidthLeft, actualHeight + this._highlightWidth); + this._thumbnail.rcDestination = new RECT(0 + highlightWidthLeft, 0 + this._highlightWidth, baseWidth - highlightWidthRight, baseHeight - this._highlightWidth); } else { @@ -378,8 +391,9 @@ namespace EveOPreview.UI Size overlaySize = this.ClientSize; Point overlayLocation = this.Location; - overlayLocation.X += (this.Size.Width - this.ClientSize.Width) / 2; - overlayLocation.Y += (this.Size.Height - this.ClientSize.Height) - (this.Size.Width - this.ClientSize.Width) / 2; + int borderWidth = (this.Size.Width - this.ClientSize.Width) / 2; + overlayLocation.X += borderWidth; + overlayLocation.Y += (this.Size.Height - this.ClientSize.Height) - borderWidth; this._isPositionChanged = false; this._overlay.Size = overlaySize;