示例#1
0
        void DrawCyTitle(System.Windows.Forms.DataGridViewCellPaintingEventArgs e, RectangleF[] rtfs, RectangleF rtCyTitle, int _charFullWidth, int _charWidth)
        {
            StringFormat _sf = new StringFormat();

            _sf.Alignment     = StringAlignment.Center;
            _sf.LineAlignment = StringAlignment.Center;
            Font     CyTitleFont = new Font("楷体_GB2312", 9F);
            Graphics g           = e.Graphics;

            System.Drawing.Text.TextRenderingHint      trh = g.TextRenderingHint;
            System.Drawing.Drawing2D.InterpolationMode im  = g.InterpolationMode;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            RectangleF rtf       = new RectangleF(rtCyTitle.Right - _charWidth, rtCyTitle.Y, _charWidth, rtCyTitle.Height);
            int        maxLength = rtfs.Length > CyEditor.CYTITLE.Length ? CyEditor.CYTITLE.Length : rtfs.Length;//用小的
            int        j         = 0;

            for (int i = CyEditor.CYTITLE.Length - 1; i >= 0; i--)
            {
                if (j >= maxLength)
                {
                    break;
                }
                string s = CyEditor.CYTITLE.Substring(i, 1);
                g.DrawString(s, CyTitleFont, new SolidBrush(Color.Green), rtf, _sf);
                rtf.Offset(-_charFullWidth, 0);
                j++;
            }
            g.TextRenderingHint = trh;
            g.InterpolationMode = im;
            DrawCyLine(g, rtCyTitle.X, rtCyTitle.Y, rtCyTitle.Width, rtCyTitle.Height, _charFullWidth);
        }
示例#2
0
        internal override void Create()
        {
            switch (_style)
            {
            case Styles.Pattern:
                Assert.NoNull(this.Height, "NullButtonHeight");
                Assert.NoNull(_textureFile, "NullButtonTextureFile");
                _antiAlias         = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
                _fontStyle         = System.Drawing.FontStyle.Regular;
                _image             = System.Drawing.Image.FromFile(_textureFile);
                _textHeightPadding = 3;
                _textWidthPadding  = 6;
                this.AdjustSizeForText();
                this.CreateFromPattern();
                break;

            case Styles.Rounded:
                _textHeightPadding = 2;
                _textWidthPadding  = -4;
                this.AdjustSizeForText();
                this.CreateRounded();
                break;

            case Styles.Template:
                Assert.NoNull(_templateFile, "NullButtonTemplateFile");
                _image      = Image.FromFile(_templateFile);
                this.Height = _image.Height;
                this.AdjustSizeForText();
                this.CreateFromTemplate();
                break;
            }
        }
示例#3
0
        void DefaultPaintCell(GB_GridView.CellPaintEventArgs e)
        {
            if (m_cellPaint != null)
            {
                m_cellPaint(this, e);
                if (e.Handled)
                {
                    return;
                }
            }
            GDI.Brush brush = m_background;

            if (e.ColumnIndex == m_mouseColumn)
            {
                brush = m_hoverbackground;
            }

            e.Graphics.FillRectangle(brush, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1);
            //e.Graphics.DrawRectangle(System.Drawing.Pens.Black, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1);
            // 判断下有没有SortGraph
            System.Windows.Forms.SortOrder so = GetColumnSortGraph(e.ColumnIndex);
            if (so != System.Windows.Forms.SortOrder.None)
            {
                GDI.Drawing2D.GraphicsPath path = new GDI.Drawing2D.GraphicsPath();
                // 创建一个5*9的三角形
                GDI.Point[] ptList = null;

                if (so == System.Windows.Forms.SortOrder.Ascending) // 箭头朝上
                {
                    ptList = new GDI.Point[] {
                        new GDI.Point(5, 0), new GDI.Point(0, 5), new GDI.Point(9, 5)
                    };
                }
                else
                {
                    ptList = new GDI.Point[] {
                        new GDI.Point(4, 5), new GDI.Point(0, 0), new GDI.Point(9, 0)
                    };
                }
                GDI.Size offset = new GDI.Size(e.Bounds.Right - e.Bounds.Width / 2 - 5, e.Bounds.Top);
                path.AddLines(new GDI.Point[] { GDI.Point.Add(ptList[0], offset), GDI.Point.Add(ptList[1], offset), GDI.Point.Add(ptList[2], offset) });
                e.Graphics.FillPath(m_foreground, path);
                path.Dispose();
            }

            if (e.Value != null)
            {
                GDI.StringFormat sf = new System.Drawing.StringFormat();
                sf.Alignment     = System.Drawing.StringAlignment.Center;
                sf.FormatFlags   = System.Drawing.StringFormatFlags.NoWrap;
                sf.LineAlignment = System.Drawing.StringAlignment.Center;
                sf.Trimming      = System.Drawing.StringTrimming.EllipsisCharacter;
                System.Drawing.Text.TextRenderingHint hint = e.Graphics.TextRenderingHint;
                e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
                e.Graphics.DrawString(e.Value.ToString(), Font, m_foreground, e.Bounds, sf);
                e.Graphics.TextRenderingHint = hint;
            }
        }
示例#4
0
        public FontDef(string FilePath)
        {
            XmlDocument tDoc = new XmlDocument();

            tDoc.Load(FilePath);

            XmlElement tRoot = tDoc.DocumentElement;

            _TexWidth  = Convert.ToInt32(tRoot.GetAttribute("TexWidth"));
            _TexHeight = Convert.ToInt32(tRoot.GetAttribute("TexHeight"));
            _AntiAlias = (System.Drawing.Text.TextRenderingHint)Convert.ToInt32(tRoot.GetAttribute("AntiAlias"));

            foreach (XmlNode x in tRoot)
            {
                XmlElement tObj = x as XmlElement;
                if (tObj != null)
                {
                    CharDef tChar = new CharDef();
                    tChar.Advance     = Convert.ToInt32(tObj.GetAttribute("Advance"));
                    tChar.Baseline    = Convert.ToInt32(tObj.GetAttribute("Baseline"));
                    tChar.Character   = Convert.ToChar(tObj.GetAttribute("Character"));
                    tChar.ImageMargin = Convert.ToInt32(tObj.GetAttribute("ImageMargin"));
                    tChar.FontColor   = Color.FromArgb(Convert.ToInt32(tObj.GetAttribute("FontColor")));

                    FontStyle tStyle = FontStyle.Regular;
                    if (Convert.ToBoolean(tObj.GetAttribute("Bold")))
                    {
                        tStyle = FontStyle.Bold;
                    }
                    if (Convert.ToBoolean(tObj.GetAttribute("Italic")))
                    {
                        tStyle |= FontStyle.Italic;
                    }
                    if (Convert.ToBoolean(tObj.GetAttribute("Strikeout")))
                    {
                        tStyle |= FontStyle.Strikeout;
                    }
                    if (Convert.ToBoolean(tObj.GetAttribute("Underline")))
                    {
                        tStyle |= FontStyle.Underline;
                    }
                    tChar.SrcFont = new Font(tObj.GetAttribute("FontName"), Convert.ToSingle(tObj.GetAttribute("FontSize")), tStyle);

                    _CharList.Add(tChar);
                }
            }

            RenderTexture();
        }
示例#5
0
文件: Device.cs 项目: BGog/GHud
 public Device()
 {
     valid                = false;
     width                = 0;
     height               = 0;
     is_color             = false;
     font_pt              = 0.0F;
     render_hint          = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
     clear_color          = System.Drawing.Color.White;
     clear_brush          = Brushes.White;
     inverted_clear_brush = Brushes.Black;
     default_txt_brush    = Brushes.Black;
     inverted_txt_brush   = Brushes.White;
     default_pen          = Pens.Black;
     use_backdrops        = false;
 }
示例#6
0
文件: Device.cs 项目: BGog/GHud
 public Device()
 {
     valid = false;
     width = 0;
     height = 0;
     is_color = false;
     font_pt = 0.0F;
     render_hint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
     clear_color = System.Drawing.Color.White;
     clear_brush = Brushes.White;
     inverted_clear_brush = Brushes.Black;
     default_txt_brush = Brushes.Black;
     inverted_txt_brush = Brushes.White;
     default_pen = Pens.Black;
     use_backdrops = false;
 }
示例#7
0
        public bool Initialize(string FontName, float FontSize, System.Drawing.FontStyle FontStyle, bool AntiAliased)
        {
            //Debug.Assert(!_initialized);
            if (_initialized)
            {
                return(false);
            }
            System.Drawing.Font font = new System.Drawing.Font(FontName, FontSize, FontStyle, System.Drawing.GraphicsUnit.Pixel);

            System.Drawing.Text.TextRenderingHint hint = AntiAliased ? System.Drawing.Text.TextRenderingHint.AntiAlias : System.Drawing.Text.TextRenderingHint.SystemDefault;

            int tempSize = (int)(FontSize * 2);

            using (System.Drawing.Bitmap charBitmap = new System.Drawing.Bitmap(tempSize, tempSize, System.Drawing.Imaging.PixelFormat.Format32bppArgb))
            {
                using (System.Drawing.Graphics charGraphics = System.Drawing.Graphics.FromImage(charBitmap))
                {
                    charGraphics.PageUnit          = System.Drawing.GraphicsUnit.Pixel;
                    charGraphics.TextRenderingHint = hint;

                    MeasureChars(font, charGraphics);

                    using (var fontSheetBitmap = new System.Drawing.Bitmap(_texWidth, _texHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb))
                    {
                        using (var fontSheetGraphics = System.Drawing.Graphics.FromImage(fontSheetBitmap))
                        {
                            fontSheetGraphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                            fontSheetGraphics.Clear(System.Drawing.Color.FromArgb(0, System.Drawing.Color.Black));

                            BuildFontSheetBitmap(font, charGraphics, charBitmap, fontSheetGraphics);

                            if (!BuildFontSheetTexture(fontSheetBitmap))
                            {
                                return(false);
                            }
                        }
                        //System.Drawing.Bitmap bm = new System.Drawing.Bitmap(fontSheetBitmap);
                        //bm.Save(@"C:\temp\test.png");
                    }
                }
            }

            _initialized = true;

            return(true);
        }
        /// <summary>
        /// Draw text centre into a array of automatically made bitmaps
        /// </summary>
        /// <param name="size">Size of bitmaps</param>
        /// <param name="text">Array with text to draw</param>
        /// <param name="font">Font to draw in</param>
        /// <param name="hint">Text rendering hint to use</param>
        /// <param name="forecolor">Fore colour</param>
        /// <param name="backcolor">Back color. If transparent, no back is drawn</param>
        /// <param name="backscale">Gradient of back</param>
        /// <param name="centertext">If true, centre text in box. Ignore textformat</param>
        /// <param name="textformat">Text format. Setting it allows you to word wrap etc into the bitmap. No format means a single line across the bitmap unless \n is in there </param>
        /// <param name="angleback">Angle of gradient on back</param>
        /// <param name="pos">Start position in array to start from</param>
        /// <param name="length">Number of items to take in array, or -1 means automatically work it out</param>
        public static Bitmap[] DrawTextIntoFixedSizeBitmaps(Size size, string[] text,
                                                            Font font, System.Drawing.Text.TextRenderingHint hint, Color forecolor, Color?backcolor,
                                                            float backscale = 1.0F, bool centertext = false, StringFormat textformat = null, int angleback = 90,
                                                            int pos         = 0, int length = -1)
        {
            if (length == -1)
            {
                length = text.Length - pos;
            }

            Bitmap[] bmp = new Bitmap[length];
            for (int i = 0; i < length; i++)
            {
                bmp[i] = new Bitmap(size.Width, size.Height);
                DrawTextIntoFixedSizeBitmap(ref bmp[i], text[i + pos], font, hint, forecolor, backcolor, backscale, centertext, textformat, angleback);
            }
            return(bmp);
        }
示例#9
0
        public Boolean Initialize(String fontName, Single fontSize, System.Drawing.FontStyle fontStyle, Boolean antiAliased)
        {
            Debug.Assert(!this.Initialized, "Ensure not initialized");

            System.Drawing.Font font = new System.Drawing.Font(fontName, fontSize, fontStyle, System.Drawing.GraphicsUnit.Pixel);

            System.Drawing.Text.TextRenderingHint hint = antiAliased ? System.Drawing.Text.TextRenderingHint.AntiAlias : System.Drawing.Text.TextRenderingHint.SystemDefault;

            Int32 tempSize = (Int32)(fontSize * 2.0f);

            using (System.Drawing.Bitmap charBitmap = new System.Drawing.Bitmap(tempSize, tempSize, PixelFormat.Format32bppArgb))
            {
                using (System.Drawing.Graphics charGraphics = System.Drawing.Graphics.FromImage(charBitmap))
                {
                    charGraphics.PageUnit          = System.Drawing.GraphicsUnit.Pixel;
                    charGraphics.TextRenderingHint = hint;

                    this.MeasureChars(font, charGraphics);

                    using (System.Drawing.Bitmap fontSheetBitmap = new System.Drawing.Bitmap(this.TexWidth, this.TexHeight, PixelFormat.Format32bppArgb))
                    {
                        using (System.Drawing.Graphics fontSheetGraphics = System.Drawing.Graphics.FromImage(fontSheetBitmap))
                        {
                            fontSheetGraphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                            fontSheetGraphics.Clear(System.Drawing.Color.FromArgb(0, System.Drawing.Color.Black));

                            this.BuildFontSheetBitmap(font, charGraphics, charBitmap, fontSheetGraphics);

                            if (!this.BuildFontSheetTexture(fontSheetBitmap))
                            {
                                return(false);
                            }
                        }
                    }
                }
            }

            this.Initialized = true;
            return(true);
        }
示例#10
0
        public FontDef(string FilePath)
        {
            XmlDocument tDoc = new XmlDocument();
            tDoc.Load(FilePath);

            XmlElement tRoot = tDoc.DocumentElement;
            _TexWidth = Convert.ToInt32(tRoot.GetAttribute("TexWidth"));
            _TexHeight = Convert.ToInt32(tRoot.GetAttribute("TexHeight"));
            _AntiAlias = (System.Drawing.Text.TextRenderingHint)Convert.ToInt32(tRoot.GetAttribute("AntiAlias"));

            foreach (XmlNode x in tRoot)
            {
                XmlElement tObj = x as XmlElement;
                if (tObj != null)
                {
                    CharDef tChar = new CharDef();
                    tChar.Advance = Convert.ToInt32(tObj.GetAttribute("Advance"));
                    tChar.Baseline = Convert.ToInt32(tObj.GetAttribute("Baseline"));
                    tChar.Character = Convert.ToChar(tObj.GetAttribute("Character"));
                    tChar.ImageMargin = Convert.ToInt32(tObj.GetAttribute("ImageMargin"));
                    tChar.FontColor = Color.FromArgb(Convert.ToInt32(tObj.GetAttribute("FontColor")));

                    FontStyle tStyle = FontStyle.Regular;
                    if(Convert.ToBoolean(tObj.GetAttribute("Bold")))
                        tStyle = FontStyle.Bold;
                    if(Convert.ToBoolean(tObj.GetAttribute("Italic")))
                        tStyle |= FontStyle.Italic;
                    if (Convert.ToBoolean(tObj.GetAttribute("Strikeout")))
                        tStyle |= FontStyle.Strikeout;
                    if (Convert.ToBoolean(tObj.GetAttribute("Underline")))
                        tStyle |= FontStyle.Underline;
                    tChar.SrcFont = new Font(tObj.GetAttribute("FontName"), Convert.ToSingle(tObj.GetAttribute("FontSize")), tStyle);

                    _CharList.Add(tChar);
                }
            }

            RenderTexture();
        }
        /// <summary>
        /// Draw text centre into a autosized bitmap
        /// </summary>
        /// <param name="text">Text to draw</param>
        /// <param name="maxsize">Maximum size of bitmap to make</param>
        /// <param name="font">Font to draw in</param>
        /// <param name="hint">Text rendering hint to use</param>
        /// <param name="forecolor">Fore colour</param>
        /// <param name="backcolor">Back color. If transparent, no back is drawn</param>
        /// <param name="backscale">Gradient of back</param>
        /// <param name="textformat">Text format. Setting it allows you to word wrap etc into the bitmap. No format means a single line across the bitmap unless \n is in there </param>
        public static Bitmap DrawTextIntoAutoSizedBitmap(string text, Size maxsize, Font font, System.Drawing.Text.TextRenderingHint hint, Color forecolor, Color backcolor,
                                                         float backscale = 1.0F, StringFormat textformat = null)
        {
            Bitmap t = new Bitmap(1, 1);

            using (Graphics bgr = Graphics.FromImage(t))
            {
                bgr.TextRenderingHint = hint;

                // if frmt, we measure the string within the maxsize bounding box.
                SizeF sizef = (textformat != null) ? bgr.MeasureString(text, font, maxsize, textformat) : bgr.MeasureString(text, font);
                //System.Diagnostics.Debug.WriteLine("Bit map auto size " + sizef);

                int    width  = Math.Min((int)(sizef.Width + 1), maxsize.Width);
                int    height = Math.Min((int)(sizef.Height + 1), maxsize.Height);
                Bitmap img    = new Bitmap(width, height);

                using (Graphics dgr = Graphics.FromImage(img))
                {
                    if (!backcolor.IsFullyTransparent() && text.Length > 0)
                    {
                        Rectangle backarea = new Rectangle(0, 0, img.Width, img.Height);
                        using (Brush bb = new System.Drawing.Drawing2D.LinearGradientBrush(backarea, backcolor, backcolor.Multiply(backscale), 90))
                            dgr.FillRectangle(bb, backarea);

                        //dgr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;   // only worth doing this if we have filled it.. if transparent, antialias does not work
                    }

                    using (Brush textb = new SolidBrush(forecolor))
                    {
                        if (textformat != null)
                        {
                            dgr.DrawString(text, font, textb, new Rectangle(0, 0, width, height), textformat); // use the draw into rectangle with formatting function
                        }
                        else
                        {
                            dgr.DrawString(text, font, textb, 0, 0);
                        }
                    }

                    return(img);
                }
            }
        }
        /// <summary>
        /// Draw text centre into a bitmap already defined
        /// </summary>
        /// <param name="bitmap">Bitmap to draw into</param>
        /// <param name="text">Text to draw</param>
        /// <param name="font">Font to draw in</param>
        /// <param name="hint">Text rendering hint to use</param>
        /// <param name="forecolor">Fore colour</param>
        /// <param name="backcolor">Back color. If not given, no backcolor is drawn</param>
        public static void DrawTextCentreIntoBitmap(ref Bitmap bitmap, string text, Font font, System.Drawing.Text.TextRenderingHint hint, Color forecolor, Color?backcolor = null)
        {
            using (Graphics bgr = Graphics.FromImage(bitmap))
            {
                bgr.TextRenderingHint = hint;

                if (backcolor != null)
                {
                    Rectangle backarea = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
                    using (Brush bb = new SolidBrush(backcolor.Value))
                        bgr.FillRectangle(bb, backarea);
                }

                SizeF sizef = bgr.MeasureString(text, font);

                using (Brush textb = new SolidBrush(forecolor))
                    bgr.DrawString(text, font, textb, bitmap.Width / 2 - (int)((sizef.Width + 1) / 2), bitmap.Height / 2 - (int)((sizef.Height + 1) / 2));
            }
        }
        /// <summary>
        /// Draw text centre into a bitmap
        /// </summary>
        /// <param name="bitmap">Bitmap to draw into</param>
        /// <param name="text">Text to draw</param>
        /// <param name="font">Font to draw in</param>
        /// <param name="hint">Text rendering hint to use</param>
        /// <param name="forecolor">Fore colour</param>
        /// <param name="backcolor">Back color. If transparent, no back is drawn</param>
        /// <param name="backscale">Gradient of back</param>
        /// <param name="centertext">If true, centre text in box. Ignore textformat</param>
        /// <param name="textformat">Text format. Setting it allows you to word wrap etc into the bitmap. No format means a single line across the bitmap unless \n is in there </param>
        /// <param name="angleback">Angle of gradient on back</param>

        public static Bitmap DrawTextIntoFixedSizeBitmap(ref Bitmap bitmap, string text, Font font, System.Drawing.Text.TextRenderingHint hint, Color forecolor, Color?backcolor,
                                                         float backscale = 1.0F, bool centertext = false, StringFormat textformat = null, int angleback = 90)
        {
            using (Graphics dgr = Graphics.FromImage(bitmap))
            {
                dgr.TextRenderingHint = hint;

                if (backcolor != null)
                {
                    if (backcolor.Value.IsFullyTransparent())       // if transparent colour to paint in, need to fill clear it completely
                    {
                        dgr.Clear(Color.Transparent);
                    }
                    else
                    {
                        Rectangle backarea = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
                        using (Brush bb = new System.Drawing.Drawing2D.LinearGradientBrush(backarea, backcolor.Value, backcolor.Value.Multiply(backscale), angleback))
                            dgr.FillRectangle(bb, backarea);

                        //dgr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // only if filled
                    }
                }

                using (Brush textb = new SolidBrush(forecolor))
                {
                    if (centertext)
                    {
                        SizeF sizef = dgr.MeasureString(text, font);
                        int   w     = (int)(sizef.Width + 1);
                        int   h     = (int)(sizef.Height + 1);
                        dgr.DrawString(text, font, textb, bitmap.Width / 2 - w / 2, bitmap.Height / 2 - h / 2);
                    }
                    else if (textformat != null)
                    {
                        dgr.DrawString(text, font, textb, new Rectangle(0, 0, bitmap.Width, bitmap.Height), textformat);
                    }
                    else
                    {
                        dgr.DrawString(text, font, textb, 0, 0);
                    }
                }

                return(bitmap);
            }
        }
示例#14
0
		internal void Read(System.IO.BinaryReader reader)
		{
			m_FontName = reader.ReadString();
			m_Style = (FontStyle)reader.ReadUInt32();
			m_Size = reader.ReadSingle();
			m_Unit = (GraphicsUnit)reader.ReadUInt32();
			m_FontType = (FontType)reader.ReadUInt32();
			m_RenderingHint = (System.Drawing.Text.TextRenderingHint)reader.ReadUInt32();
		}
示例#15
0
        private void PaintItem(int index, Graphics graphics)
        {
            int left = 1;
            // draw the tree lines
            bool lastLine = index == entries.Length - 1;

            if (!lastLine)
            {
                lastLine = entries[index + 1].IndentLevel < entries[index].IndentLevel;
            }
            bool firstLine = index == 0;

            if (!firstLine)
            {
                firstLine = entries[index - 1].IndentLevel == 0;
            }
            Rectangle area = new Rectangle(0, index * lineHeight + AutoScrollPosition.Y, ClientSize.Width, lineHeight);

            graphics.FillRectangle(SystemBrushes.Window, area);
            graphics.DrawRectangle(SystemPens.ControlLight, area);
            Rectangle indent = area;

            indent.Width = entries[index].IndentLevel * buttonWidth;
            graphics.FillRectangle(SystemBrushes.ControlLight, indent);
            left = entries[index].IndentLevel * buttonWidth + buttonWidth + 1; // left side of the label text
            if (entries[index].Flags.HasFlag(PropertyEntryType.HasSubEntries))
            {                                                                  // draw a square with a "+" or "-" sign in front of the label
                int ym = (area.Top + area.Bottom) / 2;
                int xm = entries[index].IndentLevel * buttonWidth + buttonWidth / 2 + 1;
                int s2 = square / 2;
                int s3 = square / 3;
                graphics.DrawRectangle(SystemPens.ControlText, xm - s2, ym - s2, square, square);
                graphics.DrawLine(SystemPens.ControlText, xm - s3, ym, xm + s3, ym); // the horizontal "minus" line
                if (!entries[index].IsOpen)
                {
                    graphics.DrawLine(SystemPens.ControlText, xm, ym - s3, xm, ym + s3);                         // the vertical "plus" line
                }
            }
            bool showValue = (entries[index].Value != null) && !entries[index].Flags.HasFlag(PropertyEntryType.Checkable);

            if (showValue)
            {
                graphics.DrawLine(SystemPens.ControlLight, middle, area.Top, middle, area.Bottom);            // the vertical divider line
            }
            Rectangle labelRect;

            if (showValue)
            {
                labelRect = new Rectangle(left, area.Top, middle - left, area.Height);
            }
            else
            {
                labelRect = new Rectangle(left, area.Top, area.Right - left, area.Height);
            }
            if (graphics.MeasureString(entries[index].Label, Font).Width > labelRect.Width)
            {
                labelNeedsExtension[index] = true;
            }
            if (index == selected)
            {
                graphics.FillRectangle(SystemBrushes.Highlight, labelRect);
                if (entries[index].Flags.HasFlag(PropertyEntryType.Bold))
                {
                    graphics.DrawString(entries[index].Label, new Font(Font, FontStyle.Bold), SystemBrushes.HighlightText, labelRect, stringFormat);
                }
                else
                {
                    graphics.DrawString(entries[index].Label, Font, SystemBrushes.HighlightText, labelRect, stringFormat);
                }
            }
            else if (entries[index].Flags.HasFlag(PropertyEntryType.Seperator))
            {
                int ym = (labelRect.Top + labelRect.Bottom) / 2;
                labelRect.Width -= buttonWidth;
                graphics.DrawLine(SystemPens.ControlLight, labelRect.Left, ym, labelRect.Right, ym); // the horizontal separator line
                StringFormat seperatorFormat = stringFormat.Clone() as StringFormat;
                seperatorFormat.Alignment = StringAlignment.Center;
                graphics.DrawString(entries[index].Label, Font, SystemBrushes.ControlText, labelRect, seperatorFormat);
            }
            else
            {
                if (entries[index].Flags.HasFlag(PropertyEntryType.Highlight))
                {
                    graphics.DrawString(entries[index].Label, Font, new SolidBrush(Color.Red), labelRect, stringFormat);
                }
                else if (entries[index].Flags.HasFlag(PropertyEntryType.Bold))
                {
                    graphics.DrawString(entries[index].Label, new Font(Font, FontStyle.Bold), SystemBrushes.ControlText, labelRect, stringFormat);
                }
                else
                {
                    graphics.DrawString(entries[index].Label, Font, SystemBrushes.ControlText, labelRect, stringFormat);
                }
            }
            if (showValue)
            {
                int right = area.Right;
                if (entries[index].Flags.HasFlag(PropertyEntryType.ContextMenu) || entries[index].Flags.HasFlag(PropertyEntryType.DropDown))
                {
                    right -= buttonWidth;
                }
                Rectangle valueRect = new Rectangle(middle, area.Top, right - middle, area.Height);
                DrawString(graphics, entries[index].Value, Font, SystemBrushes.ControlText, valueRect, false);
            }
            if (entries[index].Flags.HasFlag(PropertyEntryType.ContextMenu))
            {   // draw three vertical dots (maybe we could also use the Unicode "⁞" character
                Rectangle buttonRect = new Rectangle(area.Right - buttonWidth, area.Top, buttonWidth, area.Height);
                ControlPaint.DrawButton(graphics, buttonRect, ButtonState.Flat);
                int d  = Math.Max(area.Height / 9, 2);
                int dy = (area.Height - 5 * d) / 2;
                int xm = (int)(area.Right - buttonWidth / 2.0);
                for (int i = 0; i < 3; i++)
                {
                    graphics.FillRectangle(SystemBrushes.ControlText, xm - d / 2, buttonRect.Top + dy, d, d);
                    dy += 2 * d;
                }
            }
            else if (entries[index].Flags.HasFlag(PropertyEntryType.DropDown))
            {   // draw a combo button
                Rectangle buttonRect = new Rectangle(area.Right - buttonWidth, area.Top, buttonWidth, area.Height);
                ControlPaint.DrawComboButton(graphics, buttonRect, ButtonState.Flat);
                //int numLines = (int)(0.25 * buttonWidth);
                //int xm = (int)(area.Right - buttonWidth / 2.0);
                //int ym = (int)(area.Top + 0.4 * area.Height);
                //graphics.DrawLine(SystemPens.ControlText, xm - numLines, ym - 3, xm + numLines, ym - 3); // the horizontal above line
                //for (int i = 0; i <= numLines; i++)
                //{
                //    int w2 = numLines - i;
                //    if (w2 == 0) graphics.FillRectangle(SystemBrushes.ControlText, xm, ym + i, 1, 1); // a single pixel
                //    else graphics.DrawLine(SystemPens.ControlText, xm - w2, ym + i, xm + w2, ym + i); // the horizontal "minus" line
                //}
            }
            else if (entries[index].Flags.HasFlag(PropertyEntryType.CancelButton) || entries[index].Flags.HasFlag(PropertyEntryType.OKButton))
            {
                Font         fontForSymbols = Font; // new Font(FontFamily.GenericSansSerif, Font.Size, FontStyle.Bold);
                StringFormat sf             = new StringFormat(StringFormatFlags.LineLimit);
                sf.SetMeasurableCharacterRanges(new CharacterRange[] { new CharacterRange(0, 1) });
                sf.Alignment     = StringAlignment.Near;
                sf.LineAlignment = StringAlignment.Near;
                System.Drawing.Text.TextRenderingHint txtrendr = graphics.TextRenderingHint;
                graphics.TextContrast      = 0;
                graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                if (entries[index].Flags.HasFlag(PropertyEntryType.CancelButton))
                {
                    Rectangle buttonRect = new Rectangle(area.Right - area.Height, area.Top, area.Height, area.Height); // square rect at the right end
                    ControlPaint.DrawButton(graphics, buttonRect, ButtonState.Flat);
                    Region[]   rgn  = graphics.MeasureCharacterRanges("✖", fontForSymbols, buttonRect, sf);
                    RectangleF bnds = rgn[0].GetBounds(graphics);
                    SizeF      sz   = graphics.MeasureString("✖", fontForSymbols);
                    PointF     p    = new PointF(buttonRect.Left + (buttonRect.Width - bnds.Width) / 2.0f, buttonRect.Top + (buttonRect.Height - bnds.Height) / 2.0f);
                    graphics.DrawString("✖", fontForSymbols, SystemBrushes.ControlText, p, sf); // ✓✔✗✘✕✖⋮
                }
                if (entries[index].Flags.HasFlag(PropertyEntryType.OKButton))
                {
                    Rectangle buttonRect = new Rectangle(area.Right - 2 * area.Height, area.Top, area.Height, area.Height); // square rect at the right end
                    ControlPaint.DrawButton(graphics, buttonRect, ButtonState.Flat);
                    Region[]   rgn  = graphics.MeasureCharacterRanges("✔", fontForSymbols, buttonRect, sf);
                    RectangleF bnds = rgn[0].GetBounds(graphics);
                    SizeF      sz   = graphics.MeasureString("✔", fontForSymbols);
                    PointF     p    = new PointF(buttonRect.Left + (buttonRect.Width - bnds.Width) / 2.0f, buttonRect.Top + (buttonRect.Height - bnds.Height) / 2.0f);
                    graphics.DrawString("✔", fontForSymbols, SystemBrushes.ControlText, p, sf); // ✓✔✗✘✕✖⋮⁞
                }
                graphics.TextRenderingHint = txtrendr;
            }
            if (entries[index].Flags.HasFlag(PropertyEntryType.Checkable))
            {
                Rectangle cbrect = new Rectangle(entries[index].IndentLevel * buttonWidth, area.Top, area.Height, area.Height);
                cbrect.Inflate(-1, -1);
                ButtonState bs = ButtonState.Flat;
                if (entries[index].Value == "1")
                {
                    bs |= ButtonState.Checked;
                }
                ControlPaint.DrawCheckBox(graphics, cbrect, bs);
            }
        }