예제 #1
0
파일: MainForm.cs 프로젝트: mahabara/RTT
        private void button_load_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ConfigHelper ch = new ConfigHelper();
            string defaultfilename = ch.GetConfig(Constant.CONFIG_TS_LOAD_PATH);
            ofd.InitialDirectory = defaultfilename;
            ofd.RestoreDirectory = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                fName = ofd.FileName;

                //this.dataDisplayBox.AppendText(fName + "\n");
                string fpath = fName.Replace(ofd.SafeFileName, "");
                //this.dataDisplayBox.AppendText(fpath + "\n");
                TsFileHelper tfh = new TsFileHelper();
                //get tabs from file
                List<Tabcontent> tabs = tfh.getTabs(fName);
                //delete all current pages
                this.tabControl1.TabPages.Clear();
                //init tabindex
                this._tabindex = 0;
                //add tabpage from tabs
                foreach(Tabcontent tab in tabs)
                {
                    this.AddTab(tab);
                }
                ch.UpdateConfig(Constant.CONFIG_TS_LOAD_PATH, fpath);

            }
        }
예제 #2
0
파일: MainForm.cs 프로젝트: mahabara/RTT
        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            //terminate cmdprocessthread
            cmdProcessThread_run = false;
            cmdQueue.Enqueue("");
            _waitcmdQueueEventHandle.Set();
            _cmdProcessThread.Abort();

            //stop RU Master
            //if(_TCA_ON)
            //    RumaControlClientFactory.StopDefaultTool();

            //save log
            //if (this._log)
                //LogManager.WriteLog(LogFile.Log, this.dataDisplayBox.Text);

            //save button ts file as default ts file
            string localpath = Application.StartupPath;
            string filepath = localpath + @"\default.ts";
            //get current tabs in mainform
            List<Tabcontent> tabs = GetCurrentTabs();

            TsFileHelper tfh = new TsFileHelper();
            tfh.SaveTab(tabs, filepath);

            //close session
            this.closVisa32sesn();
            this.closeVisacomsesn();

            //close serial port
            if(this._COM_RRU!=null)
            {
                Close_serial_port();
                this._COM_RRU.Dispose();
                this._COM_RRU = null;
            }
            //close serial 2
            if (this._COM2 != null)
            {
                Close_serial2_port();
                this._COM2.Dispose();
                this._COM2 = null;
            }

            //save color
            if (this.backcolor!="")
            {
                ConfigHelper ch = new ConfigHelper();
                ch.UpdateConfig("disp_backcolor", this.backcolor);
            }
            if (this.forecolor != "")
            {
                ConfigHelper ch = new ConfigHelper();
                ch.UpdateConfig("disp_forecolor", this.forecolor);
            }
            //save font
            if (this.fontstyle != "")
            {
                ConfigHelper ch = new ConfigHelper();
                ch.UpdateConfig("disp_font", this.fontstyle);
            }

            //close socket
            if(this.toolStripButton2.Checked==true)
            {
                try
                {
                    this._createServer.Abort();
                    newsock.Close();
                }
                catch
                {
                    WriteTraceText("Stop socket server failed.");
                }
                //this.RequestStopthread();
                //this._createServer.Join();
                //this._createServer = null;
            }
        }