private void CheckAppInstance() { if (!mutex.WaitOne(TimeSpan.Zero, true)) { SpaceVIL.MessageBox msg = new SpaceVIL.MessageBox(Controller.GetLanguage()["IsRunning"], Controller.GetLanguage()["OutputTitle"]); msg.GetCancelButton().SetVisible(false); msg.Show(); msg.OnCloseDialog += () => { Environment.Exit(0); }; } }
private void InitController() { if (GetSettings().StartAppMinimized) { _mainWindow.Minimize(); } if (GetSettings().AutoStart) { _mainWindow.EventOnStart += () => { _mainWindow.BtnStart.EventMouseClick?.Invoke(_mainWindow.BtnStart, null); }; } _mainWindow.EventClose += () => { _baloonTooltip.Visible = false; _baloonTooltip.Dispose(); WindowManager.AppExit(); }; _mainWindow.BtnSettings.EventMouseClick += (sender, args) => { _gamepadHandler.Stop(); _settingsWindow.Show(); _mainWindow.UpdateUIStartButton(!_gamepadHandler.IsRunning()); }; _mainWindow.Title.GetMinimizeButton().EventMouseClick += (sender, args) => { _mainWindow.SetHidden(true); _baloonTooltip.ShowBalloonTip(1000); }; _mainWindow.BtnStart.EventMouseClick += (sender, args) => { if (_gamepadHandler.IsRunning()) { _gamepadHandler.Stop(); } else { _gamepadHandler.Run(); } _mainWindow.UpdateUIStartButton(!_gamepadHandler.IsRunning()); }; _mainWindow.BtnStatus.EventMouseClick += (sender, args) => { if (!_gamepad.IsConnected()) { SpaceVIL.MessageBox msgBox = new SpaceVIL.MessageBox(GetLanguage()["MsgIsConnection"], GetLanguage()["OutputTitle"]); msgBox.GetCancelButton().SetVisible(false); msgBox.Show(); } else { _mainWindow.UpdateBatteryLevel(_gamepad.GetBatteryInfo()); } }; _settingsWindow.SaveBtn.EventMouseClick += (sender, args) => { _cfgManager.SaveSettings(); _cfgManager.SaveProfile(); }; _cfgManager.EventOnIOProfileFail += (message, title) => { SpaceVIL.MessageBox msgException = new SpaceVIL.MessageBox(message, title); msgException.GetCancelButton().SetVisible(false); msgException.Show(); }; _cfgManager.EventOnIOSettingsFail += _cfgManager.EventOnIOProfileFail; _cfgManager.EventOnLanguageChange += (name) => { _baloonTooltip.BalloonTipText = Controller.GetLanguage()["BalloonText"]; _showMenuItem.Text = Controller.GetLanguage()["TrayShow"]; _exitMenuItem.Text = Controller.GetLanguage()["TrayExit"]; _settingsWindow.UpdateUI(); _mainWindow.UpdateUI(); }; _cfgManager.EventOnProfileChange += (name) => { _cfgManager.CurrentProfile = _cfgManager.ProfileList[name]; _cfgManager.CommonSettings.DefaultProfile = _cfgManager.CurrentProfile.Name; _settingsWindow.UpdateUI(); _mainWindow.UpdateUI(); }; (_gamepadHandler as XInputHandler).OnBatteryLevelChanged = (level) => { _mainWindow.UpdateBatteryLevel(level); }; }