FrmSubstring.cs
2.7 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
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 CodeSplice
{
public partial class FrmSubstring : Asa.Theme.FlatForm
{
private bool change;
public string Code { set; get; }
public string Mode { set; get; }
public int Start { set; get; }
public int Length { set; get; }
public FrmSubstring()
{
InitializeComponent();
}
private void ShowStr()
{
label1.Text = Code.Substring(0, Start);
label2.Text = Code.Substring(Start, Length);
label3.Text = Code.Substring(Start + Length);
}
private void FrmSubstring_Load(object sender, EventArgs e)
{
change = true;
TxtType.Text = Mode;
flatNumberBox1.Value = Start;
flatNumberBox1.Minimum = 0;
flatNumberBox1.Maximum = Code.Length - 1;
flatNumberBox2.Maximum = 1;
flatNumberBox2.Value = Length;
flatNumberBox2.Maximum = Code.Length;
ShowStr();
change = false;
}
private void FlatNumberBox1_ValueChanged(object sender)
{
if (change) return;
change = true;
int n = Convert.ToInt32(flatNumberBox1.Value);
if (n + Length > Code.Length)
{
if (flatNumberBox2.Value > 1)
{
flatNumberBox2.Value--;
Length = Convert.ToInt32(flatNumberBox2.Value);
}
}
Start = n;
change = false;
ShowStr();
}
private void FlatNumberBox2_ValueChanged(object sender)
{
if (change) return;
int n = Convert.ToInt32(flatNumberBox2.Value);
if (n + Start > Code.Length)
flatNumberBox2.Value--;
Length = Convert.ToInt32(flatNumberBox2.Value);
ShowStr();
}
private void BtnAllShow_Click(object sender, EventArgs e)
{
change = true;
flatNumberBox1.Value = 0;
flatNumberBox2.Value = Code.Length;
Start = 0;
Length = Code.Length;
ShowStr();
change = false;
}
private void BtnNo_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.No;
Close();
}
private void BtnYes_Click(object sender, EventArgs e)
{
Mode = TxtType.Text;
DialogResult = DialogResult.Yes;
Close();
}
}
}