public RecentAnalysisViewModel(RecentAnalysis analysis)
 {
     m_analysis = analysis;
     var command = new LoadRecentAnalysisCommand();
     command.RecentAnalysisSelected += command_RecentAnalysisSelected;
     LoadRecent = command;
 }
        private ObservableCollection<RecentAnalysisViewModel> LoadRecent(XmlNode data)
        {
            var allAnalysis = new ObservableCollection<RecentAnalysisViewModel>();
            foreach (XmlNode node in data.ChildNodes)
            {
                if (node.Name == "Analysis")
                {
                    var name = node.Attributes["Name"].Value;
                    var path = node.Attributes["Path"].Value;

                    var analysis = new RecentAnalysis(path, name);
                    allAnalysis.Add(new RecentAnalysisViewModel(analysis));
                }
            }
            return allAnalysis;
        }
        public override void Execute(object parameter)
        {
            var result = m_analysisLoadDialog.ShowDialog();

            if (result == null || !result.Value)
                return;

            var filename = m_analysisLoadDialog.FileName;
            var path = Path.GetDirectoryName(filename);
            var name = Path.GetFileName(filename);

            var newAnalysis = new RecentAnalysis(path, name);

            if (ExistingAnalysisSelected != null)
            {
                ExistingAnalysisSelected(this, new OpenAnalysisArgs(newAnalysis));
            }
        }
        /// <summary>
        ///     Loads the analysis.
        /// </summary>
        /// <param name="recentAnalysis"></param>
        public void LoadAnalysis(RecentAnalysis recentAnalysis)
        {
            if (recentAnalysis == null)
            {
                OnStatus("Cannot open analysis file.");
                return;
            }

            Action loadAnalysis = delegate
            {
                var filename = Path.Combine(recentAnalysis.Path, recentAnalysis.Name);

                OnStatus("Gaining access to the analysis database...");
                var providers = DataAccessFactory.CreateDataAccessProviders(filename, false);
                var analysis = new MultiAlignAnalysis();
                analysis.MetaData.AnalysisPath = recentAnalysis.Path;
                analysis.MetaData.AnalysisName = recentAnalysis.Name;
                analysis.MetaData.AnalysisSetupInfo = null;
                analysis.DataProviders = providers;

                OnStatus("Detecting your clusters...");
                analysis.Clusters = providers.ClusterCache.FindAll();

                OnStatus("Updating your datasets...");
                analysis.MetaData.Datasets = providers.DatasetCache.FindAll().ToObservableCollection();

                OnStatus("Securing mass tags...");
                var provider = new MassTagDatabaseLoaderCache();
                provider.Provider = analysis.DataProviders.MassTags;
                analysis.MassTagDatabase = provider.LoadDatabase();

                OnStatus("Analysis Loaded...");
                ThreadSafeDispatcher.Invoke(() =>
                {
                    if (AnalysisLoaded != null)
                    {
                        AnalysisLoaded(this, new AnalysisStatusArgs(analysis));
                    }
                });
            };

            m_loadingTask = new Task(loadAnalysis);
            m_loadingTask.Start();
        }
Example #5
0
        public void AddAnalysis(RecentAnalysis recent)
        {
            var analysis = new RecentAnalysisViewModel(recent);
            RecentAnalysisViewModel model = null;

            foreach (var x in RecentAnalysis)
            {
                if (x.Analysis == recent)
                    model = x;
            }

            if (model != null)
            {
                RecentAnalysis.Remove(model);
            }

            RecentAnalysis.Insert(0, analysis);

            if (RecentAnalysis.Count > 10)
            {
                RecentAnalysis.RemoveAt(RecentAnalysis.Count - 1);
            }
        }
Example #6
0
 public OpenAnalysisArgs(RecentAnalysis analysis)
 {
     AnalysisData = analysis;
 }
Example #7
0
        /// <summary>
        ///     Loads a recent analysis
        /// </summary>
        /// <param name="recentAnalysis"></param>
        private void LoadAnalysis(RecentAnalysis recentAnalysis)
        {
            string message;
            if (StateModerator.IsAnalysisRunning(out message))
            {
                Status = "Cannot open a new analysis while one is running.";
                return;
            }

            var filename = Path.Combine(recentAnalysis.Path, recentAnalysis.Name);
            if (!File.Exists(filename))
            {
                StateModerator.CurrentViewState = ViewState.HomeView;
                Status = "The analysis file does not exist";
                return;
            }

            // Show the open view
            StateModerator.CurrentViewState = ViewState.OpenView;
            LoadingAnalysisViewModel.LoadAnalysis(recentAnalysis);
        }
Example #8
0
        private void DisplayAnalysis(MultiAlignAnalysis analysis)
        {
            // Change the title
            var version = ApplicationUtility.GetEntryAssemblyData();
            Title = string.Format("{0} - {1}", version, analysis.MetaData.AnalysisName);

            var model = new AnalysisViewModel(analysis);
            CurrentAnalysis = model;
            StateModerator.CurrentViewState = ViewState.AnalysisView;
            var recent = new RecentAnalysis(analysis.MetaData.AnalysisPath,
                analysis.MetaData.AnalysisName);
            GettingStartedViewModel.CurrentWorkspace.AddAnalysis(recent);
        }
Example #9
0
        /// <summary>
        ///     Adds the finished analysis back into the UI
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AnalysisRunningViewModel_AnalysisComplete(object sender, AnalysisStatusArgs e)
        {
            var path = e.Configuration.AnalysisPath;
            var name = Path.GetFileName(e.Configuration.AnalysisName);
            var recent = new RecentAnalysis(path, name);
            StateModerator.CurrentViewState = ViewState.AnalysisView;
            StateModerator.CurrentAnalysisState = AnalysisState.Viewing;

            GettingStartedViewModel.AddAnalysis(recent);
            DisplayAnalysis(e.Configuration.Analysis);
        }
Example #10
0
 public OpenAnalysisArgs(RecentAnalysis analysis)
 {
     AnalysisData = analysis;
 }
 public void AddAnalysis(RecentAnalysis recent)
 {
     CurrentWorkspace.AddAnalysis(recent);
     SaveWorkSpace();
 }