51 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace DevComponents.DotNetBar.Layout
{
/// <summary>
/// Represents the item used as empty spacer element.
/// </summary>
public class LayoutSpacerItem : LayoutItemBase
{
#region Constructor
#endregion
#region Implementation
protected override void OnPaintBackground(PaintContext context)
{
base.OnPaintBackground(context);
if (this.DesignMode && !this.IsSelected && this.Bounds.Width > 0 && this.Bounds.Height > 0)
{
using (Pen borderPen = this.DesignTimeBorderPen)
{
Rectangle clientRectangle = this.Bounds;
clientRectangle.Width--;
clientRectangle.Height--;
context.Graphics.DrawRectangle(borderPen, clientRectangle);
}
}
}
protected Pen DesignTimeBorderPen
{
get
{
Color color = (SystemColors.Control.GetBrightness() < 0.5) ? ControlPaint.Light(SystemColors.Control) : ControlPaint.Dark(SystemColors.Control);
LayoutControl lc = GetLayoutControl();
if (lc != null)
color = (lc.BackColor.GetBrightness() < 0.5) ? ControlPaint.Light(lc.BackColor) : ControlPaint.Dark(lc.BackColor);
Pen pen = new Pen(color);
pen.DashStyle = DashStyle.Dash;
return pen;
}
}
#endregion
}
}