- ak_wizard_src.zip
- UtilityLibrary.Designers
- UtilityLibrary.Win32.WindowsAPI
- UtilityLibrary
- AssemblyInfo.cs
- Collections
- Combos
- CommandBars
- Controls.resX
- DateTimeControls
- Dialogs
- Gantt Chart
- General
- licenses.licx
- Menus
- mssccprj.scc
- Notification
- OutlookBar
- Resources
- Controls.resX
- DragCursor.cur
- ImagesColorPicker.resX
- ImagesMenu.resX
- MenuControlImages.resX
- SortedListView.resX
- vssver.scc
- Serialization
- Smtp
- Strong Keys
- UtilityLibStrongKey.snk
- vssver.scc
- TreeListView
- UtilityLibrary.csproj
- UtilityLibrary.csproj.user
- UtilityLibrary.csproj.vspscc
- UtilityLibrary.suo
- vssver.scc
- WinControls
- Wizards
|
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace UtilityLibrary.WinControls
{
/// <summary>
/// Summary description for BorderLabel.
/// </summary>
public class BorderLabel : Label
{
Pen pen = null;
Pen hoverPen = null;
bool highlight = false;
int width = -1;
int gap = 0;
public BorderLabel(Color BorderColor, Color HoverColor): this(BorderColor, HoverColor, 1)
{
}
public BorderLabel(Color BorderColor, Color HoverColor, int Width)
{
highlight = true;
width = Width;
pen = new Pen(BorderColor, Width);
hoverPen = new Pen(HoverColor, Width);
pen.Alignment = PenAlignment.Inset;
hoverPen.Alignment = PenAlignment.Inset;
if ( Width == 1 )
gap = 1;
}
public BorderLabel(Color BorderColor): this(BorderColor, 1)
{
}
public BorderLabel(Color BorderColor, int Width)
{
highlight = false;
width = Width;
pen = new Pen(BorderColor, Width);
pen.Alignment = PenAlignment.Inset;
if ( Width == 1 )
gap = 1;
}
override protected void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
// Draw a border around the label
Rectangle rc = Bounds;
e.Graphics.DrawRectangle(pen, 0, 0, rc.Width-gap, rc.Height-gap);
}
override protected void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if ( highlight )
{
Graphics g = CreateGraphics();
Rectangle rc = Bounds;
g.DrawRectangle(hoverPen, 0, 0, rc.Width-gap, rc.Height-gap);
g.Dispose();
}
}
override protected void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
if ( highlight )
{
Graphics g = CreateGraphics();
Rectangle rc = Bounds;
g.DrawRectangle(pen, 0, 0, rc.Width-gap, rc.Height-gap);
g.Dispose();
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.