Merge pull request #1 from Proopai/beta

Beta to Master for Hotkey Cycles
This commit is contained in:
Eric
2024-10-04 16:28:00 -05:00
committed by GitHub
13 changed files with 354 additions and 30 deletions

View File

@@ -165,6 +165,77 @@ The following hotkey is described as `modifier+key` where `modifier` can be **Co
<div style="page-break-after: always;"></div> <div style="page-break-after: always;"></div>
### 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 ### 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: 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:

View File

@@ -27,7 +27,14 @@ namespace EveOPreview.Configuration.Implementation
string rawData = File.ReadAllText(filename); 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 // Validate data after loading it
this._thumbnailConfiguration.ApplyRestrictions(); this._thumbnailConfiguration.ApplyRestrictions();

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -14,6 +15,32 @@ namespace EveOPreview.Configuration.Implementation
public ThumbnailConfiguration() public ThumbnailConfiguration()
{ {
this.ConfigVersion = 1;
this.CycleGroup1ForwardHotkeys = new List<string> { "F14", "Control+F14" };
this.CycleGroup1BackwardHotkeys = new List<string> { "F13", "Control+F13" };
this.CycleGroup1ClientsOrder = new Dictionary<string, int>
{
{ "EVE - Example DPS Toon 1", 1 },
{ "EVE - Example DPS Toon 2", 2 },
{ "EVE - Example DPS Toon 3", 3 }
};
this.CycleGroup2ForwardHotkeys = new List<string> { "F16", "Control+F16" };
this.CycleGroup2BackwardHotkeys = new List<string> { "F15", "Control+F15" };
this.CycleGroup2ClientsOrder = new Dictionary<string, int>
{
{ "EVE - Example Logi Toon 1", 1 },
{ "EVE - Example Scout Toon 2", 2 },
{ "EVE - Example Tackle Toon 3", 3 }
};
this.PerClientActiveClientHighlightColor = new Dictionary<string, Color>
{
{"EVE - Example Toon 1", Color.Red},
{"EVE - Example Toon 2", Color.Green}
};
this.PerClientLayout = new Dictionary<string, Dictionary<string, Point>>(); this.PerClientLayout = new Dictionary<string, Dictionary<string, Point>>();
this.FlatLayout = new Dictionary<string, Point>(); this.FlatLayout = new Dictionary<string, Point>();
this.ClientLayout = new Dictionary<string, ClientLayout>(); this.ClientLayout = new Dictionary<string, ClientLayout>();
@@ -53,8 +80,35 @@ namespace EveOPreview.Configuration.Implementation
this.EnableActiveClientHighlight = false; this.EnableActiveClientHighlight = false;
this.ActiveClientHighlightColor = Color.GreenYellow; this.ActiveClientHighlightColor = Color.GreenYellow;
this.ActiveClientHighlightThickness = 3; this.ActiveClientHighlightThickness = 3;
this.LoginThumbnailLocation = new Point(5, 5);
} }
[JsonProperty("ConfigVersion")]
public int ConfigVersion { get; set; }
[JsonProperty("CycleGroup1ForwardHotkeys")]
public List<string> CycleGroup1ForwardHotkeys { get; set; }
[JsonProperty("CycleGroup1BackwardHotkeys")]
public List<string> CycleGroup1BackwardHotkeys { get; set; }
[JsonProperty("CycleGroup1ClientsOrder")]
public Dictionary<string, int> CycleGroup1ClientsOrder { get; set; }
[JsonProperty("CycleGroup2ForwardHotkeys")]
public List<string> CycleGroup2ForwardHotkeys { get; set; }
[JsonProperty("CycleGroup2BackwardHotkeys")]
public List<string> CycleGroup2BackwardHotkeys { get; set; }
[JsonProperty("CycleGroup2ClientsOrder")]
public Dictionary<string, int> CycleGroup2ClientsOrder { get; set; }
[JsonProperty("PerClientActiveClientHighlightColor")]
public Dictionary<string, Color> PerClientActiveClientHighlightColor { get; set; }
public bool MinimizeToTray { get; set; } public bool MinimizeToTray { get; set; }
public int ThumbnailRefreshPeriod { get; set; } public int ThumbnailRefreshPeriod { get; set; }
@@ -119,6 +173,9 @@ namespace EveOPreview.Configuration.Implementation
public int ActiveClientHighlightThickness { get; set; } public int ActiveClientHighlightThickness { get; set; }
[JsonProperty("LoginThumbnailLocation")]
public Point LoginThumbnailLocation { get; set; }
[JsonProperty] [JsonProperty]
private Dictionary<string, Dictionary<string, Point>> PerClientLayout { get; set; } private Dictionary<string, Dictionary<string, Point>> PerClientLayout { get; set; }
[JsonProperty] [JsonProperty]
@@ -132,14 +189,6 @@ namespace EveOPreview.Configuration.Implementation
[JsonProperty] [JsonProperty]
private List<string> PriorityClients { get; set; } private List<string> 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) public Point GetThumbnailLocation(string currentClient, string activeClient, Point defaultLocation)
{ {
Point location; Point location;
@@ -220,6 +269,12 @@ namespace EveOPreview.Configuration.Implementation
this.ClientHotkey[currentClient] = (new KeysConverter()).ConvertToInvariantString(hotkey); 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) public bool IsPriorityClient(string currentClient)
{ {
return this.PriorityClients.Contains(currentClient); return this.PriorityClients.Contains(currentClient);

View File

@@ -1,10 +1,21 @@
using System.Drawing; using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
namespace EveOPreview.Configuration namespace EveOPreview.Configuration
{ {
public interface IThumbnailConfiguration public interface IThumbnailConfiguration
{ {
List<string> CycleGroup1ForwardHotkeys { get; set; }
List<string> CycleGroup1BackwardHotkeys { get; set; }
Dictionary<string, int> CycleGroup1ClientsOrder { get; set; }
List<string> CycleGroup2ForwardHotkeys { get; set; }
List<string> CycleGroup2BackwardHotkeys { get; set; }
Dictionary<string, int> CycleGroup2ClientsOrder { get; set; }
Dictionary<string, Color> PerClientActiveClientHighlightColor { get; set; }
bool MinimizeToTray { get; set; } bool MinimizeToTray { get; set; }
int ThumbnailRefreshPeriod { get; set; } int ThumbnailRefreshPeriod { get; set; }
@@ -38,7 +49,8 @@ namespace EveOPreview.Configuration
Color ActiveClientHighlightColor { get; set; } Color ActiveClientHighlightColor { get; set; }
int ActiveClientHighlightThickness { get; set; } int ActiveClientHighlightThickness { get; set; }
Point GetDefaultThumbnailLocation(); Point LoginThumbnailLocation { get; set; }
Point GetThumbnailLocation(string currentClient, string activeClient, Point defaultLocation); Point GetThumbnailLocation(string currentClient, string activeClient, Point defaultLocation);
void SetThumbnailLocation(string currentClient, string activeClient, Point location); void SetThumbnailLocation(string currentClient, string activeClient, Point location);
@@ -47,6 +59,7 @@ namespace EveOPreview.Configuration
Keys GetClientHotkey(string currentClient); Keys GetClientHotkey(string currentClient);
void SetClientHotkey(string currentClient, Keys hotkey); void SetClientHotkey(string currentClient, Keys hotkey);
Keys StringToKey(string hotkey);
bool IsPriorityClient(string currentClient); bool IsPriorityClient(string currentClient);

View File

@@ -12,7 +12,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: Guid("04f08f8d-9e98-423b-acdb-4effb31c0d35")] [assembly: Guid("04f08f8d-9e98-423b-acdb-4effb31c0d35")]
[assembly: AssemblyVersion("5.1.2.0")] [assembly: AssemblyVersion("6.0.0.3")]
[assembly: AssemblyFileVersion("5.1.2.0")] [assembly: AssemblyFileVersion("6.0.0.3")]
[assembly: CLSCompliant(false)] [assembly: CLSCompliant(false)]

View File

@@ -1,10 +1,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Threading; using System.Windows.Threading;
using EveOPreview.Configuration; using EveOPreview.Configuration;
using EveOPreview.Mediator.Messages; using EveOPreview.Mediator.Messages;
using EveOPreview.UI.Hotkeys;
using EveOPreview.View; using EveOPreview.View;
using MediatR; using MediatR;
@@ -42,6 +46,8 @@ namespace EveOPreview.Services
private int _refreshCycleCount; private int _refreshCycleCount;
private int _hideThumbnailsDelay; private int _hideThumbnailsDelay;
private List<HotkeyHandler> _cycleClientHotkeyHandlers = new List<HotkeyHandler>();
#endregion #endregion
public ThumbnailManager(IMediator mediator, IThumbnailConfiguration configuration, IProcessMonitor processMonitor, IWindowManager windowManager, IThumbnailViewFactory factory) 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._thumbnailUpdateTimer.Interval = new TimeSpan(0, 0, 0, 0, configuration.ThumbnailRefreshPeriod);
this._hideThumbnailsDelay = this._configuration.HideThumbnailsDelay; 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<IntPtr, IThumbnailView> 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<string, int> cycleOrder)
{
IOrderedEnumerable<KeyValuePair<string, int>> 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> keys, bool isForwards, Dictionary<string, int> 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() public void Start()
@@ -108,7 +217,7 @@ namespace EveOPreview.Services
view.ThumbnailLocation = this.IsManageableThumbnail(view) view.ThumbnailLocation = this.IsManageableThumbnail(view)
? this._configuration.GetThumbnailLocation(view.Title, this._activeClient.Title, view.ThumbnailLocation) ? this._configuration.GetThumbnailLocation(view.Title, this._activeClient.Title, view.ThumbnailLocation)
: this._configuration.GetDefaultThumbnailLocation(); : this._configuration.LoginThumbnailLocation;
this._thumbnailViews.Add(view.Id, view); this._thumbnailViews.Add(view.Id, view);
@@ -306,8 +415,9 @@ namespace EveOPreview.Services
view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays; view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays;
view.SetHighlight(this._configuration.EnableActiveClientHighlight && (view.Id == this._activeClient.Handle), view.SetHighlight(
this._configuration.ActiveClientHighlightColor, this._configuration.ActiveClientHighlightThickness); this._configuration.EnableActiveClientHighlight && (view.Id == this._activeClient.Handle),
this._configuration.ActiveClientHighlightThickness);
if (!view.IsActive) if (!view.IsActive)
{ {

View File

@@ -5,7 +5,7 @@ using EveOPreview.Services.Interop;
namespace EveOPreview.Services.Implementation namespace EveOPreview.Services.Implementation
{ {
sealed class WindowManager : IWindowManager public class WindowManager : IWindowManager
{ {
#region Private constants #region Private constants
private const int WINDOW_SIZE_THRESHOLD = 300; private const int WINDOW_SIZE_THRESHOLD = 300;
@@ -30,6 +30,7 @@ namespace EveOPreview.Services.Implementation
public void ActivateWindow(IntPtr handle) public void ActivateWindow(IntPtr handle)
{ {
User32NativeMethods.SetForegroundWindow(handle); User32NativeMethods.SetForegroundWindow(handle);
User32NativeMethods.SetFocus(handle);
int style = User32NativeMethods.GetWindowLong(handle, InteropConstants.GWL_STYLE); int style = User32NativeMethods.GetWindowLong(handle, InteropConstants.GWL_STYLE);

View File

@@ -1,4 +1,6 @@
namespace EveOPreview.Services using EveOPreview.View;
namespace EveOPreview.Services
{ {
public interface IThumbnailManager public interface IThumbnailManager
{ {
@@ -7,5 +9,9 @@
void UpdateThumbnailsSize(); void UpdateThumbnailsSize();
void UpdateThumbnailFrames(); void UpdateThumbnailFrames();
IThumbnailView GetClientByTitle(string title);
IThumbnailView GetClientByPointer(System.IntPtr ptr);
IThumbnailView GetActiveClient();
} }
} }

View File

@@ -11,6 +11,12 @@ namespace EveOPreview.Services.Interop
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr window); 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")] [DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Drawing; using System.Drawing;
using EveOPreview.Configuration;
using EveOPreview.Services; using EveOPreview.Services;
namespace EveOPreview.View namespace EveOPreview.View
@@ -10,13 +11,15 @@ namespace EveOPreview.View
private IDwmThumbnail _thumbnail; private IDwmThumbnail _thumbnail;
private Point _startLocation; private Point _startLocation;
private Point _endLocation; private Point _endLocation;
private IThumbnailConfiguration _config;
#endregion #endregion
public LiveThumbnailView(IWindowManager windowManager) public LiveThumbnailView(IWindowManager windowManager, IThumbnailConfiguration config, IThumbnailManager thumbnailManager)
: base(windowManager) : base(windowManager, config, thumbnailManager)
{ {
this._startLocation = new Point(0, 0); this._startLocation = new Point(0, 0);
this._endLocation = new Point(this.ClientSize); this._endLocation = new Point(this.ClientSize);
this._config = config;
} }
protected override void RefreshThumbnail(bool forceRefresh) protected override void RefreshThumbnail(bool forceRefresh)

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using EveOPreview.Configuration;
using EveOPreview.Services; using EveOPreview.Services;
namespace EveOPreview.View namespace EveOPreview.View
@@ -9,10 +10,11 @@ namespace EveOPreview.View
{ {
#region Private fields #region Private fields
private readonly PictureBox _thumbnail; private readonly PictureBox _thumbnail;
private IThumbnailConfiguration _config;
#endregion #endregion
public StaticThumbnailView(IWindowManager windowManager) public StaticThumbnailView(IWindowManager windowManager, IThumbnailConfiguration config, IThumbnailManager thumbnailManager)
: base(windowManager) : base(windowManager, config, thumbnailManager)
{ {
this._thumbnail = new StaticThumbnailImage this._thumbnail = new StaticThumbnailImage
{ {
@@ -22,6 +24,7 @@ namespace EveOPreview.View
Size = new Size(this.ClientSize.Width, this.ClientSize.Height) Size = new Size(this.ClientSize.Width, this.ClientSize.Height)
}; };
this.Controls.Add(this._thumbnail); this.Controls.Add(this._thumbnail);
this._config = config;
} }
protected override void RefreshThumbnail(bool forceRefresh) protected override void RefreshThumbnail(bool forceRefresh)

View File

@@ -1,7 +1,9 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using EveOPreview.Configuration;
using EveOPreview.Services; using EveOPreview.Services;
using EveOPreview.UI.Hotkeys; using EveOPreview.UI.Hotkeys;
@@ -32,7 +34,7 @@ namespace EveOPreview.View
private bool _isCustomMouseModeActive; private bool _isCustomMouseModeActive;
private double _opacity; private double _opacity;
private DateTime _suppressResizeEventsTimestamp; private DateTime _suppressResizeEventsTimestamp;
private Size _baseZoomSize; private Size _baseZoomSize;
private Point _baseZoomLocation; private Point _baseZoomLocation;
@@ -40,9 +42,13 @@ namespace EveOPreview.View
private Size _baseZoomMaximumSize; private Size _baseZoomMaximumSize;
private HotkeyHandler _hotkeyHandler; private HotkeyHandler _hotkeyHandler;
private IThumbnailConfiguration _config;
private Lazy<Color> _myBorderColor;
private IThumbnailManager _thumbnailManager;
#endregion #endregion
protected ThumbnailView(IWindowManager windowManager) protected ThumbnailView(IWindowManager windowManager, IThumbnailConfiguration config, IThumbnailManager thumbnailManager)
{ {
this.SuppressResizeEvent(); this.SuppressResizeEvent();
@@ -66,9 +72,13 @@ namespace EveOPreview.View
InitializeComponent(); InitializeComponent();
this._overlay = new ThumbnailOverlay(this, this.MouseDown_Handler); 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; } public IntPtr Id { get; set; }
@@ -78,14 +88,15 @@ namespace EveOPreview.View
set set
{ {
this.Text = value; this.Text = value;
this._overlay.SetOverlayLabel(value); this._overlay.SetOverlayLabel(value.Replace("EVE - ", ""));
SetDefaultBorderColor();
} }
} }
public bool IsActive { get; set; } public bool IsActive { get; set; }
public bool IsOverlayEnabled { get; set; } public bool IsOverlayEnabled { get; set; }
public Point ThumbnailLocation public Point ThumbnailLocation
{ {
get => this.Location; get => this.Location;
@@ -114,6 +125,21 @@ namespace EveOPreview.View
public Action<IntPtr, bool> ThumbnailDeactivated { get; set; } public Action<IntPtr, bool> ThumbnailDeactivated { get; set; }
public void SetDefaultBorderColor()
{
this._myBorderColor = new Lazy<Color>(() =>
{
if (this._config.PerClientActiveClientHighlightColor.Any(x => x.Key == this.Title))
{
return this._config.PerClientActiveClientHighlightColor[Title];
}
else
{
return _config.ActiveClientHighlightColor;
}
});
}
public new void Show() public new void Show()
{ {
this.SuppressResizeEvent(); this.SuppressResizeEvent();
@@ -219,7 +245,12 @@ namespace EveOPreview.View
this._isTopMost = enableTopmost; 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) if (this._isHighlightRequested == enabled)
{ {
@@ -230,7 +261,7 @@ namespace EveOPreview.View
{ {
this._isHighlightRequested = true; this._isHighlightRequested = true;
this._highlightWidth = width; this._highlightWidth = width;
this.BackColor = color; this.BackColor = _myBorderColor.Value;
} }
else else
{ {
@@ -241,6 +272,12 @@ namespace EveOPreview.View
this._isSizeChanged = true; this._isSizeChanged = true;
} }
public void ClearBorder()
{
this.SetHighlight(false, 0);
this.Refresh(true);
}
public void ZoomIn(ViewZoomAnchor anchor, int zoomFactor) public void ZoomIn(ViewZoomAnchor anchor, int zoomFactor)
{ {
int oldWidth = this._baseZoomSize.Width; int oldWidth = this._baseZoomSize.Width;
@@ -475,6 +512,7 @@ namespace EveOPreview.View
private void HotkeyPressed_Handler(object sender, HandledEventArgs e) private void HotkeyPressed_Handler(object sender, HandledEventArgs e)
{ {
this.SetHighlight();
this.ThumbnailActivated?.Invoke(this.Id); this.ThumbnailActivated?.Invoke(this.Id);
e.Handled = true; e.Handled = true;
@@ -549,7 +587,12 @@ namespace EveOPreview.View
this.ThumbnailDeactivated?.Invoke(this.Id, true); this.ThumbnailDeactivated?.Invoke(this.Id, true);
break; break;
case MouseButtons.Left: case MouseButtons.Left:
var oldWindow = this._thumbnailManager.GetActiveClient();
this.ThumbnailActivated?.Invoke(this.Id); this.ThumbnailActivated?.Invoke(this.Id);
this.SetHighlight();
this.Refresh(true);
oldWindow?.ClearBorder();
break; break;
case MouseButtons.Right: case MouseButtons.Right:
case MouseButtons.Left | MouseButtons.Right: case MouseButtons.Left | MouseButtons.Right:

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using EveOPreview.Services;
namespace EveOPreview.View namespace EveOPreview.View
{ {
@@ -20,7 +21,8 @@ namespace EveOPreview.View
void SetOpacity(double opacity); void SetOpacity(double opacity);
void SetFrames(bool enable); void SetFrames(bool enable);
void SetTopMost(bool enableTopmost); 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 ZoomIn(ViewZoomAnchor anchor, int zoomFactor);
void ZoomOut(); void ZoomOut();
@@ -37,5 +39,9 @@ namespace EveOPreview.View
Action<IntPtr> ThumbnailActivated { get; set; } Action<IntPtr> ThumbnailActivated { get; set; }
Action<IntPtr, bool> ThumbnailDeactivated { get; set; } Action<IntPtr, bool> ThumbnailDeactivated { get; set; }
IWindowManager WindowManager { get; }
void SetDefaultBorderColor();
void ClearBorder();
} }
} }