public OverlayControlViewModel(IOverlayWindowService windowService) { this.Title.Value = "Overlay"; this.OverlayWindowService = windowService; this.OverlayWindowService.SetWindowFactory(this); this.PopupOverlayWindowRequest = new InteractionRequest <INotification>(); var ObservableWindowState = Observable.FromEvent <eWindowStateTypes>( handler => this.OverlayWindowService.WindowStateChanged += handler, handler => this.OverlayWindowService.WindowStateChanged -= handler ); this.ShowOverlayWindowState = ObservableWindowState .Select(x => eWindowStateTypes.Shown == x) .Select(x => x ? "表示 ON" : "表示 OFF") .ToReadOnlyReactiveProperty("表示 OFF") .AddTo(this.Disposable); this.CanOperationToOverlayWindow = ObservableWindowState .Select(x => eWindowStateTypes.Initializeing != x) .ToReadOnlyReactiveProperty(true) .AddTo(this.Disposable); this.ShowOverlayWindowRequest = new ReactiveProperty <bool>(); this.ShowOverlayWindowRequest .Where(x => x) .Subscribe(_ => this.OverlayWindowService.Show()) .AddTo(this.Disposable); this.ShowOverlayWindowRequest .Where(x => !x) .Subscribe(_ => this.OverlayWindowService.Hide()) .AddTo(this.Disposable); this.ScreenCollection = new ReactiveCollection <Screen>(); this.ScreenCollection.AddRangeOnScheduler(Screen.AllScreens); this.ScreenUpdateCommand = new ReactiveCommand(); this.ScreenUpdateCommand .Subscribe(_ => { this.ScreenCollection.ClearOnScheduler(); this.ScreenCollection.AddRangeOnScheduler(Screen.AllScreens); }) .AddTo(this.Disposable); this.UseScreen = Observable.FromEventPattern ( handler => this.OverlayWindowService.UseScreenChanged += handler, handler => this.OverlayWindowService.UseScreenChanged -= handler ) .Select(_ => this.OverlayWindowService.UseScreen) .ToReactiveProperty(Screen.PrimaryScreen) .AddTo(this.Disposable); this.UseScreen .Where(x => x != null) .Subscribe(x => this.OverlayWindowService.UseScreen = x) .AddTo(this.Disposable); }
public OverlayWindow(IOverlayWindowService windowService) { windowService.SetWindowController(this); InitializeComponent(); }