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 Render(MarkupDrawContext d) { SetFont(d); base.Render(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); }
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 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); }
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 (_MFace != "" || _MSize != 0 && _MRelativeSize || _MSize>4 && !_MRelativeSize) { if (_MFace != "") d.CurrentFont = new Font(_MFace, ((_MRelativeSize || _MSize == 0)?font.SizeInPoints + _MSize:_MSize), font.Style); else d.CurrentFont = new Font(font.FontFamily, ((_MRelativeSize || _MSize == 0)? font.SizeInPoints + _MSize : _MSize), font.Style); } else font = null; } catch { font = null; } if (font != null) m_OldFont = font; if (!d.IgnoreFormattingColors) { if (!_MForeColor.IsEmpty) { _MOldForeColor = d.CurrentForeColor; d.CurrentForeColor = _MForeColor; } else if (_MSystemColorName != "") { //#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; }
protected override void ArrangeInternal(Rectangle bounds, MarkupDrawContext d) { Rectangle r = bounds; if (m_Width > 0) r.Width = m_Width; if (m_Padding.IsEmpty) { base.ArrangeInternal(r, d); if (m_Width > 0) this.Bounds = new Rectangle(this.Bounds.X, this.Bounds.Y, m_Width, this.Bounds.Height + m_Padding.Bottom); } else { r.X += m_Padding.Left; r.Y += m_Padding.Top; 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; this.Bounds = r; } }
/// <summary> /// Provides final rectangle to element and lets it arrange it's content given new constraint. /// </summary> /// <param name="finalRect">Final rectangle.</param> /// <param name="d"></param> protected abstract void ArrangeCore(Rectangle finalRect, MarkupDrawContext d);
private Size GetMarkupTextSize( GridLayoutInfo layoutInfo, TextRowVisualStyle style, int width) { Graphics g = layoutInfo.Graphics; MarkupDrawContext d = new MarkupDrawContext(g, style.Font, style.TextColor, false); _TextMarkup.InvalidateElementsSize(); _TextMarkup.Measure(new Size(width, 0), d); return (_TextMarkup.Bounds.Size); }
private void RenderTextMarkup( Graphics g, TextRowVisualStyle style, Rectangle r) { MarkupDrawContext d = new MarkupDrawContext(g, style.Font, style.TextColor, false); _TextMarkup.Arrange(new Rectangle(r.Location, r.Size), d); Size size = _TextMarkup.Bounds.Size; switch (style.Alignment) { case Alignment.MiddleLeft: case Alignment.MiddleCenter: case Alignment.MiddleRight: if (r.Height > size.Height) r.Y += (r.Height - size.Height)/2; break; default: if (r.Height > size.Height) r.Y = r.Bottom - size.Height; break; } _TextMarkup.Bounds = new Rectangle(r.Location, size); Region oldClip = g.Clip; try { g.SetClip(r, CombineMode.Intersect); _TextMarkup.Render(d); } finally { g.Clip = oldClip; } }
protected override void ArrangeCore(System.Drawing.Rectangle finalRect, MarkupDrawContext d) {}
public override void Measure(System.Drawing.Size availableSize, MarkupDrawContext d) { //#if (FRAMEWORK20) // if (BarUtilities.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 + (BarFunctions.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 += BarUtilities.TextMarkupCultureSpecificPadding; // size.Height += BarUtilities.TextMarkupCultureSpecificPadding; // } // this.Bounds = new Rectangle(Point.Empty, size); // } // else //#endif { 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 += TextHelper.TextMarkupCultureSpecificPadding; size.Height += TextHelper.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 += TextHelper.TextMarkupCultureSpecificPadding; size.Height += TextHelper.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 += TextHelper.TextMarkupCultureSpecificPadding; size.Height += TextHelper.TextMarkupCultureSpecificPadding; } this.Bounds = new Rectangle(Point.Empty, size); } } } IsSizeValid = true; }
protected override void ArrangeInternal(Rectangle bounds, MarkupDrawContext d) { base.ArrangeInternal(bounds, d); this.Bounds = new Rectangle(this.Bounds.X, this.Bounds.Y, this.Bounds.Width , this.Bounds.Height + d.CurrentFont.Height); }
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 (BarUtilities.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; }
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) {}
public override void RenderEnd(MarkupDrawContext d) { d.StrikeOut = false; base.RenderEnd(d); }
protected override void ArrangeCore(Rectangle finalRect, MarkupDrawContext d) { }
public override void Render(MarkupDrawContext d) { d.StrikeOut = true; }
public override void Measure(Size availableSize, MarkupDrawContext d) { Bounds = Rectangle.Empty; }
/// <summary> /// Arranges the element given the final size. Layout is two step process with Measure followed by Arrange. /// </summary> /// <param name="finalSize"></param> /// <param name="d"></param> public void Arrange(Rectangle finalSize, MarkupDrawContext d) { this.ArrangeCore(finalSize, d); }
/// <summary> /// Renders element. /// </summary> /// <param name="d">Provides markup drawing context information.</param> public abstract void Render(MarkupDrawContext d);
/// <summary> /// Renders element tag end. Most implementations do not need to do anything but mplementations like the ones /// that change color should return state back at this time. /// </summary> /// <param name="d">Provides markup drawing context information.</param> public virtual void RenderEnd(MarkupDrawContext d) { }