Exemple #1
0
        void RenderPreview(Bitmap bmp, string fontName, int fontSize, StyleBase style)
        {
            var size = (float)(fontSize + style.FontSize);

            if (size < 2)
            {
                return;
            }
            style.MixStyle(out var fs, out var fc, out var bc);
            _ForeColorButton.DefaultColor = fc;
            using (var g = Graphics.FromImage(bmp))
                using (var f = new Font(String.IsNullOrEmpty(style.Font) ? fontName : style.Font, size, fs))
                    using (var b = new SolidBrush(fc))
                        using (var bg = new SolidBrush(ThemeHelper.DocumentPageColor)) {
                            g.FillRectangle(bg, 0, 0, bmp.Width, bmp.Height);
                            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, bc, 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, string fontName, int fontSize, CommentLabel label)
        {
            var style = Config.Instance.CommentStyles.Find(i => i.StyleID == label.StyleID);

            if (style == null || String.IsNullOrEmpty(label.Label))
            {
                return;
            }
            var size = (float)(fontSize + style.FontSize);

            if (size < 2)
            {
                return;
            }
            Codist.SyntaxHighlight.FormatStore.MixStyle(style, out var fs, out var fc, out var bc);
            using (var g = Graphics.FromImage(bmp))
                using (var f = new Font(String.IsNullOrEmpty(style.Font) ? fontName : style.Font, size, fs))
                    using (var b = new SolidBrush(fc))
                        using (var bg = new SolidBrush(ThemeHelper.DocumentPageColor)) {
                            g.FillRectangle(bg, 0, 0, bmp.Width, bmp.Height);
                            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, bc, 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));
                        }
        }
Exemple #3
0
        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));
                    }
        }