private void FrmTrendConfig_Load(object sender, EventArgs e) { foreach (var item in CommonMethods.TrendName.Keys) { listTotalTrend.Add(item); } string str = inihelper.ReadIniData("已选曲线", "selectTrend", "", CommonMethods.FilePath); strList = str.Split(',').ToList(); for (int i = 0; i < strList.Count; i++) { if (strList[i] == "@") { strList.RemoveAt(i); } } listSelectTrend = strList; foreach (var item in listSelectTrend) { listTotalTrend.Remove(item); } listUnSelectTrend = listTotalTrend; listSelectTrend = listSelectTrend.ToList(); UpdateData(); }
private void FrmRealTrend_Load(object sender, EventArgs e) { mytimer = new Timer(); string str = inihelper.ReadIniData("已选实时曲线", "selectRealTrend", "", CommonMethods.FilePath); sqlArray = str.Split(','); if (sqlArray.Length == 1 && sqlArray[0] == "@") { return; } for (int i = 0; i < sqlArray.Length; i++) { listParameter.Add(CommonMethods.TrendName[sqlArray[i]].Name); } int a = 0; //设置Chart属性 chart_Trend.SeriesCount = listParameter.Count < 12 ? listParameter.Count : 12; chart_Trend.XDataType = StripChartX.XAxisDataType.TimeStamp; chart_Trend.TimeStampFormat = "HH:mm:ss"; chart_Trend.LegendVisible = true; chart_Trend.DisplayPoints = int.TryParse(inihelper.ReadIniData("已选实时显示点数", "selectRealTrend", "", CommonMethods.FilePath), out a)?a:100; for (int i = 0; i < sqlArray.Length; i++) { chart_Trend.Series[i].Name = sqlArray[i]; } //动态生成CheckBox for (int i = 0; i < sqlArray.Length; i++) { CheckBox chk = new CheckBox(); chk.AutoSize = true; chk.Name = "chk_" + i.ToString(); chk.Tag = i; chk.Checked = true; chk.ForeColor = chart_Trend.Series[i].Color; chk.Text = sqlArray[i]; chk.CheckedChanged += Chk_CheckedChanged; chk.Location = new Point(15, 25 + 46 * i); this.MainPanel.Controls.Add(chk); } mytimer.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["Interval"].ToString());; mytimer.Enabled = true; mytimer.Tick += Mytimer_Tick; }