public OverlayWindowViewModel(IReactionHubProxy reactionHubProxy, IDisplayControlService displayControl, IUsersActivity usersActivity) { this.ReactionHub = reactionHubProxy; this.DisplayControl = displayControl; this.UsersActivity = usersActivity; this.DisplayTime = this.DisplayControl.DisplayTime .ToReactiveProperty() .AddTo(this.Disposable); this.MaxOpacity = this.DisplayControl.MaxOpacity .ToReactiveProperty() .AddTo(this.Disposable); this.Scale = this.DisplayControl.Scale .ToReactiveProperty() .AddTo(this.Disposable); this.MoveMethod = this.DisplayControl.MoveMethod .ToReactiveProperty() .AddTo(this.Disposable); this.OpacityCurve = this.DisplayControl.OpacityCurve .ToReactiveProperty() .AddTo(this.Disposable); this.Message = this.UsersActivity .SelectedUser .Select(x => x?.Name ?? "川原's System.") .ToReactiveProperty() .AddTo(this.Disposable); this.ReactionHub.Connected += async() => { //リアクションの受信設定 this.ReactionHub.OnReceiveReaction() .Subscribe(x => this.OnInteraction(x.Item1, x.Item2)) .AddTo(this.Disposable); //リスナー登録 var ret = await this.ReactionHub.AddListener(); if (ret.ResultTypes == eResultTypes.Failed) { throw new ArgumentException(ret.Message); } }; this.ReactionHub.Open(); }
public MultiUsersViewModel(IUsersActivity usersActivity, IUsersStore usersStore, IThemeService themeService, IStatusService statusService) { this.UsersActivity = usersActivity; this.UserStore = usersStore; this.ThemeService = themeService; this.StatusService = statusService; this.NewUserName = new ReactiveProperty <string>(); this.SelectedUser = this.UsersActivity .SelectedUser .ToReactivePropertyAsSynchronized(x => x.Value) .AddTo(this.Disposable); this.Users = this.UsersActivity .Users .ToReadOnlyReactiveCollection() .AddTo(this.Disposable); this.FilePath = this.UserStore .ToReactivePropertyAsSynchronized(x => x.FilePath) .AddTo(this.Disposable); this.AddUserCommand = this.NewUserName .Select(x => !string.IsNullOrWhiteSpace(x)) .ToReactiveCommand() .AddTo(this.Disposable); this.RemoveUserCommand = this.SelectedUser .Select(x => x != null) .ToReactiveCommand() .AddTo(this.Disposable); this.UnselectCommand = this.SelectedUser .Select(x => x != null) .ToReactiveCommand() .AddTo(this.Disposable); this.ResetUserCount = this.SelectedUser .Select(x => x != null) .ToReactiveCommand() .AddTo(this.Disposable); this.SaveCommand = this.FilePath .Select(x => !string.IsNullOrWhiteSpace(x)) .ToReactiveCommand() .AddTo(this.Disposable); this.LoadCommand = this.FilePath .Select(x => !string.IsNullOrWhiteSpace(x)) .ToReactiveCommand() .AddTo(this.Disposable); this.AddUserCommand .Subscribe(_ => { this.UsersActivity.AddUser(this.NewUserName.Value); this.NewUserName.Value = string.Empty; }); this.RemoveUserCommand .Subscribe(_ => { this.UsersActivity.RemoveUser(this.SelectedUser.Value); this.SelectedUser.Value = null; }); this.UnselectCommand .Subscribe(_ => { this.SelectedUser.Value = null; }); this.ResetUserCount .Subscribe(_ => { this.UsersActivity.CountReset(); }); this.SaveCommand .Subscribe(_ => { this.UsersActivity.Save(); }); this.LoadCommand .Subscribe(_ => { this.UsersActivity.Load(); }); this.SelectedUser .Select(x => x != null) .Subscribe(x => { this.ThemeService.IsBusy = x; }) .AddTo(this.Disposable); this.SelectedUser .Select(x => x != null ? $"発表者:{x.Name}" : "準備完了") .Subscribe(x => { this.StatusService.SetStatus(x); }) .AddTo(this.Disposable); this.Title.Value = "Multi Users"; }