/// <summary>
        /// Occurs when the More Details button is clicked. Shows more details of a map in the MapDetailsControl in the Backstage.
        /// </summary>
        private void MoreDetailsButton_Click(object sender)
        {
            HyperlinkButton button = (HyperlinkButton)sender;
            ListBoxItem     lbi    = Util.GetParentOfType <ListBoxItem>(button);

            ResultsListBox.SelectedItem  = lbi.DataContext;
            MapDetailsControl.Visibility = Visibility.Visible;
            MapDetailsControl.Activate((ContentItem)lbi.DataContext);
        }
Example #2
0
        /// <summary>
        /// Peforms the previous search again.
        /// </summary>
        private void GenerateResults()
        {
            if (SearchResultsTextBlock != null && DataPager != null)
            {
                SearchResultsTextBlock.Text = "";
                DataPager.Visibility        = Visibility.Collapsed;
            }
            Items = null;
            if (ArcGISOnlineEnvironment.ArcGISOnline.User.IsSignedIn)
            {
                ArcGISOnlineEnvironment.ArcGISOnline.Content.Search(ArcGISOnlineEnvironment.WebMapTypeQualifier + " AND owner:" + ArcGISOnlineEnvironment.ArcGISOnline.User.Current.Username, (object sender, ContentSearchEventArgs e) =>
                {
                    if (e.Error != null)
                    {
                        return;
                    }

                    _isDirty = false;

                    Items = new PagedSearchResult(e.Result);
                    DataPager.Visibility      = DataPager.PageCount > 1 ? Visibility.Visible : Visibility.Collapsed;
                    ResultsListBox.Visibility = e.Result.TotalCount > 0 ? Visibility.Visible : Visibility.Collapsed;

                    //select first item in list and show/hide map details depending on
                    //if it was previously visible
                    //
                    if (e.Result.Items != null && e.Result.Items.Length > 0)
                    {
                        SearchResultsTextBlock.Text = string.Format(ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.Resources.Strings.MyMapControlMaps, e.Result.TotalCount.ToString());
                        ResultsListBox.SelectedItem = e.Result.Items[0];
                        ResultsListBox.ScrollIntoView(e.Result.Items[0]);
                        if (MapDetailsControl.Visibility == Visibility.Visible)
                        {
                            MapDetailsControl.Activate(e.Result.Items[0]);
                        }
                    }
                    else
                    {
                        MapDetailsControl.Visibility = Visibility.Collapsed;
                        SearchResultsTextBlock.Text  = ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.Resources.Strings.MyMapControlZeroMaps;
                    }
                });
            }
        }
        /// <summary>
        /// Raised when the asynchronous call to search using the ContentService has completed.
        /// </summary>
        void SearchCompleted(object sender, ContentSearchEventArgs e)
        {
            SearchButton.IsEnabled       = true;
            SearchTextBox.IsEnabled      = true;
            ProgressIndicator.Visibility = Visibility.Collapsed;

            if (e.Error != null)
            {
                return;
            }

            Items = new PagedSearchResult(e.Result);
            DataPager.Visibility          = DataPager.PageCount > 1 ? Visibility.Visible : Visibility.Collapsed;
            MapResultsListBox.Visibility  = e.Result.TotalCount > 0 ? Visibility.Visible : Visibility.Collapsed;
            SortByToggleButton.Visibility = e.Result.TotalCount > 0 ? Visibility.Visible : Visibility.Collapsed;

            SearchResultsTextBlock.Text = string.Format(ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.Resources.Strings.SearchMapResultsFor, e.Result.TotalCount.ToString(), SearchTextBox.Text);
            SearchTextBox.SelectAll();
            SearchTextBox.Focus();

            //select first item in list and show/hide map details depending on
            //if it was previously visible
            //
            if (e.Result.Items.Length > 0)
            {
                MapResultsListBox.SelectedItem = e.Result.Items[0];
                MapResultsListBox.ScrollIntoView(e.Result.Items[0]);
                if (MapDetailsControl.Visibility == Visibility.Visible)
                {
                    MapDetailsControl.Activate(e.Result.Items[0]);
                }
            }
            else
            {
                MapDetailsControl.Visibility = Visibility.Collapsed;
            }
        }
Example #4
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;
                }
            }
        }