Пример #1
0
        public ProgressForm(IEnumerable <string> taskNames, IterationListenerRegistry ilr)
        {
            InitializeComponent();

            _progressCellByTaskName = new Dictionary <string, DataGridViewProgressCell>();
            _textBoxLogByTaskName   = new Dictionary <string, TextBox>();
            _lastMessageByTaskName  = new Dictionary <string, string>();
            _rowByTaskName          = new Dictionary <string, DataGridViewRow>();
            _tasksDone = 0;

            _ilr     = ilr;
            _ilProxy = new IterationListenerProxy()
            {
                form = this
            };
            _ilr.addListener(_ilProxy, 1000);

            var boxShown = false;

            foreach (var task in taskNames)
            {
                var textBox = _textBoxLogByTaskName[task] = new TextBox
                {
                    Text = String.Format("{0}{1}{0}Starting...{0}",
                                         Environment.NewLine,
                                         new string('-', 30)),
                    Dock       = DockStyle.Fill,
                    Multiline  = true,
                    ScrollBars = ScrollBars.Vertical
                };

                if (boxShown)
                {
                    textBox.Visible = false;
                }
                else
                {
                    textBox.Visible = true;
                    boxShown        = true;
                }

                ProgressSplit.Panel2.Controls.Add(textBox);

                JobDataView.Rows.Add(task, 0);
                var row = JobDataView.Rows[JobDataView.Rows.Count - 1];
                row.Tag = textBox;
                _rowByTaskName[task]               = row;
                _progressCellByTaskName[task]      = row.Cells[1] as DataGridViewProgressCell;
                _progressCellByTaskName[task].Text = "waiting";
            }
        }
Пример #2
0
        void processFile(string filename, Config config, ReaderList readers)
        {
            // read in data file
            using (var msdList = new MSDataList())
            {
                string msg = String.Format("Opening file \"{0}\" for read...", filename);
                if (LogUpdate != null)
                {
                    LogUpdate(msg, _info);
                }
                if (StatusUpdate != null)
                {
                    StatusUpdate(msg, ProgressBarStyle.Marquee, _info);
                }
                readers.read(filename, msdList);

                foreach (var msd in msdList)
                {
                    var outputFilename = config.outputFilename(filename, msd);

                    if (filename == outputFilename)
                    {
                        throw new ArgumentException("Output filepath is the same as input filepath");
                    }

                    if (StatusUpdate != null)
                    {
                        StatusUpdate("Waiting...", ProgressBarStyle.Marquee, _info);
                    }

                    // only one thread
                    lock (calculateSHA1Mutex)
                    {
                        if (LogUpdate != null)
                        {
                            LogUpdate("Calculating SHA1 checksum...", _info);
                        }
                        if (StatusUpdate != null)
                        {
                            StatusUpdate("Calculating SHA1 checksum...", ProgressBarStyle.Marquee, _info);
                        }
                        MSDataFile.calculateSHA1Checksums(msd);
                    }

                    if (LogUpdate != null)
                    {
                        LogUpdate("Processing...", _info);
                    }
                    if (StatusUpdate != null)
                    {
                        StatusUpdate("Processing...", ProgressBarStyle.Marquee, _info);
                    }

                    SpectrumListFactory.wrap(msd, config.Filters);

                    if ((msd.run.spectrumList == null) || msd.run.spectrumList.empty())
                    {
                        if ((msd.run.chromatogramList != null) && !msd.run.chromatogramList.empty())
                        {
                            msg = "Note: input contains only chromatogram data.";
                            switch (config.WriteConfig.format)
                            {
                            case MSDataFile.Format.Format_MZ5:
                            case MSDataFile.Format.Format_mzML:
                                break;

                            default:
                                msg += "  The selected output format can only represent spectra.  Consider using mzML instead.";
                                break;
                            }
                        }
                        else
                        {
                            msg = "Note: input contains no spectra or chromatogram data.";
                        }
                        if (LogUpdate != null)
                        {
                            LogUpdate(msg, _info);
                        }
                        if (StatusUpdate != null)
                        {
                            StatusUpdate(msg, ProgressBarStyle.Continuous, _info);
                        }
                    }

                    if (StatusUpdate != null && msd.run.spectrumList != null)
                    {
                        StatusUpdate(String.Format("Processing ({0} of {1})",
                                                   DataGridViewProgressCell.MessageSpecialValue.CurrentValue,
                                                   DataGridViewProgressCell.MessageSpecialValue.Maximum),
                                     ProgressBarStyle.Continuous, _info);
                    }

                    // write out the new data file
                    var ilr = new IterationListenerRegistry();
                    ilr.addListener(this, 100);
                    msg = String.Format("Writing \"{0}\"...", outputFilename);
                    if (LogUpdate != null)
                    {
                        LogUpdate(msg, _info);
                    }
                    if (StatusUpdate != null)
                    {
                        StatusUpdate(msg, ProgressBarStyle.Continuous, _info);
                    }
                    MSDataFile.write(msd, outputFilename, config.WriteConfig, ilr);
                    ilr.removeListener(this);
                }
            }
        }
Пример #3
0
        private void embedAllButton_Click(object sender, EventArgs e)
        {
            var    searchPath = new StringBuilder(searchPathTextBox.Text);
            string extensions = extensionsTextBox.Text;

            Application.UseWaitCursor = true;
            deleteAllButton.Enabled   = embedAllButton.Enabled = false;
            embeddedChanges           = true;

            try
            {
                // add location of original idpDBs to the search path
                var mergedFilepaths = session.CreateSQLQuery("SELECT DISTINCT Filepath FROM MergedFiles").List <string>();
                foreach (var filepath in mergedFilepaths)
                {
                    searchPath.AppendFormat(";{0}", System.IO.Path.GetDirectoryName(filepath));
                }
            }
            catch
            {
                // ignore if MergedFiles does not exist
            }

            var quantitationMethodBySource = new Dictionary <int, Embedder.QuantitationConfiguration>();
            var xicConfigBySource          = new Dictionary <int, Embedder.XICConfiguration> {
                { 0, _defaultXicConfig }
            };

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                int id     = (int)row.Cells[idColumn.Index].Value;
                var method = QuantitationMethodForRow(row.Index);

                if (IsLabelFree(method))
                {
                    xicConfigBySource[id]          = (Embedder.XICConfiguration)row.Cells[quantitationSettingsColumn.Index].Value;
                    quantitationMethodBySource[id] = new Embedder.QuantitationConfiguration(QuantitationMethod.LabelFree, _defaultIsobaricConfig.ToString());
                }
                else if (IsIsobaric(method))
                {
                    quantitationMethodBySource[id] = (Embedder.QuantitationConfiguration)row.Cells[quantitationSettingsColumn.Index].Value;
                }
            }

            okButton.Text   = "Cancel";
            EmbedInProgress = true;

            new Thread(() =>
            {
                try
                {
                    var ilr = new IterationListenerRegistry();
                    ilr.addListener(new EmbedderIterationListener(this), 1);

                    var tempFolder      = string.Empty;
                    var splitSourceList = new List <List <string> >();
                    if (quantitationMethodBySource.Any(x => IsLabelFree(x.Value.QuantitationMethod)) && xicConfigBySource.Any(x => x.Value.AlignRetentionTime))
                    {
                        tempFolder      = getTempFolder();
                        splitSourceList = GetRTAlignGroups();
                    }

                    string idpDbFilepath = session.Connection.GetDataSource();
                    if (embedScanTimeOnlyBox.Checked)
                    {
                        Embedder.EmbedScanTime(idpDbFilepath, searchPath.ToString(), extensions, quantitationMethodBySource, ilr);
                    }
                    else
                    {
                        Embedder.Embed(idpDbFilepath, searchPath.ToString(), extensions, quantitationMethodBySource, ilr);
                    }

                    if (quantitationMethodBySource.Any(x => IsLabelFree(x.Value.QuantitationMethod)))
                    {
                        BeginInvoke(new MethodInvoker(() => ModeandDefaultPanel.Visible = false));
                        if (xicConfigBySource.Any(x => x.Value.AlignRetentionTime))
                        {
                            try
                            {
                                RTAlignPreparations(splitSourceList, tempFolder);
                                foreach (var kvp in xicConfigBySource)
                                {
                                    kvp.Value.RTFolder = tempFolder;
                                }
                            }
                            catch (Exception rtError)
                            {
                                MessageBox.Show("Error: Cannot prepare RT alignment. Skipping to next stage." +
                                                Environment.NewLine + rtError.Message);
                                foreach (var kvp in xicConfigBySource)
                                {
                                    kvp.Value.AlignRetentionTime = false;
                                }
                            }
                        }

                        Embedder.EmbedMS1Metrics(idpDbFilepath, searchPath.ToString(), extensions, quantitationMethodBySource, xicConfigBySource, ilr);
                        if (!string.IsNullOrEmpty(tempFolder) && Directory.Exists(tempFolder))
                        {
                            Directory.Delete(tempFolder, true);
                        }
                        BeginInvoke(new MethodInvoker(() => ModeandDefaultPanel.Visible = true));
                    }
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("QuantitationConfiguration"))
                    {
                        string message = ex.Message.Replace("[QuantitationConfiguration] ", "");
                        message        = Char.ToUpper(message[0]) + message.Substring(1);
                        MessageBox.Show(message);
                    }
                    else if (ex.Message.Contains("no filepath"))
                    {
                        bool multipleMissingFilepaths = ex.Message.Contains("\n");
                        string missingFilepaths       = ex.Message.Replace("\n", "\r\n");
                        missingFilepaths = missingFilepaths.Replace("[embed] no", "No");
                        missingFilepaths = missingFilepaths.Replace("[embedScanTime] no", "No");
                        MessageBox.Show(missingFilepaths + "\r\n\r\nCheck that " +
                                        (multipleMissingFilepaths ? "these source files" : "this source file") +
                                        " can be found in the search path with one of the specified extensions.");
                    }
                    else
                    {
                        Program.HandleException(ex);
                    }
                }
                BeginInvoke(new MethodInvoker(() => Refresh()));
            }).Start();
        }
Пример #4
0
        private void embedAllButton_Click (object sender, EventArgs e)
        {
            var searchPath = new StringBuilder(searchPathTextBox.Text);
            string extensions = extensionsTextBox.Text;
            Application.UseWaitCursor = true;
            deleteAllButton.Enabled = embedAllButton.Enabled = false;
            embeddedChanges = true;

            try
            {
                // add location of original idpDBs to the search path
                var mergedFilepaths = session.CreateSQLQuery("SELECT DISTINCT Filepath FROM MergedFiles").List<string>();
                foreach (var filepath in mergedFilepaths)
                    searchPath.AppendFormat(";{0}", System.IO.Path.GetDirectoryName(filepath));
            }
            catch
            {
                // ignore if MergedFiles does not exist
            }

            var quantitationMethodBySource = new Dictionary<int, Embedder.QuantitationConfiguration>();
            var xicConfigBySource = new Dictionary<int, Embedder.XICConfiguration>{{0, _defaultXicConfig}};

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                int id = (int) row.Cells[idColumn.Index].Value;
                var method = QuantitationMethodForRow(row.Index);

                if (IsLabelFree(method))
                {
                    xicConfigBySource[id] = (Embedder.XICConfiguration) row.Cells[quantitationSettingsColumn.Index].Value;
                    quantitationMethodBySource[id] = new Embedder.QuantitationConfiguration(QuantitationMethod.LabelFree, _defaultIsobaricConfig.ToString());
                }
                else if (IsIsobaric(method))
                    quantitationMethodBySource[id] = (Embedder.QuantitationConfiguration) row.Cells[quantitationSettingsColumn.Index].Value;
            }

            okButton.Text = "Cancel";
            EmbedInProgress = true;

            new Thread(() =>
            {
                try
                {
                    var ilr = new IterationListenerRegistry();
                    ilr.addListener(new EmbedderIterationListener(this), 1);

                    var tempFolder = string.Empty;
                    var splitSourceList = new List<List<string>>();
                    if (quantitationMethodBySource.Any(x => IsLabelFree(x.Value.QuantitationMethod)) && xicConfigBySource.Any(x => x.Value.AlignRetentionTime))
                    {
                        tempFolder = getTempFolder();
                        splitSourceList = GetRTAlignGroups();
                    }

                    string idpDbFilepath = session.Connection.GetDataSource();
                    if (embedScanTimeOnlyBox.Checked)
                        Embedder.EmbedScanTime(idpDbFilepath, searchPath.ToString(), extensions, quantitationMethodBySource, ilr);
                    else
                        Embedder.Embed(idpDbFilepath, searchPath.ToString(), extensions, quantitationMethodBySource, ilr);

                    if (quantitationMethodBySource.Any(x => IsLabelFree(x.Value.QuantitationMethod)))
                    {
                        BeginInvoke(new MethodInvoker(() => ModeandDefaultPanel.Visible = false));
                        if (xicConfigBySource.Any(x => x.Value.AlignRetentionTime))
                        {
                            try
                            {
                                RTAlignPreparations(splitSourceList, tempFolder);
                                foreach (var kvp in xicConfigBySource)
                                    kvp.Value.RTFolder = tempFolder;
                            }
                            catch (Exception rtError)
                            {
                                MessageBox.Show("Error: Cannot prepare RT alignment. Skipping to next stage." +
                                                Environment.NewLine + rtError.Message);
                                foreach (var kvp in xicConfigBySource)
                                    kvp.Value.AlignRetentionTime = false;
                            }
                        }

                        Embedder.EmbedMS1Metrics(idpDbFilepath, searchPath.ToString(), extensions, quantitationMethodBySource, xicConfigBySource, ilr);
                        if (!string.IsNullOrEmpty(tempFolder) && Directory.Exists(tempFolder))
                            Directory.Delete(tempFolder,true);
                        BeginInvoke(new MethodInvoker(() => ModeandDefaultPanel.Visible = true));
                    }
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("QuantitationConfiguration"))
                    {
                        string message = ex.Message.Replace("[QuantitationConfiguration] ", "");
                        message = Char.ToUpper(message[0]) + message.Substring(1);
                        MessageBox.Show(message);
                    }
                    else if (ex.Message.Contains("no filepath"))
                    {
                        bool multipleMissingFilepaths = ex.Message.Contains("\n");
                        string missingFilepaths = ex.Message.Replace("\n", "\r\n");
                        missingFilepaths = missingFilepaths.Replace("[embed] no", "No");
                        missingFilepaths = missingFilepaths.Replace("[embedScanTime] no", "No");
                        MessageBox.Show(missingFilepaths + "\r\n\r\nCheck that " +
                                        (multipleMissingFilepaths ? "these source files" : "this source file") +
                                        " can be found in the search path with one of the specified extensions.");
                    }
                    else
                        Program.HandleException(ex);
                }
                BeginInvoke(new MethodInvoker(() => Refresh()));
            }).Start();
        }
Пример #5
0
        void processFile(string filename, Config config, ReaderList readers)
        {
            if (LogUpdate != null)
            {
                LogUpdate("Opening file...", _info);
            }
            if (StatusUpdate != null)
            {
                StatusUpdate("Opening file...", ProgressBarStyle.Marquee, _info);
            }

            // read in data file
            using (var msdList = new MSDataList())
            {
                readers.read(filename, msdList);

                foreach (var msd in msdList)
                {
                    var outputFilename = config.outputFilename(filename, msd);

                    if (filename == outputFilename)
                    {
                        throw new ArgumentException("Output filepath is the same as input filepath");
                    }

                    if (LogUpdate != null)
                    {
                        LogUpdate("Calculating SHA1 checksum...", _info);
                    }
                    if (StatusUpdate != null)
                    {
                        StatusUpdate("Calculating SHA1 checksum...", ProgressBarStyle.Marquee, _info);
                    }

                    // only one thread
                    lock (calculateSHA1Mutex)
                        MSDataFile.calculateSHA1Checksums(msd);

                    if (LogUpdate != null)
                    {
                        LogUpdate("Processing...", _info);
                    }
                    if (StatusUpdate != null)
                    {
                        StatusUpdate("Processing...", ProgressBarStyle.Marquee, _info);
                    }

                    SpectrumListFactory.wrap(msd, config.Filters);
                    if (StatusUpdate != null && msd.run.spectrumList != null)
                    {
                        StatusUpdate(String.Format("Processing ({0} of {1})",
                                                   DataGridViewProgressCell.MessageSpecialValue.CurrentValue,
                                                   DataGridViewProgressCell.MessageSpecialValue.Maximum),
                                     ProgressBarStyle.Continuous, _info);
                    }

                    // write out the new data file
                    IterationListenerRegistry ilr = null;
                    ilr = new IterationListenerRegistry();
                    ilr.addListener(this, 100);
                    MSDataFile.write(msd, outputFilename, config.WriteConfig, ilr);
                }
            }
        }
Пример #6
0
        void processFile(string filename, Config config, ReaderList readers)
        {
            // read in data file
            using (var msdList = new MSDataList())
            {
                string msg = String.Format("Opening file \"{0}\" for read...",filename);
                if (LogUpdate != null) LogUpdate(msg, _info);
                if (StatusUpdate != null) StatusUpdate(msg, ProgressBarStyle.Marquee, _info);
                readers.read(filename, msdList);

                foreach (var msd in msdList)
                {
                    var outputFilename = config.outputFilename(filename, msd);

                    if (filename == outputFilename)
                        throw new ArgumentException("Output filepath is the same as input filepath");

                    if (StatusUpdate != null) StatusUpdate("Waiting...", ProgressBarStyle.Marquee, _info);

                    // only one thread 
                    lock (calculateSHA1Mutex)
                    {
                        if (LogUpdate != null) LogUpdate("Calculating SHA1 checksum...", _info);
                        if (StatusUpdate != null) StatusUpdate("Calculating SHA1 checksum...", ProgressBarStyle.Marquee, _info);
                        MSDataFile.calculateSHA1Checksums(msd);
                    }

                    if (LogUpdate != null) LogUpdate("Processing...", _info);
                    if (StatusUpdate != null) StatusUpdate("Processing...", ProgressBarStyle.Marquee, _info);

                    SpectrumListFactory.wrap(msd, config.Filters);

                    if ((msd.run.spectrumList == null) || msd.run.spectrumList.empty())
                    {
                        if ((msd.run.chromatogramList != null) && !msd.run.chromatogramList.empty())
                        {
                            msg = "Note: input contains only chromatogram data.";
                            switch (config.WriteConfig.format)
                            {
                                case MSDataFile.Format.Format_MZ5:
                                case MSDataFile.Format.Format_mzML:
                                    break;
                                default:
                                    msg += "  The selected output format can only represent spectra.  Consider using mzML instead.";
                                    break;
                            }
                        }
                        else
                            msg = "Note: input contains no spectra or chromatogram data.";
                        if (LogUpdate != null) LogUpdate(msg, _info);
                        if (StatusUpdate != null) StatusUpdate(msg, ProgressBarStyle.Marquee, _info);
                    }

                    if (StatusUpdate != null && msd.run.spectrumList != null)
                        StatusUpdate(String.Format("Processing ({0} of {1})", 
                                                   DataGridViewProgressCell.MessageSpecialValue.CurrentValue,
                                                   DataGridViewProgressCell.MessageSpecialValue.Maximum),
                                     ProgressBarStyle.Continuous, _info);

                    // write out the new data file
                    var ilr = new IterationListenerRegistry();
                    ilr.addListener(this, 100);
                    msg = String.Format("Writing \"{0}\"...", outputFilename);
                    if (LogUpdate != null) LogUpdate(msg, _info);
                    if (StatusUpdate != null) StatusUpdate(msg, ProgressBarStyle.Marquee, _info);
                    MSDataFile.write(msd, outputFilename, config.WriteConfig, ilr);
                    ilr.removeListener(this);
                }
            }
        }
Пример #7
0
        private void loadRefSeqGeneMetadata()
        {
            #region Check for updated gene2protein database and download it

            if (!File.Exists(Path.Combine(Application.StartupPath, "gene2protein.db3")))
                throw new Exception("missing gene2protein.db3 mapping file");

            /*string g2pTimestamp = null;

            string g2pPath = Path.Combine(Application.UserAppDataPath, "gene2protein.db3");
            string g2pPathAlternate = Path.Combine(Application.StartupPath, "gene2protein.db3");
            var copyUserToAlternate = new ProcessStartInfo("cmd.exe", String.Format("/C copy /Y \"{0}\" \"{1}\"", g2pPath, g2pPathAlternate));
            copyUserToAlternate.CreateNoWindow = true;

            if (!File.Exists(g2pPath) && File.Exists(g2pPathAlternate))
                File.Copy(g2pPathAlternate, g2pPath);
            else if (File.Exists(g2pPath) && !File.Exists(g2pPathAlternate))
            {
                var p = Process.Start(copyUserToAlternate);
                p.WaitForExit();
                if (p.ExitCode == 1)
                    MessageBox.Show("Unable to copy gene2protein.db3 from user-specific path to application path:\r\n" +
                                    Path.GetDirectoryName(g2pPath) +
                                    "\r\nto\r\n" +
                                    Path.GetDirectoryName(g2pPathAlternate),
                                    "Unable to copy");
            }

            if (File.Exists(g2pPath))
            {
                // if the file exists, check its timestamp and compare it to the timestamp on the server
                using (var con = new SQLiteConnection(@"Data Source=" + g2pPath + ";Version=3"))
                {
                    try
                    {
                        con.Open();
                        g2pTimestamp = con.ExecuteQuery("SELECT Timestamp FROM About").Single().GetString(0);
                    }
                    catch (Exception e)
                    {
                        throw new Exception("error getting timestamp of current gene2protein database (\"" + g2pPath + "\"): " + e.Message, e);
                    }
                }

                string g2pURL = "http://fenchurch.mc.vanderbilt.edu/bin/g2p";
                string g2pTimestampURL = String.Format("{0}/G2P_TIMESTAMP", g2pURL);

                string latestTimestamp;
                lock (Program.WebClient)
                {
                    latestTimestamp = Program.WebClient.DownloadString(g2pTimestampURL).Trim();
                }

                if (g2pTimestamp.CompareTo(latestTimestamp) < 0)
                {
                    Invoke(new MethodInvoker(() =>
                    {
                        var form = new NewVersionForm("RefSeq Gene to Protein Database",
                                                      g2pTimestamp,
                                                      latestTimestamp,
                                                      String.Empty)
                                                      {
                                                          Owner = this,
                                                          StartPosition = FormStartPosition.CenterParent
                                                      };

                        if (form.ShowDialog() == DialogResult.Yes)
                        {
                            var oldG2Ptime = File.GetLastWriteTimeUtc(g2pPath);
                            string backupG2Pname = String.Format("{0}.{1}.bak", g2pPath, oldG2Ptime.ToString("yyyyMMddHHmm"));
                            try
                            {
                                if (!File.Exists(backupG2Pname))
                                    File.Copy(g2pPath, backupG2Pname);
                                File.Delete(g2pPath);

                                string g2pDatabaseURL = String.Format("{0}/gene2protein.db3", g2pURL);
                                lock (Program.WebClient)
                                {
                                    Program.WebClient.DownloadFile(g2pDatabaseURL, g2pPath);

                                    var p = Process.Start(copyUserToAlternate);
                                    p.WaitForExit();
                                    if (p.ExitCode == 1)
                                        MessageBox.Show("Unable to copy gene2protein.db3 from user-specific path to application path:\r\n" +
                                                        Path.GetDirectoryName(g2pPath) +
                                                        "\r\nto\r\n" +
                                                        Path.GetDirectoryName(g2pPathAlternate),
                                                        "Unable to copy");
                                }
                                g2pTimestamp = latestTimestamp;
                            }
                            catch (Exception)
                            {
                                if (!File.Exists(g2pPath))
                                    File.Move(backupG2Pname, g2pPath);
                            }
                        }
                        else
                            g2pTimestamp = null; // no update
                    }));
                }
                else
                    g2pTimestamp = null; // no update
            }
            else // downloading database for the first time (or it has been deleted)
            {
                string g2pURL = "http://fenchurch.mc.vanderbilt.edu/bin/g2p";
                string g2pDatabaseURL = String.Format("{0}/gene2protein.db3", g2pURL);
                lock (Program.WebClient)
                {
                    Program.WebClient.DownloadFile(g2pDatabaseURL, g2pPath);

                    var p = Process.Start(copyUserToAlternate);
                    p.WaitForExit();
                    if (p.ExitCode == 1)
                        MessageBox.Show("Unable to copy gene2protein.db3 from user-specific path to application path:\r\n" +
                                        Path.GetDirectoryName(g2pPath) +
                                        "\r\nto\r\n" +
                                        Path.GetDirectoryName(g2pPathAlternate),
                                        "Unable to copy");
                }
            }*/
            #endregion

            if (session == null)
                return;

            try
            {
                clearSession();
                var ilr = new IterationListenerRegistry();
                ilr.addListener(progressMonitor.GetIterationListenerProxy(), 1);
                Embedder.EmbedGeneMetadata(Text, ilr);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "embedding gene metadata failed");
            }

            OpenFiles(new List<string> { Text }, null);
        }
Пример #8
0
        public ProgressForm(IEnumerable<string> taskNames, IterationListenerRegistry ilr)
        {
            InitializeComponent();

            _progressCellByTaskName = new Dictionary<string, DataGridViewProgressCell>();
            _textBoxLogByTaskName = new Dictionary<string, TextBox>();
            _lastMessageByTaskName = new Dictionary<string, string>();
            _rowByTaskName = new Dictionary<string, DataGridViewRow>();
            _tasksDone = 0;

            _ilr = ilr;
            _ilProxy = new IterationListenerProxy() { form = this };
            _ilr.addListener(_ilProxy, 1000);

            var boxShown = false;

            foreach (var task in taskNames)
            {
                var textBox = _textBoxLogByTaskName[task] = new TextBox
                {
                    Text = String.Format("{0}{1}{0}Starting...{0}",
                                         Environment.NewLine,
                                         new string('-', 30)),
                    Dock = DockStyle.Fill,
                    Multiline = true,
                    ScrollBars = ScrollBars.Vertical
                };

                if (boxShown)
                    textBox.Visible = false;
                else
                {
                    textBox.Visible = true;
                    boxShown = true;
                }

                ProgressSplit.Panel2.Controls.Add(textBox);

                JobDataView.Rows.Add(task, 0);
                var row = JobDataView.Rows[JobDataView.Rows.Count - 1];
                row.Tag = textBox;
                _rowByTaskName[task] = row;
                _progressCellByTaskName[task] = row.Cells[1] as DataGridViewProgressCell;
                _progressCellByTaskName[task].Text = "waiting";
            }
        }