public void putong_warn() { all_warn_list.Clear(); try { bool warning_is = false; foreach (putongpoint point in all_putong_point) { try { double position = double.Parse(point.key); int index = MainWindow.Dizhi_Index.IndexOf(position); DataList.Data_Struct data_struct = (DataList.Data_Struct)MainWindow.Real_Data_List[index]; point.weiyi = data_struct.应变量; if (point.key == data_struct.位置.ToString()) { try { point.weiyi = data_struct.位移量; if (point.weiyi >= MainWindow.yuzhi) { string warn_string = "报警位置:" + data_struct.位置.ToString() + " 位移值:" + data_struct.位移量.ToString() + "mm"; all_warn_list.Add(warn_string); point.Set_Warn_is(); warning_is = true; warn_bofang1 = true; } else { point.Set_Warn_is_not(); } } catch { } } } catch { } } if (warning_is == false) { warn_bofang1 = false; } } catch { } }
public void Read_Real_Data() { try { DateTime newtime = new DateTime(); DirectoryInfo[] dirs = FileCaozuo.Read_All_FilesDirect(MainWindow.path); ArrayList allpoints = MainWindow.Point_ini.ReadSections(); // 地图上所有的点 bool is_exit = false; // 是否在柱子上 foreach (DirectoryInfo dir in dirs) { try { string nowtime_string = dir.Name; string nowtime_sub_string = nowtime_string.Substring(4, nowtime_string.Length - 4); string year = nowtime_sub_string.Substring(0, 4); string month = nowtime_sub_string.Substring(4, 2); string day = nowtime_sub_string.Substring(6, 2); string hour = nowtime_sub_string.Substring(8, 2); string min = nowtime_sub_string.Substring(10, 2); DateTime nowtime = DateTime.Parse(year + "-" + month + "-" + day + " " + hour + ":" + min + ":00"); if (nowtime > newtime) { newtime = nowtime; } } catch { } } string newpath = MainWindow.path + "data" + newtime.ToString("yyyyMMddHHmm") + "\\"; ArrayList filelist = FileCaozuo.Read_All_Files(newpath, "*.txt"); ArrayList timelist = new ArrayList(); // 时间列表 foreach (string name in filelist) { // 每个文件的的名称 string filename = string_caozuo.Get_Dian_String(name, 1); string mydate = string_caozuo.Get_HengGang_String(filename, 1); string mytime = string_caozuo.Get_HengGang_String(filename, 2); string year = string_caozuo.Get_Xiahuaxian_String(mydate, 1); string month = string_caozuo.Get_Xiahuaxian_String(mydate, 2); string day = string_caozuo.Get_Xiahuaxian_String(mydate, 3); string hour = string_caozuo.Get_Xiahuaxian_String(mytime, 1); string min = string_caozuo.Get_Xiahuaxian_String(mytime, 2); string sec = string_caozuo.Get_Xiahuaxian_String(mytime, 3); DateTime nowtime = DateTime.Parse(year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec); timelist.Add(nowtime); } DateTime maxtime = new DateTime(); DateTime mintime = DateTime.Now; // 找出最近的时候 foreach (DateTime time in timelist) { if (time >= maxtime) { maxtime = time; } if (time < mintime) { mintime = time; } } MainWindow.updatetime = maxtime; //更新时间 // 最新的文件就是maxtime的文件 string nowfilename = maxtime.ToString("yyyy_MM_dd-HH_mm_ss") + ".txt"; string oldfilename = mintime.ToString("yyyy_MM_dd-HH_mm_ss") + ".txt"; // 读取些文件信息 // 最新值 string[] all_line = FileCaozuo.Read_All_Line(newpath + nowfilename); double position = 0; double value = 0; // 标准值 string[] all_line_old = FileCaozuo.Read_All_Line(newpath + oldfilename); double value_old = 0; //MainWindow.Real_Data_List.Clear(); for (int i = 0; i < all_line.Length; i++) { try { string str_new = all_line[i]; string str_old = all_line_old[i]; position = double.Parse(string_caozuo.Get_Table_String(str_new, 1)); value = double.Parse(string_caozuo.Get_Table_String(str_new, 2)); value_old = double.Parse(string_caozuo.Get_Table_String(str_old, 2)); DataList.Data_Struct datasrtuct = new DataList.Data_Struct(); datasrtuct.位置 = position; datasrtuct.位置X = 0; datasrtuct.位置Y = 0; datasrtuct.应变量 = double.Parse(Math.Abs(value - value_old).ToString("#0.0000")); datasrtuct.位移量 = double.Parse(Jisuan_Weiyi(Math.Abs(value - value_old)).ToString("#0.0000")); // 将值放入数据队列中 if (MainWindow.Real_Data_List.Count < all_line.Length) { MainWindow.Real_Data_List.Add(datasrtuct); MainWindow.Dizhi_Index.Add(position); } else { MainWindow.Real_Data_List[i] = datasrtuct; MainWindow.Dizhi_Index[i] = position; } } catch { } //int a = 0; } //myreal_data_list = Real_Data_List; } catch { } }
private void Thread_Tick() { try { if (gengxin_is == false) { Console.Write("false"); } if (gengxin_is == false) { gengxin_is = true; } else { return; } Console.WriteLine("开始读取"); ArrayList[] yingbian = null; ArrayList[] wendu = null; try { yingbian = new ArrayList[line_count]; wendu = new ArrayList[line_count]; for (int i = 0; i < line_count; i++) { yingbian[i] = new ArrayList(); wendu[i] = new ArrayList(); } } catch { } DateTime newtime = new DateTime(); DirectoryInfo[] dirs = FileCaozuo.Read_All_FilesDirect(path); ArrayList allpoints = Point_ini.ReadSections(); // 地图上所有的点 bool is_exit = false; // 是否在柱子上 timelist.Clear(); foreach (DirectoryInfo dir in dirs) { try { string nowtime_string = dir.Name; string nowtime_sub_string = nowtime_string.Substring(4, nowtime_string.Length - 4); string year = nowtime_sub_string.Substring(0, 4); string month = nowtime_sub_string.Substring(4, 2); string day = nowtime_sub_string.Substring(6, 2); string hour = nowtime_sub_string.Substring(8, 2); string min = nowtime_sub_string.Substring(10, 2); DateTime nowtime = DateTime.Parse(year + "-" + month + "-" + day + " " + hour + ":" + min + ":00"); if (nowtime > newtime) { newtime = nowtime; } } catch { } } newpath = "D:\\bgdata\\" + "data" + newtime.ToString("yyyyMMddHHmm") + "\\"; ArrayList filelist = FileCaozuo.Read_All_Files(newpath, "*.txt"); // 时间列表 foreach (string name in filelist) { // 每个文件的的名称 string filename = string_caozuo.Get_Dian_String(name, 1); string mydate = string_caozuo.Get_HengGang_String(filename, 1); string mytime = string_caozuo.Get_HengGang_String(filename, 2); string year = string_caozuo.Get_Xiahuaxian_String(mydate, 1); string month = string_caozuo.Get_Xiahuaxian_String(mydate, 2); string day = string_caozuo.Get_Xiahuaxian_String(mydate, 3); string hour = string_caozuo.Get_Xiahuaxian_String(mytime, 1); string min = string_caozuo.Get_Xiahuaxian_String(mytime, 2); string sec = string_caozuo.Get_Xiahuaxian_String(mytime, 3); DateTime nowtime = DateTime.Parse(year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec); timelist.Add(nowtime); } DateTime maxtime = new DateTime(); DateTime mintime = DateTime.Now; // 找出最近的时候 foreach (DateTime time in timelist) { if (time >= maxtime) { maxtime = time; } if (time < mintime) { mintime = time; } //<<<<<<< HEAD // //lock (timer1) // //{ // // timer1.Stop(); // // timer1.Start(); // //} // // mainthread = Thread.CurrentThread; // //ThreadPool.SetMaxThreads(1000, 1000); // //ThreadPool.SetMinThreads(100, 100); // //ThreadPool.QueueUserWorkItem(new WaitCallback(Insert_Cmd),time); // CreateSqlValueType[] create = new CreateSqlValueType[2]; // create[0] = new CreateSqlValueType("float", "position", true); // //create[1] = new CreateSqlValueType("datetime", "mytime"); // create[1] = new CreateSqlValueType("nvarchar(50)", "value"); // bool result = MainWindow.data_builder.Create_Table("data" + time.ToString("yyyyMMddHHmmss"), create); // if (result == false) continue; // Insert_Cmd(time); //======= Insert_Cmd(time); //lock (timer1) //{ // timer1.Stop(); // timer1.Start(); //} //mainthread = Thread.CurrentThread; ////ThreadPool.SetMaxThreads(1000, 1000); ////ThreadPool.SetMinThreads(100, 100); //ThreadPool.QueueUserWorkItem(new WaitCallback(Insert_Cmd),time); } updatetime = maxtime; //更新时间 // 最新的文件就是maxtime的文件 string nowfilename = maxtime.ToString("yyyy_MM_dd-HH_mm_ss") + ".txt"; string oldfilename = mintime.ToString("yyyy_MM_dd-HH_mm_ss") + ".txt"; try { if (is_shebei == true) { // 建立数据库图表 CreateSqlValueType[] create_type = new CreateSqlValueType[7]; create_type[0] = new CreateSqlValueType("nvarchar(50)", "id", true); create_type[1] = new CreateSqlValueType("datetime", "create_time"); create_type[2] = new CreateSqlValueType("int", "position"); create_type[3] = new CreateSqlValueType("int", "positionX"); create_type[4] = new CreateSqlValueType("int", "positionY"); create_type[5] = new CreateSqlValueType("float", "yingbian"); create_type[6] = new CreateSqlValueType("float", "weiyi"); data_builder.Create_Table("Data" + DateTime.Now.ToString("yyyy_MM_dd"), create_type); } } catch { } // 读取些文件信息 // 最新值 string[] all_line = FileCaozuo.Read_All_Line(newpath + nowfilename); // double position = 0; double value = 0; // 标准值 string[] all_line_old = FileCaozuo.Read_All_Line("D:\\bgdata\\标准.txt"); double value_old = 0; //Real_Data_List.Clear(); // string myfilename = time.ToString("yyyy_MM_dd-HH_mm_ss") + ".txt"; for (int i = 0; i < all_line.Length; i++) { try { lock (timer1) { timer1.Stop(); timer1.Start(); } string str_new = all_line[i]; string str_old = all_line_old[i]; position = double.Parse(string_caozuo.Get_Table_String(str_new, 1)); value = double.Parse(string_caozuo.Get_Table_String(str_new, 2)); value_old = double.Parse(string_caozuo.Get_Table_String(str_old, 2)); DataList.Data_Struct datasrtuct = new DataList.Data_Struct(); datasrtuct.位置 = position; datasrtuct.位置X = 0; datasrtuct.位置Y = 0; datasrtuct.应变量 = double.Parse(Math.Abs(value - value_old).ToString("#0.0000")); datasrtuct.位移量 = double.Parse(Jisuan_Weiyi(Math.Abs(value - value_old)).ToString("#0.0000")); try { // 保存数据 if (is_shebei == true) { string[] insert_data = new string[7]; insert_data[0] = datasrtuct.位置.ToString() + str_new; } } catch { } // 应变量应减去相应的温度变化 try { for (int j = 0; j < line_count; j++) { try { if (position >= yingbian_start[j] && position <= yingbian_end[j]) { yingbian[j].Add(datasrtuct); DataList.Data_Struct yingbian_struct = (DataList.Data_Struct)yingbian[j][yingbian[j].IndexOf(datasrtuct)]; DataList.Data_Struct wendu_struct = (DataList.Data_Struct)wendu[j][yingbian[j].IndexOf(datasrtuct)]; yingbian_struct.应变量 = Math.Abs(yingbian_struct.应变量 - wendu_struct.应变量); yingbian_struct.位移量 = Math.Abs(yingbian_struct.位移量 - wendu_struct.位移量); } } catch { } try { if (position >= wendu_start[j] && position <= wendu_end[j]) { wendu[j].Add(datasrtuct); } } catch { } } } catch { } // 将值放入数据队列中 if (Real_Data_List.Count < all_line.Length) { Real_Data_List.Add(datasrtuct); Dizhi_Index.Add(position); } else { Real_Data_List[i] = datasrtuct; Dizhi_Index[i] = position; } } catch { } //int a = 0; } gengxin_is = false; } catch { } }
public void Show_Report(object sender, EventArgs e) { if (DateTime.Now.Hour != 9 || DateTime.Now.Minute != 35) { return; } try { ArrayList allline = MainWindow.Report_Config.ReadSections(); // 所有的报表项 for (int i = 0; i < MainWindow.Real_Data_List.Count; i++) { try { DataList.Data_Struct mystruct = (DataList.Data_Struct)MainWindow.Real_Data_List[i]; foreach (string linename in allline) { double start = double.Parse(string_caozuo.Get_Xiahuaxian_String(linename, 1)); double end = double.Parse(string_caozuo.Get_Xiahuaxian_String(linename, 2)); if (mystruct.位置 >= start && mystruct.位置 <= end) { if (nowname == "" || nowname == linename) { nowname = linename; nowallvalue = nowallvalue + mystruct.位移量; //累加 if (mystruct.位移量 >= maxvalue) { maxvalue = mystruct.位移量; //最大值 maxposition = mystruct.位置; // 最大值的位置 } nowcounts++; } if (nowname != linename && nowname != "") { string report_name = "report" + DateTime.Now.ToString("yyyyMMdd"); SqlConnect.CreateSqlValueType[] create_report = new SqlConnect.CreateSqlValueType[6]; create_report[0] = new SqlConnect.CreateSqlValueType("nvarchar(50)", "Line_Name", true, false); create_report[1] = new SqlConnect.CreateSqlValueType("nvarchar(50)", "mylinename"); create_report[2] = new SqlConnect.CreateSqlValueType("nvarchar(50)", "Agv_Value"); create_report[3] = new SqlConnect.CreateSqlValueType("nvarchar(50)", "Max_Value"); create_report[4] = new SqlConnect.CreateSqlValueType("nvarchar(50)", "Max_Position"); create_report[5] = new SqlConnect.CreateSqlValueType("nvarchar(50)", "Last_Cha"); MainWindow.builder.Create_Table(report_name, create_report); string[] insert_string = new string[6]; insert_string[0] = nowname; insert_string[1] = MainWindow.Report_Config.IniReadValue(nowname, "position_name"); insert_string[2] = (nowallvalue / nowcounts).ToString(); insert_string[3] = maxvalue.ToString(); insert_string[4] = maxposition.ToString(); insert_string[5] = ""; string[] update_string = new string[6]; update_string[0] = "Line_Name='" + nowname + "'"; update_string[1] = "mylinename='" + MainWindow.Report_Config.IniReadValue(nowname, "position_name") + "'"; update_string[2] = "Agv_Value='" + (nowallvalue / nowcounts).ToString() + "'"; update_string[3] = "Max_Value='" + maxvalue.ToString() + "'"; update_string[4] = "Max_Position='" + maxposition.ToString() + "'"; update_string[5] = "Last_Cha=''"; try { MainWindow.builder.Insert(report_name, insert_string); } catch { MainWindow.builder.Updata(report_name, "Line_Name='" + nowname + "'", update_string); } nowname = linename; nowallvalue = mystruct.位移量; //累加 maxvalue = 0; if (mystruct.位移量 >= maxvalue) { maxvalue = mystruct.位移量; //最大值 maxposition = mystruct.位置; // 最大值的位置 } nowcounts = 1; //MainWindow.builder.Create_Table(DateTime.Now.ToString("ReportyyyyMMddHHmmss")); } } } } catch { } } } catch { } }
private void Thread_Tick() { try { ArrayList[] yingbian = null; ArrayList[] wendu = null; try { yingbian = new ArrayList[line_count]; wendu = new ArrayList[line_count]; for (int i = 0; i < line_count; i++) { yingbian[i] = new ArrayList(); wendu[i] = new ArrayList(); } } catch { } DateTime newtime = new DateTime(); DirectoryInfo[] dirs = FileCaozuo.Read_All_FilesDirect(path); ArrayList allpoints = Point_ini.ReadSections(); // 地图上所有的点 bool is_exit = false; // 是否在柱子上 foreach (DirectoryInfo dir in dirs) { try { string nowtime_string = dir.Name; string nowtime_sub_string = nowtime_string.Substring(4, nowtime_string.Length - 4); string year = nowtime_sub_string.Substring(0, 4); string month = nowtime_sub_string.Substring(4, 2); string day = nowtime_sub_string.Substring(6, 2); string hour = nowtime_sub_string.Substring(8, 2); string min = nowtime_sub_string.Substring(10, 2); DateTime nowtime = DateTime.Parse(year + "-" + month + "-" + day + " " + hour + ":" + min + ":00"); if (nowtime > newtime) { newtime = nowtime; } } catch { } } string newpath = path + "data" + newtime.ToString("yyyyMMddHHmm") + "\\"; ArrayList filelist = FileCaozuo.Read_All_Files(newpath, "*.txt"); ArrayList timelist = new ArrayList(); // 时间列表 foreach (string name in filelist) { // 每个文件的的名称 string filename = string_caozuo.Get_Dian_String(name, 1); string mydate = string_caozuo.Get_HengGang_String(filename, 1); string mytime = string_caozuo.Get_HengGang_String(filename, 2); string year = string_caozuo.Get_Xiahuaxian_String(mydate, 1); string month = string_caozuo.Get_Xiahuaxian_String(mydate, 2); string day = string_caozuo.Get_Xiahuaxian_String(mydate, 3); string hour = string_caozuo.Get_Xiahuaxian_String(mytime, 1); string min = string_caozuo.Get_Xiahuaxian_String(mytime, 2); string sec = string_caozuo.Get_Xiahuaxian_String(mytime, 3); DateTime nowtime = DateTime.Parse(year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec); timelist.Add(nowtime); } DateTime maxtime = new DateTime(); DateTime mintime = DateTime.Now; // 找出最近的时候 foreach (DateTime time in timelist) { if (time >= maxtime) { maxtime = time; } if (time < mintime) { mintime = time; } } updatetime = maxtime; //更新时间 // 最新的文件就是maxtime的文件 string nowfilename = maxtime.ToString("yyyy_MM_dd-HH_mm_ss") + ".txt"; string oldfilename = mintime.ToString("yyyy_MM_dd-HH_mm_ss") + ".txt"; // 读取些文件信息 // 最新值 string[] all_line = FileCaozuo.Read_All_Line(newpath + nowfilename); // try{ File.Copy(newpath + nowfilename, "D://data//" + nowfilename); } catch {} double position = 0; double value = 0; // 标准值 string[] all_line_old = FileCaozuo.Read_All_Line("D:\\bgdata\\标准.txt"); double value_old = 0; //Real_Data_List.Clear(); for (int i = 0; i < all_line.Length; i++) { try { string str_new = all_line[i]; string str_old = all_line_old[i]; position = double.Parse(string_caozuo.Get_Table_String(str_new, 1)); value = double.Parse(string_caozuo.Get_Table_String(str_new, 2)); value_old = double.Parse(string_caozuo.Get_Table_String(str_old, 2)); DataList.Data_Struct datasrtuct = new DataList.Data_Struct(); datasrtuct.位置 = position; datasrtuct.位置X = 0; datasrtuct.位置Y = 0; datasrtuct.应变量 = double.Parse(Math.Abs(value - value_old).ToString("#0.0000")); datasrtuct.位移量 = double.Parse(Jisuan_Weiyi(Math.Abs(value - value_old)).ToString("#0.0000")); // 应变量应减去相应的温度变化 try { for (int j = 0; j < line_count; j++) { try { if (position >= yingbian_start[j] && position <= yingbian_end[j]) { yingbian[j].Add(datasrtuct); DataList.Data_Struct yingbian_struct = (DataList.Data_Struct)yingbian[j][yingbian[j].IndexOf(datasrtuct)]; DataList.Data_Struct wendu_struct = (DataList.Data_Struct)wendu[j][yingbian[j].IndexOf(datasrtuct)]; yingbian_struct.应变量 = Math.Abs(yingbian_struct.应变量 - wendu_struct.应变量); yingbian_struct.位移量 = Math.Abs(yingbian_struct.位移量 - wendu_struct.位移量); } } catch { } try { if (position >= wendu_start[j] && position <= wendu_end[j]) { wendu[j].Add(datasrtuct); } } catch { } } } catch { } // 将值放入数据队列中 if (Real_Data_List.Count < all_line.Length) { Real_Data_List.Add(datasrtuct); Dizhi_Index.Add(position); } else { Real_Data_List[i] = datasrtuct; Dizhi_Index[i] = position; } } catch { } //int a = 0; } //myreal_data_list = Real_Data_List; } catch { } }
public void ReSet(ArrayList list) { if (mymode == 2) { try { #region // all_putong_point.Clear(); // subgrid.Children.Clear(); // int shu = thislist.Count; // for (int i = 1; i <= shu; i++) // { // try // { // DataList.Data_Struct datastruct = (DataList.Data_Struct)thislist[i - 1]; // Label position = new Label(); // position.Content = datastruct.位移量.ToString("#0.000") + " mm"; // position.FontSize = 10; // position.Margin = new Thickness(0, i * 20 + 40, 0, 0); // subgrid.Children.Add(position); // position.Foreground = System.Windows.Media.Brushes.White; // Label yidong = new Label(); // yidong.Content = " "; // yidong.FontSize = 10; // yidong.Width = datastruct.位移量 * 10; // // yidong.Height = topimage.Height / 3; // yidong.VerticalAlignment = VerticalAlignment.Top; // yidong.HorizontalAlignment = HorizontalAlignment.Left; // yidong.Margin = new Thickness(140 - yidong.Width, i * 20 + 40, 0, 0); // if (datastruct.位移量 <= 0.5) // { // yidong.Background = System.Windows.Media.Brushes.Blue; // } // if (datastruct.位移量 > 0.5 && datastruct.位移量 < 2) // { // yidong.Background = System.Windows.Media.Brushes.Yellow; // } // if (datastruct.位移量 >= 2) // { // yidong.Background = System.Windows.Media.Brushes.Red; // } // subgrid.Children.Add(yidong); // Label position1 = new Label(); // position1.Content = datastruct.位置.ToString("#0"); // position1.FontSize = 10; // position1.VerticalAlignment = VerticalAlignment.Top; // position1.HorizontalAlignment = HorizontalAlignment.Left; // position1.Margin = new Thickness(150, i * 20 + 40, 0, 0); // subgrid.Children.Add(position1); // subgrid.VerticalAlignment = VerticalAlignment.Top; // subgrid.HorizontalAlignment = HorizontalAlignment.Left; // subgrid.Margin = new Thickness(left, 0, 0, 0); // subgrid.Height = (shu) * position1.Height; // } // catch { } // } //} //catch { } #endregion double rukou = 0; double chukou = 0; double shangci = 0; subgrid.Background = Brushes.LightGray; all_putong_point.Clear(); subgrid.Children.Clear(); int index = 0; foreach (string name in mylist) { int points_count = 0; int my_count = 0; double rukou1 = double.Parse(MainWindow.Point_ini.IniReadValue(name, "rukou")); double chukou1 = double.Parse(MainWindow.Point_ini.IniReadValue(name, "chukou")); if (index == 0) { // 图片1 if (rukou1 < 2361) { try { string path = Environment.CurrentDirectory + "\\1.png"; //new Uri(path, UriKind.Absolute) BitmapImage myimage = new BitmapImage(new Uri(path, UriKind.Absolute)); Image image = new Image(); image.Source = myimage; image.Width = 2800; image.Height = 2200; image.Margin = new Thickness(-800, -290, 0, 0); image.VerticalAlignment = VerticalAlignment.Top; image.HorizontalAlignment = HorizontalAlignment.Left; subgrid.Children.Add(image); } catch { } } if (rukou1 < 2934 && rukou1 >= 2361) { try { string path = Environment.CurrentDirectory + "\\2.png"; //new Uri(path, UriKind.Absolute) BitmapImage myimage = new BitmapImage(new Uri(path, UriKind.Absolute)); Image image = new Image(); image.Source = myimage; image.Width = 2800; image.Height = 2200; image.Margin = new Thickness(-800, -290, 0, 0); image.VerticalAlignment = VerticalAlignment.Top; image.HorizontalAlignment = HorizontalAlignment.Left; subgrid.Children.Add(image); } catch { } } if (rukou1 >= 2934) { try { string path = Environment.CurrentDirectory + "\\3.png"; //new Uri(path, UriKind.Absolute) BitmapImage myimage = new BitmapImage(new Uri(path, UriKind.Absolute)); Image image = new Image(); image.Source = myimage; image.Width = 2000; image.Height = 1300; image.Margin = new Thickness(0, 100, 0, 0); image.VerticalAlignment = VerticalAlignment.Top; image.HorizontalAlignment = HorizontalAlignment.Left; subgrid.Children.Add(image); } catch { } } } index = 1; points_count = (int)(Math.Abs(chukou1 - rukou1) * 5); double X11 = double.Parse(MainWindow.Point_ini.IniReadValue(name, "X1")); double X21 = double.Parse(MainWindow.Point_ini.IniReadValue(name, "X2")); double Y11 = double.Parse(MainWindow.Point_ini.IniReadValue(name, "Y1")); double Y21 = double.Parse(MainWindow.Point_ini.IniReadValue(name, "Y2")); double offsite_x1 = double.Parse(MainWindow.Point_ini.IniReadValue(myname, "offsite_x")); double offsite_y1 = double.Parse(MainWindow.Point_ini.IniReadValue(myname, "offsite_y")); //index++; double mywidth = 0; double myheight = 0; myheight = origin_height * suofang; mywidth = origin_width * suofang; //subgrid.Margin = new Thickness(subgrid.Margin.Left - (mywidth - subgrid.Width) / 2, subgrid.Margin.Top - (myheight - subgrid.Height) / 2, 0, 0); subgrid.Margin = new Thickness(0, 0, 0, 0); subgrid.Width = mywidth; subgrid.Height = myheight; points_count = (int)(Math.Abs(chukou1 - rukou1) * 5); foreach (DataList.Data_Struct item in MainWindow.Real_Data_List) { if (item.位置 >= rukou1 && item.位置 <= chukou1) { try { my_count++; double x = (X21 - X11) / points_count * my_count + X11; double y = (Y21 - Y11) / points_count * my_count + Y11; putongpoint point = new putongpoint(x, y); point.key = item.位置.ToString(); point.Width = 2; point.Height = 2; if (rukou1 < 2361) { point.Margin = new Thickness((x - 400) * suofang + 2400, (y - 100) * suofang - 300, 0, 0); } if (rukou1 < 2934 && rukou1 >= 2361) { point.Margin = new Thickness((x - 400) * suofang - 300, (y - 103) * suofang - 300, 0, 0); } if (rukou1 >= 2934) { point.Margin = new Thickness((x - 430) * suofang + 350, (y - 100) * suofang - 830, 0, 0); } // point.MouseDown += new MouseButtonEventHandler(PuTong_Click); // // subgrid.Children.Add(point); all_putong_point.Add(point); } catch { } } if (item.位置 > chukou1) { break; } } foreach (putongpoint point in all_putong_point) { try { point.mode = 1; double position = double.Parse(point.key); int index1 = MainWindow.Dizhi_Index.IndexOf(position); DataList.Data_Struct data_struct = (DataList.Data_Struct)MainWindow.Real_Data_List[index1]; point.weiyi = data_struct.应变量; //point.Set_Warn_is_not(); if (point.weiyi < 1) { ScaleTransform transform = new ScaleTransform(1, 1); point.RenderTransformOrigin = new Point(0.5, 0.5); point.RenderTransform = transform; point.Set_Warn_is_not(); } if (point.weiyi >= 1 && point.weiyi <= 5) { ScaleTransform transform = new ScaleTransform(point.weiyi, point.weiyi); point.RenderTransformOrigin = new Point(0.5, 0.5); point.RenderTransform = transform; if (point.weiyi >= 2) { point.Set_Warn_is(); } } if (point.weiyi > 5) { ScaleTransform transform = new ScaleTransform(5, 5); point.RenderTransformOrigin = new Point(0.5, 0.5); point.RenderTransform = transform; point.Set_Warn_is(); } if (point.key == data_struct.位置.ToString()) { try { point.weiyi = data_struct.位移量; } catch { } } } catch { } } } } catch { } } if (mymode == 1) { thislist = list; subgrid.Children.Clear(); Image topimage = new Image(); string path = System.Environment.CurrentDirectory + "\\zhu_tou.png"; BitmapImage imagetop = new BitmapImage(new Uri(path, UriKind.Absolute)); topimage.Source = imagetop; topimage.Margin = new Thickness(left, 0, 0, 0); subgrid.Children.Add(topimage); topimage.VerticalAlignment = VerticalAlignment.Top; topimage.HorizontalAlignment = HorizontalAlignment.Left; topimage.Height = height; int shu = thislist.Count; int tu_shu = (shu + 1) / 2; double my_tu_shu = (double)tu_shu / 2 / 3 + 1; int a = (int)Math.Ceiling(my_tu_shu); for (int i = 1; i <= a; i++) { Image shenimage = new Image(); string shenpath = System.Environment.CurrentDirectory + "\\zhu_shen.png"; BitmapImage imageshen = new BitmapImage(new Uri(shenpath, UriKind.Absolute)); shenimage.Height = height; shenimage.Source = imageshen; shenimage.Margin = new Thickness(left, topimage.Height * i, 0, 0); //shenimage.Width = width; subgrid.Children.Add(shenimage); shenimage.VerticalAlignment = VerticalAlignment.Top; shenimage.HorizontalAlignment = HorizontalAlignment.Left; } Image dimage = new Image(); string dipath = System.Environment.CurrentDirectory + "\\zhu_di.png"; BitmapImage imagedi = new BitmapImage(new Uri(dipath, UriKind.Absolute)); dimage.Height = height; //dimage.Width = width; dimage.Source = imagedi; dimage.Margin = new Thickness(left, (my_tu_shu + 1) * topimage.Height, 0, 0); subgrid.Children.Add(dimage); dimage.VerticalAlignment = VerticalAlignment.Top; dimage.HorizontalAlignment = HorizontalAlignment.Left; subgrid.VerticalAlignment = VerticalAlignment.Top; subgrid.HorizontalAlignment = HorizontalAlignment.Left; // subgrid.Margin = new Thickness(left, 0, 0, 0); // subgrid.Height = (my_tu_shu + 3) * topimage.Height; for (int i = 0; i < shu / 2; i++) { try { DataList.Data_Struct datastruct = (DataList.Data_Struct)thislist[i]; Label position = new Label(); // position.MouseDown += new MouseButtonEventHandler(Click); position.Content = datastruct.位移量.ToString("#0.000") + " mm"; position.FontSize = 10; position.Margin = new Thickness(0, topimage.Height + (double)i * ((my_tu_shu - 1) * topimage.Height) / ((double)shu / 2), 0, 0); subgrid.Children.Add(position); position.Foreground = System.Windows.Media.Brushes.White; Label yidong = new Label(); yidong.Content = " "; yidong.FontSize = 10; yidong.Width = datastruct.位移量 * 10; yidong.Height = topimage.Height / 3; yidong.VerticalAlignment = VerticalAlignment.Top; yidong.HorizontalAlignment = HorizontalAlignment.Left; yidong.Margin = new Thickness(140 - yidong.Width, topimage.Height + (double)i * ((my_tu_shu - 1) * topimage.Height) / ((double)shu / 2), 0, 0); // 标尺 Label shendu = new Label(); shendu.Content = (i * 0.2).ToString() + "m"; shendu.VerticalAlignment = VerticalAlignment.Top; shendu.HorizontalAlignment = HorizontalAlignment.Left; shendu.Margin = new Thickness(90 - yidong.Width, topimage.Height + (double)i * ((my_tu_shu - 1) * topimage.Height) / ((double)shu / 2), 0, 0); subgrid.Children.Add(shendu); if (datastruct.位移量 <= 0.5) { yidong.Background = System.Windows.Media.Brushes.Blue; } if (datastruct.位移量 > 0.5 && datastruct.位移量 < 2) { yidong.Background = System.Windows.Media.Brushes.Yellow; } if (datastruct.位移量 >= 2) { yidong.Background = System.Windows.Media.Brushes.Red; } subgrid.Children.Add(yidong); Label position1 = new Label(); position1.MouseDown += new MouseButtonEventHandler(Click); position1.MouseEnter += new MouseEventHandler(Label_Enter); position1.MouseLeave += new MouseEventHandler(Label_Leave); //position1.Width = 100; //position1.Height = 30; position1.Content = datastruct.位置.ToString("#0.000"); position1.FontSize = 10; position1.Margin = new Thickness(140, topimage.Height + i * ((my_tu_shu - 1) * topimage.Height) / (shu / 2), 0, 0); subgrid.Children.Add(position1); DataList.Data_Struct datastruct1 = (DataList.Data_Struct)thislist[shu - 1 - i]; Label position2 = new Label(); position2.Content = datastruct1.位移量.ToString("#0.000") + " mm"; position2.FontSize = 10; position2.Margin = new Thickness(width, topimage.Height + (double)i * ((my_tu_shu - 1) * topimage.Height) / ((double)shu / 2), 0, 0); subgrid.Children.Add(position2); position2.Foreground = System.Windows.Media.Brushes.White; Label yidong1 = new Label(); yidong1.Content = " "; yidong1.FontSize = 10; yidong1.Width = datastruct1.位移量 * 10; yidong1.Height = topimage.Height / 3; yidong1.Margin = new Thickness(271, topimage.Height + (double)i * ((my_tu_shu - 1) * topimage.Height) / ((double)shu / 2), 0, 0); yidong1.VerticalAlignment = VerticalAlignment.Top; yidong1.HorizontalAlignment = HorizontalAlignment.Left; if (datastruct1.位移量 <= 0.5) { yidong1.Background = System.Windows.Media.Brushes.Blue; } if (datastruct1.位移量 > 0.5 && datastruct.位移量 < 2) { yidong1.Background = System.Windows.Media.Brushes.Yellow; } if (datastruct1.位移量 >= 2) { yidong1.Background = System.Windows.Media.Brushes.Red; } subgrid.Children.Add(yidong1); Label position3 = new Label(); position3.Content = datastruct1.位置.ToString("#0.000"); position3.MouseDown += new MouseButtonEventHandler(Click); position3.MouseEnter += new MouseEventHandler(Label_Enter); position3.MouseLeave += new MouseEventHandler(Label_Leave); position3.FontSize = 10; //position3.Width = 100; //position3.Height = 50; position3.Margin = new Thickness(210, topimage.Height + i * ((my_tu_shu - 1) * topimage.Height) / (shu / 2), 0, 0); subgrid.Children.Add(position3); } catch { } } } }