/// <summary> /// this function send the commands to the simulator in other thread. /// </summary> /// <param name="textCommandsStr"></param> public void executeCommandsInThread(string textCommandsStr, JoystickViewModel joystickViewModel) { // set the background of the TextBox to be PaleVioletRed joystickViewModel.NotSentYet = true; Thread thread = new Thread(new ThreadStart(() => { // get the commands in array string[] commands = textCommandsStr.Split('\n'); int index = 0; int len = commands.Length; foreach (var command in commands) { this.telnetClient.write(command); // if this is not the last command to be send to the simulator if (index < len - 1) { // wait 2 seconds before sending the next command to the simulator Thread.Sleep(2000); } index++; } // set the background of the TextBox back to white joystickViewModel.NotSentYet = false; })); thread.Start(); }
public MyControlView() { InitializeComponent(); vm = new JoystickViewModel(); this.DataContext = vm; myJoystick.DataContext = vm; }
public Joystick() { InitializeComponent(); vm = new JoystickViewModel(new JoystickModel()); Knob.MouseLeftButtonDown += Knob_MouseLeftButtonDown; Knob.MouseLeftButtonUp += Knob_MouseLeftButtonUp; Knob.MouseMove += Knob_MouseMove; DataContext = this; centerKnob = Knob.Resources["CenterKnob"] as Storyboard; }
public Joystick() { InitializeComponent(); Knob.MouseLeftButtonDown += Knob_MouseLeftButtonDown; Knob.MouseLeftButtonUp += Knob_MouseLeftButtonUp; Knob.MouseMove += Knob_MouseMove; centerKnob = Knob.Resources["CenterKnob"] as Storyboard; // Add the ViewModel as the Data context vm = new JoystickViewModel(); this.DataContext = vm; }
public Joystick() { InitializeComponent(); acounter = 0; ecounter = 0; vm = new JoystickViewModel(); Knob.MouseLeftButtonDown += Knob_MouseLeftButtonDown; Knob.MouseLeftButtonUp += Knob_MouseLeftButtonUp; Knob.MouseMove += Knob_MouseMove; centerKnob = Knob.Resources["CenterKnob"] as Storyboard; }
public Joystick() { InitializeComponent(); //work also without this lines: Knob.MouseLeftButtonDown += Knob_MouseLeftButtonDown; Knob.MouseLeftButtonUp += Knob_MouseLeftButtonUp; Knob.MouseMove += Knob_MouseMove; centerKnob = Knob.Resources["CenterKnob"] as Storyboard; vm = new JoystickViewModel(); this.DataContext = vm; // UpdateKnobPosition(); }
/// <summary> /// this is the constructor of this class. /// </summary> public Joystick() { InitializeComponent(); Knob.MouseLeftButtonDown += Knob_MouseLeftButtonDown; Knob.MouseLeftButtonUp += Knob_MouseLeftButtonUp; Knob.MouseMove += Knob_MouseMove; centerKnob = Knob.Resources["CenterKnob"] as Storyboard; string ip = (string)Settings.Default["IP"]; int portClient = Int32.Parse((string)Settings.Default["PortClient"]); // create the telnetClient with defult ip and port. MyTelnetClient mtc = new MyTelnetClient(); //mtc.connect(ip, portClient); // the model for this viewModel MyJoystickModel joystickModel = new MyJoystickModel(mtc); Connector connector = Connector.getInstance(); // give this joystickModel to the connector connector.setJoystickModel(joystickModel); // give this telnetClient to the connector connector.setClient(mtc); joystickViewModel = new JoystickViewModel(joystickModel); this.DataContext = joystickViewModel; }
public View(string port, string ip) { int tempPort; // Connect settings - client and server. telnetClient = new MyTelnetClient(); Application.Current.Properties["model"] = new MySimulatorModel(telnetClient); mySimulator = (MySimulatorModel)Application.Current.Properties["model"]; // Define all controls in the view window. joystickViewModel = new JoystickViewModel(mySimulator); dashboardViewModel = new DashboardViewModel(mySimulator); errorViewModel = new ErrorViewModel(mySimulator); mapViewModel = new MapViewModel(mySimulator); // Checks the reseve port. try { tempPort = int.Parse(port); } catch { Console.WriteLine("Error - worng formt of port"); tempPort = 0; } if (mySimulator.connect(ip, tempPort) == 0) { mySimulator.start(); } InitializeComponent(); Joystick.DataContext = joystickViewModel; dash.DataContext = dashboardViewModel; error.DataContext = errorViewModel; map.DataContext = mapViewModel; disconnect.DataContext = mapViewModel; }
/// <summary> /// the constractur of the Joystick window. /// </summary> public Joystick() { InitializeComponent(); vm = new JoystickViewModel(new JoystickModel()); DataContext = vm; }
public joystickUserControl() { InitializeComponent(); joystickVM = new JoystickViewModel(FIAModel.Model); DataContext = joystickVM; }
public JoystickPage(IConfig c, IDataMeasure d, ICancelTaskService cts) { viewModel = new JoystickViewModel(c, d, cts); DataContext = viewModel; InitializeComponent(); }
public JoystickController() { InitializeComponent(); joystickVM = new JoystickViewModel(new MySimulatorModel()); DataContext = joystickVM; }
// Intialize the different local components. public void Init() { joystickVM = (Application.Current as App).MainViewModel.joystickViewModel; // Make the DataContext the JoystickVM. DataContext = joystickVM; }
public JoystickWindow() { InitializeComponent(); DataContext = new JoystickViewModel(); }
public WasdFinalSolver(JoystickViewModel joystick) { joystick.OnKeyPress += Joystick_OnKeyPress; }