private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; if (featureSet == null || featureSet.Features.Count < 1) { MessageBox.Show("No features retured from query"); return; } GraphicsLayer graphicsLayer = Map.Layers["MySelectionGraphicsLayer"] as GraphicsLayer; if (featureSet != null && featureSet.Features.Count > 0) { foreach (Graphic feature in featureSet.Features) { feature.Symbol = ResultsFillSymbol; graphicsLayer.Graphics.Insert(0, feature); } } //ResultsDisplay.Visibility = Visibility.Visible; ResultsDisplay.IsExpanded = true; _drawSurface.IsEnabled = false; }
// *********************************************************************************** // * ... Got the wind direction info from the weather station layer... // *********************************************************************************** private void WindDirectionQueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { try { FeatureSet featureSet = args.FeatureSet; if (featureSet.Features.Count > 0) { string weatherStationName = ""; DateTime date; string recordedDate = ""; int windTo = -999; client.Graphic graphic = featureSet.Features[0]; if (!string.IsNullOrEmpty(_windDirectionFieldName)) { windTo = Convert.ToInt32(graphic.Attributes[_windDirectionFieldName]) + 180; if (windTo > 360) { windTo = windTo - 360; } } string windDirection = "Wind direction (blowing to:) " + windTo.ToString(); if (!string.IsNullOrEmpty(_windWeatherStationFieldName)) { weatherStationName = "Station Name: " + Convert.ToString(graphic.Attributes[_windWeatherStationFieldName]); } if (!string.IsNullOrEmpty(_windRecordedDateFieldName)) { date = Convert.ToDateTime(graphic.Attributes[_windRecordedDateFieldName]); recordedDate = "Recorded on: " + date.ToString("F", CultureInfo.CreateSpecificCulture("en-us")); } string windDirectionInfo = weatherStationName + System.Environment.NewLine + _weatherStationDistanceInfo + System.Environment.NewLine + windDirection + System.Environment.NewLine + recordedDate + System.Environment.NewLine + System.Environment.NewLine + "Do you want to use wind direction from this weather station?"; _windDirectionQuestionResult = MessageBox.Show(windDirectionInfo, "Wind Direction Information", MessageBoxButton.YesNo); if (_windDirectionQuestionResult == MessageBoxResult.Yes) { _windDirectionTo = windTo; WindDirectionTo = _windDirectionTo; } } else { MessageBox.Show("Please try again!", "Error"); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); MessageBox.Show("Error find the wind direction info!", "Error"); return; } }
void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; if (featureSet != null && featureSet.Features.Count > 0) { QueryDetailsDataGrid.ItemsSource = featureSet.Features; } else { MessageBox.Show("No features returned from query"); } }
/// <summary> /// 查询完成后触发的事件 /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { ResourceDictionary resourcedic = new ResourceDictionary(); resourcedic.Source = new Uri("Resources/MapSymbolResources.xaml", UriKind.Relative); GraphicsLayer graphicsLayer = MainMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); // Check for new results. FeatureSet featureSet = args.FeatureSet; if (featureSet.Features.Count > 0) { if (featureSet.Features.Count > 1) { foreach (Graphic resultFeature in featureSet.Features) { resultFeature.Symbol = resourcedic["ResultsFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(resultFeature); } } else { featureSet.Features[0].Symbol = resourcedic["ResultsFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(featureSet.Features[0]); ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = featureSet.Features[0].Geometry.Extent; double expandPercentage = 100; double widthExtend = selectedFeatureExtent.Width * (expandPercentage / 100); double heightExtend = selectedFeatureExtent.Height * (expandPercentage / 100); ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new Envelope ( selectedFeatureExtent.XMin, selectedFeatureExtent.YMin, selectedFeatureExtent.XMax, selectedFeatureExtent.YMax ); MainMap.ZoomTo(displayExtent); } } else { MessageBox.Show("没有对应的数据"); } }
private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; MyMapTip.GraphicsLayer = graphicsLayer; if (featureSet != null && featureSet.Features.Count > 0) { foreach (Graphic feature in featureSet.Features) { feature.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol; graphicsLayer.Graphics.Add(feature); } } }
private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; if (featureSet == null || featureSet.Features.Count < 1) { MessageBox.Show("No features returned from query"); return; } if (featureSet != null && featureSet.Features.Count > 0) { foreach (Graphic feature in featureSet.Features) { feature.Symbol = LayoutRoot.Resources["ResultsFillSymbol"] as FillSymbol; selectionGraphicslayer.Graphics.Insert(0, feature); } ResultsDisplay.Visibility = Visibility.Visible; } MyDrawObject.IsEnabled = true; }
void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; if (featureSet != null && featureSet.Features.Count > 0) { SelectedWellsTreeView.Tag = featureSet.ObjectIdFieldName; SelectedWellsTreeView.ItemsSource = featureSet.Features; foreach (Graphic g in featureSet.Features) { g.Symbol = LayoutRoot.Resources["SelectMarkerSymbol"] as MarkerSymbol; graphicsLayer.Graphics.Add(g); } ResultsDisplay.Visibility = System.Windows.Visibility.Visible; } else { ResultsDisplay.Visibility = System.Windows.Visibility.Collapsed; MessageBox.Show("No wells found here, please try another location."); } }
private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; if (featureSet == null || featureSet.Features.Count < 1) { MessageBox.Show("No features returned from query"); return; } if (featureSet != null && featureSet.Features.Count > 0) { foreach (Graphic graphic in featureSet.Features) { graphic.Symbol = LayoutRoot.Resources["FootprintFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol;; footprintsGraphicsLayer.Graphics.Add(graphic); } } myDrawObject.IsEnabled = true; }
void StatesGraphicsLayerQueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs queryArgs) { if (queryArgs.FeatureSet == null) { return; } FeatureSet resultFeatureSet = queryArgs.FeatureSet; ESRI.ArcGIS.Client.GraphicsLayer graphicsLayer = MyMap.Layers["StatesGraphicsLayer"] as ESRI.ArcGIS.Client.GraphicsLayer; if (resultFeatureSet != null && resultFeatureSet.Features.Count > 0) { foreach (ESRI.ArcGIS.Client.Graphic graphicFeature in resultFeatureSet.Features) { graphicFeature.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(graphicFeature); } } }
private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { KeyValuePair <int, int>[] DataValues; DataValues = new KeyValuePair <int, int> [24]; int[] CalcOf24Hour = new int[24]; try { for (int i = 0; i < 24; i++) { CalcOf24Hour[i] = 0; } FeatureSet featureSet = args.FeatureSet; if (featureSet != null && featureSet.Features.Count > 0) { foreach (Graphic feature in featureSet.Features) // 统计当天案件数 { DateTime bjsj = DateTime.Parse(feature.Attributes["BJSJ"].ToString()); CalcOf24Hour[bjsj.Hour] += 1; } } for (int i = 0; i < 24; i++) { DataValues[i] = new KeyValuePair <int, int>(i, CalcOf24Hour[i]); } ((ColumnSeries)AJCOUNT).ItemsSource = DataValues; /* AJCOUNT.Dispatcher.Invoke( // 此结构是WIN GUI 处理多线程修改界面元素的保护 * new Action( * delegate * { * AJCOUNT.ItemsSource = AJTJ; * AJCOUNT.Refresh(); * })); */ } catch (Exception) { } }
private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; /* * if (featureSet == null || featureSet.Features.Count < 1) * { * // MessageBox.Show("No features returned from query"); * return; * } * * GraphicsLayer graphicsLayer = GlobalLayers._MainMap.Layers["canvas"] as GraphicsLayer; * if (featureSet != null && featureSet.Features.Count > 0) * { * foreach (Graphic feature in featureSet.Features) * { * feature.Symbol = LayoutRoot.Resources["ResultsFillSymbol"] as FillSymbol; * graphicsLayer.Graphics.Insert(0, feature); * } * ResultsDisplay.Visibility = Visibility.Visible; * } * MyDrawObject.IsEnabled = false; * */ }
private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { // Clear previous results. GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); // Check for new results. FeatureSet featureSet = args.FeatureSet; if (featureSet.Features.Count > 0) { // Add results to the map. foreach (Graphic resultFeature in featureSet.Features) { resultFeature.Symbol = LayoutRoot.Resources["ResultsFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(resultFeature); } } else { MessageBox.Show("No features found"); } }
private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { try { FeatureSet featureSet = args.FeatureSet; if (featureSet == null || featureSet.Features.Count == 0) // 未扫到视频 { return; } if (featureSet.Features.Count > 0) { //foreach (Graphic feature in featureSet.Features) //{ // GlobalLayers._MainMap.Dispatcher.Invoke( // new Action( // delegate // { Graphic feature = featureSet.Features[0]; //只取查询到的摄像头集合的第一个来播 string stdid = feature.Attributes["STDID"].ToString(); //获取视频编号,用来播放视频 //if (!GeomServControl.alVideoNeedToPlay.Contains(stdid))//LPY 2015-3-13 17:00:45 添加 用来修改为另外一种方式显示视频点上墙排版,但是效果不好,暂时注释掉 //{ // GeomServControl.alVideoNeedToPlay.Add(stdid); // return; //} //return; if (GeomServControl.alVideosPlayed.Contains(stdid))//首个视频编号已存在于已播放列表,不需要重新打开,其实也不用打开列表 { //_currentVideo.DB33 = ""; // 不重新打开不能把当前的视频号清除掉 //scrX = 0; //scrY = 0; return; } //if (_currentVideo.DB33 != "") //{ // VideoToWall._closeb20win(QueryLayer._currentVideo.winno, QueryLayer._currentVideo.ptr); // //QueryLayer.lastPlayedid = ""; // _currentVideo.DB33 = ""; //} double x = Convert.ToDouble(feature.Attributes["X"].ToString());//地图X double y = Convert.ToDouble(feature.Attributes["Y"].ToString()); MapPoint mapPoint = new MapPoint(x, y); mapPoint.SpatialReference = new SpatialReference(4326); Point scrPoint = GlobalLayers._MainMap.MapToScreen(mapPoint); //将地图坐标转换为屏幕坐标,取屏幕x,y作为视频开窗起始点 _currentVideo.DB33 = stdid; //待播放的视频ID lastPlayedid = stdid; //同时把待播放的视频ID记录为播放下一个视频前需要关闭的视频编号 int videoX = Convert.ToInt32(scrPoint.X); videoX = videoX < 0 ? 0 : videoX; //坐标小于0的话,取0值 scrX = Convert.ToInt32(videoX * 1.2) - shiftX; //这里的1.2和下面Y坐标乘以1.6是因为大屏分辨率的问题,可能还需调整 scrX = scrX > 0 ? scrX : 0; int videoY = Convert.ToInt32(scrPoint.Y); videoY = videoY < 0 ? 0 : videoY; scrY = Convert.ToInt32(videoY * 1.6) - shiftY; scrY = scrY > 0 ? scrY : 0;//最小x,y值为0,0 //GlobalLayers._skinfowindow.Width = 200; //VideoToWall._closeallb20win(); if (_currentVideo.DB33 != "") { VideoToWall._closeb20win(_currentVideo.winno, _currentVideo.ptr); } _currentVideo.winno = VideoToWall._openb20win(stdid, scrX, scrY, 1000, 1000, _currentVideo.ptr); //视频上墙 haveOpened = true; //已打开一个视频 GeomServControl.alVideosPlayed.Add(stdid); //Thread.Sleep(TimeSpan.FromSeconds(Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["playtime"]))); /* * string XH = feature.Attributes["XH"].ToString(); // 真实库为大写 * if (!GlobalLayers._GraphicLogCollention.ContainsKey(XH)) // 没有打开过的 * { * Graphic gp = null; * * graphicsLayer = GlobalLayers._MainMap.Layers[LayerName] as GraphicsLayer; * gp = new Graphic(); * gp.Geometry = feature.Geometry; // new MapPoint(122.10324, 30.0219); * gp.Symbol = App.Current.Resources["ResultsSymbol"] as Symbol; * * gp.Attributes["ID"] = XH; // 视频编号为地图上的唯一ID * // XH.Substring(12, 4); // 取视频编号的倒数第二开始的后4位 * // 在视频点名称后面加 4位编码,方便键盘控制 * if (XH.Length == 18) * gp.Attributes["MC"] = feature.Attributes["MC"].ToString() + "(" + XH.Substring(12, 4) + ")"; * else * gp.Attributes["MC"] = feature.Attributes["MC"].ToString(); * if (LayerName == "DynamicResultGraphicLayer") * GlobalLayers.DynamicResultGraphicLayer.Graphics.Add(gp); * else * GlobalLayers.ResultGraphicLayer.Graphics.Add(gp); * * GlobalLayers._GraphicLogCollention.TryAdd(XH, gp); * } * String VID = feature.Attributes["XH"].ToString(); * MapPoint Mp = feature.Geometry as MapPoint; * if (LayerName == "DynamicResultGraphicLayer") // 如果查询的是视频图层,在大屏上处理和GQY的通讯 * GlobalLayers._gqyvideocontrol.FlushOpenVID(VID, Mp); * else * GlobalLayers._gqyvideocontrol.OpenVID(VID, Mp); * */ // })); //} // GlobalLayers.ResultGraphicLayer.Refresh(); } } catch (Exception e) { // MessageBox.Show(e.ToString()); } }
private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; // If initial query to populate states combo box if ((args.UserState as string) == "initial") { // Just show on initial load QueryComboBox.Items.Add("Select..."); foreach (Graphic graphic in args.FeatureSet.Features) { QueryComboBox.Items.Add(graphic.Attributes["STATE_NAME"].ToString()); } QueryComboBox.SelectedIndex = 0; return; } // Remove the first entry if "Select..." if (QueryComboBox.Items[0].ToString().Contains("Select...")) { QueryComboBox.Items.RemoveAt(0); } // If an item has been selected GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); if (featureSet != null && featureSet.Features.Count > 0) { // Show selected feature attributes in DataGrid Graphic selectedFeature = featureSet.Features[0]; QueryDetailsDataGrid.ItemsSource = selectedFeature.Attributes; // Highlight selected feature selectedFeature.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(selectedFeature); // Zoom to selected feature (define expand percentage) ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = selectedFeature.Geometry.Extent; double expandPercentage = 30; double widthExpand = selectedFeatureExtent.Width * (expandPercentage / 100); double heightExpand = selectedFeatureExtent.Height * (expandPercentage / 100); ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope( selectedFeatureExtent.XMin - (widthExpand / 2), selectedFeatureExtent.YMin - (heightExpand / 2), selectedFeatureExtent.XMax + (widthExpand / 2), selectedFeatureExtent.YMax + (heightExpand / 2)); MyMap.ZoomTo(displayExtent); // If DataGrid not visible (initial load), show it if (DataGridScrollViewer.Visibility == Visibility.Collapsed) { DataGridScrollViewer.Visibility = Visibility.Visible; QueryGrid.Height = Double.NaN; QueryGrid.UpdateLayout(); } } else { QueryDetailsDataGrid.ItemsSource = null; DataGridScrollViewer.Visibility = Visibility.Collapsed; QueryGrid.Height = Double.NaN; QueryGrid.UpdateLayout(); } }
private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; // If initial query to populate states list box if ((args.UserState as string) == "initial") { // Just show on initial load QueryListBox.Items.Add("Select..."); foreach (Graphic graphic in args.FeatureSet.Features) { QueryListBox.Items.Add(graphic.Attributes["STATE_NAME"].ToString()); } QueryListBox.SelectedIndex = 0; return; } // Remove the first entry if "Select..." if (QueryListBox.Items[0].ToString().Contains("Select...")) { QueryListBox.Items.RemoveAt(0); } // If an item has been selected GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); if (featureSet != null && featureSet.Features.Count > 0) { // Show selected feature attributes in DataGrid Graphic selectedFeature = featureSet.Features[0]; ResultsListBox.Items.Clear(); //QueryDetailsDataGrid.ItemsSource = selectedFeature.Attributes; foreach (KeyValuePair <string, object> pair in selectedFeature.Attributes) { TextBlock tb1 = new TextBlock() { FontSize = 30, FontWeight = FontWeights.Bold, Text = string.Format("{0}: ", pair.Key) }; TextBlock tb2 = new TextBlock() { FontSize = 30, Text = string.Format(" {0}", pair.Value) }; StackPanel sp = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Vertical }; sp.Children.Add(tb1); sp.Children.Add(tb2); ListBoxItem item = new ListBoxItem(); item.Content = sp; ResultsListBox.Items.Add(item); } // Highlight selected feature selectedFeature.Symbol = DefaultFillSymbol; graphicsLayer.Graphics.Add(selectedFeature); // Zoom to selected feature (define expand percentage) ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = selectedFeature.Geometry.Extent; double expandPercentage = 30; double widthExpand = selectedFeatureExtent.Width * (expandPercentage / 100); double heightExpand = selectedFeatureExtent.Height * (expandPercentage / 100); ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope( selectedFeatureExtent.XMin - (widthExpand / 2), selectedFeatureExtent.YMin - (heightExpand / 2), selectedFeatureExtent.XMax + (widthExpand / 2), selectedFeatureExtent.YMax + (heightExpand / 2)); MyMap.ZoomTo(displayExtent); // If DataGrid not visible (initial load), show it if (ResultsListBox.Visibility == Visibility.Collapsed) { ResultsListBox.Visibility = Visibility.Visible; QueryGrid.Height = Double.NaN; QueryGrid.UpdateLayout(); } } else { //QueryDetailsDataGrid.ItemsSource = null; ResultsListBox.Visibility = Visibility.Collapsed; QueryGrid.Height = Double.NaN; QueryGrid.UpdateLayout(); } }