Esempio n. 1
0
        private void Edit()
        {
            TabPage    curTabPage = GetCurTabPage();
            ScpiEditor scpiEditor = new ScpiEditor();

            TabData tabData = (TabData)curTabPage.Tag;

            tabData.state = State.Edit;

            //copy Scpilistview commands to scpi editor
            ScpiListView curScpiListView = (ScpiListView)curTabPage.Controls[0];

            string readStr   = "";
            string editorTxt = "";

            while (curScpiListView.GetNextLine(ref readStr) == true)
            {
                editorTxt += readStr + System.Environment.NewLine;
            }
            //TODO:remove the extra new line
            //editorTxt.Remove(editorTxt.LastIndexOf(System.Environment.NewLine));

            scpiEditor.Text = editorTxt;

            curTabPage.Controls.Remove(curScpiListView);
            curScpiListView.Dispose();
            curTabPage.Controls.Add(scpiEditor);
        }
Esempio n. 2
0
        private void FinishEdit()
        {
            TabPage    curTabPage = GetCurTabPage();
            ScpiEditor scpiEditor = (ScpiEditor)curTabPage.Controls[0];

            ScpiListView scpiListView = new ScpiListView();

            scpiListView.LoadFromEditor(scpiEditor);

            curTabPage.Controls.RemoveAt(0);
            scpiEditor.Dispose();
            curTabPage.Controls.Add(scpiListView);
        }
Esempio n. 3
0
        public void LoadFromEditor(ScpiEditor scpiEditor)
        {
            //clear the list view
            this.Items.Clear();

            //Create parser
            TextParser txtParser = new TextParser(scpiEditor, ParseStd.SFXSCPI);//SRIX:change pasrsetd:sfxscpi to variable

            //Load the file in the listview
            ScpiCommand scpiCmd = new ScpiCommand();

            while (txtParser.GetNextLine(ref scpiCmd))
            {
                AddLine(scpiCmd);
            }
        }
Esempio n. 4
0
        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();
            }
        }