/// <summary> /// 加载所有地图数据 /// </summary> /// <returns></returns> public ObservableCollection <Ga_Map> GetMapRegulate() { ObservableCollection <Ga_Map> ga_s = new ObservableCollection <Ga_Map>(); MySqlDataReader mySql = IO_AGVMapService.MapArray(); while (mySql.Read()) { ga_s.Add(new Ga_Map() { Name = mySql["Name"].ToString(), Width = Convert.ToDouble(mySql["Width"].ToString()), Height = Convert.ToDouble(mySql["Height"].ToString()), ID = Convert.ToInt32(mySql["ID"].ToString()), CreateTime = UTC.ConvertLongDateTime(long.Parse(mySql["CreateTime"].ToString())).ToString("yyyy-MM-dd HH:mm:ss") }); } mySql.Close(); return(ga_s); }
/// <summary> /// 查询所有地图 /// </summary> public void MapDataBinding(string MpName) { MapInstrument.keyValuePairs.Clear(); MapInstrument.valuePairs.Clear(); MapInstrument.wirePointArrays.Clear(); MapInstrument.GetKeyValues.Clear(); Thread thread = new Thread(() => { DataTable dt = new DataTable("Map"); dt.Columns.Add(new DataColumn("MapName")); dt.Columns.Add(new DataColumn("MapInfo")); DataTable ga = GesMap.GetMapData(MpName); this.Dispatcher.BeginInvoke(new Action(() => { if (ga != null) { foreach (DataRow item in ga.Rows) { dt.Rows.Add(new object[] { item["Name"].ToString(), (UTC.ConvertLongDateTime(long.Parse(item["CreateTime"].ToString())).ToString() + "," + item["Width"].ToString() + "," + item["Height"].ToString()) }); } MapData.ItemsSource = dt.DefaultView; MapData.AutoGenerateColumns = false; MapData.SelectedIndex = 0; if (ga.Rows.Count > 0) { MapShow(); } } })); }); thread.IsBackground = true; thread.Start(); }