<commit_before>﻿using System;
using System.Text.RegularExpressions;
using Outliner.Controls.FiltersBase;
using Outliner.Scene;

namespace Outliner.Filters
{
public class NameFilter : Filter<IMaxNodeWrapper>
{
   public NameFilter() 
   {
      this.SearchString = String.Empty;
      this.CaseSensitive = false;
      this._useWildcard = false;
   }

   private const String SEARCH_BEGINS_WITH = "^";
   private const String SEARCH_WILDCARD = ".";
   private RegexOptions _regExpOptions;
   private String _searchString;
   private String _origSearchString;
   private Boolean _useWildcard;


   public String SearchString 
   {
      get 
      {
         return _origSearchString;
      }
      set
      {
         if (value == null)
            throw new ArgumentNullException("value");

         _origSearchString = value;
         if (value == String.Empty)
               _searchString = value;
         else
         {
               if (this.UseWildcard || value.Substring(0, 1) == "*")
                  _searchString = SEARCH_WILDCARD + Regex.Escape(value.Substring(1, value.Length - 1));
               else
                  _searchString = SEARCH_BEGINS_WITH + Regex.Escape(value);
         }

         this.OnFilterChanged();
      }
   }
   public Boolean CaseSensitive 
   {
      get { return _regExpOptions == RegexOptions.None; }
      set
      {
         if (value)
               _regExpOptions = RegexOptions.None;
         else
               _regExpOptions = RegexOptions.IgnoreCase;

         this.OnFilterChanged();
      }
   }
   public Boolean UseWildcard 
   {
      get { return _useWildcard; }
      set
      {
         _useWildcard = value;
         this.SearchString = _origSearchString;
      }<commit_msg>Added comments to NameFilter<commit_after>﻿using System;
using System.Text.RegularExpressions;
using Outliner.Controls.FiltersBase;
using Outliner.Scene;

namespace Outliner.Filters
{
public class NameFilter : Filter<IMaxNodeWrapper>
{
   public NameFilter() 
   {
      this.SearchString = String.Empty;
      this.CaseSensitive = false;
      this._useWildcard = false;
   }

   private const String SEARCH_BEGINS_WITH = "^";
   private const String SEARCH_WILDCARD = ".";
   private RegexOptions _regExpOptions;
   private String _searchString;
   private String _origSearchString;
   private Boolean _useWildcard;


   public String SearchString 
   {
      get 
      {
         return _origSearchString;
      }
      set
      {
         if (value == null)
            throw new ArgumentNullException("value");

         _origSearchString = value;
         if (value == String.Empty)
               _searchString = value;
         else
         {
               if (this.UseWildcard || value.Substring(0, 1) == "*")
                  _searchString = SEARCH_WILDCARD + Regex.Escape(value.Substring(1, value.Length - 1));
               else
                  _searchString = SEARCH_BEGINS_WITH + Regex.Escape(value);
         }

         this.OnFilterChanged();
      }
   }

   /// <summary>
   /// Gets or sets whether the search should be case sensitive.
   /// If true, a searchstring "S" matches "Sphere", but not "sphere"
   /// </summary>
   public Boolean CaseSensitive 
   {
      get { return _regExpOptions == RegexOptions.None; }
      set
      {
         if (value)
               _regExpOptions = RegexOptions.None;
         else
               _regExpOptions = RegexOptions.IgnoreCase;

         this.OnFilterChanged();
      }
   }

   /// <summary>
   /// Gets or sets whether a wildcard should be prepended to the search string by default.
   /// If true, a searchstring "e" matches "sphere".
   /// </summary>
   public Boolean UseWildcard 
   {
      get { return _useWildcard; }
      set
      {
         _useWildcard = value;
         this.SearchString = _origSearchString;
      }
{'fraction_non_alphanumeric': 0.08715953307392996, 'fraction_numerical': 0.0020752269779507134, 'mean_word_length': 2.024313725490196, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6523629', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1082, 'n_words': 257}