//鼠标移动 private void alarmViedoPanel_MouseMove(object sender, MouseEventArgs e) { Size midPoint = new Size(alarmViedoPanel.Size.Width / 2, alarmViedoPanel.Size.Height / 2); Size loc = new Size(e.X, e.Y); loc.Width = loc.Width - midPoint.Width; loc.Height = midPoint.Height - loc.Height; Console.WriteLine(string.Format("位置 X:{0},Y:{1}", loc.Width, loc.Height)); Double r = Math.Sqrt(loc.Width * loc.Width + loc.Height * loc.Height); //Console.WriteLine(string.Format("R {0}", r)); double tanA = (double)loc.Height / (double)loc.Width; Console.WriteLine(string.Format("角 tan{0},绝对值{1}", tanA, Math.Abs(tanA))); int N = 30; if (Math.Abs(loc.Width) > alarmViedoPanel.Size.Width / 2 - N || Math.Abs(loc.Height) > alarmViedoPanel.Size.Height / 2 - N) { if (Math.Abs(tanA) < 1) { //横向的 if (loc.Width > 0) { //右 //MessageBox.Show("右"); Cursor = Cursors.PanEast; myCursor = enumCursor.PanEast; } else { //左 //MessageBox.Show("左"); Cursor = Cursors.PanWest; myCursor = enumCursor.PanWest; } } else { //纵向的 if (loc.Height > 0) { //上 //MessageBox.Show("上"); Cursor = Cursors.PanNorth; myCursor = enumCursor.PanNorth; } else { //下 //MessageBox.Show("下"); Cursor = Cursors.PanSouth; myCursor = enumCursor.PanSouth; } } } else { Cursor = Cursors.Default; myCursor = enumCursor.Default; return; } }
public static void mostrarMensagem(enumCor corMensagem, String mensagem, enumCursor modoCursor) { Cursor.Current = estadoCursor[(int)modoCursor]; tbMensagem.ForeColor = cores[(int)corMensagem]; tbMensagem.Text = mensagem; }
/// <summary> /// 鼠标按下 /// </summary> /// <param name="_myCursor">鼠标类型枚举</param> private void AlarmViedoPanel_MouseDown(enumCursor _myCursor,bool isDown) { if (null != AlarmViedoPanel_MouseDownEvent) { AlarmViedoPanel_MouseDownEventArgs args = new AlarmViedoPanel_MouseDownEventArgs(); args.MyCursor = _myCursor; args.IsDown = isDown; AlarmViedoPanel_MouseDownEvent(this,args); } }
public static void mostrarMensagem(enumCor corMensagem,String mensagem,enumCursor modoCursor) { Cursor.Current = estadoCursor[(int)modoCursor]; tbMensagem.ForeColor = cores[(int)corMensagem]; tbMensagem.Text = mensagem; }