diff --git a/README.md b/README.md index 95a5d2c..23e6c47 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,77 @@ The following hotkey is described as `modifier+key` where `modifier` can be **Co
+### Cycle Clients with Hotkey Setup + +In a similar pattern to the per client Hotkey Setup, It is possible to set a key combinations to cycle through select Eve Windows. EVE-O Preview doesn't provide any GUI to set the these hotkeys. It should be done via editing the configuration file directly. Don't forget to make a backup copy of the file before editing it. + +If you have not run EVE-O Preview before, or since this feature was added then it is recommended to quickly open and close EVE-O Preview once to trigger the config to update with some sample values. + +**Note**: Don't forget to make a backup copy of the file before editing it. + +Open the file using any text editor. find the entries **CycleGroup1ForwardHotkeys** and **CycleGroup1BackwardHotkeys**. Most probably it will look like + + "CycleGroup1ForwardHotkeys": [ + "F14", + "Control+F14" + ], + "CycleGroup1BackwardHotkeys": [ + "F13", + "Control+F13" + ] + +**Note**: It is highly recommended to leave the Hotkey values as default and bind them with a gaming device if you can support it. + +Next find the entry **CycleGroup1ForwardHotkeys**. Most probably it will look like + + "CycleGroup1ClientsOrder": { + "EVE - Example DPS Toon 1": 1, + "EVE - Example DPS Toon 2": 2, + "EVE - Example DPS Toon 3": 3 + } + +You should modify this entry with a list of each of your clients replacing "Example DPS Toon 1", etc with the name of your character. The numbers on the right are used to force the order in which they cycle. +If a character appears in the list but is not currently logged in, then it will simply be skipped. +If a character does not appear in the list, then they will never become active when cycling clients. + +By now you may have noticed that there are two groups. The above configuration can be followed for a second group by using the values **CycleGroup2ForwardHotkeys**, **CycleGroup2BackwardHotkeys**, and **CycleGroup2ForwardHotkeys** +This may provide useful if you want to have one HotKey to cycle through a group of DPS characters, while another HotKey cycles through support roles such as gate scouts, or a group of logi. + +Alternatively you may not want to use any of these HotKeys. Please note that deleting the values in their entirety will simply result in them being automatically re-generated. +Should you wish to remove these HotKeys completely, Simply set the values to empty, such as the example below: + + "CycleGroup1ForwardHotkeys": [], + "CycleGroup1BackwardHotkeys": [], + "CycleGroup1ClientsOrder": {}, + "CycleGroup2ForwardHotkeys": [], + "CycleGroup2BackwardHotkeys": [], + "CycleGroup2ClientsOrder": {} + +**Hints** +* Minimise the use of modifiers or standard keys to minimise issues with the client playing up. In the default example unusual Function keys (e.g. F14) are used which are then bound to a game pad or gaming mouse. +* The Eve client can be somewhat less than stable, often getting confused as client focus switches. It is near certain that you will experience issues such as keys sticking or even in some cases D-Scan running each time the client swaps. So far I have found no perfect solution and opt for the most stable solution instead, of sticking to the F14+ keys. +* For the best experience try to use the Control modifier. In the default example F14 is used to cycle to the next client, but if pressed mid locking a target (Control + Clicking) then the client will not cycle. By registering Control+F4 as an additional hotkey, the client will cycle. +* For a list of supported keys, see: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.keys + +### Per Client Border Color +Have you ever wanted your main client to show up in a different color so that it more easily catches your eye? Or maybe your Logi to stand out? + +EVE-O Preview doesn't provide any GUI to set the these per client overrides as yet. Though, It can be done via editing the configuration file directly. +**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 **PerClientActiveClientHighlightColor**. Most probably it will look like + + "PerClientActiveClientHighlightColor": { + "EVE - Example Toon 1": "Red", + "EVE - Example Toon 2": "Green" + } + +You should modify this entry with a list of each of your clients replacing "Example Toon 1", etc with the name of your character. The names on the right represent which highligh color to use for that clients border. + +If a client does not appear in this list, then it will use the global highlight color by default. + +**Hint** For a list of supported colors see: https://docs.microsoft.com/en-us/dotnet/api/system.drawing.color#properties + ### Compatibility Mode This setting allows to enable an alternate thumbnail render. This render doesn't use advanced DWM API to create live previews. Instead it is a screenshot-based render with the following pros and cons: diff --git a/src/Eve-O-Preview/Configuration/Implementation/ConfigurationStorage.cs b/src/Eve-O-Preview/Configuration/Implementation/ConfigurationStorage.cs index 3419b74..637c497 100644 --- a/src/Eve-O-Preview/Configuration/Implementation/ConfigurationStorage.cs +++ b/src/Eve-O-Preview/Configuration/Implementation/ConfigurationStorage.cs @@ -27,7 +27,14 @@ namespace EveOPreview.Configuration.Implementation string rawData = File.ReadAllText(filename); - JsonConvert.PopulateObject(rawData, this._thumbnailConfiguration); + JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings() + { + ObjectCreationHandling = ObjectCreationHandling.Replace + }; + + // StageHotkeyArraysToAvoidDuplicates(rawData); + + JsonConvert.PopulateObject(rawData, this._thumbnailConfiguration, jsonSerializerSettings); // Validate data after loading it this._thumbnailConfiguration.ApplyRestrictions(); diff --git a/src/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs b/src/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs index 859a859..22864c1 100644 --- a/src/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs +++ b/src/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Drawing; +using System.Linq; using System.Windows.Forms; using Newtonsoft.Json; @@ -14,6 +15,32 @@ namespace EveOPreview.Configuration.Implementation public ThumbnailConfiguration() { + this.ConfigVersion = 1; + + this.CycleGroup1ForwardHotkeys = new List { "F14", "Control+F14" }; + this.CycleGroup1BackwardHotkeys = new List { "F13", "Control+F13" }; + this.CycleGroup1ClientsOrder = new Dictionary + { + { "EVE - Example DPS Toon 1", 1 }, + { "EVE - Example DPS Toon 2", 2 }, + { "EVE - Example DPS Toon 3", 3 } + }; + + this.CycleGroup2ForwardHotkeys = new List { "F16", "Control+F16" }; + this.CycleGroup2BackwardHotkeys = new List { "F15", "Control+F15" }; + this.CycleGroup2ClientsOrder = new Dictionary + { + { "EVE - Example Logi Toon 1", 1 }, + { "EVE - Example Scout Toon 2", 2 }, + { "EVE - Example Tackle Toon 3", 3 } + }; + + this.PerClientActiveClientHighlightColor = new Dictionary + { + {"EVE - Example Toon 1", Color.Red}, + {"EVE - Example Toon 2", Color.Green} + }; + this.PerClientLayout = new Dictionary>(); this.FlatLayout = new Dictionary(); this.ClientLayout = new Dictionary(); @@ -53,8 +80,35 @@ namespace EveOPreview.Configuration.Implementation this.EnableActiveClientHighlight = false; this.ActiveClientHighlightColor = Color.GreenYellow; this.ActiveClientHighlightThickness = 3; + + this.LoginThumbnailLocation = new Point(5, 5); } + + [JsonProperty("ConfigVersion")] + public int ConfigVersion { get; set; } + + [JsonProperty("CycleGroup1ForwardHotkeys")] + public List CycleGroup1ForwardHotkeys { get; set; } + + [JsonProperty("CycleGroup1BackwardHotkeys")] + public List CycleGroup1BackwardHotkeys { get; set; } + + [JsonProperty("CycleGroup1ClientsOrder")] + public Dictionary CycleGroup1ClientsOrder { get; set; } + + [JsonProperty("CycleGroup2ForwardHotkeys")] + public List CycleGroup2ForwardHotkeys { get; set; } + + [JsonProperty("CycleGroup2BackwardHotkeys")] + public List CycleGroup2BackwardHotkeys { get; set; } + + [JsonProperty("CycleGroup2ClientsOrder")] + public Dictionary CycleGroup2ClientsOrder { get; set; } + + [JsonProperty("PerClientActiveClientHighlightColor")] + public Dictionary PerClientActiveClientHighlightColor { get; set; } + public bool MinimizeToTray { get; set; } public int ThumbnailRefreshPeriod { get; set; } @@ -119,6 +173,9 @@ namespace EveOPreview.Configuration.Implementation public int ActiveClientHighlightThickness { get; set; } + [JsonProperty("LoginThumbnailLocation")] + public Point LoginThumbnailLocation { get; set; } + [JsonProperty] private Dictionary> PerClientLayout { get; set; } [JsonProperty] @@ -132,14 +189,6 @@ namespace EveOPreview.Configuration.Implementation [JsonProperty] private List PriorityClients { get; set; } - public Point GetDefaultThumbnailLocation() - { - // Returns default thumbnail location - // This location can be used for f.e. EVE clients sitting on the login screen - // Can be made configurable later (that's why it was moved out here) - return new Point(5, 5); - } - public Point GetThumbnailLocation(string currentClient, string activeClient, Point defaultLocation) { Point location; @@ -220,6 +269,12 @@ namespace EveOPreview.Configuration.Implementation this.ClientHotkey[currentClient] = (new KeysConverter()).ConvertToInvariantString(hotkey); } + public Keys StringToKey(string hotkey) + { + object rawValue = (new KeysConverter()).ConvertFromInvariantString(hotkey); + return rawValue != null ? (Keys)rawValue : Keys.None; + } + public bool IsPriorityClient(string currentClient) { return this.PriorityClients.Contains(currentClient); diff --git a/src/Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs b/src/Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs index 8b97051..ae992d8 100644 --- a/src/Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs +++ b/src/Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs @@ -1,10 +1,21 @@ -using System.Drawing; +using System.Collections.Generic; +using System.Drawing; using System.Windows.Forms; namespace EveOPreview.Configuration { public interface IThumbnailConfiguration { + List CycleGroup1ForwardHotkeys { get; set; } + List CycleGroup1BackwardHotkeys { get; set; } + Dictionary CycleGroup1ClientsOrder { get; set; } + + List CycleGroup2ForwardHotkeys { get; set; } + List CycleGroup2BackwardHotkeys { get; set; } + Dictionary CycleGroup2ClientsOrder { get; set; } + + Dictionary PerClientActiveClientHighlightColor { get; set; } + bool MinimizeToTray { get; set; } int ThumbnailRefreshPeriod { get; set; } @@ -38,7 +49,8 @@ namespace EveOPreview.Configuration Color ActiveClientHighlightColor { get; set; } int ActiveClientHighlightThickness { get; set; } - Point GetDefaultThumbnailLocation(); + Point LoginThumbnailLocation { get; set; } + Point GetThumbnailLocation(string currentClient, string activeClient, Point defaultLocation); void SetThumbnailLocation(string currentClient, string activeClient, Point location); @@ -47,6 +59,7 @@ namespace EveOPreview.Configuration Keys GetClientHotkey(string currentClient); void SetClientHotkey(string currentClient, Keys hotkey); + Keys StringToKey(string hotkey); bool IsPriorityClient(string currentClient); diff --git a/src/Eve-O-Preview/Properties/AssemblyInfo.cs b/src/Eve-O-Preview/Properties/AssemblyInfo.cs index 98345fb..543d812 100644 --- a/src/Eve-O-Preview/Properties/AssemblyInfo.cs +++ b/src/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("5.1.2.0")] -[assembly: AssemblyFileVersion("5.1.2.0")] +[assembly: AssemblyVersion("6.0.0.3")] +[assembly: AssemblyFileVersion("6.0.0.3")] [assembly: CLSCompliant(false)] \ No newline at end of file diff --git a/src/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs b/src/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs index eb9b11b..cd3166b 100644 --- a/src/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs +++ b/src/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; +using System.Linq; using System.Threading.Tasks; +using System.Windows.Forms; using System.Windows.Threading; using EveOPreview.Configuration; using EveOPreview.Mediator.Messages; +using EveOPreview.UI.Hotkeys; using EveOPreview.View; using MediatR; @@ -42,6 +46,8 @@ namespace EveOPreview.Services private int _refreshCycleCount; private int _hideThumbnailsDelay; + + private List _cycleClientHotkeyHandlers = new List(); #endregion public ThumbnailManager(IMediator mediator, IThumbnailConfiguration configuration, IProcessMonitor processMonitor, IWindowManager windowManager, IThumbnailViewFactory factory) @@ -69,6 +75,109 @@ namespace EveOPreview.Services this._thumbnailUpdateTimer.Interval = new TimeSpan(0, 0, 0, 0, configuration.ThumbnailRefreshPeriod); this._hideThumbnailsDelay = this._configuration.HideThumbnailsDelay; + + RegisterCycleClientHotkey(this._configuration.CycleGroup1ForwardHotkeys?.Select(x => this._configuration.StringToKey(x)), true, this._configuration.CycleGroup1ClientsOrder); + RegisterCycleClientHotkey(this._configuration.CycleGroup1BackwardHotkeys?.Select(x => this._configuration.StringToKey(x)), false, this._configuration.CycleGroup1ClientsOrder); + + RegisterCycleClientHotkey(this._configuration.CycleGroup2ForwardHotkeys?.Select(x => this._configuration.StringToKey(x)), true, this._configuration.CycleGroup2ClientsOrder); + RegisterCycleClientHotkey(this._configuration.CycleGroup2BackwardHotkeys?.Select(x => this._configuration.StringToKey(x)), false, this._configuration.CycleGroup2ClientsOrder); + } + + public IThumbnailView GetClientByTitle(string title) + { + return _thumbnailViews.FirstOrDefault(x => x.Value.Title == title).Value; + } + + public IThumbnailView GetClientByPointer(IntPtr ptr) + { + return _thumbnailViews.FirstOrDefault(x => x.Key == ptr).Value; + } + + public IThumbnailView GetActiveClient() + { + return GetClientByPointer(this._activeClient.Handle); + } + + public void SetActive(KeyValuePair newClient) + { + this.GetActiveClient()?.ClearBorder(); + + this._windowManager.ActivateWindow(newClient.Key); + this.SwitchActiveClient(newClient.Key, newClient.Value.Title); + + newClient.Value.SetHighlight(); + newClient.Value.Refresh(true); + } + + public void CycleNextClient(bool isForwards, Dictionary cycleOrder) + { + IOrderedEnumerable> clientOrder; + if (isForwards) + { + clientOrder = cycleOrder.OrderBy(x => x.Value); + } + else + { + clientOrder = cycleOrder.OrderByDescending(x => x.Value); + } + + bool setNextClient = false; + IThumbnailView lastClient = null; + + foreach (var t in clientOrder) + { + if (t.Key == _activeClient.Title) + { + setNextClient = true; + lastClient = _thumbnailViews.FirstOrDefault(x => x.Value.Title == t.Key).Value; + continue; + } + + if (!setNextClient) + { + continue; + } + + if (_thumbnailViews.Any(x => x.Value.Title == t.Key)) + { + var ptr = _thumbnailViews.First(x => x.Value.Title == t.Key); + SetActive(ptr); + return; + } + } + + // we didn't get a next one. just get the first one from the start. + foreach (var t in clientOrder) + { + if (_thumbnailViews.Any(x => x.Value.Title == t.Key)) + { + var ptr = _thumbnailViews.First(x => x.Value.Title == t.Key); + SetActive(ptr); + _activeClient = (ptr.Key, t.Key); + return; + } + } + } + + public void RegisterCycleClientHotkey(IEnumerable keys, bool isForwards, Dictionary cycleOrder) + { + foreach (var hotkey in keys) + { + if (hotkey == Keys.None) + { + return; + } + + var newHandler = new HotkeyHandler(default(IntPtr), hotkey); + newHandler.Pressed += (object s, HandledEventArgs e) => + { + this.CycleNextClient(isForwards, cycleOrder); + e.Handled = true; + }; + + newHandler.Register(); + this._cycleClientHotkeyHandlers.Add(newHandler); + } } public void Start() @@ -108,7 +217,7 @@ namespace EveOPreview.Services view.ThumbnailLocation = this.IsManageableThumbnail(view) ? this._configuration.GetThumbnailLocation(view.Title, this._activeClient.Title, view.ThumbnailLocation) - : this._configuration.GetDefaultThumbnailLocation(); + : this._configuration.LoginThumbnailLocation; this._thumbnailViews.Add(view.Id, view); @@ -306,8 +415,9 @@ namespace EveOPreview.Services view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays; - view.SetHighlight(this._configuration.EnableActiveClientHighlight && (view.Id == this._activeClient.Handle), - this._configuration.ActiveClientHighlightColor, this._configuration.ActiveClientHighlightThickness); + view.SetHighlight( + this._configuration.EnableActiveClientHighlight && (view.Id == this._activeClient.Handle), + this._configuration.ActiveClientHighlightThickness); if (!view.IsActive) { diff --git a/src/Eve-O-Preview/Services/Implementation/WindowManager.cs b/src/Eve-O-Preview/Services/Implementation/WindowManager.cs index 80ff23c..d7f8a9f 100644 --- a/src/Eve-O-Preview/Services/Implementation/WindowManager.cs +++ b/src/Eve-O-Preview/Services/Implementation/WindowManager.cs @@ -5,7 +5,7 @@ using EveOPreview.Services.Interop; namespace EveOPreview.Services.Implementation { - sealed class WindowManager : IWindowManager + public class WindowManager : IWindowManager { #region Private constants private const int WINDOW_SIZE_THRESHOLD = 300; @@ -30,6 +30,7 @@ namespace EveOPreview.Services.Implementation public void ActivateWindow(IntPtr handle) { User32NativeMethods.SetForegroundWindow(handle); + User32NativeMethods.SetFocus(handle); int style = User32NativeMethods.GetWindowLong(handle, InteropConstants.GWL_STYLE); diff --git a/src/Eve-O-Preview/Services/Interface/IThumbnailManager.cs b/src/Eve-O-Preview/Services/Interface/IThumbnailManager.cs index 87e464b..5830516 100644 --- a/src/Eve-O-Preview/Services/Interface/IThumbnailManager.cs +++ b/src/Eve-O-Preview/Services/Interface/IThumbnailManager.cs @@ -1,4 +1,6 @@ -namespace EveOPreview.Services +using EveOPreview.View; + +namespace EveOPreview.Services { public interface IThumbnailManager { @@ -7,5 +9,9 @@ void UpdateThumbnailsSize(); void UpdateThumbnailFrames(); + + IThumbnailView GetClientByTitle(string title); + IThumbnailView GetClientByPointer(System.IntPtr ptr); + IThumbnailView GetActiveClient(); } } \ No newline at end of file diff --git a/src/Eve-O-Preview/Services/Interop/User32NativeMethods.cs b/src/Eve-O-Preview/Services/Interop/User32NativeMethods.cs index 6adc97a..d24df0a 100644 --- a/src/Eve-O-Preview/Services/Interop/User32NativeMethods.cs +++ b/src/Eve-O-Preview/Services/Interop/User32NativeMethods.cs @@ -11,6 +11,12 @@ namespace EveOPreview.Services.Interop [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr window); + [DllImport("user32.dll")] + public static extern void SetFocus(IntPtr window); + + [DllImport("user32.dll")] + public static extern void EnableWindow(IntPtr window, bool isEnabled); + [DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); diff --git a/src/Eve-O-Preview/View/Implementation/LiveThumbnailView.cs b/src/Eve-O-Preview/View/Implementation/LiveThumbnailView.cs index 487d9c1..0c4a7f9 100644 --- a/src/Eve-O-Preview/View/Implementation/LiveThumbnailView.cs +++ b/src/Eve-O-Preview/View/Implementation/LiveThumbnailView.cs @@ -1,5 +1,6 @@ using System; using System.Drawing; +using EveOPreview.Configuration; using EveOPreview.Services; namespace EveOPreview.View @@ -10,13 +11,15 @@ namespace EveOPreview.View private IDwmThumbnail _thumbnail; private Point _startLocation; private Point _endLocation; + private IThumbnailConfiguration _config; #endregion - public LiveThumbnailView(IWindowManager windowManager) - : base(windowManager) + public LiveThumbnailView(IWindowManager windowManager, IThumbnailConfiguration config, IThumbnailManager thumbnailManager) + : base(windowManager, config, thumbnailManager) { this._startLocation = new Point(0, 0); this._endLocation = new Point(this.ClientSize); + this._config = config; } protected override void RefreshThumbnail(bool forceRefresh) diff --git a/src/Eve-O-Preview/View/Implementation/StaticThumbnailView.cs b/src/Eve-O-Preview/View/Implementation/StaticThumbnailView.cs index c01ebc3..b00d4b3 100644 --- a/src/Eve-O-Preview/View/Implementation/StaticThumbnailView.cs +++ b/src/Eve-O-Preview/View/Implementation/StaticThumbnailView.cs @@ -1,6 +1,7 @@ using System; using System.Drawing; using System.Windows.Forms; +using EveOPreview.Configuration; using EveOPreview.Services; namespace EveOPreview.View @@ -9,10 +10,11 @@ namespace EveOPreview.View { #region Private fields private readonly PictureBox _thumbnail; + private IThumbnailConfiguration _config; #endregion - public StaticThumbnailView(IWindowManager windowManager) - : base(windowManager) + public StaticThumbnailView(IWindowManager windowManager, IThumbnailConfiguration config, IThumbnailManager thumbnailManager) + : base(windowManager, config, thumbnailManager) { this._thumbnail = new StaticThumbnailImage { @@ -22,6 +24,7 @@ namespace EveOPreview.View Size = new Size(this.ClientSize.Width, this.ClientSize.Height) }; this.Controls.Add(this._thumbnail); + this._config = config; } protected override void RefreshThumbnail(bool forceRefresh) diff --git a/src/Eve-O-Preview/View/Implementation/ThumbnailView.cs b/src/Eve-O-Preview/View/Implementation/ThumbnailView.cs index 87d2250..279312e 100644 --- a/src/Eve-O-Preview/View/Implementation/ThumbnailView.cs +++ b/src/Eve-O-Preview/View/Implementation/ThumbnailView.cs @@ -1,7 +1,9 @@ using System; using System.ComponentModel; using System.Drawing; +using System.Linq; using System.Windows.Forms; +using EveOPreview.Configuration; using EveOPreview.Services; using EveOPreview.UI.Hotkeys; @@ -32,7 +34,7 @@ namespace EveOPreview.View private bool _isCustomMouseModeActive; private double _opacity; - + private DateTime _suppressResizeEventsTimestamp; private Size _baseZoomSize; private Point _baseZoomLocation; @@ -40,9 +42,13 @@ namespace EveOPreview.View private Size _baseZoomMaximumSize; private HotkeyHandler _hotkeyHandler; + + private IThumbnailConfiguration _config; + private Lazy _myBorderColor; + private IThumbnailManager _thumbnailManager; #endregion - protected ThumbnailView(IWindowManager windowManager) + protected ThumbnailView(IWindowManager windowManager, IThumbnailConfiguration config, IThumbnailManager thumbnailManager) { this.SuppressResizeEvent(); @@ -66,9 +72,13 @@ namespace EveOPreview.View InitializeComponent(); this._overlay = new ThumbnailOverlay(this, this.MouseDown_Handler); + + this._config = config; + SetDefaultBorderColor(); + this._thumbnailManager = thumbnailManager; } - protected IWindowManager WindowManager { get; } + public IWindowManager WindowManager { get; } public IntPtr Id { get; set; } @@ -78,14 +88,15 @@ namespace EveOPreview.View set { this.Text = value; - this._overlay.SetOverlayLabel(value); + this._overlay.SetOverlayLabel(value.Replace("EVE - ", "")); + SetDefaultBorderColor(); } } public bool IsActive { get; set; } public bool IsOverlayEnabled { get; set; } - + public Point ThumbnailLocation { get => this.Location; @@ -114,6 +125,21 @@ namespace EveOPreview.View public Action ThumbnailDeactivated { get; set; } + public void SetDefaultBorderColor() + { + this._myBorderColor = new Lazy(() => + { + if (this._config.PerClientActiveClientHighlightColor.Any(x => x.Key == this.Title)) + { + return this._config.PerClientActiveClientHighlightColor[Title]; + } + else + { + return _config.ActiveClientHighlightColor; + } + }); + } + public new void Show() { this.SuppressResizeEvent(); @@ -219,7 +245,12 @@ namespace EveOPreview.View this._isTopMost = enableTopmost; } - public void SetHighlight(bool enabled, Color color, int width) + public void SetHighlight() + { + SetHighlight(_config.EnableActiveClientHighlight, _config.ActiveClientHighlightThickness); + } + + public void SetHighlight(bool enabled, int width) { if (this._isHighlightRequested == enabled) { @@ -230,7 +261,7 @@ namespace EveOPreview.View { this._isHighlightRequested = true; this._highlightWidth = width; - this.BackColor = color; + this.BackColor = _myBorderColor.Value; } else { @@ -241,6 +272,12 @@ namespace EveOPreview.View this._isSizeChanged = true; } + public void ClearBorder() + { + this.SetHighlight(false, 0); + this.Refresh(true); + } + public void ZoomIn(ViewZoomAnchor anchor, int zoomFactor) { int oldWidth = this._baseZoomSize.Width; @@ -475,6 +512,7 @@ namespace EveOPreview.View private void HotkeyPressed_Handler(object sender, HandledEventArgs e) { + this.SetHighlight(); this.ThumbnailActivated?.Invoke(this.Id); e.Handled = true; @@ -549,7 +587,12 @@ namespace EveOPreview.View this.ThumbnailDeactivated?.Invoke(this.Id, true); break; case MouseButtons.Left: + var oldWindow = this._thumbnailManager.GetActiveClient(); this.ThumbnailActivated?.Invoke(this.Id); + this.SetHighlight(); + this.Refresh(true); + + oldWindow?.ClearBorder(); break; case MouseButtons.Right: case MouseButtons.Left | MouseButtons.Right: diff --git a/src/Eve-O-Preview/View/Interface/IThumbnailView.cs b/src/Eve-O-Preview/View/Interface/IThumbnailView.cs index 00cac7d..07d27f1 100644 --- a/src/Eve-O-Preview/View/Interface/IThumbnailView.cs +++ b/src/Eve-O-Preview/View/Interface/IThumbnailView.cs @@ -1,6 +1,7 @@ using System; using System.Drawing; using System.Windows.Forms; +using EveOPreview.Services; namespace EveOPreview.View { @@ -20,7 +21,8 @@ namespace EveOPreview.View void SetOpacity(double opacity); void SetFrames(bool enable); void SetTopMost(bool enableTopmost); - void SetHighlight(bool enabled, Color color, int width); + void SetHighlight(); + void SetHighlight(bool enabled, int width); void ZoomIn(ViewZoomAnchor anchor, int zoomFactor); void ZoomOut(); @@ -37,5 +39,9 @@ namespace EveOPreview.View Action ThumbnailActivated { get; set; } Action ThumbnailDeactivated { get; set; } + + IWindowManager WindowManager { get; } + void SetDefaultBorderColor(); + void ClearBorder(); } } \ No newline at end of file