Ejemplo n.º 1
0
        private void btnAddReg_Click(object sender, EventArgs e)
        {
            // Add a new region
            PresenterFont f = new PresenterFont();

            f.VerticalAlignment   = VerticalAlignment.Top;
            f.HorizontalAlignment = HorizontalAlignment.Left;
            GfxTextRegion r = new GfxTextRegion(new Rectangle(30, 30, 300, 150), f, "Sample message");

            proj.data.lTextRegions.Add(r);
            proj.RefreshUI();

            // Set the region as current
            foreach (TextRegionCtrl c in pnlPreviewImage.Controls)
            {
                if (c.textRegion == r)
                {
                    currentRegion = c;
                }
                c.Selected = c.textRegion == r;
            }
            txtMessage.Text       = r.message;
            txtMessage.Enabled    = true;
            btnChangeFont.Enabled = true;
            proj.dirty            = true;
        }
Ejemplo n.º 2
0
            public void PrepFontFit(GfxContext ctx, Dictionary <int, BibleVerse> verses, int startVerse, PresenterFont font)
            {
                Size nativeSize = DisplayEngine.NativeResolution.Size;

                //////////////////////////////////////////////////////////////////
                // Format data
                BibleVerse bv1      = verses[1];
                string     bookname = Program.BibleDS.BibleLookUp.FindByVersionIdMappingBook(bv1.RefVersion, bv1.RefBook).DisplayBook;
                string     title    = bookname + " " + bv1.RefChapter;
                string     data     = "";

                for (int i = startVerse; i <= verses.Count; i++)
                {
                    data += verses[i].RefVerse + ". " + verses[i].Text + "\r\n";
                }

                //////////////////////////////////////////////////////////////////
                // Measure
                StringFormat sf           = GetStringFormat();
                int          insideHeight = nativeSize.Height - paddingPixels * 2;
                int          insideWidth  = nativeSize.Width - paddingPixels * 2;
                int          titleHeight  = font.SizeInPoints * 2;
                RectangleF   rTitle       = new RectangleF(paddingPixels, paddingPixels, insideWidth, titleHeight);
                RectangleF   rText        = new RectangleF(paddingPixels, paddingPixels + titleHeight,
                                                           insideWidth, insideHeight - titleHeight);

                //////////////////////////////////////////////////////////////////
                // Build context
                ctx.destSize = DisplayEngine.NativeResolution.Size;
                ctx.textRegions.Clear();

                // Title text
                GfxTextRegion trTitle = new GfxTextRegion();

                ctx.textRegions.Add(trTitle);
                trTitle.font = (PresenterFont)font.Clone();
                trTitle.font.SizeInPoints = (int)(trTitle.font.SizeInPoints * 1.5);
                trTitle.message           = title;
                trTitle.bounds            = rTitle;

                // Data
                GfxTextRegion trData = new GfxTextRegion();

                ctx.textRegions.Add(trData);
                trData.font = (PresenterFont)font.Clone();
                trData.font.VerticalAlignment   = VerticalAlignment.Top;
                trData.font.HorizontalAlignment = HorizontalAlignment.Left;
                trData.fontClip = true;
                trData.message  = data;
                trData.bounds   = rText;
            }
Ejemplo n.º 3
0
        public Dictionary <string, AnouncementData> GetAnouncements()
        {
            #if DEMO
            return(new Dictionary <string, AnouncementData>());
            #else
            Dictionary <string, AnouncementData> anouncements = new Dictionary <string, AnouncementData>();
            foreach (XmlNode xn in xd.DocumentElement.ChildNodes)
            {
                if (xn.Name == "Anouncement")
                {
                    AnouncementData d = new AnouncementData();
                    d.name    = xn.Attributes["Name"].InnerText;
                    d.imageId = int.Parse(xn["ImageId"].InnerText);
                    if (xn["Opacity"] != null)
                    {
                        d.opacity = int.Parse(xn["Opacity"].InnerText);
                    }

                    // Load all text regions
                    foreach (XmlNode xnc in xn.ChildNodes)
                    {
                        if (xnc.Name == "TextRegion")
                        {
                            GfxTextRegion textRegion = new GfxTextRegion();
                            string[]      parts      = xnc["Bounds"].InnerText.Split(",".ToCharArray());
                            if (parts.Length != 4)
                            {
                                continue;
                            }
                            textRegion.bounds  = new RectangleF(float.Parse(parts[0]), float.Parse(parts[1]), float.Parse(parts[2]), float.Parse(parts[3]));
                            textRegion.message = xnc["Message"].InnerText;
                            textRegion.font    = PresenterFont.FromXMLNode(xnc);

                            d.lTextRegions.Add(textRegion);
                        }
                    }

                    anouncements.Add(d.name, d);
                }
            }
            return(anouncements);
            #endif
        }
Ejemplo n.º 4
0
        public GfxContext GetCurrentGfxContext()
        {
            // Check bounds
            if (currentSlideNum > songSlides.Count - 1)
            {
                currentSlideNum = songSlides.Count - 1;
            }

            SongSlideData data    = songSlides[currentSlideNum];
            string        verse   = data.text;
            const int     PADDING = 30;

            // No formatting support
            if (stripFormatting)
            {
                verse = SongProject.RemoveVerseFormatting(verse);
            }

            // Double space support
            if (!stripFormatting)
            {
                string lineSpacing = songFont.DoubleSpace ? "\r\n\r\n" : "\r\n";
                verse = verse.Replace("\r\n", "\n").Replace("\n", lineSpacing);
            }

            #region Standard format (build context)
            Size nativeSize = DisplayEngine.NativeResolution.Size;
            graphicsContext.destSize = nativeSize;
            graphicsContext.textRegions.Clear();

            // Add the verse box
            GfxTextRegion rVerse = new GfxTextRegion();
            rVerse.bounds  = new Rectangle(PADDING, PADDING, nativeSize.Width - PADDING * 2, nativeSize.Height - 80);
            rVerse.font    = songFont;
            rVerse.message = verse;
            graphicsContext.textRegions.Add(rVerse);

            // Last slide ***
            if (data.isLast)
            {
                GfxTextRegion rEnd = new GfxTextRegion();
                rEnd.bounds = new Rectangle(PADDING, nativeSize.Height - 80, nativeSize.Width - PADDING * 2, 40);
                rEnd.font   = (PresenterFont)songFont.Clone();
                rEnd.font.HorizontalAlignment = HorizontalAlignment.Center;
                rEnd.message = "* * *";
                graphicsContext.textRegions.Add(rEnd);
            }

            // Copyright
            if (copyright != "")
            {
                GfxTextRegion rEnd = new GfxTextRegion();
                rEnd.bounds                   = new Rectangle(PADDING, nativeSize.Height - 40, nativeSize.Width - PADDING * 2, 40 - 7);
                rEnd.font                     = new PresenterFont();
                rEnd.font.fontName            = "Verdana";
                rEnd.font.Italic              = true;
                rEnd.font.SizeInPoints        = 12;
                rEnd.font.HorizontalAlignment = HorizontalAlignment.Center;
                rEnd.font.VerticalAlignment   = VerticalAlignment.Bottom;
                rEnd.font.Color               = songFont.Color;
                rEnd.font.Shadow              = false;
                rEnd.font.Outline             = false;
                rEnd.message                  = copyright;
                graphicsContext.textRegions.Add(rEnd);
            }
            #endregion

            return(graphicsContext.Clone());
        }
Ejemplo n.º 5
0
            public void PrepSlideSingleVerse(GfxContext ctx, VerseBreakDown data, int subIndex, PresenterFont font)
            {
                #region Format data
                string txt;
                string reference;
                if (data.bibleVerse.RefVersion != "")
                {
                    reference = data.bibleVerse.ToString();
                    txt       = data.primaryText[subIndex];
                }
                else
                {
                    reference = data.bibleVerse.ToString(true);
                    txt       = data.secondaryText[subIndex];
                }
                #endregion

                Size nativeSize = DisplayEngine.NativeResolution.Size;

                #region Measure
                StringFormat sf           = GetStringFormat();
                int          insideHeight = nativeSize.Height - paddingPixels * 2;
                int          insideWidth  = nativeSize.Width - paddingPixels * 2;
                Point        anchorTop    = new Point(paddingPixels, paddingPixels);
                Point        anchorBottom = new Point(paddingPixels, paddingPixels + (int)((double)insideHeight / 2));

                // Measure the reference blocks
                int refemSize      = (int)(font.SizeInPoints * .9); // actual drawing size is smaller than usual
                int refBlockHeight = (int)(font.SizeInPoints * 1.2);
                #endregion

                #region Build context

                ctx.destSize = DisplayEngine.NativeResolution.Size;
                ctx.textRegions.Clear();

                // Primary text
                GfxTextRegion rVerse = new GfxTextRegion();
                ctx.textRegions.Add(rVerse);
                rVerse.font    = font;
                rVerse.message = txt;

                RectangleF r1 = new RectangleF(paddingPixels, 0, insideWidth,
                                               InternalMeasureString(txt, font, insideWidth, sf).Height);
                if (font.VerticalStringAlignment == StringAlignment.Near)
                {
                    r1.Y = paddingPixels;
                }
                else if (font.VerticalStringAlignment == StringAlignment.Center)
                {
                    r1.Y = (float)(((double)insideHeight - r1.Height) / 2) + paddingPixels;
                }
                else
                {
                    r1.Y = nativeSize.Height - r1.Height - refBlockHeight - paddingPixels * 2;
                }
                rVerse.bounds         = r1;
                rVerse.bounds.Height += refBlockHeight; // give some slack

                // Reference
                GfxTextRegion rRef = new GfxTextRegion();
                ctx.textRegions.Add(rRef);
                rRef.font = (PresenterFont)font.Clone();
                SetRefFont(rRef.font);
                rRef.message = reference;

                r1.Y              += r1.Height + refBlockHeight; // +refemSize; // relocate the box
                rRef.bounds        = r1;
                rRef.bounds.Height = refBlockHeight;

                #endregion
            }
Ejemplo n.º 6
0
            public bool PrepSlideDoubleVerse(GfxContext ctx, Dictionary <int, BibleVerse> bibVerses, int currentVerseNum, PresenterFont font)
            {
                #region Format data
                BibleVerse bva        = bibVerses[currentVerseNum];
                BibleVerse bvb        = bibVerses[currentVerseNum + 1];
                string     firstText  = bva.RefVerse + ". " + bva.Text;
                string     secondText = bvb.RefVerse + ". " + bvb.Text;
                string     reference  = bva.ToString() + "-" + bvb.RefVerse;
                #endregion

                Size nativeSize = DisplayEngine.NativeResolution.Size;

                #region Measure
                StringFormat sf           = GetStringFormat();
                int          insideHeight = nativeSize.Height - paddingPixels * 2;
                int          insideWidth  = nativeSize.Width - paddingPixels * 2;
                Point        anchorTop    = new Point(paddingPixels, paddingPixels);
                Point        anchorBottom = new Point(paddingPixels, paddingPixels + (int)((double)insideHeight / 2));

                // Measure the reference blocks
                int refemSize      = (int)(font.SizeInPoints * .9); // actual drawing size is smaller than usual
                int refBlockHeight = (int)(font.SizeInPoints * 1.2);

                // Determine top of rectangle
                // Measure both strings
                RectangleF r = new RectangleF(paddingPixels, 0, insideWidth,
                                              InternalMeasureString(firstText, font, insideWidth, sf).Height);
                int h1      = (int)r.Height; // Get the size of the verse so we can fix the reference at the bottom
                int h2      = (int)InternalMeasureString(secondText, font, insideWidth, sf).Height;
                int offsetY = (int)(((double)insideHeight - h1 - h2 - refBlockHeight) / 2);
                if (font.VerticalAlignment == VerticalAlignment.Top)
                {
                    r.Y = paddingPixels;
                }
                else if (font.VerticalAlignment == VerticalAlignment.Middle)
                {
                    r.Y = offsetY;
                }
                else
                {
                    r.Y = nativeSize.Height - paddingPixels * 2 - h1 - h2 - refBlockHeight;
                }

                // Size check
                int standardMax = (int)((double)insideHeight / 2);
                if (h1 + h2 + refBlockHeight > standardMax)
                {
                    return(false);
                }
                #endregion

                #region Build context

                ctx.destSize = DisplayEngine.NativeResolution.Size;
                ctx.textRegions.Clear();

                // Draw the first part
                GfxTextRegion rVerse = new GfxTextRegion();
                ctx.textRegions.Add(rVerse);
                rVerse.font = font;
                rVerse.font.HorizontalAlignment = HorizontalAlignment.Left;
                rVerse.message = firstText;
                rVerse.bounds  = r;

                GfxTextRegion rVerse2 = new GfxTextRegion();
                ctx.textRegions.Add(rVerse2);
                rVerse2.font    = font;
                rVerse2.message = secondText;
                r.Y            += h1 + refemSize;
                r.Height        = h2;
                rVerse2.bounds  = r;

                // Reference
                GfxTextRegion rRef = new GfxTextRegion();
                ctx.textRegions.Add(rRef);
                rRef.font = (PresenterFont)font.Clone();
                SetRefFont(rRef.font);
                rRef.message       = reference;
                r.Y               += h2 + refBlockHeight - refemSize; // Move to the bottom of the rectangle
                rRef.bounds        = r;
                rRef.bounds.Height = refBlockHeight;

                #endregion

                return(true);
            }
Ejemplo n.º 7
0
            public bool PrepSlideMultiTranslation(GfxContext ctx, VerseBreakDown data, int subIndex, PresenterFont font)
            {
                // If only one version is available then fall back
                if (data.bibleVerse.RefVersion == "" || data.bibleVerse.SecondaryVersion == "" ||
                    data.bibleVerse.Text == "" || data.bibleVerse.SecondaryText == "")
                {
                    return(false);
                }

                // Format data
                string primaryText   = subIndex > data.primaryText.Count - 1 ? data.primaryText[data.primaryText.Count - 1] : data.primaryText[subIndex];
                string secondaryText = subIndex > data.secondaryText.Count - 1 ? data.secondaryText[data.secondaryText.Count - 1] : data.secondaryText[subIndex];
                string priRef        = data.bibleVerse.ToString();
                string secRef        = data.bibleVerse.ToString(true);

                Size nativeSize = DisplayEngine.NativeResolution.Size;

                #region Measure
                StringFormat sf           = GetStringFormat();
                int          insideHeight = nativeSize.Height - paddingPixels * 2;
                int          insideWidth  = nativeSize.Width - paddingPixels * 2;
                Point        anchorTop    = new Point(paddingPixels, paddingPixels);
                Point        anchorBottom = new Point(paddingPixels, paddingPixels + (int)((double)insideHeight / 2));

                // Measure the reference blocks
                int refemSize      = (int)(font.SizeInPoints * .9); // actual drawing size is smaller than usual
                int refBlockHeight = (int)(font.SizeInPoints * 1.2);

                // Measure both strings
                RectangleF r1 = new RectangleF(anchorTop.X, anchorTop.Y, insideWidth,
                                               InternalMeasureString(primaryText, font, insideWidth, sf).Height);
                RectangleF r2 = new RectangleF(anchorBottom.X, anchorBottom.Y, insideWidth,
                                               InternalMeasureString(secondaryText, font, insideWidth, sf).Height);

                if (r1.Height + r2.Height + refBlockHeight * 2 > insideHeight)
                {
                    return(false);
                }

                #endregion

                #region Build context
                ctx.destSize = DisplayEngine.NativeResolution.Size;
                ctx.textRegions.Clear();

                // First part
                GfxTextRegion rVerse1 = new GfxTextRegion();
                ctx.textRegions.Add(rVerse1);
                rVerse1.font = font;
                rVerse1.font.HorizontalAlignment = HorizontalAlignment.Left;
                rVerse1.font.VerticalAlignment   = VerticalAlignment.Top;
                rVerse1.message = primaryText;

                // First reference
                GfxTextRegion rRef1 = new GfxTextRegion();
                ctx.textRegions.Add(rRef1);
                rRef1.font = (PresenterFont)font.Clone();
                SetRefFont(rRef1.font);
                rRef1.message = priRef;

                // Second part
                GfxTextRegion rVerse2 = new GfxTextRegion();
                ctx.textRegions.Add(rVerse2);
                rVerse2.font = font;
                rVerse2.font.HorizontalAlignment = HorizontalAlignment.Left;
                rVerse2.font.VerticalAlignment   = VerticalAlignment.Top;
                rVerse2.message = secondaryText;

                // Second reference
                GfxTextRegion rRef2 = new GfxTextRegion();
                ctx.textRegions.Add(rRef2);
                rRef2.font = (PresenterFont)font.Clone();
                SetRefFont(rRef2.font);
                rRef2.message = secRef;

                // Adjust bounds
                int standardMax = (int)((double)insideHeight / 2);
                if (r1.Height + refBlockHeight > standardMax || r2.Height + refBlockHeight > standardMax)
                {
                    rVerse1.bounds         = r1;             // First part
                    rVerse1.bounds.Height += refBlockHeight; // give some slack
                    r1.Y                  += r1.Height;      // First reference
                    rRef1.bounds           = r1;
                    rRef1.bounds.Height    = refBlockHeight;
                    r1.Y                  += refBlockHeight;             // Second part
                    rVerse2.bounds         = r1;
                    rVerse2.bounds.Height += refBlockHeight;             // give some slack
                    r1.Y                  += r2.Height + refBlockHeight; // Second reference
                    rRef2.bounds           = r1;
                    rRef2.bounds.Height    = refBlockHeight;
                }
                else
                {
                    rVerse1.bounds         = r1;                         // First part
                    rVerse1.bounds.Height += refBlockHeight;             // give some slack
                    r1.Y                  += r1.Height + refBlockHeight; // First reference
                    rRef1.bounds           = r1;
                    rRef1.bounds.Height    = refBlockHeight;
                    r1.Y                  += refBlockHeight;             // Second part
                    rVerse2.bounds         = r2;
                    rVerse2.bounds.Height += refBlockHeight;             // give some slack
                    r2.Y                  += r2.Height + refBlockHeight; // Second reference
                    rRef2.bounds           = r2;
                    rRef2.bounds.Height    = refBlockHeight;
                }
                #endregion

                return(true);
            }