posizione Testo
This commit is contained in:
parent
a2dca4b750
commit
922315061d
5 changed files with 285 additions and 27 deletions
|
|
@ -6,7 +6,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using MaddoLibrary.Base.Log;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace CatalogLib
|
||||
|
|
@ -71,6 +71,11 @@ namespace CatalogLib
|
|||
SetBase(key, value);
|
||||
}
|
||||
|
||||
public void SetFloat(string key, float value)
|
||||
{
|
||||
SetBase(key, value);
|
||||
}
|
||||
|
||||
public void Set<T>(string key, T value)
|
||||
{
|
||||
SetBase(key, value);
|
||||
|
|
@ -134,6 +139,23 @@ namespace CatalogLib
|
|||
return (double)_settingsDict[key];
|
||||
}
|
||||
|
||||
public float GetFloat(string key, float defaultValue = 0)
|
||||
{
|
||||
if (!_settingsDict.ContainsKey(key))
|
||||
{
|
||||
SetFloat(key, defaultValue);
|
||||
}
|
||||
|
||||
if (_settingsDict[key] is float f) return f;
|
||||
MaddoLogger.LogError("Error while parsing {0}", key);
|
||||
|
||||
float fl = 0;
|
||||
SetFloat(key, float.TryParse(_settingsDict[key].ToString(), out f) ? fl : defaultValue);
|
||||
return (float) _settingsDict[key];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public T Get<T>(string key, T defaultValue)
|
||||
{
|
||||
if (!_settingsDict.ContainsKey(key))
|
||||
|
|
@ -146,6 +168,8 @@ namespace CatalogLib
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public string GetString(string key, string defaultValue = "")
|
||||
{
|
||||
if (!_settingsDict.ContainsKey(key))
|
||||
|
|
@ -184,7 +208,10 @@ namespace CatalogLib
|
|||
//return _settingsDict.ContainsKey(key) ? _settingsDict[key] : defaultValue;
|
||||
}
|
||||
|
||||
|
||||
public T GetEnum<T>(string name, T defaultValue)
|
||||
{
|
||||
return (T)Enum.Parse(typeof(T), GetString(name, defaultValue.ToString()));
|
||||
}
|
||||
|
||||
public void SetDefaults()
|
||||
{
|
||||
|
|
@ -262,12 +289,8 @@ namespace CatalogLib
|
|||
get { return 0; }
|
||||
}
|
||||
|
||||
public string Posizione
|
||||
{
|
||||
get { return string.Empty; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public DateTime DataPartenza { get; set; }
|
||||
public string TestoOrario { get; internal set; }
|
||||
public int DimStandard { get; internal set; }
|
||||
|
|
@ -290,7 +313,9 @@ namespace CatalogLib
|
|||
set { SetString("DirDestinazione", value); }
|
||||
}
|
||||
|
||||
public float Margine { get; set; }
|
||||
public float Margine { get => GetFloat("Margin", 1);
|
||||
set => SetFloat("Margin", value);
|
||||
}
|
||||
public float MargVert { get; set; }
|
||||
public string Allineamento { get; set; }
|
||||
|
||||
|
|
@ -432,8 +457,54 @@ namespace CatalogLib
|
|||
}
|
||||
}
|
||||
|
||||
public bool FotoRidimensiona
|
||||
{
|
||||
get => GetBool("FotoRidimensiona", false);
|
||||
set => Set("FotoRidimensiona", value);
|
||||
}
|
||||
|
||||
public Positions TextPosition
|
||||
{
|
||||
get => GetEnum("TextPosition", Positions.Alto); //(Positions)Enum.Parse(typeof(Positions), GetString("TextPosition", Positions.Alto.ToString()));
|
||||
set => SetString("TextPosition", value.ToString());
|
||||
}
|
||||
|
||||
public Alignments TextAlignment
|
||||
{
|
||||
get => GetEnum("TextAlignment", Alignments.Centro);
|
||||
set => SetString("TextAlignment", value.ToString());
|
||||
}
|
||||
|
||||
public bool Threading
|
||||
{
|
||||
get => GetBool("Threading", true);
|
||||
set => SetBool("Threading", value);
|
||||
}
|
||||
[Obsolete]
|
||||
public string Posizione
|
||||
{
|
||||
get => string.Empty;
|
||||
set { }
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Enums
|
||||
|
||||
public enum Positions
|
||||
{
|
||||
Alto,
|
||||
Basso
|
||||
}
|
||||
|
||||
public enum Alignments
|
||||
{
|
||||
Sinistra,
|
||||
Centro,
|
||||
Destra
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue