private void deleteToolStripMenuItem2_Click(object sender, EventArgs e) { if (dgTriggerEvents.MultiSelect == true) { throw new NotImplementedException("Editing mutliple triggers at once is unsupported."); } VI_Trigger selected_trigger = null; foreach (DataGridViewRow row in this.dgTriggers.SelectedRows) { selected_trigger = row.DataBoundItem as VI_Trigger; } if (selected_trigger != null) { foreach (DataGridViewRow row in this.dgTriggerEvents.SelectedRows) { VI_TriggerEvent selected_event = row.DataBoundItem as VI_TriggerEvent; if (selected_event != null) { //Remove Event selected_trigger.Remove(selected_event); } } } ProfileEdited(); refresh_dgTriggers(); refresh_dgTriggerEvents(); }
public frm_AddEdit_PhraseTrigger( VI_Trigger trigger_to_edit ) { // Passing a trigger to the contructor edits an existing InitializeComponent(); this.trigger_to_edit = trigger_to_edit; populate_fields(); }
// Delete Trigger private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { if (dgTriggers.MultiSelect == true) { throw new NotImplementedException("Editing mutliple triggers at once is unsupported."); } foreach (DataGridViewRow row in this.dgTriggers.SelectedRows) { VI_Trigger selected_trigger = row.DataBoundItem as VI_Trigger; if (selected_trigger != null) { GAVPI.vi_profile.Profile_Triggers.Remove(selected_trigger); // Remove refernces of this trigger from existing triggers foreach (VI_Trigger existing_trigger in GAVPI.vi_profile.Profile_Triggers) { existing_trigger.TriggerEvents.Remove(selected_trigger); } ProfileEdited(); refresh_dgTriggers(); } } }
public frmTrigger(VI_Trigger trigger_to_edit) { // Passing a trigger to the contructor edits an existing InitializeComponent(); this.trigger_to_edit = trigger_to_edit; populate_fields(); }
private void btnAdd_Click(object sender, EventArgs e) { VI_Trigger selected_trigger = cbAddtoTriggerEvent.SelectedItem as VI_Trigger; //if (selected_trigger.TriggerEvents.Contains(event_to_add)) //{ // // Ignore Doubles // //MessageBox.Show("Trigger " + selected_trigger.name + " already contains " + event_to_add.name); // //return; //} if ((event_to_add.GetType().Name != "VI_Action_Sequence") && event_to_add.name == selected_trigger.name) { MessageBox.Show("You cannot add a trigger to itself."); this.DialogResult = DialogResult.Cancel; return; } else { selected_trigger.TriggerEvents.Add(event_to_add); this.DialogResult = DialogResult.OK; this.Close(); } }
private void refresh_dgTriggerEvents() { List <VI_TriggerEvent> dg_data_trigger_events = new List <VI_TriggerEvent>(); foreach (DataGridViewRow row in this.dgTriggers.SelectedRows) { VI_Trigger selected_trigger = row.DataBoundItem as VI_Trigger; if (selected_trigger != null) { foreach (VI_TriggerEvent trigger_event in selected_trigger.TriggerEvents) { dg_data_trigger_events.Add(trigger_event); } } } dgTriggerEvents.DataSource = null; dgTriggerEvents.DataSource = dg_data_trigger_events.ToList(); }
// Edit Trigger private void editToolStripMenuItem_Click(object sender, EventArgs e) { if (dgTriggers.MultiSelect == true) { throw new NotImplementedException("Editing mutliple triggers at once is unsupported."); } foreach (DataGridViewRow row in this.dgTriggers.SelectedRows) { VI_Trigger selected_trigger = row.DataBoundItem as VI_Trigger; if (selected_trigger != null) { frm_AddEdit_PhraseTrigger newTrigger = new frm_AddEdit_PhraseTrigger(selected_trigger); if (newTrigger.ShowDialog() == DialogResult.OK) { ProfileEdited(); refresh_dgTriggers(); } // if() } } }
public void Add_Trigger(VI_Trigger trigger_toAdd) { Profile_Triggers.Add(trigger_toAdd); }