forked from Blackfrosch/VAGEDCSuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormFindCancel.cs
194 lines (177 loc) · 6.05 KB
/
FormFindCancel.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Be.Windows.Forms;
namespace VAGSuite
{
/// <summary>
/// Summary description for FormFindCancel.
/// </summary>
public class FormFindCancel : DevExpress.XtraEditors.XtraForm
{
HexBox _hexBox;
private DevExpress.XtraEditors.SimpleButton btnCancel;
private System.Windows.Forms.Label lblFinding;
private System.Windows.Forms.Timer timer;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lblPercent;
private System.Windows.Forms.Timer timerPercent;
private System.ComponentModel.IContainer components;
public FormFindCancel()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.btnCancel = new DevExpress.XtraEditors.SimpleButton();
this.lblFinding = new System.Windows.Forms.Label();
this.timer = new System.Windows.Forms.Timer(this.components);
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.lblPercent = new System.Windows.Forms.Label();
this.timerPercent = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
//this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnCancel.Location = new System.Drawing.Point(208, 40);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(72, 23);
this.btnCancel.TabIndex = 0;
this.btnCancel.Text = "Cancel";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// lblFinding
//
this.lblFinding.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.lblFinding.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblFinding.ForeColor = System.Drawing.Color.Blue;
this.lblFinding.Location = new System.Drawing.Point(128, 40);
this.lblFinding.Name = "lblFinding";
this.lblFinding.Size = new System.Drawing.Size(80, 23);
this.lblFinding.TabIndex = 1;
//
// timer
//
this.timer.Interval = 50;
this.timer.Tick += new System.EventHandler(this.timer_Tick);
//
// groupBox1
//
this.groupBox1.Location = new System.Drawing.Point(80, 16);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(200, 8);
this.groupBox1.TabIndex = 11;
this.groupBox1.TabStop = false;
//
// label1
//
this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.label1.ForeColor = System.Drawing.Color.Blue;
this.label1.Location = new System.Drawing.Point(16, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 16);
this.label1.TabIndex = 10;
this.label1.Text = "Finding...";
//
// lblPercent
//
this.lblPercent.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.lblPercent.Location = new System.Drawing.Point(80, 40);
this.lblPercent.Name = "lblPercent";
this.lblPercent.Size = new System.Drawing.Size(48, 23);
this.lblPercent.TabIndex = 12;
this.lblPercent.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// timerPercent
//
this.timerPercent.Tick += new System.EventHandler(this.timerPercent_Tick);
//
// FormFindCancel
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.BackColor = System.Drawing.SystemColors.Control;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(292, 68);
this.ControlBox = false;
this.Controls.Add(this.lblPercent);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.lblFinding);
this.Controls.Add(this.btnCancel);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FormFindCancel";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Finding...";
this.Activated += new System.EventHandler(this.FormFindCancel_Activated);
this.Deactivate += new System.EventHandler(this.FormFindCancel_Deactivate);
this.ResumeLayout(false);
}
#endregion
public void SetHexBox(HexBox hexBox)
{
_hexBox = hexBox;
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void timer_Tick(object sender, System.EventArgs e)
{
if(lblFinding.Text.Length == 13)
lblFinding.Text = "";
lblFinding.Text += ".";
}
private void FormFindCancel_Activated(object sender, System.EventArgs e)
{
timer.Enabled = true;
timerPercent.Enabled = true;
}
private void FormFindCancel_Deactivate(object sender, System.EventArgs e)
{
timer.Enabled = false;
}
private void timerPercent_Tick(object sender, System.EventArgs e)
{
long pos = _hexBox.CurrentFindingPosition;
long length = _hexBox.ByteProvider.Length;
double percent = (double)pos / (double)length * (double)100;
System.Globalization.NumberFormatInfo nfi =
new System.Globalization.CultureInfo("en-US").NumberFormat;
string text = percent.ToString("0.00", nfi) + " %";
lblPercent.Text = text;
}
}
}