⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hstatusbar.cs

📁 c#编写的汽车销售公司erp进销存系统
💻 CS
字号:
using System;
using System.Windows.Forms;
using System.Drawing;

namespace CallCenter.BusinessInterfaces.MainForms
{
	/// <summary>
	/// HStatusBar 的摘要说明。
	/// </summary>
	public class HStatusBar:StatusBar
	{
//		private Color _color;
		public HStatusBar()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
			this.BackColor=Color.Red;
		}
		public override System.Drawing.Color BackColor
		{
			get
			{
				return Color.Red;//base.BackColor;
			}
			set
			{
				base.BackColor = value;
			}
		}
		public Color setColor
		{
			get
			{
				return BackColor;
			}
			set
			{
				BackColor=value;
			}
		}
		private Color _panelcolor1=Color.FromArgb(195,218,249);//panel颜色1
		public Color panelcolor1
		{
			get 
			{
				return _panelcolor1;
			}
			set
			{
				_panelcolor1=value;
			}
		}
		private Color _panelcolor2=Color.FromArgb(158,190,245);//panel颜色2
		public Color panelcolor2
		{
			get 
			{
				return _panelcolor2;
			}
			set
			{
				_panelcolor2=value;
			}
		}
		private Color _textcolor=Color.Black;//文本颜色
		public Color textcolor
		{
			get
			{
				return _textcolor;
			}
			set
			{
				_textcolor=value;
			}
		}
		private Color _bordercolor=Color.Blue;//边框颜色
		public Color bordercolor
		{
			get
			{
				return _bordercolor;
			}
			set
			{
				_bordercolor=value;
			}
		}
	
		protected override void OnDrawItem(StatusBarDrawItemEventArgs sbdevent)
		{
			base.OnDrawItem (sbdevent);
			
			// Create a StringFormat object to align text in the panel.
			StringFormat sf = new StringFormat();

			// Format the String of the StatusBarPanel to be centered.
			sf.LineAlignment = StringAlignment.Center;
			sf.FormatFlags = StringFormatFlags.NoWrap;
			
			StatusBarPanel panel = (StatusBarPanel)sbdevent.Panel;
			if( panel.Alignment == HorizontalAlignment.Left )
				sf.Alignment = StringAlignment.Center;
			else if( panel.Alignment == HorizontalAlignment.Left )
				sf.Alignment = StringAlignment.Near;
			else
				sf.Alignment = StringAlignment.Far;

			
				Rectangle rect = sbdevent.Bounds;
//				rect.Width -= 1;
//				rect.Height -= 2;
			System.Drawing.Drawing2D.LinearGradientBrush bBackground 
				= new System.Drawing.Drawing2D.LinearGradientBrush(rect, panelcolor1, panelcolor2, 10);
				Graphics g = sbdevent.Graphics;
				g.FillRectangle(bBackground, rect);
				g.DrawRectangle(new Pen(bordercolor),rect);
				g.DrawString(panel.Text,this.Font,new SolidBrush(textcolor),sbdevent.Bounds,sf);
			bBackground.Dispose();
			
		}
		protected override void OnPaint(PaintEventArgs e)
		{
			// paint all the panels
			int xStart = 0;
			OnDrawItem(new StatusBarDrawItemEventArgs(e.Graphics,Font,
				new Rectangle(xStart,2,this.Panels[0].Width-2,Height-1),1,DrawItemState.Default,this.Panels[0]));

			xStart += this.Panels[1].Width;
			OnDrawItem(new StatusBarDrawItemEventArgs(e.Graphics,Font,
				new Rectangle(xStart,2,this.Panels[1].Width-2,Height-1),1,DrawItemState.Default,this.Panels[1]));
			
			xStart += this.Panels[2].Width;
			OnDrawItem(new StatusBarDrawItemEventArgs(e.Graphics,Font,
				new Rectangle(xStart,2,this.Panels[2].Width-2,Height-1),1,DrawItemState.Default,this.Panels[2]));

		
			xStart += this.Panels[3].Width;
			OnDrawItem(new StatusBarDrawItemEventArgs(e.Graphics,Font,
				new Rectangle(xStart,2,this.Panels[3].Width,Height-1),1,DrawItemState.Default,this.Panels[3]));

			// draw the resize grip
			if( this.SizingGrip == true )
				ControlPaint.DrawSizeGrip(e.Graphics,SystemColors.Control,new Rectangle(this.Width-17,this.Height - 17,
					16,16));

			base.OnPaint (e);
		}
	
		protected override void OnResize(EventArgs e)
		{
			// test if the size is near maximuized, disable the sizing grip
			if( SystemInformation.VirtualScreen.Width <= Width )
				this.SizingGrip = false;
			else
				this.SizingGrip = true;
	
			base.OnResize (e);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -