Example #1
0
        private void Searcher_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {

            aTimer.Enabled = false;
            aTimer.Stop();
            if (e.Cancelled)
            {

                if (flag == 2)
                {/*
                    Searcher.Dispose();
                    displayError("Loading Please Wait !!!");
                    Searcher = new System.ComponentModel.BackgroundWorker();
                    Searcher.WorkerReportsProgress = true;
                    Searcher.WorkerSupportsCancellation = true;
                   */
                    updateStatusBar(" ");
                    flag = 1;
                    this.Author.Children.Clear();
                    this.Paper.Children.Clear();
                    this.Journal.Children.Clear();

                    progressBar.Value = 0;

                    TabItem selectedTab = mw.tabDynamic.SelectedItem as TabItem;
                    if (getSearchBoxText() != "")
                        selectedTab.Header = getSearchBoxText();


                    d.qs = this.getSearchBoxText(); Console.WriteLine(d.qs);
                    d.yl = this.getYlo(); Console.WriteLine(d.yl);
                    d.yh = this.getYhi(); Console.WriteLine(d.yh);
                    d.ic = this.getIncludePatents(); Console.WriteLine(d.ic);
                    d.so = this.getSortOrder(); Console.WriteLine(d.so);
                    d.rt = this.getResultType(); Console.WriteLine(d.rt);
                    d.b = Searcher;
                    d.pageId = currentPageSelected;
                    test = new Controller(this);
                    updateStatusBar("Looking up for " + d.qs+"...");
                    Searcher.RunWorkerAsync(d);
                }
                else
                {
                    updateStatusBar(" ");
                    flag = 0; progressBar.Value = 0;
                    cancel.Visibility = Visibility.Hidden;
                }
            }
            else
            {
                updateStatusBar(" ");
                if (resultList != null)
                {
                    updateStatusBar("Fetched Results.");
                    Console.WriteLine(this.resultList.getCount());
                    this.setResult(resultList); // searchCompleted(e);
                }
                else
                {
                    //TabPage.displayError("No Results found !!");
                    updateStatusBar("No Results Found.Please check your Search Query.");
                    NoResults welcome = new NoResults();
                    Grid g1 = new Grid();
                    g1 = welcome.grid;
                    welcome.Content = null;
                    this.ResultsPane.Items.Add(g1);
                    Console.WriteLine("it's null so sad"); progressBar.Value = 0; cancel.Visibility = Visibility.Hidden;
                    progressBar.Visibility = Visibility.Hidden;
                    searchBox.Opacity = 1;
                }
                flag = 0;
            }
        }