//读入配置文件 private bool Init() { filestr = Globals.CGlobal.inifile;//inifile=路径+\Risun.ini //System.Windows.Forms.Application.StartupPath + @"\Risun.ini"; // if (System.IO.File.Exists(filestr) == false) { return(false); } iFile = new Globals.CIniIFile(filestr); try { strSql = @"Data Source=" + iFile.GetString("LOCALSERVER", "Server", ".") + ";Initial Catalog=SUNRISE10_CDB;" + "User ID=" + iFile.GetString("LOCALSERVER", "User", "sa") + ";Password="******"LOCALSERVER", "Pwd", ""); lid = iFile.GetString("PADSECTION", "LINE", "0"); stid = iFile.GetString("PADSECTION", "STATION", "0"); this.trackBar1.Value = iFile.GetInt("PADSECTION", "RefreshSec", 5); ShowAllScreen = iFile.GetString("PADSECTION", "ShowAllScreen", "").ToUpper(); //是否全屏 SeqKind = iFile.GetInt("PADSECTION", "SeqKind", 0); //工序类型 SeqName = iFile.GetString("PADSECTION", "SeqName", ""); //工序名称 MaxScreenFontSize = Convert.ToSingle(iFile.GetInt("PADSECTION", "MaxScreenFontSize", 20)); SplitterDistance = iFile.GetInt("PADSECTION", "SplitterDistance", 600); //分隔符位置 width = iFile.GetInt("PADSECTION", "width", 800); //资料宽 height = iFile.GetInt("PADSECTION", "height", 1000); //资料高 DS.videoSer = iFile.GetString("PADSECTION", "videoSer", "192.168.4.253"); DS.viedoPort = iFile.GetString("PADSECTION", "viedoPort", "8080"); } catch (Exception ex) { MessageBox.Show("配置文件出错"); return(false); } this.label7.Text = this.trackBar1.Value.ToString() + "秒"; if (lid == "0" || stid == "0") { MessageBox.Show("配置文件中站和线是未配置", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (!DS.TestConn(strSql)) { MessageBox.Show("连接数据库失败!请检查用户名、密码或网络等问题。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }