C#讀取txt檔案並畫圖
tools.cs
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using ZedGraph; namespace HistoryLine { class tools { static string path = @"C:\"; string[] lines = File.ReadAllLines(path + "2.txt"); //讀入所有行,放入陣列 private StreamReader sr; private StreamReader getStream() { string path = @"C:\2.txt"; FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read); this.sr= new StreamReader(file); // StreamReader sr = new StreamReader(file); return this.sr; } private double GetRMS(PointPairList dayList) //獲取某天的均方根值,即有效值 { double sum = 0; //求dayList集合中資料的均方根值 for (int i = 0; i < dayList.Count; i++) { sum += (dayList[i].Y) * (dayList[i].Y); //求平方和 } return Math.Sqrt(sum / dayList.Count); } public void getDatAll(PointPairList list, int lie) //獲取全部資料 { String line = getStream().ReadLine(); while ((line = sr.ReadLine()) != "") { string[] linesplit = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);//每行資料分割 double X = (double)new XDate((DateTime.Parse(linesplit[linesplit.Length - 2]))); //提取X點 double Y = double.Parse(linesplit[lie]); list.Add(X, Y); } getStream().Close(); } public void getpartdat(PointPairList list1, int lie, string starDate, string endDate) //獲取部分資料 { String line = getStream().ReadLine(); double time1 = (double)new XDate((DateTime.Parse(starDate))); double time2 = (double)new XDate((DateTime.Parse(endDate))); while ((line = sr.ReadLine()) != "") { string[] linesplit = line.Split(new char[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);//每行資料分割 string[] linesplit1 = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);//每行資料分割 double X = (double)new XDate((DateTime.Parse(linesplit[linesplit.Length - 3]))); //提取X點,時間型轉成double型 double X1 = (double)new XDate((DateTime.Parse(linesplit1[linesplit1.Length - 2]))); //提取X點,時間型轉成double型 if (X < time1) { } else if (X <= time2) { double Y = double.Parse(linesplit[lie]); list1.Add(X1, Y); } else { break; } } getStream().Close(); } private void sortdate(PointPairList list2) //對一天的資料排序 { for (int j = 0; j < list2.Count - 1; j++) //氣泡排序 { for (int k = 0; k < list2.Count - 1 - j; k++) { if (list2[k].Y > list2[k + 1].Y) { double tmp1 = list2[k].Y; list2[k].Y = list2[k + 1].Y; list2[k + 1].Y = tmp1; } } } } private Tuple<double,double>Exec(PointPairList list2) //對一天的資料求最大值,最小值 { double tmp = list2[0].Y; double tmp1 = list2[0].Y; for (int j = 1; j < list2.Count - 1; j++) { if(list2[j].Y> tmp) { tmp = list2[j].Y; //最大值 } if(list2[j].Y < tmp1) { tmp1 = list2[j].Y; //最小值 } } Tuple<double, double> tup = new Tuple<double, double>(tmp, tmp1); return tup; } public void getPeakVaule(PointPairList list, int lie) //獲取峰值資料 { double X = 0; double Y = 0; double y2 = 0; PointPairList list2 = new PointPairList();//一天的資料 String line; line = getStream().ReadLine(); line = sr.ReadLine(); string[] lines1 = line.Split(new char[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);//第二行解析 XDate x1 = new XDate((DateTime.Parse(lines1[lines1.Length - 3]))); double tmp = (double)x1; //提取第二行的X點時間點 Y = double.Parse(lines1[lie]); list2.Add(tmp, Y); while ((line = sr.ReadLine()) != "") { string[] linesplit = line.Split(new char[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);//每行資料分割 XDate x = new XDate((DateTime.Parse(linesplit[linesplit.Length - 3]))); X = (double)x; //提取X點 Y = double.Parse(linesplit[lie]); //提取Y點 if (X == tmp) { list2.Add(X, Y); } if (X != tmp) { //峰值 y2 = Exec(list2).Item1; list.Add(tmp, y2); list2.Clear(); list2.Add(X, Y); tmp = X; //tmp值改變 } } //最後一天的峰值 y2 = Exec(list2).Item1; list.Add(tmp, y2); list2.Clear(); } public void getBeatValue(PointPairList list, int lie) //獲取跳動值 { PointPairList list2 = new PointPairList();//一天的資料 double X, Y, y2; String line; line = getStream().ReadLine(); line = sr.ReadLine(); string[] lines1 = line.Split(new char[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);//第二行解析 XDate x1 = new XDate((DateTime.Parse(lines1[lines1.Length - 3]))); double tmp = (double)x1; //提取第二行的X點時間點 Y = double.Parse(lines1[lie]); list2.Add(tmp, Y); while ((line = sr.ReadLine()) != "") { string[] linesplit = line.Split(new char[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);//每行資料分割 XDate x = new XDate((DateTime.Parse(linesplit[linesplit.Length - 3]))); X = (double)x; //提取X點 Y = double.Parse(linesplit[lie]); //提取Y點 if (X == tmp) { list2.Add(X, Y); } if (X != tmp) { //跳動值 y2 = Exec(list2).Item1 - Exec(list2).Item2; list.Add(tmp, y2); list2.Clear(); list2.Add(X, Y); tmp = X; //tmp值改變 } } //最後一天的跳動值 y2 = Exec(list2).Item1 - Exec(list2).Item2; list.Add(tmp, y2); list2.Clear(); } public void getEffectValue(PointPairList list, int lie) //獲取有效值資料 { PointPairList list2 = new PointPairList();//一天的資料 double X, Y, y2; String line; line = getStream().ReadLine(); line = sr.ReadLine(); string[] lines1 = line.Split(new char[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);//第二行解析 XDate x1 = new XDate((DateTime.Parse(lines1[lines1.Length - 3]))); double tmp = (double)x1; //提取第二行的X點時間點 Y = double.Parse(lines1[lie]); list2.Add(tmp, Y); while ((line = sr.ReadLine()) != "") { string[] linesplit = line.Split(new char[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);//每行資料分割 XDate x = new XDate((DateTime.Parse(linesplit[linesplit.Length - 3]))); X = (double)x; //提取X點 Y = double.Parse(linesplit[lie]); //提取Y點 if (X == tmp) { list2.Add(X, Y); } if (X != tmp) { //有效值 y2 = GetRMS(list2); list.Add(tmp, y2); list2.Clear(); list2.Add(X, Y); tmp = X; //tmp值改變 } } //最後一天的有效值 y2 = GetRMS(list2); list.Add(tmp, y2); list2.Clear(); } } }
CreatGrap.cs
using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using ZedGraph; namespace HistoryLine { class CreatGrap { GraphPane myPane; public GraphPane getPane() { return this.myPane; } public void CreatGraphics(ZedGraphControl zgc, PointPairList list1, string format, DateUnit majorunit) { myPane = zgc.GraphPane; myPane.CurveList.Clear(); //將面板上的控制元件清除 myPane.GraphObjList.Clear(); //標題、x,y軸標籤設定之前清除 zgc.IsEnableVZoom = false; //垂直軸不縮放 zgc.IsShowPointValues = true; //顯示點的座標 myPane.XAxis.Scale.MajorStepAuto = true; //自動設定大刻度步長 myPane.XAxis.Scale.MinorStepAuto = true; //自動設定小刻度步長 //myPane.XAxis.Scale.Format = "yyyy-MM-dd "; //橫軸格式 myPane.XAxis.Scale.Format = format; //橫軸格式 //myPane.XAxis.Scale.MajorUnit = DateUnit.Day; //大刻度步長單位 myPane.XAxis.Scale.MajorUnit = majorunit; //大刻度步長單位 myPane.XAxis.Type = AxisType.DateAsOrdinal; //資料顯示方式 myPane.XAxis.MajorGrid.IsVisible = true; //設定虛線 myPane.XAxis.MajorGrid.Color = Color.Green; //虛線的顏色 zgc.GraphPane.CurveList.Clear(); LineItem myCurve = myPane.AddCurve("", list1, Color.Red, SymbolType.None); //填充圖表顏色 // myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f); //畫到zedGraphControl1控制元件中,此句必加 zgc.AxisChange(); } } }
框架主程式
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ZedGraph; namespace HistoryLine { public partial class Form2 : Form { int row;//列數 CreatGrap graphic = new CreatGrap();//建立畫圖類物件 tools tool = new tools();//建立工具類物件 public Form2() { InitializeComponent(); } private void empty() { //zedGraphControl1.GraphPane.XAxis.Title.Text = "X Axis"; //X軸標題 //zedGraphControl1.GraphPane.YAxis.Title.Text = "Y Axis"; //zedGraphControl1.GraphPane.Title.Text = "Title"; //zedGraphControl1.GraphPane.CurveList.Clear(); //zedGraphControl1.GraphPane.GraphObjList.Clear(); //zedGraphControl1.AxisChange(); //zedGraphControl1.Refresh(); comboBox1.Items.Clear(); comboBox1.Text = "請選擇曲線型別"; } private void zedGraphControl1_Load(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { // comboBox1.SelectedIndex =0;//預設顯示第一個選擇項 } private void getAllDate(int row) { PointPairList list1 = new PointPairList(); tool.getDatAll(list1, row); //獲取第n列的全部資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().XAxis.Title.Text = "年/月/日"; //X軸標題 switch (row) { case 0: graphic.getPane().Title.Text = "4#氣缸振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 1: graphic.getPane().Title.Text = "3#氣缸振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 2: graphic.getPane().Title.Text = "2#氣缸振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 3: graphic.getPane().Title.Text = "1#氣缸振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 4: graphic.getPane().Title.Text = "1#中體振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 5: graphic.getPane().Title.Text = "2#中體振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 6: graphic.getPane().Title.Text = "3#中體振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 7: graphic.getPane().Title.Text = "4#中體振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 8: graphic.getPane().Title.Text = "1#中體噪聲曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓/Pa"; //Y軸標題 break; case 9: graphic.getPane().Title.Text = "2#中體噪聲曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓/Pa"; //Y軸標題 break; case 10: graphic.getPane().Title.Text = "3#中體噪聲曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓/Pa"; //Y軸標題 break; case 11: graphic.getPane().Title.Text = "4#中體噪聲曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓/Pa"; //Y軸標題 break; case 12: graphic.getPane().Title.Text = "1#填料溫度曲線"; //標題 graphic.getPane().YAxis.Title.Text = "溫度/℃"; //Y軸標題 break; case 13: graphic.getPane().Title.Text = "2#填料溫度曲線"; //標題 graphic.getPane().YAxis.Title.Text = "溫度/℃"; //Y軸標題 break; case 14: graphic.getPane().Title.Text = "3#填料溫度曲線"; //標題 graphic.getPane().YAxis.Title.Text = "溫度/℃"; //Y軸標題 break; case 15: graphic.getPane().Title.Text = "4#填料溫度曲線"; //標題 graphic.getPane().YAxis.Title.Text = "溫度/℃"; //Y軸標題 break; case 16: graphic.getPane().Title.Text = "1#活塞桿水平沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 17: graphic.getPane().Title.Text = "2#活塞桿水平沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 18: graphic.getPane().Title.Text = "3#活塞桿水平沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 19: graphic.getPane().Title.Text = "4#活塞桿水平沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 20: graphic.getPane().Title.Text = "1#活塞桿垂直沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 21: graphic.getPane().Title.Text = "2#活塞桿垂直沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 22: graphic.getPane().Title.Text = "3#活塞桿垂直沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 23: graphic.getPane().Title.Text = "4#活塞桿垂直沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 24: graphic.getPane().Title.Text = "1#曲軸水平振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 25: graphic.getPane().Title.Text = "2#曲軸水平振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 26: graphic.getPane().Title.Text = "1#曲軸箱振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 27: graphic.getPane().Title.Text = "1#曲軸垂直振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 28: graphic.getPane().Title.Text = "2#曲軸垂直振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 29: graphic.getPane().Title.Text = "2#曲軸箱振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 30: graphic.getPane().Title.Text = "轉速報警曲線"; //標題 graphic.getPane().YAxis.Title.Text = "轉速"; //Y軸標題 break; case 31: graphic.getPane().Title.Text = "相位報警曲線"; //標題 graphic.getPane().YAxis.Title.Text = "相位"; //Y軸標題 break; default: break; } zedGraphControl1.Refresh(); } private void button1_Click(object sender, EventArgs e) //顯示部分資料 { PointPairList list1 = new PointPairList(); string starDate = dateTimePicker1.Value.ToString("yyyy-MM-dd"); string endDate = dateTimePicker2.Value.ToString("yyyy-MM-dd"); tool.getpartdat(list1, row, starDate, endDate); //獲取第n列的部分資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().XAxis.Title.Text = "年/月/日"; //X軸標題 switch (row) { case 0: graphic.getPane().Title.Text = "4#氣缸振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度 / g"; //Y軸標題 break; case 1: graphic.getPane().Title.Text = "3#氣缸振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 2: graphic.getPane().Title.Text = "2#氣缸振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 3: graphic.getPane().Title.Text = "1#氣缸振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 4: graphic.getPane().Title.Text = "1#中體振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 5: graphic.getPane().Title.Text = "2#中體振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 6: graphic.getPane().Title.Text = "3#中體振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 7: graphic.getPane().Title.Text = "4#中體振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 8: graphic.getPane().Title.Text = "1#中體噪聲曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓/Pa"; //Y軸標題 break; case 9: graphic.getPane().Title.Text = "2#中體噪聲曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓/Pa"; //Y軸標題 break; case 10: graphic.getPane().Title.Text = "3#中體噪聲曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓/Pa"; //Y軸標題 break; case 11: graphic.getPane().Title.Text = "4#中體噪聲曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓/Pa"; //Y軸標題 break; case 12: graphic.getPane().Title.Text = "1#填料溫度曲線"; //標題 graphic.getPane().YAxis.Title.Text = "溫度/℃"; //Y軸標題 break; case 13: graphic.getPane().Title.Text = "2#填料溫度曲線"; //標題 graphic.getPane().YAxis.Title.Text = "溫度/℃"; //Y軸標題 break; case 14: graphic.getPane().Title.Text = "3#填料溫度曲線"; //標題 graphic.getPane().YAxis.Title.Text = "溫度/℃"; //Y軸標題 break; case 15: graphic.getPane().Title.Text = "4#填料溫度曲線"; //標題 graphic.getPane().YAxis.Title.Text = "溫度/℃"; //Y軸標題 break; case 16: graphic.getPane().Title.Text = "1#活塞桿水平沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 17: graphic.getPane().Title.Text = "2#活塞桿水平沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 18: graphic.getPane().Title.Text = "3#活塞桿水平沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 19: graphic.getPane().Title.Text = "4#活塞桿水平沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 20: graphic.getPane().Title.Text = "1#活塞桿垂直沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 21: graphic.getPane().Title.Text = "2#活塞桿垂直沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 22: graphic.getPane().Title.Text = "3#活塞桿垂直沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 23: graphic.getPane().Title.Text = "4#活塞桿垂直沉降位移曲線"; //標題 graphic.getPane().YAxis.Title.Text = "位移/mm"; //Y軸標題 break; case 24: graphic.getPane().Title.Text = "1#曲軸水平振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 25: graphic.getPane().Title.Text = "2#曲軸水平振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 26: graphic.getPane().Title.Text = "1#曲軸箱振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 27: graphic.getPane().Title.Text = "1#曲軸垂直振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 28: graphic.getPane().Title.Text = "2#曲軸垂直振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 29: graphic.getPane().Title.Text = "2#曲軸箱振動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度/g"; //Y軸標題 break; case 30: graphic.getPane().Title.Text = "轉速報警曲線"; //標題 graphic.getPane().YAxis.Title.Text = "轉速"; //Y軸標題 break; case 31: graphic.getPane().Title.Text = "相位報警曲線"; //標題 graphic.getPane().YAxis.Title.Text = "相位"; //Y軸標題 break; default: break; } zedGraphControl1.Refresh(); } private void zedGraphControl1_MouseMove(object sender, MouseEventArgs e) //畫豎線 { Graphics gc = zedGraphControl1.CreateGraphics(); Pen pen = new Pen(Color.Blue); pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; RectangleF rect = zedGraphControl1.GraphPane.Chart.Rect; //確保在畫圖區域 if (rect.Contains(e.Location)) { zedGraphControl1.Refresh(); gc.DrawLine(pen, e.X, rect.Top, e.X, rect.Bottom); } } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { PointPairList list1 = new PointPairList(); switch (row) { case 0: //"4#氣缸振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "4#氣缸振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "4#氣缸振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 1: //"3#氣缸振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "3#氣缸振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "3#氣缸振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 2: //"2#氣缸振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#氣缸振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#氣缸振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 3: //"1#氣缸振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#氣缸振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#氣缸振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 4: //"1#中體振動曲線"; //PointPairList list1 = new PointPairList(); if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#中體振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#中體振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 5: //"2#中體振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#中體振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#中體振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 6: //"3#中體振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "3#中體振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "3#中體振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 7: //"4#中體振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "4#中體振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "4#中體振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 8: //"1#中體噪聲曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#中體噪聲有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓有效值/Pa"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#中體噪聲峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓峰值/Pa"; } break; case 9: //"2#中體噪聲曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#中體噪聲有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓有效值/Pa"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#中體噪聲峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓峰值/Pa"; } break; case 10: //"3#中體噪聲曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "3#中體噪聲有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓有效值/Pa"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "3#中體噪聲峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓峰值/Pa"; } break; case 11: //"4#中體噪聲曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "4#中體噪聲有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓有效值/Pa"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "4#中體噪聲峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "聲壓峰值/Pa"; } break; case 12: //"1#填料溫度曲線" break; case 13: //"2#填料溫度曲線" break; case 14: //"3#填料溫度曲線" break; case 15: //"4#填料溫度曲線" break; case 16: //"1#活塞桿水平沉降位移曲線" if (comboBox1.SelectedIndex == 0) { tool.getBeatValue(list1, row);//獲取第n列的跳動資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#活塞桿水平沉降位移跳動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "跳動/mm"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#活塞桿水平沉降位移峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "峰值/mm"; } break; case 17: //"2#活塞桿水平沉降位移曲線" if (comboBox1.SelectedIndex == 0) { tool.getBeatValue(list1, row);//獲取第n列的跳動資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#活塞桿水平沉降位移跳動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "跳動/mm"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#活塞桿水平沉降位移峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "峰值/mm"; } break; case 18: // "3#活塞桿水平沉降位移曲線" if (comboBox1.SelectedIndex == 0) { tool.getBeatValue(list1, row);//獲取第n列的跳動資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "3#活塞桿水平沉降位移跳動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "跳動/mm"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "3#活塞桿水平沉降位移峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "峰值/mm"; } break; case 19: //"4#活塞桿水平沉降位移曲線" if (comboBox1.SelectedIndex == 0) { tool.getBeatValue(list1, row);//獲取第n列的跳動資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "4#活塞桿水平沉降位移跳動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "跳動/mm"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "4#活塞桿水平沉降位移峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "峰值/mm"; } break; case 20: //"1#活塞桿垂直沉降位移曲線" if (comboBox1.SelectedIndex == 0) { tool.getBeatValue(list1, row);//獲取第n列的跳動資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#活塞桿垂直沉降位移跳動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "跳動/mm"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#活塞桿垂直沉降位移峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "峰值/mm"; } break; case 21: //"2#活塞桿垂直沉降位移曲線" if (comboBox1.SelectedIndex == 0) { tool.getBeatValue(list1, row);//獲取第n列的跳動資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#活塞桿垂直沉降位移跳動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "跳動/mm"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#活塞桿垂直沉降位移峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "峰值/mm"; } break; case 22: //"3#活塞桿垂直沉降位移曲線" if (comboBox1.SelectedIndex == 0) { tool.getBeatValue(list1, row);//獲取第n列的跳動資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "3#活塞桿垂直沉降位移跳動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "跳動/mm"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "3#活塞桿垂直沉降位移峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "峰值/mm"; } break; case 23: //"4#活塞桿垂直沉降位移曲線" if (comboBox1.SelectedIndex == 0) { tool.getBeatValue(list1, row);//獲取第n列的跳動資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "4#活塞桿垂直沉降位移跳動曲線"; //標題 graphic.getPane().YAxis.Title.Text = "跳動/mm"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "4#活塞桿垂直沉降位移峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "峰值/mm"; } break; case 24: //"1#曲軸水平振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#曲軸水平振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#曲軸水平振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 25: //"2#曲軸水平振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#曲軸水平振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#曲軸水平振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 26: //"1#曲軸箱振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#曲軸箱振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#曲軸箱振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 27: //"1#曲軸垂直振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#曲軸垂直振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "1#曲軸垂直振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 28: //"2#曲軸垂直振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#曲軸垂直振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#曲軸垂直振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 29: //"2#曲軸箱振動曲線" if (comboBox1.SelectedIndex == 0) { tool.getEffectValue(list1, row);//獲取第n列的有效值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#曲軸箱振動有效值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度有效值/g"; } if (comboBox1.SelectedIndex == 1) { tool.getPeakVaule(list1, row);//獲取第n列的峰值資料 graphic.CreatGraphics(zedGraphControl1, list1, "yyyy-MM-dd ", DateUnit.Day); graphic.getPane().Title.Text = "2#曲軸箱振動峰值曲線"; //標題 graphic.getPane().YAxis.Title.Text = "加速度峰值/g"; } break; case 30: //"轉速報警曲線" break; case 31: //"相位報警曲線" break; default: break; } graphic.getPane().XAxis.Title.Text = "年/月/日"; //X軸標題 zedGraphControl1.Refresh(); } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { switch (listBox1.SelectedIndex) { case 0: row = 0; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "4#氣缸振動有效值曲線", "4#氣缸振動峰值曲線" }); break;//選擇第一列 case 1: row = 1; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "3#氣缸振動有效值曲線", "3#氣缸振動峰值曲線" }); break;//選擇第二列 case 2: row = 2; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "2#氣缸振動有效值曲線", "2#氣缸振動峰值曲線" }); break;//選擇第三列 case 3: row = 3; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "1#氣缸振動有效值曲線", "1#氣缸振動峰值曲線" }); break;// case 4: row = 4; empty();//清空圖表和下拉框 getAllDate(row); comboBox1.Items.AddRange(new object[] { "1#中體振動有效值曲線", "1#中體振動峰值曲線" }); break; case 5: row = 5; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "2#中體振動有效值曲線", "2#中體振動峰值曲線" }); break; case 6: row = 6; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "3#中體振動有效值曲線", "3#中體振動峰值曲線" }); break; case 7: row = 7; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "4#中體振動有效值曲線", "4#中體振動峰值曲線" }); break; case 8: row = 8; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "1#中體噪聲有效值曲線", "1#中體噪聲峰值曲線" }); break; case 9: row = 9; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "2#中體噪聲有效值曲線", "2#中體噪聲峰值曲線" }); break;// case 10: row = 10; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "3#中體噪聲有效值曲線", "3#中體噪聲峰值曲線" }); break; case 11: row = 11; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "4#中體噪聲有效值曲線", "4#中體噪聲峰值曲線" }); break; case 12: row = 12; empty(); getAllDate(row); break; case 13: row = 13; empty(); getAllDate(row); break; case 14: row = 14; empty(); getAllDate(row); break; case 15: row = 15; empty(); getAllDate(row); break;// case 16: row = 16; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "1#活塞桿水平沉降位移跳動曲線", "1#活塞桿水平沉降位移峰值曲線" }); break; case 17: row = 17; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "2#活塞桿水平沉降位移跳動曲線", "2#活塞桿水平沉降位移峰值曲線" }); break; case 18: row = 18; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "3#活塞桿水平沉降位移跳動曲線", "3#活塞桿水平沉降位移峰值曲線" }); break; case 19: row = 19; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "4#活塞桿水平沉降位移跳動曲線", "4#活塞桿水平沉降位移峰值曲線" }); break; case 20: row = 20; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "1#活塞桿垂直沉降位移跳動曲線", "1#活塞桿垂直沉降位移峰值曲線" }); break; case 21: row = 21; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "2#活塞桿垂直沉降位移跳動曲線", "2#活塞桿垂直沉降位移峰值曲線" }); break;// case 22: row = 22; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "3#活塞桿垂直沉降位移跳動曲線", "3#活塞桿垂直沉降位移峰值曲線" }); break; case 23: row = 23; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "4#活塞桿垂直沉降位移跳動曲線", "4#活塞桿垂直沉降位移峰值曲線" }); break; case 24: row = 24; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "1#曲軸水平振動有效值曲線", "1#曲軸水平振動峰值曲線" }); break; case 25: row = 25; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "2#曲軸水平振動有效值曲線", "2#曲軸水平振動峰值曲線" }); break; case 26: row = 26; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "1#曲軸箱振動有效值曲線", "1#曲軸箱振動峰值曲線" }); break; case 27: row = 27; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "1#曲軸垂直振動有效值曲線", "1#曲軸垂直振動峰值曲線" }); break;// case 28: row = 28; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "2#曲軸垂直振動有效值曲線", "2#曲軸垂直振動峰值曲線" }); break; case 29: row = 29; empty(); getAllDate(row); comboBox1.Items.AddRange(new object[] { "2#曲軸箱振動有效值曲線", "2#曲軸箱振動峰值曲線" }); break; case 30: row = 30; empty(); getAllDate(row); break; case 31: row = 31; empty(); getAllDate(row); break; //第32列 default: empty(); comboBox1.Items.Clear(); break; } } } }
相關推薦
C#讀取txt檔案並畫圖
tools.cs using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; us
c#讀取txt檔案並匯入到資料庫
這是一個ado.net和檔案操作相結合的一個例子,比較經典哦。做的過程中出現了好多問題最終還是做出來了,學習的確需要別人的幫助,如果別人有問題了不管多忙都先學著去幫助別人,因為你要相信你並不是什麼都會。學習相互提高才是最好的狀態。做這個小例子我問了一個網上的“高手”他卻騙我
C++讀取txt檔案,並利用ROS將其作為資料流輸出
#include "ros/ros.h" #include "std_msgs/String.h" #include <sstream> #include <iostream> #include <vector> #include <
初涉C#之讀取txt檔案並繪製座標曲線圖
這兩天由於各種原因,不得不迫使自己學些傍身的東西。所以開始找一些程式語言來武裝武裝自己。C#沒有C++那麼複雜,但也相對於VB要高階一些,或許是個不錯的選擇呢。這兩天看了下讀取文字資料的資料,也在網上查了各種繪製座標圖的方法。怎麼說呢,可能是自己領悟能力比較弱,進
C++讀取txt檔案資料
本次實驗主要目的是實現C++提取txt檔案的資料,txt檔案中的資料為double型。 txt檔案的資料為 1.123456789098 2.123456789098 3.123456789098 4.123456789098 5.123456789098 6.123456789098 7
linux C 讀取目錄檔案並統計檔案數
#include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <errno.h> #include <string.h> #define MAX 1024
java讀取txt檔案並解析其內容
package readtext;/* @author wb @great forever i think,therefor i am */ import java.io.BufferedReader; import java.io.FileInputStream; import java
bash讀取txt檔案, 並在瀏覽器中以表格形式輸出
例如文字 data.txt 1 201623210021 wangzhiguo 25 2 201623210022 yangjiangbo 26 3 201623210023 yangzhen 24 4
批量讀取txt檔案並進行非線性擬合
在處理大量存於txt檔案中的離散資料過程中,忽然有一刻,我實在受夠了低效率的一個一個在origin中擬合(其實是看到那一堆資料的一刻。。哈哈),於是想在matlab中寫一個可以一勞永逸,輕輕鬆鬆處理資料,留出時間玩耍的程式,於是有了下面的內容。 #批量讀取txt
C# 讀取txt檔案資料,StreamReader.BaseStream.Seek()後ReadLine()有錯誤的問題
readerPOSPath.BaseStream.Seek(n, SeekOrigin.Begin); linepos = readerPOSPath.ReadLine();//讀一行 按照上面的方法。Seek到指定位置後,緊接著ReadLine(),得到的結果有Seek之前的資料,也就是
逐行讀取txt檔案並存入到陣列中
get_file_contents_on_line.php $file = fopen("log.txt", "r"); $user=array(); $i=0; //輸出文字中所有的行,直到檔案結束為止。 while(! feof
C#讀取TXT檔案
public void ReadTxt(string path) { StreamReader sr = new StreamReader(path, En
C# 讀取 TXT檔案的時候中文亂碼解決方法
用C#編寫notepad時,讀取檔案時發現英文顯示正常,但是中文就是一個一個方框。如果把txt轉換成UTF-8格式時讀取就正常,so懷疑是編碼問題,仔細查了查幫助,發現Default的說明是“獲取系統的當前 ANSI 內碼表的編碼”,就用了下,果然不是亂碼了。
C#讀取.sql檔案並執行檔案中的sql
有些時候我們需要在程式中編寫讀取sql指令碼檔案並執行這些sql語句,但是我們在有些時候會遇到讀出來的sql語句不能執行,其實不能執行並不是你的sql指令碼檔案有錯誤,而是去執行sql語句的時候,而是C#程式碼裡面執行sql語句的程式碼對sql裡面的一些標誌字元不識別罷了
c++讀取txt檔案到string
string str_native_json("");FILE* file;longlSize;char*szBuf;file = fopen("native_video.txt", "r+");if(file){fseek(file, 0, SEEK_END);lSize = ftell(file);fse
C#讀取CSV檔案並儲存進資料庫
/// <summary> /// 讀檔案 /// </summary> /// <param name="path">檔案路徑</param
用python 讀取txt檔案並儲存為array
Reading Text Tables with Python Reading tables is a pretty common thing to do and there are a number of ways to read tables besides writi
c#讀取dbf檔案並輸出某一列
private void button1_Click(object sender, EventArgs e) { string constr = "Provid
C++ 讀取PE檔案並十六進位制列印輸出
分析PE結構的時候,想自己把裡邊的結構理解後列印LoadPE分析的東西,在此先把讀取PE 結構的C++程式碼貼出來: #include <iostream> #include <iomanip> #include <windows.h>
C#讀取txt檔案時中文亂碼
解決辦法 使用GB2312中文字符集 StreamReader reader = new StreamReader(txtUrl, Encoding.GetEncoding(“gb2312”)); 或使用utf-8中文字符集 StreamReader r