private void Start() { buttostart.Image = Properties.Resources.PausePressed; buttonStop.Enabled = true; TabPage curTabPage = GetCurTabPage(); TabData tabData = (TabData)curTabPage.Tag; tabData.state = State.Running; tabData.machineName = comboBoxInsName.Text; tabData.port = Convert.ToInt32(textBoxPort.Text); tabData.fileName = comboBoxFileName.Text; tabData.parseStd = ParseStd.TEK; //disable the input fields comboBoxFileName.Enabled = false; comboBoxInsName.Enabled = false; textBoxPort.Enabled = false; //ScpiListView scpiListView = GetCurrentListview(); //scpiListView.ResetScpiList(); try { Thread scpiTestThread = new Thread(this.ScpiRunner); tabData.scpiTestThread = scpiTestThread; //store the modified struct data back to the tag //curTabPage.Tag = tabData; scpiTestThread.Start(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { //Enable the input fields comboBoxFileName.Enabled = true; comboBoxInsName.Enabled = true; textBoxPort.Enabled = true; //set the play icon System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(formScpiGUI)); buttostart.Image = ((System.Drawing.Image)(resources.GetObject("buttostart.Image"))); buttonStop.Enabled = false; } }
public void LoadFromFile(TabData tabData) { //clear the list view this.Items.Clear(); //Create parser TextParser txtParser = new TextParser(tabData.fileName, tabData.parseStd); //Load the file in the listview ScpiCommand scpiCmd = new ScpiCommand(); while (txtParser.GetNextLine(ref scpiCmd)) { AddLine(scpiCmd); } }
private void LoadFile(string fileName) { TabPage curTabPage = GetCurTabPage(); TabData tabData = (TabData)curTabPage.Tag; tabData.fileName = fileName; tabData.parseStd = ParseStd.TEK; tabData.state = State.View; curTabPage.Text = System.IO.Path.GetFileName(fileName); ScpiListView scpiListView = (ScpiListView)tabControl.SelectedTab.Controls[0]; scpiListView.LoadFromFile(tabData); }
private void newTab_Click(object sender, EventArgs e) { //Add tab page TabPage newTabPage = new TabPage(); ScpiListView newListView = new ScpiListView(); newTabPage.Controls.Add(newListView); TabData tabData = new TabData(); newTabPage.Tag = tabData; tabControl.Controls.Add(newTabPage); //Set focus tabControl.SelectedTab = newTabPage; //Clear Details comboBoxFileName.Text = ""; }
private void buttonSave_Click(object sender, EventArgs e) { TabPage curTabPage = GetCurTabPage(); TabData tabData = (TabData)curTabPage.Tag; if (State.Edit == tabData.state) { ScpiEditor scpiEditor = (ScpiEditor)curTabPage.Controls[0]; //Use StreamWriter class. System.IO.StreamWriter sw = new System.IO.StreamWriter(tabData.fileName); //Use writeline methode to write the text and //in para.. put your text, i have used textBox1's text sw.WriteLine(scpiEditor.Text); //always close your stream sw.Close(); } }
private void waitTimer_Tick(object sender, EventArgs e) { if (waitProgressBar.Value < waitProgressBar.Maximum) { waitProgressBar.Value++; } else { this.RemoveEmbeddedControl(waitProgressBar); waitTimer.Stop(); ListViewItem curItem = this.Items[m_ParserPointer - 1]; curItem.BackColor = COLOR_COMPLETED; //waitProgressBar.Visible = false; waitProgressBar.Value = 0; TabPage parentTab = (TabPage)this.Parent; TabData tabData = (TabData)parentTab.Tag; tabData.scpiTestThread.Resume(); } }
/// <summary> /// launches a thred that runs scpitest. scpitest needs to be tun in a /// seperate thread to enable pause and breakpoint features /// </summary> private void ScpiRunner() { //Always get the curtabpage and work on it instead of directly //working on tabControl.SelectedTab. This helps if the selected //tab chnages evne before the function gets completed //TabPage curTabPage = tabControl.SelectedTab; //ScpiListView curScpilistView = (ScpiListView)curTabPage.Controls[0]; ScpiListView curScpilistView = (ScpiListView)this.Invoke(new GetCurrentListviewDelegate(this.GetCurrentListview), null); TabData tabData = (TabData)this.Invoke(new GetCurTabDataDelegate(this.GetCurTabData), null); try { //AutoResetEvent syncEvent = new AutoResetEvent(false); TextParser parser = new TextParser(curScpilistView, ParseStd.TEK); ScpiTest scpiTest = new ScpiTest(parser, curScpilistView, tabData.machineName, tabData.port); //tabData.syncEvent = syncEvent; scpiTest.Run(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void ShowWait(ScpiCommand scpiCmd) { if (this.InvokeRequired) { this.BeginInvoke(new ShowWaitDelegate(this.ShowWait), new object[] { scpiCmd }); } else { string cmd = scpiCmd.Str; cmd = cmd.Remove(0, 2); cmd.Trim(); int wait = Convert.ToInt32(cmd); waitProgressBar.Maximum = wait; waitProgressBar.Visible = true; // pg.s //for (int i = 0; i < wait; i++) //{ // //when the output of scpugui is directed to text file // //Invalid handle error appears when drawtextprogressbar is first called // //And scpigui stops there. // System.Threading.Thread.Sleep(1000); // pg.Value = i; //} this.AddEmbeddedControl(waitProgressBar, HDR_RESULT, m_ParserPointer - 1); TabPage parentTab = (TabPage)this.Parent; TabData tabData = (TabData)parentTab.Tag; tabData.scpiTestThread.Suspend(); waitTimer.Start(); } }
private void buttonStart_Click(object sender, EventArgs e) { TabData tabData = (TabData)tabControl.SelectedTab.Tag; switch (tabData.state) { case State.Edit: FinishEdit(); Start(); break; case State.View: Start(); break; case State.RunFinished: LoadFile(tabData.fileName); Start(); break; // case State.Running: // Pause(); break; } }