private void Form1_KeyUp(object sender, KeyEventArgs e) { LeftTimer.Stop(); RightTimer.Stop(); UpTimer.Stop(); DownTimer.Stop(); }
private void Form1_KeyDown(object sender, KeyEventArgs e) { if ((e.KeyCode == Keys.Left) || (e.KeyCode == Keys.A)) { LeftTimer.Start(); } if ((e.KeyCode == Keys.Right) || (e.KeyCode == Keys.D)) { RightTimer.Start(); } if ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.W)) { UpTimer.Start(); } if ((e.KeyCode == Keys.Down) || (e.KeyCode == Keys.S)) { DownTimer.Start(); } if (e.KeyCode == Keys.Space) { int i = shootNr % 3; bullets[i].Location = new Point(plane.Location.X + 20, plane.Location.Y - 30); bullets[i].Visible = true; shootNr++; if (shootNr == 6) { shootNr = 3; } } }
public QuickForm() { InitializeComponent(); boLoSearch = new BoLoSearch.BoLoSearch(); SetStartup(_settings.LaunchOnStartup); update = new CheckUpdate(_settings); AddTrayIcons(); mouseHook.MouseDown += new MouseEventHandler((s, e) => { AddMouseEvent("MouseDown", e.Button.ToString(), e.X, e.Y, ""); }); mouseHook.MouseUp += new MouseEventHandler((s, e) => { AddMouseEvent("MouseUp", e.Button.ToString(), e.X, e.Y, ""); }); mouseHook.MouseWheel += new MouseEventHandler((s, e) => { AddMouseEvent("MouseWheel", "", -1, -1, e.Delta.ToString()); }); mouseHook.Start(); keyboardHook.KeyDown += new KeyEventHandler((s, e) => { KeyboardEvent("KeyDown", e.KeyCode.ToString(), "", e.Shift.ToString(), e.Alt.ToString(), e.Control.ToString()); }); keyboardHook.KeyUp += new KeyEventHandler((s, e) => { KeyboardEvent("KeyUp", e.KeyCode.ToString(), "", e.Shift.ToString(), e.Alt.ToString(), e.Control.ToString()); }); keyboardHook.KeyPress += new KeyPressEventHandler((s, e) => { KeyboardEvent("KeyPress", "", e.KeyChar.ToString(), "", "", ""); }); keyboardHook.Start(); // 自定义关机和logoff的事件 Microsoft.Win32.SystemEvents.SessionEnding += SessionEndingEvent; UpTimer.Enabled = true; UpTimer.Start(); CreateFile(); _trayIcon.Icon = _settings.aiTranslate ? Resources.favicon_open : Resources.favicon_close; registerCom(true); Thread thread_update = new Thread(UpdateCheck); thread_update.IsBackground = true; thread_update.Start(); }
public void Effect(IBonusModel effectTaker) { if (!_isBonusTaken) { _effect.SetEffect(effectTaker.EffectType, effectTaker.Effect); _timer = new UpTimer(0, effectTaker.Duration); _isBonusTaken = true; } OnEffect.Invoke(effectTaker); }