Ejemplo n.º 1
0
        public RenderedSlide RenderSlide(SermonLayoutRenderInfo renderInfo, Slide slide, List <Compiler.XenonCompilerMessage> messages)
        {
            RenderedSlide res = new RenderedSlide();

            res.MediaType  = MediaType.Image;
            res.AssetPath  = "";
            res.RenderedAs = "Liturgy-t1restart";

            Bitmap   bmp  = new Bitmap(Layouts.SermonLayout.Size.Width, Layouts.SermonLayout.Size.Height);
            Bitmap   kbmp = new Bitmap(Layouts.SermonLayout.Size.Width, Layouts.SermonLayout.Size.Height);
            Graphics gfx  = Graphics.FromImage(bmp);
            Graphics kgfx = Graphics.FromImage(kbmp);

            gfx.Clear(Color.Gray);
            kgfx.Clear(Color.Black);
            gfx.FillRectangle(Brushes.Black, Layouts.SermonLayout.Key);
            kgfx.FillRectangle(new SolidBrush(slide.Colors["keytrans"]), Layouts.SermonLayout.Key);

            // put 'preacher' in top left
            gfx.DrawString(slide.Lines[2].Content[0].Data, renderInfo.RegularFont, Brushes.White, Layouts.SermonLayout.TopLine.Move(Layouts.SermonLayout.TextAera.Location).Move(Layouts.SermonLayout.Key.Location).Move(100, 0), GraphicsHelper.LeftVerticalCenterAlign);
            kgfx.DrawString(slide.Lines[2].Content[0].Data, renderInfo.RegularFont, Brushes.White, Layouts.SermonLayout.TopLine.Move(Layouts.SermonLayout.TextAera.Location).Move(Layouts.SermonLayout.Key.Location).Move(100, 0), GraphicsHelper.LeftVerticalCenterAlign);
            // put reference in top right
            gfx.DrawString(slide.Lines[1].Content[0].Data, renderInfo.ItalicFont, Brushes.White, Layouts.SermonLayout.TopLine.Move(Layouts.SermonLayout.TextAera.Location).Move(Layouts.SermonLayout.Key.Location).Move(-100, 0), GraphicsHelper.RightVerticalCenterAlign);
            kgfx.DrawString(slide.Lines[1].Content[0].Data, renderInfo.ItalicFont, Brushes.White, Layouts.SermonLayout.TopLine.Move(Layouts.SermonLayout.TextAera.Location).Move(Layouts.SermonLayout.Key.Location).Move(-100, 0), GraphicsHelper.RightVerticalCenterAlign);
            // put title in center mid
            gfx.DrawString(slide.Lines[0].Content[0].Data, renderInfo.BoldFont, Brushes.White, Layouts.SermonLayout.MainLine.Move(Layouts.SermonLayout.TextAera.Location).Move(Layouts.SermonLayout.Key.Location), GraphicsHelper.CenterAlign);
            kgfx.DrawString(slide.Lines[0].Content[0].Data, renderInfo.BoldFont, Brushes.White, Layouts.SermonLayout.MainLine.Move(Layouts.SermonLayout.TextAera.Location).Move(Layouts.SermonLayout.Key.Location), GraphicsHelper.CenterAlign);

            res.Bitmap    = bmp;
            res.KeyBitmap = kbmp;
            return(res);
        }
        private RenderedSlide _RenderSlide(Slide slide, List <XenonCompilerMessage> Messages)
        {
            // use an appropriate slide render for the task
            switch (slide.Format)
            {
            case SlideFormat.Liturgy:
                return(lsr.RenderSlide(_project.Layouts.LiturgyLayout.GetRenderInfo(), slide, Messages));

            case SlideFormat.LiturgyVerse:
                return(lvsr.RenderSlide(_project.Layouts.LiturgyLayout.GetRenderInfo(), slide, Messages));

            case SlideFormat.LiturgyTitledVerse:
                return(tlvsr.RenderSlide(slide, Messages));

            case SlideFormat.Video:
                return(vsr.RenderSlide(slide, Messages));

            case SlideFormat.UnscaledImage:
                return(isr.RenderImageSlide(slide, Messages));

            case SlideFormat.ScaledImage:
                return(isr.RenderImageSlide(slide, Messages));

            case SlideFormat.AutoscaledImage:
                return(isr.RenderImageSlide(slide, Messages));

            case SlideFormat.FilterImage:
                return(ifr.RenderImageSlide(slide, Messages));

            case SlideFormat.LiturgyImage:
                return(isr.RenderImageSlide(slide, Messages));

            case SlideFormat.Reading:
                return(rsr.RenderSlide(_project.Layouts.ReadingLayout.GetRenderInfo(), slide, Messages));

            case SlideFormat.SermonTitle:
                return(ssr.RenderSlide(_project.Layouts.SermonLayout.GetRenderInfo(), slide, Messages));

            case SlideFormat.AnthemTitle:
                return(atsr.RenderSlide(slide, Messages));

            case SlideFormat.TwoPartTitle:
                return(tpsr.RenderSlide(slide, Messages));

            case SlideFormat.HymnTextVerse:
                return(hvsr.RenderSlide(_project.Layouts.TextHymnLayout.GetRenderInfo(), slide, Messages));

            case SlideFormat.Prefab:
                return(psr.RenderSlide(slide, Messages));

            case SlideFormat.Script:
                return(sr.RenderSlide(slide, Messages));

            case SlideFormat.ResourceCopy:
                return(csr.RenderSlide(slide, Messages));

            default:
                return(RenderedSlide.Default());
            }
        }
        public RenderedSlide RenderSlide(SlideAssembly.Slide slide, List <Compiler.XenonCompilerMessage> messages)
        {
            string rendertype = "Video";

            // check if path exists
            if (slide.Data.ContainsKey("key-type"))
            {
                if ((string)slide.Data["key-type"] == "chroma")
                {
                    rendertype = "ChromaKeyVideo";
                }
            }
            RenderedSlide res = new RenderedSlide()
            {
                AssetPath  = slide.Lines[0].Content[0].Data,
                MediaType  = SlideAssembly.MediaType.Video,
                RenderedAs = rendertype
            };

            if (!System.IO.File.Exists(res.AssetPath))
            {
                messages.Add(new Compiler.XenonCompilerMessage()
                {
                    ErrorMessage = $"Could not find file {res.AssetPath}", ErrorName = "Missing Video File", Level = Compiler.XenonCompilerMessageType.Error
                });
                throw new FileNotFoundException();
            }

            res.KeyBitmap = new Bitmap(1920, 1080);
            Graphics gfx = Graphics.FromImage(res.KeyBitmap);

            // for now videos are fully transparent all the time
            gfx.Clear(Color.White);
            return(res);
        }
        public RenderedSlide RenderSlide(Slide slide, List <Compiler.XenonCompilerMessage> messages)
        {
            RenderedSlide res = new RenderedSlide();

            res.MediaType  = MediaType.Text;
            res.AssetPath  = "";
            res.RenderedAs = "Action";
            res.Text       = (string)slide.Data["source"];
            return(res);
        }
        public RenderedSlide RenderSlide(Slide slide, List <Compiler.XenonCompilerMessage> messages)
        {
            RenderedSlide res = new RenderedSlide();

            // only do audio for now
            res.MediaType     = MediaType.Audio;
            res.RenderedAs    = "Resource";
            res.Name          = Path.GetFileNameWithoutExtension(slide.Asset);
            res.CopyExtension = Path.GetExtension(slide.Asset);
            res.AssetPath     = slide.Asset;
            return(res);
        }
Ejemplo n.º 6
0
        public RenderedSlide RenderSlide(Slide slide, List <Compiler.XenonCompilerMessage> messages)
        {
            RenderedSlide res = new RenderedSlide();

            res.MediaType  = MediaType.Image;
            res.AssetPath  = "";
            res.RenderedAs = "Liturgy";

            Bitmap   bmp  = new Bitmap(Layouts.TwoPartTitleLayout.Size.Width, Layouts.TwoPartTitleLayout.Size.Height);
            Bitmap   kbmp = new Bitmap(Layouts.TwoPartTitleLayout.Size.Width, Layouts.TwoPartTitleLayout.Size.Height);
            Graphics gfx  = Graphics.FromImage(bmp);
            Graphics kgfx = Graphics.FromImage(kbmp);

            gfx.Clear(Color.Gray);
            kgfx.Clear(Color.Black);
            gfx.FillRectangle(Brushes.Black, Layouts.TwoPartTitleLayout.Key);
            kgfx.FillRectangle(new SolidBrush(slide.Colors["keytrans"]), Layouts.TwoPartTitleLayout.Key);

            Font bf = new Font(Layouts.TwoPartTitleLayout.Font, FontStyle.Bold);

            var lineheight = gfx.MeasureStringCharacters(slide.Lines[0].Content[0].Data, bf, Layouts.AnthemTitleLayout.Key);

            if ((string)slide.Data["orientation"] == "vertical")
            {
                gfx.DrawString(slide.Lines[0].Content[0].Data, bf, Brushes.White, Layouts.TwoPartTitleLayout.Line1.Move(Layouts.TwoPartTitleLayout.Key.Location), GraphicsHelper.CenterAlign);
                kgfx.DrawString(slide.Lines[0].Content[0].Data, bf, Brushes.White, Layouts.TwoPartTitleLayout.Line1.Move(Layouts.TwoPartTitleLayout.Key.Location), GraphicsHelper.CenterAlign);
                gfx.DrawString(slide.Lines[1].Content[0].Data, Layouts.TwoPartTitleLayout.Font, Brushes.White, Layouts.TwoPartTitleLayout.Line2.Move(Layouts.TwoPartTitleLayout.Key.Location), GraphicsHelper.CenterAlign);
                kgfx.DrawString(slide.Lines[1].Content[0].Data, Layouts.TwoPartTitleLayout.Font, Brushes.White, Layouts.TwoPartTitleLayout.Line2.Move(Layouts.TwoPartTitleLayout.Key.Location), GraphicsHelper.CenterAlign);
            }
            else
            {
                int ycord = (int)((Layouts.TwoPartTitleLayout.Key.Height / 2) - (lineheight.Height / 2));
                gfx.DrawString(slide.Lines[0].Content[0].Data, bf, Brushes.White, Layouts.TwoPartTitleLayout.MainLine.Move(Layouts.TwoPartTitleLayout.Key.Location).Move(0, ycord), GraphicsHelper.LeftVerticalCenterAlign);
                kgfx.DrawString(slide.Lines[0].Content[0].Data, bf, Brushes.White, Layouts.TwoPartTitleLayout.MainLine.Move(Layouts.TwoPartTitleLayout.Key.Location).Move(0, ycord), GraphicsHelper.LeftVerticalCenterAlign);
                gfx.DrawString(slide.Lines[1].Content[0].Data, Layouts.TwoPartTitleLayout.Font, Brushes.White, Layouts.TwoPartTitleLayout.MainLine.Move(Layouts.TwoPartTitleLayout.Key.Location).Move(0, ycord), GraphicsHelper.RightVerticalCenterAlign);
                kgfx.DrawString(slide.Lines[1].Content[0].Data, Layouts.TwoPartTitleLayout.Font, Brushes.White, Layouts.TwoPartTitleLayout.MainLine.Move(Layouts.TwoPartTitleLayout.Key.Location).Move(0, ycord), GraphicsHelper.RightVerticalCenterAlign);
            }


            res.Bitmap    = bmp;
            res.KeyBitmap = kbmp;
            return(res);
        }
        public static void ExportSlides(string directory, Project proj, List <XenonCompilerMessage> messages)
        {
            foreach (var slide in proj.Slides)
            {
                SlideRenderer slideRenderer = new SlideRenderer(proj);
                // render the slide
                RenderedSlide rs = slideRenderer.RenderSlide(slide, messages);

                if (rs.RenderedAs == "Resource")
                {
                    // for now only allow audio files to be rendered as resource
                    string filename = Path.Join(directory, $"Resource_{rs.Name}{rs.CopyExtension}");
                    File.Copy(rs.AssetPath, filename, true);
                    continue;
                }

                if (rs.MediaType == MediaType.Image)
                {
                    string filename  = Path.Join(directory, $"{slide.Number}_{rs.RenderedAs}.png");
                    string kfilename = Path.Join(directory, $"Key_{slide.Number}.png");
                    rs.Bitmap.Save(filename, ImageFormat.Png);
                    rs.KeyBitmap.Save(kfilename, ImageFormat.Png);
                }
                else if (rs.MediaType == MediaType.Video)
                {
                    string filename  = Path.Join(directory, $"{slide.Number}_{rs.RenderedAs}.mp4");
                    string kfilename = Path.Join(directory, $"Key_{slide.Number}.png");
                    File.Copy(rs.AssetPath, filename);
                    rs.KeyBitmap.Save(kfilename, ImageFormat.Png);
                }
                else if (rs.MediaType == MediaType.Text)
                {
                    // output text file
                    string filename = Path.Join(directory, $"{slide.Number}_{rs.RenderedAs}.txt");
                    using (StreamWriter sw = new StreamWriter(filename, false))
                    {
                        sw.Write(rs.Text);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public RenderedSlide RenderSlide(Slide slide, List <Compiler.XenonCompilerMessage> messages)
        {
            RenderedSlide res = new RenderedSlide();

            res.MediaType  = MediaType.Image;
            res.AssetPath  = "";
            res.RenderedAs = "Liturgy";

            Bitmap   bmp  = new Bitmap(Layouts.AnthemTitleLayout.Size.Width, Layouts.AnthemTitleLayout.Size.Height);
            Bitmap   kbmp = new Bitmap(Layouts.AnthemTitleLayout.Size.Width, Layouts.AnthemTitleLayout.Size.Height);
            Graphics gfx  = Graphics.FromImage(bmp);
            Graphics kgfx = Graphics.FromImage(kbmp);

            gfx.Clear(Color.Gray);
            kgfx.Clear(Color.Black);
            gfx.FillRectangle(Brushes.Black, Layouts.SermonLayout.Key);
            SolidBrush kb = new SolidBrush(slide.Colors["keytrans"]);

            kgfx.FillRectangle(kb, Layouts.SermonLayout.Key);

            Font bf = new Font(Layouts.AnthemTitleLayout.Font, FontStyle.Bold);

            // musician
            gfx.DrawString(slide.Lines[1].Content[0].Data, bf, Brushes.White, Layouts.AnthemTitleLayout.TopLine.Move(Layouts.AnthemTitleLayout.Key.Location), GraphicsHelper.LeftVerticalCenterAlign);
            kgfx.DrawString(slide.Lines[1].Content[0].Data, bf, Brushes.White, Layouts.AnthemTitleLayout.TopLine.Move(Layouts.AnthemTitleLayout.Key.Location), GraphicsHelper.LeftVerticalCenterAlign);
            // anthem title
            gfx.DrawString(slide.Lines[0].Content[0].Data, bf, Brushes.White, Layouts.AnthemTitleLayout.TopLine.Move(Layouts.AnthemTitleLayout.Key.Location), GraphicsHelper.RightVerticalCenterAlign);
            kgfx.DrawString(slide.Lines[0].Content[0].Data, bf, Brushes.White, Layouts.AnthemTitleLayout.TopLine.Move(Layouts.AnthemTitleLayout.Key.Location), GraphicsHelper.RightVerticalCenterAlign);
            // accompanianist
            gfx.DrawString(slide.Lines[2].Content[0].Data, Layouts.AnthemTitleLayout.Font, Brushes.White, Layouts.AnthemTitleLayout.MainLine.Move(Layouts.AnthemTitleLayout.Key.Location), GraphicsHelper.LeftVerticalCenterAlign);
            kgfx.DrawString(slide.Lines[2].Content[0].Data, Layouts.AnthemTitleLayout.Font, Brushes.White, Layouts.AnthemTitleLayout.MainLine.Move(Layouts.AnthemTitleLayout.Key.Location), GraphicsHelper.LeftVerticalCenterAlign);
            // credit
            gfx.DrawString(slide.Lines[3].Content[0].Data, Layouts.AnthemTitleLayout.Font, Brushes.White, Layouts.AnthemTitleLayout.MainLine.Move(Layouts.AnthemTitleLayout.Key.Location), GraphicsHelper.RightVerticalCenterAlign);
            kgfx.DrawString(slide.Lines[3].Content[0].Data, Layouts.AnthemTitleLayout.Font, Brushes.White, Layouts.AnthemTitleLayout.MainLine.Move(Layouts.AnthemTitleLayout.Key.Location), GraphicsHelper.RightVerticalCenterAlign);

            res.Bitmap    = bmp;
            res.KeyBitmap = kbmp;
            return(res);
        }
        public RenderedSlide RenderSlide(HymnTextVerseRenderInfo renderInfo, Slide slide, System.Collections.Generic.List <Compiler.XenonCompilerMessage> messages)
        {
            RenderedSlide res = new RenderedSlide();

            res.MediaType  = MediaType.Image;
            res.AssetPath  = "";
            res.RenderedAs = "Full";

            Bitmap   bmp  = new Bitmap(Layouts.TextHymnLayout.Size.Width, Layouts.TextHymnLayout.Size.Height);
            Bitmap   kbmp = new Bitmap(Layouts.TextHymnLayout.Size.Width, Layouts.TextHymnLayout.Size.Height);
            Graphics gfx  = Graphics.FromImage(bmp);
            Graphics kgfx = Graphics.FromImage(kbmp);

            if ((bool)slide.Data.GetOrDefault("is-overlay", false))
            {
                res.RenderedAs = "Full.nodrive";
                RenderOverlayVerse(renderInfo, slide, res, bmp, kbmp, gfx, kgfx);
            }
            else
            {
                RenderNormalVerse(renderInfo, slide, res, bmp, kbmp, gfx, kgfx);
            }
            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);
        }
Ejemplo n.º 11
0
        public RenderedSlide RenderImageSlide(Slide slide, List <Compiler.XenonCompilerMessage> messages)
        {
            RenderedSlide res = new RenderedSlide();

            res.MediaType = MediaType.Image;
            res.AssetPath = slide.Asset;

            Bitmap   kbmp = new Bitmap(1920, 1080);
            Graphics kgfx = Graphics.FromImage(kbmp);

            kgfx.Clear(Color.White);
            res.KeyBitmap = kbmp;

            Bitmap sourceimage;

            try
            {
                sourceimage = new Bitmap(slide.Asset);
            }
            catch (Exception)
            {
                throw new Exception($"Unable to load image <{slide.Asset}> for slide {slide}");
            }

            if (slide.Format == SlideFormat.UnscaledImage)
            {
                res.Bitmap     = RenderUnscaled(sourceimage);
                res.RenderedAs = "Full";
                if (slide.Data.ContainsKey("key-type"))
                {
                    if ((string)slide.Data["key-type"] == "chroma")
                    {
                        res.RenderedAs = "ChromaKeyStill";
                    }
                }
            }
            else if (slide.Format == SlideFormat.ScaledImage)
            {
                res.Bitmap     = RenderUniformScale(sourceimage);
                res.RenderedAs = "Full";
                if (slide.Data.ContainsKey("key-type"))
                {
                    if ((string)slide.Data["key-type"] == "chroma")
                    {
                        res.RenderedAs = "ChromaKeyStill";
                    }
                }
            }
            else if (slide.Format == SlideFormat.AutoscaledImage)
            {
                bool invert = false;
                if (slide.Data.ContainsKey("invert-color"))
                {
                    invert = (bool)slide.Data["invert-color"];
                }
                Color ccm = Color.White;
                Color ccf = Color.Black;
                int   cct = 0;
                bool  cc  = false;
                if (slide.Data.ContainsKey("color-correct-black-white"))
                {
                    cc  = true;
                    ccm = Color.Black;
                    cct = (int)slide.Data["color-correct-black-white"];
                    ccf = Color.White;
                }
                res.Bitmap     = RenderAutoScaled(sourceimage, invert, (cc, ccm, ccf, cct));
                res.RenderedAs = "Full";
                if (slide.Data.ContainsKey("key-type"))
                {
                    if ((string)slide.Data["key-type"] == "chroma")
                    {
                        res.RenderedAs = "ChromaKeyStill";
                    }
                }
            }
            else if (slide.Format == SlideFormat.LiturgyImage)
            {
                res.Bitmap     = RenderLiturgyImage(sourceimage);
                res.KeyBitmap  = RenderLiturgyImageKey(sourceimage, slide.Colors["keytrans"]);
                res.RenderedAs = "Liturgy";
            }

            return(res);
        }
        public RenderedSlide RenderSlide(Slide slide, List <XenonCompilerMessage> messages)
        {
            RenderedSlide res = new RenderedSlide();

            res.AssetPath  = "";
            res.MediaType  = MediaType.Image;
            res.RenderedAs = "Full";

            Bitmap   bmp  = new Bitmap(Layouts.PrefabLayout.Size.Width, Layouts.PrefabLayout.Size.Height);
            Bitmap   kbmp = new Bitmap(Layouts.PrefabLayout.Size.Width, Layouts.PrefabLayout.Size.Height);
            Graphics gfx  = Graphics.FromImage(bmp);
            Graphics kgfx = Graphics.FromImage(kbmp);

            gfx.Clear(Color.White);
            kgfx.Clear(Color.White);

            res.KeyBitmap = kbmp;


            Bitmap src = null;

            try
            {
                switch (slide.Data["prefabtype"])
                {
                case PrefabSlides.Copyright:
                    res.RenderedAs = "Full-startrecord";
                    src            = ProjectResources.PrefabSlides.CopyrightLicense;
                    break;

                case PrefabSlides.ViewServices:
                    src = ProjectResources.PrefabSlides.ViewServices;
                    break;

                case PrefabSlides.ViewSeries:
                    src = ProjectResources.PrefabSlides.ViewSessions;
                    break;

                case PrefabSlides.ApostlesCreed:
                    switch (slide.Data["layoutnum"])
                    {
                    case 1:
                        src = ProjectResources.PrefabSlides.ApostlesCreed1;
                        break;

                    case 2:
                        src = ProjectResources.PrefabSlides.ApostlesCreed2;
                        break;

                    case 3:
                        src = ProjectResources.PrefabSlides.ApostlesCreed3;
                        break;
                    }
                    break;

                case PrefabSlides.NiceneCreed:
                    switch (slide.Data["layoutnum"])
                    {
                    case 1:
                        src = ProjectResources.PrefabSlides.NiceneCreed1;
                        break;

                    case 2:
                        src = ProjectResources.PrefabSlides.NiceneCreed2;
                        break;

                    case 3:
                        src = ProjectResources.PrefabSlides.NiceneCreed3;
                        break;

                    case 4:
                        src = ProjectResources.PrefabSlides.NiceneCreed4;
                        break;

                    case 5:
                        src = ProjectResources.PrefabSlides.NiceneCreed5;
                        break;
                    }
                    break;

                case PrefabSlides.LordsPrayer:
                    src = ProjectResources.PrefabSlides.LordsPrayer;
                    break;

                // special case for prefab scripts
                case PrefabSlides.Script_LiturgyOff:
                case PrefabSlides.Script_OrganIntro:
                    ScriptRenderer sr = new ScriptRenderer();
                    return(sr.RenderSlide(slide, messages));
                }
            }
            catch (Exception ex)
            {
                res.Bitmap = bmp;
                string tmp = "KEY ERROR on data attribute";
                object a;
                slide.Data.TryGetValue("prefabtype", out a);
                if (a is PrefabSlides && a != null)
                {
                    tmp = ((PrefabSlides)a).Convert();
                }
                messages.Add(new XenonCompilerMessage()
                {
                    Level = XenonCompilerMessageType.Error, ErrorMessage = $"Requested prefab image not loaded. While rendering slide {slide.Number}", ErrorName = "Prefab not found", Token = tmp
                });
                throw ex;
            }

            if (src != null)
            {
                gfx.DrawImage(src, new Rectangle(new Point(0, 0), Layouts.PrefabLayout.Size));
            }

            res.Bitmap = bmp;
            return(res);
        }
        private void RenderOverlayVerse(HymnTextVerseRenderInfo renderInfo, Slide slide, RenderedSlide res, Bitmap bmp, Bitmap kbmp, Graphics gfx, Graphics kgfx)
        {
            gfx.Clear(Color.White);
            // try background transparency at 50%?? (not sure if gray is actualy 50%)
            kgfx.Clear(Color.Gray);

            // debug

            // define new boxes for overlays
            Rectangle MainHymnNameBox = new Rectangle((int)(1920 * 0.1), (int)(1080 * 0.03), (int)(1920 * 0.8), (int)(1080 * 0.13));

            //gfx.DrawRectangle(Pens.Green, MainHymnNameBox);

            //gfx.DrawRectangle(Pens.Green, Layouts.TextHymnLayout.CopyrightBox);
            //gfx.DrawRectangle(Pens.Blue, Layouts.TextHymnLayout.NameBox);
            //gfx.DrawRectangle(Pens.Blue, Layouts.TextHymnLayout.NumberBox);
            //gfx.DrawRectangle(Pens.Blue, Layouts.TextHymnLayout.TitleBox);
            //gfx.DrawRectangle(Pens.Red, Layouts.TextHymnLayout.TextBox);

            // draw name
            string name     = (string)slide.Data["name"];
            Font   namefont = new Font("Arial", 30, (FontStyle.Bold | FontStyle.Underline));

            gfx.DrawString(name, namefont, Brushes.Black, MainHymnNameBox, GraphicsHelper.CenterAlign);
            kgfx.DrawString(name, namefont, Brushes.White, MainHymnNameBox, GraphicsHelper.CenterAlign);

            // draw title
            Font   titlefont       = new Font("Arial", 30);
            string titleandsubname = (string)slide.Data["sub-name"] == "" ? (string)slide.Data["title"] : $"{(string)slide.Data["title"]}\r\n{(string)slide.Data["sub-name"]}";

            gfx.DrawString(titleandsubname, titlefont, Brushes.Black, Layouts.TextHymnLayout.TitleBox, GraphicsHelper.CenterAlign);
            kgfx.DrawString(titleandsubname, titlefont, Brushes.White, Layouts.TextHymnLayout.TitleBox, GraphicsHelper.CenterAlign);

            // draw sub-title
            //gfx.DrawString((string)slide.Data["sub-name"], renderInfo.TitleFont, Brushes.Black, Layouts.TextHymnLayout.TitleBox, GraphicsHelper.CenterAlign);

            // draw number and tune
            string numberandtune = (string)slide.Data["tune"] == "" ? $"{(string)slide.Data["number"]}" : $"{(string)slide.Data["number"]}\r\n{(string)slide.Data["tune"]}";

            gfx.DrawString(numberandtune, renderInfo.NumberFont, Brushes.Black, Layouts.TextHymnLayout.NumberBox, GraphicsHelper.CenterAlign);
            kgfx.DrawString(numberandtune, renderInfo.NumberFont, Brushes.White, Layouts.TextHymnLayout.NumberBox, GraphicsHelper.CenterAlign);

            // draw copyright
            gfx.DrawString((string)slide.Data["copyright"], renderInfo.CopyrightFont, Brushes.Gray, Layouts.TextHymnLayout.CopyrightBox, GraphicsHelper.CenterAlign);
            kgfx.DrawString((string)slide.Data["copyright"], renderInfo.CopyrightFont, Brushes.Gray, Layouts.TextHymnLayout.CopyrightBox, GraphicsHelper.CenterAlign);

            // draw text
            // compute interline spacing


            Rectangle versebox = new Rectangle(0, (int)(1080 * 0.16), 1920, (int)(1080 * 0.7));
            //gfx.DrawRectangle(Pens.Red, versebox);
            Font versefont = new Font("Arial", 56, FontStyle.Bold);

            double lineheight = gfx.MeasureString(slide.Lines[0].Content[0].Data, versefont).Height;
            double interspace = (versebox.Height - (slide.Lines.Count * lineheight)) / (slide.Lines.Count + 1);

            double    offset = 0;
            Rectangle vline  = new Rectangle(0, versebox.Y, versebox.Width, (int)lineheight).Move(new Point(0, (int)interspace));

            foreach (var line in slide.Lines)
            {
                gfx.DrawString(line.Content[0].Data, versefont, Brushes.Black, vline.Move(new Point(0, (int)offset)), GraphicsHelper.CenterAlign);
                kgfx.DrawString(line.Content[0].Data, versefont, Brushes.White, vline.Move(new Point(0, (int)offset)), GraphicsHelper.CenterAlign);
                offset += interspace + lineheight;
            }

            res.Bitmap    = bmp;
            res.KeyBitmap = kbmp;
        }
        private void RenderNormalVerse(HymnTextVerseRenderInfo renderInfo, Slide slide, RenderedSlide res, Bitmap bmp, Bitmap kbmp, Graphics gfx, Graphics kgfx)
        {
            gfx.Clear(Color.White);
            kgfx.Clear(Color.White);

            // debug

            //gfx.DrawRectangle(Pens.Green, Layouts.TextHymnLayout.CopyrightBox);
            //gfx.DrawRectangle(Pens.Blue, Layouts.TextHymnLayout.NameBox);
            //gfx.DrawRectangle(Pens.Blue, Layouts.TextHymnLayout.NumberBox);
            //gfx.DrawRectangle(Pens.Blue, Layouts.TextHymnLayout.TitleBox);
            //gfx.DrawRectangle(Pens.Red, Layouts.TextHymnLayout.TextBox);

            // draw name
            string name = (string)slide.Data["name"];

            gfx.DrawString(name, renderInfo.NameFont, Brushes.Black, Layouts.TextHymnLayout.NameBox, GraphicsHelper.CenterAlign);

            // draw title
            string titleandsubname = (string)slide.Data["sub-name"] == "" ? (string)slide.Data["title"] : $"{(string)slide.Data["title"]}\r\n{(string)slide.Data["sub-name"]}";

            gfx.DrawString(titleandsubname, renderInfo.TitleFont, Brushes.Black, Layouts.TextHymnLayout.TitleBox, GraphicsHelper.CenterAlign);

            // draw sub-title
            //gfx.DrawString((string)slide.Data["sub-name"], renderInfo.TitleFont, Brushes.Black, Layouts.TextHymnLayout.TitleBox, GraphicsHelper.CenterAlign);

            // draw number and tune
            string numberandtune = (string)slide.Data["tune"] == "" ? $"{(string)slide.Data["number"]}" : $"{(string)slide.Data["number"]}\r\n{(string)slide.Data["tune"]}";

            gfx.DrawString(numberandtune, renderInfo.NumberFont, Brushes.Black, Layouts.TextHymnLayout.NumberBox, GraphicsHelper.CenterAlign);

            // draw copyright
            gfx.DrawString((string)slide.Data["copyright"], renderInfo.CopyrightFont, Brushes.Gray, Layouts.TextHymnLayout.CopyrightBox, GraphicsHelper.CenterAlign);

            // draw text
            // compute interline spacing



            double lineheight = gfx.MeasureString(slide.Lines[0].Content[0].Data, renderInfo.VerseFont).Height;
            double interspace = (Layouts.TextHymnLayout.TextBox.Height - (slide.Lines.Count * lineheight)) / (slide.Lines.Count + 1);

            double    offset = 0;
            Rectangle vline  = new Rectangle(0, Layouts.TextHymnLayout.TextBox.Y, Layouts.TextHymnLayout.TextBox.Width, (int)lineheight).Move(new Point(0, (int)interspace));

            foreach (var line in slide.Lines)
            {
                gfx.DrawString(line.Content[0].Data, renderInfo.VerseFont, Brushes.Black, vline.Move(new Point(0, (int)offset)), GraphicsHelper.CenterAlign);
                offset += interspace + lineheight;
            }

            res.Bitmap    = bmp;
            res.KeyBitmap = kbmp;
        }
        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);
        }