-
Notifications
You must be signed in to change notification settings - Fork 0
/
launcher.cs
271 lines (213 loc) · 8.25 KB
/
launcher.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Nini.Config;
using Velocity = NVelocity.App.Velocity;
using VelocityContext = NVelocity.VelocityContext;
using ParseErrorException = NVelocity.Exception.ParseErrorException;
using MethodInvocationException = NVelocity.Exception.MethodInvocationException;
using ComponentFactory.Krypton.Toolkit;
using System.Threading;
// sound
using System.Media;
// reg expr
using System.Text.RegularExpressions;
// para app.config
using System.Configuration;
namespace myWay
{
public partial class launcher : Form
{
protected List<string> errores = new List<string>();
protected string mode;
public launcher()
{
InitializeComponent();
}
private void launcher_Load(object sender, EventArgs e)
{
// vemos si existe un conf.xml o ultimo proyecto utilizado...
project pr = new project();
pr = project.loadProject(Path.Combine(util.conf_dir, "conf.xml"));
if (pr != null)
{
general.actualProject = pr;
this.Text = "myWay " + pr.name;
}
loadControls();
}
private void loadControls()
{
mode = sf.cadena(System.Configuration.ConfigurationManager.AppSettings["mode"]);
switch (mode)
{
case "project":
panel1.Controls.Clear();
myWay.userControls.projectMode uc = new myWay.userControls.projectMode();
uc.actualProject = general.actualProject;
panel1.Controls.Add(uc);
uc.refreshDataWithActualProject();
break;
case "template":
panel1.Controls.Clear();
myWay.userControls.templateMode ucx = new myWay.userControls.templateMode();
//ucx.realProject = general.actualProject;
panel1.Controls.Add(ucx);
ucx.refreshDataWithActualProject();
break;
default:
panel1.Controls.Clear();
myWay.userControls.projectMode uc3 = new myWay.userControls.projectMode();
uc3.actualProject = general.actualProject;
panel1.Controls.Add(uc3);
uc3.refreshDataWithActualProject();
mode = "project";
break;
}
}
private void kryptonButton1_Click(object sender, EventArgs e)
{
switch (mode)
{
case "template":
panel1.Controls.Clear();
myWay.userControls.projectMode uc = new myWay.userControls.projectMode();
uc.actualProject = general.actualProject;
panel1.Controls.Add(uc);
uc.refreshDataWithActualProject();
mode="project";
break;
case "project":
panel1.Controls.Clear();
myWay.userControls.templateMode ucx = new myWay.userControls.templateMode();
// ucx.realProject = general.actualProject;
panel1.Controls.Add(ucx);
ucx.refreshDataWithActualProject();
mode = "template";
break;
}
try
{
// save data...
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["mode"].Value = sf.cadena(mode);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}
catch (Exception ex2)
{
throw;
}
}
private void launcher_FormClosing(object sender, FormClosingEventArgs e)
{
//try
//{
// project pr = new project();
// pr = general.actualProject;
// pr.templateSelectedFullUri = general.templateSelectedFullUri;
// pr.templateSelected = general.templateSelected;
// pr.templateSelectedFullUri = general.templateSelectedFullUri;
// pr.targetDirectory = general.targetDirectory;
// pr.saveProject(Path.Combine(util.conf_dir, "conf.xml"));
// pr.saveProject(Path.Combine(util.projects_dir, general.actualProject.name) + ".xml");
//}
//catch (Exception)
//{
// //throw;
//}
try
{
// save data...
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["mode"].Value = sf.cadena(mode);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}
catch (Exception ex2)
{
throw;
}
}
private void butOpenProject2_Click(object sender, EventArgs e)
{
OpenFileDialog fil = new OpenFileDialog();
fil.DefaultExt = "xml";
fil.InitialDirectory = util.projects_dir;
if (fil.ShowDialog() == DialogResult.OK)
{
Console.WriteLine(fil.FileName);
general.actualProject = project.loadProject(fil.FileName);
// lo guardamos como conf.xml
if (general.actualProject != null)
{
this.Text = "myWay " + general.actualProject.name;
// groupBox1.Text = general.actualProject.name;
general.actualProject.saveProject(Path.Combine(util.projects_dir, "conf.xml"));
loadControls();
}
}
}
private void butNewProject2_Click(object sender, EventArgs e)
{
newProject np = new newProject();
np.ShowDialog();
if (np.DialogResult == DialogResult.Cancel)
{
}
else
{
if (np.DialogResult == DialogResult.Yes)
{
general.actualProject = np.pr;
this.Text = "myWay " + general.actualProject.name;
loadControls();
}
}
}
private void butEditModel_Click(object sender, EventArgs e)
{
model ed = new model();
ed.actualProject = general.actualProject;
ed.ShowDialog();
// actualizamos los datos...
general.actualProject = ed.actualProject;
loadControls();
}
private void butReload_Click(object sender, EventArgs e)
{
modifyProject np = new modifyProject();
np.pr = general.actualProject;
np.ShowDialog();
if (np.DialogResult == DialogResult.Cancel)
{
}
else
{
if (np.DialogResult == DialogResult.Yes)
{
// if we found tables...
if (np.pr.tables.Count >= 1)
{
general.actualProject = np.pr;
loadControls();
}
}
}
}
private void kryptonButton2_Click(object sender, EventArgs e)
{
help hp = new help();
hp.ShowDialog();
}
private void kryptonButton3_Click(object sender, EventArgs e)
{
}
}
}