Esempio n. 1
0
        /// <summary>
        /// Finds the specified text in the target.
        /// </summary>
        /// <param name="findData">The text to search for.</param>
        /// <param name="findMode">Whether to find next, previous, or display a dialog.</param>
        /// <returns>True if the find text was found and selected.  False otherwise.</returns>
        public bool Find(FindData findData, FindMode findMode)
        {
            TextBoxFinder finder = new(this);
            bool          result = finder.Find(this, findData, findMode);

            return(result);
        }
Esempio n. 2
0
 void SetFindMode()
 {
     if (findButton.Checked)
     {
         findAndReplaceMode            = FindMode.Find;
         groupBox.Location             = new Point(13, 111);
         findAreaLabel.Location        = new Point(10, 65);
         findAreaComboBox.Location     = new Point(15, 82);
         findNextButton.Location       = new Point(148, 256);
         replaceAllButton.Visible      = false;
         replacePatternLabel.Visible   = false;
         replaceNextButton.Visible     = false;
         replaceNextButton.Enabled     = findNextButton.Enabled;;
         replacePatternTextBox.Enabled = false;
         replacePatternTextBox.Visible = false;
         this.ClientSize = new Size(250, 285);
     }
     else
     {
         findAndReplaceMode            = FindMode.Replace;
         groupBox.Location             = new Point(13, 161);
         findAreaLabel.Location        = new Point(10, 111);
         findAreaComboBox.Location     = new Point(15, 128);
         findNextButton.Location       = new Point(87, 306);
         replaceAllButton.Enabled      = findNextButton.Enabled;
         replaceAllButton.Visible      = true;
         replaceAllButton.Location     = new Point(148, 336);
         replacePatternLabel.Visible   = true;
         replaceNextButton.Visible     = true;
         replaceNextButton.Enabled     = findNextButton.Enabled;;
         replacePatternTextBox.Enabled = true;
         replacePatternTextBox.Visible = true;
         this.ClientSize = new Size(250, 365);
     }
 }
Esempio n. 3
0
        public ReplaceParameter(string replaceFrom, string replaceTo, FindMode mode)
        {
            this.ReplaceFrom = replaceFrom;
            this.ReplaceTo   = replaceTo;
            this.Mode        = mode;

            switch (mode)
            {
            case FindMode.Plain:
                string escapedText = Regex.Escape(this.ReplaceFrom);
                this.ReplaceFromPattern = new Regex(escapedText, RegexOptions.Compiled);
                this.ReplaceToPattern   = new[] { ExtendReplaceTo.Plain(this.ReplaceTo) };
                break;


            case FindMode.Word:
                string escapedWord = Regex.Escape(this.ReplaceFrom);
                escapedText             = "\\b" + escapedWord + "\\b";
                this.ReplaceFromPattern = new Regex(escapedText, RegexOptions.Compiled);
                this.ReplaceToPattern   = new[] { ExtendReplaceTo.Plain(this.ReplaceTo) };
                break;

            case FindMode.Regex:
                this.ReplaceFromPattern = new Regex(this.ReplaceFrom, RegexOptions.Compiled);
                this.ReplaceToPattern   = ExtendReplaceTo.Parse(this.ReplaceTo);
                break;
            }
        }
Esempio n. 4
0
 private void AllFiles_CheckedChanged(object sender, EventArgs e)
 {
     if (Mode == FindMode.Replace)
     {
         return;
     }
     Mode = AllFiles.Checked ? FindMode.FindInAllFiles : FindMode.FindInCurrentFile;
 }
Esempio n. 5
0
        private void SetMode(FindMode findMode)
        {
            _findMode = findMode;

            _toggleReplace.Bitmap = _findMode == FindMode.Find ? ToggleDownImage : ToggleUpImage;

            _replaceRow.Visibility       = _findMode == FindMode.Replace ? Visibility.Visible : Visibility.Collapsed;
            _replaceWith.Control.Visible = _findMode == FindMode.Replace;
        }
Esempio n. 6
0
        public static void FindAndHighlight(String word, FindMode fm)
        {
            word = word.ToUpper();
            var matches = FindMatch(word, 0, fm);

            foreach (TextBox c in pu.Controls)
            {
                SetTbColour(c, matches.Any(s => s.Tb == c));
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Возвращает коллекцию типов, унаследованных от <paramref name="parentType"/>
 /// </summary>
 /// <param name="parentType">Родительский тип</param>
 /// <param name="assemblyNames">Имена сборок текущего проекта, в которых необходимо произвести поиск
 /// (если не указаны, ищем в сборке, в которой определён <paramref name="parentType"/>)</param>
 /// <returns>Коллекция типов, являющихся наследниками <paramref name="parentType"/>,
 /// или null, если таковые не найдены</returns>
 public static List <Type> GetInheritedTypes(this Type parentType, FindMode finedMode = FindMode.All, List <string> assemblyNames = null)
 => (assemblyNames != null
         ? AppDomain.CurrentDomain
     .GetAssemblies()
     .Where(a => assemblyNames.Contains(a.FullName))
     ?.SelectMany(a => a.GetTypes())
         : Assembly.GetAssembly(parentType)
     .GetTypes())
 ?.Where(t => t.IsSubclassOf(parentType) &&              // Является ли наследником
         OptionalChecking(t, finedMode))
 ?.ToList();
Esempio n. 8
0
        INameWorker CreateWorker(FindMode mode, string text, bool ignoreCase)
        {
            switch (mode)
            {
            case FindMode.Simple: return(new SimpleNameWorker(text, ignoreCase));

            case FindMode.RegExp: return(new RegExNameWorker(text, ignoreCase));

            default: return(null);
            }
        }
 void OnUpdateSearchMode()
 {
     if (IsSearchModeAlways)
     {
         SearchMode = FindMode.Always;
     }
     if (IsSearchModeFindOnEnter)
     {
         SearchMode = FindMode.FindOnEnter;
     }
 }
        public T FindFirstByName([CanBeNull] string nameRaw, FindMode findMode = FindMode.Exact)
        {
            if (nameRaw == null)
            {
                return(null);
            }
            //no matter which mode, if anything matches exactly, then return that.
            //this prevents errors where partial matches would return something wrong
            foreach (var myItem in MyItems)
            {
                if (myItem.Name == nameRaw)
                {
                    return(myItem);
                }
            }

            string nameUpper = nameRaw.ToUpperInvariant();

            if (findMode == FindMode.IgnoreCase)
            {
                foreach (var myItem in MyItems)
                {
                    if (string.Equals(myItem.Name.ToUpperInvariant(), nameUpper,
                                      StringComparison.CurrentCulture))
                    {
                        return(myItem);
                    }
                }
            }
            else
            if (findMode == FindMode.Partial)
            {
                foreach (var myItem in MyItems)
                {
                    if (myItem.Name.ToUpperInvariant().Contains(nameUpper))
                    {
                        return(myItem);
                    }
                }
            }
            else
            if (findMode == FindMode.StartsWith)
            {
                foreach (var myItem in MyItems)
                {
                    if (myItem.Name.ToUpperInvariant().StartsWith(nameUpper))
                    {
                        return(myItem);
                    }
                }
            }
            return(null);
        }
        /// <summary>
        /// Escape magic chars so we can use regex for plain old filters.
        /// Static so the whole world can use it.
        /// </summary>
        /// <returns></returns>
        public static Regex CreateRegex(string regExString, FindMode mode, bool matchCase, bool matchWholeWord, bool next)
        {
            Regex r;

            switch (mode)
            {
            case FindMode.Normal:
                // replace escape characters
                regExString = Regex.Escape(regExString);
                //regExString = regExString.Replace(@"\*", ".*").Replace(@"\?", ".");
                break;

            case FindMode.Wildcard:
                regExString = regExString.Replace("*", @"\w*");         // multiple characters wildcard (*)
                regExString = regExString.Replace("?", @"\w");          // single character wildcard (?)
                break;

            case FindMode.Extended:
                //\n  new line (LF)
                //\r   carriage return (CR)
                //\t   tab character
                //\0  null character
                //\xddd   special character with code ddd
                regExString = regExString.Replace(@"\\", @"\");
                break;

            case FindMode.Regex:
                // No changes needed.
                break;
            }

            // Figure out options.
            if (matchWholeWord || mode == FindMode.Wildcard) // if wild cards selected, find whole words only
            {
                regExString = string.Format("{0}{1}{0}", @"\b", regExString);
            }

            RegexOptions options = RegexOptions.None;

            if (!next)
            {
                options |= RegexOptions.RightToLeft;
            }

            if (!matchCase)
            {
                options |= RegexOptions.IgnoreCase;
            }

            return(new Regex(regExString, options));
        }
        /// <summary>Escape magic chars so we can use regex for plain old filters.
        /// Static so the whole world can use it.</summary>
        /// <returns></returns>
        public static Regex CreateRegex(string regExString, FindMode mode, bool matchCase, bool matchWholeWord, bool next)
        {
            Regex r = null;

            switch (mode)
            {
                case FindMode.Normal:
                    // replace escape characters
                    regExString = Regex.Escape(regExString);
                    //regExString = regExString.Replace(@"\*", ".*").Replace(@"\?", ".");
                    break;

                case FindMode.Wildcard:
                    regExString = regExString.Replace("*", @"\w*");     // multiple characters wildcard (*)
                    regExString = regExString.Replace("?", @"\w");      // single character wildcard (?)
                    break;

                case FindMode.Extended:
                    //\n  new line (LF)
                    //\r   carriage return (CR)
                    //\t   tab character
                    //\0  null character
                    //\xddd   special character with code ddd
                    regExString = regExString.Replace(@"\\", @"\");
                    break;

                case FindMode.Regex:
                    // No changes needed.
                    break;
            }

            // Figure out options.
            if (matchWholeWord || mode == FindMode.Wildcard) // if wild cards selected, find whole words only
            {
                regExString = string.Format("{0}{1}{0}", @"\b", regExString);
            }

            RegexOptions options = RegexOptions.None;
            if (!next)
            {
                options |= RegexOptions.RightToLeft;
            }

            if (!matchCase)
            {
                options |= RegexOptions.IgnoreCase;
            }

            return new Regex(regExString, options);
        }
Esempio n. 13
0
        public FindWindow(Events events, FindMode mode)
        {
            InitializeComponent();
            _events = events;
            if (!string.IsNullOrEmpty(_storedQuery))
            {
                SearchQuery.Text = _storedQuery;
            }

            if (GetTargetEditor() == null && mode == FindMode.FindInCurrentFile)
            {
                mode = FindMode.FindInAllFiles;
            }
            Mode = mode;
            ReplaceButton.Enabled = ReplaceAllButton.Enabled = FindNextButton.Enabled = !string.IsNullOrEmpty(SearchQuery.Text);
        }
Esempio n. 14
0
        public static void SetScintillaSearchFlags(Scintilla scintilla, FindOptions findOptions, FindMode findMode)
        {
            if (scintilla == null) {
                return;
            }

            // 検索オプション
            scintilla.SearchFlags = 0;
            scintilla.SearchFlags |= findOptions.HasFlag(FindOptions.MatchWholeWordOnly) ?
                SearchFlags.WholeWord : SearchFlags.None;
            scintilla.SearchFlags |= findOptions.HasFlag(FindOptions.MatchCase) ?
                SearchFlags.MatchCase : SearchFlags.None;

            // 検索モード
            scintilla.SearchFlags |= findMode == FindMode.RegularExpression ?
                SearchFlags.Regex : SearchFlags.None;
        }
Esempio n. 15
0
    void OnGUI()
    {
        Object oj = EditorGUILayout.ObjectField("当前查询物体:", _target, typeof(Object), false);

        if (oj != _target)
        {
            _target        = oj;
            _needCalculate = true;
        }

        EditorGUILayout.BeginHorizontal();

        FindMode fm = (FindMode)EditorGUILayout.EnumPopup("查找方式", _findMode, GUILayout.Height(25));

        if (fm != _findMode)
        {
            _findMode      = fm;
            _needCalculate = true;
        }

        if (GUILayout.Button("计算引用", GUILayout.Height(25)))
        {
            _needCalculate = true;
        }

        EditorGUILayout.EndHorizontal();

        GUILayout.Space(10f);

        _DoCalculate();

        switch (_findMode)
        {
        case FindMode.Reference:
            ShowReference();
            break;

        case FindMode.BeReference:
            ShowBeReferences();
            break;

        default:
            break;
        }
    }
Esempio n. 16
0
            public void SetMode(FindMode findMode)
            {
                _form._modeFind.Checked        = findMode == FindMode.Find;
                _form._modeFindReplace.Checked = findMode == FindMode.Replace;

                bool replace = findMode == FindMode.Replace;

                _form.ShowControl(_form._replaceWith, replace);
                _form.ShowControl(_form._replaceWithLabel, replace);
                _form.ShowControl(_form._keepOpen, replace);
                _form.ShowControl(_form._skipFile, replace);
                _form.ShowControl(_form._replaceAll, replace);
                _form.ShowControl(_form._replace, replace);
                _form.ShowControl(_form._replaceFindNext, replace);
                _form.ShowControl(_form._findNext, !replace);
                _form.ShowControl(_form._findPrevious, !replace);
                _form.ShowControl(_form._findAll, !replace);
            }
Esempio n. 17
0
        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FindMode?findModeq = (FindMode?)value;

            if (findModeq == null)
            {
                return(value);
            }
            FindMode findMode = findModeq.Value;

            switch (findMode)
            {
            case FindMode.Always: return("Always");

            case FindMode.FindClick: return("Find on Click");
            }
            return(value);
        }
Esempio n. 18
0
        /// <summary>
        /// 在当前文件中查找字符串
        /// </summary>
        /// <param name="strPrefix">字符串前缀,如"SRWF-"</param>
        /// <param name="strSuffix">字符串后缀,如以" " 或 "" 结束</param>
        /// <param name="findMode">查找模式 FindMode, 从头部或尾部查找</param>
        /// <param name="offset">要检索的长度,如 1024 byte</param>
        /// <returns>若找到返回该字符串,否则返回空字符串""</returns>
        public string GetStringFromDataBuffer(string strPrefix, string strSuffix, FindMode findMode, int offset)
        {
            string strFind = "";
            int    indexStart = -1, indexEnd = -1;

            if (findMode == FindMode.Begin)
            {
                indexStart = Util.IndexOf(_dataBuffer, strPrefix, 0, offset);

                if (indexStart >= 0)
                {
                    indexEnd = Util.IndexOf(_dataBuffer, strSuffix, indexStart, (offset - indexStart));
                }

                if (indexEnd >= 0)
                {
                    strFind = Encoding.UTF8.GetString(_dataBuffer, indexStart, (indexEnd - indexStart));
                }
            }
            else if (findMode == FindMode.End)
            {
                indexStart = Util.IndexOf(_dataBuffer, strPrefix, (FileSize - offset), offset);

                if (indexStart >= 0)
                {
                    indexEnd = Util.IndexOf(_dataBuffer, strSuffix, indexStart, (FileSize - indexStart));
                }

                if (indexEnd >= 0)
                {
                    strFind = Encoding.UTF8.GetString(_dataBuffer, indexStart, (indexEnd - indexStart));
                }
            }

            return(strFind);
        }
Esempio n. 19
0
        private static void SetSearchDimensions(int startX, int startY, FindMode fm, out int miny, out int maxy,
                                                out int minx, out int maxx, Direction d = Direction.NotSet)
        {
            miny = 0;
            maxy = height;
            minx = 0;
            maxx = width;

            if (startX != -1)
            {
                minx = startX - 1;
                maxx = startX + 1;
            }

            if (startY != -1)
            {
                miny = startY - 1;
                maxy = startY + 1;
            }

            //constrain the possible
            if (d != Direction.NotSet && fm == FindMode.Crossword)
            {
                minx = maxx = startX + directions[d].Item1;
                miny = maxy = startY + directions[d].Item2;
            }
        }
Esempio n. 20
0
        /// <summary>
        /// from a starting point, find a letter
        /// </summary>
        /// <param name="letter"></param>
        /// <param name="fm"></param>
        /// <param name="startX"></param>
        /// <param name="startY"></param>
        /// <param name="ignorelist"></param>
        /// <param name="d"></param>
        /// <returns></returns>
        private static IEnumerable<GridPoint> GetSquare(char letter, FindMode fm, int startX = -1, int startY = -1,
                                                      List<GridPoint> ignorelist = null, Direction d = Direction.NotSet)
        {
            //if we want a direction, must have a position as well
            if (!((startX == -1 || startY == -1) && d != Direction.NotSet))
            {
                int minx, miny, maxx, maxy;
                SetSearchDimensions(startX, startY, fm, out miny, out maxy, out minx, out maxx, d);

                for (int y = miny; y <= maxy; y++)
                {
                    if (OutOfBounds(y, false))
                        continue;

                    for (int x = minx; x <= maxx; x++)
                    {
                        if (OutOfBounds(x, true))
                            continue;

                        if (y == startY && x == startX)
                            continue;

                        var gp = grid[y][x];

                        if (ignorelist != null && ignorelist.Contains(gp))
                            continue;

                        if (grid[y][x].C == letter)
                            yield return grid[y][x];
                    }
                }
            }
            yield return null;
        }
Esempio n. 21
0
        /*
        private static Tuple<int, int> GetControlPos(GridPoint tb)
        {
            var p = tb.Name.IndexOf(':');

            int x = int.Parse(tb.Name.Substring(0, p));
            int y = int.Parse(tb.Name.Substring(p + 1));

            return new Tuple<int, int>(x, y);
        }
        */
        /// <summary>
        /// find words based on raw input text
        /// </summary>
        /// <param name="word"></param>
        /// <param name="posc"></param>
        /// <param name="fm"></param>
        /// <param name="lastaccum"></param>
        /// <param name="lastdir"></param>
        /// <returns></returns>
        private static List<GridPoint> FindMatch(string word, int posc, FindMode fm, List<GridPoint> lastaccum = null,
                                               Direction lastdir = Direction.NotSet)
        {
            if (string.IsNullOrWhiteSpace(word))
                return new List<GridPoint>();

            int x = -1;
            int y = -1;
            if (lastaccum != null)
            {
                var lgp = lastaccum.Last();
                var lastpos = new Tuple<int, int>(lgp.X, lgp.Y);
                x = lastpos.Item1;
                y = lastpos.Item2;
            }

            foreach (var f in GetSquare(word[posc], fm, x, y, lastaccum, lastdir))
            {
                //bad branch
                if (f == null)
                    continue;

                var lastaccumnew = new List<GridPoint>();
                if (lastaccum != null)
                    lastaccumnew.AddRange(lastaccum);
                lastaccumnew.Add(f);

                var found = new List<GridPoint>();
                var ret = new List<GridPoint>();

                //finished
                if (posc == (word.Length - 1))
                {
                    ret.Add(f);
                    return ret;
                }

                if (lastaccum == null && lastdir == Direction.NotSet)
                {
                    found = FindMatch(word, posc + 1, fm, lastaccumnew);
                }
                else if (lastaccum != null)
                {
                    var thisdir = GetDirection(lastaccum.Last(), f);
                    found = FindMatch(word, posc + 1, fm, lastaccumnew, thisdir);
                }

                if (found.Count == 0)
                    continue;

                ret.Add(f);
                ret.AddRange(found);
                return ret;
            }

            return new List<GridPoint>();
        }
Esempio n. 22
0
 public LinkedList<MarkupElement> Find(string[] query, bool deepSearch, bool matchCase, bool[] matchWhole, FindMode mode)
 {
     return Find(
         query,
         deepSearch,
         createBoolArray(matchCase, query.Length),
         matchWhole,
         mode);
 }
Esempio n. 23
0
        private void SetMode( FindMode Mode )
        {
            this.Mode = Mode;
            RawModeName = Enum.GetName( typeof( FindMode ), Mode );

            foreach ( RegItem R in RegexPairs ) R.Validate( Mode );

            NotifyChanged( "RawModeName", "ModeName" );
        }
Esempio n. 24
0
        public static double NearDouble(double[] data, double BaseValue, FindMode mode = FindMode.None)
        {
            bool flag = false;

            List <double> list = data.Copy().ToList();

            // 초기화 작업
            foreach (double d in data.Copy())
            {
                switch (mode)
                {
                case FindMode.None: flag = true; break;

                case FindMode.NoOver:
                    if (d > BaseValue)
                    {
                        list.Remove(d);
                    }
                    break;

                case FindMode.NoUnder:
                    if (d < BaseValue)
                    {
                        list.Remove(d);
                    }
                    break;
                }

                if (flag)
                {
                    break;
                }
            }
            data = list.ToArray();


            if (data.Length == 1)
            {
                return(data[0]);
            }

            double Near = double.MinValue;

            foreach (double d in data)
            {
                if (Math.Abs(BaseValue - d) < Math.Abs(BaseValue - Near))
                {
                    if (d >= BaseValue && mode == FindMode.NoOver && !(Max(data) == d))
                    {
                        continue;
                    }
                    else if (d <= BaseValue && mode == FindMode.NoUnder)
                    {
                        continue;
                    }
                    if (d == BaseValue)
                    {
                        continue;
                    }

                    Near = d;
                }
            }


            return(Near);
        }
Esempio n. 25
0
        public void Start(bool preview = false)
        {
            var probing = DataContext as ProbingViewModel;

            if (!probing.ValidateInput() || probing.Passes == 0)
            {
                return;
            }

            mode = FindMode.XY;

            if (probing.WorkpieceSizeX <= 0d && probing.WorkpieceSizeY <= 0d)
            {
                probing.SetError(nameof(probing.WorkpieceSizeX), "Workpiece X size cannot be 0.");
                probing.SetError(nameof(probing.WorkpieceSizeY), "Workpiece Y size cannot be 0.");
                return;
            }

            if (probing.WorkpieceSizeX <= 0d)
            {
                mode = FindMode.Y;
                //   probing.SetError(nameof(probing.WorkpieceSizeX), "Workpiece X size cannot be 0.");
                //   return;
            }

            if (probing.WorkpieceSizeY <= 0d)
            {
                mode = FindMode.X;
                // probing.SetError(nameof(probing.WorkpieceSizeY), "Workpiece Y size cannot be 0.");
                // return;
            }

            if (mode != FindMode.Y && probing.ProbeCenter == Center.Inside && probing.WorkpieceSizeX < probing.XYClearance * 2d + probing.ProbeDiameter)
            {
                probing.SetError(nameof(probing.WorkpieceSizeX), "Probing XY clearance too large for workpiece X size.");
                return;
            }

            if (mode != FindMode.X && probing.ProbeCenter == Center.Inside && probing.WorkpieceSizeY < probing.XYClearance * 2d + probing.ProbeDiameter)
            {
                probing.SetError(nameof(probing.WorkpieceSizeY), "Probing XY clearance too large for workpiece Y size.");
                return;
            }

            pass = preview ? 1 : probing.Passes;

            if (CreateProgram(preview))
            {
                do
                {
                    if (preview)
                    {
                        probing.PreviewText = probing.Program.ToString().Replace("G53", string.Empty);
                        PreviewOnCompleted();
                        probing.PreviewText += "\n; Post XY probe\n" + probing.Program.ToString().Replace("G53", string.Empty);
                    }
                    else
                    {
                        probing.Program.Execute(true);
                        OnCompleted();
                    }
                } while (--pass != 0 && CreateProgram(preview));
            }
        }
Esempio n. 26
0
        public IEnumerable <File> Find(FindMode _findmode, List <String> _criteria)
        {
            DirectoryInfo[] containDirs = null;
            try
            {
                containDirs = CurrentDirInfo.GetDirectories();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            List <File> findResInInnderDirs = new List <File>();

            foreach (DirectoryInfo dir in containDirs)
            {
                Dir innerDir = new Dir(dir);
                findResInInnderDirs.AddRange(innerDir.Find(_findmode, _criteria));
            }
            List <FileInfo>      containFiles = new List <FileInfo>(CurrentDirInfo.GetFiles());
            Predicate <FileInfo> pred         = null;

            if (_findmode == FindMode.Name)
            {
                if (_criteria.Count() != 1)
                {
                    throw new Exception("Wrong arguments count");
                }
                pred = delegate(FileInfo fi) {
                    Regex re = new Regex("\\w*" + _criteria[0] + "\\w*");
                    return(re.IsMatch(fi.Name));
                };
            }
            else if (_findmode == FindMode.Size)
            {
                if (_criteria.Count() != 2)
                {
                    throw new Exception("Wrong arguments count");
                }
                pred = delegate(FileInfo fi) {
                    double low, high, fileSize = fi.Length;
                    if (!double.TryParse(_criteria.ToList()[0], out low))
                    {
                        throw new Exception("Bad arguments");
                    }
                    if (!double.TryParse(_criteria.ToList()[1], out high))
                    {
                        throw new Exception("Bad arguments");
                    }
                    return(fileSize > low && fileSize < high);
                };
            }
            else if (_findmode == FindMode.Date)
            {
                if (_criteria.Count() != 2)
                {
                    throw new Exception("Wrong arguments count");
                }
                pred = delegate(FileInfo fi)
                {
                    DateTime dt_low  = Convert.ToDateTime(_criteria.ToList()[0]);
                    DateTime dt_high = Convert.ToDateTime(_criteria.ToList()[1]);
                    DateTime cr_dt   = fi.CreationTime;
                    return(cr_dt < dt_high && cr_dt > dt_low);
                };
            }
            else
            {
                throw new Exception("Undefined operation");
            }
            List <FileInfo> finfo = containFiles.FindAll(pred);

            foreach (FileInfo fi in finfo)
            {
                findResInInnderDirs.Add(new File(fi));
            }
            return(findResInInnderDirs);
        }
Esempio n. 27
0
        private void SetMode(FindMode findMode)
        {
            _findMode = findMode;

            _toggleReplace.Bitmap = _findMode == FindMode.Find ? ToggleDownImage : ToggleUpImage;

            _replaceRow.Visibility = _findMode == FindMode.Replace ? Visibility.Visible : Visibility.Collapsed;
            _replaceWith.Control.Visible = _findMode == FindMode.Replace;
        }
Esempio n. 28
0
 private void asciiRadioButton_CheckedChanged(object sender, EventArgs e)
 {
     this.Mode  = FindMode.Ascii;
     _didChange = true;
 }
Esempio n. 29
0
 private void asciiRadioButton_CheckedChanged( object sender, EventArgs e )
 {
     this.Mode = FindMode.Ascii;
     _didChange = true;
 }
Esempio n. 30
0
 private void binaryRadioButton_CheckedChanged( object sender, EventArgs e )
 {
     this.Mode = FindMode.Binary;
     _didChange = true;
 }
Esempio n. 31
0
        /// <summary>
        /// from a starting letter/position, find all possible words from this
        /// </summary>
        /// <param name="word"></param>
        /// <param name="history"></param>
        /// <param name="lastdir"></param>
        /// <param name="fm"></param>
        /// <param name="minx"></param>
        /// <param name="maxx"></param>
        /// <param name="miny"></param>
        /// <param name="maxy"></param>
        private static IEnumerable<FoundWord> Solve(String word, List<GridPoint> history, Direction lastdir, FindMode fm, int minx,
                                          int maxx, int miny, int maxy)
        {
            var retwords = new List<FoundWord>();
            //if its a word, add
            if (trieroot.ContainsWord(word, false))
            {
                var sc = GetWordScore(history);
                retwords.Add(new FoundWord(word, sc, history));
            }

            for (int y = miny; y <= maxy; y++)
            {
                if (OutOfBounds(y, false))
                    continue;

                for (int x = minx; x <= maxx; x++)
                {
                    if (OutOfBounds(x, true))
                        continue;

                    var p = grid[y][x];

                    if (history.Contains(p))
                        continue;

                    Direction newdir = history.Count == 0 ? Direction.NotSet : GetDirection(history.Last(), p);

                    if (newdir != lastdir && lastdir != Direction.NotSet && fm == FindMode.Crossword)
                        continue;

                    String newword = word + p.C;

                    if (trieroot.ContainsWord(newword, true))
                    {
                        var newhistory = new List<GridPoint>();
                        newhistory.AddRange(history);
                        newhistory.Add(p);

                        int nminx = -1, nminy, nmaxx = -1, nmaxy;
                        SetSearchDimensions(x, y, fm, out nminy, out nmaxy, out nminx, out nmaxx, newdir);
                        retwords.AddRange(Solve(newword, newhistory, newdir, fm, nminx, nmaxx, nminy, nmaxy));
                    }
                }
            }
            return retwords;
        }
Esempio n. 32
0
 public LinkedList<MarkupElement> Find(string[] query, bool[] matchCase, bool[] matchWhole, FindMode mode)
 {
     return Find(query, true, matchCase, matchWhole, mode);
 }
Esempio n. 33
0
            public void SetMode(FindMode findMode)
            {
                _form._modeFind.Checked = findMode == FindMode.Find;
                _form._modeFindReplace.Checked = findMode == FindMode.Replace;

                bool replace = findMode == FindMode.Replace;

                _form.ShowControl(_form._replaceWith, replace);
                _form.ShowControl(_form._replaceWithLabel, replace);
                _form.ShowControl(_form._keepOpen, replace);
                _form.ShowControl(_form._skipFile, replace);
                _form.ShowControl(_form._replaceAll, replace);
                _form.ShowControl(_form._replace, replace);
                _form.ShowControl(_form._replaceFindNext, replace);
                _form.ShowControl(_form._findNext, !replace);
                _form.ShowControl(_form._findPrevious, !replace);
                _form.ShowControl(_form._findAll, !replace);
            }
Esempio n. 34
0
 public LinkedList<MarkupElement> Find(string[] query, bool matchCase, FindMode mode)
 {
     return Find(
         query,
         matchCase,
         false,
         mode);
 }
Esempio n. 35
0
 public static PartialViewResult SearchPopup(this ControllerBase controller, FindOptions findOptions, FindMode mode, string prefix)
 {
     return(Manager.SearchPopup(controller, findOptions, mode, new Context(null, prefix)));
 }
Esempio n. 36
0
            public bool Validate( FindMode Mode = FindMode.MATCH )
            {
                try
                {
                    Regex RegEx = RegExObj;
                    if( Mode == FindMode.MATCH )
                    {
                        string.Format( Format.Trim(), RegEx.GetGroupNames() );
                    }
                    Valid = true;
                }
                catch( Exception ex )
                {
                    ProcManager.PanelMessage( ID, ex.Message, LogType.ERROR );
                    Valid = false;
                }

                return Valid;
            }
Esempio n. 37
0
 public void SetMode(FindMode findMode)
 {
     _control.SetMode(findMode);
 }
Esempio n. 38
0
        /// <summary>
        /// find all words and their scores in a grid and output the words found to a listbox
        /// </summary>
        /// <param name="fm"></param>
        /// <param name="maxret"></param>
        public static List<FoundWord> Solve(FindMode fm, bool onlyBest, int maxret = -1)
        {
            var foundwords = new List<FoundWord>();

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    var gp = grid[y][x];
                    int miny;
                    int maxy;
                    int minx;
                    int maxx;
                    if (fm == FindMode.Anywhere)
                    {
                        miny = 0;
                        maxy = height;
                        minx = 0;
                        maxx = width;
                    }
                    else
                    {
                        SetSearchDimensions(x, y, fm, out miny, out maxy, out minx, out maxx);
                    }

                    foundwords.AddRange(Solve(grid[y][x].C.ToString(), new List<GridPoint> { gp }, Direction.NotSet, fm,
                                              minx, maxx, miny, maxy));
                }
            }

            if (onlyBest)
            {
                var nodupes = foundwords.GroupBy(s => s.Word).Select(s1 => s1.OrderByDescending(s2 => s2.WordScore).First()).ToList();
                foundwords = nodupes;
            }

            foundwords = foundwords.OrderByDescending(s => s.WordScore).ToList();

            if (maxret > 0)
                foundwords = foundwords.Take(maxret).ToList();

            return foundwords;
        }
Esempio n. 39
0
        public LinkedList<MarkupElement> Find(string[] query, bool deepSearch, bool[] matchCase, bool[] matchWhole, FindMode mode)
        {
            //check to make sure that the amount of queries matches the find mode
            int minQuery = 0;
            if ((mode & FindMode.TagName) == FindMode.TagName) { minQuery++; }
            if ((mode & FindMode.AttributeName) == FindMode.AttributeName) { minQuery++; }
            if ((mode & FindMode.AttributeValue) == FindMode.AttributeValue) { minQuery++; }
            if ((mode & FindMode.Text) == FindMode.Text) { minQuery++; }
            if (query.Length != minQuery) {
                throw new Exception("Expected " + minQuery + " query strings to match the mode \"" + mode + "\".");
            }
            if (matchCase.Length != minQuery) {
                throw new Exception("Expected " + minQuery + " match case options to match the mode \"" + mode + "\".");
            }
            if (matchWhole.Length != minQuery) {
                throw new Exception("Expected " + minQuery + " match case options to match the mode \"" + mode + "\".");
            }

            //define the initial list in which we search on.
            LinkedList<Node> list = Children;

            /*
                Each mode has the exact same code except we tweak the
                arguments for findCore respectively.

                We pipe the list into the findCore function and push the result
                back into the list so we reduce it each time.
            */

            //find by tag name?
            int querySelector=0;
            if ((mode & FindMode.TagName) == FindMode.TagName) {
                list = Helpers.ConvertLinkedListType<Node, MarkupElement>(
                    findCore(
                        query[querySelector],
                        deepSearch,
                        matchCase[querySelector],
                        matchWhole[querySelector++],
                        list,
                        false,
                        false,
                        false));
            }

            //find by attribute name?
            if ((mode & FindMode.AttributeName) == FindMode.AttributeName) {
                list = Helpers.ConvertLinkedListType<Node, MarkupElement>(
                    findCore(
                        query[querySelector],
                        deepSearch,
                        matchCase[querySelector],
                        matchWhole[querySelector++],
                        list,
                        false,
                        true,
                        false));
            }

            //find by attribute value?
            if ((mode & FindMode.AttributeValue) == FindMode.AttributeValue) {
                list = Helpers.ConvertLinkedListType<Node, MarkupElement>(
                    findCore(
                        query[querySelector],
                        deepSearch,
                        matchCase[querySelector],
                        matchWhole[querySelector++],
                        list,
                        false,
                        true,
                        true));
            }

            //find by text?
            if ((mode & FindMode.Text) == FindMode.Text) {
                list = Helpers.ConvertLinkedListType<Node, MarkupElement>(
                    findCore(
                        query[querySelector],
                        deepSearch,
                        matchCase[querySelector],
                        matchWhole[querySelector++],
                        list,
                        true,
                        false,
                        false));
            }

            //return the list
            return Helpers.ConvertLinkedListType<MarkupElement, Node>(list);
        }
Esempio n. 40
0
 public static PartialViewResult SearchPopup(this ControllerBase controller, FindOptions findOptions, FindMode mode, Context context)
 {
     return(Manager.SearchPopup(controller, findOptions, mode, context));
 }
Esempio n. 41
0
        public static MemberInfo GetMemberInfo <T, V>(this Expression <Func <T, V> > expression, object objectInstance, FindMode findMode)
        {
            MemberInfo member = expression.GetMemberInfo();

            if ((member.DeclaringType.IsInterface) && (findMode == FindMode.FindClass) && (objectInstance != null))
            {
                Type t = objectInstance.GetType();
                if (t != member.DeclaringType)
                {
                    MemberInfo newMember = t.GetProperty(member.Name);
                    if (newMember != null)
                    {
                        member = newMember;
                    }
                }
            }

            return(member);
        }
Esempio n. 42
0
 private void binaryRadioButton_CheckedChanged(object sender, EventArgs e)
 {
     this.Mode  = FindMode.Binary;
     _didChange = true;
 }
Esempio n. 43
0
 void OnFindModeChanged(FindMode mode)
 {
     InitSearch();
 }
Esempio n. 44
0
 public void SetMode(FindMode findMode)
 {
     _control.SetMode(findMode);
 }
Esempio n. 45
0
        protected internal virtual PartialViewResult SearchPopup(ControllerBase controller, FindOptions findOptions, FindMode mode, Context context)
        {
            if (!Finder.IsFindable(findOptions.QueryName))
            {
                throw new UnauthorizedAccessException(NormalControlMessage.ViewForType0IsNotAllowed.NiceToString().FormatWith(findOptions.QueryName));
            }

            var desc = DynamicQueryManager.Current.QueryDescription(findOptions.QueryName);

            SetSearchViewableAndCreable(findOptions, desc);
            SetDefaultOrder(findOptions, desc);

            controller.ViewData.Model = context;

            controller.ViewData[ViewDataKeys.FindMode]         = mode;
            controller.ViewData[ViewDataKeys.FindOptions]      = findOptions;
            controller.ViewData[ViewDataKeys.QueryDescription] = desc;

            if (!controller.ViewData.ContainsKey(ViewDataKeys.Title))
            {
                controller.ViewData[ViewDataKeys.Title] = QueryUtils.GetNiceName(findOptions.QueryName);
            }

            return(new PartialViewResult
            {
                ViewName = SearchPopupControlView,
                ViewData = controller.ViewData,
                TempData = controller.TempData
            });
        }
Esempio n. 46
0
        /// <summary>
        /// Recherche de client dynamique
        /// </summary>
        /// <param name="mode"></param>
        private void FindClient(FindMode mode)
        {
            Cursor.Current = Cursors.WaitCursor;
            lvClient.Items.Clear();

            if (_AppConfig.ShowGestionClient_CoursFinish)
            {
                switch (mode)
                {
                case FindMode.All:
                    var ClientAll = from client in _ClientList.Cast <Customer>()
                                    select client;

                    foreach (Customer client in ClientAll)
                    {
                        AddClient(client);
                    }
                    break;

                case FindMode.ContratNumber:
                    var ClientContractNumber = from client in _ClientList.Cast <Customer>()
                                               where client.ContratNumber.ToLower().Contains(txtNumeroContrat.Text.ToLower())
                                               select client;

                    foreach (Customer client in ClientContractNumber)
                    {
                        AddClient(client);
                    }
                    break;

                case FindMode.FullName:
                    var ClientFullName = from client in _ClientList.Cast <Customer>()
                                         where client.GetFullName(false).ToLower().Contains(txtFullName.Text.ToLower())
                                         select client;

                    foreach (Customer client in ClientFullName)
                    {
                        AddClient(client);
                    }
                    break;

                case FindMode.GroupeNumber:
                    var ClientGroupNumber = from client in _ClientList.Cast <Customer>()
                                            where client.NumeroGroupe.ToString().Contains(txtGroupNumber.Text)
                                            select client;

                    foreach (Customer client in ClientGroupNumber)
                    {
                        AddClient(client);
                    }
                    break;
                }
            }
            else
            {
                switch (mode)
                {
                case FindMode.All:
                    var ClientAll = from client in _ClientList.Cast <Customer>()
                                    where client.TypeClient == ProfileType.Actif
                                    select client;

                    foreach (Customer client in ClientAll)
                    {
                        AddClient(client);
                    }
                    break;

                case FindMode.ContratNumber:
                    var ClientContractNumber = from client in _ClientList.Cast <Customer>()
                                               where client.ContratNumber.ToLower().Contains(txtNumeroContrat.Text.ToLower()) && client.TypeClient == ProfileType.Actif
                                               select client;

                    foreach (Customer client in ClientContractNumber)
                    {
                        AddClient(client);
                    }
                    break;

                case FindMode.FullName:
                    var ClientFullName = from client in _ClientList.Cast <Customer>()
                                         where client.GetFullName(false).ToLower().Contains(txtFullName.Text.ToLower()) && client.TypeClient == ProfileType.Actif
                                         select client;

                    foreach (Customer client in ClientFullName)
                    {
                        AddClient(client);
                    }
                    break;

                case FindMode.GroupeNumber:
                    var ClientGroupNumber = from client in _ClientList.Cast <Customer>()
                                            where client.NumeroGroupe.ToString().Contains(txtGroupNumber.Text) && client.TypeClient == ProfileType.Actif
                                            select client;

                    foreach (Customer client in ClientGroupNumber)
                    {
                        AddClient(client);
                    }
                    break;
                }
            }

            Cursor.Current = Cursors.Default;

            lblResult.Text = "Client(s) trouvés : " + lvClient.Items.Count.ToString();
        }
Esempio n. 47
0
        public FindAndReplacePad(FindMode mode)
        {
            this.Owner = _mainForm;
            _mainForm.MdiChildActivate += new EventHandler(MainFormMdiChildActivate);
            // this.Activated += new EventHandler(FindFormActivated);
            this.Load   += new EventHandler(FindFormLoad);
            this.TopMost = true;
            FindOptions.Singler.Positions.Clear();

            findAndReplaceMode   = mode;
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            this.TopMost         = false;
            this.Text            = "查找和替换";
            //groupBox
            groupBox.Location = mode == FindMode.Replace ? new Point(13, 161) : new Point(13, 111);
            groupBox.Size     = new Size(220, 139);
            groupBox.Enabled  = true;
            groupBox.Visible  = true;
            groupBox.Text     = "查找选项";
            //matchCaseCheckBox
            matchCaseCheckBox.Enabled  = true;
            matchCaseCheckBox.Visible  = true;
            matchCaseCheckBox.Checked  = FindOptions.Singler.MatchCase;
            matchCaseCheckBox.Text     = "大小写匹配";
            matchCaseCheckBox.Location = new Point(18, 20);
            matchCaseCheckBox.AutoSize = true;
            matchCaseCheckBox.UseVisualStyleBackColor = true;
            matchCaseCheckBox.CheckedChanged         += new EventHandler(MatchCaseCheckBoxCheckedChanged);
            groupBox.Controls.Add(matchCaseCheckBox);
            //matchWholeWordCheckBox
            matchWholeWordCheckBox.Enabled  = true;
            matchWholeWordCheckBox.Visible  = true;
            matchWholeWordCheckBox.Checked  = FindOptions.Singler.MatchWholeWord;
            matchWholeWordCheckBox.Text     = "全字匹配";
            matchWholeWordCheckBox.Location = new Point(18, 40);
            matchWholeWordCheckBox.AutoSize = true;
            matchWholeWordCheckBox.UseVisualStyleBackColor = true;
            matchWholeWordCheckBox.CheckedChanged         += new EventHandler(MatchWholeWordCheckBoxCheckedChanged);
            groupBox.Controls.Add(matchWholeWordCheckBox);
            //upWardCheckBox
            upWardCheckBox.Enabled  = true;
            upWardCheckBox.Visible  = true;
            upWardCheckBox.Checked  = FindOptions.Singler.UpWard;
            upWardCheckBox.Text     = "向上查找";
            upWardCheckBox.Location = new Point(18, 60);
            upWardCheckBox.AutoSize = true;
            upWardCheckBox.UseVisualStyleBackColor = true;
            upWardCheckBox.CheckStateChanged      += new EventHandler(UpWardCheckBoxCheckStateChanged);
            groupBox.Controls.Add(upWardCheckBox);
            //findStrategyTypeCheckBox
            findStrategyTypeCheckBox.Enabled  = true;
            findStrategyTypeCheckBox.Visible  = true;
            findStrategyTypeCheckBox.AutoSize = true;
            findStrategyTypeCheckBox.Text     = "使用";
            findStrategyTypeCheckBox.Location = new Point(18, 80);
            findStrategyTypeCheckBox.UseVisualStyleBackColor = true;
            //if (FindOptions.Singler.FindStrategyType == FindStrategyType.Normal)
            //    findStrategyTypeCheckBox.Checked = false;
            //else
            //    findStrategyTypeCheckBox.Checked = true;
            findStrategyTypeCheckBox.CheckedChanged += new EventHandler(FindStrategyTypeCheckBoxCheckedChanged);
            groupBox.Controls.Add(findStrategyTypeCheckBox);
            //findStrategyTypeComboBox
            findStrategyTypeComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            findStrategyTypeComboBox.Items.AddRange(new object[] { "正则表达式", "通配符" });
            findStrategyTypeComboBox.Enabled           = findStrategyTypeCheckBox.Checked;
            findStrategyTypeComboBox.Visible           = true;
            findStrategyTypeComboBox.FormattingEnabled = true;
            findStrategyTypeComboBox.Location          = new Point(28, 100);
            findStrategyTypeComboBox.Size                  = new Size(175, 20);
            findStrategyTypeComboBox.SelectedIndex         = 0;
            findStrategyTypeComboBox.SelectedIndexChanged += new EventHandler(FindStrategyTypeComboBoxSelectedIndexChanged);
            groupBox.Controls.Add(findStrategyTypeComboBox);
            //

            //toolStrip
            toolStrip.Location  = new Point(0, 0);
            toolStrip.Dock      = DockStyle.Top;
            toolStrip.Stretch   = true;
            toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
            toolStrip.Visible   = true;
            //findButton
            findButton.Text    = "快速查找(&F)";
            findButton.Checked = findAndReplaceMode == FindMode.Find;
            findButton.Click  += new EventHandler(FindButtonClick);
            toolStrip.Items.Add(findButton);
            //toolStripSeparator
            toolStrip.Items.Add(toolStripSeparator);
            //replaceButton
            replaceButton.Text    = "快速替换(&H)";
            replaceButton.Checked = findAndReplaceMode == FindMode.Replace;
            replaceButton.Click  += new EventHandler(ReplaceButtonClick);
            toolStrip.Items.Add(replaceButton);
            //

            //findPatternLabel
            findPattrenLabel.Text      = "查找内容:";
            findPattrenLabel.TextAlign = ContentAlignment.MiddleCenter;
            findPattrenLabel.Location  = new Point(10, 25);
            findPattrenLabel.Size      = new Size(77, 14);
            findPattrenLabel.Visible   = true;

            //findPatternTextBox
            findPatternTextBox.Enabled      = true;
            findPatternTextBox.Visible      = true;
            findPatternTextBox.Location     = new Point(15, 41);
            findPatternTextBox.Size         = new Size(215, 21);
            findPatternTextBox.Text         = FindOptions.Singler.FindContent;
            findPatternTextBox.TextChanged += new EventHandler(FindPatternTextBoxTextChanged);

            //replacePatternLabel
            replacePatternLabel.Location  = new Point(10, 65);
            replacePatternLabel.Text      = "替换为:";
            replacePatternLabel.TextAlign = ContentAlignment.MiddleCenter;
            replacePatternLabel.Size      = new Size(63, 14);

            //replacePatternTextBox
            replacePatternTextBox.Text         = FindOptions.Singler.ReplaceContent;
            replacePatternTextBox.Location     = new Point(15, 82);
            replacePatternTextBox.Size         = new Size(215, 20);
            replacePatternTextBox.Enabled      = mode == FindMode.Replace;
            replacePatternTextBox.Visible      = mode == FindMode.Replace;
            replacePatternTextBox.TextChanged += new EventHandler(ReplacePatternTextBoxTextChanged);

            //findNextButton
            findNextButton.Enabled         = false;
            findNextButton.Visible         = true;
            findNextButton.Text            = "查找下一个";
            findNextButton.Size            = new Size(85, 23);
            findNextButton.Location        = mode == FindMode.Find ? new Point(148, 236) : new Point(148, 286);
            findNextButton.Click          += new EventHandler(FindNextButtonClick);
            findNextButton.EnabledChanged += new EventHandler(FindNextButtonEnabledChanged);

            //replaceNextButton
            replaceNextButton.Size     = new Size(56, 23);
            replaceNextButton.Location = new Point(177, 306);
            replaceNextButton.Text     = "替换";
            replaceNextButton.Visible  = mode == FindMode.Replace;
            replaceNextButton.Click   += new EventHandler(ReplaceNextButtonClick);

            //replaceAllButton
            replaceAllButton.Size    = new Size(85, 23);
            replaceAllButton.Text    = "全部替换";
            replaceAllButton.Visible = mode == FindMode.Replace;
            replaceAllButton.Click  += new EventHandler(ReplaceAllButtonClick);

            //findAreaLabel
            findAreaLabel.Size      = new Size(77, 14);
            findAreaLabel.Text      = "查找范围:";
            findAreaLabel.TextAlign = ContentAlignment.MiddleCenter;

            //findAreaComboBox
            findAreaComboBox.Location              = mode == FindMode.Replace ? new Point(15, 128) : new Point(15, 82);
            findAreaComboBox.Size                  = new Size(215, 20);
            findAreaComboBox.DropDownStyle         = ComboBoxStyle.DropDownList;
            findAreaComboBox.SelectedIndexChanged += new EventHandler(FindAreaComboBoxSelectedIndexChanged);
            //
            AddControls();
            SetFindMode();
        }