public MainWindowViewModel(IContainerExtension container, IRegionManager regionManager, MyImage myImage) { LoadImageCommand.Subscribe(x => myImage.LoadImage()); DropEvent.Select(x => x?.FirstOrDefault()?.LocalPath).Where(x => x != null) .Subscribe(x => myImage.LoadImage(x)); }
public ImageScrollControlViewModel(IContainerExtension container, IRegionManager regionManager) { var mainImages = container.Resolve <MainImages>(); var viewSettings = container.Resolve <ViewSettings>(); IsImageViewerInterlock = viewSettings.ObserveProperty(x => x.IsImageViewerInterlock).ToReadOnlyReactiveProperty(); CanVisibleReducedImage = viewSettings.ObserveProperty(x => x.CanVisibleReducedImage).ToReadOnlyReactiveProperty(); IsSamplingFrameOnImage = new[] { viewSettings.ObserveProperty(x => x.IsVisibleImageOverlapSamplingFrame), viewSettings.ObserveProperty(x => x.IsSamplingFrameOnImage) } .CombineLatestValuesAreAllTrue() .ToReadOnlyReactiveProperty(); IsSamplingFrameOnScrollContent = new[] { viewSettings.ObserveProperty(x => x.IsVisibleImageOverlapSamplingFrame), viewSettings.ObserveProperty(x => x.IsSamplingFrameOnImage).Inverse() } .CombineLatestValuesAreAllTrue() .ToReadOnlyReactiveProperty(); // 画像管理クラスのインデックスを取得 int index = mainImages.GetImageIndex(); LoadImageCommand.Subscribe(x => mainImages.LoadImage(index)); ImageSource = mainImages.ImageSources[index].ObserveProperty(x => x.ImageSource) .ToReadOnlyReactiveProperty(mode: ReactivePropertyMode.None); // View通知情報のデバッグ表示 ImageZoomPayload .Subscribe(x => Console.WriteLine($"VM({index})-ZoomMagRatio: {x.IsEntire} => {(x.MagRatio * 100.0):f2} %")); ImageScrollOffsetCenterRatio .Subscribe(x => Console.WriteLine($"VM({index})-ScrollOffsetRatio: ({x.X:f2}, {x.Y:f2})")); SamplingFrameRect .Subscribe(x => Console.WriteLine($"VM({index})-SamplingFrameRect: ({x.X:f2}, {x.Y:f2}) {x.Width:f2} x {x.Height:f2}")); ZoomAllCommand .Subscribe(x => { // 全画面の再要求を行うと、Viewで設定した倍率をクリアしてしまうので行わない if (!ImageZoomPayload.Value.IsEntire) { ImageZoomPayload.Value = new ImageZoomPayload(true, double.NaN); } }); ZoomX1Command .Subscribe(x => ImageZoomPayload.Value = new ImageZoomPayload(false, 1.0)); OffsetCenterCommand .Subscribe(x => ImageScrollOffsetCenterRatio.Value = new Point(0.5, 0.5)); //PointTest.Subscribe(x => Console.WriteLine($"VM-PointTest: {x}")); }