Example #1
0
 public void UpdateDeviceInfo(DeviceInfo deviceInfo)
 {
     if (advTree_Station.InvokeRequired)
     {
         UpdateDeviceInfoDel updateDeviceInfoDel = new
                                                   UpdateDeviceInfoDel(UpdateDeviceInfo);
         this.Invoke(updateDeviceInfoDel, deviceInfo);
     }
     else
     {
         advTree_Station.ClearAndDisposeAllNodes();
         if (deviceInfo == null)
         {
             return;
         }
         UpdateStationTree(deviceInfo.StationList);
     }
 }
Example #2
0
        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;
                }
            }
        }