-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselectName.cs
182 lines (154 loc) · 5.4 KB
/
selectName.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TimingMadShoken
{
public partial class selectName : Form
{
public class Info
{
public String serie;
public String type;
public int num;
public String chanson;
public String fullname;
public String language;
public String name;
public String artiste;
public Info(String fullName)
{
serie = "";
type = "";
num = 0;
chanson = "";
fullname = "";
language = "";
name = "";
artiste = "";
String[] splitted = fullName.Split(new Char[] {'.'});
String cleanName = splitted[0];
String[] parts = cleanName.Split(new Char[] { '-' });
if (parts.Length >= 3)
{
int pos = 0;
if (parts.Length == 4)
{
this.language = parts[pos++].Trim();
}
else
{
this.language = "";
}
this.serie = parts[pos++].Trim();
String typenum = parts[pos++].Trim();
if (typenum.Length >= 3)
{
this.type = typenum.Substring(0, 2);
short numvalue;
Int16.TryParse(typenum.Substring(2, typenum.Length - 2), out numvalue);
this.num = numvalue;
}
else
{
this.type = typenum;
this.num = 0;
}
this.chanson = parts[pos++].Trim();
}
generateName();
}
public Info(String serieArg, String typeArg, int numArg, String chansonArg, String languageArg, String artisteArg)
{
this.serie = serieArg;
this.type = typeArg;
this.num = numArg;
this.chanson = chansonArg;
this.language = languageArg;
this.artiste = artisteArg;
generateName();
}
private void generateName()
{
this.name = (serie.Length > 0 ? serie + " - " : "")
+ (type.Length > 0 ? type : "")
+ (num > 0 ? num.ToString() : "")
+ ((type.Length > 0 || num > 0) ? " - " : "")
+ (chanson.Length > 0 ? chanson : "");
this.fullname = (language.Length > 0 ? language + " - " : "") + name;
}
}
public enum Emode { NOUVEAU_TIME, CHANGE_TIME_NAME };
private Emode mode = Emode.NOUVEAU_TIME;
public selectName()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int num = 0;
int.TryParse(this.numerocomboBox2.Text, out num);
Info info = new Info(this.serietextBox1.Text, this.typecomboBox1.Text
, num
, chansontextBox1.Text, this.languagecomboBox2.Text, this.artistetextBox.Text);
switch (this.mode)
{
case Emode.CHANGE_TIME_NAME:
((TimingMadShoken.mainForm)Owner).setTimeName(info);
break;
case Emode.NOUVEAU_TIME:
((TimingMadShoken.mainForm)Owner).nouveauTime(info);
break;
}
}
private void button2_Click(object sender, EventArgs e)
{
Info info = new Info("", "", 0, "", "", "");
switch (this.mode)
{
case Emode.CHANGE_TIME_NAME:
((TimingMadShoken.mainForm)Owner).setTimeName(info);
break;
case Emode.NOUVEAU_TIME:
((TimingMadShoken.mainForm)Owner).nouveauTime(info);
break;
}
}
private void cancelbutton3_Click(object sender, EventArgs e)
{
((TimingMadShoken.mainForm)Owner).cancelNouveauTime();
}
internal void setNouveauTimeMode()
{
this.mode = Emode.NOUVEAU_TIME;
}
internal void setChangeTimeName()
{
this.mode = Emode.CHANGE_TIME_NAME;
}
private void selectName_FormClosed(object sender, FormClosedEventArgs e)
{
Owner.Enabled = true;
}
private void selectName_Load(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void chansontextBox1_TextChanged(object sender, EventArgs e)
{
}
internal void setInfoTime(Info info)
{
this.serietextBox1.Text = info.serie;
this.chansontextBox1.Text = info.chanson;
this.languagecomboBox2.Text = info.language;
this.numerocomboBox2.Text = info.num.ToString();
this.typecomboBox1.Text = info.type;
}
}
}