private void mapControl_OnMarkerEnter(GMapMarker item) { //isMarkerSelect = true; if (item is GMapMarkerImage) { GMapMarkerImage imageMarker = item as GMapMarkerImage; imageMarker.SelectedPen = new Pen(Brushes.Red, 2); } }
private void mapControl_OnMarkerLeave(GMapMarker item) { //isMarkerSelect = false; if (item is GMapMarkerImage) { GMapMarkerImage imageMarker = item as GMapMarkerImage; imageMarker.SelectedPen.Dispose(); imageMarker.SelectedPen = null; } }
public void UpdateSolarEnergyStatus(List<SolarEnergyStatusList> newSolarEnergyStatusList) { if (mapControl.InvokeRequired) { this.Invoke(new Action<List<SolarEnergyStatusList>>(UpdateSolarEnergyStatus), newSolarEnergyStatusList); } else { List<Guid> normalList = newSolarEnergyStatusList.FindAll(_=>_.Alarm==0).Select(_ => _.DeviceID).ToList(); List<Guid> alarmList = newSolarEnergyStatusList.FindAll(_ => _.Alarm != 0).Select(_ => _.DeviceID).ToList(); #region 改变离线设备图标 string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Image"); Bitmap bitmap_SolarEnergy_offline = Bitmap.FromFile(Path.Combine(basePath, "SolarEnergy_offline.png")) as Bitmap; Bitmap bitmap_SolarEnergy_normal = Bitmap.FromFile(Path.Combine(basePath, "SolarEnergy_normal.png")) as Bitmap; Bitmap bitmap_SolarEnergy_alarm = Bitmap.FromFile(Path.Combine(basePath, "SolarEnergy_alarm.png")) as Bitmap; foreach (var item in baseOverlay.Markers) { GMapMarkerImage marker = item as GMapMarkerImage; if (marker.TypeID == (int)DeviceParamType.SolarEnergyDevice) { if (normalList.Contains(marker.ID)) { marker.Image = bitmap_SolarEnergy_normal; marker.RoutePen = new Pen(Color.Blue, 1); mapControl.UpdateRouteLocalPosition(marker.StationRoute); marker.MarkerStatus = MarkerStatus.Normal; } else if(alarmList.Contains(marker.ID)) { marker.Image = bitmap_SolarEnergy_alarm; marker.RoutePen = new Pen(Color.Red, 1); mapControl.UpdateRouteLocalPosition(marker.StationRoute); marker.MarkerStatus = MarkerStatus.Alarm; } } } mapControl.Refresh(); #endregion UpdateSolarEnergyExceptionList(OMClientManager.solarEnergyStatusList); } }
public void UpdateStationStatus(Dictionary<Guid, int> newStationStatusDic) { if (mapControl.InvokeRequired) { this.Invoke(new Action<Dictionary<Guid, int>>(UpdateStationStatus), newStationStatusDic); } else { #region 改变离线设备图标 string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Image"); Bitmap bitmap_Station_offline = Bitmap.FromFile(Path.Combine(basePath, "Station_offline.png")) as Bitmap; Bitmap bitmap_Station_normal = Bitmap.FromFile(Path.Combine(basePath, "Station_normal.png")) as Bitmap; foreach (var item in baseOverlay.Markers) { GMapMarkerImage marker = item as GMapMarkerImage; if (marker.TypeID == (int)DeviceParamType.Station) { if (newStationStatusDic.Keys.Contains(marker.ID)) { if (newStationStatusDic[marker.ID] == 1 || newStationStatusDic[marker.ID] == 3)//状态为开机或工作,图标点亮 { marker.Image = bitmap_Station_normal; marker.RoutePen = new Pen(Color.Blue, 1); mapControl.UpdateRouteLocalPosition(marker.StationRoute); marker.MarkerStatus = MarkerStatus.Normal; } else//其余状态图标置灰 { marker.Image = bitmap_Station_offline; marker.RoutePen = new Pen(Color.Gray, 1); mapControl.UpdateRouteLocalPosition(marker.StationRoute); marker.MarkerStatus = MarkerStatus.Offline; } } } } mapControl.Refresh(); #endregion } }
private void timer_Alarm_Tick(object sender, EventArgs e) { foreach (GMapMarker m in baseOverlay.Markers) { if (m is GMapMarkerImage) { GMapMarkerImage marker = m as GMapMarkerImage; if (marker.MarkerStatus == MarkerStatus.Alarm) { if (marker.AlarmPen == null) { marker.AlarmPen = new Pen(Brushes.Red, 2); } else { marker.AlarmPen.Dispose(); marker.AlarmPen = null; } } } } mapControl.Refresh(); }
private void checkBoxX_ExceptionHint_CheckedChanged(object sender, EventArgs e) { if (checkBoxX_ExceptionHint.Checked) { timer_Alarm.Start(); } else { timer_Alarm.Stop(); foreach (GMapMarker m in baseOverlay.Markers) { if (m is GMapMarkerImage) { GMapMarkerImage marker = m as GMapMarkerImage; if (marker.AlarmPen != null) { marker.AlarmPen.Dispose(); marker.AlarmPen = null; } } } mapControl.Refresh(); } }
public void UpdateDeviceInfo(DeviceInfo deviceInfo) { if (mapControl.InvokeRequired) { UpdateDeviceInfoDel updateDeviceInfoDel = new UpdateDeviceInfoDel(UpdateDeviceInfo); this.Invoke(updateDeviceInfoDel, deviceInfo); } else { baseOverlay.Markers.Clear(); baseOverlay.Routes.Clear(); advTree_Station.ClearAndDisposeAllNodes(); //RefreshMapControl(); if (deviceInfo == null) return; UpdateStationTree(deviceInfo.StationList); string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Image"); Bitmap bitmap = Bitmap.FromFile(Path.Combine(basePath, "Turntable_offline.png")) as Bitmap; foreach (var item in deviceInfo.TurnTableList) { if (item.Lat == null && item.Lon == null) continue; PointLatLng point = new PointLatLng(item.Lat.Value, item.Lon.Value); GMapMarkerImage marker = new GMapMarkerImage(point, bitmap); baseOverlay.Markers.Add(marker); StationList station = deviceInfo.StationList.Find(_ => _.StationID == item.StationID); if (station != null) { marker.CenterPoint = (station.Lat != null && station.Lon != null) ? new PointLatLng(station.Lat.Value, station.Lon.Value) : new PointLatLng(); marker.Overlay.Routes.Add(marker.StationRoute); } marker.ID = item.DeviceID; marker.TypeID = item.TypeID; marker.ToolTipMode = MarkerTooltipMode.Always; marker.ToolTipText = item.Name; } bitmap = Bitmap.FromFile(Path.Combine(basePath, "Station_offline.png")) as Bitmap; foreach (var item in deviceInfo.StationList) { if (item.Lat == null && item.Lon == null) continue; PointLatLng point = new PointLatLng(item.Lat.Value, item.Lon.Value); GMapMarkerImage marker = new GMapMarkerImage(point, bitmap); baseOverlay.Markers.Add(marker); StationList station = deviceInfo.StationList.Find(_ => _.StationID == item.PStationID); if (station != null) { marker.CenterPoint = (station.Lat != null && station.Lon != null) ? new PointLatLng(station.Lat.Value, station.Lon.Value) : new PointLatLng(); marker.Overlay.Routes.Add(marker.StationRoute); } marker.ID = item.StationID; marker.TypeID = item.TypeID; marker.ToolTipMode = MarkerTooltipMode.Always; marker.ToolTipText = item.Name; } bitmap = Bitmap.FromFile(Path.Combine(basePath, "UPS_offline.png")) as Bitmap; foreach (var item in deviceInfo.UPSList) { if (item.Lat == null && item.Lon == null) continue; PointLatLng point = new PointLatLng(item.Lat.Value, item.Lon.Value); GMapMarkerImage marker = new GMapMarkerImage(point, bitmap); baseOverlay.Markers.Add(marker); StationList station = deviceInfo.StationList.Find(_ => _.StationID == item.StationID); if (station != null) { marker.CenterPoint = (station.Lat != null && station.Lon != null) ? new PointLatLng(station.Lat.Value, station.Lon.Value) : new PointLatLng(); marker.Overlay.Routes.Add(marker.StationRoute); } marker.ID = item.DeviceID; marker.TypeID = item.TypeID; marker.ToolTipMode = MarkerTooltipMode.Always; marker.ToolTipText = item.Name; } bitmap = Bitmap.FromFile(Path.Combine(basePath, "SolarEnergy_offline.png")) as Bitmap; foreach (var item in deviceInfo.SolarEnergyList) { if (item.Lat == null && item.Lon == null) continue; PointLatLng point = new PointLatLng(item.Lat.Value, item.Lon.Value); GMapMarkerImage marker = new GMapMarkerImage(point, bitmap); baseOverlay.Markers.Add(marker); StationList station = deviceInfo.StationList.Find(_ => _.StationID == item.StationID); if (station != null) { marker.CenterPoint = (station.Lat != null && station.Lon != null) ? new PointLatLng(station.Lat.Value, station.Lon.Value) : new PointLatLng(); marker.Overlay.Routes.Add(marker.StationRoute); } marker.ID = item.DeviceID; marker.TypeID = item.TypeID; marker.ToolTipMode = MarkerTooltipMode.Always; marker.ToolTipText = item.Name; } } }
public void UpdateCameraStatus(List<CameraStatusList> newCameraStatusList) { if (mapControl.InvokeRequired) { this.Invoke(new Action<List<CameraStatusList>>(UpdateCameraStatus), newCameraStatusList); } else { try { List<Guid> offlineCameraIDs = newCameraStatusList.FindAll(cs => cs.IsOnline == false).Select(_ => _.DeviceID).ToList(); List<CameraList> offLineCameras = OMClientManager.deviceInfo.CameraList.FindAll(_ => { return offlineCameraIDs.Contains(_.DeviceID); }); List<Guid?> offlineTurntableIDs = offLineCameras.Select(_ => _.Turntable_PTZ_DeviceID).Distinct().ToList(); //List<TurnTableList> offlineTurnTableList = OMClientManager.deviceInfo.TurnTableList.FindAll(_ => //{ // return offlineTurntableIDs.Contains(_.DeviceID); //}); List<Guid> normalCameraIDs = newCameraStatusList.FindAll(cs => cs.IsOnline == true && cs.SignalStatus == 1 && cs.HardwareStatus == 1).Select(_ => _.DeviceID).ToList(); List<CameraList> normalCameras = OMClientManager.deviceInfo.CameraList.FindAll(_ => { return normalCameraIDs.Contains(_.DeviceID); }); List<Guid?> normalTurntableIDs = normalCameras.Select(_ => _.Turntable_PTZ_DeviceID).Distinct().ToList(); List<Guid> alarmCameraIDs = newCameraStatusList.FindAll(cs => cs.IsOnline == true && (cs.SignalStatus == 2 || cs.HardwareStatus == 2)).Select(_ => _.DeviceID).ToList(); List<CameraList> alarmCameras = OMClientManager.deviceInfo.CameraList.FindAll(_ => { return alarmCameraIDs.Contains(_.DeviceID); }); List<Guid?> alarmTurntableIDs = alarmCameras.Select(_ => _.Turntable_PTZ_DeviceID).Distinct().ToList(); //offlineTurntableIDs = offlineTurntableIDs.Except(alarmTurntableIDs).ToList(); //normalTurntableIDs = normalTurntableIDs.Except(alarmTurntableIDs).Except(offlineTurntableIDs).ToList(); #region 改变离线设备图标 string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Image"); Bitmap bitmap_Turntable_offline = Bitmap.FromFile(Path.Combine(basePath, "Turntable_offline.png")) as Bitmap; Bitmap bitmap_Turntable_normal = Bitmap.FromFile(Path.Combine(basePath, "Turntable_normal.png")) as Bitmap; Bitmap bitmap_Turntable_alarm = Bitmap.FromFile(Path.Combine(basePath, "Turntable_alarm.png")) as Bitmap; foreach (var item in baseOverlay.Markers) { GMapMarkerImage marker = item as GMapMarkerImage; if (marker.TypeID == (int)DeviceParamType.TurnTableDevice) { if (alarmTurntableIDs.Contains(marker.ID)) { marker.Image = bitmap_Turntable_alarm; marker.RoutePen = new Pen(Color.Red, 1); mapControl.UpdateRouteLocalPosition(marker.StationRoute); marker.MarkerStatus = MarkerStatus.Alarm; } else if (offlineTurntableIDs.Contains(marker.ID)) { marker.Image = bitmap_Turntable_offline; marker.RoutePen = new Pen(Color.Gray, 1); mapControl.UpdateRouteLocalPosition(marker.StationRoute); marker.MarkerStatus = MarkerStatus.Offline; } else if (normalTurntableIDs.Contains(marker.ID)) { marker.Image = bitmap_Turntable_normal; marker.RoutePen = new Pen(Color.Blue, 1); mapControl.UpdateRouteLocalPosition(marker.StationRoute); marker.MarkerStatus = MarkerStatus.Normal; } } } mapControl.Refresh(); #endregion UpdateCameraExceptionList(OMClientManager.cameraStatusList); } catch(Exception ex) { MessageBox.Show("更新状态信息出错"); } } }
private void mapControl_OnMarkerClick(GMapMarker item, MouseEventArgs e) { if (item.Overlay.Id == "baseOverlay") { if (item is GMapMarkerImage) { GMapMarkerImage marker = item as GMapMarkerImage; if (markerIDList.Contains(marker.ID)) return; if (marker.TypeID == (int)DeviceParamType.TurnTableDevice) { markerIDList.Add(marker.ID); List<CameraList> cameraList = OMClientManager.deviceInfo.CameraList.FindAll(_ => _.Turntable_PTZ_DeviceID == marker.ID); TurntableForm tf = new TurntableForm(this, cameraList, OMClientManager.cameraStatusList, OMClientManager.deviceInfo.StreamMediaList); tf.ID = marker.ID; //tf.CloseForm += new // TurntableForm.CloseFormEventHandler(CloseDisplayForm); tf.lbxTitle.Text = marker.ToolTipText; //df.Location = this.PointToClient(MousePosition);//鼠标相对于窗体的坐标 tf.Location = GetStartLocation(MousePosition, tf.Size); tf.TopMost = true; tf.Show(); } else if (marker.TypeID == (int)DeviceParamType.UPSDevice) { markerIDList.Add(marker.ID); UPSStatusList UPSStatus = OMClientManager.UPSStatusList.Find(_ => _.DeviceID == marker.ID); UPSForm UPSForm = new UPSForm(this, UPSStatus); UPSForm.ID = marker.ID; UPSForm.lbxTitle.Text = marker.ToolTipText; UPSForm.Location = GetStartLocation(MousePosition, UPSForm.Size); UPSForm.TopMost = true; UPSForm.Show(); } else if (marker.TypeID == (int)DeviceParamType.SolarEnergyDevice) { markerIDList.Add(marker.ID); SolarEnergyStatusList SolarEnergyStatus = OMClientManager.solarEnergyStatusList.Find(_ => _.DeviceID == marker.ID); SolarEnergyForm solarEnergyForm = new SolarEnergyForm(this, SolarEnergyStatus); solarEnergyForm.ID = marker.ID; solarEnergyForm.lbxTitle.Text = marker.ToolTipText; solarEnergyForm.Location = GetStartLocation(MousePosition, solarEnergyForm.Size); solarEnergyForm.TopMost = true; solarEnergyForm.Show(); } else if (marker.TypeID == (int)DeviceParamType.Station) { markerIDList.Add(marker.ID); int stationStatus = 0; if (OMClientManager.stationStatusDic.ContainsKey(marker.ID)) { stationStatus = OMClientManager.stationStatusDic[marker.ID]; } StationForm stationForm = new StationForm(this, stationStatus); stationForm.ID = marker.ID; stationForm.lbxTitle.Text = marker.ToolTipText; stationForm.Location = GetStartLocation(MousePosition, stationForm.Size); stationForm.TopMost = true; stationForm.Show(); } } } else if (item.Overlay.Id == "markerOverlay") { if (isClear) { item.Overlay.Markers.Remove(item); isClear = false; } } }