/// <summary> /// Mouse move sensor timer tick function. /// Sends x and y acceleration. /// Screen orientation aware (swaps x and y values on landscape). /// Supports invert Y setting. /// Supports scrolling when scroll button is being held. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer_Tick(object sender, EventArgs e) { if (x != (int)(sensor.GetGVector().X * 10) || y != (int)(sensor.GetGVector().Y * 10)) { x = (int)(sensor.GetGVector().X * 10); y = (int)(sensor.GetGVector().Y * 10); if (Convert.ToBoolean((string)Settings.get("invertY"))) { y = -y; } if (SystemSettings.ScreenOrientation == Microsoft.WindowsCE.Forms.ScreenOrientation.Angle180 || SystemSettings.ScreenOrientation == Microsoft.WindowsCE.Forms.ScreenOrientation.Angle270) { int z = x; x = y; y = z; y = -y; } string data; if (scroll) { data = "SCROLL " + y.ToString() + ";"; } else { data = x.ToString() + " " + y.ToString() + ";"; } if (send != null) { send(data); } } }
/// <summary> /// Vol sensor panel timer tick. /// Changes interval depending on phone position. /// Sends MEDIA VOLUP and MEDIA VOLDOWN commands. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void volTimer_Tick(object sender, EventArgs e) { if (sensor.GetGVector().X < -1) { send("MEDIA VOLDOWN;"); volTimer.Interval = (int)(Math.Abs(800 / sensor.GetGVector().X)); } else if (sensor.GetGVector().X > 1) { send("MEDIA VOLUP;"); volTimer.Interval = (int)(Math.Abs(800 / sensor.GetGVector().X)); } }