private static void logoIcon_MouseMove(object sender, MouseEventArgs e) { if (beginMove) { Button btn = sender as Button; Panel panel = sender as Panel; DSkin.Controls.DSkinPictureBox DSkinPictureBox = sender as DSkin.Controls.DSkinPictureBox; Control control = new Button(); if (btn != null) { control = (Control)((Button)sender).Tag; } else if (panel != null) { control = (Control)((Panel)sender).Tag; } else if (DSkinPictureBox != null) { control = (Control)((DSkin.Controls.DSkinPictureBox)sender).Tag; } if (control != null) { control.Left += Control.MousePosition.X - currentXPosition; //根据鼠标x坐标确定窗体的左边坐标x control.Top += Control.MousePosition.Y - currentYPosition; //根据鼠标的y坐标窗体的顶部,即Y坐标 currentXPosition = Control.MousePosition.X; currentYPosition = Control.MousePosition.Y; } } }
/// <summary> /// 给关闭按钮设置鼠标移入移出颜色 /// </summary> /// <param name="picBox"></param> public static void CloseButtonMouseEnterAndLeaveEvent(DSkin.Controls.DSkinPictureBox picBox) { picBox.MouseEnter += new EventHandler(delegate(object sender, EventArgs e) { picBox.BackColor = Color.FromArgb(150, 200, 0, 0); picBox.Cursor = System.Windows.Forms.Cursors.Hand; }); picBox.MouseLeave += new EventHandler(delegate(object sender, EventArgs e) { picBox.BackColor = Color.Transparent; }); }
/// <summary> /// 图片框鼠标移入移出事件 /// </summary> /// <param name="pic"></param> public static void PictureBoxMouseEnterAndLeaveEnvent(DSkin.Controls.DSkinPictureBox pic) { pic.MouseEnter += new EventHandler(delegate(object sender, EventArgs e) { pic.Cursor = System.Windows.Forms.Cursors.Hand; pic.Size = new Size(pic.Size.Width + 2, pic.Size.Height + 2); pic.Location = new Point(pic.Location.X - 1, pic.Location.Y - 1); pic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; }); pic.MouseLeave += new EventHandler(delegate(object sender, EventArgs e) { pic.Size = new Size(pic.Size.Width - 2, pic.Size.Height - 2); pic.Location = new Point(pic.Location.X + 1, pic.Location.Y + 1); }); }