Update configuration system to use JSON
This commit is contained in:
53
Eve-O-Preview/Configuration/ApplicationConfiguration.cs
Normal file
53
Eve-O-Preview/Configuration/ApplicationConfiguration.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
namespace EveOPreview.Configuration
|
||||
{
|
||||
public class ApplicationConfiguration : IApplicationConfiguration
|
||||
{
|
||||
public ApplicationConfiguration()
|
||||
{
|
||||
// Default values
|
||||
this.MinimizeToTray = true;
|
||||
this.ThumbnailRefreshPeriod = 500;
|
||||
|
||||
this.ThumbnailsOpacity = 0.5;
|
||||
|
||||
this.EnableClientsLocationTracking = false;
|
||||
this.HideActiveClientThumbnail = false;
|
||||
this.ShowThumbnailsAlwaysOnTop = true;
|
||||
this.HideThumbnailsOnLostFocus = false;
|
||||
this.EnablePerClientThumbnailsLayouts = false;
|
||||
|
||||
this.SyncThumbnailsSize = true;
|
||||
this.ThumbnailsWidth = 250;
|
||||
this.ThumbnailsHeight = 150;
|
||||
|
||||
this.EnableThumbnailZoom = false;
|
||||
this.ThumbnailZoomFactor = 2;
|
||||
this.ThumbnailZoomAnchor = ZoomAnchor.NW;
|
||||
|
||||
this.ShowThumbnailOverlays = true;
|
||||
this.ShowThumbnailFrames = true;
|
||||
}
|
||||
|
||||
public bool MinimizeToTray { get; set; }
|
||||
public int ThumbnailRefreshPeriod { get; set; }
|
||||
|
||||
public double ThumbnailsOpacity { get; set; }
|
||||
|
||||
public bool EnableClientsLocationTracking { get; set; }
|
||||
public bool HideActiveClientThumbnail { get; set; }
|
||||
public bool ShowThumbnailsAlwaysOnTop { get; set; }
|
||||
public bool HideThumbnailsOnLostFocus { get; set; }
|
||||
public bool EnablePerClientThumbnailsLayouts { get; set; }
|
||||
|
||||
public bool SyncThumbnailsSize { get; set; }
|
||||
public int ThumbnailsWidth { get; set; }
|
||||
public int ThumbnailsHeight { get; set; }
|
||||
|
||||
public bool EnableThumbnailZoom { get; set; }
|
||||
public int ThumbnailZoomFactor { get; set; }
|
||||
public ZoomAnchor ThumbnailZoomAnchor { get; set; }
|
||||
|
||||
public bool ShowThumbnailOverlays { get; set; }
|
||||
public bool ShowThumbnailFrames { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace EveOPreview.Configuration
|
||||
{
|
||||
public class Configuration
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,36 @@
|
||||
namespace EveOPreview.Configuration
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace EveOPreview.Configuration
|
||||
{
|
||||
public class ConfigurationStorage
|
||||
public class ConfigurationStorage : IConfigurationStorage
|
||||
{
|
||||
|
||||
private const string ConfigurationFileName = "EVE-O Preview.json";
|
||||
|
||||
private readonly IApplicationConfiguration _configuration;
|
||||
|
||||
public ConfigurationStorage(IApplicationConfiguration configuration)
|
||||
{
|
||||
this._configuration = configuration;
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
if (!File.Exists(ConfigurationStorage.ConfigurationFileName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string rawData = File.ReadAllText(ConfigurationStorage.ConfigurationFileName);
|
||||
|
||||
JsonConvert.PopulateObject(rawData, this._configuration);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
string rawData = JsonConvert.SerializeObject(this._configuration, Formatting.Indented);
|
||||
|
||||
File.WriteAllText(ConfigurationStorage.ConfigurationFileName, rawData);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Eve-O-Preview/Configuration/IApplicationConfiguration.cs
Normal file
27
Eve-O-Preview/Configuration/IApplicationConfiguration.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
namespace EveOPreview.Configuration
|
||||
{
|
||||
public interface IApplicationConfiguration
|
||||
{
|
||||
bool MinimizeToTray { get; set; }
|
||||
int ThumbnailRefreshPeriod { get; set; }
|
||||
|
||||
double ThumbnailsOpacity { get; set; }
|
||||
|
||||
bool EnableClientsLocationTracking { get; set; }
|
||||
bool HideActiveClientThumbnail { get; set; }
|
||||
bool ShowThumbnailsAlwaysOnTop { get; set; }
|
||||
bool HideThumbnailsOnLostFocus { get; set; }
|
||||
bool EnablePerClientThumbnailsLayouts { get; set; }
|
||||
|
||||
bool SyncThumbnailsSize { get; set; }
|
||||
int ThumbnailsWidth { get; set; }
|
||||
int ThumbnailsHeight { get; set; }
|
||||
|
||||
bool EnableThumbnailZoom { get; set; }
|
||||
int ThumbnailZoomFactor { get; set; }
|
||||
ZoomAnchor ThumbnailZoomAnchor { get; set; }
|
||||
|
||||
bool ShowThumbnailOverlays { get; set; }
|
||||
bool ShowThumbnailFrames { get; set; }
|
||||
}
|
||||
}
|
||||
8
Eve-O-Preview/Configuration/IConfigurationStorage.cs
Normal file
8
Eve-O-Preview/Configuration/IConfigurationStorage.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace EveOPreview.Configuration
|
||||
{
|
||||
public interface IConfigurationStorage
|
||||
{
|
||||
void Load();
|
||||
void Save();
|
||||
}
|
||||
}
|
||||
15
Eve-O-Preview/Configuration/ZoomAnchor.cs
Normal file
15
Eve-O-Preview/Configuration/ZoomAnchor.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace EveOPreview.Configuration
|
||||
{
|
||||
public enum ZoomAnchor
|
||||
{
|
||||
NW,
|
||||
N,
|
||||
NE,
|
||||
W,
|
||||
C,
|
||||
E,
|
||||
SW,
|
||||
S,
|
||||
SE
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user