コード例 #1
0
ファイル: Hints.cs プロジェクト: WendyH/HMSEditor
        /// <summary>
        /// Clears all displayed hints
        /// </summary>
        public void Clear()
        {
            items.Clear();
            if (tb.Controls.Count != 0)
            {
                var toDelete = new List <Control>();
                foreach (Control item in tb.Controls)
                {
                    if (item is UnfocusablePanel)
                    {
                        toDelete.Add(item);
                    }
                }

                foreach (var item in toDelete)
                {
                    tb.Controls.Remove(item);
                }

                for (int i = 0; i < tb.LineInfos.Count; i++)
                {
                    var li = tb.LineInfos[i];
                    li.bottomPadding = 0;
                    tb.LineInfos[i]  = li;
                }
                tb.NeedRecalc();
                tb.Invalidate();
                tb.Select();
                tb.ActiveControl = null;
            }
        }
コード例 #2
0
ファイル: FindForm.cs プロジェクト: walney/ynoteclassic
 private bool TryFindNext(string pattern, RegexOptions opt, FindNextDirection direction, Range range, out Place foundMatchPlace)
 {
     if (direction == FindNextDirection.Next)
     {
         foreach (var r in range.GetRangesByLines(pattern, opt))
         {
             foundMatchPlace = r.Start;
             tb.Selection    = r;
             tb.DoSelectionVisible();
             tb.Invalidate();
             return(true); // always return on the first match
         }
     }
     else // find previous
     {
         foreach (var r in range.GetRangesByLinesReversed(pattern, opt))
         {
             foundMatchPlace = r.Start;
             tb.Selection    = r;
             tb.DoSelectionVisible();
             tb.Invalidate();
             return(true); // always return on the first match
         }
     }
     foundMatchPlace = Place.Empty;
     return(false);
 }
コード例 #3
0
        public virtual void FindNext(string pattern)
        {
            try
            {
                RegexOptions opt = cbMatchCase.Checked ? RegexOptions.None : RegexOptions.IgnoreCase;
                if (!cbRegex.Checked)
                {
                    pattern = Regex.Escape(pattern);
                }
                if (cbWholeWord.Checked)
                {
                    pattern = "\\b" + pattern + "\\b";
                }
                //
                Range range = tb.Selection.Clone();
                range.Normalize();
                //
                if (firstSearch)
                {
                    startPlace  = range.Start;
                    firstSearch = false;
                }
                //
                range.Start = range.End;
                if (range.Start >= startPlace)
                {
                    range.End = new Place(tb.GetLineLength(tb.LinesCount - 1), tb.LinesCount - 1);
                }
                else
                {
                    range.End = startPlace;
                }
                //
                foreach (var r in range.GetRangesByLines(pattern, opt))
                {
                    tb.Selection = r;
                    tb.DoSelectionVisible();
                    tb.Invalidate();
                    tsStatusUpdateLabel.Text = "Find: Found search term '" + tbFind.Text + "'.";
                    return;
                }

                //
                if (range.Start >= startPlace && startPlace > Place.Empty)
                {
                    tb.Selection.Start = new Place(0, 0);
                    FindNext(pattern);
                    return;
                }

                tsStatusUpdateLabel.Text = "Find: Unable to find search term '" + tbFind.Text + "'.";
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex);
            }
        }
コード例 #4
0
        public bool Find(string pattern)
        {
            RegexOptions opt = cbMatchCase.Checked ? RegexOptions.None : RegexOptions.IgnoreCase;

            if (!cbRegex.Checked)
            {
                pattern = Regex.Escape(pattern);
            }
            if (cbWholeWord.Checked)
            {
                pattern = "\\b" + pattern + "\\b";
            }
            //
            Range range = tb.Selection.Clone();

            range.Normalize();
            //
            if (firstSearch)
            {
                startPlace  = range.Start;
                firstSearch = false;
            }

            //
            range.Start = range.End;
            if (range.Start >= startPlace)
            {
                range.End = new Place(tb.GetLineLength(tb.LinesCount - 1), tb.LinesCount - 1);
            }
            else
            {
                range.End = startPlace;
            }
            //
            foreach (var r in range.GetRangesByLines(pattern, opt))
            {
                tb.Selection.Start = r.Start;
                tb.Selection.End   = r.End;
                tb.DoSelectionVisible();
                tb.Invalidate();
                return(true);
            }

            if (range.Start >= startPlace && startPlace > Place.Empty)
            {
                tb.Selection.Start = new Place(0, 0);
                return(Find(pattern));
            }

            return(false);
        }
コード例 #5
0
ファイル: Bookmarks.cs プロジェクト: mainframe-projects/Canal
        public override void Add(Bookmark bookmark)
        {
            foreach (var bm in items)
            {
                if (bm.LineIndex == bookmark.LineIndex)
                {
                    return;
                }
            }

            items.Add(bookmark);
            counter++;
            tb.Invalidate();
        }
コード例 #6
0
ファイル: FindForm.cs プロジェクト: ywscr/ynoteclassic
 /// <summary>
 ///     <summary>
 ///         Find Next
 ///     </summary>
 ///     <param name="pattern"></param>
 ///     id FindNext(string pattern)
 public void FindNext(string pattern)
 {
     try
     {
         var opt = cbMatchCase.Checked ? RegexOptions.None : RegexOptions.IgnoreCase;
         if (!cbRegex.Checked)
         {
             pattern = Regex.Escape(pattern);
         }
         if (cbWholeWord.Checked)
         {
             pattern = "\\b" + pattern + "\\b";
         }
         //
         var range = tb.Selection.Clone();
         range.Normalize();
         //
         if (_firstSearch)
         {
             _startPlace  = range.Start;
             _firstSearch = false;
         }
         //
         range.Start = range.End;
         range.End   = range.Start >= _startPlace
             ? new Place(tb.GetLineLength(tb.LinesCount - 1), tb.LinesCount - 1)
             : _startPlace;
         //
         foreach (var r in range.GetRanges(pattern, opt))
         {
             tb.Selection = r;
             tb.DoSelectionVisible();
             tb.Invalidate();
             return;
         }
         //
         if (range.Start >= _startPlace && _startPlace > Place.Empty)
         {
             tb.Selection.Start = new Place(0, 0);
             FindNext(pattern);
             return;
         }
         MessageBox.Show("Not found");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #7
0
ファイル: FindForm.cs プロジェクト: secoba/SSCOM-1
        public virtual void FindNext(string pattern)
        {
            List <Range> ranges = null;
            Place        end;

            try
            {
                RegexOptions opt = CaseChecked ? RegexOptions.None : RegexOptions.IgnoreCase;/*match case*/

                if (WholeWordChecked)
                {
                    pattern = "\\b" + pattern + "\\b"; /*match all*/
                }
                //
                Range range = tb.Selection.Clone();
                range.Normalize();
                //
                range.Start = range.End;
                range.End   = new Place(tb.GetLineLength(tb.LinesCount - 1), tb.LinesCount - 1);
                //
                ranges = new List <Range>(range.GetRangesByLines(pattern, opt));
                foreach (Range r in ranges)
                {
                    tb.Selection = r;
                    tb.DoSelectionVisible();
                    tb.Invalidate();
                    return;
                }
                //
                end         = range.Start;
                range.Start = new Place(0, 0);
                range.End   = end;
                //
                ranges = new List <Range>(range.GetRangesByLines(pattern, opt));
                foreach (Range r in ranges)
                {
                    tb.Selection = r;
                    tb.DoSelectionVisible();
                    tb.Invalidate();
                    return;
                }
                //MessageBox.Show("Not found");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #8
0
 /// <summary>
 /// Clears all displayed hints
 /// </summary>
 public void Clear()
 {
     items.Clear();
     if (tb.Controls.Count != 0)
     {
         tb.Controls.Clear();
         for (int i = 0; i < tb.LineInfos.Count; i++)
         {
             var li = tb.LineInfos[i];
             li.bottomPadding = 0;
             tb.LineInfos[i]  = li;
         }
         tb.NeedRecalc();
         tb.Invalidate();
         tb.Select();
         tb.ActiveControl = null;
     }
 }
コード例 #9
0
ファイル: Bookmarks.cs プロジェクト: WendyH/HMSEditor
        public void Set(int lineIndex, string name)
        {
            bool exist = false; string namel = name.ToLower();

            foreach (var b in this)
            {
                if (b.Name.ToLower() == namel)
                {
                    b.LineIndex = lineIndex; exist = true; break;
                }
            }
            if (!exist)
            {
                Add(new Bookmark(tb, name, lineIndex));
            }
            tb.NeedRecalc(true);             // By WendyH
            tb.Invalidate();
        }
コード例 #10
0
 private void FindNext()
 {
     try
     {
         string       pattern = tbFind.Text;
         RegexOptions opt     = cbMatchCase.Checked ? RegexOptions.None : RegexOptions.IgnoreCase;
         if (!cbRegex.Checked)
         {
             pattern = Regex.Replace(pattern, RegexSpecSymbolsPattern, "\\$0");
         }
         if (cbWholeWord.Checked)
         {
             pattern = "\\b" + pattern + "\\b";
         }
         //
         Range range = tb.Selection.Clone();
         range.Normalize();
         //
         if (firstSearch)
         {
             startPlace  = range.Start;
             firstSearch = false;
         }
         //
         range.Start = range.End;
         if (range.Start >= startPlace)
         {
             range.End = new Place(tb.GetLineLength(tb.LinesCount - 1), tb.LinesCount - 1);
         }
         else
         {
             range.End = startPlace;
         }
         //
         foreach (var r in range.GetRanges(pattern, opt))
         {
             tb.Selection = r;
             tb.DoSelectionVisible();
             tb.Invalidate();
             return;
         }
         //
         if (range.Start >= startPlace && startPlace > Place.Empty)
         {
             tb.Selection.Start = new Place(0, 0);
             FindNext();
             return;
         }
         MessageBox.Show("Not found");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #11
0
 public void FindNext(string pattern)
 {
     try
     {
         tbFind.BackColor = Color.White;
         RegexOptions opt = cbMatchCase.Checked ? RegexOptions.None : RegexOptions.IgnoreCase;
         if (!cbRegex.Checked)
         {
             pattern = Regex.Escape(pattern);
         }
         if (cbWholeWord.Checked)
         {
             pattern = "\\b" + pattern + "\\b";
         }
         //
         Range range = tb.Selection.Clone();
         range.Normalize();
         //
         if (firstSearch)
         {
             startPlace  = range.Start;
             firstSearch = false;
         }
         //
         range.Start = range.End;
         if (range.Start >= startPlace)
         {
             range.End = new Place(tb.GetLineLength(tb.LinesCount - 1), tb.LinesCount - 1);
         }
         else
         {
             range.End = startPlace;
         }
         //
         foreach (var r in range.GetRangesByLines(pattern, opt))
         {
             tb.Selection = r;
             tb.DoSelectionVisible();
             tb.Invalidate();
             return;
         }
         //
         if (range.Start >= startPlace && startPlace > Place.Empty)
         {
             tb.Selection.Start = new Place(0, 0);
             FindNext(pattern);
             return;
         }
         tbFind.BackColor = Color.LightCoral;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #12
0
 public virtual void FindNext(string pattern)
 {
     try
     {
         RegexOptions opt = cbMatchCase.Checked ? RegexOptions.None : RegexOptions.IgnoreCase;
         if (!cbRegex.Checked)
         {
             pattern = Regex.Escape(pattern);
         }
         if (cbWholeWord.Checked)
         {
             pattern = "\\b" + pattern + "\\b";
         }
         //
         Range range = tb.Selection.Clone();
         range.Normalize();
         //
         if (firstSearch)
         {
             startPlace  = range.Start;
             firstSearch = false;
         }
         //
         range.Start = range.End;
         if (range.Start >= startPlace)
         {
             range.End = new Place(tb.GetLineLength(tb.LinesCount - 1), tb.LinesCount - 1);
         }
         else
         {
             range.End = startPlace;
         }
         //
         foreach (var r in range.GetRangesByLines(pattern, opt))
         {
             tb.Selection = r;
             tb.DoSelectionVisible();
             tb.Invalidate();
             return;
         }
         //
         if (range.Start >= startPlace && startPlace > Place.Empty)
         {
             tb.Selection.Start = new Place(0, 0);
             FindNext(pattern);
             return;
         }
         MessageBox.Show("Совпадений не найдено", MBCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, MBCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #13
0
ファイル: Hints.cs プロジェクト: Guido1234/CodeLibrary
        /// <summary>
        /// Add and shows the hint
        /// </summary>
        /// <param name="hint"></param>
        public void Add(Hint hint)
        {
            items.Add(hint);

            if (hint.Inline /* || hint.Range.Start.iLine >= tb.LinesCount - 1*/)
            {
                var li = tb.LineInfos[hint.Range.Start.iLine];
                hint.TopPadding   = li.bottomPadding;
                li.bottomPadding += hint.HostPanel.Height;
                tb.LineInfos[hint.Range.Start.iLine] = li;
                tb.NeedRecalc(true);
            }

            LayoutHint(hint);

            tb.OnVisibleRangeChanged();

            hint.HostPanel.Parent = tb;

            tb.Select();
            tb.ActiveControl = null;
            tb.Invalidate();
        }
コード例 #14
0
        /// <summary>
        /// Select all chars of control
        /// </summary>
        public void SelectAll()
        {
            ColumnSelectionMode = false;

            Start = new Place(0, 0);
            if (tb.LinesCount == 0)
            {
                Start = new Place(0, 0);
            }
            else
            {
                end   = new Place(0, 0);
                start = new Place(tb[tb.LinesCount - 1].Count, tb.LinesCount - 1);
            }
            if (this == tb.Selection)
            {
                tb.Invalidate();
            }
        }
コード例 #15
0
ファイル: Range.cs プロジェクト: snarfblam/editroid
 /// <summary>
 /// Select all chars of control
 /// </summary>
 public void SelectAll()
 {
     Start = new Place(0, 0);
     if (tb.lines.Count == 0)
     {
         Start = new Place(0, 0);
     }
     else
     {
         end   = new Place(0, 0);
         start = new Place(tb.lines[tb.lines.Count - 1].Count, tb.lines.Count - 1);
     }
     if (this == tb.Selection)
     {
         tb.Invalidate();
     }
 }
コード例 #16
0
        public bool Find(string pattern)
        {
            try
            {
                RegexOptions opt = cbMatchCase.Checked ? RegexOptions.None : RegexOptions.IgnoreCase;
                if (!cbRegex.Checked)
                {
                    pattern = Regex.Escape(pattern);
                }
                if (cbWholeWord.Checked)
                {
                    pattern = "\\b" + pattern + "\\b";
                }
                //
                Range range = tb.Selection.Clone();
                range.Normalize();

                //get count
                Range rangetmp = range.Clone();
                rangetmp.Start = new Place(0, 0);
                rangetmp.End   = new Place(tb.GetLineLength(tb.LinesCount - 1), tb.LinesCount - 1);
                int total = rangetmp.GetRangesByLines(pattern, opt).Count();

                //
                if (firstSearch)
                {
                    startPlace  = range.Start;
                    firstSearch = false;
                }
                //
                range.Start = range.End;
                if (range.Start >= startPlace)
                {
                    range.End = new Place(tb.GetLineLength(tb.LinesCount - 1), tb.LinesCount - 1);
                }
                else
                {
                    range.End = startPlace;
                }
                //
                IEnumerable <Range> ranges = range.GetRangesByLines(pattern, opt);
                ShowFindInfo(total, total - ranges.Count());
                foreach (var r in ranges)
                {
                    tb.Selection = r;
                    tb.DoSelectionVisible();
                    tb.Invalidate();
                    return(true);
                }
                //
                if (range.Start >= startPlace && startPlace > Place.Empty)
                {
                    tb.Selection.Start = new Place(0, 0);
                    Find(pattern);
                    return(true);
                }
                tb.Selection.Start = new Place(0, 0);
                //this.Title = "Not found";
            }
            catch (Exception ex)
            {
                //this.Title = ex.Message;
            }

            return(true);
        }