public ChatCollectServiceCreationPresetControlViewModel(IRegionManager regionManager, Model.TVTComment model) { this.regionManager = regionManager; this.model = model; ChatCollectServiceEntries = model.ChatServices.SelectMany(x => x.ChatCollectServiceEntries).Select(x => new SelectableViewModel <Model.ChatCollectServiceEntry.IChatCollectServiceEntry>(x)).ToList(); foreach (var entry in ChatCollectServiceEntries) { entry.PropertyChanged += ChatCollectServiceEntryListItemChanged; } ChatCollectServiceEntries.First().IsSelected = true; OkCommand = new DelegateCommand(() => { var entry = ChatCollectServiceEntries.FirstOrDefault(x => x.IsSelected)?.Value; var option = OptionRegionViewModel?.GetChatCollectServiceCreationOption(); if (string.IsNullOrWhiteSpace(PresetName.Value) || entry == null || option == null) { return; } confirmation.ChatCollectServiceCreationPreset = new Model.ChatCollectServiceCreationPreset(PresetName.Value, entry, option); confirmation.Confirmed = true; FinishInteraction(); }); CancelCommand = new DelegateCommand(() => { confirmation.Confirmed = false; FinishInteraction(); }); }
public BasicSettingControlViewModel(Model.TVTComment model) { this.model = model; var assembly = Assembly.GetExecutingAssembly().GetName(); this.Version = assembly.Version.ToString(3); }
public NichanChatCollectServiceCreationOptionControlViewModel(Model.TVTComment model) { var nichan = model.ChatServices.OfType <Model.ChatService.NichanChatService>().Single(); Boards = nichan.BoardList; Method = Model.ChatCollectServiceEntry.NichanChatCollectServiceEntry.ChatCollectServiceCreationOption.ThreadSelectMethod.Auto; OkCommand = new DelegateCommand(() => Finished?.Invoke(this, new EventArgs())); RefreshThreadsCommand = new DelegateCommand(RefreshThreads); }
public DefaultChatCollectServicesViewModel(Model.TVTComment model) { liveChatCollectService = model.DefaultChatCollectServiceModule.LiveChatCollectService; recordChatCollectService = model.DefaultChatCollectServiceModule.RecordChatCollectService; LiveServices = model.ChatServices.SelectMany(x => x.ChatCollectServiceEntries).Where(x => x.CanUseDefaultCreationOption) .Select(x => new DefaultChatCollectServiceViewModel(liveChatCollectService, x, liveChatCollectService.Contains(x))).ToArray(); RecordServices = model.ChatServices.SelectMany(x => x.ChatCollectServiceEntries).Where(x => x.CanUseDefaultCreationOption) .Select(x => new DefaultChatCollectServiceViewModel(recordChatCollectService, x, recordChatCollectService.Contains(x))).ToArray(); }
public ChatPostControlViewModel(Model.TVTComment model) { this.model = model; this.model.Initialize().ContinueWith(task => { if (!task.IsCompletedSuccessfully) { return; } this.initialize(); }, TaskScheduler.FromCurrentSynchronizationContext()); }
public ShellViewModel(Model.TVTComment model) { this.model = model; Window mainWindow = Application.Current.MainWindow; mainWindow.MouseLeftButtonDown += (_, __) => { mainWindow.DragMove(); }; // 初期化が終わるまで最小化しておく mainWindow.WindowState = WindowState.Minimized; model.ApplicationClose += CloseApplication; }
public ChatCollectServiceCreationPresetSettingControlViewModel(Model.TVTComment model) { this.model = model; ChatCollectServiceCreationPresets = model.ChatCollectServiceCreationPresetModule.CreationPresets; AddPreset = new DelegateCommand(async() => { ChatCollectServiceCreationPresetConfirmation result = await AddPresetRequest.RaiseAsync(new ChatCollectServiceCreationPresetConfirmation { Title = "プリセット追加" }); if (!result.Confirmed) { return; } model.ChatCollectServiceCreationPresetModule.AddCreationPreset( result.ChatCollectServiceCreationPreset.Name, result.ChatCollectServiceCreationPreset.ServiceEntry, result.ChatCollectServiceCreationPreset.CreationOption); }); RemovePreset = new DelegateCommand(() => { model.ChatCollectServiceCreationPresetModule.RemoveCreationPreset(SelectedChatCollectServiceCreationPreset); }); }
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(); }
public NgSettingWindowViewModel(Model.TVTComment model) { this.model = model; Model.Serialization.WindowPositionEntity rect = model.Settings.View.NgSettingWindowPosition; WindowLeft = rect.X; WindowTop = rect.Y; WindowWidth = rect.Width; WindowHeight = rect.Height; TargetChatCollectServiceEntries = new List <Contents.SelectableViewModel <Model.ChatCollectServiceEntry.IChatCollectServiceEntry> >( model.ChatServices.SelectMany(service => service.ChatCollectServiceEntries) .Select(x => new Contents.SelectableViewModel <Model.ChatCollectServiceEntry.IChatCollectServiceEntry>(x, true))); var updateTimer = Observable.Interval(TimeSpan.FromSeconds(3)); disposables.Add((IDisposable)(Rules = model.ChatModule.ChatModRules.MakeOneWayLinkedCollection(x => new Contents.ChatModRuleListItemViewModel(x, updateTimer.Select(_ => new Unit()))))); AddWordNgCommand = new DelegateCommand(() => { if (string.IsNullOrWhiteSpace(NgText)) { return; } model.ChatModule.AddChatModRule(new Model.ChatModRules.WordNgChatModRule(TargetChatCollectServiceEntries.Where(x => x.IsSelected).Select(x => x.Value), NgText)); }); AddUserNgCommand = new DelegateCommand(() => { if (string.IsNullOrWhiteSpace(NgText)) { return; } model.ChatModule.AddChatModRule(new Model.ChatModRules.UserNgChatModRule(TargetChatCollectServiceEntries.Where(x => x.IsSelected).Select(x => x.Value), NgText)); }); AddIroKomeNgCommand = new DelegateCommand(() => { model.ChatModule.AddChatModRule(new Model.ChatModRules.IroKomeNgChatModRule(TargetChatCollectServiceEntries.Where(x => x.IsSelected).Select(x => x.Value))); }); AddJyougeKomeNgCommand = new DelegateCommand(() => { model.ChatModule.AddChatModRule(new Model.ChatModRules.JyougeKomeNgChatModRule(TargetChatCollectServiceEntries.Where(x => x.IsSelected).Select(x => x.Value))); }); AddJyougeIroKomeNgCommand = new DelegateCommand(() => { model.ChatModule.AddChatModRule(new Model.ChatModRules.JyougeIroKomeNgChatModRule(TargetChatCollectServiceEntries.Where(x => x.IsSelected).Select(x => x.Value))); }); AddRandomizeColorRuleCommand = new DelegateCommand(() => { model.ChatModule.AddChatModRule(new Model.ChatModRules.RandomizeColorChatModRule(TargetChatCollectServiceEntries.Where(x => x.IsSelected).Select(x => x.Value))); }); AddSmallOnMultiLineRuleCommand = new DelegateCommand(() => { model.ChatModule.AddChatModRule(new Model.ChatModRules.SmallOnMultiLineChatModRule(TargetChatCollectServiceEntries.Where(x => x.IsSelected).Select(x => x.Value), SmallOnMultiLineRuleLineCount.Value)); }); AddSetColorRuleCommand = new DelegateCommand(() => { model.ChatModule.AddChatModRule(new Model.ChatModRules.SetColorChatModRule( TargetChatCollectServiceEntries.Where(x => x.IsSelected).Select(x => x.Value), SetColorRuleColor.Value )); }); RemoveRuleCommand = new DelegateCommand(() => { if (SelectedRule == null) { return; } model.ChatModule.RemoveChatModRule(SelectedRule.ChatModRule); }); }