实例介绍
【实例简介】
会员管理
商品管理
账单审计
【实例截图】
【核心代码】
bool toolstipshow = false;
PanelEnhanced panel1 = null;
MemberManagement mm = null; //会员管理
Part part = null; //商品管理
BillAudit ba = null;//账单审计
public Form1()
{
InitializeComponent();
groupBox1.Visible = false;
groupBox2.Visible = false;
}
protected override CreateParams CreateParams
{
get
{
CreateParams paras = base.CreateParams;
paras.ExStyle |= 0x02000000;
return paras;
}
}
MouseHook mh = null;
//窗体加载
private void Form1_Load(object sender, EventArgs e)
{
MouserSet();
LoadPanl();
SetBackGroundImage();
SetPanlLight();
SetToolStripImage();
//隐藏ToolStrip
TimerTool();
}
private void mh_MouseClickEvent(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
//MessageBox.Show(e.X "-" e.Y);
// textBox1.Text = e.X.ToString();
// textBox2.Text = e.Y.ToString();
}
}
private void mh_MouseMoveEvent(object sender, MouseEventArgs e)
{
int x = e.Location.X;
int y = e.Location.Y;
if (toolstipshow)
{
if (x < this.Location.X || x > this.Location.X this.Size.Width || y < this.Location.Y 30 || y > this.Location.Y 60)
{
toolstipshow = false;
toolStrip1.Visible = toolstipshow;
}
}
else
{
if (x >= this.Location.X && x <= this.Location.X this.Size.Width && y == this.Location.Y 30)
{
toolstipshow = true;
toolStrip1.Visible = toolstipshow;
}
}
/*
textBox1.Text = e.X.ToString();
textBox2.Text = e.Y.ToString();
textBox3.Text = this.Location.X.ToString() ;
textBox4.Text = this.Location.Y.ToString();
*/
}
private void MouserSet()
{
mh = new MouseHook();
mh.SetHook();
mh.MouseMoveEvent = mh_MouseMoveEvent;
mh.MouseClickEvent = mh_MouseClickEvent;
}
System.Timers.Timer timer;
private void TimerTool()
{
//设置定时间隔(毫秒为单位)
int interval = 2000;
timer = new System.Timers.Timer(interval);
//设置执行一次(false)还是一直执行(true)
timer.AutoReset = false;
//设置是否执行System.Timers.Timer.Elapsed事件
timer.Enabled = true;
//绑定Elapsed事件
timer.Elapsed = new System.Timers.ElapsedEventHandler(HiddenToolStrip);
}
private void HiddenToolStrip(object sender, System.Timers.ElapsedEventArgs e)
{
toolStrip1.Visible = toolstipshow;
}
/// <summary>
/// 设置工具栏图片
/// </summary>
private void SetToolStripImage()
{
toolStripButton1.Image = System.Drawing.Image.FromFile(@"..\\..\\Resources\\home.ico");
toolStripButton2.Image = System.Drawing.Image.FromFile(@"..\\..\\Resources\\Vip.ico");
toolStripButton3.Image = System.Drawing.Image.FromFile(@"..\\..\\Resources\\bill.ico");
toolStripButton4.Image = System.Drawing.Image.FromFile(@"..\\..\\Resources\\data.ico");
toolStripButton5.Image = System.Drawing.Image.FromFile(@"..\\..\\Resources\\Exit.ico");
}
/// <summary>
/// 添加控件
/// </summary>
private void LoadPanl()
{
panel1 = new PanelEnhanced();
panel1.Dock = DockStyle.Fill;
this.Controls.Add(panel1);
}
/// <summary>
/// 防止闪烁
/// </summary>
private void SetPanlLight()
{
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
}
/// <summary>
/// 设置背景图
/// </summary>
private void SetBackGroundImage()
{
switch ((int)DateTime.Now.DayOfWeek)
{
case 0:
panel1.BackgroundImage = Properties.Resources.funny_week7;
break;
case 1:
panel1.BackgroundImage = Properties.Resources.funny_week1;
break;
case 2:
panel1.BackgroundImage = Properties.Resources.funny_week2;
break;
case 3:
panel1.BackgroundImage = Properties.Resources.funny_week3;
break;
case 4:
panel1.BackgroundImage = Properties.Resources.funny_week4;
break;
case 5:
panel1.BackgroundImage = Properties.Resources.funny_week5;
break;
default:
panel1.BackgroundImage = Properties.Resources.funny_week6;
break;
}
}
/// <summary>
/// 会员管理
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton2_Click(object sender, EventArgs e)
{
panel1.Controls.Clear();
mm = new MemberManagement();
mm.Dock = DockStyle.Fill;
mm.TopLevel = false;
panel1.Controls.Add(mm);
mm.Show();
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
panel1.Controls.Clear();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (mh!=null)
{
mh.UnHook();
}
}
/// <summary>
/// 商品管理
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton4_Click(object sender, EventArgs e)
{
panel1.Controls.Clear();
part = new Part();
part.Dock = DockStyle.Fill;
part.TopLevel = false;
panel1.Controls.Add(part);
part.Show();
}
private void toolStripButton3_Click(object sender, EventArgs e)
{
panel1.Controls.Clear();
ba = new BillAudit();
ba.Dock = DockStyle.Fill;
ba.TopLevel = false;
panel1.Controls.Add(ba);
ba.Show();
}
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论