FrmCodeText.cs
2.6 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CodeSplicing
{
public partial class FrmCodeText : Form
{
public FrmCodeText()
{
InitializeComponent();
CboField.Items.AddRange(Asa.Common.Config.Field.ToArray());
}
public int Start { get; private set; }
public int Len { get; private set; }
public string Texts { get; private set; }
public string Field { get; private set; }
public FrmCodeText(string s, string field, int start, int len) : this()
{
Texts = s;
CboField.Text = field;
Start = start;
Len = len;
NudStart.Value = start;
NudLen.Value = len;
}
private void ShowText()
{
if (Start > 0)
lblText1.Text = Texts.Substring(0, Start);
else
lblText1.Text = "";
lblText2.Text = Texts.Substring(Start, Len);
if (Start + Len < Texts.Length)
lblText3.Text = Texts.Substring(Start + Len, Texts.Length - Start - Len);
else
lblText3.Text = "";
}
private void NudStart_ValueChanged(object sender, EventArgs e)
{
int n = Convert.ToInt32(NudStart.Value);
if (n + Len > Texts.Length)
{
NudStart.Value--;
}
else
{
Start = n;
ShowText();
}
}
private void NudLen_ValueChanged(object sender, EventArgs e)
{
int n = Convert.ToInt32(NudLen.Value);
if (Start + n > Texts.Length)
{
NudLen.Value--;
}
else
{
Len = n;
ShowText();
}
}
private void BtnAll_Click(object sender, EventArgs e)
{
//start = 0;
//len = text.Length;
NudStart.Value = 0;
NudLen.Value = Texts.Length;
}
private void BtnOK_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
}
private void CboField_SelectedIndexChanged(object sender, EventArgs e)
{
Field = CboField.Text;
}
private void FrmCodeText_Load(object sender, EventArgs e)
{
Asa.Common.Language.SetLanguage(this);
}
}
}