private async void ExcuteOpenDeleteButtonDialog(object param) { var view = new DeleteButtonDialog(); string owner = (param as StreamClass).Owner; view.DeleteButtonTextBlock.Text = "\"" + owner + "\"を削除しますか"; var manager = SelectedLeftMenu.Manager; var result = await DialogHost.Show(view); if (!Equals(result, true)) { return; } //削除 if (!manager.RemoveFavorite(owner)) { //削除に失敗しました var notify = new NotifyDialog(); notify.NotifyTextBlock.Text = "削除に失敗しました"; await DialogHost.Show(notify); return; } manager.Save(); //Gridの更新 RefreshBridge.Refresh(manager); RefreshDataGrid(); }
private async void ExcuteOpenAddButtonDialog(object param) { var view = new AddButtonDialog(); view.AddButtonTextBlock.Text = "追加する名前を入力 (" + SelectedLeftMenu.Text + ")"; if (SelectedTopMenu == TopMenuSelection.All) { view.AddButtonTextBox.Text = (param as StreamClass).Owner; } var manager = SelectedLeftMenu.Manager; bool isTwitch = SelectedLeftMenu.Text == "Twitch"; while (true) { var result = await DialogHost.Show(view); if (!Equals(result, true)) { return; } //追加 string s = view.AddButtonTextBox.Text; if (string.IsNullOrWhiteSpace(s)) { //名前が入力されていません var notify = new NotifyDialog(); notify.NotifyTextBlock.Text = "名前が入力されていません"; await DialogHost.Show(notify); continue; } if (isTwitch && !s.All(c => char.IsLower(c) || char.IsDigit(c) || c == '_')) { //Twitchは英数小文字で入力してください var notify = new NotifyDialog(); notify.NotifyTextBlock.Text = "Twitchは英数小文字で入力してください"; await DialogHost.Show(notify); continue; } if (!manager.AddFavorite(s)) { //sはすでに登録されています var notify = new NotifyDialog(); notify.NotifyTextBlock.Text = s + "はすでに登録されています"; await DialogHost.Show(notify); return; } manager.Save(); //Gridの更新 RefreshBridge.Refresh(manager); RefreshDataGrid(); break; } }