public MainWindow() { InitializeComponent(); var top = Properties.Settings.Default.WindowTop; var left = Properties.Settings.Default.WindowLeft; var height = Properties.Settings.Default.WindowHeight; // Restore window location if (top != 0 || left != 0 || height != 440) { WindowStartupLocation = WindowStartupLocation.Manual; Top = top; Left = left; SetHeight(height); } listener = new LowLevelKeyboardListener(); listener.OnKeyPressed += Listener_OnKeyPressed; listener.HookKeyboard(); simConnectManager = new SimConnectManager(); simConnectManager.ConnectStatusEvent += SimConnectManager_ConnectStatusEvent; tugManager = new TugManager(simConnectManager); tugManager.TugStatusEvent += TugManager_TugStatusEvent; exitManager = new ExitManager(simConnectManager); exitManager.ExitEvent += ExitManager_ExitEvent; servicesManager = new ServicesManager(simConnectManager); servicesManager.ParkingBrakeEvent += ServicesManager_ParkingBrakeEvent; speedSlider.Value = Properties.Settings.Default.TugSpeed; speedSlider.Minimum = 5; speedSlider.Maximum = 50; tugManager.SetSpeed(Properties.Settings.Default.TugSpeed); btnOpenMainDoor.IsEnabled = false; btnOpenCargoDoor.IsEnabled = false; btnOpenEmergencyDoor.IsEnabled = false; simConnectManager.Start(); }
private void SpeedSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { tugManager.SetSpeed((uint)e.NewValue); }
public MainWindow() { try { InitializeComponent(); } catch (Exception Ex) { MessageBox.Show(Ex.ToString(), "Exception Caught", MessageBoxButton.OK, MessageBoxImage.Error); } ConnectedOnce = false; uint tugSpeed = 25; try { if (Properties.Settings.Default.CallUpgrade) { Properties.Settings.Default.Upgrade(); Properties.Settings.Default.CallUpgrade = false; } var top = Properties.Settings.Default.WindowTop; var left = Properties.Settings.Default.WindowLeft; var height = Properties.Settings.Default.WindowHeight; tugSpeed = Properties.Settings.Default.TugSpeed; // Restore window location if (top != 0 || left != 0 || height != 480) { WindowStartupLocation = WindowStartupLocation.Manual; Top = top; Left = left; SetHeight(height); } } catch { MessageBox.Show("Unable to load settings file", "Exception Caught", MessageBoxButton.OK, MessageBoxImage.Error); } try { listener = new LowLevelKeyboardListener(); listener.OnKeyPressed += Listener_OnKeyPressed; listener.HookKeyboard(); } catch { MessageBox.Show("Unable to connect to keyboard", "Exception Caught", MessageBoxButton.OK, MessageBoxImage.Error); } try { simConnectManager = new SimConnectManager(); simConnectManager.ConnectStatusEvent += SimConnectManager_ConnectStatusEvent; tugManager = new TugManager(simConnectManager); tugManager.TugStatusEvent += TugManager_TugStatusEvent; exitManager = new ExitManager(simConnectManager); exitManager.ExitEvent += ExitManager_ExitEvent; servicesManager = new ServicesManager(simConnectManager); servicesManager.ParkingBrakeEvent += ServicesManager_ParkingBrakeEvent; speedSlider.Value = tugSpeed; speedSlider.Minimum = 5; speedSlider.Maximum = 50; tugManager.SetSpeed(tugSpeed); btnOpenMainDoor.IsEnabled = false; btnOpenCargoDoor.IsEnabled = false; btnOpenEmergencyDoor.IsEnabled = false; btnForward.IsEnabled = false; btnReverse.IsEnabled = false; btnLeft.IsEnabled = false; btnRight.IsEnabled = false; simConnectManager.Start(); } catch { MessageBox.Show("Unable to initialize SimConnect manager", "Exception Caught", MessageBoxButton.OK, MessageBoxImage.Error); } }