| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace HOZProject
- {
- public partial class FormUCMain : Form
- {
- public FormUCMain()
- {
- InitializeComponent();
- }
- private void FormUCMain_LocationChanged(object sender, EventArgs e)
- {
- }
- #region 关闭与最小化按钮事件
- private void pichide_MouseEnter(object sender, EventArgs e)
- {
- pichide.Image = Properties.Resources.Min_Blue;
- }
- private void pichide_MouseLeave(object sender, EventArgs e)
- {
- pichide.Image = Properties.Resources.Min_Gray;
- }
- private void picexit_MouseEnter(object sender, EventArgs e)
- {
- picexit.Image = Properties.Resources.exit_Red;
- }
- private void picexit_MouseLeave(object sender, EventArgs e)
- {
- picexit.Image = Properties.Resources.exit_Gray;
- }
- private void picexit_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void pichide_Click(object sender, EventArgs e)
- {
- this.WindowState = FormWindowState.Minimized;
- }
- #endregion
- #region 拖动窗体
- private Point mouseOff;//鼠标移动位置变量
- private bool leftFlag;//标签是否为左键
- private void FormUCMain_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- mouseOff = new Point(-e.X, -e.Y); //得到变量的值
- leftFlag = true; //点击左键按下时标注为true;
- }
- }
- private void FormUCMain_MouseMove(object sender, MouseEventArgs e)
- {
- if (leftFlag)
- {
- Point mouseSet = Control.MousePosition;
- mouseSet.Offset(mouseOff.X, mouseOff.Y); //设置移动后的位置
- Location = mouseSet;
- }
- }
- private void FormUCMain_MouseUp(object sender, MouseEventArgs e)
- {
- if (leftFlag)
- {
- leftFlag = false;//释放鼠标后标注为false;
- }
- }
- #endregion
- }
- }
|