private void buttonAddController_Click(object sender, EventArgs e)
{
List<KeyValuePair<string, object>> outputModules = new List<KeyValuePair<string, object>>();
foreach (KeyValuePair<Guid, string> kvp in ApplicationServices.GetAvailableModules<IControllerModuleInstance>()) {
outputModules.Add(new KeyValuePair<string, object>(kvp.Value, kvp.Key));
}
Common.Controls.ListSelectDialog addForm = new Common.Controls.ListSelectDialog("Add Controller", (outputModules));
if (addForm.ShowDialog() == DialogResult.OK) {
IModuleDescriptor moduleDescriptor = ApplicationServices.GetModuleDescriptor((Guid)addForm.SelectedItem);
string name = moduleDescriptor.TypeName;
ControllerFactory controllerFactory = new ControllerFactory();
OutputController oc = (OutputController)controllerFactory.CreateDevice((Guid)addForm.SelectedItem, name);
VixenSystem.OutputControllers.Add(oc);
// In the case of a controller that has a form, the form will not be shown
// until this event handler completes. To make sure it's in a visible state
// before evaluating if it's running or not, we're calling DoEvents.
// I hate DoEvents calls, so if you know of a better way...
Application.DoEvents();
// select the new controller, and then repopulate the list -- it will make sure the currently
// displayed controller is selected.
_PopulateFormWithController(oc);
_PopulateControllerList();
//We added a controller so set the _changesMade to true
_changesMade = true;
}
}