Example #1
0
 private void joystick_button_Click(object sender, RoutedEventArgs e)
 {
     if (joystickView == null)
     {
         joystickView = new JoystickView(clientModel);
     }
     joystickView.Show();
     joystick_button.Visibility       = Visibility.Hidden;
     close_joystick_button.Visibility = Visibility.Visible;
 }
Example #2
0
        private void initializeControls()
        {
            // Load any saved settings
            RobotParameters.ReadParametersFromDisk(this);

            // Text
            _potisionTextView = (TextView)FindViewById(Resource.Id.PositionTextView);

            // Button Controls
            Button initializeButton = (Button)FindViewById(Resource.Id.InitializationButton);
            Button lightButton      = (Button)FindViewById(Resource.Id.LightButton);

            initializeButton.Click += InitializeButton_Click;
            lightButton.Click      += LightButton_Click;

            // Joystick
            JoystickView joystick = (JoystickView)FindViewById(Resource.Id.Joystick);

            joystick.PositionChanged += Joystick_PositionChanged;
            joystick.PositionStop    += Joystick_PositionStop;

            // Head and Arm buttons
            _headLeftButton      = (Button)FindViewById(Resource.Id.HeadLeftButton);
            _headRightButton     = (Button)FindViewById(Resource.Id.HeadRightButton);
            _shoulderOpenButton  = (Button)FindViewById(Resource.Id.ShoulderOpenButton);
            _shoulderCloseButton = (Button)FindViewById(Resource.Id.ShoulderCloseButton);
            _wristOpenButton     = (Button)FindViewById(Resource.Id.WristOpenButton);
            _wristCloseButton    = (Button)FindViewById(Resource.Id.WristCloseButton);
            _gripperOpenButton   = (Button)FindViewById(Resource.Id.GripperOpenButton);
            _gripperCloseButton  = (Button)FindViewById(Resource.Id.GripperCloseButton);

            _headLeftButton.Touch      += Button_Touch;
            _headRightButton.Touch     += Button_Touch;
            _shoulderOpenButton.Touch  += Button_Touch;
            _shoulderCloseButton.Touch += Button_Touch;
            _wristOpenButton.Touch     += Button_Touch;
            _wristCloseButton.Touch    += Button_Touch;
            _gripperOpenButton.Touch   += Button_Touch;
            _gripperCloseButton.Touch  += Button_Touch;

            _timer           = new Timer();
            _timer.Interval  = 1; // interval in milliseconds
            _timer.Enabled   = false;
            _timer.Elapsed  += TimerEvent;
            _timer.AutoReset = true;
        }
Example #3
0
        private static void SetupJoystickInfo(Window win)
        {
            LeftJoystickView = new JoystickView("Left Joystick")
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Percent(50),
                Height = 4
            };

            RightJoystickView = new JoystickView("Right Joystick")
            {
                X      = Pos.Right(LeftJoystickView),
                Y      = Pos.Top(LeftJoystickView),
                Width  = Dim.Fill(),
                Height = 4
            };

            win.Add(LeftJoystickView, RightJoystickView);
        }
Example #4
0
		public SetupPage()
		{
			InitializeComponent();

			Loaded += new RoutedEventHandler(async (object v, RoutedEventArgs e) =>
			{
				var vmm = DataContext as BaseViewModel;
				await vmm.Loaded();
			});

			var vm = DataContext as SetupWindowViewModel;

			if (vm.EditMachine == null)
			{
				vm.EditMachine = new Action<int>((mID) =>
				{
					var dlg = new MachineView();
					var vmdlg = dlg.DataContext as MachineViewModel;
					vmdlg.LoadMachine(mID);
					dlg.ShowDialog();
				});
			}

			if (vm.EditJoystick == null)
			{
				vm.EditJoystick = new Action(() =>
				{
					var dlg = new JoystickView();
					var vmdlg = dlg.DataContext as JoystickView;
					dlg.ShowDialog();
				});
			}

			if (vm.MessageBox == null)
			{
				vm.MessageBox = new Func<string, string, MessageBoxButton, MessageBoxImage, MessageBoxResult>((messageBoxText, caption, button, icon) =>
				{
					return MessageBox.Show(messageBoxText, caption, button, icon);
				});
			}
		}
Example #5
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.FragmentJoystick, container, false);

            // We have to capture every touch event otherwise the controls "under" this fragment receive it
            view.Touch += (sender, args) => { args.Handled = true; };


            // Initialize the controls
            _imageViewCameraStream = view.FindViewById <ImageView>(Resource.Id.joystickCameraView);

            _joystickViewLeft  = view.FindViewById <JoystickView>(Resource.Id.joystickLeft);
            _joystickViewRight = view.FindViewById <JoystickView>(Resource.Id.joystickRight);

            _joystickViewLeft.ValuesChanged  += delegate { JoystickViewOnValuesChanged(LeftJoystickIndex); };
            _joystickViewRight.ValuesChanged += delegate { JoystickViewOnValuesChanged(RightJoystickIndex); };

            _imageViewContextualMenuLeft =
                view.FindViewById <ImageView>(Resource.Id.imageViewContextualMenuJoystickLeft);

            _imageViewContextualMenuRight =
                view.FindViewById <ImageView>(Resource.Id.imageViewContextualMenuJoystickRight);


            _imageViewContextualMenuLeft.Click += delegate
            {
                ShowJoystickConfigurationOptionsMenu(_imageViewContextualMenuLeft, LeftJoystickIndex);
            };
            _imageViewContextualMenuRight.Click += delegate
            {
                ShowJoystickConfigurationOptionsMenu(_imageViewContextualMenuRight, RightJoystickIndex);
            };



            return(view);
        }
Example #6
0
        private void JoystickViewOnValuesChanged(int joystickId)
        {
            // When a joystick has changed we calculate the motor values depending on the actual configuration
            var          configuration = GetRelatedJoystickConfiguration(joystickId);
            JoystickView joystick      = GetRelatedJoystickView(joystickId);

            float motor1 = 0;
            float motor2 = 0;

            switch (configuration.JoystickMode)
            {
            case JoystickConfiguration.JoystickModes.Single:
                motor1 = joystick.ThumbX;
                motor2 = joystick.ThumbY;
                break;

            case JoystickConfiguration.JoystickModes.Syncron:
                CalculateSyncronValues(joystick.ThumbAngle, joystick.ThumbDistance, out motor1, out motor2);
                break;
            }

            SetMotor(configuration.MotorIndexes[0], motor1);
            SetMotor(configuration.MotorIndexes[1], motor2);
        }
 // Use this for initialization
 void Start()
 {
     joystick            = GetComponent <JoystickView>();
     fireButtonTransform = fireButton.transform;
 }