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>
|
</Info>
|
||||||
<!--Cover definitions when a category is missing a cover-->
|
<!--Cover definitions when a category is missing a cover-->
|
||||||
<!--Possible types are: Default, Song, Artist, Letter, Edition, Genre, Language, Year, Decade, Date -->
|
<!--Possible types are: Default, Song, Artist, Letter, Edition, Genre, Language, Year, Decade, Date -->
|
||||||
<CoverGenerator1 Type="Default">
|
<CoverGenerator Type="Default">
|
||||||
<Text>
|
<Text>
|
||||||
<!--<Text>: Text to be shown, %TEXT% will be replaced by the category or song name-->
|
<!--<Text>: Text to be shown, %TEXT% will be replaced by the category or song name-->
|
||||||
<Text>%TEXT%</Text>
|
<Text>%TEXT%</Text>
|
||||||
@@ -39,5 +39,5 @@
|
|||||||
<ShowFirstCover>true</ShowFirstCover>
|
<ShowFirstCover>true</ShowFirstCover>
|
||||||
<!--<ImageAlpha>Alpha value of the image in case the first cover is shown(optional)-->
|
<!--<ImageAlpha>Alpha value of the image in case the first cover is shown(optional)-->
|
||||||
<ImageAlpha>0.75</ImageAlpha>
|
<ImageAlpha>0.75</ImageAlpha>
|
||||||
</CoverGenerator1>
|
</CoverGenerator>
|
||||||
</root>
|
</root>
|
||||||
@@ -28,12 +28,6 @@ using VocaluxeLib.Xml;
|
|||||||
|
|
||||||
namespace Vocaluxe.Base
|
namespace Vocaluxe.Base
|
||||||
{
|
{
|
||||||
struct SThemeCover
|
|
||||||
{
|
|
||||||
public string Name, Folder;
|
|
||||||
public string FilePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
static class CCover
|
static class CCover
|
||||||
{
|
{
|
||||||
private const string _NoCoverName = "No Cover";
|
private const string _NoCoverName = "No Cover";
|
||||||
@@ -262,6 +256,10 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
private static void _LoadCoverGenerators(SThemeCover coverTheme)
|
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);
|
CXMLReader xmlReader = CXMLReader.OpenFile(coverTheme.FilePath);
|
||||||
string coverPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder);
|
string coverPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder);
|
||||||
lock (_CoverGenerators)
|
lock (_CoverGenerators)
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ namespace Vocaluxe.Base
|
|||||||
private readonly SColorF _TextColor;
|
private readonly SColorF _TextColor;
|
||||||
private readonly SColorF _BGColor;
|
private readonly SColorF _BGColor;
|
||||||
private const int _LineSpace = 5;
|
private const int _LineSpace = 5;
|
||||||
|
private readonly int _MarginLeft;
|
||||||
|
private readonly int _MarginRight;
|
||||||
|
private readonly int _MarginTop;
|
||||||
|
private readonly int _MarginBottom;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Split lines after special chars, descending priority
|
/// Split lines after special chars, descending priority
|
||||||
@@ -60,6 +64,10 @@ namespace Vocaluxe.Base
|
|||||||
_Image = Path.Combine(basePath, _Theme.Image);
|
_Image = Path.Combine(basePath, _Theme.Image);
|
||||||
_Valid = File.Exists(_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
|
private class CTextElement
|
||||||
@@ -135,7 +143,7 @@ namespace Vocaluxe.Base
|
|||||||
{
|
{
|
||||||
pen.LineJoin = LineJoin.Round;
|
pen.LineJoin = LineJoin.Round;
|
||||||
pen.Alignment = PenAlignment.Outset;
|
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;
|
int nextLineEl = 0;
|
||||||
for (int i = 0; i < lineCount; i++)
|
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
|
//Center Text if this is the only line or the middle line
|
||||||
float width = _GetWidth(elements, firstEl, nextLineEl - 1);
|
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)
|
else if (i == lineCount - 1)
|
||||||
{
|
{
|
||||||
//Place last line at right
|
//Place last line at right
|
||||||
float width = _GetWidth(elements, firstEl, nextLineEl - 1);
|
float width = _GetWidth(elements, firstEl, nextLineEl - 1);
|
||||||
left = bmpSize.Width - width - _Theme.Text.Margin.Right;
|
left = bmpSize.Width - width - _MarginRight;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
left = _Theme.Text.Margin.Left;
|
left = _MarginLeft;
|
||||||
//g.DrawString(line, fo, new SolidBrush(_TextColor.AsColor()), left, top, StringFormat.GenericTypographic);
|
//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);
|
path.AddString(line, fo.FontFamily, (int)fo.Style, emSize, new PointF(left, top), StringFormat.GenericTypographic);
|
||||||
top += maxHeight + _LineSpace;
|
top += maxHeight + _LineSpace;
|
||||||
@@ -222,8 +230,8 @@ namespace Vocaluxe.Base
|
|||||||
/// <returns>Factor for resizing the text (Maximizing this factor means maximizing the height)</returns>
|
/// <returns>Factor for resizing the text (Maximizing this factor means maximizing the height)</returns>
|
||||||
private float _DistributeText(List<CTextElement> elements, int width, int height)
|
private float _DistributeText(List<CTextElement> elements, int width, int height)
|
||||||
{
|
{
|
||||||
int availableWidth = width - _Theme.Text.Margin.Left - _Theme.Text.Margin.Right;
|
int availableWidth = width - _MarginLeft - _MarginRight;
|
||||||
int availableHeight = height - _Theme.Text.Margin.Top - _Theme.Text.Margin.Bottom;
|
int availableHeight = height - _MarginTop - _MarginBottom;
|
||||||
|
|
||||||
float textHeight = elements.Select(el => el.Height).Max();
|
float textHeight = elements.Select(el => el.Height).Max();
|
||||||
|
|
||||||
|
|||||||
+27
-7
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
@@ -28,8 +29,12 @@ namespace VocaluxeLib
|
|||||||
{
|
{
|
||||||
public struct SMargin
|
public struct SMargin
|
||||||
{
|
{
|
||||||
public int Default;
|
[XmlAttribute] public int Default;
|
||||||
public int Left, Right, Top, Bottom;
|
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
|
public struct SThemeCoverGeneratorText
|
||||||
@@ -43,12 +48,27 @@ namespace VocaluxeLib
|
|||||||
|
|
||||||
public struct SThemeCoverGenerator
|
public struct SThemeCoverGenerator
|
||||||
{
|
{
|
||||||
public ECoverGeneratorType Type;
|
[XmlAttribute] public ECoverGeneratorType Type;
|
||||||
public SThemeCoverGeneratorText Text;
|
public SThemeCoverGeneratorText Text;
|
||||||
public SThemeColor BackgroundColor;
|
public SThemeColor BackgroundColor;
|
||||||
public string Image;
|
[XmlElement(IsNullable = true)] public string Image;
|
||||||
public float ImageAlpha;
|
[DefaultValue(0.5f)] public float ImageAlpha;
|
||||||
public bool ShowFirstCover;
|
[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
|
public struct SInfo
|
||||||
@@ -99,7 +119,7 @@ namespace VocaluxeLib
|
|||||||
[XmlRoot("Color")]
|
[XmlRoot("Color")]
|
||||||
public struct SThemeColor
|
public struct SThemeColor
|
||||||
{
|
{
|
||||||
[XmlAttribute] public string Name;
|
[DefaultValue(null), XmlAttribute] public string Name;
|
||||||
public float? R;
|
public float? R;
|
||||||
public float? G;
|
public float? G;
|
||||||
public float? B;
|
public float? B;
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ namespace VocaluxeLib.Xml
|
|||||||
bool ok = true;
|
bool ok = true;
|
||||||
string val;
|
string val;
|
||||||
bool defOk = GetAttribute(xPath, "Default", out val) && int.TryParse(val, out el.Default);
|
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 + "/Right", ref el.Right, el.Default);
|
||||||
ok &= TryGetIntValue(xPath + "/Top", ref el.Top, 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;
|
return ok || defOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user