Exemplo n.º 1
0
 public ManageOpenInEditorReferencesViewModel(ConfigurationViewModel configuration)
 {
     Title         = "Manage OpenInEditor references.";
     Configuration = configuration;
     Filter        = new ReactiveProperty <string>();
     Filter
     .Throttle(TimeSpan.FromMilliseconds(500))
     .Subscribe(FilterChanged);
 }
Exemplo n.º 2
0
        private Task EditConfigurationExecute(ConfigurationViewModel arg)
        {
            if (!ServiceLocator.TryGetService(out IViewModelPresenter viewModelPresenter))
            {
                throw new Exception($"{nameof(IViewModelPresenter)} missing.");
            }

            viewModelPresenter.Present(arg);
            return(Task.CompletedTask);
        }
Exemplo n.º 3
0
        private async Task DeleteConfigurationExecute(ConfigurationViewModel arg)
        {
            if (!ServiceLocator.TryGetService(out IUIService uiService))
            {
                throw new Exception($"{nameof(IUIService)} not available.");
            }

            if (uiService.GetYesNo("Delete for sure?", "Question") &&
                await _configurationManager.DeleteConfigurationAsync(arg.Id))
            {
                await ReloadConfigurationsAsync(null);
            }
        }
Exemplo n.º 4
0
        private async Task BuildTemplateExecute(ConfigurationViewModel arg)
        {
            EventHandler ProgressOnCanceled(CancellationTokenSource cts)
            {
                return((sender, args) =>
                       cts.Cancel());
            }

            using (var cts = new CancellationTokenSource())
            {
                if (!ServiceLocator.TryGetService(out IUIService uiService))
                {
                    throw new Exception($"{nameof(IUIService)} not available.");
                }

                var progress = await uiService.ShowProgressAsync($"Building templates", "loading...", true);

                try
                {
                    var rewriter = new RewriteTool(arg.Model);
                    progress.Canceled += ProgressOnCanceled(cts);
                    await Task.Delay(1000, cts.Token);

                    progress.SetIndeterminate();
                    await rewriter.ExecuteAsync(cts.Token, new Progress <string>(p => progress.SetMessage(p)));
                }
                catch (TaskCanceledException)
                {
                }
                catch (OperationCanceledException)
                {
                }
                finally
                {
                    progress.Canceled -= ProgressOnCanceled(cts);
                    await progress.CloseAsync();
                }
            }
        }
Exemplo n.º 5
0
 private async void ConfigurationSaved(ConfigurationViewModel obj)
 {
     await ReloadConfigurationsAsync(null);
 }