private void listBox_SelectedIndexChanged(object sender, EventArgs e) { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); if (listBox.SelectedIndex == -1) { System.ComponentModel.ComponentResourceManager localResources = new System.ComponentModel.ComponentResourceManager(typeof(CustomEventsForm)); btnAddSave.Text = localResources.GetString("btnAddSave.Text"); txtCmd.Text = ""; txtArgs.Text = ""; boxWait.Checked = false; return; } btnAddSave.Text = PackageEditor.Messages.Messages.btnApply; CustomEvent customEvent = curCustomEvents[listBox.SelectedIndex]; txtCmd.Text = customEvent.cmd; txtArgs.Text = customEvent.args; boxWait.Checked = customEvent.execWait; }
private void PropertyToCustomEvents(String inPropertyName, List <CustomEvent> outCustomEvents) { String inPropertyValue = ""; virtPackage.GetProperty(inPropertyName, ref inPropertyValue); String[] values = inPropertyValue.Split(';'); foreach (String value in values) { if (value == "") { continue; } CustomEvent newCustomEvent; newCustomEvent = new CustomEvent("", "", false); String[] eventElements = value.Split('>'); // cmd if (eventElements.Length > 0) { newCustomEvent.cmd = eventElements[0]; } // args if (eventElements.Length > 1) { newCustomEvent.args = eventElements[1]; } // flags if (eventElements.Length > 2) { String[] flags = eventElements[2].Split(','); foreach (String flag in flags) { if (flag.ToLower() == "wait") { newCustomEvent.execWait = true; } } } outCustomEvents.Add(newCustomEvent); } }
private void btnAddSave_Click(object sender, EventArgs e) { int saveSelectedIndex = listBox.SelectedIndex; System.ComponentModel.ComponentResourceManager localResources = new System.ComponentModel.ComponentResourceManager(typeof(CustomEventsForm)); if (txtCmd.Text == "") { MessageBox.Show(localResources.GetString("enterCommand")); return; } int selectedIndex = listBox.SelectedIndex; if (listBox.SelectedIndex == -1) { CustomEvent customEvent = new CustomEvent( txtCmd.Text, txtArgs.Text, boxWait.Checked); curCustomEvents.Add(customEvent); } else { CustomEvent customEvent = curCustomEvents[listBox.SelectedIndex]; customEvent.cmd = txtCmd.Text; customEvent.args = txtArgs.Text; customEvent.execWait = boxWait.Checked; } RefreshDisplay(); listBox.SelectedIndex = -1; // Force refresh listBox.SelectedIndex = saveSelectedIndex; // Re-select edited item ActiveControl = comboBox; }
private void PropertyToCustomEvents(String inPropertyName, List<CustomEvent> outCustomEvents) { String inPropertyValue = ""; virtPackage.GetProperty(inPropertyName, ref inPropertyValue); String[] values = inPropertyValue.Split(';'); foreach (String value in values) { if (value == "") continue; CustomEvent newCustomEvent; newCustomEvent = new CustomEvent("", "", false); String[] eventElements = value.Split('>'); // cmd if (eventElements.Length > 0) newCustomEvent.cmd = eventElements[0]; // args if (eventElements.Length > 1) newCustomEvent.args = eventElements[1]; // flags if (eventElements.Length > 2) { String[] flags = eventElements[2].Split(','); foreach (String flag in flags) { if (flag.ToLower() == "wait") newCustomEvent.execWait = true; } } outCustomEvents.Add(newCustomEvent); } }