public static PresenterFont FromXMLNode(XmlNode xnc) { PresenterFont font = new PresenterFont(); if (xnc["FontName"] != null) { font.FontName = xnc["FontName"].InnerText; } if (xnc["SizeInPoints"] != null) { font.SizeInPoints = int.Parse(xnc["SizeInPoints"].InnerText); } if (xnc["Color"] != null) { font.Color = Color.FromArgb(int.Parse(xnc["Color"].InnerText)); } if (xnc["VertAlign"] != null) { font.VerticalAlignment = (VerticalAlignment)Enum.Parse(typeof(VerticalAlignment), xnc["VertAlign"].InnerText); } if (xnc["HorAlign"] != null) { font.HorizontalAlignment = (HorizontalAlignment)Enum.Parse(typeof(HorizontalAlignment), xnc["HorAlign"].InnerText); } if (xnc["Outline"] != null) { font.Outline = bool.Parse(xnc["Outline"].InnerText); } if (xnc["Shadow"] != null) { font.Shadow = bool.Parse(xnc["Shadow"].InnerText); } if (xnc["OutlineColor"] != null) { font.OutlineColor = Color.FromArgb(int.Parse(xnc["OutlineColor"].InnerText)); } if (xnc["ShadowColor"] != null) { font.ShadowColor = Color.FromArgb(int.Parse(xnc["ShadowColor"].InnerText)); } if (xnc["Italic"] != null) { font.Italic = bool.Parse(xnc["Italic"].InnerText); } if (xnc["Bold"] != null) { font.Bold = bool.Parse(xnc["Bold"].InnerText); } if (xnc["DoubleSpace"] != null) { font.DoubleSpace = bool.Parse(xnc["DoubleSpace"].InnerText); } return(font); }
public static void SaveFontToDatabase(int id, PresenterFont font) { using (FBirdTask t = new FBirdTask()) { // check is font saved t.CommandText = "SELECT COUNT(*) FROM [PPTFONT] WHERE [AUTONUMBER] = @AUTONUMBER"; t.AddParameter("@AUTONUMBER", id); if ((int)t.ExecuteScalar() == 0) { // insert t.CommandText = "INSERT INTO [PPTFONT] ([AUTONUMBER], [FONTNAME], [SIZEINPOINTS], [COLOR], [VERTICALALIGNMENT], [HORIZONTALALIGNMENT], [OUTLINE], [SHADOW], [OUTLINECOLOR], [SHADOWCOLOR], [ITALIC], [BOLD], [DOUBLESPACE]) " + "VALUES (@AUTONUMBER, @FONTNAME, @SIZEINPOINTS, @COLOR, @VERTICALALIGNMENT, @HORIZONTALALIGNMENT, @OUTLINE, @SHADOW, @OUTLINECOLOR, @SHADOWCOLOR, @ITALIC, @BOLD, @DOUBLESPACE)"; } else { // update t.CommandText = "UPDATE [PPTFONT] SET " + "[FONTNAME] = @FONTNAME, " + "[SIZEINPOINTS] = @SIZEINPOINTS," + "[COLOR] = @COLOR," + "[VERTICALALIGNMENT] = @VERTICALALIGNMENT," + "[HORIZONTALALIGNMENT] = @HORIZONTALALIGNMENT," + "[OUTLINE] = @OUTLINE," + "[SHADOW] = @SHADOW," + "[ITALIC] = @ITALIC," + "[BOLD] = @BOLD, " + "[OUTLINECOLOR] = @OUTLINECOLOR, " + "[SHADOWCOLOR] = @SHADOWCOLOR, " + "[DOUBLESPACE] = @DOUBLESPACE " + "WHERE [AUTONUMBER] = @AUTONUMBER"; } // add parameters t.AddParameter("@FONTNAME", 512, font.FontName); t.AddParameter("@SIZEINPOINTS", font.SizeInPoints); t.AddParameter("@COLOR", font.Color.ToArgb()); t.AddParameter("@VERTICALALIGNMENT", (int)font.VerticalAlignment); t.AddParameter("@HORIZONTALALIGNMENT", (int)font.HorizontalAlignment); t.AddParameter("@OUTLINE", font.Outline); t.AddParameter("@SHADOW", font.Shadow); t.AddParameter("@ITALIC", font.Italic); t.AddParameter("@BOLD", font.Bold); t.AddParameter("@OUTLINECOLOR", font.OutlineColor.ToArgb()); t.AddParameter("@SHADOWCOLOR", font.ShadowColor.ToArgb()); t.AddParameter("@DOUBLESPACE", font.DoubleSpace); // save to db t.ExecuteNonQuery(); } }
// Graphics prep private void PrepareForDisplay() { // This method will prepare the data for the graphics engine to make it faster // It take all the bible text and break it across multiple slides // Requirements: reload data on the fly (save state and start from where left off) // Clean up int currentVerseBackup = currentVerseNum; // back this up just in case this.slideData.Clear(); // Init bibFont = PresenterFont.GetFontFromDatabase(-1); // Get the bib font from db /// Split each of the verses if necessary foreach (BibleVerse bvCurrent in this.bibVerses.Values) { // Calculate max block size Size nativeSize = DisplayEngine.NativeResolution.Size; int transCount = TranslationList().Count; double insideHeight = nativeSize.Height; insideHeight -= imageFactory.paddingPixels * 2; // Top and bottom insideHeight -= imageFactory.paddingPixels * (transCount - 1); // Between translations insideHeight /= transCount; insideHeight -= bibFont.SizeInPoints * 1.5; // Space for verse labels int maxh = (int)insideHeight; Size maxSize = new Size(imageFactory.maxInsideWidth, maxh); VerseBreakDown d = new VerseBreakDown(); d.bibleVerse = bvCurrent; d.primaryText = InternalBreakString(bvCurrent.RefVerse, bvCurrent.Text, maxSize); d.secondaryText = InternalBreakString(bvCurrent.SecondaryVerse, bvCurrent.SecondaryText, maxSize); d.tertiaryText = InternalBreakString(bvCurrent.TertiaryVerse, bvCurrent.TertiaryText, maxSize); slideData.Add(bvCurrent.RefVerse, d); } // Read initial opacity EnsureBackground(); UpdateOpacity(Program.ConfigHelper.BibleImageOpacity); // Reset the current location if (bibVerses.Count > 0 && currentVerseBackup < bibVerses.Count + 1 && currentVerseBackup != -1) { currentVerseNum = currentVerseBackup; } else { currentVerseNum = 1; } }
private void btnFont_Click(object sender, EventArgs e) { #if DEMO new DemoVersionOnly("Changing font").ShowDialog(); #else FontSelection fsForm = new FontSelection(); fsForm.LoadFont(PresenterFont.GetFontFromDatabase(-2)); if (fsForm.ShowDialog() == DialogResult.OK) { PresenterFont.SaveFontToDatabase(-2, fsForm.PresenterFont); } Program.ConfigHelper.NotifySongDefaultsChanged(); #endif }
private void btnFont_Click(object sender, EventArgs e) { #if DEMO new DemoVersionOnly("Changing font").ShowDialog(); #else FontSelection fsForm = new FontSelection(); currentRow.FontId = currentRow.AutoNumber; fsForm.LoadFont(PresenterFont.GetFontFromDatabase(currentRow.FontId)); if (fsForm.ShowDialog() == DialogResult.OK) { PresenterFont.SaveFontToDatabase(currentRow.FontId, fsForm.PresenterFont); } #endif }
private RectangleF MeasureVerse(string text, PresenterFont f, int width) { // init uninitialized objects Graphics gMeasuring = Graphics.FromImage(new Bitmap(1, 1)); GraphicsPath pathMeasuring = new GraphicsPath(); StringFormat sfMeasuring = (StringFormat)StringFormat.GenericTypographic.Clone(); sfMeasuring.Alignment = StringAlignment.Near; sfMeasuring.LineAlignment = StringAlignment.Near; sfMeasuring.FormatFlags = StringFormatFlags.FitBlackBox | StringFormatFlags.NoClip | StringFormatFlags.MeasureTrailingSpaces; pathMeasuring.Reset(); pathMeasuring.AddString(text, f.FontFamily, (int)f.FontStyle, f.SizeInPoints, new Rectangle(0, 0, width, 1), sfMeasuring); return(pathMeasuring.GetBounds()); }
public static void AppendToXMLNode(XmlNode xnc, PresenterFont font) { AddStringNode(xnc, "FontName", font.FontName); AddStringNode(xnc, "SizeInPoints", font.SizeInPoints.ToString()); AddStringNode(xnc, "Color", font.Color.ToArgb().ToString()); AddStringNode(xnc, "VertAlign", font.VerticalAlignment.ToString()); AddStringNode(xnc, "HorAlign", font.HorizontalAlignment.ToString()); AddStringNode(xnc, "Outline", font.Outline.ToString()); AddStringNode(xnc, "Shadow", font.Shadow.ToString()); AddStringNode(xnc, "OutlineColor", font.OutlineColor.ToArgb().ToString()); AddStringNode(xnc, "ShadowColor", font.ShadowColor.ToArgb().ToString()); AddStringNode(xnc, "Italic", font.Italic.ToString()); AddStringNode(xnc, "Bold", font.Bold.ToString()); AddStringNode(xnc, "DoubleSpace", font.DoubleSpace.ToString()); }
private void btnFont_Click(object sender, EventArgs e) { #if DEMO new DemoVersionOnly("Changing font").ShowDialog(); #else FontSelection fsForm = new FontSelection(); fsForm.LoadFont(PresenterFont.GetFontFromDatabase(-1)); fsForm.cbDoubleSpace.Visible = false; fsForm.gbAlignment.Visible = (GetCurrentFormat() != BibleRenderingFormat.MultiTranslation); if (fsForm.ShowDialog() == DialogResult.OK) { PresenterFont.SaveFontToDatabase(-1, fsForm.PresenterFont); proj.RefreshData(); } #endif }
private void btnFont_Click(object sender, EventArgs e) { #if DEMO new DemoVersionOnly("Changing font").ShowDialog(); #else FontSelection fsForm = new FontSelection(); fsForm.LoadFont(PresenterFont.GetFontFromDatabase(proj.currentSong.FontId)); if (fsForm.ShowDialog() == DialogResult.OK) { proj.currentSong.FontId = proj.currentSong.AutoNumber; PresenterFont.SaveFontToDatabase(proj.currentSong.FontId, fsForm.PresenterFont); proj.RefreshData(); } proj.currentSong.AcceptChanges(); #endif }
public void SaveAnouncement(AnouncementData ad) { // Search and remove the previous version XmlNode nodeToRemove = null; foreach (XmlNode xn in xd.DocumentElement.ChildNodes) { if (xn.Name == "Anouncement" && xn.Attributes["Name"].InnerText == ad.name) { nodeToRemove = xn; } } if (nodeToRemove != null) { xd.DocumentElement.RemoveChild(nodeToRemove); } // Write the new version XmlNode an = xd.CreateElement("Anouncement"); XmlAttribute xaName = xd.CreateAttribute("Name"); xaName.InnerText = ad.name; an.Attributes.Append(xaName); AddStringNode(an, "ImageId", ad.imageId.ToString()); AddStringNode(an, "Opacity", ad.opacity.ToString()); // Write out each region foreach (GfxTextRegion tr in ad.lTextRegions) { XmlNode xnTr = xd.CreateElement("TextRegion"); // Save basics string bounds = tr.bounds.X.ToString() + "," + tr.bounds.Y.ToString() + "," + tr.bounds.Width.ToString() + "," + tr.bounds.Height.ToString(); AddStringNode(xnTr, "Bounds", bounds); AddStringNode(xnTr, "Message", tr.message); // Save the font PresenterFont.AppendToXMLNode(xnTr, tr.font); an.AppendChild(xnTr); } // Finish and save xd.DocumentElement.AppendChild(an); Save(); }
public object Clone() { PresenterFont font = new PresenterFont(); font.Bold = this.Bold; font.Color = this.Color; font.Outline = this.Outline; font.Shadow = this.Shadow; font.OutlineColor = this.OutlineColor; font.ShadowColor = this.ShadowColor; font.FontAlignment = this.FontAlignment; font.FontName = this.FontName; font.Italic = this.Italic; font.SizeInPoints = this.SizeInPoints; return(font); }
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 }
private void LoadData(PresenterDataset.SongsRow currentSong) { // Clear songVerses.Clear(); // Populate songVerses LoadVerses(songVerses, currentSong.AutoNumber, false); // Load other data currentSong.Image = Data.Songs.GetSongBackground(currentSong.AutoNumber); copyright = EmpowerPresenter.Data.Songs.GetSongCopyright(currentSong.AutoNumber); songFont = PresenterFont.GetFontFromDatabase(currentSong.FontId); graphicsContext.opacity = currentSong.Overlay; if (graphicsContext.opacity == 777) { graphicsContext.opacity = Program.ConfigHelper.SongDefaultOpacity; } // Load img into context if (graphicsContext.img == null) { PhotoInfo pi = new PhotoInfo(); pi.ImageId = currentSong.Image; graphicsContext.img = pi.FullSizeImage; } // Load formatting settings string settings = currentSong.Settings; if (settings == null || settings == "") { settings = Program.ConfigHelper.SongDefaultFormat; } string[] sparts = settings.Split("|".ToCharArray()); if (sparts.Length == 2) { stripFormatting = bool.Parse(sparts[0]); includeVerseNumbers = bool.Parse(sparts[1]); } }
public void SaveProject(ScrollerData sd) { // Search and remove the previous version XmlNode nodeToRemove = null; foreach (XmlNode xn in xd.DocumentElement.ChildNodes) { if (xn.Name == "Project" && xn.Attributes["Name"].InnerText == sd.name) { nodeToRemove = xn; } } if (nodeToRemove != null) { xd.DocumentElement.RemoveChild(nodeToRemove); } // Write the new version XmlNode an = xd.CreateElement("Project"); XmlAttribute xaName = xd.CreateAttribute("Name"); xaName.InnerText = sd.name; an.Attributes.Append(xaName); AddStringNode(an, "LeftMessage", sd.leftMessage); AddStringNode(an, "Message", sd.message); AddStringNode(an, "RightMessage", sd.rightMessage); if (sd.font == null) { sd.font = new PresenterFont(); sd.font.SizeInPoints = 12; } PresenterFont.AppendToXMLNode(an, sd.font); // Finish and save xd.DocumentElement.AppendChild(an); Save(); }
// Database support public static PresenterFont GetFontFromDatabase(int id) { PresenterFont font = new PresenterFont(); using (FBirdTask t = new FBirdTask()) { t.CommandText = "SELECT [FONTNAME], [SIZEINPOINTS], [COLOR], [VERTICALALIGNMENT], [HORIZONTALALIGNMENT], [OUTLINE], [SHADOW], [OUTLINECOLOR], [SHADOWCOLOR], [ITALIC], [BOLD], [DOUBLESPACE] " + "FROM [PPTFONT] " + "WHERE [AUTONUMBER] = @AUTONUMBER"; t.AddParameter("@AUTONUMBER", id); t.ExecuteReader(); if (t.DR.Read()) { font.FontName = t.GetString(0); font.SizeInPoints = t.GetInt32(1); font.Color = t.GetColor(2, Color.Black); switch (t.GetInt32(3)) { case 0: font.VerticalAlignment = VerticalAlignment.Top; break; case 1: font.VerticalAlignment = VerticalAlignment.Middle; break; case 2: font.VerticalAlignment = VerticalAlignment.Bottom; break; default: break; } switch (t.GetInt32(4)) { case 0: font.HorizontalAlignment = HorizontalAlignment.Left; break; case 2: font.HorizontalAlignment = HorizontalAlignment.Center; break; case 1: font.HorizontalAlignment = HorizontalAlignment.Right; break; default: break; } font.Outline = t.GetBoolean(5); font.Shadow = t.GetBoolean(6); font.OutlineColor = t.GetColor(7, Color.White); font.ShadowColor = t.GetColor(8, Color.Gray); font.Italic = t.GetBoolean(9); font.Bold = t.GetBoolean(10); font.DoubleSpace = t.GetBoolean(11); } return(font); } }
//////////////////////////////////////////////////////////////////////////////////////// public ScrollerProject() { font = new PresenterFont(); font.SizeInPoints = 12; }
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); }
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 }
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); }
public GfxTextRegion(Rectangle bounds, PresenterFont font, string message) { this.bounds = bounds; this.font = font; this.message = message; }
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; }