private void SelectStation(DataGrid sender) { if (this.FloatAQIPopup.IsOpen) { this.FloatAQIPopup.IsOpen = false; } if (this.FloatWRWPopup.IsOpen) { this.FloatWRWPopup.IsOpen = false; } DataGrid grid = sender; if ((grid != null) && (grid.SelectedIndex != -1)) { if (this.LastStation != null) { this.LastStation.IsFocused = false; } StationData selectedItem = grid.SelectedItem as StationData; this.LastStation = this.GetStation(selectedItem.Station); if (this.LastStation.DataVisibility != 1) { this.LastStation.IsFocused = true; Point viewportPoint = new Point(this.LeftFrame.get_ActualWidth(), 0.0); Location location = this.map.ViewportPointToLocation(viewportPoint); LocationRect rect = new LocationRect { West = this.map.BoundingRectangle.West + ((location.Longitude - this.map.BoundingRectangle.West) / this.mapScale), North = this.map.BoundingRectangle.North, East = this.map.BoundingRectangle.West + ((this.map.BoundingRectangle.East - this.map.BoundingRectangle.West) / this.mapScale), South = this.map.BoundingRectangle.North - ((this.map.BoundingRectangle.North - this.map.BoundingRectangle.South) / this.mapScale) }; Location location2 = new Location { Longitude = this.map.BoundingRectangle.West + ((this.map.Center.Longitude - this.map.BoundingRectangle.West) / this.mapScale), Latitude = this.map.BoundingRectangle.North - ((this.map.Center.Latitude - this.map.BoundingRectangle.South) / this.mapScale) }; if (((rect.West <= this.LastStation.Location.Longitude) && (this.LastStation.Location.Longitude <= rect.East)) && ((rect.South <= this.LastStation.Location.Latitude) && (this.LastStation.Location.Latitude <= rect.North))) { this.OpenAQIWRWFloatPopup(); } else { Location location3 = new Location { Longitude = this.LastStation.Location.Longitude, Latitude = this.LastStation.Location.Latitude }; if (this.LastStation.Location.Longitude < rect.West) { if ((this.LastStation.Location.Longitude - this.BeijingWest) > (location2.Longitude - rect.West)) { location3.Longitude = this.LastStation.Location.Longitude; } else { location3.Longitude = this.BeijingWest + (location2.Longitude - rect.West); } } else if (this.LastStation.Location.Longitude > rect.East) { if ((this.BeijingEast - this.LastStation.Location.Longitude) > (rect.East - location2.Longitude)) { location3.Longitude = this.LastStation.Location.Longitude; } else { location3.Longitude = this.BeijingEast - (rect.East - location2.Longitude); } } if (this.LastStation.Location.Latitude > rect.North) { if ((this.BeijingNorth - this.LastStation.Location.Latitude) > (rect.North - location2.Latitude)) { location3.Latitude = this.LastStation.Location.Latitude; } else { location3.Latitude = this.BeijingNorth - (rect.North - location2.Latitude); } } else if (this.LastStation.Location.Latitude < rect.South) { if ((this.LastStation.Location.Latitude - this.BeijingSouth) > (location2.Latitude - rect.South)) { location3.Latitude = this.LastStation.Location.Latitude; } else { location3.Latitude = this.BeijingSouth + (location2.Latitude - rect.South); } } Location center = new Location { Longitude = location3.Longitude + (((this.map.BoundingRectangle.East - this.map.BoundingRectangle.West) / 2.0) * (1.0 - (1.0 / this.mapScale))), Latitude = location3.Latitude - (((this.map.BoundingRectangle.North - this.map.BoundingRectangle.South) / 2.0) * (1.0 - (1.0 / this.mapScale))) }; this.bMoveAnimating = true; this.bsMapMode.SetView(center, this.bsMapMode.ZoomLevel, 0.0, 0.0, this.bMoveAnimating); } } } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { List<BindingElement> bindingElementsInTopDownChannelStackOrder = new List<BindingElement> { new BinaryMessageEncodingBindingElement() }; HttpTransportBindingElement item = new HttpTransportBindingElement { MaxBufferSize = 0x7fffffff, MaxReceivedMessageSize = 0x7fffffffL }; bindingElementsInTopDownChannelStackOrder.Add(item); CustomBinding binding = new CustomBinding(bindingElementsInTopDownChannelStackOrder); this.dataService = new DataServiceClient(binding, new EndpointAddress(new Uri(Application.get_Current().get_Host().get_Source(), "../DataService.svc"), new AddressHeader[0])); this.dataService.GetWebPredictCompleted += new EventHandler<GetWebPredictCompletedEventArgs>(this.dataService_GetWebPredictCompleted); this.dataService.GetWebPredictAsync(); this.dataService.GetWebDataCompleted += new EventHandler<GetWebDataCompletedEventArgs>(this.dataService_GetWebDataCompleted); this.dataService.GetWebDataAsync("GetRTC"); this.dataService.GetWebAlertCompleted += new EventHandler<GetWebAlertCompletedEventArgs>(this.dataService_GetWebAlertCompleted); this.dataService.GetWebAlertAsync(); this.dataService.DayForecastCompleted += new EventHandler<DayForecastCompletedEventArgs>(this.dataService_DayForecastCompleted); this.dataService.GetRTCCompleted += new EventHandler<GetRTCCompletedEventArgs>(this.dataService_GetRTCCompleted); this.dataService.GetRTC24hCompleted += new EventHandler<GetRTC24hCompletedEventArgs>(this.dataService_GetRTC24hCompleted); this.dataService.GetAlertCompleted += new EventHandler<GetAlertCompletedEventArgs>(this.dataService_GetAlertCompleted); this.timer = new DispatcherTimer(); this.timer.set_Interval(new TimeSpan(0, 10, 0)); this.timer.add_Tick(new EventHandler(this.timer_Tick)); this.timer.Start(); this.CurrentChannelName = this.Actually.get_Name(); this.Actually.set_Source(new BitmapImage(new Uri("/BEPB;component/Images/ssnd-.png", UriKind.Relative))); (this.wrwButtons.get_Resources().get_Item("PM25Storyboard") as Storyboard).Begin(); this.WRWChannelClicked = -1; this.CurrentWRWName = this.wrw_pm25.get_Tag().ToString(); this.wrw_pm25.set_Background(base.get_Resources().get_Item("PM25_ImageBrush") as ImageBrush); this.dgWRW.Columns[1].Header = "PM2.5 浓度(微克/立方米)"; this.BeijingCenter = new Location(this.BeijingSouth + ((this.BeijingNorth - this.BeijingSouth) / 2.0), this.BeijingWest + ((this.BeijingEast - this.BeijingWest) / 2.0)); this.DowntownCenter = new Location(39.93157, 116.41005); double num = 28.0; double num2 = 12.0; double num3 = 14.0; double num4 = 20.0; double num5 = 0.0; ScriptObject property = (ScriptObject) HtmlPage.get_Window().GetProperty("screen"); this.screenWidth = (double) property.GetProperty("width"); this.screenHeight = (double) property.GetProperty("height"); if (this.screenHeight >= 1080.0) { this.LineLength = 172.0; this.ActuallyGrid.set_Background(base.get_Resources().get_Item("LeftFrameBackground420WrwImageBrush") as ImageBrush); this.LeftFrameTopRectangle.set_Fill(base.get_Resources().get_Item("LeftFrameBackground420WrwTopImageBrush") as ImageBrush); this.LeftFrameWrwCollapsedBottomRectangle.set_Fill(base.get_Resources().get_Item("LeftFrameBackground420BottomImageBrush") as ImageBrush); this.StartZoomLevel = 9.0; this.EndZoomLevel = 11.0; this.BeijingCenter.Latitude += 0.00625; this.BeijingCenter.Longitude -= 0.15; this.mapScale = 1.0; this.东城区Name.set_FontSize(14.0); this.东城区Name.set_Content("东城区"); this.东城区Name.Location = new Location(39.916, 116.408); this.西城区Name.set_FontSize(16.0); this.西城区Name.set_Content("西城区"); this.西城区Name.Location = new Location(39.914, 116.358); this.朝阳区Name.set_FontSize(36.0); this.朝阳区Name.set_Content("朝 阳 区"); this.朝阳区Name.Location = new Location(39.96, 116.52); this.丰台区Name.set_FontSize(36.0); this.丰台区Name.set_Content("丰 台 区"); this.丰台区Name.Location = new Location(39.84, 116.27); this.石景山区Name.set_FontSize(22.0); this.石景山区Name.set_Content("石 景 山 区"); this.石景山区Name.Location = new Location(39.90564, 116.2); this.海淀区Name.set_FontSize(36.0); this.海淀区Name.set_Content("海 淀 区"); this.海淀区Name.Location = new Location(40.0, 116.26); this.门头沟区Name.set_FontSize(52.0); this.门头沟区Name.set_Content("门 头 沟 区"); this.门头沟区Name.Location = new Location(40.0, 115.8); this.房山区Name.set_FontSize(52.0); this.房山区Name.set_Content("房 山 区"); this.房山区Name.Location = new Location(39.74786, 115.83); this.通州区Name.set_FontSize(52.0); this.通州区Name.set_Content("通 州 区"); this.通州区Name.Location = new Location(39.791, 116.745); this.顺义区Name.set_FontSize(52.0); this.顺义区Name.set_Content("顺 义 区"); this.顺义区Name.Location = new Location(40.16, 116.72); this.昌平区Name.set_FontSize(52.0); this.昌平区Name.set_Content("昌 平 区"); this.昌平区Name.Location = new Location(40.22072, 116.2312); this.大兴区Name.set_FontSize(52.0); this.大兴区Name.set_Content("大 兴 区"); this.大兴区Name.Location = new Location(39.665, 116.45); this.怀柔区Name.set_FontSize(52.0); this.怀柔区Name.set_Content("怀 柔 区"); this.怀柔区Name.Location = new Location(40.42, 116.5); this.平谷区Name.set_FontSize(52.0); this.平谷区Name.set_Content("平 谷 区"); this.平谷区Name.Location = new Location(40.17, 117.12133); this.密云县Name.set_FontSize(52.0); this.密云县Name.set_Content("密 云 县"); this.密云县Name.Location = new Location(40.55, 116.97); this.延庆县Name.set_FontSize(52.0); this.延庆县Name.set_Content("延 庆 县"); this.延庆县Name.Location = new Location(40.52, 116.1); num = 28.0; this.FloatForecastPopup.HOriginOffset = 100.0; this.FloatForecastPopup.VOriginOffset = 100.0; this.FloatAQIPopup.HOriginOffset = 100.0; this.FloatAQIPopup.VOriginOffset = 100.0; this.FloatWRWPopup.HOriginOffset = 100.0; this.FloatWRWPopup.VOriginOffset = 100.0; } else if (this.screenHeight >= 1024.0) { this.LineLength = 157.0; this.LeftFrameWidth = 400.0; this.ForecastTabItemWidth = 157.0; this.ActuallyTabItemWidth = 145.0; this.dgAQI.Columns[4].Width = new DataGridLength(80.0); this.StartZoomLevel = 9.0; this.EndZoomLevel = 11.0; this.BeijingCenter.Longitude -= 0.2; } else if (this.screenHeight >= 900.0) { this.LineLength = 157.0; this.LeftFrameWidth = 400.0; this.ForecastTabItemWidth = 157.0; this.ActuallyTabItemWidth = 145.0; this.dgAQI.Columns[4].Width = new DataGridLength(80.0); this.StartZoomLevel = 8.0; this.EndZoomLevel = 10.0; this.BeijingCenter.Latitude -= 0.35; this.BeijingCenter.Longitude += 0.8; this.mapScale = 1.4; num = 16.0; num2 = 9.0; num5 = 22.0; this.FloatForecastPopup.HOriginOffset = 80.0; this.FloatForecastPopup.VOriginOffset = 80.0; this.FloatAQIPopup.HOriginOffset = 80.0; this.FloatAQIPopup.VOriginOffset = 80.0; this.FloatWRWPopup.HOriginOffset = 80.0; this.FloatWRWPopup.VOriginOffset = 80.0; } else if (this.screenHeight >= 768.0) { this.LineLength = 157.0; this.LeftFrameWidth = 400.0; this.ForecastTabItemWidth = 157.0; this.ActuallyTabItemWidth = 145.0; this.dgAQI.Columns[4].Width = new DataGridLength(80.0); this.StartZoomLevel = 8.0; this.EndZoomLevel = 10.0; this.BeijingCenter.Latitude += 0.02; if (this.screenWidth >= 1366.0) { this.BeijingCenter.Longitude -= 0.3; } else { this.BeijingCenter.Longitude -= 0.6; } this.mapScale = 1.0; num = 16.0; this.FloatForecastPopup.HOriginOffset = 80.0; this.FloatForecastPopup.VOriginOffset = 80.0; this.FloatAQIPopup.HOriginOffset = 80.0; this.FloatAQIPopup.VOriginOffset = 80.0; this.FloatWRWPopup.HOriginOffset = 80.0; this.FloatWRWPopup.VOriginOffset = 80.0; } else if (this.screenHeight >= 600.0) { this.StartZoomLevel = 8.0; this.EndZoomLevel = 10.0; this.mapScale = 1.0; } this.Line1.set_Width(this.LineLength); this.Line2.set_Width(this.LineLength); this.Line3.set_Width(this.LineLength); this.Line4.set_Width(this.LineLength); this.ExpandButtonGrid.set_Width(this.LeftFrameWidth); this.LeftFrame.set_Width(this.LeftFrameWidth); this.ForecaseLeftTabItem.set_Width(new GridLength(this.ForecastTabItemWidth)); this.ForecaseRightTabItem.set_Width(new GridLength(this.ForecastTabItemWidth)); this.ActuallyLeftTabItem.set_Width(new GridLength(this.ForecastTabItemWidth)); this.ActuallyRightTabItem.set_Width(new GridLength(this.ForecastTabItemWidth)); this.QualityLeftTabItem.set_Width(new GridLength(this.ForecastTabItemWidth)); this.QualityRightTabItem.set_Width(new GridLength(this.ForecastTabItemWidth)); this.AQITabItemGrid.set_Width(this.ActuallyTabItemWidth + 1.0); this.WRWTabItemGrid.set_Width(this.ActuallyTabItemWidth); if ((Application.get_Current() as App).bLocalMapImage) { this.epbMapTileLayer.TileSources.Add(new LocalTiandituTileSource()); } else { this.epbMapTileLayer.TileSources.Add(new TiandituTileSource()); } ScaleTransform transform = new ScaleTransform(); transform.set_ScaleX(this.mapScale); transform.set_ScaleY(this.mapScale); this.map.set_RenderTransform(transform); this.map.ViewChangeEnd += new EventHandler<MapEventArgs>(this.map_ViewChangeEnd); this.bsMapMode = new BSMapMode(new Range<double>(this.StartZoomLevel, this.EndZoomLevel)); this.map.Mode = this.bsMapMode; this.bsMapMode.mapScale = this.mapScale; this.bsMapMode.LeftFrameWidth = this.LeftFrameWidth; this.bsMapMode.BeijingEast = this.BeijingEast; this.bsMapMode.BeijingSouth = this.BeijingSouth; this.bsMapMode.BeijingNorth = this.BeijingNorth; this.bsMapMode.BeijingWest = this.BeijingWest; this.bsMapMode.HomeLevel = this.StartZoomLevel; this.bsMapMode.HomeCenter = this.BeijingCenter; this.bsMapMode.airDataContext = this.airDataContext; this.bsMapMode.airDataContext.ZoomLevel = this.bsMapMode.ZoomLevel; this.bsMapMode.ZoomHome(false); this.NavigationCtrl.bsMapMode = this.bsMapMode; this.NavigationCtrl.ZoomMinLevel = this.StartZoomLevel; this.NavigationCtrl.ZoomMaxLevel = this.EndZoomLevel; this.NavigationCtrl.ZoomLevel = this.bsMapMode.airDataContext.ZoomLevel; DistrictsNameVisibilityConverter converter = base.get_Resources().get_Item("DistrictsNameVisibilityConverter") as DistrictsNameVisibilityConverter; converter.bsMapMode = this.bsMapMode; this.NorthEastText.set_FontSize(num); this.NorthWestText.set_FontSize(num); this.CityCenterText.set_FontSize(num); this.SouthEastText.set_FontSize(num); this.SouthWestText.set_FontSize(num); foreach (StationData data in (Application.get_Current() as App).StationsList) { StationPushpin pushpin = new StationPushpin(); pushpin.set_Name(data.Station); pushpin.set_Content(data.Station); pushpin.Location = new Location(data.Lat, data.Lon); pushpin.PositionOrigin = PositionOrigin.Center; pushpin.Diameter = num3 / this.mapScale; pushpin.FocusedDiameter = num4 / this.mapScale; pushpin.set_FontSize(num2); pushpin.ContentMargin = new Thickness(pushpin.ContentMargin.get_Left(), pushpin.ContentMargin.get_Top() / this.mapScale, pushpin.ContentMargin.get_Right(), pushpin.ContentMargin.get_Bottom()); pushpin.NoDataImageBrush = base.get_Resources().get_Item("NoDataImageBrush") as ImageBrush; pushpin.add_MouseLeftButtonUp(new MouseButtonEventHandler(this, (IntPtr) this.MapStation_MouseLeftButtonUp)); PathToolTip tip = new PathToolTip(); tip.set_Content(data); tip.set_ContentTemplate(base.get_Resources().get_Item("StationToolTipContentTemplate") as DataTemplate); tip.MapScale = this.mapScale; tip.set_VerticalOffset(num5); ToolTipService.SetToolTip(pushpin, tip); this.MapStations.get_Children().Add(pushpin); } this.DoubleClickTimer = new DispatcherTimer(); this.DoubleClickTimer.set_Interval(new TimeSpan(0, 0, 0, 0, 300)); this.DoubleClickTimer.add_Tick(new EventHandler(this.DoubleClickTimer_Tick)); base.add_MouseLeftButtonDown(new MouseButtonEventHandler(this, (IntPtr) this.MainPage_MouseLeftButtonDown)); this.dgAQI.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(this, (IntPtr) this.DataGrid_MouseLeftButtonDown), true); this.dgWRW.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(this, (IntPtr) this.DataGrid_MouseLeftButtonDown), true); List<AQILevel> list2 = new List<AQILevel> { new AQILevel((Application.get_Current() as App).AQILevelColorsList[1], "0-50", "一级", "优", "空气质量令人满意,基本无空气污染", "各类人群可正常活动"), new AQILevel((Application.get_Current() as App).AQILevelColorsList[2], "51-100", "二级", "良", "空气质量可接受,但某些污染物可能对极少数异常敏感人群健康有较弱影响", "极少数异常敏感人群应减少户外活动"), new AQILevel((Application.get_Current() as App).AQILevelColorsList[3], "101-150", "三级", "轻度污染", "易感人群症状有轻度加剧,健康人群出现刺激症状", "儿童、老年人及心脏病、呼吸系统疾病患者应减少长时间、高强度的户外锻炼"), new AQILevel((Application.get_Current() as App).AQILevelColorsList[4], "151-200", "四级", "中度污染", "进一步加剧易感人群症状,可能对健康人群心脏、呼吸系统有影响", "儿童、老年人及心脏病、呼吸系统疾病患者避免长时间、高强度的户外锻炼,一般人群适量减少户外活动"), new AQILevel((Application.get_Current() as App).AQILevelColorsList[5], "201-300", "五级", "重度污染", "心脏病和肺病患者症状显著加剧,运动耐受力降低,健康人群普遍出现症状", "儿童、老年人和心脏病、肺病患者应停留在室内,停止户外活动,一般人群减少户外活动"), new AQILevel((Application.get_Current() as App).AQILevelColorsList[6], ">300", "六级", "严重污染", "健康人群运动耐受力降低,有明显强烈症状,提前出现某些症状", "儿童、老年人和病人应该留在室内,避免体力消耗,一般人群应避免户外活动") }; this.dgAQIDetailText.ItemsSource = list2; this.wrwtlRect1.set_Fill((Application.get_Current() as App).AQILevelColorsList[1]); this.wrwtlRect2.set_Fill((Application.get_Current() as App).AQILevelColorsList[2]); this.wrwtlRect3.set_Fill((Application.get_Current() as App).AQILevelColorsList[3]); this.wrwtlRect4.set_Fill((Application.get_Current() as App).AQILevelColorsList[4]); this.wrwtlRect5.set_Fill((Application.get_Current() as App).AQILevelColorsList[5]); this.wrwtlRect6.set_Fill((Application.get_Current() as App).AQILevelColorsList[6]); this.aqiEllipse1.set_Fill((Application.get_Current() as App).AQILevelColorsList[1]); this.aqiEllipse2.set_Fill((Application.get_Current() as App).AQILevelColorsList[2]); this.aqiEllipse3.set_Fill((Application.get_Current() as App).AQILevelColorsList[3]); this.aqiEllipse4.set_Fill((Application.get_Current() as App).AQILevelColorsList[4]); this.aqiEllipse5.set_Fill((Application.get_Current() as App).AQILevelColorsList[5]); this.aqiEllipse6.set_Fill((Application.get_Current() as App).AQILevelColorsList[6]); App app = Application.get_Current() as App; app.MapRange = this.MapRange; this.map.Focus(); }
private void MapStation_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { TimeSpan span = (TimeSpan) (DateTime.Now - this.LastStationClick); this.ClickedStation = sender as StationPushpin; this.LastStationClick = DateTime.Now; if (span.TotalMilliseconds < 300.0) { this.MapRange.set_Text(this.MapRange.get_Text() + span.TotalMilliseconds.ToString() + " ms\n"); this.DoubleClickTimer.Stop(); } else { this.DoubleClickTimer.Start(); } }