private void connect_Click(object sender, RoutedEventArgs e)
 {
     if (!cw.IsLoaded)
     {
         cw = new ConnectWindow((Application.Current as App).flightSimulatorViewModel);
         cw.Show();
     }
 }
        private void ConnectButton_Click(object sender, RoutedEventArgs e)
        {
            // Open connection window - at first with default IP and Port, or if changed the changed values.
            ConnectWindow cW = new ConnectWindow()
            {
                DataContext = (Application.Current as App).ConnectViewModel
            };

            cW.Show();
            connectButton.IsEnabled    = false;
            disconnectButton.IsEnabled = true;
            MyControls.IsEnabled       = true;
            GameMap.IsEnabled          = true;
        }
 public MainWindow()
 {
     InitializeComponent();
     DataContext = (Application.Current as App).flightSimulatorViewModel;
     //model = new FlightSimulatorModel(new MyTelnetClient());
     ////flightSimulatorViewModel = new FlightSimulatorViewModel(new FlightSimulatorModel(new MyTelnetClient()));
     //flightSimulatorViewModel = new FlightSimulatorViewModel(model);
     //manualControlsViewModel = new ManualControlsViewModel(model);
     //dashboardViewModel = new DashboardViewModel(model);
     //mapControlViewModel = new MapControlViewModel(model);
     //DataContext = flightSimulatorViewModel;
     myDashboard.DataContext      = (Application.Current as App).dashboardViewModel;
     myMapControl.DataContext     = (Application.Current as App).mapControlViewModel;
     myManualControls.DataContext = (Application.Current as App).manualControlsViewModel;
     //dashboard.DataContext = flightSimulatorViewModel;
     //Joystick.MyEvent += SetXY;
     cw = new ConnectWindow((Application.Current as App).flightSimulatorViewModel);
     ew = new ErrorsWindow((Application.Current as App).flightSimulatorViewModel);
 }