/// <summary>
        ///     Aplica os dados do aplicativo para: LockScreen
        /// </summary>
        /// <param name="dataUpdatedNotification">Notificação de atualização de dados.</param>
        /// <param name="cancellationToken">Token de cancelamento.</param>
        /// <returns>Task</returns>
        private async Task ApplyDataApplicationLockScreen(DataUpdated dataUpdatedNotification,
                                                          CancellationToken cancellationToken)
        {
            var request = dataUpdatedNotification.Request;
            var dataApplicationLockScreen = request.Data.Application.LockScreen;

            if (_lockScreen.IsLocked != dataApplicationLockScreen)
            {
                if (dataApplicationLockScreen)
                {
                    _lockScreen.Lock();
                }
                else
                {
                    _lockScreen.Unlock();
                }

                Log.Debug("Lock screen activated: {Mode}", dataApplicationLockScreen);

                await _messageBus.Send(
                    new UserNotificationPost(
                        new NotificationMessage(Resources.Notification_LockScreenDefined.QueryString(
                                                    dataApplicationLockScreen
                                ? Resources.Name_Term_Active
                                : Resources.Name_Term_Inactive
                                                    )), request), cancellationToken);
            }
        }
Example #2
0
        /// <summary>
        ///     Evento: ApplicationInitialized
        /// </summary>
        /// <param name="notification">Evento.</param>
        /// <param name="cancellationToken">Token de cancelamento.</param>
        /// <returns>Task</returns>
        public async Task Handle(ApplicationInitialized notification, CancellationToken cancellationToken)
        {
            const Window formType = Window.GroupWork;
            var          forms    = await _messageBus.Send <IDictionary <Window, Form> >(
                new WindowOpen(formType), cancellationToken);

            var form = forms[formType];

            ((IFormLayout)form).NotUseEscToClose   = true;
            ((IFormLayout)form).ShowButtonMinimize = true;

            var lockScreen = false;

            form.SizeChanged += (sender, args) =>
            {
                if (form.WindowState == FormWindowState.Minimized)
                {
                    foreach (var formLayout in Application
                             .OpenForms
                             .Cast <Form>()
                             .Where(a => a != form && a is IFormLayout)
                             .ToArray())
                    {
                        formLayout.Hide();
                    }

                    lockScreen = _lockScreen.IsLocked;
                    if (lockScreen)
                    {
                        _lockScreen.Unlock();
                    }
                }
                else if (lockScreen)
                {
                    _lockScreen.Lock();
                    lockScreen = false;
                }
            };
        }