Beispiel #1
0
 private void ShowSignInPageButton_Click(object sender, EventArgs e)
 {
     if ((ApplicationBar.Buttons[0] as IApplicationBarIconButton).Text.Equals("Sign In"))
     {
         SignInPage.IsOpen = true;
     }
     else //Sign Out
     {
         ResultsListBox.ItemsSource = null;
         WebmapContent.Children.Clear();
         var crd = IdentityManager.Current.FindCredential(DEFAULT_SERVER_URL, portal.CurrentUser.UserName);
         IdentityManager.Current.RemoveCredential(crd);
         portal.InitializeAsync(portal.Url, (credential, exception) =>
         {
             if (exception == null)
             {
                 ResetVisibility();
                 (ApplicationBar.Buttons[0] as IApplicationBarIconButton).Text = "Sign In";
             }
             else
             {
                 MessageBox.Show("Error initializing portal : " + exception.Message);
             }
         });
     }
 }
Beispiel #2
0
 private void ShowSignIn_Click(object sender, RoutedEventArgs e)
 {
     if (SignInButton.Content.ToString() == "Sign In")
     {
         ShadowGrid.Visibility = Visibility.Visible;
         LoginGrid.Visibility  = Visibility.Visible;
     }
     else //Sign Out
     {
         ResultsListBox.ItemsSource = null;
         WebmapContent.Children.Clear();
         var crd = IdentityManager.Current.FindCredential(DEFAULT_SERVER_URL, portal.CurrentUser.UserName);
         IdentityManager.Current.RemoveCredential(crd);
         portal.InitializeAsync(portal.Url, (credential, exception) =>
         {
             if (exception == null)
             {
                 ResetVisibility();
                 SignInButton.Content = "Sign In";
             }
             else
             {
                 MessageBox.Show("Error initializing portal : " + exception.Message);
                 ShadowGrid.Visibility = Visibility.Collapsed;
             }
         });
     }
 }
Beispiel #3
0
        private void LoadPortalBasemaps()
        {
            // Initialize a portal to get the query to return web maps in the basemap gallery
            ArcGISPortal portal = new ArcGISPortal();

            portal.InitializeAsync("http://www.arcgis.com/sharing/rest", (s, e) =>
            {
                if (portal.ArcGISPortalInfo != null)
                {
                    // Return the first 20 basemaps in the gallery
                    SearchParameters parameters = new SearchParameters()
                    {
                        Limit = 20
                    };
                    // Use the advertised query to search the basemap gallery and return web maps as portal items
                    portal.ArcGISPortalInfo.SearchBasemapGalleryAsync(parameters, (result, error) =>
                    {
                        if (error == null && result != null)
                        {
                            basemapList.ItemsSource = result.Results;
                        }
                    });
                }
            });
        }
Beispiel #4
0
        public void InitializePortal(string PortalUrl)
        {
            ArcGISPortal arcgisPortal = new ArcGISPortal();

            arcgisPortal.InitializeAsync(PortalUrl, (p, ex) =>
            {
                if (ex == null)
                {
                    ArcGISPortalInfo portalInfo = p.ArcGISPortalInfo;
                    if (portalInfo == null)
                    {
                        MessageBox.Show("Portal Information could not be retrieved");
                        return;
                    }
                    PropertiesListBox.Items.Add(string.Format("Current Version: {0}", p.CurrentVersion));
                    PropertiesListBox.Items.Add(string.Format("Access: {0}", portalInfo.Access));
                    PropertiesListBox.Items.Add(string.Format("Host Name: {0}", portalInfo.PortalHostname));
                    PropertiesListBox.Items.Add(string.Format("Name: {0}", portalInfo.PortalName));
                    PropertiesListBox.Items.Add(string.Format("Mode: {0}", portalInfo.PortalMode));

                    ESRI.ArcGIS.Client.WebMap.BaseMap basemap = portalInfo.DefaultBaseMap;

                    PropertiesListBox.Items.Add(string.Format("Default BaseMap Title: {0}", basemap.Title));
                    PropertiesListBox.Items.Add(string.Format("WebMap Layers ({0}):", basemap.Layers.Count));

                    foreach (WebMapLayer webmapLayer in basemap.Layers)
                    {
                        PropertiesListBox.Items.Add(webmapLayer.Url);
                    }

                    portalInfo.GetFeaturedGroupsAsync((portalgroup, exp) =>
                    {
                        if (exp == null)
                        {
                            GroupsList.ItemsSource = portalgroup;
                            (ApplicationBar.Buttons[1] as IApplicationBarIconButton).IsEnabled = true;
                        }
                    });

                    portalInfo.SearchFeaturedItemsAsync(new SearchParameters()
                    {
                        Limit = 15
                    }, (result, err) =>
                    {
                        if (err == null)
                        {
                            FeaturedMapsList.ItemsSource = result.Results;
                            (ApplicationBar.Buttons[0] as IApplicationBarIconButton).IsEnabled = true;
                        }
                    });
                }
                else
                {
                    MessageBox.Show("Failed to initialize" + ex.Message.ToString());
                }
            });
        }
        public void InitializePortal(string PortalUrl)
        {
            ArcGISPortal arcgisPortal = new ArcGISPortal();
            arcgisPortal.InitializeAsync(PortalUrl, (p, ex) =>
            {
                if (ex == null)
                {
                    ArcGISPortalInfo portalInfo = p.ArcGISPortalInfo;
                    if (portalInfo == null)
                    {
                        MessageBox.Show("Portal Information could not be retrieved");
                        return;
                    }
                    PropertiesListBox.Items.Add(string.Format("Current Version: {0}", p.CurrentVersion));
                    PropertiesListBox.Items.Add(string.Format("Access: {0}", portalInfo.Access));
                    PropertiesListBox.Items.Add(string.Format("Host Name: {0}", portalInfo.PortalHostname));
                    PropertiesListBox.Items.Add(string.Format("Name: {0}", portalInfo.PortalName));
                    PropertiesListBox.Items.Add(string.Format("Mode: {0}", portalInfo.PortalMode));

                    ESRI.ArcGIS.Client.WebMap.BaseMap basemap = portalInfo.DefaultBaseMap;

                    PropertiesListBox.Items.Add(string.Format("Default BaseMap Title: {0}", basemap.Title));
                    PropertiesListBox.Items.Add(string.Format("WebMap Layers ({0}):", basemap.Layers.Count));

                    foreach (WebMapLayer webmapLayer in basemap.Layers)
                    {
                        PropertiesListBox.Items.Add(webmapLayer.Url);
                    }

                    portalInfo.GetFeaturedGroupsAsync((portalgroup, exp) =>
                    {
                        if (exp == null)
                        {
                            PropertiesListBox.Items.Add("Groups:");

                            ListBox listGroups = new ListBox();
                            listGroups.ItemTemplate = LayoutRoot.Resources["PortalGroupTemplate"] as DataTemplate;

                            listGroups.ItemsSource = portalgroup;
                            PropertiesListBox.Items.Add(listGroups);
                        }
                    });

                    portalInfo.SearchFeaturedItemsAsync(new SearchParameters() { Limit = 15 }, (result, err) =>
                    {
                        if (err == null)
                        {
                            FeaturedMapsList.ItemsSource = result.Results;
                        }
                    });
                }
                else
                    MessageBox.Show("Failed to initialize" + ex.Message.ToString());
            });
        }
Beispiel #6
0
        /// <summary>
        /// Initializes the <see cref="ArcGISPortal"/> instance
        /// </summary>
        /// <param name="portal"></param>
        /// <returns></returns>
        public static Task InitializeTaskAsync(this ArcGISPortal portal)
        {
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();

            portal.InitializeAsync(portal.Url, (agsPortal, ex) =>
            {
                if (ex != null)
                {
                    tcs.TrySetException(ex);
                }
                else
                {
                    tcs.TrySetResult(true);
                }
            });

            return(tcs.Task);
        }
        private void apply(object commandParameter)
        {
            if (ViewerApplication != null)
            {
                if (ViewerApplication.BingMapsAppId != BingMapsAppId)
                {
                    if (View.Instance != null && View.Instance.ConfigurationStore != null)
                        View.Instance.ConfigurationStore.BingMapsAppId = BingMapsAppId;
                    ViewerApplication.BingMapsAppId = BingMapsAppId;
                    if (View.Instance != null && View.Instance.Map != null)
                    {
                        foreach (Layer layer in View.Instance.Map.Layers)
                        {
                            Client.Bing.TileLayer bingLayer = layer as Client.Bing.TileLayer;
                            if (bingLayer != null && ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetUsesBingAppID(bingLayer))
                            {
                                bingLayer.Token = ConfigurationStore.Current.BingMapsAppId;
                                bingLayer.Refresh();
                            }
                        }
                    }
                }
                if (ViewerApplication.PortalAppId != PortalAppId)
                {
                    if (View.Instance != null && View.Instance.ConfigurationStore != null)
                        View.Instance.ConfigurationStore.PortalAppId = PortalAppId;
                    ViewerApplication.PortalAppId = PortalAppId;
                }
                if (ViewerApplication.GeometryService != GeometryServiceUrl)
                {
                    if (View.Instance != null)
                        View.Instance.SetGeometryServiceUrl(GeometryServiceUrl);
                    ViewerApplication.GeometryService = GeometryServiceUrl;
                }

                bool portalChanged = false;
                if (ViewerApplication.ArcGISOnlineSharing != ArcGISOnlineSharing)
                {
                    if (View.Instance != null)
                        View.Instance.ArcGISOnlineSharing = ArcGISOnlineSharing;
                    ViewerApplication.ArcGISOnlineSharing = ArcGISOnlineSharing;
                    portalChanged = true;
                }
                if (ViewerApplication.ArcGISOnlineSecure != ArcGISOnlineSecure)
                {
                    if (View.Instance != null)
                        View.Instance.ArcGISOnlineSecure = ArcGISOnlineSecure;
                    ViewerApplication.ArcGISOnlineSecure = ArcGISOnlineSecure;
                    portalChanged = true;
                }
                if (ViewerApplication.Proxy != Proxy)
                {
                    if (View.Instance != null)
                        View.Instance.ProxyUrl = Proxy;
                    ViewerApplication.Proxy = Proxy;
                }

                if (portalChanged)
                {
                    ArcGISPortal portal = new ArcGISPortal()
                    {
                        Url = View.Instance.BaseUrl.ToLower().StartsWith("https://") ? ArcGISOnlineSecure 
                            : ArcGISOnlineSharing,
                        ProxyUrl = ViewerApplication.ArcGISOnlineProxy
                    };

                    BuilderApplication.Instance.UpdatingSettings = true;
                    portal.InitializeAsync(portal.Url, (o, ex) =>
                    {
                        View.Instance.Portal = portal;
                        BuilderApplication.Instance.UpdatingSettings = false;
                    });
                }
            }
            raiseChange();
        }
Beispiel #8
0
        private void apply(object commandParameter)
        {
            if (ViewerApplication != null)
            {
                if (ViewerApplication.BingMapsAppId != BingMapsAppId)
                {
                    if (View.Instance != null && View.Instance.ConfigurationStore != null)
                    {
                        View.Instance.ConfigurationStore.BingMapsAppId = BingMapsAppId;
                    }
                    ViewerApplication.BingMapsAppId = BingMapsAppId;
                    if (View.Instance != null && View.Instance.Map != null)
                    {
                        foreach (Layer layer in View.Instance.Map.Layers)
                        {
                            Client.Bing.TileLayer bingLayer = layer as Client.Bing.TileLayer;
                            if (bingLayer != null && ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetUsesBingAppID(bingLayer))
                            {
                                bingLayer.Token = ConfigurationStore.Current.BingMapsAppId;
                                bingLayer.Refresh();
                            }
                        }
                    }
                }
                if (ViewerApplication.PortalAppId != PortalAppId)
                {
                    if (View.Instance != null && View.Instance.ConfigurationStore != null)
                    {
                        View.Instance.ConfigurationStore.PortalAppId = PortalAppId;
                    }
                    ViewerApplication.PortalAppId = PortalAppId;
                }
                if (ViewerApplication.GeometryService != GeometryServiceUrl)
                {
                    if (View.Instance != null)
                    {
                        View.Instance.SetGeometryServiceUrl(GeometryServiceUrl);
                    }
                    ViewerApplication.GeometryService = GeometryServiceUrl;
                }

                bool portalChanged = false;
                if (ViewerApplication.ArcGISOnlineSharing != ArcGISOnlineSharing)
                {
                    if (View.Instance != null)
                    {
                        View.Instance.ArcGISOnlineSharing = ArcGISOnlineSharing;
                    }
                    ViewerApplication.ArcGISOnlineSharing = ArcGISOnlineSharing;
                    portalChanged = true;
                }
                if (ViewerApplication.ArcGISOnlineSecure != ArcGISOnlineSecure)
                {
                    if (View.Instance != null)
                    {
                        View.Instance.ArcGISOnlineSecure = ArcGISOnlineSecure;
                    }
                    ViewerApplication.ArcGISOnlineSecure = ArcGISOnlineSecure;
                    portalChanged = true;
                }
                if (ViewerApplication.Proxy != Proxy)
                {
                    if (View.Instance != null)
                    {
                        View.Instance.ProxyUrl = Proxy;
                    }
                    ViewerApplication.Proxy = Proxy;
                }

                if (portalChanged)
                {
                    ArcGISPortal portal = new ArcGISPortal()
                    {
                        Url = View.Instance.BaseUrl.ToLower().StartsWith("https://") ? ArcGISOnlineSecure
                            : ArcGISOnlineSharing,
                        ProxyUrl = ViewerApplication.ArcGISOnlineProxy
                    };

                    BuilderApplication.Instance.UpdatingSettings = true;
                    portal.InitializeAsync(portal.Url, (o, ex) =>
                    {
                        View.Instance.Portal = portal;
                        BuilderApplication.Instance.UpdatingSettings = false;
                    });
                }
            }
            raiseChange();
        }
 private void LoadPortalBasemaps()
 {
     // Initialize a portal to get the query to return web maps in the basemap gallery
     ArcGISPortal portal = new ArcGISPortal();
     portal.InitializeAsync("http://www.arcgis.com/sharing/rest", (s, e) =>
     {
         if (portal.ArcGISPortalInfo != null)
         {
             // Return the first 20 basemaps in the gallery
             SearchParameters parameters = new SearchParameters() { Limit = 20 };
             // Use the advertised query to search the basemap gallery and return web maps as portal items
             portal.ArcGISPortalInfo.SearchBasemapGalleryAsync(parameters, (result, error) =>
             {
                 if (error == null && result != null)
                 {
                     basemapList.ItemsSource = result.Results;
                 }
             });
         }
     });
 }