/// <summary> /// Return result of XAML Service call /// Render geometry to layer /// </summary> /// <remarks> /// if result is greater than recordLimit show a message to reduce area of interest /// </remarks> private void XAMLService_GetSQLDataXAMLCompleted(object sender, GetSQLDataXAMLCompletedEventArgs e) { string layer = e.UserState.ToString(); if (e.Error == null) { int resultCnt = e.Result.OutputFields.Count; if (resultCnt > 0) { if (resultCnt < recordLimit) { totalFeatures += e.Result.OutputFields.Count; totalByteSize += e.Result.XAML.Length; queryTime = e.Result.QueryTime; totalPoints += e.Result.totalPoints; renderStart = DateTime.Now; MapLayer currentLayer = (MapLayer)MainMap.FindName(layer); MapLayer newLayer = (MapLayer)XamlReader.Load(e.Result.XAML); currentLayer.Children.Add(newLayer); foreach (XAMLServiceReference.XAMLFields shp in e.Result.OutputFields) { UIElement el = (UIElement)newLayer.FindName(shp.ID); if (el != null) { el.MouseEnter += polygon_MouseEnter; el.MouseLeave += polygon_MouseLeave; StringBuilder label = new StringBuilder("ID = " + shp.ID + "\n"); foreach (KeyValuePair<string, string> field in shp.Fields) { label.Append(field.Key + ":" + field.Value + "\n"); } ToolTip tt = AddToolTip(label.ToString()); ToolTipService.SetToolTip(el, tt); if (el.GetType().Equals(typeof(Pushpin))) { Pushpin p = (Pushpin)el; p.PositionOrigin = PositionOrigin.BottomCenter; p.Background = new SolidColorBrush(MiscFunctions.ColorFromInt(LayerStyle[layer].fill)); p.Foreground = new SolidColorBrush(Colors.Black); p.FontSize = 8; } if (el.GetType().Equals(typeof(MapLayer))) { MapLayer p = (MapLayer)el; foreach (MapPolygon mp in p.Children) { mp.Fill = new SolidColorBrush(MiscFunctions.ColorFromInt(LayerStyle[layer].fill)); mp.Stroke = new SolidColorBrush(MiscFunctions.ColorFromInt(LayerStyle[layer].stroke)); mp.Opacity = LayerStyle[layer].opacity; } } if (el.GetType().Equals(typeof(MapPolyline))) { MapPolyline p = (MapPolyline)el; p.Stroke = new SolidColorBrush(MiscFunctions.ColorFromInt(LayerStyle[layer].stroke)); p.StrokeThickness = 2; p.StrokeMiterLimit = 0; } if (el.GetType().Equals(typeof(MapPolygon))) { MapPolygon p = (MapPolygon)el; p.Stroke = new SolidColorBrush(MiscFunctions.ColorFromInt(LayerStyle[layer].stroke)); p.Fill = new SolidColorBrush(MiscFunctions.ColorFromInt(LayerStyle[layer].fill)); p.Opacity = LayerStyle[layer].opacity; } } } renderStop = DateTime.Now; } else { ShowMessage("Too many records for Vector display, " + resultCnt + ". Try a smaller area of interest."); } } } else { ShowMessage("Error occurred while loading layer from database:" + e.Error.Message); } // if this is the last layer call cleanup loading and allow menu interaction if (--layerCnt == 0) { SidePanelBorder.IsHitTestVisible = true; loaderStop(); } //update metrics ((TextBlock)metrics.FindName("features")).Text = totalFeatures.ToString(); ((TextBlock)metrics.FindName("points")).Text = totalPoints.ToString(); ((TextBlock)metrics.FindName("bytesize")).Text = totalByteSize.ToString(); }