示例#1
0
        private void Scan_Click(object sender, RoutedEventArgs e)
        {
            literatureSourceUIs = new List <LiteratureSourceUI>();
            SourcesList.Children.Clear();
            TextSearchResults textSearchResults = richTextBoxAdv.FindAll(new Regex(@"\[.*?\]"), FindOptions.None);

            if (textSearchResults != null)
            {
                int index = 1;
                for (int i = 0; i < textSearchResults.Count; i++)
                {
                    TextSearchResult textSearchResult = textSearchResults[i];
                    string[]         sublinks         = textSearchResult.Text.Substring(1, textSearchResult.Text.Length - 1).Split('#');
                    for (int j = 0; j < sublinks.Length; j++)
                    {
                        string text = sublinks[j].Trim();
                        try
                        {
                            literatureSourceUIs.First(x => x.literatureSource.shadowText == text);
                        }
                        catch
                        {
                            LiteratureSourceUI literatureSourceUI = new LiteratureSourceUI(new LiteratureSource(index, text), this);
                            literatureSourceUIs.Add(literatureSourceUI);
                            index++;
                            SourcesList.Children.Add(literatureSourceUI);
                        }
                    }
                }
            }
        }
        private void ShowAll_Click(object sender, RoutedEventArgs e)
        {
            mainWindow.richTextBoxAdv.Selection.CharacterFormat.HighlightColor = HighlightColor.NoColor;
            List <string> allShadows = mainWindow.GetAllShadows(this);

            foreach (string shadow in allShadows)
            {
                TextSearchResults textSearchResults = mainWindow.richTextBoxAdv.FindAll(shadow, FindOptions.None);
                if (textSearchResults != null)
                {
                    for (int j = 0; j < textSearchResults.Count; j++)
                    {
                        TextSearchResult textSearchResult = textSearchResults[j];
                        mainWindow.richTextBoxAdv.Selection.SelectionRanges.Add(textSearchResult.Start, textSearchResult.End);
                    }
                    mainWindow.richTextBoxAdv.Selection.CharacterFormat.HighlightColor = HighlightColor.Gray25;
                }
            }
        }