Exemplo n.º 1
0
        /// <summary>
        /// Called when a sketch is completed.
        /// </summary>
        protected override async Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            var sb           = new StringBuilder();
            var popupContent = await QueuedTask.Run(() =>
            {
                var popupContents = new List <PopupContent>();
                var mapView       = MapView.Active;
                if (mapView != null)
                {
                    //Get the features that intersect the sketch geometry.
                    var features = mapView.GetFeatures(geometry);
                    if (features.Count > 0)
                    {
                        foreach (var kvp in features)
                        {
                            var bfl  = kvp.Key;
                            var oids = kvp.Value;
                            sb.AppendLine($@"{bfl}: {oids.Count} selected");
                            foreach (var objectID in oids)
                            {
                                // for each MapMember/object id combo (within the geometry)
                                // create a DynamicPopupContent in the list of popupContents
                                popupContents.Add(new DynamicPopupContent(bfl, objectID));
                            }
                        }
                    }
                }
                return(popupContents);
            });

            var clickPoint = MouseCursorPosition.GetMouseCursorPosition();
            var popupDef   = new PopupDefinition()
            {
                Append   = true,                             // if true new record is appended to existing (if any)
                Dockable = true,                             // if true popup is dockable - if false Append is not applicable
                Position = clickPoint,                       // Position of top left corner of the popup (in pixels)
                Size     = new System.Windows.Size(200, 400) // size of the popup (in pixels)
            };

            MessageBox.Show($@"Pop-up selection:{Environment.NewLine}{sb.ToString()}");
            MapView.Active.ShowCustomPopup(popupContent, null, true, popupDef);
            return(true);
        }
        /// <summary>
        /// Called when a sketch is completed.
        /// </summary>
        protected override async Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            var popupContent = await QueuedTask.Run(() =>
            {
                var popupContents = new List <PopupContent>();
                var mapView       = MapView.Active;
                if (mapView != null)
                {
                    //Get the features that intersect the sketch geometry.
                    var features = mapView.GetFeatures(geometry);
                    if (features.Count > 0)
                    {
                        foreach (var kvp in features)
                        {
                            var bfl  = kvp.Key;
                            var oids = kvp.Value;
                            foreach (var objectID in oids)
                            {
                                popupContents.Add(new DynamicPopupContent(bfl, objectID));
                            }
                        }
                    }
                }
                return(popupContents);
            });

            var clickPoint = MouseCursorPosition.GetMouseCursorPosition();
            var popupDef   = new PopupDefinition()
            {
                Append   = true,                             // if true new record is appended to existing (if any)
                Dockable = true,                             // if true popup is dockable - if false Append is not applicable
                Position = clickPoint,                       // Position of top left corner of the popup (in pixels)
                Size     = new System.Windows.Size(200, 400) // size of the popup (in pixels)
            };

            MapView.Active.ShowCustomPopup(popupContent, null, true, popupDef);
            return(true);
        }