public MainImageViewModel(IContainerExtension container, IRegionManager regionManager) { _container = container; _regionManager = regionManager; ImageSource = MainImage .ObserveProperty(x => x.ImageSource) .ToReadOnlyReactiveProperty(); ImageSource.Subscribe(x => InspectLinePoints.SetSourceSize(x.PixelWidth, x.PixelHeight)); // Viewの非表示時のクリア LineLevels.ObserveProperty(x => x.IsShowingView).Where(b => !b) .Subscribe(_ => { InspectLinePoints.ClearPoints(); // 画像上のLine表示 LineLevels.ReleaseLinePoints(); // OxyPlot図(次回表示用) }); // マウス移動開始 MouseDown.Where(_ => LineLevels.IsShowingView) .Subscribe(p => InspectLinePoints.SetPoint1(p.X, p.Y)); // マウス移動中 var mouseMove = MouseDown.Merge(MouseDown.SelectMany(MouseMove.TakeUntil(MouseUp))) .Where(_ => LineLevels.IsShowingView); // ViewのLine表示は常時更新 mouseMove.Subscribe(p => InspectLinePoints.SetPoint2(p.X, p.Y)); // Line画素値の取得は重いので計算を間引く mouseMove .Throttle(TimeSpan.FromMilliseconds(500)) // 指定期間分だけ値が通過しなかったら最後の一つを流す .Subscribe(_ => LineLevels.SetLinePointsRatio(InspectLinePoints.GetPointsRatio())); }