-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStartGUI.cs
108 lines (92 loc) · 3.48 KB
/
StartGUI.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
using Aml.Engine.CAEX;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace Aml.Editor.Plugin
{
/// <summary>
/// This is a window forms UI control, containing a tree view. The Tree view is updated, ever when an InternalElement is selected
/// in the editor which has an Instance Class relation to a SystemUnitClass. The Tree view is populated with the ExternalInterface
/// objects and InternalElement objects of the referenced SystemUnitClass.
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
public partial class StartGUI : UserControl
{
private MWController mWController;
private MWData.MWFileType filetype;
#region Public Constructors
public StartGUI(MWController mWController)
{
this.mWController = mWController;
InitializeComponent();
}
#endregion Public Constructors
private void createDeviceBtn_Click(object sender, EventArgs e)
{
mWController.ChangeGui(MWController.MWGUIType.CreateDevice);
}
private void createInterfaceBtn_Click(object sender, EventArgs e)
{
mWController.ChangeGui(MWController.MWGUIType.CreateInterface);
}
private void importIODDFileBtn_Click(object sender, EventArgs e)
{
filetype = MWData.MWFileType.IODD;
openFileDialog.Filter = "IODD Files (*.xml)|*.xml|All Files (*.*)|*.*";
openFileDialog.ShowDialog();
}
private void importGSDFileBtn_Click(object sender, EventArgs e)
{
filetype = MWData.MWFileType.GSD;
openFileDialog.Filter = "GSDML Files (*.xml)|*.xml|All Files (*.*)|*.*";
openFileDialog.ShowDialog();
}
private void openFileDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
foreach (String filename in openFileDialog.FileNames)
{
String error = mWController.importFile(filename, filetype);
if (error != null)
{
MessageBox.Show(error);
}
}
}
internal void updateDeviceDropdown(List<MWData.MWObject> devices)
{
devicesComboBox.Items.Clear();
if (devices.Count > 0)
{
foreach (MWData.MWObject device in devices)
{
string name = "";
if (device is MWDevice)
{
name = ((MWDevice) device).deviceName;
}
else
{
name = ((MWInterface)device).numberOfInterface.ToString();
}
devicesComboBox.Items.Add(name);
}
}
else
{
devicesComboBox.Items.Add("<No created Objects>");
}
}
private void devicesComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
mWController.showDevice(devicesComboBox.SelectedIndex);
}
private void openEditDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
mWController.showDevice(openEditDialog.FileName);
}
private void editFileBtn_Click(object sender, EventArgs e)
{
openEditDialog.ShowDialog();
}
}
}