/// <summary> /// this is the constructor of this class. /// </summary> /// <param name="joystickModel"></param> public JoystickViewModel(IJoystickModel joystickModel) { this.joystickModel = joystickModel; notSentYet = false; joystickModel.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e) { NotifyPropertyChanged(e.PropertyName); }; }
public JoystickViewModel(IJoystickModel model) { this.model = model; model.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { NotifyPropertyChanged("VM_" + e.PropertyName); if (e.PropertyName == "aileron" || e.PropertyName == "elevator") { NotifyPropertyChanged("VM_Margin_SmallCircle"); } }; }
/// <summary> /// this function execute the connectCommand. /// </summary> public void executeConnectCommand() { Connector connector = Connector.getInstance(); /* if connection established at first */ if (connectPerformed == 0) { connectPerformed = 1; // update the ip Ip = (string)Settings.Default["IP"]; ServerPort = Int32.Parse((string)Settings.Default["PortServer"]); int check = ts.startServer(ip, serverPort); if (check == 0) { // update the port ClientPort = Int32.Parse((string)Settings.Default["PortClient"]); mtc.connect(ip, clientPort); connector.setServer(ts); connector.setClient(mtc); IJoystickModel model = connector.getJoystickModel(); model.setTelnetClient(mtc); ts.readData(); } } /* if connection has been established once */ else { ts.closeServer(); Ip = (string)Settings.Default["IP"]; ServerPort = Int32.Parse((string)Settings.Default["PortServer"]); int check = ts.startServer(ip, serverPort); if (check == 0) { mtc.disconnect(); // update the port ClientPort = Int32.Parse((string)Settings.Default["PortClient"]); mtc.connect(ip, clientPort); connector.setServer(ts); connector.setClient(mtc); IJoystickModel model = connector.getJoystickModel(); model.setTelnetClient(mtc); ts.readData(); } } }
/// <summary> /// this function set the joystickModel. /// </summary> /// <param name="_joystickModel"></param> public void setJoystickModel(IJoystickModel _joystickModel) { this.joystickModel = _joystickModel; }