public void MapRefreshHostInfo(List <HostInfo> list) { // 显示所有的主机 GMapMarker g = null; GMapControlExt gMapControlExt = map; if (appState.MapDatas.DicHostInfoMarker.Count > 0) { foreach (GMapMarker gm in appState.MapDatas.DicHostInfoMarker.Values) { gMapControlExt.Markers.Remove(gm); } } appState.MapDatas.DicHostInfoMarker.Clear(); if (list != null && list.Count > 0) { foreach (HostInfo h in list) { g = new GMapMarker(new PointLatLng((double)h.Lat, (double)h.Lng)); { CustomMarkerHostInfo customMarkerHostInfo = new CustomMarkerHostInfo(gMapControlExt, g, h.ToString(), h); //customMarkerHostInfo.MarkerHostInfoDoubleClick += customMarkerHostInfo_MarkerHostInfoDoubleClick; customMarkerHostInfo.UpdateSize(13.0 / 18); g.Shape = customMarkerHostInfo; //g.Offset = new System.Windows.Point(-13, -13); g.ZIndex = int.MaxValue; gMapControlExt.Markers.Add(g); } appState.MapDatas.DicHostInfoMarker.Add(h.GUID, g); } } }
/// <summary> /// 更新尺寸 /// </summary> public void UpdateMapMarkerSize() { double zoom = map.Zoom; if (appState.MapDatas.DicHostInfoMarker != null && appState.MapDatas.DicHostInfoMarker.Values.Count > 0) { foreach (GMapMarker g in appState.MapDatas.DicHostInfoMarker.Values) { CustomMarkerHostInfo c = (CustomMarkerHostInfo)g.Shape; if (c != null) { c.UpdateSize(zoom / 18); } } } if (appState.MapDatas.DicLightInfoMarker != null && appState.MapDatas.DicLightInfoMarker.Values.Count > 0) { foreach (GMapMarker g in appState.MapDatas.DicLightInfoMarker.Values) { CustomMarkerLightInfo c = (CustomMarkerLightInfo)g.Shape; if (c != null) { c.UpdateSize(zoom / 18); } } } }
public void MapAddHostInfo(HostInfo h) { // 在地图显示 GMapMarker g = null; GMapControlExt gMapControlExt = map; g = new GMapMarker(new PointLatLng((double)h.Lat, (double)h.Lng)); { CustomMarkerHostInfo customMarkerHostInfo = new CustomMarkerHostInfo(gMapControlExt, g, h.ToString(), h); //customMarkerHostInfo.MarkerHostInfoDoubleClick += customMarkerHostInfo_MarkerHostInfoDoubleClick; customMarkerHostInfo.UpdateSize(13.0 / 18); g.Shape = customMarkerHostInfo; //g.Offset = new System.Windows.Point(-13, -13); g.ZIndex = int.MaxValue; gMapControlExt.Markers.Add(g); } appState.MapDatas.DicHostInfoMarker.Add(h.GUID, g); // 在左侧列表显示 // 加入新的分组 TreeGroupInfo tgi = appState.TreeDatas.TreeGroupInfos.FirstOrDefault(t => t.GroupInfo.GUID.Trim() == h.GroupInfoGUID.Trim()); TreeHostInfo thi = new TreeHostInfo() { HostInfo = h }; thi.AddAllGroup(); if (tgi != null) { tgi.TreeHostInfos.Add(thi); } else { if (h.GroupInfoGUID.Trim() == "") { // 增加未分组的主机 new UIBLL().AddNoneTreeGroupInfo().TreeHostInfos.Add(thi); } } appState.TreeDatas.ListHostInfo.Add(h); }