Пример #1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            MyTelnetClient client = new MyTelnetClient();

            fs = new MyFlightSimulator(client);
            MainWindow wnd = new MainWindow();

            VM = new MainViewModel(fs);
            wnd.DataContext                = VM;
            wnd.dash.DataContext           = new DashboardViewModel(fs);
            wnd.map.DataContext            = new MapViewModel(fs);
            wnd.controllers.DataContext    = new MyControlsViewModel(fs);
            wnd.connect_button.DataContext = new ConnectionViewModel(fs);
            wnd.Show();
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();
            //create new telnet client
            ITelnetClient telnetClient = new MyTelnetClient();
            //create new model
            IModel model = new MyModel(telnetClient);
            Start  s     = new Start(model);

            //send the model to each of the object
            DashBoard dbView       = new DashBoard(model);
            Map       mapView      = new Map(model);
            Joystick  JoystickMain = new Joystick(model);
            Sliders   slide        = new Sliders(model);

            //add the object to the mainwindow
            dbSpace.Children.Add(dbView);
            mapSpace.Children.Add(mapView);
            joystick.Children.Add(JoystickMain);
            sliders.Children.Add(slide);
            screen.Children.Add(s);
        }
Пример #3
0
        // Initializing the simulator models and all of the view models.
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Connection part
            MyTelnetClient TCinstance = MyTelnetClient.Instance;

            connectVM = new ConnectionViewModel(TCinstance);

            // Map part
            IMapModel mapModel = new MyMapModel(TCinstance);

            mapVM = new MapViewModel(mapModel);

            // Gear part
            IGearModel gearModel = new MyGearModel(TCinstance);

            gearVM = new GearViewModel(gearModel);

            // Dashboard part
            IDashboardModel dashboardModel = new MyDashboardModel(TCinstance);

            dashboardVM = new DashboardViewModel(dashboardModel);
        }
        public MainWindow()
        {
            InitializeComponent();
            client = new MyTelnetClient();
            model  = new MainModel(client);
            vm     = new ViewModel(model);
            mapVm  = new MapViewModel(model);

            //
            joystickVm  = new JoystickViewModel(model);
            DataContext = vm;

            dashboardVM = new DashboardViewModel(model);

            myMapObject.DataContext    = mapVm;
            joystickObject.DataContext = joystickVm;
            dashboadObject.DataContext = dashboardVM;


            //vm.model.connect("127.0.0.1", 5402);
            //vm.model.start();
        }
Пример #5
0
        /*
         * The cconection button - responsible for connecting properly, and showing the right windows.
         */
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // connection
            MyTelnetClient         telnetCli = new MyTelnetClient();
            MyFlightSimulatorModel model     = new MyFlightSimulatorModel(telnetCli);

            this.vm = new ConnectionViewModel(model);

            // bind the error light to the vm
            this.errorLight.DataContext = new DashboardVM(model);

            // get the ip and port from the textbox
            string ip   = this.IPTextbox.Text;
            string port = this.PortTextbox.Text;

            try
            {
                // converting the port from string to int
                int intPort = int.Parse(port);

                // connecting to the server
                int isSucceed = this.vm.model.connect(ip, intPort);
                if (isSucceed == 1)
                {
                    this.vm.model.start();
                    this.vm.model.startQueue();
                    AppWindow app = new AppWindow(model, this, this.vm);
                    app.Show();
                    this.Hide();
                }
            }
            catch
            {
                this.vm.model.ConnectionError = "Blue";
            }
        }