Font picker

This commit is contained in:
Maddo 2017-03-17 16:23:29 +01:00
commit f038c63718
9 changed files with 289 additions and 51 deletions

View file

@ -25,26 +25,26 @@ namespace CatalogLib
var o = exif.GetValue(ExifTag.Orientation);
if (o != null)
{
int v = (int) o.Value;
int v = (int)o.Value;
switch (v)
{
//1 = Horizontal(normal)
//2 = Mirror horizontal
//3 = Rotate 180
//4 = Mirror vertical
//5 = Mirror horizontal and rotate 270 CW
//6 = Rotate 90 CW
//7 = Mirror horizontal and rotate 90 CW
//8 = Rotate 270 CW
//1 = Horizontal(normal)
//2 = Mirror horizontal
//3 = Rotate 180
//4 = Mirror vertical
//5 = Mirror horizontal and rotate 270 CW
//6 = Rotate 90 CW
//7 = Mirror horizontal and rotate 90 CW
//8 = Rotate 270 CW
case 1:
break;
case 2:
break;
case 3:
//image.Rotate(180f);
//image.Rotate(90);
image.Rotate(180f);
break;
@ -69,10 +69,15 @@ namespace CatalogLib
}
//JpegDecoder j = new JpegDecoder();
image.Save(Path.Combine(PicSettings.Instance.DirectoryDestinazione,workFile.Name));
image.Save(Path.Combine(PicSettings.Instance.DirectoryDestinazione, workFile.Name));
//image.Resize(200, 200).Save("");
}
}
private void SetExtraText(ref Image image)
{
//if ()
}
}
}

View file

@ -35,11 +35,11 @@ namespace CatalogLib
public void DeserializeSettings(string serializedData)
{
_settingsDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(serializedData);
}
public void Set(string key, object value)
public void SetBase(string key, object value)
{
if (_settingsDict.ContainsKey(key))
{
@ -53,20 +53,28 @@ namespace CatalogLib
public void SetString(string key, string value)
{
Set(key, value);
SetBase(key, value);
}
public void SetInt(string key, int value)
{
Set(key, value);
SetBase(key, value);
}
public void SetBool(string key, bool value)
{
Set(key, value);
SetBase(key, value);
}
public void SetDouble(string key, double value)
{
SetBase(key, value);
}
public void Set<T>(string key, T value)
{
SetBase(key, value);
}
public bool Exists(string key)
{
@ -83,7 +91,7 @@ namespace CatalogLib
if (_settingsDict[key] is int) return (int)_settingsDict[key];
Debug.WriteLine($"Error while parsing {key}");
//return defaultValue;
int r;
if (int.TryParse(_settingsDict[key].ToString(), out r))
@ -95,12 +103,48 @@ namespace CatalogLib
{
SetInt(key, defaultValue);
}
return (int) _settingsDict[key];
return (int)_settingsDict[key];
//return (int) _settingsDict[key];
//return _settingsDict.ContainsKey(key) ? (int)_settingsDict[key] : defaultValue;
}
public double GetDouble(string key, double defaultValue = 0)
{
if (!_settingsDict.ContainsKey(key))
{
SetDouble(key, defaultValue);
// setdouble default
}
if (_settingsDict[key] is double) return (double)_settingsDict[key];
Debug.WriteLine($"Error while parsing {key}");
double d;
if (double.TryParse(_settingsDict[key].ToString(), out d))
{
SetDouble(key, d);
// setdouble key r
}
else
{
SetDouble(key, defaultValue);
//setdouble defaultvalue
}
return (double)_settingsDict[key];
}
public T Get<T>(string key, T defaultValue)
{
if (!_settingsDict.ContainsKey(key))
{
Set<T>(key, defaultValue);
// setdouble default
}
return (T)_settingsDict[key];
}
public string GetString(string key, string defaultValue = "")
{
@ -108,7 +152,7 @@ namespace CatalogLib
{
SetString(key, defaultValue);
}
return (string) _settingsDict[key];
return (string)_settingsDict[key];
//return _settingsDict.ContainsKey(key) ? (string)_settingsDict[key] : defaultValue;
}
@ -120,7 +164,7 @@ namespace CatalogLib
SetBool(key, defaultValue);
return defaultValue;
}
return (bool) _settingsDict[key];
return (bool)_settingsDict[key];
@ -334,11 +378,7 @@ namespace CatalogLib
set { SetString("FotoSuffisso", value); }
}
public bool EnableText
{
get { return GetBool("EnableText", false); }
set { SetBool("EnableText", value); }
}
public bool EnableThumbnails
{
get { return GetBool("EnableThumbnails", false); }
@ -349,5 +389,29 @@ namespace CatalogLib
get { return GetBool("EnableLogo", false); }
set { SetBool("EnableLogo", value); }
}
#region Text
public bool EnableText
{
get { return GetBool("EnableText", false); }
set { SetBool("EnableText", value); }
}
public string NomeFont
{
get { return GetString("nomeFont", "Verdana"); }
set { SetString("nomeFont", value); }
}
public double DimensioneFont
{
get { return Get<double>("dimensioneFont", 1); }
set { SetDouble("dimensioneFont", value); }
}
#endregion
}
}