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); } }
private void Form1_Load(object sender, EventArgs e) { for (int i = 0; i < Constant.DEVICE_LIST.Length; i++) { this.comboBox_instrumentprefix.Items.Add(Constant.DEVICE_LIST[i]); } string filepath = localpath +@"\default.ts"; if(File.Exists(filepath)) { TsFileHelper tfh = new TsFileHelper(); //get tabs from file List<Tabcontent> tabs = tfh.getTabs(filepath); //delete all current pages this.tabControl1.TabPages.Clear(); //init tabindex this._tabindex = 0; //add tabpage from tabs if(tabs.Count!=0) { foreach (Tabcontent tab in tabs) { this.AddTab(tab); } } else { Tabcontent tc = new Tabcontent(); this.AddTab(tc); } } else { string filePath = System.IO.Path.Combine(localpath, "default.ts"); File.Create(filePath); Tabcontent tc = new Tabcontent(); this.AddTab(tc); } //load config Dictionary<string, string> tempaddr = new Dictionary<string, string>(); ConfigHelper ch = new ConfigHelper(); tempaddr = ch.GetAddr(); this.addr.SetAddress(tempaddr,this.link); //load color this.backcolor = ch.GetConfig("disp_backcolor"); if (this.backcolor != "") { this.dataDisplayBox.BackColor = ColorTranslator.FromHtml(this.backcolor); } this.forecolor = ch.GetConfig("disp_forecolor"); if (this.forecolor != "") { this.dataDisplayBox.ForeColor = ColorTranslator.FromHtml(this.forecolor); } //load font FontConverter fc = new FontConverter(); this.fontstyle = ch.GetConfig("disp_font"); if (this.fontstyle != "") { this.dataDisplayBox.Font = (Font)fc.ConvertFromString(this.fontstyle); } //init instrument status //initInstrumentStatus(this.addr, this.addr,true); this.initInstrumentStatusbyVisa32(this.addr, this.addr, true); foreach (Control ctl in this.SerialpropertyBox.Controls) { if (ctl.Name == "label_rruport") { ctl.Text = this.addr.RRU; } else if (ctl.Name == "label_rrubaud") { ctl.Text = this.addr.Baudrate_rru; } else if (ctl.Name == "label_serial2port") { ctl.Text = this.addr.SERIAL2; } else if (ctl.Name == "label_serial2baud") { ctl.Text = this.addr.Baudrate_com2; } } //ipep ipep = new IPEndPoint(IPAddress.Any, int.Parse(this.addr.Server_Port)); //log LogManager.LogFielPrefix = "RTT "; //string logPath = System.Environment.CurrentDirectory + @"\log\"; if (!Directory.Exists(logPath)) Directory.CreateDirectory(logPath); LogManager.LogPath = logPath; LogManager.WriteLog(LogFile.Trace, "RTT start, version is "+ Assembly.GetExecutingAssembly().GetName().Version.ToString()); //update if (!Directory.Exists(updatePath)) Directory.CreateDirectory(updatePath); if (!Directory.Exists(backuppath)) Directory.CreateDirectory(backuppath); //snapshot //_snapPath = System.Environment.CurrentDirectory + @"\snapshot\"; if (!Directory.Exists(_snapPath)) Directory.CreateDirectory(_snapPath); //rxevm if (!Directory.Exists(_rxevmPath)) Directory.CreateDirectory(_rxevmPath); //cmd queue process thread cmdProcessThread_run = true; _cmdProcessThread = new Thread(new ThreadStart(cmdProcessThread)); _cmdProcessThread.Start(); //cqEventSender.QueueChanged += new cmdQueueEventSender.QueueChangHandler(cmdProcessThread); this.Text = "RTT v" + Assembly.GetExecutingAssembly().GetName().Version.ToString(); this.label_terminal_IP.Text = this.addr.DU_IP; this.Show(); //this.InputBox.Focus(); }