예제 #1
0
        public ClusterViewerSettingsViewModel(ClusterViewerSettings clusterViewerSettings)
        {
            this.ShouldReducePoints = clusterViewerSettings.ShouldReducePoints;
            this.NetDivisions       = clusterViewerSettings.NetDivisions;
            this.MassDivisions      = clusterViewerSettings.MassDivisions;
            this.PointsPerDivision  = clusterViewerSettings.PointsPerDivision;
            this.ShowDivisionLines  = clusterViewerSettings.ShowDivisionLines;
            this.Status             = false;

            this.SaveCommand = new RelayCommand(() =>
            {
                this.Status = true;
                if (this.ReadyToClose != null)
                {
                    this.ReadyToClose(this, EventArgs.Empty);
                }
            });

            this.CancelCommand = new RelayCommand(() =>
            {
                this.Status = false;
                if (this.ReadyToClose != null)
                {
                    this.ReadyToClose(this, EventArgs.Empty);
                }
            });
        }
예제 #2
0
        /// <summary>
        /// Loads the layout from file.
        /// </summary>
        public void LoadLayoutFile()
        {
            var filePath = (!string.IsNullOrEmpty(this.layoutFilePath) && File.Exists(this.layoutFilePath))
                               ? this.layoutFilePath
                               : this.standardLayoutFilePath;

            var viewSettingsSerializer = new XmlSerializer(typeof(ViewSettings));
            var viewSettings           = new ViewSettings();

            using (var reader = File.Open(filePath, FileMode.Open))
            {
                try
                {
                    viewSettings    = (ViewSettings)viewSettingsSerializer.Deserialize(reader);
                    this.LayoutRoot = viewSettings.ClusterViewLayoutRoot;
                    this.LayoutRoot.PropertyChanged += (o, e) => this.layoutUpdated = true;
                    this.ClusterPlotViewModel.ClusterViewerSettings = viewSettings.ClusterViewerSettings;
                    this.originalSettings = viewSettings.ClusterViewerSettings;
                }
                catch (InvalidCastException)
                {
                    MessageBox.Show("Could not deserialize layout settings.");
                }
            }
        }
예제 #3
0
        public void CreateSettingsWindow(ClusterViewerSettings clusterViewerSettings)
        {
            var viewModel = new ClusterViewerSettingsViewModel(clusterViewerSettings);
            var window    = new ClusterViewerSettingsWindow
            {
                DataContext = viewModel,
            };

            viewModel.ReadyToClose += (o, e) => window.Close();

            window.ShowDialog();

            if (this.ClusterViewModel != null && viewModel.Status)
            {
                this.ClusterViewModel.ClusterPlotViewModel.ClusterViewerSettings = viewModel.ClusterViewerSettings;
            }
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClusterViewModel"/> class.
        /// </summary>
        /// <param name="viewFactory">Factory for creating child windows.</param>
        /// <param name="matches">The clusters.</param>
        /// <param name="providers">Database access provider</param>
        /// <param name="rawProvider">Provider for LCMSRun for access to PBF files.</param>
        public ClusterViewModel(IClusterViewFactory viewFactory, List <ClusterMatch> matches, FeatureDataAccessProviders providers, ScanSummaryProviderCache rawProvider)
        {
            this.viewFactory                 = viewFactory;
            this.providers                   = providers;
            this.dbLock                      = new object();
            this.throttler                   = new Throttler(TimeSpan.FromMilliseconds(500));
            this.XicPlotViewModel            = new XicPlotViewModel(rawProvider);
            this.ClusterFeaturePlotViewModel = new ClusterFeaturePlotViewModel();
            this.Matches                     = new ObservableCollection <ClusterMatch>(matches ?? new List <ClusterMatch>());
            var clusters = this.Matches.Select(match => match.Cluster).ToList();

            this.rawProvider = rawProvider;

            this.SettingsCommand = new RelayCommand(() => this.viewFactory.CreateSettingsWindow(this.ClusterPlotViewModel.ClusterViewerSettings));

            this.Features    = new ObservableCollection <UMCLightViewModel>();
            this.MsMsSpectra = new ObservableCollection <MSSpectra>();

            this.ClusterPlotViewModel = new ClusterPlotViewModel(clusters);

            this.ShowChargeStateDistributionCommand = new RelayCommand(this.ShowChargeStateDistributionImpl);
            this.ShowDatasetHistogramCommand        = new RelayCommand(this.ShowDatasetHistogramImpl);

            this.layoutUpdated    = false;
            this.originalSettings = new ClusterViewerSettings();

            // Set up standard layout path
            var assemblyPath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);

            if (!string.IsNullOrEmpty(assemblyPath))
            {
                this.standardLayoutFilePath = Path.Combine(assemblyPath, StandardLayoutFileName);
            }

            // Listen for changes in selected cluster in ClusterViewModel.
            Messenger.Default.Register <PropertyChangedMessage <UMCClusterLight> >(
                this,
                args =>
            {
                if (args.Sender == this.ClusterPlotViewModel && !this.ClusterPlotViewModel.SelectedCluster.Equals(this.SelectedMatch))
                {
                    this.SelectedMatch = this.Matches.FirstOrDefault(match => match.Cluster == this.ClusterPlotViewModel.SelectedCluster);
                }
            });

            // Listen for changes in selected cluster internally.
            Messenger.Default.Register <PropertyChangedMessage <ClusterMatch> >(
                this,
                arg =>
            {
                if (arg.Sender == this)
                {
                    this.throttler.Run(() => this.MatchSelected(arg));
                }
            });

            // When the selected MSFeature changes, update MS/MS spectra
            Messenger.Default.Register <PropertyChangedMessage <MSFeatureLight> >(
                this,
                arg =>
            {
                if (arg.Sender == this.XicPlotViewModel && arg.NewValue != null)
                {
                    this.MsMsSpectra.Clear();
                    foreach (var msmsSpectrum in arg.NewValue.MSnSpectra)
                    {
                        this.MsMsSpectra.Add(msmsSpectrum);
                    }

                    var first = this.MsMsSpectra.FirstOrDefault();
                    if (first != null)
                    {
                        this.SelectedMsMsSpectra = first;
                    }
                }
            });

            // Load layout.
            this.layoutFilePath = "layout.xml";
            this.LoadLayoutFile();

            if (this.Matches.Count > 0)
            {
                this.SelectedMatch = this.Matches[0];
            }
        }