示例#1
0
        private void connectButton_Click(object sender, RoutedEventArgs e)
        {
            if (!vm.VM_Connected)
            {
                string ip   = ipTextBox.Text;
                int    port = Int32.Parse(portTextBox.Text);
                if ((ip != "localhost" && ip != "127.0.0.1") || port != 5402)
                {
                    errorWindow.Content  = "Invalid Port or IP ! please re-insert correct credentials";
                    errorArea.Background = Brushes.Red;
                }
                else
                {
                    model.setClient(new MyTelnetClient());

                    vm.connect(ip, port);
                    SteerVM steerVM = new SteerVM(this.model);
                    //MapVM mapVM = new MapVM(this.model);
                    vm = new FlightGearViewModel(this.model);
                    //mapUC.DataContext = mapVM;
                    steerUC.DataContext = steerVM;
                    DataContext         = vm;
                }
            }
            else
            {
                errorWindow.Content  = "Exception: you are already connected";
                errorArea.Background = Brushes.Red;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MainWindow"/> class.
 /// </summary>
 public MainWindow()
 {
     InitializeComponent();
     client          = new Client();
     vm              = new FlightGearViewModel(new FlightGearModel(client));
     DataContext     = vm;
     map.DataContext = vm;
     controller.SetViewModel(vm);
     disconnectButton.IsEnabled = false;
     connectWindow = new Connect();
 }
示例#3
0
        //private bool connected;

        public MainWindow()
        {
            InitializeComponent();
            ipTextBox.Text   = ConfigurationManager.AppSettings["ip"];
            portTextBox.Text = ConfigurationManager.AppSettings["port"];


            this.model = new MyDashboardModel(null);
            vm         = new FlightGearViewModel(this.model);
            //SteerVM steerVM = new SteerVM(this.model);
            //MapVM mapVM = new MapVM(this.model);

            ////mapUC.DataContext = mapVM;
            //steerUC.DataContext = steerVM;
            //DataContext = vm;

            vm.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "VM_ErrorString")
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        errorWindow.Content  = vm.VM_ErrorString;
                        errorArea.Background = Brushes.Red;
                    });
                }
                if (e.PropertyName == "VM_Connected")
                {
                    if (vm.VM_Connected == true)
                    {
                        connectionStatus.Content    = "Connected";
                        connectionStatus.Foreground = Brushes.Green;
                        elipseConnectionStatus.Fill = Brushes.Green;
                        errorWindow.Content         = "";
                        errorArea.Background        = Brushes.Transparent;
                        //connected = true;
                    }
                    if (vm.VM_Connected == false)
                    {
                        connectionStatus.Content    = "Disconnected";
                        connectionStatus.Foreground = Brushes.Red;
                        elipseConnectionStatus.Fill = Brushes.Red;

                        //connected = false;
                    }
                }
            };
        }
 /// <summary>Sets the view model.</summary>
 /// <param name="vm">The veiew model.</param>
 public void SetViewModel(FlightGearViewModel vm)
 {
     this.vm = vm;
 }
 /// <summary>
 /// Sets the view model.
 /// </summary>
 /// <param name="vm">The vm.</param>
 public void SetViewModel(FlightGearViewModel vm)
 {
     joy.SetViewModel(vm);
 }