/// <summary> /// An event handler called when a slice command was removed. /// </summary> /// <param name="sender">The sender object.</param> /// <param name="e">The event arguments.</param> private void OnCommandRemoved(object sender, PlCommandEventArgs e) { // Find the list box item corresponding to the selected. CommandListBoxItem item = this.listCommands.Items.FirstOrDefault((object it) => { // Get the selected item. CommandListBoxItem commandItem = it as CommandListBoxItem; // Check the item command matches the removed command. return object.ReferenceEquals(commandItem.Command, e.Command); }) as CommandListBoxItem; // If the item is not null. if (null != item) { // Remove the item. this.listCommands.Items.Remove(item); // Call the command selection changed event handler. this.OnCommandSelectionChanged(sender, e); // Call the start conditions changed event handler. this.OnStartConditionsChanged(sender, e); } }
/// <summary> /// An event handler called when a slice command was added. /// </summary> /// <param name="sender">The sender object.</param> /// <param name="e">The event arguments.</param> private void OnCommandAdded(object sender, PlCommandEventArgs e) { // Add a new item to the list. this.listCommands.AddItem(e.Command); // Call the start conditions changed event handler. this.OnStartConditionsChanged(sender, e); }