/// <summary> /// Parses song part. /// </summary> /// <param name="elem"></param> /// <param name="defaultMainSize"></param> /// <returns></returns> private PowerPraiseSong.Part ParseSongPart(XmlElement elem, int defaultMainSize) { var part = new PowerPraiseSong.Part { // Caption Caption = elem.GetAttribute("caption") }; // Slides foreach (var slideElem in elem.Cast <XmlElement>().Where(slideElem => slideElem.Name == "slide")) { part.Slides.Add(ParseSongSlide(slideElem, defaultMainSize)); } return(part); }
public static PowerPraiseSong GetExpectedPowerPraiseSong() { PowerPraiseSong ppl = new PowerPraiseSong { Title = "Näher, mein Gott, zu Dir", Language = "Deutsch", Category = "Anbetung" }; // General // Songtext PowerPraiseSong.Part part = new PowerPraiseSong.Part { Caption = "Teil 1" }; PowerPraiseSong.Slide slide = new PowerPraiseSong.Slide { MainSize = 42, Background = new ImageBackground("Blumen\\Blume 3.jpg") }; slide.Lines.Add("Näher, mein Gott, zu Dir,"); slide.Lines.Add("sei meine Bitt'!"); slide.Lines.Add("Näher, o Herr, zu Dir"); slide.Lines.Add("mit jedem Schritt."); part.Slides.Add(slide); slide = new PowerPraiseSong.Slide { MainSize = 44, Background = new ImageBackground("Blumen\\Blume 3.jpg") }; slide.Lines.Add("Nur an dem Herzen Dein"); slide.Lines.Add("kann ich geborgen sein;"); slide.Lines.Add("deshalb die Bitte mein:"); slide.Lines.Add("Näher zu Dir!"); part.Slides.Add(slide); ppl.Parts.Add(part); part = new PowerPraiseSong.Part { Caption = "Teil 2" }; slide = new PowerPraiseSong.Slide { MainSize = 42, Background = new ImageBackground("Blumen\\Blume 3.jpg") }; slide.Lines.Add("Näher, mein Gott, zu Dir!"); slide.Lines.Add("Ein jeder Tag"); slide.Lines.Add("soll es neu zeigen mir,"); slide.Lines.Add("was er vermag:"); part.Slides.Add(slide); slide = new PowerPraiseSong.Slide { MainSize = 42, Background = new ImageBackground("Blumen\\Blume 3.jpg") }; slide.Lines.Add("Wie seiner Gnade Macht,"); slide.Lines.Add("Erlösung hat gebracht,"); slide.Lines.Add("in uns're Sündennacht."); slide.Lines.Add("Näher zu Dir!"); part.Slides.Add(slide); ppl.Parts.Add(part); part = new PowerPraiseSong.Part { Caption = "Teil 3" }; slide = new PowerPraiseSong.Slide { MainSize = 42, Background = new ImageBackground("Blumen\\Blume 3.jpg") }; slide.Lines.Add("Näher, mein Gott, zu Dir!"); slide.Lines.Add("Dich bet' ich an."); slide.Lines.Add("Wie vieles hast an mir,"); slide.Lines.Add("Du doch getan!"); part.Slides.Add(slide); slide = new PowerPraiseSong.Slide { MainSize = 42, Background = new ImageBackground("Blumen\\Blume 3.jpg") }; slide.Lines.Add("Von Banden frei und los,"); slide.Lines.Add("ruh' ich in Deinem Schoss."); slide.Lines.Add("Ja, Deine Gnad' ist gross!"); slide.Lines.Add("Näher zu Dir!"); part.Slides.Add(slide); ppl.Parts.Add(part); // Order ppl.Order.Add(ppl.Parts[0]); ppl.Order.Add(ppl.Parts[1]); ppl.Order.Add(ppl.Parts[2]); // Copyright ppl.CopyrightText.Add("Text und Musik: Lowell Mason, 1792-1872"); ppl.Formatting.CopyrightTextPosition = AdditionalInformationPosition.LastSlide; // Source ppl.SourceText = "grünes Buch 339"; ppl.Formatting.SourceTextPosition = AdditionalInformationPosition.FirstSlide; // Formatting ppl.Formatting.MainText = new PowerPraiseSongFormatting.FontFormatting { Font = new Font("Times New Roman", 44, FontStyle.Bold | FontStyle.Italic), Color = Color.White, OutlineWidth = 30, ShadowDistance = 15 }; ppl.Formatting.TranslationText = new PowerPraiseSongFormatting.FontFormatting { Font = new Font("Times New Roman", 20, FontStyle.Regular), Color = Color.White, OutlineWidth = 30, ShadowDistance = 20 }; ppl.Formatting.CopyrightText = new PowerPraiseSongFormatting.FontFormatting { Font = new Font("Times New Roman", 14, FontStyle.Regular), Color = Color.White, OutlineWidth = 30, ShadowDistance = 20 }; ppl.Formatting.SourceText = new PowerPraiseSongFormatting.FontFormatting { Font = new Font("Times New Roman", 30, FontStyle.Regular), Color = Color.White, OutlineWidth = 30, ShadowDistance = 20 }; ppl.Formatting.Outline = new PowerPraiseSongFormatting.OutlineFormatting { Color = Color.Black, Enabled = false }; ppl.Formatting.Shadow = new PowerPraiseSongFormatting.ShadowFormatting { Color = Color.Black, Direction = 125, Enabled = true }; // Line spacing ppl.Formatting.MainLineSpacing = 30; ppl.Formatting.TranslationLineSpacing = 20; // Text orientation ppl.Formatting.TextOrientation = new TextOrientation(VerticalOrientation.Middle, HorizontalOrientation.Left); ppl.Formatting.TranslationPosition = TranslationPosition.Inline; // Borders ppl.Formatting.Borders = new PowerPraiseSongFormatting.TextBorders { TextLeft = 50, TextTop = 40, TextRight = 60, TextBottom = 70, CopyrightBottom = 30, SourceTop = 20, SourceRight = 40 }; return(ppl); }
/// <summary> /// Maps a song to a PowerPraise song object /// </summary> /// <param name="song"></param> /// <param name="ppl"></param> public void Map(Song song, PowerPraiseSong ppl) { // General ppl.Title = song.Title; ppl.Language = song.Language; ppl.Category = null; foreach (var th in song.Themes) { if (th != PowerPraiseConstants.NoCategory) { ppl.Category = th; break; } } // Song parts foreach (var songPart in song.Parts) { var pplPart = new PowerPraiseSong.Part { Caption = songPart.Caption }; foreach (var songSlide in songPart.Slides) { var pplSlide = new PowerPraiseSong.Slide { Background = songSlide.Background != null ? (IBackground)songSlide.Background.Clone() : null, MainSize = (int) (songSlide.TextSize > 0 ? songSlide.TextSize : (song.Formatting != null && song.Formatting.MainText != null && song.Formatting.MainText.Font != null ? song.Formatting.MainText.Font.Size : 0)) }; pplSlide.Lines.AddRange(songSlide.Lines); pplSlide.Translation.AddRange(songSlide.Translation); pplPart.Slides.Add(pplSlide); } ppl.Parts.Add(pplPart); } // Part order if (song.PartSequence.Any()) { foreach (var p in song.PartSequence) { foreach (var t in ppl.Parts) { if (p.Caption == t.Caption) { ppl.Order.Add(t); break; } } } } else { foreach (var t in ppl.Parts) { ppl.Order.Add(t); } } // Copyright text if (song.Copyright != null) { foreach (var s in song.Copyright.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) { ppl.CopyrightText.Add(s); } } ppl.Formatting.CopyrightTextPosition = song.Formatting.CopyrightPosition; // Source / songbook ppl.SourceText = song.SongBooks.ToString(); ppl.Formatting.SourceTextPosition = song.Formatting.SourcePosition; // Linespacing if (song.Formatting.MainText != null) { ppl.Formatting.MainLineSpacing = song.Formatting.MainLineSpacing; ppl.Formatting.TranslationLineSpacing = song.Formatting.TranslationLineSpacing; } MapFormatting(song, ppl); }