Example #1
0
 /// <summary>
 /// The constructor.
 /// Just save the input model as this's model.
 /// Do not add the properties' paths, since they are not receivable.
 /// Add the model a delegate function that handles disconnection.
 /// </summary>
 /// <param name="model"> The VM's model. </param>
 public ControllersPanelVM(IFlightGearCommunicator model)
 {
     this.model = model;
     this.model.DisconnectionOccurred +=
         delegate()
     {
         DisconnectionOccurred?.Invoke();
     };
 }
Example #2
0
 /// <summary>
 /// The constructor. set the vm's model to the input model, add the error event,
 /// And set the current error to empty.
 /// </summary>
 /// <param name="model"> the VM's model </param>
 public ErrorsPanelVM(IFlightGearCommunicator model, double errorMessageShowingTimeSeconds)
 {
     this.model           = model;
     model.ErrorOccurred +=
         delegate(object sender, string error)
     {
         this.HandleError(error);
     };
     ErrorMessage = "";
     this.errorMessageShowingTimeSeconds = errorMessageShowingTimeSeconds;
 }
Example #3
0
        /// <summary>
        /// The constructor.
        /// Set the isInWaitingRoom boolean dictionary.
        /// </summary>
        /// <param name="model"> The VM's model. </param>
        public WaitingRoomControllersPanelVM(IFlightGearCommunicator model) : base(model)
        {
            isInWaitingRoom = new ConcurrentDictionary <string, bool>();

            /* Add all full paths of the properties to the dictionary with a false boolean,
             * Because they are not in waiting room yet. */
            foreach (KeyValuePair <string, string> entry in properties)
            {
                isInWaitingRoom.Add(entry.Value, false);
                mostRecentValues.Add(entry.Value, 0);
            }
        }
Example #4
0
        private void Application_Startup(object sender, StartupEventArgs args)
        {
            ITelnetClient telnetClient = new TelnetClient();

            model = new Model(telnetClient);
            model.Connect(ConfigurationManager.AppSettings.Get("DEFAULT_IP"), int.Parse(ConfigurationManager.AppSettings.Get("DEFAULT_PORT")));
            model.Start();

            dashboardViewModel = new DashboardViewModel(model);
            mapViewModel       = new MapViewModel(model);

            connectionVM = new ConnectionPanelVM(model);
            errorsVM     = new ErrorsPanelVM(model);
            controellsVM = new ControllersPanelVM(model);
        }
Example #5
0
        /// <summary>
        /// The constructor.
        /// </summary>
        /// <param name="model"> The model, used for communicating with the server. </param>
        public MapViewModel(IFlightGearCommunicator model)
        {
            this.model = model;

            foreach (string var in properties.Keys)
            {
                model.AddReceiveableVar(var, false);
            }

            // Add the viewmodel to the model's listeners.
            this.model.PropertyChanged +=
                delegate(Object sender, PropertyChangedEventArgs e)
            {
                string name = e.PropertyName;

                // If latitude changed, update latitude.
                if (name == latitudeName)
                {
                    Latitude       = this.model.GetVarValue(latitudeName);
                    PositionUpdate = 0x1;
                }

                // If longitude changed, update longitude.
                else if (name == longitudeName)
                {
                    Longitude      = this.model.GetVarValue(longitudeName);
                    PositionUpdate = 0x2;
                }
            };



            // Add self as a listener to the position change.
            this.PropertyChanged +=
                delegate(Object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == "Position")
                {
                    // Calculate the angle between the last position and the new one.
                    this.Rotation = CalculateRotation(lastLocation, Position);

                    // Update last location.
                    this.lastLocation = Position;
                }
            };
        }
Example #6
0
        /// <summary>
        /// THe constructor.
        /// </summary>
        /// <param name="model"> The model, used for communicating with the server. </param>
        public DashboardViewModel(IFlightGearCommunicator model)
        {
            this.model = model;

            // Add the viewmodel to the model's listeners.
            this.model.PropertyChanged +=
                delegate(Object sender, PropertyChangedEventArgs e)
            {
                string name = e.PropertyName;
                if (properties.ContainsKey(name))
                {
                    NotifyPropertyChanged(properties[name]);
                }
            };

            foreach (string name in properties.Keys)
            {
                this.model.AddReceiveableVar(name);
            }
        }
Example #7
0
 /// <summary>
 /// Default constructor with 10 seconds error displaying time.
 /// </summary>
 /// <param name="model"> The VM's model. </param>
 public ErrorsPanelVM(IFlightGearCommunicator model) : this(model, 10)
 {
 }
Example #8
0
 /// <summary>
 /// The constructor. get the default ip and port values from the App.config document.
 /// </summary>
 /// <param name="model"> The VM's model. </param>
 public ConnectionPanelVM(IFlightGearCommunicator model)
 {
     this.connection_IP   = ConfigurationManager.AppSettings.Get("DEFAULT_IP");
     this.connection_Port = ConfigurationManager.AppSettings.Get("DEFAULT_PORT");
     this.model           = model;
 }