Exemplo n.º 1
0
        /// <summary>
        /// Raised when the search for group maps completes.
        /// </summary>
        void GroupMapsSearchCompleted(object sender, ContentSearchEventArgs e)
        {
            if (e.Error != null)
            {
                NoMapsTextBlock.Visibility = Visibility.Visible;
                return;
            }

            PagedSearchResult pSRes = new PagedSearchResult(e.Result, new WrapperFactoryDelegate(WrapContentItem));

            DataPager.DataContext = pSRes;
            DataPager.Visibility  = DataPager.PageCount > 1 ? Visibility.Visible : Visibility.Collapsed;

            MapsOfGroupListBox.ItemsSource = pSRes;

            SetFeatureThisMapButtonVisibility();

            //check which maps of this group are featured to set the content of the FeatureThisMapButton
            ArcGISOnlineEnvironment.ArcGISOnline.Content.GetRelatedItems(((GroupBindingWrapper)DataContext).Content.FeaturedItemsId, "FeaturedItems2Item", "forward", GetGroupFeaturedMapsCompleted);

            //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)
            {
                MapsOfGroupListBox.SelectedItem = pSRes[0];
                MapsOfGroupListBox.ScrollIntoView(pSRes[0]);
                if (MapDetailsControl.Visibility == Visibility.Visible && Tab.SelectedIndex == 2)
                {
                    MapDetailsControl.Activate(((GroupMapBindingWrapper)MapsOfGroupListBox.SelectedItem).Item);
                }
            }
            else
            {
                NoMapsTextBlock.Visibility   = Visibility.Visible;
                MapDetailsControl.Visibility = Visibility.Collapsed;
            }
        }
        /// <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;
            }
        }
        /// <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;
        }