private void SelectedItemChanged()
        {
            SearchAggregateItem item = carousel.SelectedItem as SearchAggregateItem;

            if (SelectionChanged != null)
            {
                SelectionChanged(this, new EventArgs.SelectionChangedEventArgs(item));
            }

            if (item != null)
            {
                textItemTitle.Text           = ShumbiDiscover.Controls.Converters.SearchAggregateItemTitleConverter.Convert(item.Title);
                textItemDescription.Text     = ShumbiDiscover.Controls.Converters.SearchAggregateItemDescriptionConverter.Convert(item.Description, 0);
                textItemAddress.Text         = ShumbiDiscover.Controls.Converters.SearchAggregateItemUrlConverter.Convert(item.OpenUrl);
                textItemRank.Text            = ShumbiDiscover.Controls.Converters.SearchAggregateItemRankConverter.Convert(item.ProviderRanks);
                textItemSearchProviders.Text = ShumbiDiscover.Controls.Converters.SearchAggregateItemProvidersConverter.Convert(item.ProviderRanks);
            }
            else
            {
                textItemTitle.Text           = "";
                textItemDescription.Text     = "";
                textItemAddress.Text         = "";
                textItemRank.Text            = "";
                textItemSearchProviders.Text = "";
            }
        }
        private void textItemAddress_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            SearchAggregateItem item = carousel.SelectedItem as SearchAggregateItem;

            if (item != null)
            {
                if (OpenUrlRequested != null)
                {
                    OpenUrlRequested(new Uri(item.OpenUrl));
                }
            }
        }
        void carousel_SelectedIndexActivated(object sender, System.EventArgs e)
        {
            SearchAggregateItem item = carousel.SelectedItem as SearchAggregateItem;

            if (item != null)
            {
                if (OpenUrlRequested != null)
                {
                    OpenUrlRequested(new Uri(item.OpenUrl));
                }
            }
        }
        void DoSearch(object state)
        {
            IList <ISearchResult> results = (state as ISearchProvider).Search(_query, _numResults, _culture);

            if (results != null)
            {
                lock (_resultsDictionary)
                {
                    foreach (ISearchResult searchResult in results)
                    {
                        string resultKey = searchResult.OpenUrl.ToLower();

                        SearchProviderRank searchProviderRank = new SearchProviderRank();
                        searchProviderRank.Provider = searchResult.Provider;
                        searchProviderRank.Rank     = searchResult.Rank;

                        if (_resultsDictionary.ContainsKey(resultKey))
                        {
                            _resultsDictionary[resultKey].ProviderRanks.Add(searchProviderRank);
                        }
                        else
                        {
                            SearchAggregateItem searchAggregateItem = new SearchAggregateItem();
                            searchAggregateItem.Id            = Guid.NewGuid();
                            searchAggregateItem.Title         = Obany.Communications.HtmlHelper.Cleanup(searchResult.Title);
                            searchAggregateItem.Description   = Obany.Communications.HtmlHelper.Cleanup(searchResult.Description);
                            searchAggregateItem.OpenUrl       = searchResult.OpenUrl;
                            searchAggregateItem.ThumbnailUrl  = searchResult.ThumbnailUrl;
                            searchAggregateItem.ContentUrl    = searchResult.ContentUrl;
                            searchAggregateItem.Kind          = searchResult.Kind.ToString();
                            searchAggregateItem.ProviderRanks = new List <SearchProviderRank>();
                            searchAggregateItem.ProviderRanks.Add(searchProviderRank);

                            _resultsDictionary.Add(resultKey, searchAggregateItem);
                        }
                    }
                }
            }

            _runningCount--;
        }
        private void PopulateDocumentViewerFromCluster(SearchCluster cluster, Dictionary <Guid, SearchAggregateItem> searchResultDictionary, List <SearchAggregateItem> items, List <string> kindFilters, List <string> providerFilters)
        {
            if (cluster.SearchClusters != null)
            {
                foreach (SearchCluster subCluster in cluster.SearchClusters)
                {
                    PopulateDocumentViewerFromCluster(subCluster, searchResultDictionary, items, kindFilters, providerFilters);
                }
            }

            if (cluster.SearchResultIds != null)
            {
                foreach (Guid searchResultId in cluster.SearchResultIds)
                {
                    if (searchResultDictionary.ContainsKey(searchResultId))
                    {
                        SearchAggregateItem searchResultItem = searchResultDictionary[searchResultId];

                        // First skip any duplicates
                        if (!items.Contains(searchResultItem))
                        {
                            if (kindFilters.Contains(searchResultItem.Kind))
                            {
                                bool found = false;

                                for (int i = 0; i < searchResultItem.ProviderRanks.Count && !found; i++)
                                {
                                    if (providerFilters.Contains(searchResultItem.ProviderRanks[i].Provider))
                                    {
                                        items.Add(searchResultItem);
                                        found = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Value Constructor
 /// </summary>
 /// <param name="newValue">The new value</param>
 public SelectionChangedEventArgs(SearchAggregateItem newValue)
 {
     _newValue = newValue;
 }
        private void ThumbnailCompleted(string url, bool isPreview, object userState, bool success)
        {
            if (success)
            {
                SearchAggregateItem searchResultItem = userState as SearchAggregateItem;

                if (searchResultItem != null)
                {
                    Action a = delegate()
                    {
                        if (!string.IsNullOrEmpty(url))
                        {
#if SILVERLIGHT
                            // If this is the preview then just set the image url
                            // if it is not then load the image in the background until it is ready
                            // this way there will be no flicker when the images are switched
                            // But still do a background load of the image for previews as this will
                            // improve display times for images that have yet to be viewed in a control
                            if (isPreview)
                            {
                                // By assigning the new url source it will trigger the notify property changed
                                // and propogate to anything displaying it
                                searchResultItem.ThumbnailUrl = url;
                            }

                            // Load the new url into an image control, only when the image
                            // has been successfully loaded do we update anything else
                            // by triggering the property changed

                            Image image = new Image();

                            System.Windows.Media.Imaging.BitmapImage bitmapImage = new System.Windows.Media.Imaging.BitmapImage();

                            gridBuffer.Children.Add(image);
                            image.Width  = 300;
                            image.Height = 300;

                            bitmapImage.ImageOpened += delegate(object sender, RoutedEventArgs e)
                            {
                                if (!isPreview)
                                {
                                    // By assigning the new url source it will trigger the notify property changed
                                    // and propogate to anything displaying it
                                    searchResultItem.ThumbnailUrl = url;
                                }

                                if (gridBuffer.Children.Contains(image))
                                {
                                    gridBuffer.Children.Remove(image);
                                }
                            };
                            bitmapImage.UriSource = new Uri(url);

                            image.Source = bitmapImage;
#else
                            // By assigning the new url source it will trigger the notify property changed
                            // and propogate to anything displaying it
                            searchResultItem.ThumbnailUrl = url;
#endif
                        }
                    };
                    Dispatcher.BeginInvoke(a);
                }
            }
        }
 /// <summary>
 /// Convert the description
 /// </summary>
 /// <param name="searchProviderRanks">The value</param>
 /// <returns>Converted value</returns>
 public static string Convert(List <SearchProviderRank> searchProviderRanks)
 {
     return(SearchAggregateItem.CalculateRank(searchProviderRanks, _providerFilters).ToString());
 }
 /// <summary>
 /// Value Constructor
 /// </summary>
 /// <param name="newValue">The new value</param>
 public SelectionChangedEventArgs(SearchAggregateItem newValue)
 {
     _newValue = newValue;
 }