Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
BorderLabel.cs
Package: ProgressBar_src.rar [view]
Upload User: nnpulika
Upload Date: 2013-02-15
Package Size: 597k
Code Size: 2k
Category:
StatusBar
Development Platform:
C#
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Drawing.Drawing2D;
- using System.ComponentModel;
- namespace UtilityLibrary.WinControls
- {
- /// <summary>
- /// Summary description for BorderLabel.
- /// </summary>
- [ToolboxItem(false)]
- public class BorderLabel : Label
- {
- #region Class Variables
- Pen pen = null;
- Pen hoverPen = null;
- bool highlight = false;
- int width = -1;
- int gap = 0;
- #endregion
- #region Constructors
- 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;
- }
- #endregion
- #region
- 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();
- }
- }
- #endregion
- }
- }