/*
* Copyright © 2003 NullFX Software
* By: Steve Whitley
*
* $Log: Line.cs,v $
*
* */
namespace NullFX.Controls {
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
[Designer(typeof(Line.LineDesigner))]
public class Line : System.Windows.Forms.Control {
internal class LineDesigner : System.Windows.Forms.Design.ControlDesigner {
public override System.Windows.Forms.Design.SelectionRules SelectionRules {
get {
return System.Windows.Forms.Design.SelectionRules.LeftSizeable |
System.Windows.Forms.Design.SelectionRules.RightSizeable |
System.Windows.Forms.Design.SelectionRules.Visible |
System.Windows.Forms.Design.SelectionRules.Moveable;
}
}
}
private System.Windows.Forms.FlatStyle _flatStyle;
private Pen _systemPen;
private System.ComponentModel.Container components = null;
[Category("Appearance"), Description("Determines the display of the control when the users move the mouse over the control and click")]
public System.Windows.Forms.FlatStyle FlatStyle {
get{return _flatStyle;}
set{
_flatStyle = value;
Invalidate();
}
}
public Line() {
_flatStyle = FlatStyle.Standard;
_systemPen = new Pen(SystemColors.ControlDark, 2);
SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer|
ControlStyles.ResizeRedraw|
ControlStyles.UserPaint, true);
}
protected override void Dispose( bool disposing ) {
if( disposing ) {
if( components != null ) {
components.Dispose();
}
}
base.Dispose( disposing );
}
protected override Size DefaultSize {
get {
return new System.Drawing.Size(32, 2);
}
}
protected override void OnPaint(PaintEventArgs pe) {
switch(_flatStyle) {
case System.Windows.Forms.FlatStyle.Flat:
case System.Windows.Forms.FlatStyle.Popup:
case System.Windows.Forms.FlatStyle.Standard: {
pe.Graphics.FillRectangle(SystemBrushes.ControlLightLight, 0, 0, Width, 2);
pe.Graphics.FillRectangle(SystemBrushes.ControlDark, 0, 0, Width - 1, Height / 2);
}break;
case System.Windows.Forms.FlatStyle.System: {
pe.Graphics.DrawLine(_systemPen, 0, 1, Width, 1);
}break;
default:
goto case System.Windows.Forms.FlatStyle.Standard;
}
}
}
}