Exemplo n.º 1
0
        void ReleaseDesignerOutlets()
        {
            if (ArticleAbstract != null)
            {
                ArticleAbstract.Dispose();
                ArticleAbstract = null;
            }

            if (SearchResultsTableView != null)
            {
                SearchResultsTableView.Dispose();
                SearchResultsTableView = null;
            }

            if (SearchTermInput != null)
            {
                SearchTermInput.Dispose();
                SearchTermInput = null;
            }

            if (ResultsScrollView != null)
            {
                ResultsScrollView.Dispose();
                ResultsScrollView = null;
            }
        }
        internal void UpdateResults(IList newItems)
        {
            _results.Clear();

            foreach (SearchSuggestion item in newItems)
            {
                _results.Add(item);
            }

            SearchResultsTableView.ReloadData();
            UpdateViewHeight();
        }
Exemplo n.º 3
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();
            // assign the custom datasource to the tableview datasource
            SearchResultsTableView.DataSource = new SearchResultsTableViewDataSource();
            SearchResultsTableView.Delegate   = new SearchResultsTableDelegate(ArticleAbstract);
            PMQ = new PubMedQuery();

            // http://borkware.com/quickies/one?topic=NSScrollView
            // http://stackoverflow.com/questions/7612166/nsnotificationcenter-postnotificationname-with-null-object-does-not-trigger-b
            // first tell the contentView (the NSClipView) to post notifications when its bounds changes
            ResultsScrollView.ContentView.PostsBoundsChangedNotifications = true;
//			NSNotificationCenter center = new NSNotificationCenter ();
//			center.AddObserver("boundsDidChangeNotification", recievedNotice);

            // event callback if user pressed the enter button
            SearchTermInput.EditingEnded += (object sender, EventArgs e) => {
                // don't allow duplicate searches in sequence or search terms for empty strings
                if (SearchTermInput.StringValue != searchTerm && SearchTermInput.StringValue != "")
                {
                    // remember last search term so duplicate searches are not made in sequence
                    searchTerm = SearchTermInput.StringValue;
                    PMQ.Search(searchTerm);

                    // set the window title to number of results
                    Window.Title = PMQ.totalMatchedItems + " results";

                    // update the tableview with authors and titles
                    SearchResultsTableViewDataSource.authors.Clear();
                    SearchResultsTableViewDataSource.titles.Clear();
                    foreach (Dictionary <string, string> article in PMQ.results)
                    {
                        SearchResultsTableViewDataSource.authors.Add(article["author"]);
                        SearchResultsTableViewDataSource.titles.Add(article["title"]);
                        SearchResultsTableViewDataSource.years.Add(article["year"]);
                    }
                    SearchResultsTableView.ReloadData();
                }
            };

//			Console.WriteLine (ResultsScrollView.ContentView.Bounds.Location);

            // bug in xamarin.mac so this doesn't work as it should
            // http://forums.xamarin.com/discussion/4632/nstableview-selectiondidchange-problem
            // https://bugzilla.xamarin.com/show_bug.cgi?id=12467
//			SearchResultsTableView.SelectionDidChange += (object sender, EventArgs e) => {
//				Console.WriteLine(SearchResultsTableView.SelectedRow);
//			};
        }
Exemplo n.º 4
0
        void FilterContentForSearchText(string text)
        {
            //InvokeOnMainThread(() =>
            //{
            if (filteredAds != null)
            {
                filteredAds.Clear();
                filteredAds.AddRange(
                    this.SearchResultsAdList.Where(e =>
                                                   (string.IsNullOrWhiteSpace(text) || e.Name.ToUpper().Contains(text.ToUpper()))
                                                   ));
            }

            SearchResultsTableView.ReloadData();
            //}
        }
 internal void ClearResults()
 {
     _results.Clear();
     SearchResultsTableView.ReloadData();
     UpdateViewHeight();
 }