private void RedrawBuffer() { if (_bufferSurface != null) { _bufferSurface.Dispose(); } _bufferSurface = new GDISurface(this.Width, this.Height, this, true); using (Graphics gfx = Graphics.FromHdc(_bufferSurface.hDC)) { //try //{ _bufferSurface.FontTransparent = true; if (this.BackgroundImage != null) { gfx.DrawImage(this.BackgroundImage, 0, 0, this.Width, this.Height); } else { _bufferSurface.Clear(this.BackColor); } int x = LabelMargin; int y = LabelMargin; for (int i = vScroll.Value; i < _Rows.Count; i++) { FormatLabelRow r = (FormatLabelRow)_Rows[i]; x = LabelMargin; r.Visible = true; r.Top = y; if (r.RenderSeparator) { Color c1 = Color.FromArgb(120, 0, 0, 0); Brush b1 = new SolidBrush(c1); gfx.FillRectangle(b1, 0, y, this.Width, 1); Color c2 = Color.FromArgb(120, 255, 255, 255); Brush b2 = new SolidBrush(c2); gfx.FillRectangle(b2, 0, y + 1, this.Width, 1); b1.Dispose(); b2.Dispose(); //bbuff.DrawLine (this.ForeColor,new Point (0,y),new Point (this.Width,y)); } foreach (FormatLabelWord w in r.Words) { int ypos = r.Height - w.Height + y; if (w.Image != null) { gfx.DrawImage(w.Image, x, y); //bbuff.FillRect (Color.Red ,x,ypos,w.Width ,w.Height); } else { GDIFont gf = null; if (w.Element.Link != null) { Font f = null; FontStyle fs = w.Element.Font.Style; if (w.Element.Link == _ActiveElement) { if (_Link_UnderLine_Hover) { fs |= FontStyle.Underline; } f = new Font(w.Element.Font, fs); } else { if (_Link_UnderLine) { fs |= FontStyle.Underline; } f = new Font(w.Element.Font, fs); } gf = GetFont(f); } else { gf = GetFont(w.Element.Font); } _bufferSurface.Font = gf; if (w.Element.Effect != TextEffect.None) { _bufferSurface.TextForeColor = w.Element.EffectColor; if (w.Element.Effect == TextEffect.Outline) { for (int xx = -1; xx <= 1; xx++) { for (int yy = -1; yy <= 1; yy++) { _bufferSurface.DrawTabbedString(w.Text, x + xx, ypos + yy, 0, 0); } } } else if (w.Element.Effect != TextEffect.None) { _bufferSurface.DrawTabbedString(w.Text, x + 1, ypos + 1, 0, 0); } } if (w.Element.Link != null) { if (w.Element.Link == _ActiveElement) { _bufferSurface.TextForeColor = Link_Color_Hover; } else { _bufferSurface.TextForeColor = Link_Color; } } else { _bufferSurface.TextForeColor = w.Element.ForeColor; } _bufferSurface.TextBackColor = w.Element.BackColor; _bufferSurface.DrawTabbedString(w.Text, x, ypos, 0, 0); } w.ScreenArea = new Rectangle(new Point(x, ypos), w.ScreenArea.Size); //w.ScreenArea.Y = ypos; x += w.Width; } y += r.Height + r.BottomPadd; if (y > this.Height) { break; } } //} //catch (Exception x) //{ // Console.WriteLine(x.Message); //} } }
protected override void OnPaint(PaintEventArgs e) { SetAutoSize(); //base.OnPaint (e); if (_HasImageError) { CreateAll(); } var bbuff = new GDISurface(Width, Height, this, true); Graphics g = Graphics.FromHdc(bbuff.hDC); try { bbuff.FontTransparent = true; if (BackgroundImage != null) { g.DrawImage(BackgroundImage, 0, 0, Width, Height); } else { bbuff.Clear(BackColor); } int x = Margin; int y = Margin; for (int i = vScroll.Value; i < _Rows.Count; i++) { var r = (Row)_Rows[i]; x = Margin; r.Visible = true; r.Top = y; if (r.RenderSeparator) { Color c1 = Color.FromArgb(120, 0, 0, 0); Brush b1 = new SolidBrush(c1); g.FillRectangle(b1, 0, y, Width, 1); Color c2 = Color.FromArgb(120, 255, 255, 255); Brush b2 = new SolidBrush(c2); g.FillRectangle(b2, 0, y + 1, Width, 1); b1.Dispose(); b2.Dispose(); //bbuff.DrawLine (this.ForeColor,new Point (0,y),new Point (this.Width,y)); } foreach (Word w in r.Words) { int ypos = r.Height - w.Height + y; if (w.Image != null) { g.DrawImage(w.Image, x, y); //bbuff.FillRect (Color.Red ,x,ypos,w.Width ,w.Height); } else { GDIFont gf; if (w.Element.Link != null) { Font f = null; FontStyle fs = w.Element.Font.Style; if (w.Element.Link == _ActiveElement) { if (_Link_UnderLine_Hover) { fs |= FontStyle.Underline; } f = new Font(w.Element.Font, fs); } else { if (_Link_UnderLine) { fs |= FontStyle.Underline; } f = new Font(w.Element.Font, fs); } gf = GetFont(f); } else { gf = GetFont(w.Element.Font); } bbuff.Font = gf; if (w.Element.Effect != TextEffect.None) { bbuff.TextForeColor = w.Element.EffectColor; if (w.Element.Effect == TextEffect.Outline) { for (int xx = -1; xx <= 1; xx++) { for (int yy = -1; yy <= 1; yy++) { bbuff.DrawTabbedString(w.Text, x + xx, ypos + yy, 0, 0); } } } else if (w.Element.Effect != TextEffect.None) { bbuff.DrawTabbedString(w.Text, x + 1, ypos + 1, 0, 0); } } if (w.Element.Link != null) { if (w.Element.Link == _ActiveElement) { bbuff.TextForeColor = Link_Color_Hover; } else { bbuff.TextForeColor = Link_Color; } } else { bbuff.TextForeColor = w.Element.ForeColor; } bbuff.TextBackColor = w.Element.BackColor; bbuff.DrawTabbedString(w.Text, x, ypos, 0, 0); } w.ScreenArea.X = x; w.ScreenArea.Y = ypos; x += w.Width; } y += r.Height + r.BottomPadd; if (y > Height) { break; } } } catch (Exception x) { Console.WriteLine(x.Message); } bbuff.RenderToControl(0, 0); bbuff.Dispose(); g.Dispose(); }