using System;
using System.Collections.Generic;
namespace Aml.Editor.Plugin
{
///
/// This class passes the inputs of the GUIs to where needed and it is in controll of what is displayed at the screen
///
public class MWController
{
// the (initialised) GUIs
private DeviceDescription deviceDescriptionForm;
// the interface class to the AML Editor
private ModellingWizard modellingWizard;
// the MWData instance of the the plugin which handles all the AMLX stuff
private MWData mWData;
// the list of the currently loaded amlx devices / interfaces
// these will be displayed on the start GUI
private List devices = new List();
///
/// Init the controller and reload all amlx devices
///
public MWController()
{
mWData = new MWData(this);
}
///
/// Create the new CreateDevice GUI or return the previously created GUI
///
/// the CreateDevice GUI for this session
///
/// create the new DeviceDescription GUI or return the previously created GUI
///
public DeviceDescription GetDeviceDescriptionForm()
{
if (deviceDescriptionForm == null)
{
deviceDescriptionForm = new DeviceDescription(this);
}
return deviceDescriptionForm;
}
///
///
///
///
///
///
public String CreateDeviceOnClick(MWDevice newDevice, bool isEdit, bool useCaex2_15)
{
string result = "";
if (newDevice.deviceName != null && newDevice.vendorName != null)
{
// create the device
result = mWData.CreateDevice(newDevice, isEdit, useCaex2_15);
}
// update the device list
if (isEdit)
{
}
else
{
devices.Add(newDevice);
}
return result;
}
///
/// Show the correct GUI for the selected device
///
/// The index of the selected item in the dropdown
///
/// Reload all .amlx files in ./modellingwizard/ and update the dropdown.
///
///
/// Switch the displayed
///
/// the GUI Type to display
public void ChangeGui(MWGUIType targetGUI)
{
// TODO modellingWizard is null
switch (targetGUI)
{
case MWGUIType.DeviceDescription:
modellingWizard.changeGUI(GetDeviceDescriptionForm());
break;
}
}
///
/// Enum to represent the GUI
///
public enum MWGUIType { CreateDevice, CreateInterface, Start, DeviceDescription }
///
/// Call the Converter with the given file
///
/// the full path to the file
/// whether the file is an IODD or an GSD file
///
public string importFile(string filename, MWData.MWFileType filetype)
{
// call the correct import function for the file type
string result = null;
switch (filetype)
{
case MWData.MWFileType.IODD:
result = mWData.ImportIODD2AML(filename);
break;
case MWData.MWFileType.GSD:
result = mWData.ImportGSD2AML(filename);
break;
default:
result = "Invalid Filetype";
break;
}
return result;
}
}
}