Beispiel #1
0
 public MainViewModel(IFlightModel flightModel)
 {
     this.flightModel = flightModel;
     DashBoardVM      = new DashboardViewModel(flightModel);
     MapVM            = new MapViewModel(flightModel);
     ControllersVM    = new ControllersViewModel(flightModel);
 }
        public ModelControl(string filename, bool create)
        {
            reflection = new Reflection();

            heightmap           = new Heightmap(1000);
            heightmap.MinHeight = -5f;
            heightmap.MaxHeight = 5f;

            useAileronForRudder = Convert.ToBoolean(Bonsai.Utils.Settings.GetValue("UseAileronChannel"));

            AircraftParameters parameters = new AircraftParameters();

            if (create)
            {
                parameters.CreateDefault(filename);
            }
            else
            {
                parameters.File = filename;
            }
            if (parameters.Version == 2)
            {
                iFlightModel = new FlightModelWind2();
            }
            else
            {
                iFlightModel = new FlightModelWind();
            }
            iFlightModel.AircraftParameters = parameters;
            iFlightModel.Heightmap          = heightmap;
            iFlightModel.Paused             = true;
            iFlightModel.Initialize();
            airplaneModel          = new AirplaneModel(iFlightModel);
            airplaneModel.Position = new Vector3(0, 0, 0);
        }
Beispiel #3
0
 public MainWindow(IFlightModel ifm)
 {
     InitializeComponent();
     this.myFilght      = ifm;
     DataContext        = (Application.Current as App).MainViewModel;
     errLab.DataContext = (Application.Current as App).MainViewModel.ErrorVM;
 }
 public SteeringViewModel(IFlightModel m) : base(m)
 {
     this.myModel             = m;
     myModel.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e)
     {
         NotifyPropertyChanged("VM" + e.PropertyName);
     };
 }
Beispiel #5
0
 public VM_Attributes(IFlightModel model)
 {
     _model = model;
     _model.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e)
     {
         NotifyPropertyChanged("VM_" + e.PropertyName);
     };
 }
Beispiel #6
0
 public FlightViewModel(IFlightModel model)
 {
     this.model             = model;
     model.PropertyChanged +=
         delegate(Object sender, PropertyChangedEventArgs e) {
         NotifyPropertyChanged("VM_" + e.PropertyName);
     };
 }
 public ConnectionAndErrorVIewModel(IFlightModel model)
 {
     this.model             = model;
     model.PropertyChanged +=
         delegate(object sender, PropertyChangedEventArgs e)
     {
         NotifyPropertyChanged("VM_" + e.PropertyName);
     };
 }
Beispiel #8
0
 public MapViewModel(IFlightModel ifm) : base(ifm)
 {
     this.mainVM              = (Application.Current as App).MainViewModel;
     this.myModel             = ifm;
     myModel.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e)
     {
         NotifyPropertyChanged("VM" + e.PropertyName);
         NotifyPropertyChanged("VMlocation");
     };
 }
        public MainWindowViewModel()
        {
            this.model = FlightGearModel.Instance();

            model.PropertyChanged +=
                delegate(Object sender, PropertyChangedEventArgs e)
            {
                NotifyPropertyChanged("VM_" + e.PropertyName);
            };
        }
Beispiel #10
0
        IFlightModel model; // Contain instance of model FG.

        public FlightBoardViewModel()
        {
            this.model = FlightGearModel.Instance();

            // Register as listener to notify property changes.
            this.model.PropertyChanged +=
                delegate(Object sender, PropertyChangedEventArgs e)
            {
                NotifyPropertyChanged("VM_" + e.PropertyName);
            };
        }
Beispiel #11
0
        //private FlightViewModel flightViewModel;

        public MainWindow()
        {
            InitializeComponent();
            flightModel = new IFlightModel(new TcpTimeClient(10000));
            FlightViewModel flightViewModel = new FlightViewModel(flightModel);
            MapViewModel    mapViewModel    = new MapViewModel(flightModel);

            MySetteing.SetDataContext(flightViewModel);
            MyDashBoard.SetDataContext(flightViewModel);
            MyPrideBoard.SetDataContext(flightModel);
            MyMap.SetDataContext(mapViewModel);
            MyLocation.SetDataContext(mapViewModel);
            //MyExitButton.SetDataContext(flightViewModel);
        }
Beispiel #12
0
        /// <summary>
        /// Clean up.
        /// </summary>
        public void Dispose()
        {
            Bonsai.Utils.Settings.SettingsChanged -= new Bonsai.Utils.Settings.SettingsEventHandler(Settings_SettingsChanged);

            if (iFlightModel != null)
            {
                iFlightModel.Dispose();
                iFlightModel = null;
            }
            if (modelApi != null)
            {
                modelApi.Dispose();
                modelApi = null;
            }
            if (smoke != null)
            {
                smoke.Dispose();
                smoke = null;
            }
            if (airplane != null)
            {
                airplane.Dispose();
                airplane = null;
            }
            if (variometer != null)
            {
                variometer.Dispose();
                variometer = null;
            }
            if (towLine != null)
            {
                towLine.Dispose();
                towLine = null;
            }
            if (windVector != null)
            {
                windVector.Dispose();
                windVector = null;
            }
            if (ripples != null)
            {
                ripples.Dispose();
                ripples = null;
            }
            if (reflection != null)
            {
                reflection.Dispose();
                reflection = null;
            }
        }
        /***
         * the function initDisplay initiiliaze the DisplayWindow.
         ***/
        private void initDisplay(Model_Flight_Client client)
        {
            model = new MyFlightModel(client);
            InitializeComponent(); //call it from mainWindow.
                                   //int port = 5400;
                                   //string ip = "127.0.0.1";

            vm       = new FlightViewModel(model);
            graph_vm = new GraphViewModel(model);
            this.controls.DataContext = vm;
            this.indices.DataContext  = vm;
            this.joystick.DataContext = vm;
            this.graph.DataContext    = graph_vm;
        }
 public VM_AnomalyReport(IFlightModel model)
 {
     _model = model;
     _model.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e)
     {
         if (e.PropertyName.Equals("AnomalyReportList"))
         {
             NotifyPropertyChanged("VM_" + e.PropertyName);
         }
         else
         {
             NotifyPropertyChanged("VM_" + e.PropertyName);
         }
     };
 }
 public ErrorViewModel(IFlightModel m) : base(m)
 {
     this.myModel             = m;
     myModel.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e)
     {
         //if we got an error from the model as the property that changed we active the label in the view
         if (e.PropertyName == "error")
         {
             errStr  = myModel.Error;
             VMerror = Visibility.Visible;
         }
         else
         {
             VMerror = Visibility.Hidden;
         }
     };
 }
Beispiel #16
0
        /// <summary>
        /// Clean up.
        /// </summary>
        public void Dispose()
        {
            if (airplaneModel != null)
            {
                airplaneModel.Dispose();
                airplaneModel = null;
            }

            if (iFlightModel != null)
            {
                iFlightModel.Dispose();
                iFlightModel = null;
            }

            if (reflection != null)
            {
                reflection.Dispose();
                reflection = null;
            }
        }
Beispiel #17
0
 public ViewModel(IFlightModel ifm)
 {
     this.myModel = ifm;
 }
Beispiel #18
0
        public void LoadModel(string fileName)
        {
            // First clean up
            if (iFlightModel != null)
            {
                iFlightModel.Dispose();
                iFlightModel = null;
            }
            if (modelApi != null)
            {
                modelApi.Dispose();
                modelApi = null;
            }
            if (airplane != null)
            {
                airplane.Dispose();
                airplane = null;
            }
            if (variometer != null)
            {
                variometer.Dispose();
                variometer = null;
            }

            // Now load the actual model
            //model = new FlightModelWind();
            AircraftParameters parameters = new RCSim.DataClasses.AircraftParameters();

            parameters.File = fileName;

            if (!string.IsNullOrEmpty(Bonsai.Utils.Settings.GetValue("ApiFlightModel")))
            {
                try
                {
                    string   assemblyInfo  = Bonsai.Utils.Settings.GetValue("ApiFlightModel");
                    string[] assemblyParts = assemblyInfo.Split(',', ';');
                    Assembly assembly      = Assembly.LoadFrom(assemblyParts[0]);
                    RCDeskPilot.API.FlightModelSimple flightModelSimple =
                        assembly.CreateInstance(assemblyParts[1]) as RCDeskPilot.API.FlightModelSimple;
                    modelApi          = new FlightModelApi();
                    modelApi.ApiModel = flightModelSimple;
                    iFlightModel      = modelApi;
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(
                        string.Format("Failed to load the flightmodel plugin : {0}", ex.ToString()));
                }
            }
            else
            {
                if (parameters.Version == 2)
                {
                    iFlightModel = new FlightModelWind2();
                }
                else
                {
                    iFlightModel = new FlightModelWind();
                }
            }

            iFlightModel.AircraftParameters = parameters;
            iFlightModel.Initialize();
            iFlightModel.Reset();
            iFlightModel.Wind      = new Vector3(0, 0, 0);
            iFlightModel.Heightmap = Heightmap;
            iFlightModel.Water     = Program.Instance.Scenery.Water;
            airplane = new AirplaneModel(iFlightModel);

            CurrentModel = fileName;

            if (smoke != null)
            {
                smoke.Dispose();
                smoke = null;
            }
            smoke = new Smoke(owner, iFlightModel);

            UpdateVariometer();

            this.owner.UpdateCameras();
            this.Reset();
        }
Beispiel #19
0
 /*
  * Constructor - initialize GraphViewModel by given model.
  */
 public GraphViewModel(IFlightModel model) : base(model)
 {
 }
 public void SetDataContext(IFlightModel flightModel)
 {
     DataContext = new ControlViewModel(flightModel);
 }
 public void SetFlight(IFlightModel ifm)
 {
     this.myFlight = ifm;
 }
 /// <summary>
 /// controler constctor. create controler with flight manger.
 /// </summary>
 /// <param name="manger"></param>
 public FlightsController(IFlightModel flightModel)
 {
     this.manger = flightModel;
 }