Пример #1
0
        public void ShowCustomPopupWithWindowDef()
        {
            if (MapView.Active == null)
            {
                return;
            }

            //Create custom popup content
            var popups = new List <PopupContent>
            {
                new PopupContent("<b>This text is bold.</b>", "Custom tooltip from HTML string"),
                new PopupContent(new Uri("http://www.esri.com/"), "Custom tooltip from Uri")
            };
            // Sample code: https://github.com/ArcGIS/arcgis-pro-sdk-community-samples/blob/master/Framework/DynamicMenu/DynamicFeatureSelectionMenu.cs
            var topLeftCornerPoint = new System.Windows.Point(200, 200);
            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 = topLeftCornerPoint,               // 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(popups, null, true, popupDef);
        }
        private Task CreateAdvancedPopupAsync(FeatureLayer fl)
        {
            return(QueuedTask.Run(() => {
                var def = fl.GetDefinition() as CIMFeatureLayer;
                string popupText = string.Format("{0} ({1}), population {2}",
                                                 PopupDefinition.FormatFieldName("STATE_NAME"),
                                                 PopupDefinition.FormatFieldName("STATE_ABBR"),
                                                 PopupDefinition.FormatFieldName("TOTPOP2010"));

                //Create a popup definition with text and table, an image and some different chart types
                //Just add all the table fields by default like we did for the "Simple Popup"
                PopupDefinition popup = new PopupDefinition()
                {
                    Title = PopupDefinition.FormatTitle(
                        string.Format("{0} (Advanced Popup)", PopupDefinition.FormatFieldName(def.FeatureTable.DisplayField))),
                    TextMediaInfo = new TextMediaInfo()
                    {
                        Text = PopupDefinition.FormatText(popupText)
                    },
                    TableMediaInfo = new TableMediaInfo(fl.GetFeatureClass().GetDefinition().GetFields()),
                    OtherMediaInfos =
                    {
                        //Add an image of the US
                        new ImageMediaInfo()
                        {
                            SourceURL = PopupDefinition.FormatUrl(
                                new Uri("http://www.town-usa.com/images/timezone.gif", UriKind.Absolute))
                        },
                        //Add a column chart to the popup carousel
                        new ChartMediaInfo()
                        {
                            Title = PopupDefinition.FormatTitle("Column Chart"),
                            Caption = PopupDefinition.FormatCaption("1990 vs 2000 population"),
                            ChartMediaType = ChartMediaType.Column,
                            FieldNames ={ "POP1990",                  "POP2000"    }
                        },
                        //Add a pie chart to the popup carousel
                        new ChartMediaInfo()
                        {
                            Title = PopupDefinition.FormatTitle("Pie Chart"),
                            Caption = PopupDefinition.FormatCaption("2012 House Dem. vs Rep."),
                            ChartMediaType = ChartMediaType.Pie,
                            FieldNames ={ "Y2012HOU_D",               "Y2012HOU_R" }
                        },
                        //Add a line chart to the popup carousel
                        new ChartMediaInfo()
                        {
                            Title = PopupDefinition.FormatTitle("Line Chart"),
                            Caption = PopupDefinition.FormatCaption("Pop Change 1990 to 2000"),
                            ChartMediaType = ChartMediaType.Line,
                            FieldNames ={ "POP1990",                  "POP2000"    }
                        }
                    }
                };

                fl.SetPopupInfo(popup.CreatePopupInfo());
            }));
        }
Пример #3
0
        public void ShowPopupWithWindowDef(MapMember mapMember, long objectID)
        {
            if (MapView.Active == null)
            {
                return;
            }
            // Sample code: https://github.com/ArcGIS/arcgis-pro-sdk-community-samples/blob/master/Map-Exploration/CustomIdentify/CustomIdentify.cs
            var topLeftCornerPoint = new System.Windows.Point(200, 200);
            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 = topLeftCornerPoint,               // 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.ShowPopup(mapMember, objectID, popupDef);
        }
Пример #4
0
        private void ShowPopUp(string message, string titleText)
        {
            if (WindowsController.Instance.PopupController == null)
            {
                Debug.LogError("Needs an instance of PopupController to work.");
                return;
            }

            var newPopUp = new PopupDefinition();

            newPopUp.hasCancelButton = false;
            newPopUp.cancelText      = "Cancel";
            newPopUp.confirmText     = "OK";
            newPopUp.descriptionText = message;
            newPopUp.titleText       = "Error";

            WindowsController.Instance.PopupController.Show(newPopUp, null, null, true);
        }
Пример #5
0
    public void Show(PopupDefinitions definition, Action confirm, Action cancel, bool closeWindowsOnConfirm = false)
    {
        PopupDefinition def = definitions[(int)definition];

        this.closeWindowsOnConfirm = closeWindowsOnConfirm;
        this.confirm = confirm;
        this.cancel  = cancel;

        if (popup != null)
        {
            popup.Setup(def.ConfirmText, def.DescriptionText, Confirm, Cancel);
        }
        else
        {
            Debug.LogWarning("There's no UIPopup in the scene.");
        }

        windowController.HideLastWindow();
    }
Пример #6
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);
        }
Пример #7
0
        void OnFeatureSelected(BasicFeatureLayer layer, long oid)
        {
            var mapView = MapView.Active;

            mapView?.FlashFeature(layer, oid);
            Thread.Sleep(1000);
            mapView?.FlashFeature(layer, oid);
            System.Windows.Point mousePnt = 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 = mousePnt,                         // Position of top left corner of the popup (in pixels)
                Size     = new System.Windows.Size(200, 400) // size of the popup (in pixels)
            };

            //Show pop-up of feature
            mapView?.ShowPopup(layer, oid, popupDef);
        }
        /// <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);
        }
Пример #9
0
        private Task CreateSimplePopupAsync(FeatureLayer fl)
        {
            return(QueuedTask.Run(() => {
                var def = fl.GetDefinition() as CIMFeatureLayer;
                string popupText = string.Format("{0} ({1}), population {2}",
                                                 PopupDefinition.FormatFieldName("STATE_NAME"),
                                                 PopupDefinition.FormatFieldName("STATE_ABBR"),
                                                 PopupDefinition.FormatFieldName("TOTPOP2010"));
                //Create a popup definition with text and table
                //Just add all the table fields by default
                PopupDefinition popup = new PopupDefinition()
                {
                    Title = PopupDefinition.FormatTitle(
                        string.Format("{0} (Simple Popup)", PopupDefinition.FormatFieldName(def.FeatureTable.DisplayField))),
                    TextMediaInfo = new TextMediaInfo()
                    {
                        Text = PopupDefinition.FormatText(popupText)
                    },
                    TableMediaInfo = new TableMediaInfo(fl.GetFeatureClass().GetDefinition().GetFields())
                };

                fl.SetPopupInfo(popup.CreatePopupInfo());
            }));
        }
Пример #10
0
        protected override async Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e)
        {
            await QueuedTask.Run(() =>
            {
                var mapPoint = MapPointBuilder.CreateMapPoint(e.ClientPoint.X, e.ClientPoint.Y);
                var result   = ActiveMapView.GetFeatures(mapPoint);
                List <PopupContent> popups = new List <PopupContent>();
                foreach (var kvp in result)
                {
                    var layer = kvp.Key as BasicFeatureLayer;
                    if (layer == null)
                    {
                        continue;
                    }
                    var fields   = layer.GetFieldDescriptions().Where(f => f.Name == "DI_JI_HAO");
                    var tableDef = layer.GetTable().GetDefinition();
                    var oidField = tableDef.GetObjectIDField();
                    foreach (var id in kvp.Value)
                    {
                        //获取地级编号
                        //DI_JI_HAO
                        var qf = new QueryFilter()
                        {
                            WhereClause = $"{oidField} = {id}", SubFields = string.Join(",", fields.Select(f => f.Name))
                        };
                        var rows = layer.Search(qf);
                        if (!rows.MoveNext())
                        {
                            continue;
                        }
                        using (var row = rows.Current)
                        {
                            foreach (var field in fields)
                            {
                                var val = row[field.Name];
                                if (field.Name == "DI_JI_HAO")
                                {
                                    PopupContent pc = new PopupContent(new Uri("http://59.42.105.34:5001/client/?id=" + val), "林业");
                                    popups.Add(pc);
                                }
                            }
                        }
                    }
                }

                //Flash the features that intersected the sketch geometry.
                MessageBox.Show(popups.ToString());
                ActiveMapView.FlashFeature(result);
                var height             = System.Windows.SystemParameters.WorkArea.Height / 2;
                var width              = System.Windows.SystemParameters.WorkArea.Width / 2;
                var topLeftCornerPoint = new System.Windows.Point(0, 0);
                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 = topLeftCornerPoint,                    // Position of top left corner of the popup (in pixels)
                    Size     = new System.Windows.Size(width, height) // size of the popup (in pixels)
                };

                //Show the custom pop-up with the custom commands and the default pop-up commands.
                try
                {
                    ActiveMapView.ShowCustomPopup(popups, null, true, popupDef);
                } catch (System.Exception e1)
                {
                    MessageBox.Show(string.Format("{0}", e1));
                }

                //return the collection of pop-up content object.
            });
        }
Пример #11
0
        /// <summary>
        /// Called when a sketch is completed.
        /// </summary>
        protected override async Task <bool> OnSketchCompleteAsync(ArcGIS.Core.Geometry.Geometry geometry)
        {
            List <PopupContent> popupContent = await QueuedTask.Run(() =>
            {
                //Get the features that intersect the sketch geometry.
                var mapPoint = geometry as MapPoint;
                var sb       = new StringBuilder();

                sb.AppendLine(string.Format("OnSketchCompleteAsync X: {0}", mapPoint.X));
                sb.Append(string.Format("Y: {0}", mapPoint.Y));
                if (mapPoint.HasZ)
                {
                    sb.AppendLine();
                    sb.Append(string.Format("Z: {0}", mapPoint.Z));
                }
                MessageBox.Show(sb.ToString());

                var result = ActiveMapView.GetFeatures(geometry);

                //For each feature in the result create a new instance of our custom pop-up content class.
                List <PopupContent> popups = new List <PopupContent>();
                foreach (var kvp in result)
                {
                    //kvp.Value.ForEach(id => popups.Add(new DynamicPopupContent(kvp.Key, id)));
                    //kvp.Value.ForEach(id => popups.Add(new PopupContent(new Uri("https://www.google.com/webhp?ie=UTF-8&rct=j"), "xxxx")));
                    //popups.Add(new PopupContent("<b>This text is bold.</b>", "Custom tooltip from HTML string"));

                    var layer = kvp.Key as BasicFeatureLayer;
                    if (layer == null)
                    {
                        continue;
                    }
                    var fields   = layer.GetFieldDescriptions().Where(f => f.Name == "DI_JI_HAO");
                    var tableDef = layer.GetTable().GetDefinition();
                    var oidField = tableDef.GetObjectIDField();
                    foreach (var id in kvp.Value)
                    {
                        //获取地级编号
                        //DI_JI_HAO
                        var qf = new QueryFilter()
                        {
                            WhereClause = $"{oidField} = {id}", SubFields = string.Join(",", fields.Select(f => f.Name))
                        };
                        var rows = layer.Search(qf);
                        if (!rows.MoveNext())
                        {
                            continue;
                        }
                        using (var row = rows.Current)
                        {
                            foreach (var field in fields)
                            {
                                var val = row[field.Name];
                                if (field.Name == "DI_JI_HAO")
                                {
                                    PopupContent pc = new PopupContent(new Uri("http://59.42.105.34:5001/client/?id=" + val), "林业");
                                    popups.Add(pc);
                                }
                            }
                        }
                    }
                }

                //Flash the features that intersected the sketch geometry.
                ActiveMapView.FlashFeature(result);

                //return the collection of pop-up content object.
                return(popups);
            });

            var height             = System.Windows.SystemParameters.WorkArea.Height / 2;
            var width              = System.Windows.SystemParameters.WorkArea.Width / 2;
            var topLeftCornerPoint = new System.Windows.Point(0, 0);
            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 = topLeftCornerPoint,                    // Position of top left corner of the popup (in pixels)
                Size     = new System.Windows.Size(width, height) // size of the popup (in pixels)
            };

            //Show the custom pop-up with the custom commands and the default pop-up commands.
            ActiveMapView.ShowCustomPopup(popupContent, null, true, popupDef);
            return(true);
        }