public FeatureFindingSettingsViewModel(
                                               MultiAlignAnalysis analysis,
                                               FeatureLoader featureCache,
                                               IFeatureWindowFactory msFeatureWindowFactory = null,
                                               IProgress<int> progressReporter = null)
        {
            this.analysis = analysis;
            this.featureCache = featureCache;
            this.msFeatureWindowFactory = msFeatureWindowFactory ?? new MSFeatureViewFactory();
            this.progress = progressReporter ?? new Progress<int>();
            this.selectedDatasets = new ReadOnlyCollection<DatasetInformationViewModel>(new List<DatasetInformationViewModel>());
            this.msFeatureWindowFactory = new MSFeatureViewFactory();

            this.MessengerInstance.Register<PropertyChangedMessage<IReadOnlyCollection<DatasetInformationViewModel>>>(this, sds =>
            {
                this.selectedDatasets = sds.NewValue;
                this.FindMSFeaturesCommand.RaiseCanExecuteChanged();
                this.PlotMSFeaturesCommand.RaiseCanExecuteChanged();
            });

            this.FindMSFeaturesCommand = new RelayCommand(
                                        async () => await this.LoadMSFeaturesAsync(),
                                        () => this.selectedDatasets != null && 
                                              this.selectedDatasets.Count > 0 && 
                                              this.selectedDatasets.Any(file => !file.DoingWork));
            this.PlotMSFeaturesCommand = new RelayCommand(
                                        async () => await this.PlotMSFeatures(), 
                                        () => this.selectedDatasets.Any(file => file.FeaturesFound));
        }
Beispiel #2
0
        public FeatureFindingSettingsViewModel(
            MultiAlignAnalysis analysis,
            FeatureLoader featureCache,
            IFeatureWindowFactory msFeatureWindowFactory = null,
            IProgress <int> progressReporter             = null)
        {
            this.analysis               = analysis;
            this.featureCache           = featureCache;
            this.msFeatureWindowFactory = msFeatureWindowFactory ?? new MSFeatureViewFactory();
            this.progress               = progressReporter ?? new Progress <int>();
            this.selectedDatasets       = new ReadOnlyCollection <DatasetInformation>(new List <DatasetInformation>());
            this.msFeatureWindowFactory = new MSFeatureViewFactory();

            MessengerInstance.Register <PropertyChangedMessage <IReadOnlyCollection <DatasetInformation> > >(this, sds =>
            {
                this.selectedDatasets = sds.NewValue;
                this.FindMSFeaturesCommand.RaiseCanExecuteChanged();
                this.PlotMSFeaturesCommand.RaiseCanExecuteChanged();
            });

            FindMSFeaturesCommand = new RelayCommand(
                async() => await LoadMSFeaturesAsync(),
                () => this.selectedDatasets != null &&
                this.selectedDatasets.Count > 0 &&
                this.selectedDatasets.Any(file => !file.DoingWork));
            PlotMSFeaturesCommand = new RelayCommand(
                async() => await PlotMSFeatures(),
                () => this.selectedDatasets.Any(file => file.FeaturesFound));
        }
Beispiel #3
0
        /// <summary>
        /// Cosntructor
        /// </summary>
        /// <param name="analysis"></param>
        /// <param name="datasets"></param>
        /// <param name="msFeatureWindowFactory"></param>
        public FeatureFindingSettingsViewModel(
            MultiAlignAnalysis analysis,
            ObservableCollection <DatasetInformationViewModel> datasets,
            IFeatureWindowFactory msFeatureWindowFactory = null)
        {
            this.analysis = analysis;
            this.Datasets = datasets;
            this.msFeatureWindowFactory = msFeatureWindowFactory ?? new MSFeatureViewFactory();
            this.msFeatureWindowFactory = new MSFeatureViewFactory();
            this.featuresByDataset      = new Dictionary <DatasetInformation, IList <UMCLight> >();
            this.MsFeatureClusterers    = new ObservableCollection <MsFeatureClusteringAlgorithmType>(
                Enum.GetValues(typeof(MsFeatureClusteringAlgorithmType)).Cast <MsFeatureClusteringAlgorithmType>());
            this.LcmsFeatureClusterers = new ObservableCollection <GenericClusteringAlgorithmType>(
                Enum.GetValues(typeof(GenericClusteringAlgorithmType)).Cast <GenericClusteringAlgorithmType>());

            this.CanCreateXics = datasets.Select(dataset => RawLoaderFactory.CreateFileReader(dataset.Dataset.RawFile.Path, dataset.DatasetId))
                                 .Any(reader => reader is ISpectraProvider);

            // When dataset is selected/unselected, update can executes.
            this.MessengerInstance.Register <PropertyChangedMessage <bool> >(this, this.UpdateDatasetSelection);

            // When dataset state changes, update can executes.
            this.MessengerInstance.Register <PropertyChangedMessage <DatasetInformationViewModel.DatasetStates> >(this, args =>
            {
                if (args.Sender is DatasetInformationViewModel && args.PropertyName == "DatasetState")
                {
                    ThreadSafeDispatcher.Invoke(() =>
                    {
                        this.FindMsFeaturesCommand.RaiseCanExecuteChanged();
                        this.PlotMsFeaturesCommand.RaiseCanExecuteChanged();
                        this.PlotAlignedFeaturesCommand.RaiseCanExecuteChanged();
                    });
                }
            });

            this.FindMsFeaturesCommand = new RelayCommand(
                async() => await this.LoadMsFeaturesAsync(),
                () => this.Datasets.Any(ds => ds.IsSelected && !ds.IsFindingFeatures));

            this.PlotMsFeaturesCommand = new RelayCommand(
                async() => await this.PlotMsFeatures(false),
                () => this.Datasets.Any(
                    ds =>
                    ds.DatasetState >
                    DatasetInformationViewModel.DatasetStates.FindingFeatures &&
                    ds.IsSelected));

            this.PlotAlignedFeaturesCommand = new RelayCommand(
                async() => await this.PlotMsFeatures(true),
                () => this.Datasets.Any(ds => ds.IsAligned));

            this.RestoreDefaultsCommand = new RelayCommand(this.RestoreDefaults);
        }