//取消监控 private void RemoveWatching(Team team) { //删除所有信息点 try { StringBuilder stb = new StringBuilder("1<>0"); foreach (Car car in team.Cars) { stb.Append(" or ID='").Append(car.CarID).Append("'"); try { listViewWatching.Items.Remove(car.ItemInWatch); } catch { } car.ItemInWatch = null; car.IsWatched = false; if (car.ItemInList != null) { car.ItemInList.Checked = false; if (car.ItemInList.ForeColor == COLOR_CAR_IN_WATCH) { car.ItemInList.ForeColor = COLOR_CAR_NORMAL; } } } MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere(stb.ToString()); si.QueryDefinition.Columns = new string[] { "*" }; MapInfo.Data.Feature ftr = MapInfo.Engine.Session.Current.Catalog.SearchForFeature(tableWatching, si); if (ftr != null) { tableWatching.DeleteFeature(ftr); } } catch { } }
//取消监控 private void RemoveWatching(Car car) { //删除信息点 try { try { listViewWatching.Items.Remove(car.ItemInWatch); } catch { } car.ItemInWatch = null; car.IsWatched = false; if (car.ItemInList != null) { car.ItemInList.Checked = false; if (car.ItemInList.ForeColor == COLOR_CAR_IN_WATCH) { car.ItemInList.ForeColor = COLOR_CAR_NORMAL; } } MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("ID='" + car.CarID.ToString() + "'"); si.QueryDefinition.Columns = new string[] { "*" }; MapInfo.Data.Feature ftr = MapInfo.Engine.Session.Current.Catalog.SearchForFeature(tableWatching, si); if (ftr != null) { tableWatching.DeleteFeature(ftr); } } catch { } }
/// <summary> /// 向图层中添加线段 /// </summary> public static bool AddLine(Map oMap, string strLayer, string strUID, string strText, DPoint[] dPoint, System.Drawing.Color color, int lineWidth) { //获取图层和表 FeatureLayer layer = (FeatureLayer)oMap.Layers[strLayer]; //创建线图元及其样式 FeatureGeometry fg = new MultiCurve(layer.CoordSys, CurveSegmentType.Linear, dPoint); CompositeStyle cs = new MapInfo.Styles.CompositeStyle(new SimpleLineStyle(new LineWidth(lineWidth, LineWidthUnit.Pixel), 2, color)); MapInfo.Data.Feature feature = new MapInfo.Data.Feature(layer.Table.TableInfo.Columns); feature.Geometry = fg; feature.Style = cs; feature["uid"] = strUID; feature["name"] = strText; //将线图元加入图层 layer.Table.InsertFeature(feature); return(true); }
//刷新监控车辆信息 private void RefreshWatching(Car car) { if (car != null && car.Pos != null) { //删除原信息点 try { MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("ID='" + car.CarID.ToString() + "'"); si.QueryDefinition.Columns = new string[] { "*" }; MapInfo.Data.Feature ftr = MapInfo.Engine.Session.Current.Catalog.SearchForFeature(tableWatching, si); if (ftr != null) { tableWatching.DeleteFeature(ftr); } //添加新信息点 Feature ftr1 = new Feature(tableWatching.TableInfo.Columns); ftr1.Geometry = new MapInfo.Geometry.Point(mapControl.Map.GetDisplayCoordSys(), new DPoint(car.Pos.Lo, car.Pos.La)) as FeatureGeometry; //ftr1.Style = new SimpleVectorPointStyle(46, Color.Green, 16); if (car.Pos.AlarmHandle != 0) { ftr1.Style = new MapInfo.Styles.BitmapPointStyle("red_" + car.Pos.Direction.ToString() + ".bmp", BitmapStyles.NativeSize, Color.Green, 16); } else if (car.Pos.Pointed == 0) { ftr1.Style = new MapInfo.Styles.BitmapPointStyle("yellow_" + car.Pos.Direction.ToString() + ".bmp", BitmapStyles.NativeSize, Color.Green, 16); } else { ftr1.Style = new MapInfo.Styles.BitmapPointStyle("green_" + car.Pos.Direction.ToString() + ".bmp", BitmapStyles.NativeSize, Color.Red, 16); } ftr1["ID"] = car.CarID.ToString(); ftr1["Label"] = car.CarNO + " [" + car.Pos.Speed.ToString() + "km/h]"; tableWatching.InsertFeature(ftr1); tableWatching.Refresh(); } catch { } } }