-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAmethystControl.Menu.cs
513 lines (432 loc) · 23.8 KB
/
AmethystControl.Menu.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
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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MetaphysicsIndustries.Crystalline;
using MetaphysicsIndustries.Collections;
using MetaphysicsIndustries.Acuity;
using System.Drawing.Imaging;
namespace MetaphysicsIndustries.Amethyst
{
public partial class AmethystControl : CrystallineControl
{
ToolStripMenuItem _addItem = new ToolStripMenuItem("Add");
public ToolStripMenuItem AddItem
{
get { return _addItem; }
}
//ToolStripMenuItem _addLiteralItem = new ToolStripMenuItem("Literal");
//ToolStripMenuItem _addStringLiteralItem = new ToolStripMenuItem("String");
//ToolStripMenuItem _addIntegerLiteralItem = new ToolStripMenuItem("Integer");
//ToolStripMenuItem _addDoubleLiteralItem = new ToolStripMenuItem("Double");
//ToolStripMenuItem _addWindowProcessorItem = new ToolStripMenuItem("Window Processor");
//ToolStripMenuItem _addAlphaTrimItem = new ToolStripMenuItem("Alpha Trim");
//ToolStripMenuItem _addZetaTrimItem = new ToolStripMenuItem("Zeta Trim");
//ToolStripMenuItem _addWindowCalculationItem = new ToolStripMenuItem("Window Calculation");
//ToolStripMenuItem _addAveragerItem = new ToolStripMenuItem("Mean");
//ToolStripMenuItem _addVarianceCalculatorItem = new ToolStripMenuItem("Variance");
//ToolStripMenuItem _addHistogramFilterItem = new ToolStripMenuItem("Histogram");
//ToolStripMenuItem _addCalcIntervalItem = new ToolStripMenuItem("Interval");
//ToolStripMenuItem _addFilterItem = new ToolStripMenuItem("Filter");
//ToolStripMenuItem _addImpulseFilterItem = new ToolStripMenuItem("Impulse Noise");
//ToolStripMenuItem _addFilterApplyItem = new ToolStripMenuItem("Filter Apply");
//ToolStripMenuItem _addMeanFilterItem = new ToolStripMenuItem("Mean Filter");
//ToolStripMenuItem _addSobelFilterItem = new ToolStripMenuItem("Sobel Filter");
//ToolStripMenuItem _addDualBellFilterItem = new ToolStripMenuItem("Dual Bell Filter");
//ToolStripMenuItem _addAlphaTrimDualBellFilterItem = new ToolStripMenuItem("Alpha Trimmed Dual Bell Filter");
//ToolStripMenuItem _addIntervalFitFilterItem = new ToolStripMenuItem("Interval Fit");
//ToolStripMenuItem _addIntervalFit2FilterItem = new ToolStripMenuItem("Interval Fit 2");
//ToolStripMenuItem _addNegOneOneFitFilterItem = new ToolStripMenuItem("[-1,1] -> [0,1]");
//ToolStripMenuItem _addRgbToHslItem = new ToolStripMenuItem("RGB -> HSL");
//ToolStripMenuItem _addSlicerItem = new ToolStripMenuItem("Matrix.GetSlice");
//ToolStripMenuItem _addFilterGeneratorItem = new ToolStripMenuItem("Filter Generator");
//ToolStripMenuItem _addImpulseNoiseFilterGeneratorItem = new ToolStripMenuItem("Impulse Noise");
//ToolStripMenuItem _addGaussianNoiseFilterGeneratorItem = new ToolStripMenuItem("Gaussian Noise");
//ToolStripMenuItem _addMedianFilterGeneratorItem = new ToolStripMenuItem("Median");
//ToolStripMenuItem _addExpandEdgeFilterGeneratorItem = new ToolStripMenuItem("Expand Edge");
//ToolStripMenuItem _addDebugItem = new ToolStripMenuItem("Debug");
//ToolStripMenuItem _addAllInItem = new ToolStripMenuItem("All In");
//ToolStripMenuItem _addAllOutItem = new ToolStripMenuItem("All Out");
//ToolStripMenuItem _addTextItem = new ToolStripMenuItem("Text");
//ToolStripMenuItem _addAluItem = new ToolStripMenuItem("ALU");
//ToolStripMenuItem _addMuxItem = new ToolStripMenuItem("MUX");
//ToolStripMenuItem _addMultItem = new ToolStripMenuItem("Mult");
//ToolStripMenuItem _addDisplayItem = new ToolStripMenuItem("Display");
//ToolStripMenuItem _addImageDisplay = new ToolStripMenuItem("Image");
//ToolStripMenuItem _addStringDisplayItem = new ToolStripMenuItem("String");
//ToolStripMenuItem _addDoubleDisplayItem = new ToolStripMenuItem("Double");
//ToolStripMenuItem _addIntegerDisplayItem = new ToolStripMenuItem("Integer");
//ToolStripMenuItem _addMeasureItem = new ToolStripMenuItem("Measure");
//ToolStripMenuItem _addMssimItem = new ToolStripMenuItem("Mssim");
//ToolStripMenuItem _addMseItem = new ToolStripMenuItem("Mse");
//ToolStripMenuItem _addOpenFilenameItem = new ToolStripMenuItem("Open Filename");
//ToolStripMenuItem _addSaveFilenameItem = new ToolStripMenuItem("Save Filename");
//ToolStripMenuItem _addLoadImageItem = new ToolStripMenuItem("Load Image");
//ToolStripMenuItem _addSaveImageItem = new ToolStripMenuItem("Save Image");
//ToolStripMenuItem _addLoadColorImageItem = new ToolStripMenuItem("Load Color Image");
//ToolStripMenuItem _addMatrixConvolutionItem = new ToolStripMenuItem("Matrix Convolution");
//ToolStripMenuItem _addMmseItem = new ToolStripMenuItem("MMSE");
//ToolStripMenuItem _addToStringItem = new ToolStripMenuItem("ToString()");
//ToolStripMenuItem _
ToolStripMenuItem _connectItem = new ToolStripMenuItem("Connect");
ToolStripMenuItem _disconnectItem = new ToolStripMenuItem("Disconnect");
ToolStripMenuItem _executeItem = new ToolStripMenuItem("Execute");
ToolStripMenuItem _executeAsyncItem = new ToolStripMenuItem("Execute Async");
ToolStripMenuItem _deleteItem = new ToolStripMenuItem("Delete");
ToolStripSeparator _separator = new ToolStripSeparator();
protected override void SetupContextMenuItems()
{
ContextMenuStrip.Items.Add(_addItem);
AddSolusItems(AddItem);
AddZirconiaItems(AddItem);
AddGizaItems(AddItem);
AddSectionSeparator();
AddLiteralItems(AddItem);
AddDisplayItems(AddItem);
AddFileItems(AddItem);
AddMathItems(AddItem);
AddDebugItems(AddItem);
AddMenuItemForElement<ToStringElement>("ToString()", AddItem);
AddMenuItemForElement<TypeofElement>("typeof()", AddItem);
AddMenuItemForElement<FeedbackElement>("Feedback Loop", AddItem);
AddMenuItemForElement<NestedElement>("Nested Node", AddItem);
AddMenuItemForElement<ScriptElement>("Script Node", AddItem);
//AddMenuItemForElement<InputTerminalElement>("External Input", AddItem);
//AddMenuItemForElement<OutputTerminalElement>("External Output", AddItem);
//AddMenuItemForElement<NodeElementConverterNode.NodeElementConverterElement>("Node-Element Converter", AddItem);
//AddMenuItem(AddItem, new ToolStripMenuItem("Node Source"), new EventHandler(NodeSourceItem_Click));
AddMenuItem(ContextMenuStrip, _connectItem, new EventHandler(ConnectItem_Click));
AddMenuItem(ContextMenuStrip, _disconnectItem, new EventHandler(DisconnectItem_Click));
ContextMenuStrip.Items.Add(new ToolStripSeparator());
AddMenuItem(ContextMenuStrip, _executeItem, new EventHandler(ExecuteItem_Click));
AddMenuItem(ContextMenuStrip, _executeAsyncItem, new EventHandler(ExecuteAsyncItem_Click));
ContextMenuStrip.Items.Add(new ToolStripSeparator());
AddMenuItem(ContextMenuStrip, _deleteItem, new EventHandler(DeleteItem_Click2));
ContextMenuStrip.Items.Add(new ToolStripSeparator());
AddMenuItem(ContextMenuStrip, new ToolStripMenuItem("Save as image..."), new EventHandler(SaveAsImageItem_Click));
}
private void AddFileItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem fileMenu = CreateMenu("File", parentMenu);
AddMenuItemForElement<GetOpenFilenameElement>("Open Filename", fileMenu);
AddMenuItemForElement<GetSaveFilenameElement>("Save Filename", fileMenu);
AddMenuItemForElement<LoadTextFileElement>("Load Text File", fileMenu);
AddMenuItemForElement<SaveTextFileElement>("Save Text File", fileMenu);
}
private void AddMathItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem mathMenu = /**/CreateMenu("Math", /*/(/**/parentMenu);
AddMenuItemForElement<MultElement>("*", mathMenu);
AddMenuItemForElement<AddElement>("+", mathMenu);
AddMenuItemForElement<CosineElement>("cos", mathMenu);
AddMenuItemForElement<SineElement>("sin", mathMenu);
AddMenuItemForElement<DegreesToRadiansElement>("deg. to rad.", mathMenu);
AddMenuItemForElement<RadiansToDegreesElement>("rad. to deg.", mathMenu);
AddMenuItemForElement<SqrtElement>("sqrt", mathMenu);
}
public void NodeSourceItem_Click(object sender, EventArgs e)
{
AddElementAtLocation(new NodeElementConverterNode.NodeElementConverterElement(new NodeSourceElement.NodeSourceNode()), LastRightClickInDocument);
}
public static void AddMenuItem(ContextMenuStrip menu, ToolStripMenuItem item, EventHandler clickHandler)
{
item.Click += clickHandler;
menu.Items.Add(item);
}
public ToolStripMenuItem CreateMenu(string text)
{
ToolStripMenuItem menu = new ToolStripMenuItem(text);
ContextMenuStrip.Items.Add(menu);
return menu;
}
public static ToolStripMenuItem CreateMenu(string text, ToolStripMenuItem parentMenu)
{
ToolStripMenuItem newMenu = new ToolStripMenuItem(text);
parentMenu.DropDownItems.Add(newMenu);
return newMenu;
}
public ToolStripMenuItem CreateSectionMenu(string text)
{
ToolStripMenuItem newMenu = new ToolStripMenuItem(text);
AddSectionSeparator();
AddItem.DropDownItems.Insert(
AddItem.DropDownItems.IndexOf(_separator),
newMenu);
return newMenu;
}
private void AddSectionSeparator()
{
if (!_addItem.DropDownItems.Contains(_separator))
{
AddItem.DropDownItems.Insert(0, _separator);
}
}
private void AddDebugItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Debug", parentMenu);
AddMenuItemForElement<AllInElement>("All In", newMenu);
AddMenuItemForElement<AllOutElement>("All Out", newMenu);
AddMenuItemForElement<TextElement>("Text", newMenu);
AddMenuItemForElement<AluElement>("ALU", newMenu);
AddMenuItemForElement<MuxElement>("MUX", newMenu);
AddMenuItemForElement<MultAluElement>("Mult", newMenu);
AddMenuItemForElement<OneOutElement>("One Out", newMenu);
}
private void AddDisplayItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Display", parentMenu);
AddMenuItemForElement<StringValueDisplayElement>("String", newMenu);
AddMenuItemForElement<IntegerValueDisplayElement>("Integer", newMenu);
AddMenuItemForElement<FloatValueDisplayElement>("Float", newMenu);
AddMenuItemForElement<DoubleValueDisplayElement>("Double", newMenu);
}
private void AddLiteralItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Literal", parentMenu);
AddMenuItemForElement<StringLiteralElement>("String", newMenu);
AddMenuItemForElement<IntegerLiteralElement>("Integer", newMenu);
AddMenuItemForElement<FloatLiteralElement>("Float", newMenu);
AddMenuItemForElement<DoubleLiteralElement>("Double", newMenu);
}
private void AddSolusItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem solusMenu = CreateSectionMenu("Solus");
AddMenuItemForElement<ImageDisplayElement>("Image Display", solusMenu);
AddMenuItemForElement<ColorImageDisplayElement>("Color Image Display", solusMenu);
solusMenu.DropDownItems.Add(new ToolStripSeparator());
AddFilterItems(solusMenu);
AddNoiseItems(solusMenu);
AddDenoisingItems(solusMenu);
AddEdgeDetectorsItems(solusMenu);
AddLevelsItems(solusMenu);
AddMatrixOpsItems(solusMenu);
AddPyramidProcessorItems(solusMenu);
AddWindowProcessorItems(solusMenu);
AddWindowCalculationItems(solusMenu);
AddMeasureItems(solusMenu);
solusMenu.DropDownItems.Add(new ToolStripSeparator());
AddMenuItemForElement<LoadImageElement>("Load Image", solusMenu);
AddMenuItemForElement<LoadColorImageElement>("Load Color Image", solusMenu);
AddMenuItemForElement<SaveImageElement>("Save Image", solusMenu);
solusMenu.DropDownItems.Add(new ToolStripSeparator());
AddMenuItemForElement<MatrixConvolutionElement>("Matrix Convolution", solusMenu);
}
private void AddDenoisingItems(ToolStripMenuItem solusMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Denoising", solusMenu);
AddMenuItemForElement<MmseElement2>("MMSE (gaussian)", newMenu);
}
private void AddNoiseItems(ToolStripMenuItem solusMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Noise", solusMenu);
AddMenuItemForElement<GaussianNoiseMatrixFilterElement>("Gaussian Noise", newMenu);
AddMenuItemForElement<ImpulseNoiseFilterElement>("Impulse Noise", newMenu);
}
private void AddFilterItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Filter", parentMenu);
AddMenuItemForElement<MedianMatrixFilterElement>("Median", newMenu);
AddMenuItemForElement<GaussianBlurFilterElement>("Gaussian Blur", newMenu);
AddMenuItemForElement<ArithmeticMeanFilterElement>("Arithmetic Mean", newMenu);
AddMenuItemForElement<AlphaTrimmedMeanElement>("Alpha-trimmed Mean", newMenu);
AddMenuItemForElement<ZetaTrimmedMeanElement>("Zeta-trimmed Mean", newMenu);
AddMenuItemForElement<MosaicMatrixFilterElement>("Mosaic", newMenu);
AddMenuItemForElement<DftElement>("DFT", newMenu);
AddMenuItemForElement<InverseDftElement>("IDFT", newMenu);
}
private void AddEdgeDetectorsItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Edge Detect", parentMenu);
AddMenuItemForElement<SobelMatrixFilterElement>("Sobel Filter", newMenu);
AddMenuItemForElement<DualBellMatrixFilterElement>("Dual Bell Filter", newMenu);
AddMenuItemForElement<AlphaTrimmedDualBellMatrixFilterElement>("Alpha Trimmed Dual Bell Filter", newMenu);
}
private void AddLevelsItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Levels", parentMenu);
AddMenuItemForElement<IntervalFitMatrixFilterElement>("Interval Fit", newMenu);
AddMenuItemForElement<IntervalFit2FilterElement>("Interval Fit 2", newMenu);
AddMenuItemForElement<NegOneOneToZeroOneFitMatrixFilterElement>("[-1,1] -> [0,1]", newMenu);
AddMenuItemForElement<ThresholdMatrixFilterElement>("Threshold", newMenu);
AddMenuItemForElement<AndMatrixFilterElement>("Matrix And", newMenu);
AddMenuItemForElement<InverterMatrixFilterElement>("Matrix Inverter", newMenu);
//AddMenuItemForElement<FlattenerFilterElement>("Flattener", newMenu);
newMenu.DropDownItems.Add(new ToolStripSeparator());
AddMenuItemForElement<RgbToHslConverterElement>("RGB -> HSL", newMenu);
AddMenuItemForElement<HslToRgbConverterElement>("HSL -> RGB", newMenu);
}
private void AddMatrixOpsItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Matrix Ops", parentMenu);
AddMenuItemForElement<MatrixSlicerElement>("Matrix.GetSlice", newMenu);
AddMenuItemForElement<ExpandEdgeMatrixFilterElement>("Expand Edge", newMenu);
}
private void AddPyramidProcessorItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Pyramid Processors", parentMenu);
AddMenuItemForElement<ArithmeticMeanPyramidProcessor>("Arithmetic Mean Pyramid Processor", newMenu);
AddMenuItemForElement<GeometricMeanPyramidProcessor>("Geometric Mean Pyramid Processor", newMenu);
AddMenuItemForElement<MaxPyramidProcessor>("Max Pyramid Processor", newMenu);
}
private void AddMeasureItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Measure", parentMenu);
AddMenuItemForElement<MssimMeasureElement>("Mssim", newMenu);
AddMenuItemForElement<MseMeasureElement>("Mse", newMenu);
}
private void AddWindowCalculationItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Window Calculation", parentMenu);
AddMenuItemForElement<AveragerElement>("Mean", newMenu);
AddMenuItemForElement<VarianceCalculatorElement>("Variance", newMenu);
AddMenuItemForElement<HistogramElement>("Histogram", newMenu);
AddMenuItemForElement<CalculateIntervalMeasureElement>("Interval", newMenu);
}
private void AddWindowProcessorItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem newMenu = CreateMenu("Window Processor", parentMenu);
AddMenuItemForElement<AlphaTrimWindowProcessorElement>("Alpha Trim", newMenu);
AddMenuItemForElement<ZetaTrimWindowProcessorElement>("Zeta Trim", newMenu);
}
private void AddZirconiaItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem zirconiaMenu = CreateSectionMenu("Zirconia");
AddMenuItemForElement<CSharpCompilerElement>("C# Compiler", zirconiaMenu);
AddMenuItemForElement<SaveAssemblyElement>("Save Assembly", zirconiaMenu);
AddMenuItemForElement<MethodInvokeElement>("Method Invoke", zirconiaMenu);
AddMenuItemForElement<ConstructorInvokeElement>("Constructor", zirconiaMenu);
AddMenuItemForElement<CSharpRendererElement>("C# Renderer", zirconiaMenu);
}
private void AddGizaItems(ToolStripMenuItem parentMenu)
{
ToolStripMenuItem gizaMenu = CreateSectionMenu("Giza");
AddMenuItemForElement<SupergrammarParserElement>("Supergrammar Parser", gizaMenu);
AddMenuItemForElement<DefinitionBuilderElement>("Definition Builder", gizaMenu);
AddMenuItemForElement<ParserBuilderElement>("Parser Builder", gizaMenu);
AddMenuItemForElement<GenericParserElement>("Generic Parser", gizaMenu);
}
//void AddConverterItem_Click(object sender, EventArgs e)
//{
// ConverterTypeSelectionForm form = new ConverterTypeSelectionForm();
// if (form.ShowDialog(this) == DialogResult.OK)
// {
// ConverterElementBase elem = ConverterElementBase.CreateConverter(form.InputType, form.OutputType);
// elem.Location = LastRightClickInDocument;
// AddElement(elem);
// }
//}
void ExecuteItem_Click(object sender, EventArgs e)
{
try
{
AmethystElement[] elements = Entities.Extract<AmethystElement>();
//_executionEngine.Execute(elements, _valueCache);
//
//StringBuilder sb = new StringBuilder();
//foreach (AmethystElement elem in elements)
//{
// sb.AppendLine(elem.Text);
//}
//MessageBox.Show(this, "Success: \r\n" + sb.ToString());
string[] results = _asyncExecutionEngine.Iterate(elements, _valueCache);
StringBuilder sb = new StringBuilder();
foreach (string r in results)
{
sb.AppendLine(r);
}
MessageBox.Show(this, "Success: \r\n" + sb.ToString());
}
catch (Exception ex)
{
ReportException(ex);
}
Invalidate();
}
void executionEngine_OnElementExecuted(object sender, AmethystElementEventArgs e)
{
InvalidateRectFromEntity(e.Element);
Refresh();
}
void ExecuteAsyncItem_Click(object sender, EventArgs e)
{
ExecuteAsync();
}
protected override void UpdateContextMenuItems()
{
_deleteItem.Enabled = (Selection.Count > 0);
_connectItem.Enabled = (_connectionSourceTerminal != null);
_disconnectItem.Enabled = (_disconnectionCandidate != null && _disconnectionCandidate.Path != null);
}
//protected void AddMenuItemForFilter<T>(string text, ToolStripMenuItem menu)
// where T : MatrixFilter
//{
//}
protected void AddMenuItemForAmethystElement<T>(ToolStripItem item, ToolStripMenuItem menu)
where T : AmethystElement, new()
{
base.AddMenuItemForElement<T>(item, menu);
}
public ToolStripItem AddMenuItemForElement<T>(string text, ToolStripMenuItem menu)
where T : AmethystElement, new()
{
ToolStripMenuItem item = new ToolStripMenuItem(text);
AddMenuItemForElement<T>(item, menu);
return item;
}
protected void AddAmethystElement_Click<T>(object sender, EventArgs e)
where T : AmethystElement, new()
{
base.AddElement_Click<T>(sender, e);
}
//private void AddMenuItemForElement<T>(ToolStripItem item, ToolStripMenuItem menu)
// where T : AmethystElement, new()
//{
// item.Click += new EventHandler(AddElement_Click<T>);
// menu.DropDownItems.Add(item);
//}
//private void AddElement_Click<T>(object sender, EventArgs e)
// where T : AmethystElement, new()
//{
// T t = new T();
// t.Location = LastRightClickInDocument;
// AddElement(t);
//}
void ConnectItem_Click(object sender, EventArgs e)
{
_connecting = true;
}
void DeleteItem_Click2(object sender, EventArgs e)
{
try
{
AmethystElement[] elems = Selection.Extract<AmethystElement>();
if (elems.Length > 0)
{
foreach (Entity elem in elems)
{
DisconnectAndRemoveEntity(elem);
}
}
}
catch (Exception ex)
{
ReportException(ex);
}
}
void DisconnectItem_Click(object sender, EventArgs e)
{
if (_disconnectionCandidate != null)
{
InputTerminal terminalToDisconnect = _disconnectionCandidate;
DisconnectInputTerminal(terminalToDisconnect);
}
}
void SaveAsImageItem_Click(object sender, EventArgs e)
{
SaveContentsAsImagePrompt();
}
}
}