public FlatDeviceVM(IProfileService profileService, IFlatDeviceMediator flatDeviceMediator, IApplicationStatusMediator applicationStatusMediator, IImageGeometryProvider imageGeometryProvider) : base(profileService) { _applicationStatusMediator = applicationStatusMediator; _flatDeviceMediator = flatDeviceMediator; _flatDeviceMediator.RegisterHandler(this); this.Title = "LblFlatDevice"; this.ImageGeometry = imageGeometryProvider.GetImageGeometry("LightBulbSVG"); ConnectCommand = new AsyncCommand <bool>(Connect); CancelConnectCommand = new RelayCommand(CancelConnectFlatDevice); DisconnectCommand = new AsyncCommand <bool>(() => DisconnectFlatDeviceDialog()); OpenCoverCommand = new AsyncCommand <bool>(OpenCover); CloseCoverCommand = new AsyncCommand <bool>(CloseCover); RefreshFlatDeviceListCommand = new RelayCommand(RefreshFlatDeviceList, o => _flatDevice?.Connected != true); SetBrightnessCommand = new RelayCommand(SetBrightness); ToggleLightCommand = new RelayCommand(ToggleLight); AddGainCommand = new RelayCommand(AddGain); AddBinningCommand = new RelayCommand(AddBinning); DeleteGainCommand = new RelayCommand(DeleteGainDialog); DeleteBinningCommand = new RelayCommand(DeleteBinningDialog); FlatDeviceChooserVM = new FlatDeviceChooserVM(profileService); FlatDeviceChooserVM.GetEquipment(); _updateTimer = new DeviceUpdateTimer( GetFlatDeviceValues, UpdateFlatDeviceValues, profileService.ActiveProfile.ApplicationSettings.DevicePollingInterval ); _flatDeviceSettings = profileService.ActiveProfile.FlatDeviceSettings; _flatDeviceSettings.PropertyChanged += FlatDeviceSettingsChanged; profileService.ProfileChanged += ProfileChanged; profileService.ActiveProfile.FilterWheelSettings.PropertyChanged += FilterWheelSettingsChanged; UpdateWizardValueBlocks(); }
public FlatWizardVM(IProfileService profileService, IImagingVM imagingVM, ICameraMediator cameraMediator, IFilterWheelMediator filterWheelMediator, ITelescopeMediator telescopeMediator, IFlatDeviceMediator flatDeviceMediator, IApplicationResourceDictionary resourceDictionary, IApplicationStatusMediator applicationStatusMediator) : base(profileService) { Title = "LblFlatWizard"; ImageGeometry = (System.Windows.Media.GeometryGroup)resourceDictionary["FlatWizardSVG"]; ImagingVM = imagingVM; this.applicationStatusMediator = applicationStatusMediator; flatSequenceCts?.Dispose(); flatSequenceCts = new CancellationTokenSource(); var pauseTokenSource = new PauseTokenSource(); Gain = -1; StartFlatSequenceCommand = new AsyncCommand <bool>( () => StartSingleFlatCapture(new Progress <ApplicationStatus>(p => Status = p), pauseTokenSource.Token), (object o) => cameraInfo.Connected ); StartMultiFlatSequenceCommand = new AsyncCommand <bool>( () => StartMultiFlatCapture(new Progress <ApplicationStatus>(p => Status = p), pauseTokenSource.Token), (object o) => cameraInfo.Connected && filterWheelInfo.Connected ); SlewToZenithCommand = new AsyncCommand <bool>( () => SlewToZenith(), (object o) => telescopeInfo.Connected ); CancelFlatExposureSequenceCommand = new RelayCommand(CancelFindExposureTime); PauseFlatExposureSequenceCommand = new RelayCommand(obj => { IsPaused = true; pauseTokenSource.IsPaused = IsPaused; }); ResumeFlatExposureSequenceCommand = new RelayCommand(obj => { IsPaused = false; pauseTokenSource.IsPaused = IsPaused; }); FlatCount = profileService.ActiveProfile.FlatWizardSettings.FlatCount; DarkFlatCount = profileService.ActiveProfile.FlatWizardSettings.DarkFlatCount; BinningMode = profileService.ActiveProfile.FlatWizardSettings.BinningMode; Filters = new ObservableCollection <FlatWizardFilterSettingsWrapper>(); profileService.ProfileChanged += (sender, args) => { UpdateSingleFlatWizardFilterSettings(profileService); watchedFilterList.CollectionChanged -= FiltersCollectionChanged; watchedFilterList = profileService.ActiveProfile.FilterWheelSettings.FilterWheelFilters; watchedFilterList.CollectionChanged += FiltersCollectionChanged; UpdateFilterWheelsSettings(); }; watchedFilterList = profileService.ActiveProfile.FilterWheelSettings.FilterWheelFilters; watchedFilterList.CollectionChanged += FiltersCollectionChanged; // first update filters UpdateSingleFlatWizardFilterSettings(profileService); UpdateFilterWheelsSettings(); // then register consumer and get the cameraInfo so it's populated to all filters including the singleflatwizardfiltersettings this.cameraMediator = cameraMediator; cameraMediator.RegisterConsumer(this); this.filterWheelMediator = filterWheelMediator; filterWheelMediator.RegisterConsumer(this); this.telescopeMediator = telescopeMediator; this.telescopeMediator.RegisterConsumer(this); // register the flat panel mediator _flatDeviceMediator = flatDeviceMediator; _flatDeviceMediator.RegisterConsumer(this); TargetName = "FlatWizard"; }