static void RenderPreview(Bitmap bmp, FontInfo fs, CommentLabel label) { var style = Config.Instance.CommentStyles.Find(i => i.StyleID == label.StyleID); if (style == null || String.IsNullOrEmpty(label.Label)) { return; } var fontSize = (float)(fs.wPointSize + style.FontSize); if (fontSize < 2) { return; } using (var g = Graphics.FromImage(bmp)) using (var f = new Font(fs.bstrFaceName, fontSize, ConfigPage.GetFontStyle(style))) using (var b = style.ForeColor.A == 0 ? (Brush)Brushes.Black.Clone() : new SolidBrush(style.ForeColor.ToGdiColor())) { var t = label.StyleApplication == CommentStyleApplication.Tag ? label.Label : label.StyleApplication == CommentStyleApplication.TagAndContent ? label.Label + " Preview 01ioIOlLWM" : "Preview 01ioIOlLWM"; var m = g.MeasureString(t, f, bmp.Size); g.SmoothingMode = SmoothingMode.HighQuality; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.CompositingQuality = CompositingQuality.HighQuality; using (var bb = ConfigPage.GetPreviewBrush(style.BackgroundEffect, style.BackColor, ref m)) { g.FillRectangle(bb, new Rectangle(0, 0, (int)m.Width, (int)m.Height)); } g.DrawString(t, f, b, new RectangleF(PointF.Empty, bmp.PhysicalDimension)); } }
static void RenderPreview(Bitmap bmp, FontInfo fontInfo, StyleBase style) { var fontSize = (float)(fontInfo.wPointSize + style.FontSize); if (fontSize < 2) { return; } using (var g = Graphics.FromImage(bmp)) using (var f = new Font(String.IsNullOrEmpty(style.Font) ? fontInfo.bstrFaceName : style.Font, fontSize, ConfigPage.GetFontStyle(style))) using (var b = style.ForeColor.A == 0 ? (Brush)Brushes.Black.Clone() : new SolidBrush(style.ForeColor.ToGdiColor())) { const string t = "Preview 01ioIOlLWM"; var m = g.MeasureString(t, f, bmp.Size); g.SmoothingMode = SmoothingMode.HighQuality; g.TextRenderingHint = TextRenderingHint.AntiAlias; g.CompositingQuality = CompositingQuality.HighQuality; using (var bb = ConfigPage.GetPreviewBrush(style.BackgroundEffect, style.BackColor, ref m)) { g.FillRectangle(bb, new Rectangle(0, 0, (int)m.Width, (int)m.Height)); } g.DrawString(t, f, b, new RectangleF(PointF.Empty, bmp.PhysicalDimension)); } }