private void btnMappingDelete_Click(object sender, EventArgs e) { SimpleMapping mapping = mappingBeingEdited; if (mapping == null) { return; } mapper.configuration.mappings.Remove(mapping.name); //Remove any SongPrograms that pointed to this mapping from their Songs. foreach (Song song in mapper.configuration.songDict.Values) { List <SongProgram> songProgramListClone = song.programs.ToList <SongProgram>(); foreach (SongProgram songProgram in songProgramListClone) { if (songProgram.mapping == mapping) { song.programs.Remove(songProgram); } } } refreshMappingToEditSelector(); btnPatchTreeViewBySG_Click(null, null); // Hide any editor UI elements that may be visible. pnlMappingEdit.Visible = false; tlpMappingEditNameAndButtons.Visible = false; }
private void btnMappingAdd_Click(object sender, EventArgs e) { // Create a new empty SimpleMapping and initialize the editor state variables. mappingBeingEdited = new SimpleMapping(); creatingNewMapping = true; // Initialize the UI elements tbMappingName.Text = ""; tbMappingName.ReadOnly = false; enableUiDeviceLabelsForFirstTwoInputDevices(); showSimpleMappingDefEditorControls(false); lbMappingDevice1LowerPatches.Items.Clear(); lbMappingDevice2LowerPatches.Items.Clear(); lbMappingDevice1UpperPatches.Items.Clear(); lbMappingDevice2UpperPatches.Items.Clear(); cbMappingSplitDevice1.Checked = false; cbMappingSplitDevice2.Checked = false; nudMappingSplitDevice1.Value = 60; nudMappingSplitDevice2.Value = 60; nudMappingSplitDevice1.Visible = false; // Only made visible when Split checkbox is checked. nudMappingSplitDevice2.Visible = false; // Only made visible when Split checkbox is checked. lbMappingDevice1LowerPatches.Visible = false; // Only made visible when Split checkbox is checked. lbMappingDevice2LowerPatches.Visible = false; // Only made visible when Split checkbox is checked. // Make the editor UI visible pnlMappingEdit.Visible = true; tlpMappingEditNameAndButtons.Visible = true; tbMappingName.Select(); }
// A Mapping was selected for editing private void mbrcMappingSelect_Click(object sender, EventArgs e) { // Make sure it's a SimpleMapping if (((Button)sender).Tag is SimpleMapping) { SimpleMapping mapping = (SimpleMapping)(((Button)sender).Tag); // In case it's a direct-switch from one mapping to another. showSimpleMappingDefEditorControls(false); // Update the editor state variables to communicate to the OK method. mappingBeingEdited = mapping; creatingNewMapping = false; enableUiDeviceLabelsForFirstTwoInputDevices(); // Populate UI fields. tbMappingName.Text = mapping.name; tbMappingName.ReadOnly = true; // You can't edit mapping name. // If there are mappings defined for at least one Input Device then update the UI elements on the left side with data from the first one defined. if (mapping.perDeviceSimpleMappings.Count > 0) { SimpleMapping.PerDeviceSimpleMapping perDeviceSimpleMapping = mapping.perDeviceSimpleMappings[0]; cbMappingSplitDevice1.Checked = perDeviceSimpleMapping.splitPoint > 0; nudMappingSplitDevice1.Value = (perDeviceSimpleMapping.splitPoint > 0) ? perDeviceSimpleMapping.splitPoint : 60; nudMappingSplitDevice1.Visible = perDeviceSimpleMapping.splitPoint > 0; lbMappingDevice1UpperPatches.Items.Clear(); lbMappingDevice1UpperPatches.Visible = true; lbMappingDevice1LowerPatches.Items.Clear(); lbMappingDevice1LowerPatches.Visible = perDeviceSimpleMapping.splitPoint > 0; foreach (SimpleMapping.SimpleMappingDefinition mappingDefinition in perDeviceSimpleMapping.simpleMappingDefinitions) { if (mappingDefinition.bLower) { lbMappingDevice1LowerPatches.Items.Add(mappingDefinition); } else { lbMappingDevice1UpperPatches.Items.Add(mappingDefinition); } } } // If there are mappings defined for at least two Input Device then update the UI elements on the right side with the second. We ignore any beyond that. if (mapping.perDeviceSimpleMappings.Count > 1) { // Make InputDevice2 mapping def controls visible cbMappingSplitDevice2.Visible = true; SimpleMapping.PerDeviceSimpleMapping perDeviceMapping = mapping.perDeviceSimpleMappings[1]; lblMappingInputDevice2.Text = perDeviceMapping.inputDeviceName; cbMappingSplitDevice2.Checked = perDeviceMapping.splitPoint > 0; nudMappingSplitDevice2.Value = (perDeviceMapping.splitPoint > 0) ? perDeviceMapping.splitPoint : 60; nudMappingSplitDevice2.Visible = perDeviceMapping.splitPoint > 0; lbMappingDevice2UpperPatches.Items.Clear(); lbMappingDevice2UpperPatches.Visible = true; lbMappingDevice2LowerPatches.Items.Clear(); lbMappingDevice2LowerPatches.Visible = perDeviceMapping.splitPoint > 0; foreach (SimpleMapping.SimpleMappingDefinition mappingDefinition in perDeviceMapping.simpleMappingDefinitions) { if (mappingDefinition.bLower) { lbMappingDevice2LowerPatches.Items.Add(mappingDefinition); } else { lbMappingDevice2UpperPatches.Items.Add(mappingDefinition); } } } else { lbMappingDevice2LowerPatches.Visible = false; cbMappingSplitDevice2.Checked = false; nudMappingSplitDevice2.Value = 60; nudMappingSplitDevice2.Visible = false; } // Expose the Mapping Editor UI elements pnlMappingEdit.Visible = true; tlpMappingEditNameAndButtons.Visible = true; tvMappingEditorPrograms.Focus(); } else { MessageBox.Show("Presently one can only edit SimpleMappings with this UI"); } }