Пример #1
0
        /// <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();
        }
Пример #2
0
 public MyControlView()
 {
     InitializeComponent();
     vm = new JoystickViewModel();
     this.DataContext = vm;
     myJoystick.DataContext = vm;
 }
Пример #3
0
 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;
        }
Пример #5
0
        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;
        }
Пример #6
0
        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();
        }
Пример #7
0
        /// <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;
        }
Пример #8
0
        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;
        }
Пример #9
0
 /// <summary>
 /// the constractur of the  Joystick window.
 /// </summary>
 public Joystick()
 {
     InitializeComponent();
     vm          = new JoystickViewModel(new JoystickModel());
     DataContext = vm;
 }
Пример #10
0
 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;
 }
Пример #13
0
 // 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();
 }
Пример #15
0
 public WasdFinalSolver(JoystickViewModel joystick)
 {
     joystick.OnKeyPress += Joystick_OnKeyPress;
 }