コード例 #1
0
 protected override void OnClick()
 {
     //already open?
     if (_trialwarning != null)
     {
         return;
     }
     _trialwarning         = new TrialWarning();
     _trialwarning.Owner   = FrameworkApplication.Current.MainWindow;
     _trialwarning.Closed += (o, e) => { _trialwarning = null; };
     _trialwarning.Show();
     //uncomment for modal
     //_trialwarning.ShowDialog();
 }
コード例 #2
0
        /// <summary>
        /// Create a map raster layer using the URL of the gallery item
        /// </summary>
        /// <param name="item"></param>
        private async void OpenWebMapAsync(object item)
        {
            if (item is Mosaic mosaic)
            {
                if (MapView.Active == null)
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("A map must be added the the project and be active");
                    //FrameworkApplication.State.Deactivate("planet_state_connection");
                    return;
                }
                Project project          = Project.Current;
                var     serverConnection = new CIMProjectServerConnection {
                    URL = mosaic._links._self.Substring(0, mosaic._links._self.IndexOf("?")) + "/wmts?REQUEST=GetCapabilities&api_key=" + Module1.Current.API_KEY.API_KEY_Value
                };
                var connection = new CIMWMTSServiceConnection {
                    ServerConnection = serverConnection
                };
                await QueuedTask.Run(() =>
                {
                    var extent            = MapView.Active.Extent;
                    string layerName      = "Planet Basemaps";
                    GroupLayer groupLayer = MapView.Active.Map.FindLayers(layerName).FirstOrDefault() as GroupLayer;
                    if (groupLayer == null)
                    {
                        int index  = MapView.Active.Map.Layers.Count;
                        groupLayer = LayerFactory.Instance.CreateGroupLayer(MapView.Active.Map, index, layerName);
                    }
                    BasicRasterLayer layer2 = LayerFactory.Instance.CreateRasterLayer(connection, groupLayer, 0, mosaic.name);
                    MapView.Active.ZoomTo(extent, TimeSpan.Zero);
                });
            }

            //Hardcoding trial to false so warning is never shown per Annies request 20190703
            Module1.Current.IsTrial = false;
            if (Module1.Current.IsTrial)
            {
                TrialWarning _trialwarning = new TrialWarning();
                _trialwarning.Owner   = FrameworkApplication.Current.MainWindow;
                _trialwarning.Closed += (o, e) => { _trialwarning = null; };
                _trialwarning.ShowDialog();
            }
        }
コード例 #3
0
        /// <summary>
        /// Create a map raster layer using the URL of the gallery item
        /// </summary>
        /// <param name="item"></param>
        private async void OpenWebMapAsync(object item)
        {
            if (item is Mosaic mosaic)
            {
                if (MapView.Active == null)
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("A map must be added the the project and be active");
                    //FrameworkApplication.State.Deactivate("planet_state_connection");
                    return;
                }
                Project project          = Project.Current;
                var     serverConnection = new CIMProjectServerConnection {
                    URL = mosaic._links._self.Substring(0, mosaic._links._self.IndexOf("?")) + "/wmts?REQUEST=GetCapabilities&api_key=" + Module1.Current.API_KEY.API_KEY_Value
                };
                var connection = new CIMWMTSServiceConnection {
                    ServerConnection = serverConnection
                };
                await QueuedTask.Run(() =>
                {
                    var extent            = MapView.Active.Extent;
                    string layerName      = Model.Asset.BasemapsGroup;
                    GroupLayer groupLayer = MapView.Active.Map.FindLayers(layerName).FirstOrDefault() as GroupLayer;
                    if (groupLayer == null)
                    {
                        //add basemap group above any existing basemap-type layers, but below planet daily
                        //imagery group layer
                        IEnumerable <Layer> layers = MapView.Active.Map.Layers;
                        int targetIndex            = 0;
                        int lowestIndex            = MapView.Active.Map.Layers.Count;
                        if (lowestIndex > 0)
                        {
                            lowestIndex = lowestIndex - 1;
                            foreach (Layer layer in layers)
                            {
                                if (layer.Name == Model.Asset.RootGroup)
                                {
                                    targetIndex = MapView.Active.Map.Layers.IndexOf(layer) + 1;
                                    break;
                                }
                                if (layer is GroupLayer group)
                                {
                                    IEnumerable <Layer> children = group.GetLayersAsFlattenedList();
                                    foreach (Layer child in children)
                                    {
                                        string childType = child.GetType().Name;
                                        if (Model.Asset.ValidTypes.Contains(childType))
                                        {
                                            int layerIndex = MapView.Active.Map.Layers.IndexOf(group);
                                            if (layerIndex < lowestIndex)
                                            {
                                                lowestIndex = layerIndex;
                                                break;
                                            }
                                        }
                                    }
                                }
                                string type = layer.GetType().Name;
                                if (Model.Asset.ValidTypes.Contains(type))
                                {
                                    int layerIndex = MapView.Active.Map.Layers.IndexOf(layer);
                                    if (layerIndex < lowestIndex)
                                    {
                                        lowestIndex = layerIndex;
                                    }
                                }
                            }
                        }
                        if (targetIndex == 0)
                        {
                            targetIndex = lowestIndex == 0 ? lowestIndex : lowestIndex - 1;
                        }
                        groupLayer = LayerFactory.Instance.CreateGroupLayer(MapView.Active.Map, targetIndex, layerName);
                    }
                    try
                    {
                        BasicRasterLayer layer2 = LayerFactory.Instance.CreateRasterLayer(connection, groupLayer, 0, mosaic.name);
                        MapView.Active.ZoomTo(extent, TimeSpan.Zero);
                    }
                    catch (Exception)
                    {
                        ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("There is a problem loading the basemap. This is mostly likely due to a permissions issue.");
                    }
                });
            }

            //Hardcoding trial to false so warning is never shown per Annies request 20190703
            Module1.Current.IsTrial = false;
            if (Module1.Current.IsTrial)
            {
                TrialWarning _trialwarning = new TrialWarning();
                _trialwarning.Owner   = FrameworkApplication.Current.MainWindow;
                _trialwarning.Closed += (o, e) => { _trialwarning = null; };
                _trialwarning.ShowDialog();
            }
        }