예제 #1
0
        public async void Execute(FrameworkElement source)
        {
            await Task.Run(() =>
            {
                try
                {
                    Status.SetMessage(this, "Executing");
                    IItem result = null;
                    if (ActionWithArguments != null)
                    {
                        result = ActionWithArguments.ActOn(Result.Item, Arguments);
                    }
                    else
                    {
                        result = SelectedAction.ActOn(Result.Item);
                    }
                    _autoCompleteText.LearnInputForCommandResult(Input, Result);
                    _getActionsForItem.LearnActionForCommandResult(Input, SelectedAction, Result);

                    result = result ?? NoReturnValue.Object;
                    if (result != NoReturnValue.Object)
                    {
                        _temporaryResults = result.ToListWithCurrentSelection();
                        UpdateCommandOptions(new ListWithCurrentSelection <AutoCompletionResult.CommandResult>());
                        Input = CommandOptions.First().Item.Text;
                    }
                    else
                    {
                        Input     = string.Empty;
                        Arguments = string.Empty;
                        // HACK
                        _temporaryResults = new ListWithCurrentSelection <AutoCompletionResult.CommandResult>();
                        UpdateCommandOptions(_temporaryResults);
                        Caliburn.Micro.Execute.OnUIThread(() => ((MainWindowView)Window.GetWindow(source)).HideWindow());
                    }

                    Status.SetMessage(this, "Done");
                }
                catch (Exception e)
                {
                    Status.SetMessage(this, "Error :" + e.Message);
                    Description = e.Message;
                    _log.Error(e);
                }
            });
        }