Exemple #1
0
        private void HandleUSBData(USBCommand command)
        {
            Logger.LogInfo(nameof(CameraToRead), nameof(HandleUSBData), "called.");
            Logger.LogInfo(nameof(CameraToRead), nameof(HandleUSBData), nameof(command) + " is: " + command.ToString());

            try
            {
                if (command == USBCommand.ok)
                {
                    Finish();
                }
                else if (command == USBCommand.up)
                {
                    _CameraHandler.Zoom(ZoomDirection.In);
                }
                else if (command == USBCommand.down)
                {
                    _CameraHandler.Zoom(ZoomDirection.Out);
                }
            }
            catch (Java.Lang.Exception ex)
            {
                Logger.LogError(ex);
            }
        }
        private void HandleUSBData(USBCommand command)
        {
            Logger.LogInfo(nameof(MainActivity), nameof(HandleUSBData), "called.");
            Logger.LogInfo(nameof(MainActivity), nameof(HandleUSBData), nameof(command) + " is: " + command.ToString());

            try
            {
                var currentlyFocusedButton = _Buttons.Where(x => x.IsFocused).FirstOrDefault();

                if (currentlyFocusedButton == null)
                {
                    Logger.LogInfo(nameof(MainActivity), nameof(HandleUSBData), nameof(currentlyFocusedButton) + " was null.");

                    _Buttons.First().RequestFocus();
                }
                else if (command == USBCommand.ok)
                {
                    currentlyFocusedButton.CallOnClick();
                }
                else
                {
                    FindViewById <Button>(NextItemToFocus(currentlyFocusedButton, command)).RequestFocus();
                }
            }
            catch (Java.Lang.Exception ex)
            {
                Logger.LogError(ex);
            }
        }
Exemple #3
0
        private void HandleUsbData(USBCommand command)
        {
            Logger.LogInfo(nameof(ManualPhoneCall), nameof(HandleUsbData), "called.");
            Logger.LogInfo(nameof(ManualPhoneCall), nameof(HandleUsbData), nameof(command) + " is: " + command.ToString());

            try
            {
                var currentlyFocusedButton = _Buttons.Where(x => x.IsFocused).FirstOrDefault();

                if (currentlyFocusedButton == null)
                {
                    Logger.LogInfo(nameof(ManualPhoneCall), nameof(HandleUsbData), nameof(currentlyFocusedButton) + " was null.");

                    _Buttons.First(x => x.Tag.ToString() == "1").RequestFocus();
                }
                else if (command == USBCommand.ok)
                {
                    Logger.LogInfo(nameof(ManualPhoneCall), nameof(HandleUsbData), currentlyFocusedButton.Id + " called on click.");

                    currentlyFocusedButton.CallOnClick();
                }
                else
                {
                    FindViewById <Button>(NextItemToFocus(currentlyFocusedButton, command)).RequestFocus();
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
            }
        }
Exemple #4
0
        private void HandleUSBData(USBCommand command)
        {
            Logger.LogInfo(nameof(About), nameof(HandleUSBData), "called.");
            Logger.LogInfo(nameof(About), nameof(HandleUSBData), nameof(command) + " is: " + command.ToString());

            try
            {
                if (command == USBCommand.ok)
                {
                    _Back.CallOnClick();
                }
            }
            catch (Java.Lang.Exception ex)
            {
                Logger.LogError(ex);
            }
        }
Exemple #5
0
        /// <summary>
        /// Pretty complicated functions that returns the new item to select depending the given command.
        /// </summary>
        private int GetNextItemToSelect(USBCommand command)
        {
            Logger.LogInfo(nameof(ContactList), nameof(GetNextItemToSelect), "called.");

            var currentlyFocusedItem = _Contacts.CheckedItemPosition;

            _Contacts.SetItemChecked(currentlyFocusedItem, false);

            Logger.LogInfo(nameof(ContactList), nameof(GetNextItemToSelect), "currently selected item is: " + currentlyFocusedItem.ToString());

            if (currentlyFocusedItem == -1)
            {
                return(0);
            }
            else if (command == USBCommand.up)
            {
                if (currentlyFocusedItem == 0)
                {
                    return(-1);
                }
                else
                {
                    return(currentlyFocusedItem - 1);
                }
            }
            else if (command == USBCommand.down)
            {
                if (currentlyFocusedItem == (_Contacts.Count - 1))
                {
                    return(-1);
                }
                else
                {
                    return(currentlyFocusedItem + 1);
                }
            }
            else
            {
                return(currentlyFocusedItem);
            }
        }
        /// <summary>
        /// Translates the USBCommand to the correct direction.
        /// And returns the id of the next element to focus.
        /// </summary>
        protected int NextItemToFocus(View element, USBCommand command)
        {
            FocusSearchDirection direction = Constants.CommandMap[command];

            switch (direction)
            {
            case FocusSearchDirection.Up:
                return(element.NextFocusUpId);

            case FocusSearchDirection.Down:
                return(element.NextFocusDownId);

            case FocusSearchDirection.Left:
                return(element.NextFocusLeftId);

            case FocusSearchDirection.Right:
                return(element.NextFocusRightId);

            default:
                return(element.Id);
            }
        }
Exemple #7
0
        private void HandleUSBData(USBCommand command)
        {
            Logger.LogInfo(nameof(ContactList), nameof(HandleUSBData), "called.");
            Logger.LogInfo(nameof(ContactList), nameof(HandleUSBData), nameof(command) + " is: " + command.ToString());

            try
            {
                int nextItemToSelectPosition = 0;

                // If goback button is focused...
                if (_GoToPreviousActivity.IsFocused)
                {
                    Logger.LogInfo(nameof(ContactList), nameof(HandleUSBData), nameof(_GoToPreviousActivity) + " is focused.");

                    // if command is up set itemposition to last item in list...
                    if (command == USBCommand.up)
                    {
                        nextItemToSelectPosition = _Contacts.Count - 1;

                        Logger.LogInfo(nameof(ContactList), nameof(HandleUSBData), "next item to select: " + nextItemToSelectPosition.ToString());
                    }
                    // if command is down set itemposition to first item in list...
                    else if (command == USBCommand.down)
                    {
                        nextItemToSelectPosition = 0;
                    }
                    // if command is ok call goback function.
                    else if (command == USBCommand.ok)
                    {
                        _GoToPreviousActivity.ClearFocus();
                        _GoToPreviousActivity.CallOnClick();
                        return;
                    }

                    // Set new item position.
                    _GoToPreviousActivity.ClearFocus();
                    _Contacts.SetItemChecked(nextItemToSelectPosition, true);
                    _Contacts.SetSelection(nextItemToSelectPosition);
                }
                else
                {
                    // If goback button is not focused. Get the next item to select calling getnextitemtoselect.
                    nextItemToSelectPosition = GetNextItemToSelect(command);

                    Logger.LogInfo(nameof(ContactList), nameof(HandleUSBData), "next item to select is: " + nextItemToSelectPosition.ToString());

                    if (command != USBCommand.ok)
                    {
                        if (nextItemToSelectPosition == -1)
                        {
                            _GoToPreviousActivity.RequestFocus();
                            return;
                        }
                    }

                    Logger.LogInfo(nameof(ContactList), nameof(HandleUSBData), "set item checked: " + nextItemToSelectPosition.ToString());

                    _Contacts.SetItemChecked(nextItemToSelectPosition, true);
                    _Contacts.SetSelection(nextItemToSelectPosition);

                    if (command == USBCommand.ok)
                    {
                        ((TextView)_Contacts.SelectedItem).CallOnClick();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
            }
        }