#region License
/**
* Ingenious MVC : An MVC framework for .NET 2.0
* Copyright (C) 2006, JDP Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors: - Kent Boogaart (kentcb@internode.on.net)
*/
#endregion
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Ingenious.Mvc.Util;
namespace Ingenious.Mvc.Windows.Forms.Controls{
/// <include file='EtchedLine.doc.xml' path='/doc/member[@name="T:EtchedLine"]/*'/>
public sealed class EtchedLine : Control
{
private Orientation _orientation;
private Pen _darkPen;
private Pen _lightPen;
/// <include file='EtchedLine.doc.xml' path='/doc/member[@name="P:Orientation"]/*'/>
[Browsable(true)]
[Description("Specifies the orientation for the etched line. That is, which direction it is drawn.")]
public Orientation Orientation
{
get
{
return _orientation;
}
set
{
if (value != _orientation)
{
ArgumentHelper.AssertEnumMember(value);
_orientation = value;
//invert the size
Size = new Size(Height, Width);
Invalidate();
}
}
}
/// <include file='EtchedLine.doc.xml' path='/doc/member[@name="M:.ctor()"]/*'/>
public EtchedLine()
{
Orientation = Orientation.Horizontal;
Resize += new EventHandler(EtchedLine_Resize);
_darkPen = new Pen(SystemColors.ControlDark);
_lightPen = new Pen(SystemColors.ControlLightLight);
}
/// <include file='EtchedLine.doc.xml' path='/doc/member[@name="M:OnPaint(System.Windows.Forms.PaintEventArgs)"]/*'/>
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
if (Orientation == Orientation.Horizontal)
{
g.DrawLine(_darkPen, 0, 0, Width, 0);
g.DrawLine(_lightPen, 0, 1, Width, 1);
}
else
{
g.DrawLine(_darkPen, 0, 0, 0, Height);
g.DrawLine(_lightPen, 1, 0, 1, Height);
}
}
/// <include file='EtchedLine.doc.xml' path='/doc/member[@name="M:Dispose(System.Boolean)"]/*'/>
protected override void Dispose(bool disposing)
{
if (disposing)
{
_darkPen.Dispose();
_lightPen.Dispose();
}
base.Dispose(disposing);
}
private void EtchedLine_Resize(object sender, EventArgs e)
{
switch (Orientation)
{
case Orientation.Horizontal:
Height = 2;
break;
case Orientation.Vertical:
Width = 2;
break;
}
}
}
}
|