示例#1
0
 public void ShowDataStreamWnd()
 {
     if ((DataStreamWnd == null) || (DataStreamWnd.IsDisposed))
     {
         DataStreamWnd           = new DataStreamWnd(this.ConsoleLogger);
         DataStreamWnd.MdiParent = this;
         DataStreamWnd.Show();
     }
     else
     {
         DataStreamWnd.Focus();
     }
 }
示例#2
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fdb    = new FolderBrowserDialog();
            DialogResult        result = fdb.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            projectFolder = fdb.SelectedPath;

            MainForm       form = (MainForm)this.MdiParent;
            ProgressBarWnd wnd  = new ProgressBarWnd();

            wnd.Text             = "Loading project...";
            wnd.ProgressBarStyle = ProgressBarStyle.Marquee;

            // create multiple logger
            List <ILogger> loggers = new List <ILogger>();

            loggers.Add(ConsoleLogger);
            loggers.Add(wnd);
            MultipleLogger logger = new MultipleLogger(loggers);

            logger.WriteLineInfo("Start loading project: " + projectFolder);

            wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker)
            {
                try
                {
                    Project = Project.Load(projectFolder, logger);
                }
                catch (OperationCanceledException)
                {
                    logger.WriteLineInfo("Cancelled!");
                    eWorker.Cancel = true;
                }
                catch (Exception ex)
                {
                    logger.WriteLineInfo("Error occured: " + ex.Message);
                    eWorker.Cancel = true;
                }
            };

            wnd.Worker.RunWorkerCompleted += delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker)
            {
                if (!eWorker.Cancelled)
                {
                    logger.WriteLineInfo("Project has been loaded!");
                    logger.WriteLineInfo("Project folder: " + this.Project.Folder);
                    logger.WriteLineInfo("No. of data streams: " + this.Project.DataStreams.Count());
                    MetadataBuilder.PrintSummary(this.Project, ConsoleLogger);
                    if (DataStreamWnd != null)
                    {
                        DataStreamWnd.UpdateUI();
                    }
                    form?.ReportProgress(100);
                    wnd.WriteProgress(100);
                    wnd.Close();
                }
            };

            wnd.ShowDialog();
        }