예제 #1
0
        void IndexUpdaterCallback(object sender, EventArgs e)
        {
            var manager = (IndexUpdateManager)sender;

            if (!manager.IsCreatingSearchIndex)
            {
                Invoke(new Action(delegate {
                    indexesLabel.Visible       = false;
                    indexesProgressBar.Visible = false;
                    searchIndex       = Program.Root.GetSearchIndex();
                    searchBox.Enabled = true;
                    indexSearch.Index = Program.Root.GetIndex();
                    if (tabContainer.SelectedIndex == 1)
                    {
                        FillUpIndex();
                    }
                    else
                    {
                        indexPageLoaded = false;
                    }
                }));
            }
            else
            {
                Invoke(new Action(delegate {
                    indexesLabel.Visible       = true;
                    indexesProgressBar.Visible = true;
                    searchBox.Enabled          = false;
                    indexSearchBox.Enabled     = false;
                }));
            }
        }
예제 #2
0
 void SetupSearch()
 {
     AppDelegate.IndexUpdateManager.UpdaterChange += ToggleSearchCreationStatus;
     searchIndex                 = AppDelegate.Root.GetSearchIndex();
     mdocSearch                  = new IndexSearcher(AppDelegate.IndexUpdateManager.IsFresh ? AppDelegate.Root.GetIndex() : null);
     indexResults.Source         = new IndexDataSource(mdocSearch);
     multipleMatchResults.Source = new MultipleMatchDataSource(this);
     searchResults.Source        = new ResultDataSource();
     splitView.Delegate          = new SplitViewDelegate();
     tabSelector.DidSelect      += (sender, e) => {
         if (e.Item.TabView.IndexOf(e.Item) == 2)
         {
             WindowForSheet.MakeFirstResponder(toolbarSearchEntry);
         }
     };
 }
예제 #3
0
        void SetupSearch()
        {
            searchIndex = Program.Root.GetSearchIndex();
            indexSearch = new IndexSearcher(Program.IndexUpdateManager.IsFresh ? Program.Root.GetIndex() : null);

            searchInput = new SearchTextBox(searchBox.TextBox);
            searchInput.SearchTextChanged    += SearchCallback;
            indexSearchBox.SearchTextChanged += IndexSearchCallback;
            indexLoadingNode = new AnimatedTreeNode(indexListResults.Nodes [0]);
            indexLoadingNode.StartAnimation();
            tabContainer.Selected += (s, e) => {
                if (tabContainer.SelectedIndex == 1 && !indexPageLoaded)
                {
                    FillUpIndex();
                    indexPageLoaded = true;
                }
                if (match != null && ShowNodeInTree(match))
                {
                    docTree.SelectedNode = nodeToTreeNodeMap[match];
                    match = null;
                }
            };
            indexListResults.AfterSelect += (s, e) => {
                var entry = e.Node.Tag as IndexEntry;
                if (entry.Count == 1)
                {
                    LoadUrl(entry[0].Url);
                }
                else
                {
                    LoadMultipleMatchData(entry);
                    indexSplitContainer.Panel2Collapsed = false;
                    e.Node.EnsureVisible();
                }
            };
            multipleMatchList.AfterSelect += (s, e) => {
                var topic = e.Node.Tag as Topic;
                LoadUrl(topic.Url);
                multipleMatchList.SelectedNode = e.Node;
            };
            searchListResults.DrawNode     += CustomDrawing.DrawSearchResultNodeText;
            searchListResults.BeforeSelect += (s, e) => e.Cancel = e.Node.Tag == null;
            searchListResults.AfterSelect  += (s, e) => {
                var entry = e.Node.Tag as ResultDataEntry;
                LoadUrl(entry.ResultSet.GetUrl(entry.Index));
            };
        }
예제 #4
0
        void ToggleSearchCreationStatus(object sender, EventArgs e)
        {
            var manager = (IndexUpdateManager)sender;

            if (!manager.IsCreatingSearchIndex)
            {
                InvokeOnMainThread(delegate {
                    var indexSpinnerHeight  = indexSpinnerView.Frame.Height * 3 / 4;
                    var searchSpinnerHeight = spinnerView.Frame.Height * 3 / 4;

                    spinnerWidget.StopAnimation(this);
                    spinnerView.Hidden = true;
                    indexSpinnerWidget.StopAnimation(this);
                    indexSpinnerView.Hidden = true;

                    searchIndex = AppDelegate.Root.GetSearchIndex();
                    indexSearchEntry.Enabled = true;
                    mdocSearch.Index         = AppDelegate.Root.GetIndex();
                    indexResults.ReloadData();

                    var splitViewFrame = splitView.Frame;
                    splitView.Frame    = new CGRect(splitViewFrame.X,
                                                    splitViewFrame.Y - indexSpinnerHeight,
                                                    splitViewFrame.Width,
                                                    splitViewFrame.Height + indexSpinnerHeight);

                    var searchScrollViewFrame = searchScrollView.Frame;
                    searchScrollView.Frame    = new CGRect(searchScrollViewFrame.X,
                                                           searchScrollViewFrame.Y - searchSpinnerHeight,
                                                           searchScrollViewFrame.Width,
                                                           searchScrollViewFrame.Height + searchSpinnerHeight);
                });
            }
            else
            {
                InvokeOnMainThread(delegate {
                    spinnerView.Hidden = false;
                    spinnerWidget.StartAnimation(this);
                    indexSpinnerView.Hidden = false;
                    indexSpinnerWidget.StartAnimation(this);
                    indexSearchEntry.Enabled = false;
                });
            }
        }
        public async Task FinishReindexing <T>() where T : ISearchable
        {
            var existingActive = await this.GetIndexByType <T>(IndexType.Active);

            var existingInProgress = await this.GetIndexByType <T>(IndexType.InProgress);

            var toUpdate = new List <SearchableIndex>();

            if (existingActive.Success)
            {
                var newArchived = new SearchableIndex(existingActive.Value.Type, existingActive.Value.Name, IndexType.Archived.ToString());
                toUpdate.Add(newArchived);
            }

            var newActive = new SearchableIndex(existingInProgress.Value.Type, existingInProgress.Value.Name, IndexType.Active.ToString());

            toUpdate.Add(newActive);

            await _searchableIndexRepository.UpdateBatch(toUpdate.ToArray());
        }
예제 #6
0
        void SearchCallback(object sender, EventArgs e)
        {
            var input = sender as SearchTextBox;

            if (searchIndex == null)
            {
                searchIndex = Program.Root.GetSearchIndex();
                if (searchIndex == null)
                {
                    return;
                }
            }
            var text = input.Text;

            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            tabContainer.SelectedIndex = 2;
            searchListResults.Tag      = text;        // Last searched term
            Result results = searchIndex.FastSearch(text, 5);

            dataSource.ClearResultSet();
            dataSource.AddResultSet(results);
            Task.Factory.StartNew(() => searchIndex.Search(text, 20)).ContinueWith(t => Invoke(new Action(() => {
                var rs = t.Result;
                if (rs == null || rs.Count == 0 || text != ((string)searchListResults.Tag))
                {
                    return;
                }
                dataSource.AddResultSet(rs);
                ReloadSearchData();
            })), TaskScheduler.FromCurrentSynchronizationContext());
            ReloadSearchData();
            if (results.Count > 0)
            {
                var firstNode = searchListResults.Nodes[1];
                searchListResults.SelectedNode = firstNode;
                firstNode.EnsureVisible();
            }
        }
예제 #7
0
        void Search(string text)
        {
            // We may have a null search index if it's the first time the app is launched
            // In that case try to grab a snapshot and if still nothing exits cleanly
            if (searchIndex == null)
            {
                searchIndex = AppDelegate.Root.GetSearchIndex();
                if (searchIndex == null)
                {
                    return;
                }
            }
            var dataSource = ((ResultDataSource)searchResults.Source);

            dataSource.LatestSearchTerm = text;
            Result results = searchIndex.FastSearch(text, 5);

            dataSource.ClearResultSet();
            dataSource.AddResultSet(results);
            // No SynchronizationContext for MonoMac yet
            Task.Factory.StartNew(() => searchIndex.Search(text, 20)).ContinueWith(t => InvokeOnMainThread(() => {
                var rs = t.Result;
                if (rs == null || rs.Count == 0 || text != dataSource.LatestSearchTerm)
                {
                    return;
                }
                dataSource.AddResultSet(rs);
                searchResults.ReloadData();
            }));
            searchResults.ReloadData();
            if (results.Count > 0)
            {
                searchResults.SelectRow(1, false);
                searchResults.ScrollRowToVisible(0);
                OnSearchRowSelected(1);
            }
        }