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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
// **********************************************************************
//
// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using EnvDTE;
using Microsoft.VisualStudio.VCProjectEngine;
namespace Ice.VisualStudio
{
public partial class IceCppConfigurationDialog : Form, IceConfigurationDialog
{
public IceCppConfigurationDialog(Project project)
{
InitializeComponent();
_project = project;
_winRT = Util.isWinRTProject(_project);
outputDirView.init(this, _project);
includePathView.init(this, _project);
extraCompilerOptions.init(this, project);
//
// Set the toolTip messages.
//
toolTip.SetToolTip(chkStreaming, "Generate marshaling support for stream API (--stream).");
toolTip.SetToolTip(chkChecksum, "Generate checksums for Slice definitions (--checksum).");
toolTip.SetToolTip(chkIcePrefix, "Permit Ice prefixes (--ice).");
if(_project != null)
{
this.Text = "Ice Configuration - Project: " + _project.Name;
bool enabled = Util.isSliceBuilderEnabled(project);
VCConfiguration conf = Util.getActiveVCConfiguration(project);
_staticLib = conf.ConfigurationType == ConfigurationTypes.typeStaticLibrary;
setEnabled(enabled);
chkEnableBuilder.Checked = enabled;
load();
_initialized = true;
}
chkEnableBuilder.Focus();
}
#region IceConfigurationDialog interface
public bool editingIncludeDir()
{
return includePathView.editingIncludeDir();
}
public void endEditIncludeDir(bool saveChanges)
{
includePathView.endEditIncludeDir(saveChanges);
}
public void needSave()
{
if(_initialized)
{
btnApply.Enabled = hasUnsavedChanges();
}
}
public void unsetCancelButton()
{
CancelButton = null;
}
public void setCancelButton()
{
CancelButton = btnCancel;
}
#endregion IceConfigurationDialog interface
private void load()
{
if(_project == null)
{
return;
}
Cursor = Cursors.WaitCursor;
outputDirView.load();
extraCompilerOptions.load();
chkIcePrefix.Checked = Util.getProjectPropertyAsBool(_project, Util.PropertyIcePrefix);
chkStreaming.Checked = Util.getProjectPropertyAsBool(_project, Util.PropertyIceStreaming);
chkChecksum.Checked = Util.getProjectPropertyAsBool(_project, Util.PropertyIceChecksum);
comboBoxVerboseLevel.SelectedIndex = Util.getVerboseLevel(_project);
includePathView.load();
txtDllExportSymbol.Text = Util.getProjectProperty(_project, Util.PropertyIceDllExport);
btnApply.Enabled = false;
Cursor = Cursors.Default;
}
private void chkEnableBuilder_CheckedChanged(object sender, EventArgs e)
{
try
{
Cursor = Cursors.WaitCursor;
if(editingIncludeDir())
{
endEditIncludeDir(true);
}
if(_initialized)
{
_initialized = false;
setEnabled(chkEnableBuilder.Checked);
chkEnableBuilder.Enabled = true;
_initialized = true;
needSave();
}
Cursor = Cursors.Default;
}
catch(Exception ex)
{
Cursor = Cursors.Default;
Util.unexpectedExceptionWarning(ex);
throw;
}
}
private void setEnabled(bool enabled)
{
outputDirView.setEnabled(enabled);
chkIcePrefix.Enabled = enabled;
chkStreaming.Enabled = enabled;
chkChecksum.Enabled = enabled;
comboBoxVerboseLevel.Enabled = enabled;
includePathView.setEnabled(enabled);
extraCompilerOptions.setEnabled(enabled);
txtDllExportSymbol.Enabled = enabled;
}
private void formClosing(object sender, FormClosingEventArgs e)
{
try
{
if(editingIncludeDir())
{
endEditIncludeDir(false);
}
if(hasUnsavedChanges())
{
if(!Util.warnUnsavedChanges(this))
{
e.Cancel = true;
return;
}
}
Cursor = Cursors.WaitCursor;
if(_changed && Util.isSliceBuilderEnabled(_project))
{
Util.rebuildProject(_project);
}
Cursor = Cursors.Default;
}
catch(Exception ex)
{
Cursor = Cursors.Default;
Util.unexpectedExceptionWarning(ex);
throw;
}
}
private void component_Changed(object sender, EventArgs e)
{
try
{
Cursor = Cursors.WaitCursor;
if(editingIncludeDir())
{
endEditIncludeDir(true);
}
needSave();
Cursor = Cursors.Default;
}
catch(Exception ex)
{
Cursor = Cursors.Default;
Util.unexpectedExceptionWarning(ex);
throw;
}
}
private void txtDllExportSymbol_Focus(object sender, EventArgs e)
{
try
{
Cursor = Cursors.WaitCursor;
if(includePathView.editingIncludeDir())
{
includePathView.endEditIncludeDir(true);
}
Cursor = Cursors.Default;
}
catch(Exception ex)
{
Cursor = Cursors.Default;
Util.unexpectedExceptionWarning(ex);
throw;
}
}
private void txtDllExportSymbol_Changed(object sender, EventArgs e)
{
try
{
Cursor = Cursors.WaitCursor;
needSave();
Cursor = Cursors.Default;
}
catch(Exception ex)
{
Cursor = Cursors.Default;
Util.unexpectedExceptionWarning(ex);
throw;
}
}
private void btnOk_Click(object sender, EventArgs e)
{
try
{
Cursor = Cursors.WaitCursor;
if(apply())
{
Close();
}
Cursor = Cursors.Default;
}
catch(Exception ex)
{
Cursor = Cursors.Default;
Util.unexpectedExceptionWarning(ex);
throw;
}
}
private void btnApply_Click(object sender, EventArgs e)
{
try
{
Cursor = Cursors.WaitCursor;
apply();
Cursor = Cursors.Default;
}
catch(Exception ex)
{
Cursor = Cursors.Default;
Util.unexpectedExceptionWarning(ex);
throw;
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
try
{
Close();
}
catch(Exception ex)
{
Util.unexpectedExceptionWarning(ex);
throw;
}
}
//
// Apply unsaved changes, returns true if new settings are all applied correctly,
// otherwise returns false.
//
private bool apply()
{
if(!hasUnsavedChanges())
{
return true; // Nothing to do.
}
try
{
if(editingIncludeDir())
{
endEditIncludeDir(true);
}
bool changed = false;
//
// This must be the first setting to be updated, as other settings cannot be
// updated if the add-in is disabled.
//
if(chkEnableBuilder.Checked && !Util.isSliceBuilderEnabled(_project))
{
Util.addBuilderToProject(_project, new ComponentList());
}
if(!outputDirView.apply(ref changed))
{
return false;
}
if(chkIcePrefix.Checked != Util.getProjectPropertyAsBool(_project, Util.PropertyIcePrefix))
{
Util.setProjectProperty(_project, Util.PropertyIcePrefix, chkIcePrefix.Checked.ToString());
_changed = true;
}
if(chkStreaming.Checked != Util.getProjectPropertyAsBool(_project, Util.PropertyIceStreaming))
{
Util.setProjectProperty(_project, Util.PropertyIceStreaming, chkStreaming.Checked.ToString());
_changed = true;
}
if(chkChecksum.Checked != Util.getProjectPropertyAsBool(_project, Util.PropertyIceChecksum))
{
Util.setProjectProperty(_project, Util.PropertyIceChecksum, chkChecksum.Checked.ToString());
_changed = true;
}
if(comboBoxVerboseLevel.SelectedIndex != Util.getVerboseLevel(_project))
{
Util.setProjectProperty(_project, Util.PropertyVerboseLevel,
comboBoxVerboseLevel.SelectedIndex.ToString(CultureInfo.InvariantCulture));
_changed = true;
}
changed = false;
if(!extraCompilerOptions.apply(ref changed))
{
return false;
}
if(changed)
{
_changed = true;
}
if(includePathView.apply())
{
_changed = true;
}
if(!txtDllExportSymbol.Text.Equals(Util.getProjectProperty(_project, Util.PropertyIceDllExport),
StringComparison.CurrentCulture))
{
Util.setProjectProperty(_project, Util.PropertyIceDllExport, txtDllExportSymbol.Text);
_changed = true;
}
//
// This must be the last setting to be updated, as we want to update
// all other settings and that isn't possible if the builder is disabled.
//
if(!chkEnableBuilder.Checked && Util.isSliceBuilderEnabled(_project))
{
Util.removeBuilderFromProject(_project, new ComponentList());
_initialized = false;
load();
_initialized = true;
_changed = true;
}
return true;
}
finally
{
needSave(); // Call needSave to update apply button status
}
}
private bool hasUnsavedChanges()
{
if(chkEnableBuilder.Checked != Util.isSliceBuilderEnabled(_project))
{
return true;
}
//
// If the builder is disabled, we are not interested in the other settings
// to compute changes.
//
if(!Util.isSliceBuilderEnabled(_project))
{
return false;
}
if(outputDirView.hasUnsavedChanges())
{
return true;
}
if(chkIcePrefix.Checked != Util.getProjectPropertyAsBool(_project, Util.PropertyIcePrefix))
{
return true;
}
if(chkStreaming.Checked != Util.getProjectPropertyAsBool(_project, Util.PropertyIceStreaming))
{
return true;
}
if(chkChecksum.Checked != Util.getProjectPropertyAsBool(_project, Util.PropertyIceChecksum))
{
return true;
}
if(comboBoxVerboseLevel.SelectedIndex != Util.getVerboseLevel(_project))
{
return true;
}
if(extraCompilerOptions.hasUnsavedChanges())
{
return true;
}
if(!txtDllExportSymbol.Text.Trim().Equals(Util.getProjectProperty(_project, Util.PropertyIceDllExport),
StringComparison.CurrentCulture))
{
return true;
}
if(includePathView.hasUnsavedChanges())
{
return true;
}
return false;
}
private bool _initialized;
private Project _project;
private bool _staticLib = false;
private bool _changed = false;
private bool _winRT = false;
}
}
|