public override void Render(MarkupDrawContext d) { SetFont(d); base.Render(d); if (m_OldFont != null) d.CurrentFont = m_OldFont; }
public override void MeasureEnd(Size availableSize, MarkupDrawContext d) { if (m_OldFont != null) d.CurrentFont = m_OldFont; m_OldFont = null; base.MeasureEnd(availableSize, d); }
public override void Measure(Size availableSize, MarkupDrawContext d) { SetFont(d); base.Measure(availableSize, d); if (m_OldFont != null) d.CurrentFont = m_OldFont; }
public override void RenderEnd(MarkupDrawContext d) { if(m_OldFont!=null) d.CurrentFont = m_OldFont; m_OldFont = null; base.RenderEnd(d); }
protected override void ArrangeInternal(Rectangle bounds, MarkupDrawContext d) { Rectangle r = bounds; if (m_Width > 0) r.Width = m_Width; if (m_Height > 0) r.Height = m_Height; if (m_Padding.IsEmpty) { base.ArrangeInternal(r, d); if (m_Width > 0) this.Bounds = new Rectangle(this.Bounds.X, this.Bounds.Y, m_Width, m_Height > 0 ? m_Height : this.Bounds.Height + m_Padding.Bottom); else if(m_Height>0) this.Bounds = new Rectangle(this.Bounds.X, this.Bounds.Y, this.Bounds.Width, m_Height); } else { r.X += m_Padding.Left; r.Y += m_Padding.Top; r.Width -= m_Padding.Horizontal; r.Height -= m_Padding.Vertical; base.ArrangeInternal(r, d); r = new Rectangle(bounds.X, bounds.Y, this.Bounds.Width + m_Padding.Horizontal, this.Bounds.Height + m_Padding.Vertical); if (m_Width > 0) r.Width = m_Width; if (m_Height > 0) r.Height = m_Height; this.Bounds = r; } }
public override void Render(MarkupDrawContext d) { d.HyperLink = true; d.HyperlinkStyle = GetHyperlinkStyle(); if (!d.HyperlinkStyle.BackColor.IsEmpty) { using (GraphicsPath gp = new GraphicsPath()) { MarkupElementCollection col = this.Parent.Elements; int start = col.IndexOf(this) + 1; for (int i = start; i < col.Count; i++) { MarkupElement elem = col[i]; if (!elem.Visible) continue; if (elem is EndMarkupElement && ((EndMarkupElement)elem).StartElement == this) break; gp.AddRectangle(elem.RenderBounds); } using (SolidBrush brush = new SolidBrush(d.HyperlinkStyle.BackColor)) d.Graphics.FillPath(brush, gp); } } SetForeColor(d); }
public override void Render(MarkupDrawContext d) { Rectangle r = this.Bounds; r.Offset(d.Offset); if (!m_BackColor.IsEmpty) { DisplayHelp.FillRectangle(d.Graphics, r, m_BackColor); } base.Render(d); }
protected override void SetFont(MarkupDrawContext d) { Font font = d.CurrentFont; FontStyle style = d.CurrentFont.Style | FontStyle.Bold; if (!font.Bold && font.FontFamily.IsStyleAvailable(style)) d.CurrentFont = new Font(d.CurrentFont, style); else font = null; if (font != null) m_OldFont = font; base.SetFont(d); }
public override void Measure(System.Drawing.Size availableSize, MarkupDrawContext d) { if (!m_ImageSize.IsEmpty) this.Bounds = new Rectangle(Point.Empty, m_ImageSize); else if (m_ImageSource.Length == 0) this.Bounds = Rectangle.Empty; else { Image img = this.GetImage(); if (img != null) this.Bounds = new Rectangle(Point.Empty, img.Size); else this.Bounds = new Rectangle(Point.Empty, new Size(16,16)); } }
protected virtual void SetForeColor(MarkupDrawContext d) { Color c = Color.Empty; HyperlinkStyle style = GetHyperlinkStyle(); if (style != null && !style.TextColor.IsEmpty) c = style.TextColor; if (!m_ForeColor.IsEmpty) c = m_ForeColor; if (!c.IsEmpty) { m_OldForeColor = d.CurrentForeColor; d.CurrentForeColor = c; } }
protected override void SetFont(MarkupDrawContext d) { d.Underline = true; //Font font = d.CurrentFont; //FontStyle style = d.CurrentFont.Style | FontStyle.Underline; //if (!font.Underline && font.FontFamily.IsStyleAvailable(style)) // d.CurrentFont = new Font(font, style); //else // font = null; //if (font != null) // m_OldFont = font; base.SetFont(d); }
public override void Render(MarkupDrawContext d) { Point offset = this.GetContainerOffset(); d.Offset.Offset(offset.X, offset.Y); try { foreach (MarkupElement e in this.Elements) { e.Render(d); } } finally { d.Offset.Offset(-offset.X, -offset.Y); } }
protected virtual void ArrangeInternal(Rectangle bounds, MarkupDrawContext d) { SerialContentLayoutManager layout = GetLayoutManager(d.AllowMultiLine); layout.RightToLeft = d.RightToLeft; MarkupLayoutManager markupLayout = GetMarkupLayout(); markupLayout.MarkupDrawContext = d; try { MarkupElement[] blocks = new MarkupElement[this.Elements.Count]; this.Elements.CopyTo(blocks); Rectangle r = layout.Layout(new Rectangle(Point.Empty, bounds.Size), blocks, markupLayout); this.Bounds = new Rectangle(bounds.Location, r.Size); } finally { markupLayout.MarkupDrawContext = null; } }
protected override void SetFont(MarkupDrawContext d) { Font font = d.CurrentFont; try { if (m_Face != "" || m_Size != 0 && m_RelativeSize || m_Size>4 && !m_RelativeSize) { if (m_Face != "") d.CurrentFont = new Font(m_Face, ((m_RelativeSize || m_Size == 0)?font.SizeInPoints + m_Size:m_Size), font.Style); else d.CurrentFont = new Font(font.FontFamily, ((m_RelativeSize || m_Size == 0)? font.SizeInPoints + m_Size : m_Size), font.Style); } else font = null; } catch { font = null; } if (font != null) m_OldFont = font; if (!d.IgnoreFormattingColors) { if (!m_ForeColor.IsEmpty) { m_OldForeColor = d.CurrentForeColor; d.CurrentForeColor = m_ForeColor; } else if (m_SystemColorName != "") { #if DOTNETBAR if (Rendering.GlobalManager.Renderer is Rendering.Office2007Renderer) { m_OldForeColor = d.CurrentForeColor; d.CurrentForeColor = ((Rendering.Office2007Renderer)Rendering.GlobalManager.Renderer).ColorTable.Form.Active.CaptionTextExtra; } #endif } } }
protected virtual void SetFont(MarkupDrawContext d) { Font font = d.CurrentFont; try { float size = d.CurrentFont.SizeInPoints; if (m_Level == 1) { size += 12; } else if (m_Level == 2) { size += 8; } else if (m_Level == 3) { size += 6; } else if (m_Level == 4) { size += 4; } else if (m_Level == 5) { size += 2; } else if (m_Level == 6) { size += 1; } d.CurrentFont = new Font(d.CurrentFont.FontFamily, size, FontStyle.Bold); } catch { font = null; } if (font != null) m_OldFont = font; }
public override void Measure(Size availableSize, MarkupDrawContext d) { ArrangeInternal(new Rectangle(Point.Empty, availableSize), d); }
protected override void ArrangeCore(Rectangle finalRect, MarkupDrawContext d) { }
protected virtual void RestoreForeColor(MarkupDrawContext d) { if (!m_OldForeColor.IsEmpty) d.CurrentForeColor = m_OldForeColor; m_OldForeColor = Color.Empty; }
public override void Render(MarkupDrawContext d) { Rectangle r = this.Bounds; r.Offset(d.Offset); if (!d.ClipRectangle.IsEmpty && !r.IntersectsWith(d.ClipRectangle)) return; Image img = this.GetImage(); if (img != null) { Rectangle imageRect = r; imageRect.Size = img.Size; d.Graphics.DrawImage(img, imageRect); } else { using (SolidBrush brush = new SolidBrush(Color.White)) { d.Graphics.FillRectangle(brush, r); } using (Pen pen = new Pen(Color.DarkGray, 1)) { d.Graphics.DrawRectangle(pen, r); d.Graphics.DrawLine(pen, r.X, r.Y, r.Right, r.Bottom); d.Graphics.DrawLine(pen, r.Right, r.Y, r.X, r.Bottom); } } }
protected virtual void SetFont(MarkupDrawContext d) { }
protected override void ArrangeCore(System.Drawing.Rectangle finalRect, MarkupDrawContext d) {}
public override void Measure(Size availableSize, MarkupDrawContext d) { this.Bounds = Rectangle.Empty; SetFont(d); }
public override void RenderEnd(MarkupDrawContext d) { d.Underline = false; base.RenderEnd(d); }
public override void MeasureEnd(Size availableSize, MarkupDrawContext d) { d.Underline = false; base.MeasureEnd(availableSize, d); }
public override void Measure(System.Drawing.Size availableSize, MarkupDrawContext d) { // Causes layout manager to switch to the new line this.Bounds = new Rectangle(0, 0, 0, d.CurrentFont.Height); }
public override void Render(MarkupDrawContext d) {}
protected override void ArrangeCore(Rectangle finalRect, MarkupDrawContext d) { this.Bounds = finalRect; ArrangeInternal(finalRect, d); }
public override void Render(MarkupDrawContext d) { SetFont(d); }
public override void Measure(System.Drawing.Size availableSize, MarkupDrawContext d) { if (TextDrawing.UseTextRenderer) { eTextFormat format = eTextFormat.Default | eTextFormat.NoPadding; if (!d.HotKeyPrefixVisible || m_EnablePrefixHandling) format |= eTextFormat.HidePrefix; Size size = Size.Empty; if (m_TrailingSpace) { if (d.CurrentFont.Italic) { size = Size.Ceiling(TextDrawing.MeasureString(d.Graphics, m_Text, d.CurrentFont, 0, format)); size.Width += (int)(d.Graphics.MeasureString("||", d.CurrentFont).Width / 4); } else size = Size.Ceiling(TextDrawing.MeasureString(d.Graphics, m_Text + (SystemHelpers.IsVista && m_Text.Length > 0 ? "|" : "||"), d.CurrentFont, 0, format)); } else size = Size.Ceiling(TextDrawing.MeasureString(d.Graphics, m_Text, d.CurrentFont, 0, format)); if (PadText) { size.Width += TextSettings.TextMarkupCultureSpecificPadding; size.Height += TextSettings.TextMarkupCultureSpecificPadding; } this.Bounds = new Rectangle(Point.Empty, size); } else { using (StringFormat format = new StringFormat(StringFormat.GenericTypographic)) { format.FormatFlags = StringFormatFlags.NoWrap; if (d.HotKeyPrefixVisible || !m_EnablePrefixHandling) format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show; else format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Hide; if (m_TrailingSpace) { if (d.CurrentFont.Italic) { Size size = Size.Ceiling(d.Graphics.MeasureString(m_Text, d.CurrentFont, 0, format)); size.Width += (int)(d.Graphics.MeasureString("|", d.CurrentFont).Width / 4); if (PadText) { size.Width += TextSettings.TextMarkupCultureSpecificPadding; size.Height += TextSettings.TextMarkupCultureSpecificPadding; } this.Bounds = new Rectangle(Point.Empty, size); } else { Size size = Size.Ceiling(d.Graphics.MeasureString(m_Text + "|", d.CurrentFont, 0, format)); if (PadText) { size.Width += TextSettings.TextMarkupCultureSpecificPadding; size.Height += TextSettings.TextMarkupCultureSpecificPadding; } this.Bounds = new Rectangle(Point.Empty, size); } } else { Size size = Size.Ceiling(d.Graphics.MeasureString(m_Text, d.CurrentFont, 0, format)); if (PadText) { size.Width += TextSettings.TextMarkupCultureSpecificPadding; size.Height += TextSettings.TextMarkupCultureSpecificPadding; } this.Bounds = new Rectangle(Point.Empty, size); } } } IsSizeValid = true; }
public override void Render(MarkupDrawContext d) { Rectangle r = this.Bounds; r.Offset(d.Offset); if (!d.ClipRectangle.IsEmpty && !r.IntersectsWith(d.ClipRectangle)) return; Graphics g = d.Graphics; #if (FRAMEWORK20) if (TextDrawing.UseTextRenderer) { eTextFormat format = eTextFormat.Default | eTextFormat.NoClipping | eTextFormat.NoPadding; if (d.RightToLeft) format |= eTextFormat.RightToLeft; if (!d.HotKeyPrefixVisible) format |= eTextFormat.HidePrefix; if (!d.ClipRectangle.IsEmpty && r.Right > d.ClipRectangle.Right) { format|= eTextFormat.EndEllipsis; r.Width -= (r.Right - d.ClipRectangle.Right); } TextDrawing.DrawString(g, m_Text, d.CurrentFont, d.CurrentForeColor, r, format); } else #endif { using (StringFormat format = new StringFormat(StringFormat.GenericTypographic)) { format.FormatFlags |= StringFormatFlags.NoWrap; if (d.RightToLeft) format.FormatFlags |= StringFormatFlags.DirectionRightToLeft; if (d.HotKeyPrefixVisible) format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show; else format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Hide; if (!d.ClipRectangle.IsEmpty && r.Right > d.ClipRectangle.Right) { format.Trimming = StringTrimming.EllipsisCharacter; r.Width -= (r.Right - d.ClipRectangle.Right); } using (SolidBrush brush = new SolidBrush(d.CurrentForeColor)) g.DrawString(m_Text, d.CurrentFont, brush, r, format); } } if (d.StrikeOut == true) { // StrikeOut float descent = d.CurrentFont.FontFamily.GetCellDescent(d.CurrentFont.Style) * d.CurrentFont.Size / d.CurrentFont.FontFamily.GetEmHeight(d.CurrentFont.Style) + 1; using (Pen pen = new Pen(d.CurrentForeColor, 1)) { SmoothingMode sm = g.SmoothingMode; g.SmoothingMode = SmoothingMode.Default; float y = r.Top + (r.Height + descent) / 2; g.DrawLine(pen, r.X, y, r.Right - 1, y); g.SmoothingMode = sm; } } if ((d.HyperLink && (d.HyperlinkStyle == null || d.HyperlinkStyle.UnderlineStyle != eHyperlinkUnderlineStyle.None)) || d.Underline) { // Underline Hyperlink float descent = d.CurrentFont.FontFamily.GetCellDescent(d.CurrentFont.Style) * d.CurrentFont.Size / d.CurrentFont.FontFamily.GetEmHeight(d.CurrentFont.Style); using (Pen pen = new Pen(d.CurrentForeColor, 1)) { if (d.HyperLink && d.HyperlinkStyle != null && d.HyperlinkStyle.UnderlineStyle == eHyperlinkUnderlineStyle.DashedLine) pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; descent -= 1; System.Drawing.Drawing2D.SmoothingMode sm = g.SmoothingMode; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; g.DrawLine(pen, r.X, r.Bottom - descent, r.Right - 1, r.Bottom - descent); g.SmoothingMode = sm; } } this.RenderBounds = r; }