예제 #1
0
        void SessionStatusChanged(ME7LoggerSession.Statuses status)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new MethodInvoker(
                                delegate() { SessionStatusChanged(status); }));
                return;
            }

            txtSessionData.AppendText(string.Format("VISUALME7LOGGER STATUS: {0}\r\n", status));
            if (status == ME7LoggerSession.Statuses.Closed)
            {
                txtSessionData.AppendText("\r\n**********************VISUALME7LOGGER SESSION CLOSED**********************\r\n\r\n");
            }

            lblStatus.Text = string.Format("Log Status: {0} - Samples: {1}/sec{2}",
                                           status,
                                           session.SamplesPerSecond,
                                           session.CurrentSamplesPerSecond != session.SamplesPerSecond ? string.Format(" - Displaying: {0}/sec", session.CurrentSamplesPerSecond) : "");

            this.btnOpenCloseSession.Enabled = false;
            this.showDataGridViewToolStripMenuItem.Enabled = true;
            if (status == ME7LoggerSession.Statuses.Initialized)
            {
                this.Initialize();
            }
            else if (status == ME7LoggerSession.Statuses.Open)
            {
                refreshTimer.Start();

                this.btnOpenCloseSession.Enabled = true;
                this.btnOpenCloseSession.Text    = "Close Session";

                this.showDataGridViewToolStripMenuItem.Enabled =
                    this.spDataGrid.Visible        =
                        this.dataGridView1.Visible =
                            this.showDataGridViewToolStripMenuItem.Checked = false;
            }
            else if (status == ME7LoggerSession.Statuses.Closed)
            {
                refreshTimer.Stop();
                if (session.ExitCode > 0)
                {
                    MessageBox.Show(string.Format("Error! Exit Code:{0}{1}{2}", session.ExitCode, Environment.NewLine, session.ErrorText));
                }
                this.btnOpenCloseSession.Enabled = true;
                this.btnOpenCloseSession.Text    = "Open Session";
            }
            else if (status == ME7LoggerSession.Statuses.Paused)
            {
                refreshTimer.Stop();
            }
        }