Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
		public bool AddNewControllerOfTypeWithPrompts(Guid controllerTypeId)
		{
			IModuleDescriptor moduleDescriptor = ApplicationServices.GetModuleDescriptor(controllerTypeId);
			if (moduleDescriptor == null) {
				Logging.Error("couldn't get descriptor for controller of type ID: " + controllerTypeId);
				return false;
			}

			string defaultName = moduleDescriptor.TypeName;
			string name;
			using (TextDialog textDialog = new TextDialog("New Controller Name?", "Controller Name", defaultName, true)) {
				if (textDialog.ShowDialog() != DialogResult.OK)
					return false;

				name = textDialog.Response;
				if (name.Length <= 0)
					name = defaultName;
			}

			int outputCount;
			using (NumberDialog nd = new NumberDialog("Controller Output Count", "Outputs on this controller?", 0)) {
				if (nd.ShowDialog() != DialogResult.OK)
					return false;

				outputCount = nd.Value;
			}

			ControllerFactory controllerFactory = new ControllerFactory();
			OutputController oc = (OutputController)controllerFactory.CreateDevice(controllerTypeId, name);
			oc.OutputCount = outputCount;
			VixenSystem.OutputControllers.Add(oc);

			PopulateControllerTree(oc);
			OnControllersChanged();

			return true;
		}