public override void PerformLayout(PaintInfo pi) { Size size = new Size(0, pi.AvailableSize.Height); Graphics g = pi.Graphics; size.Width += 6; // Border 2 pixels on each side and 1 pixels of padding between border and content if (_Text.Length > 0) { Size textSize = TextDrawing.MeasureString(g, _Text, pi.DefaultFont); size.Width += textSize.Width; if (_Image != null) size.Width += 4; // Padding between text and image } if (_Image != null) { size.Width += _Image.Width; } if (_Text.Length == 0 && _Image == null) size.Width += 9; this.Size = size; this.CalculatedSize = size; base.PerformLayout(pi); }
protected override void OnPaint(PaintInfo p) { Graphics g = p.Graphics; Rectangle r = this.RenderBounds; if (r.Width <= 0 || r.Height <= 0) return; Rectangle buttonRect = new Rectangle(r.X, r.Y, r.Width, r.Height / 2); if (_UpImage != null) g.DrawImage(_UpImage, buttonRect.Location); else { Office2007ButtonItemStateColorTable ct = GetOffice2007StateColorTableButtonUp(p); PaintButtonBackground(p, ct, buttonRect); using (SolidBrush brush = new SolidBrush(ct.Text)) p.Graphics.FillPolygon(brush, Office2007ButtonItemPainter.GetExpandPolygon(buttonRect, ePopupSide.Top)); } _UpButtonRectangle = buttonRect; buttonRect = new Rectangle(r.X, buttonRect.Bottom, r.Width, r.Height - buttonRect.Height); if (_DownImage != null) g.DrawImage(_DownImage, buttonRect.Location); else { Office2007ButtonItemStateColorTable ct = GetOffice2007StateColorTableButtonDown(p); PaintButtonBackground(p, ct, buttonRect); using (SolidBrush brush = new SolidBrush(ct.Text)) p.Graphics.FillPolygon(brush, Office2007ButtonItemPainter.GetExpandPolygon(buttonRect, ePopupSide.Bottom)); } _DownButtonRectangle = buttonRect; base.OnPaint(p); }
protected virtual void PaintButtonBackground(PaintInfo p, Office2007ButtonItemStateColorTable ct) { Graphics g = p.Graphics; Rectangle r = this.RenderBounds; if (RenderBackground(p)) Office2007ButtonItemPainter.PaintBackground(g, ct, r, RoundRectangleShapeDescriptor.RectangleShape); }
protected override void PaintButtonBackground(PaintInfo p, DevComponents.DotNetBar.Rendering.Office2007ButtonItemStateColorTable ct) { base.PaintButtonBackground(p, ct); if (this.Text.Length == 0 && this.Image == null) { using (SolidBrush brush = new SolidBrush(ct.Text)) p.Graphics.FillPolygon(brush, Office2007ButtonItemPainter.GetExpandPolygon(this.RenderBounds, ePopupSide.Default)); } }
public override void PerformLayout(PaintInfo pi) { int height = pi.AvailableSize.Height; if (height % 2 != 0) height++; Size size = new Size(_ButtonWidth, height); if (_UpImage != null && _DownImage != null) size.Width = Math.Max(_UpImage.Width, _DownImage.Width); this.Size = size; this.CalculatedSize = size; base.PerformLayout(pi); }
public override void PerformLayout(PaintInfo p) { Size size = Size.Empty; Graphics g = p.Graphics; Font font = p.DefaultFont; eTextFormat textFormat = eTextFormat.Default | eTextFormat.NoPadding; string s = GetMeasureString(); size = TextDrawing.MeasureString(g, s, font, 0, textFormat); size.Width++; // Additional pixel for selection this.Size = size; base.PerformLayout(p); }
protected override void OnPaint(PaintInfo p) { Graphics g = p.Graphics; Font font = p.DefaultFont; Rectangle r = this.RenderBounds; eTextFormat textFormat = eTextFormat.Default | eTextFormat.NoPadding; Color color = p.ForeColor; r.X += _TextPadding.Left; r.Y += _TextPadding.Top; if (!GetIsEnabled(p)) color = p.DisabledForeColor; if (_Text.Length > 0) TextDrawing.DrawString(g, _Text, font, color, r, textFormat); base.OnPaint(p); }
protected override void PaintButtonBackground(PaintInfo p, DevComponents.DotNetBar.Rendering.Office2007ButtonItemStateColorTable ct) { base.PaintButtonBackground(p, ct); if (this.Text.Length == 0 && this.Image == null) { Point pt = new Point(RenderBounds.X + (RenderBounds.Width - 7) / 2, RenderBounds.Bottom - 6); using (SolidBrush brush = new SolidBrush(ct.Text)) { Size rs = new Size(2, 2); for (int i = 0; i < 3; i++) { p.Graphics.FillRectangle(brush, new Rectangle(pt, rs)); pt.X += rs.Width + 1; } } } }
protected override void OnPaint(PaintInfo p) { Graphics g = p.Graphics; Rectangle r = this.RenderBounds; PaintButtonBackground(p); Rectangle contentRect = r; contentRect.Inflate(-3, -3); // Two pixels border + 1 pixels padding for content if (_Text.Length > 0) { TextDrawing.DrawString(g, _Text, p.DefaultFont, GetIsEnabled(p) ? p.ForeColor : p.DisabledForeColor, contentRect, eTextFormat.Default | eTextFormat.VerticalCenter); } if (_Image != null) { Image image = GetIsEnabled(p) ? _Image : GetDisabledImage(); g.DrawImage(image, new Rectangle(contentRect.Right - _Image.Width, contentRect.Y + (contentRect.Height - _Image.Height) / 2, _Image.Width, _Image.Height)); } base.OnPaint(p); }
public override void PerformLayout(PaintInfo p) { Size size = Size.Empty; Graphics g = p.Graphics; Font font = p.DefaultFont; eTextFormat textFormat = eTextFormat.Default | eTextFormat.GlyphOverhangPadding | eTextFormat.LeftAndRightPadding; if (_Text.Length > 0) { if (Text.Trim().Length == 0) { size = TextDrawing.MeasureString(g, Text.Replace(' ', '-'), font, 0, textFormat); size.Width = (int)(size.Width); } else size = TextDrawing.MeasureString(g, Text, font, 0, textFormat); } size.Height += _TextPadding.Vertical; size.Width += _TextPadding.Horizontal; this.Size = size; base.PerformLayout(p); }
protected override void OnPaint(PaintInfo p) { Graphics g = p.Graphics; Rectangle r = new Rectangle(RenderBounds.X + 1, RenderBounds.Y + (RenderBounds.Height - _DefaultSize.Height) / 2, _DefaultSize.Width, _DefaultSize.Height); Office2007CheckBoxItemPainter painter = PainterFactory.CreateCheckBoxItemPainter(null); Office2007CheckBoxColorTable ctt = GetCheckBoxColorTable(); Office2007CheckBoxStateColorTable ct = ctt.Default; if (!this.GetIsEnabled(p)) ct = ctt.Disabled; else if (this.IsMouseDown) ct = ctt.Pressed; else if (this.IsMouseOver) ct = ctt.MouseOver; painter.PaintCheckBox(g, r, ct, this.Checked ? CheckState.Checked : CheckState.Unchecked); base.OnPaint(p); }
protected override void OnPaint(PaintInfo p) { Graphics g = p.Graphics; Font font = p.DefaultFont; Color color = p.ForeColor; if (!GetIsEnabled(p)) color = p.DisabledForeColor; eTextFormat textFormat = eTextFormat.Default | eTextFormat.NoPadding; string text = GetRenderString(); Rectangle selectionBounds = this.RenderBounds; Region oldClip = null; if (this.IsFocused && this.InputStack.Length > 0 && this.InputStack.Length < text.Length) { // Render partial selection based on the input stack Size inputSize = TextDrawing.MeasureString(g, text.Substring(0, this.InputStack.Length), font); oldClip = g.Clip; Rectangle newClip = selectionBounds; if (this.IsRightToLeft) { newClip.X += newClip.Width - inputSize.Width; newClip.Width = inputSize.Width; selectionBounds.Width -= inputSize.Width; } else { newClip.Width = inputSize.Width; selectionBounds.X += inputSize.Width; selectionBounds.Width -= inputSize.Width; } g.SetClip(newClip, System.Drawing.Drawing2D.CombineMode.Intersect); TextDrawing.DrawString(g, text, font, color, RenderBounds, textFormat); g.Clip = oldClip; g.SetClip(selectionBounds, System.Drawing.Drawing2D.CombineMode.Intersect); } if (this.IsFocused) { if (p.Colors.Highlight.IsEmpty) g.FillRectangle(SystemBrushes.Highlight, selectionBounds); else { using (SolidBrush brush = new SolidBrush(p.Colors.Highlight)) g.FillRectangle(brush, selectionBounds); } color = p.Colors.HighlightText.IsEmpty ? SystemColors.HighlightText : p.Colors.HighlightText; } if (!this.IsEmpty) { TextDrawing.DrawString(g, text, font, color, RenderBounds, textFormat); } if (oldClip != null) g.Clip = oldClip; base.OnPaint(p); }
public virtual void PerformLayout(PaintInfo pi) { _IsLayoutValid = true; }
protected virtual bool GetIsEnabled(PaintInfo p) { return p.ParentEnabled && _Enabled; }
protected virtual void OnPaint(PaintInfo p) { }
private bool RenderBackground(PaintInfo p) { if (RenderDefaultBackground) return true; if (!p.MouseOver && !this.IsMouseDown && !this.IsMouseOver && !this.Checked || !this.GetIsEnabled()) return false; return true; }
private void UpdateLayout(PaintInfo p) { if (_InternalSizeUpdate) return; _InternalSizeUpdate = true; try { if (!_ButtonGroup.IsLayoutValid) { _ButtonGroup.PerformLayout(p); } bool disposeStyle = false; ElementStyle style = GetBackgroundStyle(out disposeStyle); Rectangle textBoxControlRect = ElementStyleLayout.GetInnerRect(style, this.ClientRectangle); if (RenderButtons) { Rectangle buttonsRect = GetButtonsRenderBounds(style); if (this.RightToLeft == RightToLeft.Yes) { textBoxControlRect.X += buttonsRect.Right; textBoxControlRect.Width -= buttonsRect.Right; } else { textBoxControlRect.Width -= (textBoxControlRect.Right - buttonsRect.X); } } if (disposeStyle) style.Dispose(); //if (_TextBox.PreferredHeight < textBoxControlRect.Height) //{ // textBoxControlRect.Y += (textBoxControlRect.Height - _TextBox.PreferredHeight) / 2; //} //_TextBox.Bounds = textBoxControlRect; } finally { _InternalSizeUpdate = false; } }
protected override void OnPaint(PaintInfo p) { if (!IsLayoutValid) PerformLayout(p); Point renderOffset = p.RenderOffset; Point pr = p.RenderOffset; pr.Offset(this.RenderBounds.Location); p.RenderOffset = pr; Graphics g = p.Graphics; Region oldClip = null; bool clipSet = false; oldClip = g.Clip; Rectangle renderBounds = this.RenderBounds; renderBounds.Offset(renderOffset); g.SetClip(renderBounds, CombineMode.Intersect); clipSet = true; bool parentEnabled = p.ParentEnabled; p.ParentEnabled = p.ParentEnabled && this.Enabled; bool renderSystemItemsOnly = p.RenderSystemItemsOnly; foreach (VisualItem v in _Items) { if (renderSystemItemsOnly && v.ItemType != eSystemItemType.SystemButton) continue; if (_VerticalItemAlignment == eVerticalAlignment.Middle) v.RenderBounds = new Rectangle(p.RenderOffset.X + v.Location.X, p.RenderOffset.Y + v.Location.Y + (this.Size.Height - v.Size.Height) / 2, v.Size.Width, v.Size.Height); else if (_VerticalItemAlignment == eVerticalAlignment.Bottom) v.RenderBounds = new Rectangle(p.RenderOffset.X + v.Location.X, p.RenderOffset.Y + v.Location.Y + (this.Size.Height - v.Size.Height), v.Size.Width, v.Size.Height); else v.RenderBounds = new Rectangle(p.RenderOffset.X + v.Location.X, p.RenderOffset.Y + v.Location.Y, v.Size.Width, v.Size.Height); if (v.RenderBounds.IntersectsWith(renderBounds)) { p.RenderOffset = Point.Empty; v.ProcessPaint(p); p.RenderOffset = pr; } } p.ParentEnabled = parentEnabled; if (clipSet) { if (oldClip != null) g.Clip = oldClip; else g.ResetClip(); } if(oldClip!=null) oldClip.Dispose(); p.RenderOffset = renderOffset; base.OnPaint(p); }
protected virtual PaintInfo CreatePaintInfo(PaintEventArgs e) { PaintInfo p = new PaintInfo(); p.Graphics = e.Graphics; p.DefaultFont = this.Font; p.ForeColor = this.ForeColor; p.RenderOffset = new System.Drawing.Point(); p.WatermarkColor = _WatermarkColor; p.WatermarkEnabled = _WatermarkEnabled; p.WatermarkFont = _WatermarkFont; p.AvailableSize = this.ClientRectangle.Size; p.ParentEnabled = this.Enabled; p.MouseOver = _MouseOver || this.Focused; p.Colors = _Colors; if (!_DisabledForeColor.IsEmpty) p.DisabledForeColor = _DisabledForeColor; return p; }
protected override void OnPaint(PaintInfo p) { if (p.WatermarkEnabled && this.DrawWatermark) { Font font = p.DefaultFont; if (p.WatermarkFont != null) font = p.WatermarkFont; TextDrawing.DrawString(p.Graphics, this.WatermarkText, font, p.WatermarkColor, this.RenderBounds, eTextFormat.Default); } base.OnPaint(p); }
public override void PerformLayout(PaintInfo p) { if (p.WatermarkEnabled && this.DrawWatermark) { Font font = p.DefaultFont; if (p.WatermarkFont != null) font = p.WatermarkFont; System.Drawing.Size size = TextDrawing.MeasureString(p.Graphics, this.WatermarkText, font, 0, eTextFormat.Default | eTextFormat.NoPadding); this.Size = size; } base.PerformLayout(p); }
protected Office2007ButtonItemStateColorTable GetOffice2007StateColorTable(PaintInfo p) { if (GlobalManager.Renderer is Office2007Renderer) { Office2007ColorTable ct = ((Office2007Renderer)GlobalManager.Renderer).ColorTable; Office2007ButtonItemColorTable buttonColorTable = ct.ButtonItemColors[Enum.GetName(typeof(eButtonColor), eButtonColor.OrangeWithBackground)]; if (!this.GetIsEnabled(p)) return buttonColorTable.Disabled; else if (this.IsMouseDown) return buttonColorTable.Pressed; else if (this.IsMouseOver) return buttonColorTable.MouseOver; else if (this.Checked) return buttonColorTable.Checked; else return buttonColorTable.Default; } return null; }
protected virtual void DrawWatermark(PaintInfo p, Rectangle r) { if (this.WatermarkText.Length == 0) return; Font font = p.DefaultFont; if (this.WatermarkFont != null) font = this.WatermarkFont; eTextFormat format = eTextFormat.Default; if (_WatermarkAlignment == eTextAlignment.Center) format |= eTextFormat.HorizontalCenter; else if (_WatermarkAlignment == eTextAlignment.Right) format |= eTextFormat.Right; TextDrawing.DrawString(p.Graphics, this.WatermarkText, font, this.WatermarkColor, r, format); }
public override void PerformLayout(PaintInfo pi) { Point p = Point.Empty; Size size = Size.Empty; Size availableSize = pi.AvailableSize; Size containerSize = availableSize; bool usesFullWidth = false; Size calcSize = Size.Empty; foreach (VisualItem v in new VisualCollectionEnumerator(_Items, this.IsRightToLeft)) { if (v.Visible) { v.Location = p; pi.AvailableSize = new Size(availableSize.Width - p.X, availableSize.Height); v.PerformLayout(pi); if (v.Alignment == eItemAlignment.Right) { v.Location = new Point(containerSize.Width - v.Size.Width, p.Y); containerSize.Width -= v.Size.Width + _HorizontalItemSpacing; calcSize.Width += v.Size.Width + _HorizontalItemSpacing; usesFullWidth = true; } else { p.X += v.Size.Width + _HorizontalItemSpacing; size.Width += v.Size.Width + _HorizontalItemSpacing; calcSize.Width += v.Size.Width + _HorizontalItemSpacing; } if (v.Size.Height > size.Height) size.Height = v.Size.Height; } } if (size.Width > 0) size.Width -= +_HorizontalItemSpacing; if (usesFullWidth && _HorizontalItemAlignment != eHorizontalAlignment.Left) { if (_HorizontalItemAlignment == eHorizontalAlignment.Right) { if (containerSize.Width < availableSize.Width) containerSize.Width--; foreach (VisualItem v in new VisualCollectionEnumerator(_Items, !this.IsRightToLeft)) { if (!v.Visible || v.Alignment == eItemAlignment.Right || v is LockUpdateCheckBox) continue; v.Location = new Point(containerSize.Width - v.Size.Width, p.Y); containerSize.Width -= v.Size.Width + _HorizontalItemSpacing; } } else { int offset = (containerSize.Width - size.Width) / 2; foreach (VisualItem v in new VisualCollectionEnumerator(_Items, this.IsRightToLeft)) { if (!v.Visible || v.Alignment == eItemAlignment.Right || v is LockUpdateCheckBox) continue; v.Location = new Point(v.Location.X + offset, v.Location.Y); } } } this.CalculatedSize = calcSize; if (usesFullWidth) size.Width = availableSize.Width; pi.AvailableSize = availableSize; this.Size = size; this.RenderBounds = new Rectangle(pi.RenderOffset, size); base.PerformLayout(pi); }
private PaintInfo CreatePaintInfo(Graphics g) { PaintInfo p = new PaintInfo(); p.Graphics = g; p.DefaultFont = this.Font; p.ForeColor = this.ForeColor; p.RenderOffset = new System.Drawing.Point(); Size s = this.Size; bool disposeStyle = false; ElementStyle style = GetBackgroundStyle(out disposeStyle); s.Height -= (ElementStyleLayout.TopWhiteSpace(style, eSpacePart.Border) + ElementStyleLayout.BottomWhiteSpace(style, eSpacePart.Border)) + 2; s.Width -= (ElementStyleLayout.LeftWhiteSpace(style, eSpacePart.Border) + ElementStyleLayout.RightWhiteSpace(style, eSpacePart.Border)) + 2; p.AvailableSize = s; p.ParentEnabled = this.Enabled; p.MouseOver = _MouseOver || this.Focused; if(disposeStyle) style.Dispose(); return p; }
protected override void OnPaint(PaintInfo p) { Graphics g = p.Graphics; Font font = p.DefaultFont; Color color = p.ForeColor; if (!this.GetIsEnabled(p)) color = p.DisabledForeColor; eTextFormat textFormat = eTextFormat.Default | eTextFormat.NoPadding; if (this.IsFocused) { if (p.Colors.Highlight.IsEmpty) g.FillRectangle(SystemBrushes.Highlight, this.RenderBounds); else { using (SolidBrush brush = new SolidBrush(p.Colors.Highlight)) g.FillRectangle(brush, this.RenderBounds); } color = p.Colors.HighlightText.IsEmpty ? SystemColors.HighlightText : p.Colors.HighlightText; } if (!(this.IsEmpty && this.AllowEmptyState)) { string text = GetRenderString(); TextDrawing.DrawString(g, text, font, color, RenderBounds, textFormat); } base.OnPaint(p); }
public override void PerformLayout(PaintInfo pi) { this.Size = new System.Drawing.Size(_DefaultSize.Width + 2, _DefaultSize.Height); this.CalculatedSize = this.Size; base.PerformLayout(pi); }
internal virtual void ProcessPaint(PaintInfo p) { if (!IsRendered) return; OnPaint(p); }
public override void PerformLayout(PaintInfo pi) { base.PerformLayout(pi); this.Size = new System.Drawing.Size(this.Size.Width + 4, this.Size.Height); }
protected virtual void PaintButtonBackground(PaintInfo p) { PaintButtonBackground(p, GetOffice2007StateColorTable(p)); }