async Task HandleButtonActionAsync(string senderDeviceId, UserAction action, ButtonPressCode code)
        {
            try
            {
                await HandleActionAsync(senderDeviceId, action);
            }
            catch (HideezWindowSelectedException)
            {
                var localizedAction = $"{TranslationSource.Instance["UserAction.PressButton"]} {TranslationSource.Instance[$"Enum.ButtonPressCode.{code.ToString()}"]}";
                var message         = TranslationSource.Instance[$"UserAction.HideezWindowSelected.{action.ToString()}"];
                message = string.Format(message, Environment.NewLine, localizedAction);
                var msgOptions = new NotificationOptions {
                    CloseTimeout = NotificationOptions.LongTimeout
                };
                await _metaMessenger.Publish(new ShowInfoNotificationMessage(message, options : msgOptions, notificationId : _activeDevice.Device?.Mac));
            }
            catch (ActionNotSupportedException)
            {
                var localizedAction = TranslationSource.Instance[$"Enum.UserAction.{action.ToString()}"].ToLowerInvariant();
                await _metaMessenger.Publish(new ShowInfoNotificationMessage(string.Format(TranslationSource.Instance["UserAction.NotSupportedPart"], localizedAction, Environment.NewLine), notificationId : _activeDevice.Device?.Mac));
            }
            catch (Exception ex)
            {
                await _metaMessenger.Publish(new ShowErrorNotificationMessage(ex.Message, notificationId : _activeDevice.Device?.Mac));

                WriteLine(ex, LogErrorSeverity.Error);
            }
        }
Beispiel #2
0
        void RemoteDevice_ButtonPressed(object sender, ButtonPressCode e)
        {
            _log.WriteLine($"({SerialNo}) Vault button pressed, code: {e}");

            Task.Run(() =>
            {
                _metaMessenger.Publish(new DeviceButtonPressedMessage(Id, e));
            });
        }
 public DeviceButtonPressedMessage(string deviceId, ButtonPressCode button)
 {
     DeviceId = deviceId;
     Button   = button;
 }
Beispiel #4
0
 public ButtonPressedMessage(string deviceId, UserAction action, ButtonPressCode code)
 {
     DeviceId = deviceId;
     Action   = action;
     Code     = code;
 }