private void model_ErrorOccurredAtChatCollectServiceCreation(Model.ChatCollectServiceEntry.IChatCollectServiceEntry serviceEntry, string errorText) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = $"コメント元、\"{serviceEntry.Name}\"を有効にしようとしたとき以下のエラーが発生し、有効化できませんでした。\n\n{errorText}" }); }
private void model_ErrorOccurredInChatPosting(Model.ChatCollectService.IChatCollectService service, Model.ChatCollectService.BasicChatPostObject postObject, string errorText) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = $"\"{service.Name}\"にコメントを投稿するとき以下のエラーが発生しました。\n\n{errorText}" }); }
private async Task initializeInternal() { if (initialized) { return; } initialized = true; // モデルの初期化 try { await model.Initialize(); await BasicSettingControlViewModel.Initialize(); //await ChatPostControlViewModel.Initialize(); } catch (Exception e) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = $"初期化で予期しないエラーが発生しました\n{e.ToString()}" }); CloseApplication(); return; } if (model.State != Model.TVTCommentState.Working) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = "Viewer側(TVTestプラグイン側)と接続できませんでした" }); CloseApplication(); return; } // 表示関係の設定復元 Model.Serialization.WindowPositionEntity rect = model.Settings.View.MainWindowPosition; this.WindowPosition.X = rect.X; this.WindowPosition.Y = rect.Y; this.WindowPosition.Width = rect.Width; this.WindowPosition.Height = rect.Height; ChatListColumnInfos = model.Settings.View.ChatListViewColumns?.Select( x => new Views.AttachedProperties.GridViewColumnSettingsBinder.ColumnInfo(x.Id, x.Width) ).ToArray(); this.SelectedTab.Value = model.Settings.View.MainWindowTab; // ウィンドウの位置を復元したら最小化を解除 Window window = Application.Current.MainWindow; window.WindowState = WindowState.Normal; // モデルのイベントハンドラを登録 model.ChatCollectServiceModule.ErrorOccurredInChatCollecting += model_ErrorOccurredInChatCollecting; model.ChatCollectServiceModule.ErrorOccurredInChatPosting += model_ErrorOccurredInChatPosting; model.ChatCollectServiceModule.ErrorOccurredInServiceCreation += model_ErrorOccurredAtChatCollectServiceCreation; // モデルのプロパティを結びつける CurrentPlayTime = model.ChannelInformationModule.CurrentTime; CurrentChannel = model.ChannelInformationModule.CurrentChannel; CurrentEvent = model.ChannelInformationModule.CurrentEvent; disposables.Add(CurrentPlayTime.Subscribe(_ => updateWindowTitle())); disposables.Add(CurrentChannel.Subscribe(_ => updateWindowTitle())); disposables.Add(CurrentEvent.Subscribe(_ => updateWindowTitle())); // 旧ニコニコ実況が廃止されたので現状常にnull // 今後対応するときのためにとって置いてる forceValueData = new ReadOnlyObservableValue <Model.IForceValueData>(Observable.Return <Model.IForceValueData>(null)); UseDefaultChatCollectService = model.DefaultChatCollectServiceModule.IsEnabled; model.CommandModule.ShowWindowCommandInvoked += commandModule_ShowWindowCommandInvoked; // コマンド生成 ChangeChannelCommand = new DelegateCommand <Model.ChannelInfo>(channel => { if (channel != null) { model.ChannelInformationModule.SetCurrentChannel(channel); } }); AddChatCollectServiceCommand = new DelegateCommand <ShellContents.ChatCollectServiceAddListItemViewModel>( async x => { if (x != null) { await addChatCollectService(x); } }, _ => !UseDefaultChatCollectService.Value ); RemoveChatCollectServiceCommand = new DelegateCommand <Model.ChatCollectService.IChatCollectService>( service => { if (service != null) { model.ChatCollectServiceModule.RemoveService(service); } }, _ => !UseDefaultChatCollectService.Value ); UseDefaultChatCollectService.Subscribe(x => { AddChatCollectServiceCommand.RaiseCanExecuteChanged(); RemoveChatCollectServiceCommand.RaiseCanExecuteChanged(); }); ClearChatsCommand = new DelegateCommand(() => model.ChatModule.ClearChats()); AddWordNgCommand = new DelegateCommand <Model.Chat>(chat => { if (chat == null) { return; } model.ChatModule.AddChatModRule(new Model.ChatModRules.WordNgChatModRule(model.ChatServices.SelectMany(x => x.ChatCollectServiceEntries), chat.Text)); }); AddUserNgCommand = new DelegateCommand <Model.Chat>(chat => { if (chat == null) { return; } model.ChatModule.AddChatModRule(new Model.ChatModRules.UserNgChatModRule(chat.SourceService.Owner.ChatCollectServiceEntries, chat.UserId)); }); CopyCommentCommand = new DelegateCommand <Model.Chat>(chat => { if (chat == null) { return; } Clipboard.SetText(chat.Text); }); CopyUserCommand = new DelegateCommand <Model.Chat>(chat => { if (chat == null) { return; } Clipboard.SetText(chat.UserId); }); OnPropertyChanged(null); }
private void model_ErrorOccurredInChatCollecting(Model.ChatCollectService.IChatCollectService service, string errorText) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = $"\"{service.Name}\"で以下のエラーが発生しました。このコメント元を無効化します。\n\n{errorText}" }); }
public SettingsWindowViewModel(Model.TVTComment model) { DefaultChatCollectServices = new ShellContents.DefaultChatCollectServicesViewModel(model); niconico = model.ChatServices.OfType <Model.ChatService.NiconicoChatService>().Single(); nichan = model.ChatServices.OfType <Model.ChatService.NichanChatService>().Single(); ChatCollectServiceCreationPresetSettingControlViewModel = new SettingsWindowContents.ChatCollectServiceCreationPresetSettingControlViewModel(model); LoginNiconicoCommand = new DelegateCommand(async() => { if (string.IsNullOrWhiteSpace(NiconicoUserId.Value) || string.IsNullOrWhiteSpace(NiconicoPassword.Value)) { return; } try { await niconico.SetUser(NiconicoUserId.Value, NiconicoPassword.Value, NiconicoSid.Value, NiconicoSession.Value, NiconicoSecure.Value); syncNiconicoUserStatus(); } catch (Model.NiconicoUtils.NiconicoLoginSessionException) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = "ニコニコへのログインに失敗しました" }); } }); ApplyNichanSettingsCommand = new DelegateCommand(() => { if (string.IsNullOrWhiteSpace(NichanResCollectInterval.Value) || string.IsNullOrWhiteSpace(NichanThreadSearchInterval.Value)) { return; } try { nichan.SetIntervalValues( TimeSpan.FromSeconds(uint.Parse(NichanResCollectInterval.Value)), TimeSpan.FromSeconds(uint.Parse(NichanThreadSearchInterval.Value))); nichan.SetApiParams( NichanApiHmKey.Value, NichanApiAppKey.Value, nichan.GochanApiUserId, nichan.GochanApiPassword, NichanApiAuthUserAgent.Value, NichanApiAuthX2chUA.Value, NichanApiUserAgent.Value ); nichan.SetPastCollectServiceBackTime(TimeSpan.FromMinutes(double.Parse(NichanPastCollectServiceBackTime.Value))); syncNichanSettings(); } catch (Exception e) when(e is FormatException || e is OverflowException) { AlertRequest.Raise(new Notification { Title = "TVTCommentエラー", Content = "2ch設定の値が不正です" }); } }); ChatPreserveCount = model.ChatModule.ChatPreserveCount; syncNiconicoUserStatus(); syncNichanSettings(); }