예제 #1
0
 public DashboardViewModel(FlightSimulatorModel model)
 {
     flightSimulatorModel = model;
     flightSimulatorModel.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) {
         NotifyPropertyChanged("VM_" + e.PropertyName);
     };
 }
예제 #2
0
 public void ApplicationDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     if (e != null)
     {
         FlightSimulatorModel.Get().ThrowNewError(e.Exception.Message);
         e.Handled = true;
     }
 }
예제 #3
0
 public DashBaordViewModel()
 {
     this.model             = (Application.Current as App).Model;;
     model.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e)
     {
         NotifyPropertyChanged("VM_" + e.PropertyName);
     };
 }
예제 #4
0
 public GraphsAndListViewModel()
 {
     model = FlightSimulator.ModelInstance;
     model.PropertyChanged +=
         delegate(Object sender, PropertyChangedEventArgs e)
     {
         NotifyPropertyChanged("VM_" + e.PropertyName);
     };
 }
예제 #5
0
 public VMContainer()
 {
     this.fsmodel = new FlightSimulatorModel();
     this.fsmodel.connect();
     this.vm1 = new PlayControllerViewModel(this.fsmodel);
     this.vm2 = new JoystickControllerViewModel(this.fsmodel);
     this.vm3 = new StatDisplayViewModel(this.fsmodel);
     //this.vm4 = new GraphDisplayViewModel(this.fsmodel);
 }
예제 #6
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Model      = new FlightSimulatorModel(new MySimulatorConnector());
            JoystickVM = new MyJoystickViewModel();
            DashVM     = new DashBaordViewModel();
            SBVM       = new StatusBarViewModel();
            SVM        = new SettingsViewModel();
            // Create main application window
            MainWindow mainWindow = new MainWindow();

            mainWindow.Show();
        }
예제 #7
0
        private void Application_Startup(Object sender, StartupEventArgs e)
        {
            model = new FlightSimulatorModel(new MyTelnetClient());

            flightSimulatorViewModel = new FlightSimulatorViewModel(model);
            manualControlsViewModel  = new ManualControlsViewModel(model);
            dashboardViewModel       = new DashboardViewModel(model);
            mapControlViewModel      = new MapControlViewModel(model);

            Window mainWindow = new MainWindow();

            mainWindow.Show();
        }
예제 #8
0
 private static Command ChooseCommand()
 {
     if (FlightSimulatorModel.Get().PriorityQueue.Count != 0)
     {
         return(FlightSimulatorModel.Get().PriorityQueue.Dequeue());
     }
     else if (FlightSimulatorModel.Get().Queue.Count != 0)
     {
         return(FlightSimulatorModel.Get().Queue.Dequeue());
     }
     else
     {
         return(null);
     }
 }
예제 #9
0
 private void Application_Exit(object sender, ExitEventArgs e)
 {
     FlightSimulatorModel.ExitProgram();
 }
예제 #10
0
 public override string getValue()
 {
     return(FlightSimulatorModel.Get().GetDataByKey(path()));
 }
 // methods
 public MyJoystickViewModel()
 {
     this.model = (Application.Current as App).Model;
 }
예제 #12
0
 public BaseNotify()
 {
     Model = FlightSimulatorModel.Get();
 }
예제 #13
0
    //create a tcp server with the default _port and _ip
    public static void CreateAndRunClient(NetworkStream stream)
    {
        try
        {
            if (stream == null)
            {
                return;
            }

            Byte[] data = null;
            // Get a client stream for reading and writing.
            //  Stream stream = client.GetStream();
            if (!_runClient)
            {
                FlightSimulatorModel.Get().ThrowNewError("Oops! you got runclient problem");
                return;
            }
            while (_runClient)
            {
                // Translate the passed message into ASCII and store it as a Byte array.
                Command c = ChooseCommand();
                if (c == null)
                {
                    continue;
                }
                data = System.Text.Encoding.ASCII.GetBytes(c.execute());

                // Send the message to the connected TcpServer.
                stream.Write(data, 0, data.Length);
                data = new Byte[256];

                // String to store the response ASCII representation.
                String responseData = String.Empty;

                // Read the first batch of the TcpServer response bytes.
                Thread.Sleep(30);
                stream.ReadTimeout = 15000;
                Int32 bytes = stream.Read(data, 0, data.Length);
                responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
                responseData = responseData.Substring(0, responseData.Length - 1);
                FlightSimulatorModel.Get().UpdateValueMap(c.path(), responseData);
            }
            // Close everything
            stream.Close();
            //MyTcpClient.client.Close();
        }
        catch (IOException e)
        {
            if (stream != null)
            {
                stream.Close();
            }
            //MyTcpClient.client.Close();
            ThreadAlreadyRunning = false;
            FlightSimulatorModel.Get().ThrowNewError("Connection to the server was lost\r\nPlease insert IP and Port in the connection tab\r\n" + e.Message);
            _ip   = String.Empty;
            _port = 0;
        }
        finally
        {
            _runClient = true;
            M.Set();
        }
    }
예제 #14
0
 public MainWindow()
 {
     InitializeComponent();
     new Thread(FlightSimulatorModel.Get().InitRunBackground).Start();
 }