Esempio n. 1
0
        public void ApplicationFeedbackHandler(IFeedbackToApplication feedBack)
        {
            if (!CommandController.IsMainThread())
            {
                throw new ThreadStateException("Feedback handler must only be called on the UI thread");
            }

            string threadInfo;

            switch (feedBack.Type)
            {
            case FeedbackType.ImportantMessage:
            case FeedbackType.MessageOfNoImportance:
            case FeedbackType.CommandExecutionCompleted: {
                threadInfo   = CommandController.IsMainThread() ? "MAIN" : Thread.CurrentThread.ManagedThreadId.ToString();
                Output.Text += "\r\n" + threadInfo + ": " + (feedBack.Type == FeedbackType.CommandExecutionCompleted ? "Done" : feedBack.Message);
            } break;

            case FeedbackType.EnableCommand:
            case FeedbackType.DisableCommand: {
                throw new ArgumentException("Enable/disable command should be handled by the application command controller");
            }

            case FeedbackType.MessagesOfNoImportanceWereIgnored: {
                threadInfo   = CommandController.IsMainThread() ? "MAIN" : Thread.CurrentThread.ManagedThreadId.ToString();
                Output.Text += "\r\n" + threadInfo + ": ...";
            } break;

            case FeedbackType.CommandIsDisabled: {
                threadInfo   = CommandController.IsMainThread() ? "MAIN" : Thread.CurrentThread.ManagedThreadId.ToString();
                Output.Text += "\r\n" + threadInfo + ": COMMAND IS DISABLED";
            }
            break;

            case FeedbackType.CommandsEnabledOrDisabled: {
                DoSomething.IsEnabled  = CommandController.Enabled(typeof(DoSomethingCommand));
                PrimeNumbers.IsEnabled = CommandController.Enabled(typeof(PrimeNumbersCommand));
            }
            break;

            default: {
                throw new NotImplementedException();
            }
            }
        }
Esempio n. 2
0
        // ReSharper disable once UnusedParameter.Local
        private void CommandExecutionCompletedHandler(IFeedbackToApplication feedback)
        {
            if (!Controller.IsMainThread())
            {
                return;
            }

            Cursor = Cursors.Arrow;
        }
    private async Task CommandExecutionCompletedHandlerAsync(IFeedbackToApplication feedback)
    {
        if (!Controller.IsMainThread())
        {
            return;
        }

        Cursor = Cursors.Arrow;
        if (feedback.CommandType == typeof(SearchCommand))
        {
            await Controller.EnableCommandAsync(typeof(SelectFolderCommand));
        }
        else if (feedback.CommandType == typeof(SelectFolderCommand))
        {
            await Controller.EnableCommandAsync(typeof(SearchCommand));
        }
    }