Merge branch 'develop'
This commit is contained in:
@@ -2,6 +2,18 @@ namespace EveOPreview.Configuration
|
||||
{
|
||||
public class ClientLayout
|
||||
{
|
||||
public ClientLayout()
|
||||
{
|
||||
}
|
||||
|
||||
public ClientLayout(int x, int y, int width, int height)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.Width = width;
|
||||
this.Height = height;
|
||||
}
|
||||
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ namespace EveOPreview.Configuration
|
||||
private const string ConfigurationFileName = "EVE-O Preview.json";
|
||||
|
||||
private readonly IAppConfig _appConfig;
|
||||
private readonly IThumbnailConfig _thumbnailConfig;
|
||||
private readonly IThumbnailConfiguration _thumbnailConfiguration;
|
||||
|
||||
public ConfigurationStorage(IAppConfig appConfig, IThumbnailConfig thumbnailConfig)
|
||||
public ConfigurationStorage(IAppConfig appConfig, IThumbnailConfiguration thumbnailConfiguration)
|
||||
{
|
||||
this._appConfig = appConfig;
|
||||
this._thumbnailConfig = thumbnailConfig;
|
||||
this._thumbnailConfiguration = thumbnailConfiguration;
|
||||
}
|
||||
|
||||
public void Load()
|
||||
@@ -28,16 +28,20 @@ namespace EveOPreview.Configuration
|
||||
|
||||
string rawData = File.ReadAllText(filename);
|
||||
|
||||
JsonConvert.PopulateObject(rawData, this._thumbnailConfig);
|
||||
JsonConvert.PopulateObject(rawData, this._thumbnailConfiguration);
|
||||
|
||||
// Validate data after loading it
|
||||
this._thumbnailConfig.ApplyRestrictions();
|
||||
this._thumbnailConfiguration.ApplyRestrictions();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
string rawData = JsonConvert.SerializeObject(this._thumbnailConfig, Formatting.Indented);
|
||||
string filename = this.GetConfigFileName();
|
||||
=======
|
||||
string rawData = JsonConvert.SerializeObject(this._thumbnailConfiguration, Formatting.Indented);
|
||||
>>>>>>> develop
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -3,12 +3,24 @@ using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace EveOPreview.Configuration
|
||||
namespace EveOPreview.Configuration.Omplementation
|
||||
{
|
||||
class ThumbnailConfig : IThumbnailConfig
|
||||
sealed class ThumbnailConfiguration : IThumbnailConfiguration
|
||||
{
|
||||
public ThumbnailConfig()
|
||||
#region Private fields
|
||||
private bool _enablePerClientThumbnailLayouts;
|
||||
private bool _enableClientLayoutTracking;
|
||||
#endregion
|
||||
|
||||
public ThumbnailConfiguration()
|
||||
{
|
||||
this.PerClientLayout = new Dictionary<string, Dictionary<string, Point>>();
|
||||
this.FlatLayout = new Dictionary<string, Point>();
|
||||
this.ClientLayout = new Dictionary<string, ClientLayout>();
|
||||
this.ClientHotkey = new Dictionary<string, string>();
|
||||
this.DisableThumbnail = new Dictionary<string, bool>();
|
||||
this.PriorityClients = new List<string>();
|
||||
|
||||
this.MinimizeToTray = false;
|
||||
this.ThumbnailRefreshPeriod = 500;
|
||||
|
||||
@@ -16,29 +28,27 @@ namespace EveOPreview.Configuration
|
||||
|
||||
this.EnableClientLayoutTracking = false;
|
||||
this.HideActiveClientThumbnail = false;
|
||||
this.MinimizeInactiveClients = false;
|
||||
this.ShowThumbnailsAlwaysOnTop = true;
|
||||
this.HideThumbnailsOnLostFocus = false;
|
||||
this.EnablePerClientThumbnailLayouts = false;
|
||||
|
||||
this.ThumbnailSize = new Size(250, 150);
|
||||
this.ThumbnailMinimumSize = new Size(100, 80);
|
||||
this.ThumbnailMaximumSize = new Size(640, 400);
|
||||
this.ThumbnailSize = new Size(384, 216);
|
||||
this.ThumbnailMinimumSize = new Size(192, 108);
|
||||
this.ThumbnailMaximumSize = new Size(960, 540);
|
||||
|
||||
this.EnableThumbnailSnap = true;
|
||||
|
||||
this.ThumbnailZoomEnabled = false;
|
||||
this.ThumbnailZoomFactor = 2;
|
||||
this.ThumbnailZoomAnchor = ZoomAnchor.NW;
|
||||
|
||||
this.ShowThumbnailOverlays = true;
|
||||
this.ShowThumbnailFrames = true;
|
||||
this.ShowThumbnailFrames = false;
|
||||
|
||||
this.EnableActiveClientHighlight = false;
|
||||
this.ActiveClientHighlightColor = Color.GreenYellow;
|
||||
this.ActiveClientHighlightThickness = 3;
|
||||
|
||||
this.PerClientLayout = new Dictionary<string, Dictionary<string, Point>>();
|
||||
this.FlatLayout = new Dictionary<string, Point>();
|
||||
this.ClientLayout = new Dictionary<string, ClientLayout>();
|
||||
this.ClientHotkey = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public bool MinimizeToTray { get; set; }
|
||||
@@ -47,16 +57,45 @@ namespace EveOPreview.Configuration
|
||||
[JsonProperty("ThumbnailsOpacity")]
|
||||
public double ThumbnailOpacity { get; set; }
|
||||
|
||||
public bool EnableClientLayoutTracking { get; set; }
|
||||
public bool EnableClientLayoutTracking
|
||||
{
|
||||
get => this._enableClientLayoutTracking;
|
||||
set
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
this.ClientLayout.Clear();
|
||||
}
|
||||
|
||||
this._enableClientLayoutTracking = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HideActiveClientThumbnail { get; set; }
|
||||
public bool MinimizeInactiveClients { get; set; }
|
||||
public bool ShowThumbnailsAlwaysOnTop { get; set; }
|
||||
public bool HideThumbnailsOnLostFocus { get; set; }
|
||||
public bool EnablePerClientThumbnailLayouts { get; set; }
|
||||
|
||||
public bool EnablePerClientThumbnailLayouts
|
||||
{
|
||||
get => this._enablePerClientThumbnailLayouts;
|
||||
set
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
this.PerClientLayout.Clear();
|
||||
}
|
||||
|
||||
this._enablePerClientThumbnailLayouts = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Size ThumbnailSize { get; set; }
|
||||
public Size ThumbnailMaximumSize { get; set; }
|
||||
public Size ThumbnailMinimumSize { get; set; }
|
||||
|
||||
public bool EnableThumbnailSnap { get; set; }
|
||||
|
||||
[JsonProperty("EnableThumbnailZoom")]
|
||||
public bool ThumbnailZoomEnabled { get; set; }
|
||||
public int ThumbnailZoomFactor { get; set; }
|
||||
@@ -79,6 +118,10 @@ namespace EveOPreview.Configuration
|
||||
private Dictionary<string, ClientLayout> ClientLayout { get; set; }
|
||||
[JsonProperty]
|
||||
private Dictionary<string, string> ClientHotkey { get; set; }
|
||||
[JsonProperty]
|
||||
private Dictionary<string, bool> DisableThumbnail { get; set; }
|
||||
[JsonProperty]
|
||||
private List<string> PriorityClients { get; set; }
|
||||
|
||||
public Point GetDefaultThumbnailLocation()
|
||||
{
|
||||
@@ -168,17 +211,32 @@ namespace EveOPreview.Configuration
|
||||
this.ClientHotkey[currentClient] = (new KeysConverter()).ConvertToInvariantString(hotkey);
|
||||
}
|
||||
|
||||
public bool IsPriorityClient(string currentClient)
|
||||
{
|
||||
return this.PriorityClients.Contains(currentClient);
|
||||
}
|
||||
|
||||
public bool IsThumbnailDisabled(string currentClient)
|
||||
{
|
||||
return this.DisableThumbnail.TryGetValue(currentClient, out bool isDisabled) && isDisabled;
|
||||
}
|
||||
|
||||
public void ToggleThumbnail(string currentClient, bool isDisabled)
|
||||
{
|
||||
this.DisableThumbnail[currentClient] = isDisabled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies restrictions to different parameters of the config
|
||||
/// </summary>
|
||||
public void ApplyRestrictions()
|
||||
{
|
||||
this.ThumbnailRefreshPeriod = ThumbnailConfig.ApplyRestrictions(this.ThumbnailRefreshPeriod, 300, 1000);
|
||||
this.ThumbnailSize = new Size(ThumbnailConfig.ApplyRestrictions(this.ThumbnailSize.Width, this.ThumbnailMinimumSize.Width, this.ThumbnailMaximumSize.Width),
|
||||
ThumbnailConfig.ApplyRestrictions(this.ThumbnailSize.Height, this.ThumbnailMinimumSize.Height, this.ThumbnailMaximumSize.Height));
|
||||
this.ThumbnailOpacity = ThumbnailConfig.ApplyRestrictions((int)(this.ThumbnailOpacity * 100.00), 20, 100) / 100.00;
|
||||
this.ThumbnailZoomFactor = ThumbnailConfig.ApplyRestrictions(this.ThumbnailZoomFactor, 2, 10);
|
||||
this.ActiveClientHighlightThickness = ThumbnailConfig.ApplyRestrictions(this.ActiveClientHighlightThickness, 1, 6);
|
||||
this.ThumbnailRefreshPeriod = ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailRefreshPeriod, 300, 1000);
|
||||
this.ThumbnailSize = new Size(ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailSize.Width, this.ThumbnailMinimumSize.Width, this.ThumbnailMaximumSize.Width),
|
||||
ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailSize.Height, this.ThumbnailMinimumSize.Height, this.ThumbnailMaximumSize.Height));
|
||||
this.ThumbnailOpacity = ThumbnailConfiguration.ApplyRestrictions((int)(this.ThumbnailOpacity * 100.00), 20, 100) / 100.00;
|
||||
this.ThumbnailZoomFactor = ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailZoomFactor, 2, 10);
|
||||
this.ActiveClientHighlightThickness = ThumbnailConfiguration.ApplyRestrictions(this.ActiveClientHighlightThickness, 1, 6);
|
||||
}
|
||||
|
||||
private static int ApplyRestrictions(int value, int minimum, int maximum)
|
||||
@@ -3,10 +3,7 @@ using System.Windows.Forms;
|
||||
|
||||
namespace EveOPreview.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Thumbnails Manager configuration
|
||||
/// </summary>
|
||||
public interface IThumbnailConfig
|
||||
public interface IThumbnailConfiguration
|
||||
{
|
||||
bool MinimizeToTray { get; set; }
|
||||
int ThumbnailRefreshPeriod { get; set; }
|
||||
@@ -15,6 +12,7 @@ namespace EveOPreview.Configuration
|
||||
|
||||
bool EnableClientLayoutTracking { get; set; }
|
||||
bool HideActiveClientThumbnail { get; set; }
|
||||
bool MinimizeInactiveClients { get; set; }
|
||||
bool ShowThumbnailsAlwaysOnTop { get; set; }
|
||||
bool HideThumbnailsOnLostFocus { get; set; }
|
||||
bool EnablePerClientThumbnailLayouts { get; set; }
|
||||
@@ -23,6 +21,8 @@ namespace EveOPreview.Configuration
|
||||
Size ThumbnailMinimumSize { get; set; }
|
||||
Size ThumbnailMaximumSize { get; set; }
|
||||
|
||||
bool EnableThumbnailSnap { get; set; }
|
||||
|
||||
bool ThumbnailZoomEnabled { get; set; }
|
||||
int ThumbnailZoomFactor { get; set; }
|
||||
ZoomAnchor ThumbnailZoomAnchor { get; set; }
|
||||
@@ -44,6 +44,11 @@ namespace EveOPreview.Configuration
|
||||
Keys GetClientHotkey(string currentClient);
|
||||
void SetClientHotkey(string currentClient, Keys hotkey);
|
||||
|
||||
bool IsPriorityClient(string currentClient);
|
||||
|
||||
bool IsThumbnailDisabled(string currentClient);
|
||||
void ToggleThumbnail(string currentClient, bool isDisabled);
|
||||
|
||||
void ApplyRestrictions();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user