Exemplo n.º 1
0
        private async void OnAddAccountCommand()
        {
            var input =
                await
                _dialogCoordinator.ShowInputAsync(this, "New Account Nickname",
                                                  "Please enter a nickname easy for you to remember about this account.");

            _accountProvider.Accounts.Add(new AccountModel(input));
        }
Exemplo n.º 2
0
        public SettingsViewModel(SettingsModel settings)
        {
            Settings   = settings;
            AddRepoUrl = ReactiveCommand.CreateFromTask(async() =>
            {
                var repoUrl = await DialogCoordinator.ShowInputAsync(this, "Add new Repo",
                                                                     "Enter the url for the new Repo you want to add.\nIt usually looks like https://example.com/someFolder/repo.bin");
                if (string.IsNullOrWhiteSpace(repoUrl))
                {
                    return;
                }
                settings.Client.GroupUrls.Edit(l => l.Add(repoUrl));
            });
            var isRepoSelected =
                this.WhenAnyValue(x => x.RepoSelected,
                                  r => !string.IsNullOrWhiteSpace(r));

            RemoveRepoUrl = ReactiveCommand.Create(() => settings.Client.GroupUrls.Edit(l => l.Remove(RepoSelected)),
                                                   isRepoSelected);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 入力ダイアログを表示します。
 /// </summary>
 /// <param name="title">タイトル</param>
 /// <param name="message">メッセージ</param>
 /// <param name="settings">設定情報</param>
 /// <returns>入力値</returns>
 public async Task <string> ShowInputAsync(string title, string message, MetroDialogSettings settings = null)
 {
     return(await DialogCoordinator.ShowInputAsync(this, title, message, settings));
 }
Exemplo n.º 4
0
        private async void EditFeed(RoutedEventArgs e)
        {
            if (_selectedNode == null)
            {
                return;
            }
            SimpleTreeNodeViewModel tvm = (SimpleTreeNodeViewModel)_selectedNode;

            Model.Feed selectedFeed = null;
            if (tvm.Node is Model.Feed)
            {
                selectedFeed = (Model.Feed)tvm.Node;
            }
            else
            {
                if (tvm.Node is Model.Host)
                {
                    try
                    {
                        Model.Host selectedHost = (Model.Host)tvm.Node;
                        IsBrowserVisible = false;
                        RaisePropertyChanged("IsBrowserVisible");
                        MetroDialogSettings diagSettings = new MetroDialogSettings();
                        diagSettings.DefaultText = selectedHost.Zoom.ToString();
                        var ZoomLevel = await _dialogCoordinator.ShowInputAsync(this, "Set Zoom Level", "Enter the desired zoom level for this host: ", diagSettings);

                        int prevZoom = selectedHost.Zoom;
                        selectedHost.Zoom = Int32.Parse(ZoomLevel.ToString());
                        Data.Host dh = new Data.Host(selectedHost);
                        dh.Save();

                        if (prevZoom != selectedHost.Zoom)
                        {
                            var msg = new SendSetZoomMessage(selectedHost.Zoom);
                            msg.SetImmediately = true;
                            Messenger.Default.Send <SendSetZoomMessage>(msg);
                        }
                    }
                    catch (Exception ex)
                    {
                        await _dialogCoordinator.ShowMessageAsync(this, "Set Zoom Level", "Unable to set zoom: " + ex.Message);
                    }
                    finally
                    {
                        IsBrowserVisible = true;
                        RaisePropertyChanged("IsBrowserVisible");
                    }
                }
                return;
            }


            // Hides browser otherwise dialog gets behind it
            IsBrowserVisible = false;
            RaisePropertyChanged("IsBrowserVisible");
            MetroDialogSettings dialogSettings = new MetroDialogSettings();

            dialogSettings.DefaultText = selectedFeed.Location.ToString();
            var FeedText = await _dialogCoordinator.ShowInputAsync(this, "Edit feed", "Enter the URL of the feed:", dialogSettings);

            if (FeedText != null)
            {
                string errMsg = null;
                try
                {
                    Uri       feedUri = new Uri(FeedText);
                    Data.Feed f       = new Data.Feed(selectedFeed);
                    f.Location = feedUri;
                    f.UpdateFromUri(true, RetentionDays);
                    f.Save(true);
                    InitializeData(true);
                }
                catch (Exception ex)
                {
                    errMsg = ex.Message;
                }
                if (errMsg != null)
                {
                    await _dialogCoordinator.ShowMessageAsync(this, "Edit Feed", "Unable to edit feed with the supplied URL: " + errMsg);
                }
            }
            IsBrowserVisible = true;
            RaisePropertyChanged("IsBrowserVisible");
        }