Esempio n. 1
0
        /// <summary>
        /// Occurs when the FeatureThisMapButton is clicked.
        /// Features/unfeatures the associated map in the group.
        /// </summary>
        private void FeatureThisMapButton_Click(object sender)
        {
            Group                  group   = ((GroupBindingWrapper)DataContext).Content;
            FrameworkElement       button  = (FrameworkElement)sender;
            GroupMapBindingWrapper wrapper = (GroupMapBindingWrapper)button.DataContext;
            ContentItem            map     = (ContentItem)wrapper.Item;

            if (wrapper.IsFeatured)
            {
                ArcGISOnlineEnvironment.ArcGISOnline.Group.UnfeatureMap(group.Id, map.Id, (object sender2, RequestEventArgs e2) =>
                {
                    if (e2.Error != null)
                    {
                        return;
                    }

                    wrapper.IsFeatured = false;
                });
            }
            else
            {
                ArcGISOnlineEnvironment.ArcGISOnline.Group.FeatureMap(group.Id, map.Id, (object sender2, RequestEventArgs e2) =>
                {
                    if (e2.Error != null)
                    {
                        return;
                    }

                    wrapper.IsFeatured = true;
                });
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Determines the visibility of FeatureThisMapButton. If the signed in user is the owner of
        /// the current group the button is visible otherwise not.
        /// </summary>
        void SetFeatureThisMapButtonVisibility()
        {
            Group group = ((GroupBindingWrapper)DataContext).Content;

            if (group == null)
            {
                return;
            }

            Visibility visibility = Visibility.Collapsed;

            if (ArcGISOnlineEnvironment.ArcGISOnline.User.IsSignedIn && group.Owner.Equals(ArcGISOnlineEnvironment.ArcGISOnline.User.Current.Username))
            {
                visibility = Visibility.Visible;
            }
            else
            {
                visibility = Visibility.Collapsed;
            }

            if (MapsOfGroupListBox.ItemsSource != null)
            {
                foreach (object obj in MapsOfGroupListBox.ItemsSource)
                {
                    GroupMapBindingWrapper wrapper = (GroupMapBindingWrapper)obj;
                    wrapper.FeatureButtonVisibility = visibility;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Raised when the request for featured maps of a group completes.
        /// </summary>
        void GetGroupFeaturedMapsCompleted(object sender, ContentItemsEventArgs e)
        {
            if (e.Error != null || e.Items == null)
            {
                NoFeaturedMapsTextBlock.Visibility = Visibility.Visible;

                if (MapDetailsControl.DataContext == null)
                {
                    MapDetailsControl.Visibility = Visibility.Collapsed;
                }

                //set the content of the FeatureThisMapButtons of the maps in MapsOfGroupListBox
                if (MapsOfGroupListBox.ItemsSource != null)
                {
                    foreach (object obj in MapsOfGroupListBox.ItemsSource)
                    {
                        GroupMapBindingWrapper wrapper = (GroupMapBindingWrapper)obj;
                        wrapper.IsFeatured = false;
                    }
                }
                return;
            }

            ObservableCollection <ContentItem> featuredMaps = new ObservableCollection <ContentItem>();

            foreach (ContentItem item in e.Items)
            {
                if (item.Type == "Web Map")
                {
                    featuredMaps.Add(item);
                }
            }

            //set the content of the FeatureThisMapButtons of the maps in MapsOfGroupListBox
            if (MapsOfGroupListBox.ItemsSource != null)
            {
                foreach (object obj in MapsOfGroupListBox.ItemsSource)
                {
                    GroupMapBindingWrapper wrapper = (GroupMapBindingWrapper)obj;
                    ContentItem            item    = (ContentItem)wrapper.Item;
                    bool itemFound = false;
                    foreach (ContentItem featuredItem in featuredMaps)
                    {
                        if (featuredItem.Id == item.Id)
                        {
                            itemFound          = true;
                            wrapper.IsFeatured = true;
                            break;
                        }
                    }
                    if (!itemFound)
                    {
                        wrapper.IsFeatured = false;
                    }
                }
            }

            if (featuredMaps.Count > 0)
            {
                FeaturedMapsOfGroupListBox.ItemsSource  = featuredMaps;
                FeaturedMapsOfGroupListBox.SelectedItem = featuredMaps[0];
                FeaturedMapsOfGroupListBox.ScrollIntoView(featuredMaps[0]);
                if (MapDetailsControl.Visibility == Visibility.Visible && Tab.SelectedIndex == 1)
                {
                    MapDetailsControl.Activate(featuredMaps[0]);
                }
            }
            else
            {
                NoFeaturedMapsTextBlock.Visibility = Visibility.Visible;
                if (MapDetailsControl.DataContext == null)
                {
                    MapDetailsControl.Visibility = Visibility.Collapsed;
                }
            }
        }