/// <summary> /// コンストラクタ /// </summary> public MainWindowViewModel() { server = new Server(false, false, SendData); _ = ClosedCommand.Subscribe(Close).AddTo(Disposable); _ = OpenCommand.Subscribe(tcpOpne).AddTo(Disposable); _ = CloseCommand.Subscribe(tcpClose).AddTo(Disposable); }
/// <summary> /// コンストラクター /// </summary> public MainWindowViewModel(IAppSettingsService appSettingsService, IOpenFileDialogService openFileDialogService, ITextReadService textReadService, ITalkService talkService, ITalkQueueService talkQueueService) { AppSettingsService = appSettingsService; OpenFileDialogService = openFileDialogService; TextReadService = textReadService; TalkService = talkService; TalkQueueService = talkQueueService; TextReadService.Subscribe(TalkQueueService.Enqueue); SelectedCast.Value = TalkService.Cast; SelectedCast.Subscribe(x => TalkService.Cast = x); Volume.Value = TalkService.Volume; Volume.Subscribe(x => TalkService.Volume = x); Speed.Value = TalkService.Speed; Speed.Subscribe(x => TalkService.Speed = x); Tone.Value = TalkService.Tone; Tone.Subscribe(x => TalkService.Tone = x); Alpha.Value = TalkService.Alpha; Alpha.Subscribe(x => TalkService.Alpha = x); ToneScale.Value = TalkService.ToneScale; ToneScale.Subscribe(x => TalkService.ToneScale = x); LoadSettingsCommand.Subscribe(LoadSettings); SaveSettingsCommand.Subscribe(SaveSettings); OpenCommand.Subscribe(Open); ToggleWatchCommand.Subscribe(ToggleWatch); }
public MainPageViewModel(INavigationService navigationService) : base(navigationService) { //ViweModel→Model this.ServerSwitch = ReactiveProperty.FromObject(socket, x => x.IsServer).AddTo(this.Disposable); this.IpAddress = ReactiveProperty.FromObject(socket, x => x.IpAddress).AddTo(this.Disposable); this.Port = ReactiveProperty.FromObject(socket, x => x.Port).AddTo(this.Disposable); //ViewModel←Model this.SettingIsEnabled = socket.ObserveProperty(x => x.IsOpen).Select(x => !x).ToReactiveProperty().AddTo(this.Disposable); this.CloseCommand = socket.ObserveProperty(x => x.IsOpen).ToReactiveCommand().AddTo(this.Disposable); this.OpenCommand = socket.ObserveProperty(x => x.IsOpen).Select(x => !x).ToReactiveCommand().AddTo(this.Disposable); this.SendCommand = socket.ObserveProperty(x => x.IsOpen).ToReactiveCommand().AddTo(this.Disposable); this.ActionView = socket.ActionInfo.ToReadOnlyReactiveCollection().AddTo(this.Disposable); //ViewModel=Model this.SendData = socket.ToReactivePropertyAsSynchronized(x => x.SendData).AddTo(this.Disposable); //ViweModel内 this.ServerSwitchInfo = this.ServerSwitch.Select(x => x ? "サーバー" : "クライアント").ToReactiveProperty().AddTo(this.Disposable); this.IPAddressSettingIsEnabled = this.SettingIsEnabled.CombineLatest(this.ServerSwitch, (x, y) => x && !y) //クライアント且つCLOSE時のみIPアドレスは入力編集が可能 .ToReactiveProperty().AddTo(this.Disposable); //ボタン OpenCommand.Subscribe(_ => socket.Open()); CloseCommand.Subscribe(_ => socket.Close()); SendCommand.Subscribe(_ => socket.Send()); }