public LiturgyLayoutRenderInfo GetRenderInfo() { var res = new LiturgyLayoutRenderInfo { BoldFont = new Font(Font, FontStyle.Bold), RegularFont = Font, SpeakerBox = Speaker, TextBox = Text }; return(res); }
public RenderedSlide RenderSlide(LiturgyLayoutRenderInfo renderInfo, Slide slide, List <Compiler.XenonCompilerMessage> messages) { RenderedSlide res = new RenderedSlide(); res.MediaType = MediaType.Image; res.AssetPath = ""; res.RenderedAs = "Liturgy"; // draw it // for now just draw the layout Bitmap bmp = new Bitmap(Layouts.LiturgyLayout.Size.Width, Layouts.LiturgyLayout.Size.Height); Bitmap kbmp = new Bitmap(Layouts.LiturgyLayout.Size.Width, Layouts.LiturgyLayout.Size.Height); Graphics gfx = Graphics.FromImage(bmp); Graphics kgfx = Graphics.FromImage(kbmp); gfx.Clear(slide.Colors["background"]); // most of slide should be transparent kgfx.Clear(Color.Black); SolidBrush textcol = new SolidBrush(slide.Colors["text"]); SolidBrush speakercol = new SolidBrush(slide.Colors["alttext"]); SolidBrush sb = new SolidBrush(slide.Colors["keybackground"]); SolidBrush kb = new SolidBrush(slide.Colors["keytrans"]); gfx.FillRectangle(sb, Layouts.LiturgyLayout.Key); // make black somewhat transparent kgfx.FillRectangle(kb, Layouts.LiturgyLayout.Key); StringFormat topleftalign = new StringFormat() { LineAlignment = StringAlignment.Near, Alignment = StringAlignment.Near }; StringFormat centeralign = new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }; RectangleF text = Layouts.LiturgyLayout.Text.Move(Layouts.LiturgyLayout.Key.Location); RectangleF speaker = Layouts.LiturgyLayout.Speaker.Move(Layouts.LiturgyLayout.Key.Location); //gfx.DrawRectangle(Pens.Red, text); //gfx.DrawRectangle(Pens.Purple, speaker); // compute line spacing int textlinecombinedheight = 0; foreach (var line in slide.Lines) { textlinecombinedheight += (int)(float)line.Content[1].Attributes["height"]; } int interspace = (renderInfo.TextBox.Height - textlinecombinedheight) / (slide.Lines.Count + 1); int linenum = 0; int linepos = interspace; string lastspeaker = ""; foreach (var line in slide.Lines) { bool drawspeaker = false; if (line.Content[0].Data != lastspeaker && line.Content[0].Data != "$") { drawspeaker = true; } lastspeaker = line.Content[0].Data; LiturgyTextLine linewords = (LiturgyTextLine)line.Content[1].Attributes["textline"]; // draw line float xoffset = 0; // center the text //xoffset = (Layouts.TitleLiturgyVerseLayout.Textbox.Width / 2) - (linewords.Width / 2); RectangleF speakerblock = new RectangleF(speaker.Move(0, linepos + interspace * linenum).Location, new Size(60, 60)); // draw speaker if (drawspeaker) { float jog = 0.07f * (gfx.DpiY * gfx.MeasureStringCharacters(linewords.Speaker, flsbregular, speakerblock).Height / 72); gfx.DrawString(linewords.Speaker, flsbregular, speakercol, speakerblock.Move(0, -jog), centeralign); // make speaker fully opaque kgfx.DrawString(linewords.Speaker, flsbregular, Brushes.White, speakerblock.Move(0, -jog), centeralign); } foreach (var word in linewords.Words) { Font f = word.IsLSBSymbol ? (word.IsBold ? flsbbold : flsbregular) : (word.IsBold ? fbold : fregular); float jog = word.IsLSBSymbol ? 0.07f * (gfx.DpiY * gfx.MeasureStringCharacters(linewords.Speaker, f, speakerblock).Height / 72) : 0; gfx.DrawString(word.Value, f, textcol, text.Move(xoffset, linepos + interspace * linenum).Move(0, -jog).Location, GraphicsHelper.DefaultStringFormat()); // make text fully opaque kgfx.DrawString(word.Value, f, Brushes.White, text.Move(xoffset, linepos + interspace * linenum).Move(0, -jog).Location, GraphicsHelper.DefaultStringFormat()); xoffset += word.Size.Width; } linenum++; linepos += (int)linewords.Height; } res.Bitmap = bmp; res.KeyBitmap = kbmp; return(res); }
public RenderedSlide RenderSlide(LiturgyLayoutRenderInfo renderInfo, Slide slide, List <Compiler.XenonCompilerMessage> messages) { RenderedSlide res = new RenderedSlide(); res.MediaType = MediaType.Image; res.AssetPath = ""; res.RenderedAs = "Liturgy"; // draw it // for now just draw the layout Bitmap bmp = new Bitmap(Layouts.LiturgyLayout.Size.Width, Layouts.LiturgyLayout.Size.Height); Bitmap kbmp = new Bitmap(Layouts.LiturgyLayout.Size.Width, Layouts.LiturgyLayout.Size.Height); Graphics gfx = Graphics.FromImage(bmp); Graphics kgfx = Graphics.FromImage(kbmp); Font LSBSymbolFont = new System.Drawing.Font("LSBSymbol", 36, System.Drawing.FontStyle.Regular); gfx.Clear(Color.Black); kgfx.Clear(Color.Black); gfx.FillRectangle(Brushes.White, Layouts.LiturgyLayout.Key); kgfx.FillRectangle(Brushes.White, Layouts.LiturgyLayout.Key); StringFormat topleftalign = new StringFormat() { LineAlignment = StringAlignment.Near, Alignment = StringAlignment.Near }; StringFormat centeralign = new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }; System.Drawing.Rectangle text = Layouts.LiturgyLayout.Text.Move(Layouts.LiturgyLayout.Key.Location); System.Drawing.Rectangle speaker = Layouts.LiturgyLayout.Speaker.Move(Layouts.LiturgyLayout.Key.Location); //gfx.DrawRectangle(Pens.Red, text); //gfx.DrawRectangle(Pens.Purple, speaker); // compute line spacing int textlinecombinedheight = 0; foreach (var line in slide.Lines) { textlinecombinedheight += (int)(float)line.Content[0].Attributes["height"]; } int interspace = (renderInfo.TextBox.Height - textlinecombinedheight) / (slide.Lines.Count + 1); int linenum = 0; int linepos = interspace; foreach (var line in slide.Lines) { gfx.DrawString(line.Content[0].Data, renderInfo.RegularFont, Brushes.Black, text.Move(0, linepos + interspace * linenum).Location, topleftalign); linenum++; linepos += (int)(float)line.Content[0].Attributes["height"]; } res.Bitmap = bmp; return(res); }