forked from tianruoyouxin/tianruoocr_last
-
Notifications
You must be signed in to change notification settings - Fork 409
/
ReplaceForm.cs
112 lines (100 loc) · 2.61 KB
/
ReplaceForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace TrOCR
{
public partial class ReplaceForm : Form
{
public ReplaceForm(AdvRichTextBox mm)
{
InitializeComponent();
Fmok = mm;
var componentResourceManager = new ComponentResourceManager(typeof(FmMain));
Icon = (Icon)componentResourceManager.GetObject("minico.Icon");
StartPosition = FormStartPosition.Manual;
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void findbutton_Click(object sender, EventArgs e)
{
try
{
if (Fmok.richTextBox1.Text != "")
{
p = Fmok.richTextBox1.Text.IndexOf(findtextbox.Text, p);
if (p != -1)
{
Fmok.richTextBox1.Select(p, findtextbox.Text.Length);
p++;
}
else
{
MessageBox.Show("已查找到文档尾!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
p = 0;
}
}
}
catch
{
p = 0;
MessageBox.Show("已查找到文档尾!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
private void replacebutton_Click(object sender, EventArgs e)
{
if (Fmok.richTextBox1.Text != "")
{
p = 0;
p = Fmok.richTextBox1.Text.IndexOf(findtextbox.Text, p);
if (p != -1)
{
Fmok.richTextBox1.Select(p, findtextbox.Text.Length);
Fmok.richTextBox1.SelectedText = replacetextBox.Text;
p++;
return;
}
MessageBox.Show("已替换完!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
p = 0;
}
}
private void replaceallbutton_Click(object sender, EventArgs e)
{
if (Fmok.richTextBox1.Text != "" && findtextbox.Text != "")
{
p = 0;
p = Fmok.richTextBox1.Text.IndexOf(findtextbox.Text, p);
while (p != -1)
{
Fmok.richTextBox1.Select(p, findtextbox.Text.Length);
Fmok.richTextBox1.SelectedText = replacetextBox.Text;
p = Fmok.richTextBox1.Text.IndexOf(findtextbox.Text, p);
flag = true;
}
if (flag)
{
MessageBox.Show("替换完毕!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
if (MessageBox.Show("替换内容不存在,请重新输入!", "提醒") == DialogResult.OK)
{
findtextbox.Text = "";
}
}
}
private void canclebutton_Click(object sender, EventArgs e)
{
Hide();
Fmok.Focus();
}
private void ReplaceForm_FormClosing(object sender, FormClosingEventArgs e)
{
Hide();
Fmok.Focus();
}
public AdvRichTextBox Fmok;
private int p;
private bool flag;
}
}