示例#1
0
        private void BtnSearch_Click(object sender, EventArgs e)
        {
            if (CmbSearch.Text.Length == 0)
            {
                BtnSearchClear_Click(sender, e);
                return;
            }

            // 検索履歴から重複排除
            _ = CmbSearch.Items.Add(CmbSearch.Text);
            List <string> l1 = new List <string>();

            foreach (string _s1 in CmbSearch.Items)
            {
                l1.Add(_s1);
            }
            l1.Sort();
            CmbSearch.Items.Clear();

            string sOld = "";

            foreach (string _s1 in l1)
            {
                if (sOld != _s1)
                {
                    _    = CmbSearch.Items.Add(_s1);
                    sOld = _s1;
                }
            }
            l1.Clear();

            int iLineBgnPos = 0;

            // 画面を初期化
            RtbResult.Text = GblResult_AryText[GblResult_AryIndex].ToString();

            // 行毎に検索!!
            // 検索位置を着色
            foreach (string _s1 in RtbResult.Text.Split('\n'))
            {
                foreach (Match _m1 in Regex.Matches(_s1, CmbSearch.Text, RegexOptions.IgnoreCase))
                {
                    RtbResult.Select(iLineBgnPos + _m1.Index, _m1.Value.Length);
                    RtbResult.SelectionColor     = Color.White;
                    RtbResult.SelectionBackColor = Color.Red;
                }
                iLineBgnPos += _s1.Length + 1;
            }

            // 最初の検索位置へスクロール
            RtbResult.SelectionStart = Regex.Match(RtbResult.Text, CmbSearch.Text, RegexOptions.IgnoreCase).Index;
            RtbResult.ScrollToCaret();

            _ = CmbSearch.Focus();
        }
示例#2
0
        private void BtnPasteFilename_DragDrop(object sender, DragEventArgs e)
        {
            List <string> l1 = new List <string>();

            foreach (string _s1 in (string[])e.Data.GetData(DataFormats.FileDrop))
            {
                l1.Add(_s1);
            }
            l1.Sort();

            Clipboard.SetText(RtnShortPath(l1));
            RtbResult.Paste();

            RtbResult.Select(0, 0);
            RtbResult.ScrollToCaret();

            Scr.Visible = false;
        }
示例#3
0
        private void RtbResult_KeyUp(object sender, KeyEventArgs e)
        {
            // RichTextBox で以下の動作は不安定
            //   [Ctrl]+[↑]
            //   [Ctrl]+[↓]

            // [Ctrl]+[PgUp]
            if (e.KeyData == (Keys.Control | Keys.PageUp))
            {
                RtbResult.Select(0, 0);
                RtbResult.ScrollToCaret();
                return;
            }

            // [Ctrl]+[PgDn]
            if (e.KeyData == (Keys.Control | Keys.PageDown))
            {
                RtbResult.Select(RtbResult.TextLength, 0);
                RtbResult.ScrollToCaret();
                return;
            }

            switch (e.KeyCode)
            {
            case (Keys.Escape):
                CmbSearch.Focus();
                break;

            case (Keys.F3):
                BtnSearchNext_Click(sender, null);
                break;

            default:
                GblResult_CursorPos = RtbResult.SelectionStart;
                break;
            }
        }
示例#4
0
        private void BtnPasteTextfile_DragDrop(object sender, DragEventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            string        s1 = "";

            foreach (string _s1 in (string[])e.Data.GetData(DataFormats.FileDrop))
            {
                (string _s2, string _s3) = RtnTextFileRead(_s1, false, "");
                if (_s2.Length > 0)
                {
                    _ = sb.Append(_s3);
                }
                else
                {
                    if (File.Exists(_s1))
                    {
                        s1 += "・" + Path.GetFileName(_s1) + NL;
                    }
                }
            }

            Clipboard.SetText(Regex.Replace(sb.ToString(), RgxNL, NL));
            RtbResult.Paste();

            RtbResult.Select(0, 0);
            RtbResult.ScrollToCaret();

            Scr.Visible = false;

            if (s1.Length > 0)
            {
                _ = MessageBox.Show(
                    "[Err] テキストファイルではありません。" + NL + NL + s1,
                    ProgramID
                    );
            }
        }
示例#5
0
 private void BtnReload_Click(object sender, EventArgs e)
 {
     RtbResult.Text = RtnClipboard();
     RtbResult.Select(0, 0);
     RtbResult.ScrollToCaret();
 }