diff --git a/Output/Cover/Blue.xml b/Output/Cover/Blue.xml
index 9fcf7dd0..f7c37551 100644
--- a/Output/Cover/Blue.xml
+++ b/Output/Cover/Blue.xml
@@ -7,7 +7,7 @@
-
+
%TEXT%
@@ -39,5 +39,5 @@
true
0.75
-
+
diff --git a/Vocaluxe/Base/CCover.cs b/Vocaluxe/Base/CCover.cs
index 3c96da1a..2c4eb40a 100644
--- a/Vocaluxe/Base/CCover.cs
+++ b/Vocaluxe/Base/CCover.cs
@@ -28,12 +28,6 @@ using VocaluxeLib.Xml;
namespace Vocaluxe.Base
{
- struct SThemeCover
- {
- public string Name, Folder;
- public string FilePath;
- }
-
static class CCover
{
private const string _NoCoverName = "No Cover";
@@ -262,6 +256,10 @@ namespace Vocaluxe.Base
private static void _LoadCoverGenerators(SThemeCover coverTheme)
{
+ //SThemeCover theme;
+ //using (var stream = new FileStream(coverTheme.FilePath, FileMode.Open))
+ // theme = CMyXmlDeserializer.Deserialize(stream);
+ //string cover = theme.Info.Author;
CXMLReader xmlReader = CXMLReader.OpenFile(coverTheme.FilePath);
string coverPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder);
lock (_CoverGenerators)
diff --git a/Vocaluxe/Base/CCoverGenerator.cs b/Vocaluxe/Base/CCoverGenerator.cs
index a1de5791..1ff20fa9 100644
--- a/Vocaluxe/Base/CCoverGenerator.cs
+++ b/Vocaluxe/Base/CCoverGenerator.cs
@@ -41,6 +41,10 @@ namespace Vocaluxe.Base
private readonly SColorF _TextColor;
private readonly SColorF _BGColor;
private const int _LineSpace = 5;
+ private readonly int _MarginLeft;
+ private readonly int _MarginRight;
+ private readonly int _MarginTop;
+ private readonly int _MarginBottom;
///
/// Split lines after special chars, descending priority
@@ -60,6 +64,10 @@ namespace Vocaluxe.Base
_Image = Path.Combine(basePath, _Theme.Image);
_Valid = File.Exists(_Image);
}
+ _MarginLeft = theme.Text.Margin.Left.HasValue ? theme.Text.Margin.Left.Value : theme.Text.Margin.Default;
+ _MarginRight = theme.Text.Margin.Right.HasValue ? theme.Text.Margin.Right.Value : theme.Text.Margin.Default;
+ _MarginTop = theme.Text.Margin.Top.HasValue ? theme.Text.Margin.Top.Value : theme.Text.Margin.Default;
+ _MarginBottom = theme.Text.Margin.Bottom.HasValue ? theme.Text.Margin.Bottom.Value : theme.Text.Margin.Default;
}
private class CTextElement
@@ -135,7 +143,7 @@ namespace Vocaluxe.Base
{
pen.LineJoin = LineJoin.Round;
pen.Alignment = PenAlignment.Outset;
- float top = (bmpSize.Height - _Theme.Text.Margin.Bottom - _Theme.Text.Margin.Top - maxHeight * lineCount) / 2 + _Theme.Text.Margin.Top;
+ float top = (bmpSize.Height - _MarginBottom - _MarginTop - maxHeight * lineCount) / 2 + _MarginTop;
int nextLineEl = 0;
for (int i = 0; i < lineCount; i++)
{
@@ -152,16 +160,16 @@ namespace Vocaluxe.Base
{
//Center Text if this is the only line or the middle line
float width = _GetWidth(elements, firstEl, nextLineEl - 1);
- left = (bmpSize.Width - _Theme.Text.Margin.Left - _Theme.Text.Margin.Right - width) / 2 + _Theme.Text.Margin.Left;
+ left = (bmpSize.Width - _MarginLeft - _MarginRight - width) / 2 + _MarginLeft;
}
else if (i == lineCount - 1)
{
//Place last line at right
float width = _GetWidth(elements, firstEl, nextLineEl - 1);
- left = bmpSize.Width - width - _Theme.Text.Margin.Right;
+ left = bmpSize.Width - width - _MarginRight;
}
else
- left = _Theme.Text.Margin.Left;
+ left = _MarginLeft;
//g.DrawString(line, fo, new SolidBrush(_TextColor.AsColor()), left, top, StringFormat.GenericTypographic);
path.AddString(line, fo.FontFamily, (int)fo.Style, emSize, new PointF(left, top), StringFormat.GenericTypographic);
top += maxHeight + _LineSpace;
@@ -222,8 +230,8 @@ namespace Vocaluxe.Base
/// Factor for resizing the text (Maximizing this factor means maximizing the height)
private float _DistributeText(List elements, int width, int height)
{
- int availableWidth = width - _Theme.Text.Margin.Left - _Theme.Text.Margin.Right;
- int availableHeight = height - _Theme.Text.Margin.Top - _Theme.Text.Margin.Bottom;
+ int availableWidth = width - _MarginLeft - _MarginRight;
+ int availableHeight = height - _MarginTop - _MarginBottom;
float textHeight = elements.Select(el => el.Height).Max();
diff --git a/VocaluxeLib/Structs.cs b/VocaluxeLib/Structs.cs
index d66168fd..929f76bd 100644
--- a/VocaluxeLib/Structs.cs
+++ b/VocaluxeLib/Structs.cs
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Drawing;
@@ -28,8 +29,12 @@ namespace VocaluxeLib
{
public struct SMargin
{
- public int Default;
- public int Left, Right, Top, Bottom;
+ [XmlAttribute] public int Default;
+ public int? Left, Right, Top, Bottom;
+ [XmlIgnore] public bool LeftSpecified;
+ [XmlIgnore] public bool RightSpecified;
+ [XmlIgnore] public bool TopSpecified;
+ [XmlIgnore] public bool BottomSpecified;
}
public struct SThemeCoverGeneratorText
@@ -43,12 +48,27 @@ namespace VocaluxeLib
public struct SThemeCoverGenerator
{
- public ECoverGeneratorType Type;
+ [XmlAttribute] public ECoverGeneratorType Type;
public SThemeCoverGeneratorText Text;
public SThemeColor BackgroundColor;
- public string Image;
- public float ImageAlpha;
- public bool ShowFirstCover;
+ [XmlElement(IsNullable = true)] public string Image;
+ [DefaultValue(0.5f)] public float ImageAlpha;
+ [DefaultValue(false)] public bool ShowFirstCover;
+ }
+
+ public struct SThemeCoverInfo
+ {
+ public string Name;
+ public string Folder;
+ [XmlElement(IsNullable = true)] public string Author;
+ }
+
+ [XmlRoot("root")]
+ public struct SThemeCover
+ {
+ [XmlIgnore] public string Name, Folder, FilePath;
+ public SThemeCoverInfo Info;
+ [XmlElement("CoverGenerator", IsNullable = false)] public List CoverGenerators;
}
public struct SInfo
@@ -99,7 +119,7 @@ namespace VocaluxeLib
[XmlRoot("Color")]
public struct SThemeColor
{
- [XmlAttribute] public string Name;
+ [DefaultValue(null), XmlAttribute] public string Name;
public float? R;
public float? G;
public float? B;
diff --git a/VocaluxeLib/Xml/CXmlDeserializer.cs b/VocaluxeLib/Xml/CXmlDeserializer.cs
index db2dbb8a..42853ba4 100644
--- a/VocaluxeLib/Xml/CXmlDeserializer.cs
+++ b/VocaluxeLib/Xml/CXmlDeserializer.cs
@@ -42,10 +42,10 @@ namespace VocaluxeLib.Xml
bool ok = true;
string val;
bool defOk = GetAttribute(xPath, "Default", out val) && int.TryParse(val, out el.Default);
- ok &= TryGetIntValue(xPath + "/Left", ref el.Left, el.Default);
+ /*ok &= TryGetIntValue(xPath + "/Left", ref el.Left, el.Default);
ok &= TryGetIntValue(xPath + "/Right", ref el.Right, el.Default);
ok &= TryGetIntValue(xPath + "/Top", ref el.Top, el.Default);
- ok &= TryGetIntValue(xPath + "/Bottom", ref el.Bottom, el.Default);
+ ok &= TryGetIntValue(xPath + "/Bottom", ref el.Bottom, el.Default);*/
return ok || defOk;
}