forked from plutoscarab/Rails
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SerialNumber.cs
176 lines (166 loc) · 4.85 KB
/
SerialNumber.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
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Rails
{
/// <summary>
/// Summary description for SerialNumber.
/// </summary>
[System.Runtime.InteropServices.ComVisible(false)]
public class SerialNumber : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox serialNo;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private Type mapType;
public SerialNumber()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
public object Seed
{
get
{
try
{
uint u = uint.Parse(serialNo.Text);
return unchecked((int) u);
}
catch(FormatException)
{
return serialNo.Text;
}
catch(ArgumentException)
{
}
catch(ArithmeticException)
{
}
return -1;
}
}
public Type MapType
{
get
{
return mapType;
}
}
#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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SerialNumber));
this.label1 = new System.Windows.Forms.Label();
this.serialNo = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(16, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(200, 40);
this.label1.TabIndex = 0;
this.label1.Text = "Specify the serial number of the map you wish to use:";
//
// serialNo
//
this.serialNo.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.serialNo.Location = new System.Drawing.Point(16, 56);
this.serialNo.Name = "serialNo";
this.serialNo.Size = new System.Drawing.Size(184, 23);
this.serialNo.TabIndex = 1;
this.serialNo.Text = "";
this.serialNo.TextChanged += new System.EventHandler(this.serialNo_TextChanged);
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button1.Enabled = false;
this.button1.Location = new System.Drawing.Point(40, 96);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "OK";
//
// button2
//
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button2.Location = new System.Drawing.Point(128, 96);
this.button2.Name = "button2";
this.button2.TabIndex = 3;
this.button2.Text = "Cancel";
//
// SerialNumber
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 16);
this.ClientSize = new System.Drawing.Size(218, 136);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button2,
this.button1,
this.serialNo,
this.label1});
this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "SerialNumber";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Map Serial Number";
this.ResumeLayout(false);
}
#endregion
private void serialNo_TextChanged(object sender, System.EventArgs e)
{
button1.Enabled = false;
try
{
uint u = uint.Parse(serialNo.Text);
mapType = typeof(RandomMap);
button1.Enabled = true;
}
catch(FormatException)
{
mapType = typeof(RandomMap2);
button1.Enabled = true;
}
catch(ArgumentException)
{
}
catch(ArithmeticException)
{
}
}
}
}