Change struct of cover file
This commit is contained in:
1 parent
6001f2f47d
commit
31a9ac6afa
5 files changed
+49
-23
No files matched your search
@@ -7,7 +7,7 @@
|
||||
</Info>
|
||||
<!--Cover definitions when a category is missing a cover-->
|
||||
<!--Possible types are: Default, Song, Artist, Letter, Edition, Genre, Language, Year, Decade, Date -->
|
||||
<CoverGenerator1 Type="Default">
|
||||
<CoverGenerator Type="Default">
|
||||
<Text>
|
||||
<!--<Text>: Text to be shown, %TEXT% will be replaced by the category or song name-->
|
||||
<Text>%TEXT%</Text>
|
||||
@@ -39,5 +39,5 @@
|
||||
<ShowFirstCover>true</ShowFirstCover>
|
||||
<!--<ImageAlpha>Alpha value of the image in case the first cover is shown(optional)-->
|
||||
<ImageAlpha>0.75</ImageAlpha>
|
||||
</CoverGenerator1>
|
||||
</CoverGenerator>
|
||||
</root>
|
||||
@@ -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<SThemeCover>(stream);
|
||||
//string cover = theme.Info.Author;
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(coverTheme.FilePath);
|
||||
string coverPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder);
|
||||
lock (_CoverGenerators)
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// <returns>Factor for resizing the text (Maximizing this factor means maximizing the height)</returns>
|
||||
private float _DistributeText(List<CTextElement> 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();
|
||||
|
||||
|
||||
+27
-7
@@ -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<SThemeCoverGenerator> 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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user