Exemple #1
0
        static void SearchWithRegularExpression() 
        {
            //open document
            Document pdfDocument = new Document(Config.TestPdf);

            //create TextAbsorber object to find all the phrases matching the regular expression
            TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("\\d{4}-\\d{4}"); //like 1999-2000

            //###set text search option to specify regular expression usage
            TextSearchOptions textSearchOptions = new TextSearchOptions(true);
            textFragmentAbsorber.TextSearchOptions = textSearchOptions;

            //accept the absorber for all the pages
            pdfDocument.Pages.Accept(textFragmentAbsorber);

            //get the extracted text fragments
            TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

            //loop through the fragments
            foreach (TextFragment textFragment in textFragmentCollection)
            {
                Console.WriteLine("Text : {0} ", textFragment.Text);
                //Console.WriteLine("Position : {0} ", textFragment.Position);
                //Console.WriteLine("XIndent : {0} ", textFragment.Position.XIndent);
                //Console.WriteLine("YIndent : {0} ", textFragment.Position.YIndent);
                //Console.WriteLine("Font - Name : {0}", textFragment.TextState.Font.FontName);
                //Console.WriteLine("Font - IsAccessible : {0} ", textFragment.TextState.Font.IsAccessible);
                //Console.WriteLine("Font - IsEmbedded : {0} ", textFragment.TextState.Font.IsEmbedded);
                //Console.WriteLine("Font - IsSubset : {0} ", textFragment.TextState.Font.IsSubset);
                //Console.WriteLine("Font Size : {0} ", textFragment.TextState.FontSize);
                //Console.WriteLine("Foreground Color : {0} ", textFragment.TextState.ForegroundColor);
            } 
        }
Exemple #2
0
        /// <summary>
        /// Search document for Text signature
        /// </summary>
        public static void Run()
        {
            Console.WriteLine("\n--------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("[Example Basic Usage] # SearchForText : Search document for Text signature \n");

            // The path to the documents directory.
            string filePath = Constants.SAMPLE_SIGNED_MULTI;
            string fileName = Path.GetFileName(filePath);

            using (Signature signature = new Signature(filePath))
            {
                TextSearchOptions options = new TextSearchOptions()
                {
                    AllPages = true, // this value is set by default
                };

                // search for text signatures in document
                List <TextSignature> signatures = signature.Search <TextSignature>(options);
                Console.WriteLine($"\nSource document ['{fileName}'] contains following text signature(s).");
                // enumerate all signature for output
                foreach (TextSignature textSignature in signatures)
                {
                    Console.WriteLine($"Found Text signature at page {textSignature.PageNumber} with type [{textSignature.SignatureImplementation}] and text '{textSignature.Text}'.");
                }
            }
        }
Exemple #3
0
        public Task <long> CountFor(
            string playerId,
            string opponentId = null,
            GateWay gateWay   = GateWay.Undefined,
            GameMode gameMode = GameMode.Undefined,
            int season        = 1)
        {
            var textSearchOpts  = new TextSearchOptions();
            var mongoCollection = CreateCollection <Matchup>();

            if (string.IsNullOrEmpty(opponentId))
            {
                return(mongoCollection.CountDocumentsAsync(m =>
                                                           Builders <Matchup> .Filter.Text($"\"{playerId}\"", textSearchOpts).Inject() &&
                                                           (gameMode == GameMode.Undefined || m.GameMode == gameMode) &&
                                                           (gateWay == GateWay.Undefined || m.GateWay == gateWay) &&
                                                           (m.Season == season)));
            }

            return(mongoCollection.CountDocumentsAsync(m =>
                                                       Builders <Matchup> .Filter.Text($"\"{playerId}\" \"{opponentId}\"", textSearchOpts).Inject() &&
                                                       (gameMode == GameMode.Undefined || m.GameMode == gameMode) &&
                                                       (gateWay == GateWay.Undefined || m.GateWay == gateWay) &&
                                                       (m.Season == season)));
        }
        /// <summary>
        /// Search document and cancel process
        /// </summary>
        public static void Run()
        {
            Console.WriteLine("\n--------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("[Example Advanced Usage] # CancellationSearchProcess : Search document and cancel process\n");

            // The path to the documents directory.
            string filePath = Constants.SAMPLE_SIGNED_MULTI;

            using (Signature signature = new Signature(filePath))
            {
                signature.SearchProgress += OnSearchProgress;

                TextSearchOptions options = new TextSearchOptions("Text signature")
                {
                    // ...
                };

                // search for signatures in document
                List <TextSignature> signatures = signature.Search <TextSignature>(options);
                Console.WriteLine("\nSource document contains following signatures.");
                foreach (var textSignature in signatures)
                {
                    Console.WriteLine("Text signature found at page {0} with text {1}", textSignature.PageNumber, textSignature.Text);
                }
            }
        }
Exemple #5
0
        public Task <long> CountFor(
            string playerId,
            string opponentId = null,
            GateWay gateWay   = GateWay.Undefined,
            GameMode gameMode = GameMode.Undefined,
            Race playerRace   = Race.Total,
            Race opponentRace = Race.Total,
            int season        = 1)
        {
            var textSearchOpts  = new TextSearchOptions();
            var mongoCollection = CreateCollection <Matchup>();

            if (string.IsNullOrEmpty(opponentId))
            {
                return(mongoCollection.CountDocumentsAsync(m =>
                                                           Builders <Matchup> .Filter.Text($"\"{playerId}\"", textSearchOpts).Inject() &&
                                                           (gameMode == GameMode.Undefined || m.GameMode == gameMode) &&
                                                           (gateWay == GateWay.Undefined || m.GateWay == gateWay) &&
                                                           (playerRace == Race.Total || m.Teams.Any(team => team.Players[0].Race == playerRace && playerId == team.Players[0].BattleTag)) &&
                                                           (opponentRace == Race.Total || m.Teams.Any(team => team.Players[0].Race == opponentRace && playerId != team.Players[0].BattleTag)) &&
                                                           (m.Season == season)));
            }

            return(mongoCollection.CountDocumentsAsync(m =>
                                                       Builders <Matchup> .Filter.Text($"\"{playerId}\" \"{opponentId}\"", textSearchOpts).Inject() &&
                                                       (gameMode == GameMode.Undefined || m.GameMode == gameMode) &&
                                                       (gateWay == GateWay.Undefined || m.GateWay == gateWay) &&
                                                       (m.Season == season)));
        }
Exemple #6
0
        static void SearchWithRegularExpression()
        {
            //open document
            Document pdfDocument = new Document(Config.TestPdf);

            //create TextAbsorber object to find all the phrases matching the regular expression
            TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("\\d{4}-\\d{4}"); //like 1999-2000

            //###set text search option to specify regular expression usage
            TextSearchOptions textSearchOptions = new TextSearchOptions(true);

            textFragmentAbsorber.TextSearchOptions = textSearchOptions;

            //accept the absorber for all the pages
            pdfDocument.Pages.Accept(textFragmentAbsorber);

            //get the extracted text fragments
            TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

            //loop through the fragments
            foreach (TextFragment textFragment in textFragmentCollection)
            {
                Console.WriteLine("Text : {0} ", textFragment.Text);
                //Console.WriteLine("Position : {0} ", textFragment.Position);
                //Console.WriteLine("XIndent : {0} ", textFragment.Position.XIndent);
                //Console.WriteLine("YIndent : {0} ", textFragment.Position.YIndent);
                //Console.WriteLine("Font - Name : {0}", textFragment.TextState.Font.FontName);
                //Console.WriteLine("Font - IsAccessible : {0} ", textFragment.TextState.Font.IsAccessible);
                //Console.WriteLine("Font - IsEmbedded : {0} ", textFragment.TextState.Font.IsEmbedded);
                //Console.WriteLine("Font - IsSubset : {0} ", textFragment.TextState.Font.IsSubset);
                //Console.WriteLine("Font Size : {0} ", textFragment.TextState.FontSize);
                //Console.WriteLine("Foreground Color : {0} ", textFragment.TextState.ForegroundColor);
            }
        }
Exemple #7
0
        public static void Run()
        {
            // ExStart:SearchTextAndDrawRectangle
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            // Open document
            Document document = new Document(dataDir + "SearchAndGetTextFromAll.pdf");

            // Create TextAbsorber object to find all the phrases matching the regular expression

            TextFragmentAbsorber textAbsorber = new TextFragmentAbsorber(@"[\S]+");

            TextSearchOptions textSearchOptions = new TextSearchOptions(true);

            textAbsorber.TextSearchOptions = textSearchOptions;

            document.Pages.Accept(textAbsorber);

            var editor = new PdfContentEditor(document);

            foreach (TextFragment textFragment in textAbsorber.TextFragments)

            {
                foreach (TextSegment textSegment in textFragment.Segments)

                {
                    DrawBox(editor, textFragment.Page.Number, textSegment, System.Drawing.Color.Red);
                }
            }
            dataDir = dataDir + "SearchTextAndDrawRectangle_out.pdf";
            document.Save(dataDir);
            // ExEnd:SearchTextAndDrawRectangle
            Console.WriteLine("\nRectangle drawn successfully on searched text.\nFile saved at " + dataDir);
        }
Exemple #8
0
        /// <summary>
        ///     全文检索
        /// </summary>
        /// <param name="key"></param>
        /// <param name="caseSensitive"></param>
        /// <param name="diacriticSensitive"></param>
        /// <param name="limit"></param>
        /// <param name="language"></param>
        /// <returns></returns>
        public static List <BsonDocument> SearchText(string key, bool caseSensitive, bool diacriticSensitive, int limit,
                                                     string language = "")
        {
            //检索文法:
            //[Before2.6]http://docs.mongodb.org/manual/reference/command/text/#text-search-languages
            //[After 2.6]http://docs.mongodb.org/manual/reference/operator/query/text/#op._S_text
            //[From  3.2]https://docs.mongodb.org/master/reference/operator/query/text/
            //{
            //  $text:
            //    {
            //      $search: < string >,
            //      $language: < string >,
            //      $caseSensitive: < boolean >,
            //      $diacriticSensitive: < boolean >
            //    }
            //}
            //检索关键字
            var textSearchOption = new TextSearchOptions();

            textSearchOption.CaseSensitive      = caseSensitive;
            textSearchOption.DiacriticSensitive = diacriticSensitive;
            //语言
            if (string.IsNullOrEmpty(language))
            {
                textSearchOption.Language = language;
            }
            var textSearchQuery    = Query.Text(key, textSearchOption);
            var result             = RuntimeMongoDbContext.GetCurrentCollection().FindAs <BsonDocument>(textSearchQuery);
            var resultDocumentList = result.SetLimit(limit).ToList();

            return(resultDocumentList);
        }
Exemple #9
0
        /// <summary>
        /// Delete Text signature from the document.
        /// </summary>
        public static void Run()
        {
            Console.WriteLine("\n--------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("[Example Basic Usage] # DeleteText : Delete Text signature from the document \n");

            // The path to the documents directory.
            string filePath = Constants.SAMPLE_SIGNED_MULTI;
            string fileName = Path.GetFileName(filePath);
            // copy source file since Delete method works with same Document
            string outputFilePath = Path.Combine(Constants.OutputPath, "DeleteText", fileName);

            Constants.CheckDir(outputFilePath);
            File.Copy(filePath, outputFilePath, true);
            using (Signature signature = new Signature(outputFilePath))
            {
                TextSearchOptions options = new TextSearchOptions();

                // search for text signatures in document
                List <TextSignature> signatures = signature.Search <TextSignature>(options);
                if (signatures.Count > 0)
                {
                    TextSignature textSignature = signatures[0];
                    bool          result        = signature.Delete(textSignature);
                    if (result)
                    {
                        Console.WriteLine($"Signature with Text '{textSignature.Text}' was deleted from document ['{fileName}'].");
                    }
                    else
                    {
                        Helper.WriteError($"Signature was not deleted from the document! Signature with Text '{textSignature.Text}' was not found!");
                    }
                }
            }
        }
        /// <summary>
        /// Delete multiple signatures from the document
        /// </summary>
        public static void Run()
        {
            Console.WriteLine("\n--------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("[Example Basic Usage] # DeleteMultiple : Delete multiple signatures from the document \n");

            // The path to the documents directory.
            string filePath = Constants.SAMPLE_SIGNED_MULTI;
            string fileName = Path.GetFileName(filePath);
            // copy source file since Delete method works with same Document
            string outputFilePath = Path.Combine(Constants.OutputPath, "DeleteMultiple", fileName);

            Constants.CheckDir(outputFilePath);
            File.Copy(filePath, outputFilePath, true);
            // processing signatures
            using (Signature signature = new Signature(outputFilePath))
            {
                // define few search options
                TextSearchOptions    textSearchOptions  = new TextSearchOptions();
                ImageSearchOptions   imageSearchOptions = new ImageSearchOptions();
                BarcodeSearchOptions barcodeOptions     = new BarcodeSearchOptions();
                QrCodeSearchOptions  qrCodeOptions      = new QrCodeSearchOptions();

                // add options to list
                List <SearchOptions> listOptions = new List <SearchOptions>();
                listOptions.Add(textSearchOptions);
                listOptions.Add(imageSearchOptions);
                listOptions.Add(barcodeOptions);
                listOptions.Add(qrCodeOptions);

                // search for signatures in document
                SearchResult result = signature.Search(listOptions);
                if (result.Signatures.Count > 0)
                {
                    Console.WriteLine("\nTrying to delete all signatures...");
                    DeleteResult deleteResult = signature.Delete(result.Signatures);
                    if (deleteResult.Succeeded.Count == result.Signatures.Count)
                    {
                        Console.WriteLine("\nAll signatures were successfully deleted!");
                    }
                    else
                    {
                        Console.WriteLine($"Successfully deleted signatures : {deleteResult.Succeeded.Count}");
                        Helper.WriteError($"Not deleted signatures : {deleteResult.Failed.Count}");
                    }
                    Console.WriteLine("\nList of deleted signatures:");
                    int number = 1;
                    foreach (BaseSignature temp in deleteResult.Succeeded)
                    {
                        Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId}, Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");
                    }
                }
                else
                {
                    Helper.WriteError("No one signature was found.");
                }
            }
        }
        /// <summary>
        /// Searches the control tree and returns the first match
        /// </summary>
        /// <param name="expression">
        /// The search expression <see cref="System.String"/>
        /// </param>
        /// <param name="searchOptions">
        /// The <see cref="TextSearchOptions"/>
        /// </param>
        /// <param name="recursive">
        /// Search in all the subtree if true
        /// </param>
        /// <returns>
        /// A <see cref="Control"/> that matches the expression
        /// </returns>
        public Control FindFirst(string expression, TextSearchOptions searchOptions, bool recursive)
        {
            IFullList <Control> res = Find(expression, searchOptions, recursive, true);

            if (res.Count > 0)
            {
                return(res[0]);
            }
            return(null);
        }
        protected override TextSearchResult Search(SearchContext context)
        {
            string            regex        = GetMultiWordRegex(context.Text);
            TextSearchOptions regexOptions = new TextSearchOptions {
                UseRegularExpression = true
            };
            SearchContext newContext = new SearchContext(context.PdfViewer, context.Document, regex, regexOptions, context.SearchProgress, context.CancellationToken);

            return(base.Search(newContext));
        }
Exemple #13
0
        public void TestTextWithOptionsQueryGeneration()
        {
            var options = new TextSearchOptions
            {
                Language           = "norwegian",
                CaseSensitive      = true,
                DiacriticSensitive = true
            };
            var query    = Query.Text("foo", options);
            var expected = "{ \"$text\" : { \"$search\" : \"foo\", \"$language\" : \"norwegian\", \"$caseSensitive\" : true, \"$diacriticSensitive\" : true } }";

            Assert.AreEqual(expected, query.ToJson());
        }
Exemple #14
0
        /// <summary>
        /// Update Text signature in the document.
        /// </summary>
        public static void Run()
        {
            Console.WriteLine("\n--------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("[Example Advanced Usage] # UpdateTextAfterSearch : Update Text signature in the document\n");

            // The path to the documents directory.
            string filePath = Constants.SAMPLE_SIGNED_MULTI;
            // copy source file since Update method works with same Document
            string fileName       = Path.GetFileName(filePath);
            string outputFilePath = Path.Combine(Constants.OutputPath, "UpdateTextAfterSearch", fileName);

            Constants.CheckDir(outputFilePath);
            File.Copy(filePath, outputFilePath, true);
            //
            using (Signature signature = new Signature(outputFilePath))
            {
                TextSearchOptions options = new TextSearchOptions();
                // search for text signatures in document
                List <TextSignature> signatures = signature.Search <TextSignature>(options);
                // adjust signature properties
                foreach (TextSignature temp in signatures)
                {
                    // apply some condition to adjust signature properties
                    if (temp.Text == "Text signature")
                    {
                        temp.Left = temp.Left + 100;
                        temp.Top  = temp.Top + 100;
                        temp.Text = "Mr. John Smith";
                    }
                    temp.IsSignature = true;
                }
                // update all found signatures
                UpdateResult updateResult = signature.Update(signatures.ConvertAll(p => (BaseSignature)p));
                if (updateResult.Succeeded.Count == signatures.Count)
                {
                    Console.WriteLine("\nAll signatures were successfully updated!");
                }
                else
                {
                    Console.WriteLine($"Successfully updated signatures : {updateResult.Succeeded.Count}");
                    Helper.WriteError($"Not updated signatures : {updateResult.Failed.Count}");
                }
                Console.WriteLine("List of updated signatures:");
                foreach (BaseSignature temp in updateResult.Succeeded)
                {
                    Console.WriteLine($"Signature# Id:{temp.SignatureId}, Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");
                }
            }
        }
        public bool isNameExist(string name, bool isAll)
        {
            TextSearchOptions option = new TextSearchOptions();

            option.CaseSensitive = false;
            FilterDefinition <repairmanTable> queryFilter = Builders <repairmanTable> .Filter.Text(name, option);

            if (!isAll)
            {
                queryFilter &= defaultFilter;
            }
            var recordCount = collection.Find(queryFilter).Count();

            return(recordCount > 0);
        }
Exemple #16
0
        public async Task <IEnumerable <DataTag> > GetDataTagSuggestions(string q)
        {
            var options = new TextSearchOptions();

            options.CaseSensitive = false;
            options.Language      = "en";

            var regexFilter = Builders <DataTag> .Filter.Regex(x => x.Value, new BsonRegularExpression(q, "i"));

            var textFilter = Builders <DataTag> .Filter.Text(q, options);

            var result = await Collection.Find(Builders <DataTag> .Filter.Or(textFilter, regexFilter)).Limit(20).ToListAsync();

            return(result);
        }
        /// <summary>
        /// Delete Text signature from the document.
        /// </summary>
        public static void Run()
        {
            Console.WriteLine("\n--------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("[Example Advanced Usage] # DeleteTextAfterSearch : Delete Text signature from the document\n");

            // The path to the documents directory.
            string filePath = Constants.SAMPLE_SIGNED_MULTI;
            // copy source file since Delete method works with same Document
            string fileName       = Path.GetFileName(filePath);
            string outputFilePath = Path.Combine(Constants.OutputPath, "DeleteTextAfterSearch", fileName);

            Constants.CheckDir(outputFilePath);
            File.Copy(filePath, outputFilePath, true);
            // initialize Signature instance
            using (Signature signature = new Signature(outputFilePath))
            {
                TextSearchOptions options = new TextSearchOptions();

                List <TextSignature> signatures         = signature.Search <TextSignature>(options);
                List <BaseSignature> signaturesToDelete = new List <BaseSignature>();
                // collect signatures to delete
                foreach (TextSignature temp in signatures)
                {
                    if (temp.Text.Contains("Text signature"))
                    {
                        signaturesToDelete.Add(temp);
                    }
                }
                // delete signatures
                DeleteResult deleteResult = signature.Delete(signaturesToDelete);
                if (deleteResult.Succeeded.Count == signaturesToDelete.Count)
                {
                    Console.WriteLine("All signatures were successfully deleted!");
                }
                else
                {
                    Console.WriteLine($"Successfully deleted signatures : {deleteResult.Succeeded.Count}");
                    Helper.WriteError($"Not deleted signatures : {deleteResult.Failed.Count}");
                }
                Console.WriteLine("List of deleted signatures:");
                foreach (BaseSignature temp in deleteResult.Succeeded)
                {
                    Console.WriteLine($"Signature# Id:{temp.SignatureId}, Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");
                }
            }
        }
Exemple #18
0
 private void wrapAroundToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
 {
     if (wrapAroundToolStripMenuItem.Checked)
     {
         if (!textSearchOptions.HasFlag(TextSearchOptions.WrapAround))
         {
             textSearchOptions |= TextSearchOptions.WrapAround;
         }
     }
     else
     {
         if (textSearchOptions.HasFlag(TextSearchOptions.WrapAround))
         {
             textSearchOptions &= ~TextSearchOptions.WrapAround;
         }
     }
 }
Exemple #19
0
 private void caseSensitiveToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
 {
     if (caseSensitiveToolStripMenuItem.Checked)
     {
         if (!textSearchOptions.HasFlag(TextSearchOptions.CaseSensitive))
         {
             textSearchOptions |= TextSearchOptions.CaseSensitive;
         }
     }
     else
     {
         if (textSearchOptions.HasFlag(TextSearchOptions.CaseSensitive))
         {
             textSearchOptions &= ~TextSearchOptions.CaseSensitive;
         }
     }
 }
        public async ValueTask <IPaginationCollection <TModel> > SearchAsync(
            string membershipId,
            string keyword,
            int?skip                    = null,
            int?limit                   = null,
            bool?withCount              = null,
            string sortField            = null,
            SortDirection?sortDirection = null)
        {
            var membership = await this.membershipService.GetAsync(membershipId);

            if (membership == null)
            {
                throw ErtisAuthException.MembershipNotFound(membershipId);
            }

            var textSearchLanguage = TextSearchLanguage.None;

            if (!string.IsNullOrEmpty(membership.DefaultLanguage) && TextSearchLanguage.All.Any(x => x.ISO6391Code == membership.DefaultLanguage))
            {
                textSearchLanguage = TextSearchLanguage.All.FirstOrDefault(x => x.ISO6391Code == membership.DefaultLanguage);
            }

            var textSearchOptions = new TextSearchOptions
            {
                Language             = textSearchLanguage,
                IsCaseSensitive      = true,
                IsDiacriticSensitive = false
            };

            var paginatedDtoCollection = await this.repository.SearchAsync(keyword, textSearchOptions, skip, limit, withCount, sortField, sortDirection);

            if (paginatedDtoCollection?.Items != null)
            {
                return(new PaginationCollection <TModel>
                {
                    Items = paginatedDtoCollection.Items.Select(x => Mapper.Current.Map <TDto, TModel>(x)),
                    Count = paginatedDtoCollection.Count
                });
            }
            else
            {
                return(new PaginationCollection <TModel>());
            }
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            //open document
            Document pdfDocument = new Document(dataDir + "SearchRegularExpressionPage.pdf");

            //create TextAbsorber object to find all the phrases matching the regular expression
            TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("\\d{4}-\\d{4}"); //like 1999-2000

            //set text search option to specify regular expression usage
            TextSearchOptions textSearchOptions = new TextSearchOptions(true);

            textFragmentAbsorber.TextSearchOptions = textSearchOptions;

            //accept the absorber for a single page
            pdfDocument.Pages[1].Accept(textFragmentAbsorber);

            //get the extracted text fragments
            TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

            //loop through the fragments
            foreach (TextFragment textFragment in textFragmentCollection)
            {
                Console.WriteLine("Text : {0} ", textFragment.Text);
                Console.WriteLine("Position : {0} ", textFragment.Position);
                Console.WriteLine("XIndent : {0} ",
                                  textFragment.Position.XIndent);
                Console.WriteLine("YIndent : {0} ",
                                  textFragment.Position.YIndent);
                Console.WriteLine("Font - Name : {0}",
                                  textFragment.TextState.Font.FontName);
                Console.WriteLine("Font - IsAccessible : {0} ",
                                  textFragment.TextState.Font.IsAccessible);
                Console.WriteLine("Font - IsEmbedded : {0} ",
                                  textFragment.TextState.Font.IsEmbedded);
                Console.WriteLine("Font - IsSubset : {0} ",
                                  textFragment.TextState.Font.IsSubset);
                Console.WriteLine("Font Size : {0} ",
                                  textFragment.TextState.FontSize);
                Console.WriteLine("Foreground Color : {0} ",
                                  textFragment.TextState.ForegroundColor);
            }
        }
Exemple #22
0
        public IEnumerable <Contact> Get(string query)
        {
            // Try a faster search on text index first
            var options = new TextSearchOptions {
                CaseSensitive = false, DiacriticSensitive = false
            };
            var indexQuery = Builders <Contact> .Filter.Text(query, options);

            var indexResult = _contacts.Find(indexQuery);

            if (indexResult.Any())
            {
                return(indexResult.ToList());
            }

            // If that produces no results, search more precise instead
            return(_contacts.Find(queryFilter(query)).ToList());
        }
Exemple #23
0
        /// <summary>
        /// 全文检索
        /// </summary>
        /// <param name="collectionName"></param>
        /// <param name="key"></param>
        /// <param name="caseSensitive"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        public static List <BsonDocument> SearchText(string collectionName, string key, bool caseSensitive, int limit, IMongoQuery query = null)
        {
            //检索关键字
            var textSearchOption = new TextSearchOptions();

            textSearchOption.CaseSensitive = caseSensitive;
            var textSearchQuery = Query.Text(key, textSearchOption);

            if (query != null)
            {
                textSearchQuery = Query.And(textSearchQuery, query);
            }
            MongoCollection col                = GetDatabaseByType(_defaultDatabaseName).GetCollection(collectionName);
            var             result             = col.FindAs <BsonDocument>(textSearchQuery);
            var             resultDocumentList = result.SetLimit(limit).ToList();

            return(resultDocumentList);
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            //open document
            Document pdfDocument = new Document(dataDir + "SearchRegularExpressionPage.pdf");
            
            //create TextAbsorber object to find all the phrases matching the regular expression
            TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("\\d{4}-\\d{4}"); //like 1999-2000
            
            //set text search option to specify regular expression usage
            TextSearchOptions textSearchOptions = new TextSearchOptions(true);
            textFragmentAbsorber.TextSearchOptions = textSearchOptions;
            
            //accept the absorber for a single page
            pdfDocument.Pages[1].Accept(textFragmentAbsorber);
            
            //get the extracted text fragments
            TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
            
            //loop through the fragments
            foreach (TextFragment textFragment in textFragmentCollection)
            {
                Console.WriteLine("Text : {0} ", textFragment.Text);
                Console.WriteLine("Position : {0} ", textFragment.Position);
                Console.WriteLine("XIndent : {0} ",
                textFragment.Position.XIndent);
                Console.WriteLine("YIndent : {0} ",
                textFragment.Position.YIndent);
                Console.WriteLine("Font - Name : {0}",
                textFragment.TextState.Font.FontName);
                Console.WriteLine("Font - IsAccessible : {0} ",
                textFragment.TextState.Font.IsAccessible);
                Console.WriteLine("Font - IsEmbedded : {0} ",
                textFragment.TextState.Font.IsEmbedded);
                Console.WriteLine("Font - IsSubset : {0} ",
                textFragment.TextState.Font.IsSubset);
                Console.WriteLine("Font Size : {0} ",
                textFragment.TextState.FontSize);
                Console.WriteLine("Foreground Color : {0} ",
                textFragment.TextState.ForegroundColor);
            } 
        }
        /// <summary>
        /// Update Text signature in the document.
        /// </summary>
        public static void Run()
        {
            Console.WriteLine("\n--------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("[Example Basic Usage] # UpdateText : Update Text signature in the document \n");

            // The path to the documents directory.
            string filePath = Constants.SAMPLE_SIGNED_MULTI;
            // copy source file since Update method works with same Document
            string fileName       = Path.GetFileName(filePath);
            string outputFilePath = Path.Combine(Constants.OutputPath, "UpdateText", fileName);

            Constants.CheckDir(outputFilePath);
            File.Copy(filePath, outputFilePath, true);
            //
            using (Signature signature = new Signature(outputFilePath))
            {
                TextSearchOptions options = new TextSearchOptions();
                // search for text signatures in document
                List <TextSignature> signatures = signature.Search <TextSignature>(options);
                if (signatures.Count > 0)
                {
                    TextSignature textSignature = signatures[0];
                    // change Text property
                    textSignature.Text = "John Walkman";
                    // change position
                    textSignature.Left = textSignature.Left + 10;
                    textSignature.Top  = textSignature.Top + 10;
                    // change size. Please note not all documents support changing signature size
                    textSignature.Width  = 200;
                    textSignature.Height = 100;

                    bool result = signature.Update(textSignature);
                    if (result)
                    {
                        Console.WriteLine($"Signature with Text '{textSignature.Text}' was updated in the document ['{fileName}'].");
                    }
                    else
                    {
                        Helper.WriteError($"Signature was not updated in  the document! Signature with Text '{textSignature.Text}' was not found!");
                    }
                }
            }
        }
Exemple #26
0
        /// <summary>
        /// Search document for Text signature
        /// </summary>
        public static void Run()
        {
            Console.WriteLine("\n--------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("[Example Advanced Usage] # SearchForTextAdvanced : Search document for Text signature\n");

            // The path to the documents directory.
            string filePath = Constants.SAMPLE_SIGNED_MULTI;

            using (Signature signature = new Signature(filePath))
            {
                TextSearchOptions options = new TextSearchOptions()
                {
                    // specify special pages to search on
                    AllPages = false,
                    // single page number
                    PageNumber = 1,
                    // setup extended search in pages setup
                    PagesSetup = new PagesSetup()
                    {
                        FirstPage = true, LastPage = true, OddPages = false, EvenPages = false
                    },
                    // specify text match type
                    MatchType = TextMatchType.Exact,
                    // specify text pattern to search
                    Text = "Text signature"
                };

                // search for text signatures in document
                List <TextSignature> signatures = signature.Search <TextSignature>(options);
                Console.WriteLine("\nSource document contains following text signature(s).");
                // enumerate all signature for output
                foreach (TextSignature textSignature in signatures)
                {
                    if (textSignature != null)
                    {
                        Console.WriteLine($"Found Text signature at page {textSignature.PageNumber} with type [{textSignature.SignatureImplementation}] and text '{textSignature.Text}'.");
                        Console.WriteLine($"Location at {textSignature.Left}-{textSignature.Top}. Size is {textSignature.Width}x{textSignature.Height}.");
                    }
                }
            }
        }
Exemple #27
0
        public async Task <List <Matchup> > LoadFor(
            string playerId,
            string opponentId = null,
            GateWay gateWay   = GateWay.Undefined,
            GameMode gameMode = GameMode.Undefined,
            Race playerRace   = Race.Total,
            Race opponentRace = Race.Total,
            int pageSize      = 100,
            int offset        = 0,
            int season        = 1)
        {
            var mongoCollection = CreateCollection <Matchup>();
            var textSearchOpts  = new TextSearchOptions();

            if (string.IsNullOrEmpty(opponentId))
            {
                return(await mongoCollection
                       .Find(m => Builders <Matchup> .Filter.Text($"\"{playerId}\"", textSearchOpts).Inject() &&
                             (gameMode == GameMode.Undefined || m.GameMode == gameMode) &&
                             (gateWay == GateWay.Undefined || m.GateWay == gateWay) &&
                             (playerRace == Race.Total || m.Teams.Any(team => team.Players[0].Race == playerRace && playerId == team.Players[0].BattleTag)) &&
                             (opponentRace == Race.Total || m.Teams.Any(team => team.Players[0].Race == opponentRace && playerId != team.Players[0].BattleTag)) &&
                             (m.Season == season))
                       .SortByDescending(s => s.Id)
                       .Skip(offset)
                       .Limit(pageSize)
                       .ToListAsync());
            }

            return(await mongoCollection
                   .Find(m =>
                         Builders <Matchup> .Filter.Text($"\"{playerId}\" \"{opponentId}\"", textSearchOpts).Inject() &&
                         (gameMode == GameMode.Undefined || m.GameMode == gameMode) &&
                         (gateWay == GateWay.Undefined || m.GateWay == gateWay) &&
                         (m.Season == season))
                   .SortByDescending(s => s.Id)
                   .Skip(offset)
                   .Limit(pageSize)
                   .ToListAsync());
        }
        public static void Run()
        {
            // ExStart:SearchTextAndDrawRectangle
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            // Open document
            Document document = new Document(dataDir + "SearchAndGetTextFromAll.pdf");

            // Create TextAbsorber object to find all the phrases matching the regular expression

            TextFragmentAbsorber textAbsorber = new TextFragmentAbsorber(@"[\S]+");

            TextSearchOptions textSearchOptions = new TextSearchOptions(true);

            textAbsorber.TextSearchOptions = textSearchOptions;

            document.Pages.Accept(textAbsorber); 

            var editor = new PdfContentEditor(document); 

            foreach (TextFragment textFragment in textAbsorber.TextFragments)

            {

                foreach (TextSegment textSegment in textFragment.Segments)

                {

                        DrawBox(editor, textFragment.Page.Number, textSegment, System.Drawing.Color.Red);

                }

            }
            dataDir = dataDir + "SearchTextAndDrawRectangle_out.pdf";
            document.Save(dataDir);
            // ExEnd:SearchTextAndDrawRectangle
            Console.WriteLine("\nRectangle drawn successfully on searched text.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:ReplaceTextonRegularExpression
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            // Open document
            Document pdfDocument = new Document(dataDir + "SearchRegularExpressionPage.pdf");

            // Create TextAbsorber object to find all the phrases matching the regular expression
            TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("\\d{4}-\\d{4}"); //like 1999-2000

            // Set text search option to specify regular expression usage
            TextSearchOptions textSearchOptions = new TextSearchOptions(true);

            textFragmentAbsorber.TextSearchOptions = textSearchOptions;

            // Accept the absorber for a single page
            pdfDocument.Pages[1].Accept(textFragmentAbsorber);

            // Get the extracted text fragments
            TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

            // Loop through the fragments
            foreach (TextFragment textFragment in textFragmentCollection)
            {
                // Update text and other properties
                textFragment.Text = "New Phrase";
                // Set to an instance of an object.
                textFragment.TextState.Font            = FontRepository.FindFont("Verdana");
                textFragment.TextState.FontSize        = 22;
                textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue);
                textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green);
            }
            dataDir = dataDir + "ReplaceTextonRegularExpression_out_.pdf";
            pdfDocument.Save(dataDir);
            // ExEnd:ReplaceTextonRegularExpression
            Console.WriteLine("\nText replaced successfully based on a regular expression.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:ReplaceTextonRegularExpression
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            // Open document
            Document pdfDocument = new Document(dataDir + "SearchRegularExpressionPage.pdf");
            
            // Create TextAbsorber object to find all the phrases matching the regular expression
            TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("\\d{4}-\\d{4}"); // Like 1999-2000
            
            // Set text search option to specify regular expression usage
            TextSearchOptions textSearchOptions = new TextSearchOptions(true);
            textFragmentAbsorber.TextSearchOptions = textSearchOptions;
            
            // Accept the absorber for a single page
            pdfDocument.Pages[1].Accept(textFragmentAbsorber);
            
            // Get the extracted text fragments
            TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
            
            // Loop through the fragments
            foreach (TextFragment textFragment in textFragmentCollection)
            {
                // Update text and other properties
                textFragment.Text = "New Phrase";
                // Set to an instance of an object.
                textFragment.TextState.Font = FontRepository.FindFont("Verdana");
                textFragment.TextState.FontSize = 22;
                textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue);
                textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green);
            }
            dataDir = dataDir + "ReplaceTextonRegularExpression_out.pdf";
            pdfDocument.Save(dataDir);
            // ExEnd:ReplaceTextonRegularExpression
            Console.WriteLine("\nText replaced successfully based on a regular expression.\nFile saved at " + dataDir);
        }
Exemple #31
0
        /// <summary>
        /// Search document for Text signature skipping external signatures
        /// </summary>
        public static void Run()
        {
            Console.WriteLine("\n--------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("[Example Advanced Usage] # SearchAndSkipExternalSignatures : Search document for Text signature skipping external signatures\n");

            // The path to the documents directory.
            string filePath = Constants.SAMPLE_SIGNED_MULTI;

            using (Signature signature = new Signature(filePath))
            {
                TextSearchOptions options = new TextSearchOptions()
                {
                    // specify search on all pages
                    AllPages = false
                };
                // search for text signatures in document
                List <TextSignature> signatures = signature.Search <TextSignature>(options);
                Console.WriteLine($"\nSource document ['{filePath}'] contains following signatures.");
                // enumerate all signature for output
                foreach (TextSignature textSignature in signatures)
                {
                    if (textSignature != null)
                    {
                        Console.WriteLine($"Found Text signature at page {textSignature.PageNumber} with type [{textSignature.SignatureImplementation}] and text '{textSignature.Text}'.");
                        Console.WriteLine($"Location at {textSignature.Left}-{textSignature.Top}. Size is {textSignature.Width}x{textSignature.Height}.");
                    }
                }

                // specify SkipExternal value to exclude non signature objects from Search result
                options.SkipExternal = true;

                // search for text signatures in document skipping external
                signatures = signature.Search <TextSignature>(options);
                Console.WriteLine($"\nSource document ['{filePath}'] contains {signatures.Count} not external signatures.");
            }
        }
        public async ValueTask <IPaginationCollection <TModel> > SearchAsync(
            string keyword,
            TextSearchOptions options = null,
            int?skip                    = null,
            int?limit                   = null,
            bool?withCount              = null,
            string sortField            = null,
            SortDirection?sortDirection = null)
        {
            var paginatedDtoCollection = await this.repository.SearchAsync(keyword, options, skip, limit, withCount, sortField, sortDirection);

            if (paginatedDtoCollection?.Items != null)
            {
                return(new PaginationCollection <TModel>
                {
                    Items = paginatedDtoCollection.Items.Select(x => Mapper.Current.Map <TDto, TModel>(x)),
                    Count = paginatedDtoCollection.Count
                });
            }
            else
            {
                return(new PaginationCollection <TModel>());
            }
        }
 public FindNextCommand(FixedDocumentViewerBase viewer, TextSearchOptions textSearchOptions)
     : base(viewer, textSearchOptions)
 {
 }
Exemple #34
0
        public static TextBlock FindTextBlock(List<TextBlock> block, string toSearch, TextSearchOptions option)
        {
            var culture = new CultureInfo(string.Empty); // <- Invariant culture

            return (
                    from item in block
                    where
                        (option == TextSearchOptions.StartsWith && item.Text.StartsWith(toSearch, StringComparison.InvariantCultureIgnoreCase)) ||
                        (option == TextSearchOptions.Contains && culture.CompareInfo.IndexOf(item.Text, toSearch, CompareOptions.IgnoreCase) > -1) ||
                        (option == TextSearchOptions.ExactMatch && string.Equals(item.Text, toSearch, StringComparison.CurrentCultureIgnoreCase))
                    select item).FirstOrDefault();
        }
Exemple #35
0
 public static TextBlock FindTextBlock(List<List<TextBlock>> blockList, string toSearch, TextSearchOptions option)
 {
     return (from block in blockList
             select FindTextBlock(block, toSearch, option)).FirstOrDefault();
 }
 /// <summary>
 /// Finds the specified expression.
 /// </summary>
 /// <param name="expression">The expression.</param>
 /// <param name="searchOptions">The search options.</param>
 /// <param name="recursive">if set to <c>true</c> [recursive].</param>
 /// <returns></returns>
 public IFullList<Control> Find(string expression, TextSearchOptions searchOptions, bool recursive)
 {
     return Find(expression, searchOptions, recursive, false);
 }
 /// <summary>
 /// Searches the control tree recursively and returns the first match 
 /// </summary>
 /// <param name="expression">
 /// The search expression <see cref="System.String"/>
 /// </param>
 /// <param name="searchOptions">
 /// The <see cref="TextSearchOptions"/>
 /// </param>
 /// <returns>
 /// A <see cref="Control"/> that matches the expression
 /// </returns>		
 public Control FindFirst(string expression, TextSearchOptions searchOptions)
 {
     return FindFirst(expression, searchOptions, true);
 }
 public FindCommandBase(FixedDocumentViewerBase viewer, TextSearchOptions textSearchOptions)
 {
     this.viewer = viewer;
     this.textSearchOptions = textSearchOptions;
 }
 /// <summary>
 /// Finds the specified expression.
 /// </summary>
 /// <param name="expression">The expression.</param>
 /// <param name="searchOptions">The search options.</param>
 /// <returns></returns>
 public IFullList<Control> Find(string expression, TextSearchOptions searchOptions)
 {
     return Find(expression, searchOptions, true);
 }
 /// <summary>
 /// Searches the control tree and returns the first match 
 /// </summary>
 /// <param name="rootControl">
 /// The root <see cref="Control"/>
 /// </param>
 /// <param name="expression">
 /// The search expression <see cref="System.String"/>
 /// </param>
 /// <param name="searchOptions">
 /// The <see cref="TextSearchOptions"/>
 /// </param>
 /// <param name="recursive">
 /// Search in all the subtree if true
 /// </param>
 /// <returns>
 /// </returns>
 public static Control FindFirstInControl(Control rootControl, string expression, TextSearchOptions searchOptions, bool recursive)
 {
     return new ControlFinder(rootControl).FindFirst(expression, searchOptions, recursive);
 }
        private IFullList<Control> Find(string expression, TextSearchOptions searchOptions, bool recursive, bool stopAtFirst)
        {
            bool caseInsensitive = (searchOptions & TextSearchOptions.CaseInsensitive) != 0;

            IFullList<Control> result = new FullList<Control>();

            if ((searchOptions & TextSearchOptions.Regex) == 0)
            {
                bool partial = (searchOptions & TextSearchOptions.Partial) != 0;
                // text
                if (caseInsensitive)
                {
                    // case insensitive text
                    expression = expression.ToUpperInvariant();

                    if (partial)
                    {
                        // case insensitive partial text
                        doFind(root, result, delegate(Control c)
                                             	{
                                             		string test = c.ID;
                                             		if (string.IsNullOrEmpty(test))
                                             			return false;
                                             		test = test.ToUpperInvariant();
                                             		return (test.Contains(expression));
                                             	}, recursive, stopAtFirst);
                    }
                    else
                    {
                        // case insensitive exact text
                        doFind(root, result,
                               delegate(Control c) { return (string.Compare(c.ID, expression, StringComparison.OrdinalIgnoreCase) == 0); },
                               recursive, stopAtFirst);
                    }
                }
                else
                {
                    // case sensitive text
                    if (partial)
                    {
                        // case sensitive partial text
                        doFind(root, result, delegate(Control c) { return (c.ID.Contains(expression)); }, recursive, stopAtFirst);
                    }
                    else
                    {
                        // case sensitive exact text
                        doFind(root, result,
                               delegate(Control c) { return (string.Compare(c.ID, expression, StringComparison.Ordinal) == 0); },
                               recursive, stopAtFirst);
                    }
                }
            }
            else
            {
                // regex
                // we silently ignore the partial flag
                RegexOptions opts = caseInsensitive ? RegexOptions.IgnoreCase : RegexOptions.None;
                doFind(root, result, delegate(Control c) { return (Regex.IsMatch(c.ID, expression, opts)); }, recursive, stopAtFirst);
            }

            return result;
        }
 /// <summary>
 /// Finds all controls matching the specified expression 
 /// in the specified control and its subtree. 
 /// </summary>
 /// <param name="rootControl">
 /// The root <see cref="Control"/>
 /// </param>
 /// <param name="expression">
 /// The expression
 /// </param>
 /// <param name="searchOptions">
 /// The <see cref="TextSearchOptions"/>
 /// </param>
 /// <returns>
 /// </returns>
 public static IFullList<Control> FindInControl(Control rootControl, string expression, TextSearchOptions searchOptions)
 {
     return FindInControl(rootControl, expression, searchOptions, true);
 }
Exemple #43
0
        /// <summary>
        /// Builds a lambda expression that can be used in a where clause,
        /// that searches for the given phrase (considering the search
        /// options) in the given property name(s)
        ///
        /// Eg to search for the exact phrase "This is a test phrase" in the
        /// field/property "TestField" of some object, you could call
        /// var res = someCollection.Where(SearchText("This is a test phrase", TextSearchOptions.SearchExact, o=>o.TestField));
        ///
        /// It is important to note that the properties are OR'd together,
        /// ie the returned expression will return true if the searchPhrase
        /// is found in ANY of the properties.
        /// </summary>
        /// <param name="searchPhrase"></param>
        /// <param name="opt"></param>
        /// <param name="fieldsToSearch"></param>
        /// <returns></returns>
        public static Expression <Func <MPDrawing, bool> > SearchText(string searchPhrase, TextSearchOptions opt, params Expression <Func <MPDrawing, string> >[] fieldsToSearch)
        {
            int numFields = fieldsToSearch.Count();

            string[] propNames = new string[numFields];
            Expression <Func <MPDrawing, bool> > whereClause    = null;
            Expression <Func <MPDrawing, bool> > whereSubClause = null;

            //fetch the property names
            for (int i = 0; i < numFields; i++)
            {
                propNames[i] = GPN(fieldsToSearch[i]);
            }

            //deal with the SearchExact case
            if (opt == TextSearchOptions.SeachExact)
            {
                whereClause = WhereLike(propNames[0], searchPhrase);
                for (int j = 1; j < numFields; j++)
                {
                    whereClause = whereClause.OrElse(WhereLike(propNames[j], searchPhrase));
                }
                return(whereClause);
            }
            //tokenise the search phrase
            string[] tokens = searchPhrase.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            //if there aren't any tokens (eg a string of spaces), just search the exact phrase instead
            if (tokens.Count() == 0)
            {
                return(SearchText(searchPhrase, TextSearchOptions.SeachExact, fieldsToSearch));
            }
            ;

            //create the clause for the first property
            whereClause = WhereLike(propNames[0], tokens[0]);
            for (int i = 1; i < tokens.Length; i++)
            {
                whereClause = opt == TextSearchOptions.SearchAllWords ? whereClause.AndAlso(WhereLike(propNames[0], tokens[i])) : whereClause.OrElse(WhereLike(propNames[0], tokens[i]));
            }
            //if there are more fields, or them all up
            for (int j = 1; j < numFields; j++)
            {
                whereSubClause = WhereLike(propNames[j], tokens[0]);
                for (int i = 1; i < tokens.Length; i++)
                {
                    whereSubClause = opt == TextSearchOptions.SearchAllWords ? whereSubClause.AndAlso(WhereLike(propNames[j], tokens[i])) : whereSubClause.OrElse(WhereLike(propNames[j], tokens[i]));
                }
                whereClause = whereClause.OrElse(whereSubClause);
            }
            return(whereClause);
        }
 /// <summary>
 /// Searches the control tree recursively and returns the first match 
 /// </summary>
 /// <param name="rootControl">
 /// The root <see cref="Control"/>
 /// </param>
 /// <param name="expression">
 /// The search expression <see cref="System.String"/>
 /// </param>
 /// <param name="searchOptions">
 /// The <see cref="TextSearchOptions"/>
 /// </param>
 /// <returns>
 /// </returns>		
 public static Control FindFirstInControl(Control rootControl, string expression, TextSearchOptions searchOptions)
 {
     return FindFirstInControl(rootControl, expression, searchOptions, true);
 }
 public FindDialogViewModel(FindDialogContext context)
 {
     this.textSearchOptions = new TextSearchOptions(false, false, false);
     this.findNextCommand = new FindNextCommand(context.FixedDocumentViewer, this.TextSearchOptions);
     this.findPreviousCommand = new FindPreviousCommand(context.FixedDocumentViewer, this.TextSearchOptions);
 }
 /// <summary>
 /// Finds all controls matching the specified expression 
 /// </summary>
 /// <param name="rootControl">
 /// The root <see cref="Control"/>
 /// </param>
 /// <param name="expression">
 /// The expression
 /// </param>
 /// <param name="searchOptions">
 /// The <see cref="TextSearchOptions"/>
 /// </param>
 /// <param name="recursive">
 /// Recurse subtree if true
 /// </param>
 /// <returns>
 /// </returns>
 public static IFullList<Control> FindInControl(Control rootControl, string expression, TextSearchOptions searchOptions, bool recursive)
 {
     return new ControlFinder(rootControl).Find(expression, searchOptions, recursive);
 }
 public FindDialogViewModel(FindDialogContext context)
 {
     this.textSearchOptions   = new TextSearchOptions(false, false, false);
     this.findNextCommand     = new FindNextCommand(context.FixedDocumentViewer, this.TextSearchOptions);
     this.findPreviousCommand = new FindPreviousCommand(context.FixedDocumentViewer, this.TextSearchOptions);
 }
 /// <summary>
 /// Searches the control tree and returns the first match 
 /// </summary>
 /// <param name="expression">
 /// The search expression <see cref="System.String"/>
 /// </param>
 /// <param name="searchOptions">
 /// The <see cref="TextSearchOptions"/>
 /// </param>
 /// <param name="recursive">
 /// Search in all the subtree if true
 /// </param>
 /// <returns>
 /// A <see cref="Control"/> that matches the expression
 /// </returns>
 public Control FindFirst(string expression, TextSearchOptions searchOptions, bool recursive)
 {
     IFullList<Control> res = Find(expression, searchOptions, recursive, true);
     if (res.Count > 0)
         return res[0];
     return null;
 }