示例#1
0
 private ICommand GetCommandTest()
 {
     return(CommandBuilderProvider.Get("CommandTest")
            .Execute(async ct => await _asyncMessageDialog.Show(ct, "Hello", "From settings flyout"))
            .Error((token, exception) => Task.FromResult(true))
            .ToCommand());
 }
示例#2
0
        public void Visit(IAsyncMvvmCommand command)
        {
            var errorTitleKey   = string.Concat(command.Name, TitleResourceKeySuffix);
            var errorContentKey = string.Concat(command.Name, ContentResourceKeySuffix);
            var errorTitle      = _resources.Get(errorTitleKey);
            var errorContent    = _resources.Get(errorContentKey);
            var isDefault       = command.SetDefaultError(async(ct, ex) =>
            {
                await _messageDialog.Show(ct, errorTitle, errorContent);
            });

            if (isDefault && (string.IsNullOrEmpty(errorTitle) || string.IsNullOrEmpty(errorContent)))
            {
                var sb = new StringBuilder();
                sb.AppendLine(string.Concat("Resources missing for command ", command.Name));
                sb.AppendLine("Missing resources keys :");
                if (string.IsNullOrEmpty(errorTitle))
                {
                    sb.AppendLine(errorTitleKey);
                }
                if (string.IsNullOrEmpty(errorContent))
                {
                    sb.AppendLine(errorContentKey);
                }
                throw new InvalidOperationException(sb.ToString());
            }
        }
示例#3
0
 private ICommand GetSettingCommand1()
 {
     return(CommandBuilderProvider.Get("SettingCommand1")
            .Execute(async ct => await _messageDialog.Show(ct, "Hello", "From the settings charm bar"))
            .Error((token, exception) => Task.FromResult(true))
            .ToCommand());
 }
示例#4
0
 public ICommand GetResult1SuggestionCtrlCommand()
 {
     return(this.CommandBuilder("Result1SuggestionCtrlCommand")
            .Execute <Guid>(async(id, ct) => await _messageDialog.Show(ct, "Result1SuggestionCtrlCommand", id.ToString()))
            .Error((token, exception) => Task.FromResult(true))
            .ToCommand());
 }
示例#5
0
 public IDisposable RegisterObservable <TObservable>(IObservable <TObservable> observable, Func <Exception, string> errorKey)
 {
     return(observable
            .Catch((Exception ex) => Observable.FromAsync(async ct =>
     {
         var resourceKey = errorKey(ex);
         var title = _resources.GetResource(_errorTitleKeyProvider(resourceKey));
         var content = _resources.GetResource(_errorContentKeyProvider(resourceKey));
         await _asyncMessageDialog.Show(ct, title, content);
         return default(TObservable);
     }))
            .Subscribe(_ => { }, e => { }, () => { }));
 }
示例#6
0
 public async Task Show(CancellationToken ct, string title, string content)
 {
     Debug.WriteLine("Display async message dialog.\nTitle : {0}\nContent:{1}");
     await _innerMessageDialog.Show(ct, title, content);
 }