public void saveConfiguration() { JsonSerializerSettings serializerSettings = new JsonSerializerSettings(); serializerSettings.TypeNameHandling = TypeNameHandling.Objects; // Remove (All) pseudo-setlist Setlist setlistToRemove = configuration.setlists.Find(setlist => setlist.name == "(All)"); configuration.setlists.Remove(setlistToRemove); String json = JsonConvert.SerializeObject(configuration, Formatting.Indented, serializerSettings); String myDocsFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal); String directoryPath = myDocsFolder + @"\JoeMidi"; if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } String filePath = directoryPath + @"\JoeMidi.json"; String backupFilePath = filePath + String.Format(".{0:yyyyMMddHHmmss}", DateTime.Now); if (File.Exists(filePath)) { File.Move(filePath, backupFilePath); } File.WriteAllText(filePath, json); configuration.dirty = false; }
private void refreshSongsForSetlistsControl() { tvSongsForSetlists.Nodes.Clear(); IList <Song> songs = null; if (cbSetEditorSonglistSetSelector.SelectedIndex >= 0) { string selectedSetlist = (string)cbSetEditorSonglistSetSelector.Items[cbSetEditorSonglistSetSelector.SelectedIndex]; Setlist setlist = mapper.configuration.setlists.Find(sl => sl.name == selectedSetlist); if (setlist != null) { songs = setlist.songs; } } if (songs == null) { songs = mapper.configuration.getSortedSongList(); } foreach (Song song in songs) { TreeNode node = new TreeNode(song.name + " - " + song.artist); node.Tag = song; tvSongsForSetlists.Nodes.Add(node); } }
private void cancelSetlistEdit() { setlistBeingEdited = null; originalSetlistName = ""; pnlSetlistEdit.Visible = false; pnlSetlistSongSelector.Visible = false; // btnSetlistDel.Enabled = false; }
public Setlist(Setlist orig) { name = orig.name; foreach (String songTitle in orig.songTitles) { songTitles.Add(songTitle); } }
private void addAllPseudoSetlist() { Setlist setList = new Setlist(); setList.name = "(All)"; foreach (Song song in configuration.getSortedSongList()) { setList.songTitles.Add(song.name); } setList.bind(configuration.songDict, configuration.logicalInputDeviceDict, configuration.soundGenerators, configuration.mappings, configuration.primaryInputDevice); configuration.setlists.Insert(0, setList); }
public bool addSetlist(Setlist setlist) { if (setlist == null) { return(false); } setlists.Add(setlist); dirty = true; return(true); }
public static void createTrialConfiguration(Dictionary <String, Song> songDict, List <Setlist> setlists) { Setlist setlist = new Setlist(); setlist.name = "Silas Knight Project"; Song.createTrialConfiguration(songDict, setlist); setlists.Add(setlist); setlist = new Setlist(); setlist.name = "Cave Mollies"; Song.createTrialConfiguration(songDict, setlist); setlists.Add(setlist); }
public void refreshAllPseudoSetlist() { Setlist setList = configuration.setlists.Find(sl => sl.name == "(All)"); if (setList != null) { setList.songs.Clear(); setList.songTitles.Clear(); foreach (Song song in configuration.getSortedSongList()) { setList.songTitles.Add(song.name); } setList.bind(configuration.songDict, configuration.logicalInputDeviceDict, configuration.soundGenerators, configuration.mappings, configuration.primaryInputDevice); } }
private void btnSetlists_Click(object sender, EventArgs e) { fmSetlistPicker form = new fmSetlistPicker(); form.Init(mapper.configuration.getSortedSetlistList()); form.ShowDialog(); if (form.IsOK == true) { String setlistName = form.Choice; for (int ii = 0; ii < mapper.configuration.setlists.Count; ++ii) { if (mapper.configuration.setlists[ii].name == setlistName) { currentSetlist = mapper.configuration.setlists[ii]; refreshShowControls(); break; } } } }
private void btnSetlistAdd_Click(object sender, EventArgs e) { setlistBeingEdited = new Setlist(); originalSetlistName = ""; // Initialize the setlist edit fields tbSetlistName.Text = ""; lbSetlistSongs.Items.Clear(); // Make note for commit-time that we're creating (not updating.) creatingNewSetlist = true; // Show the setlist editor controls. refreshSongsForSetlistsControl(); pnlSetlistSongSelector.Visible = true; pnlSetlistEdit.Visible = true; tbSetlistName.Select(); }
public void createTrialConfiguration() { dirty = true; try { Mapping.PerDeviceChannelMapping globalPerInputDeviceChannelMapping = new Mapping.PerDeviceChannelMapping(); globalPerInputDeviceChannelMapping.logicalInputDeviceName = "Input Device 1"; globalPerInputDeviceChannelMapping.inputDeviceChannel = 0; ControlMapping globalControlMapping = new ControlMapping(); globalControlMapping.soundGeneratorName = "Reaper"; globalControlMapping.soundGeneratorRelativeChannel = 0; globalControlMapping.sourceControlNumber = 75; // Top Left Rotary Knob on Oxygen globalControlMapping.mappedControlNumber = 9; // I've got Reaper Master Volume mapped to this. globalControlMapping.min = 30; // This provides a nice workable vol range globalControlMapping.max = 91; globalPerInputDeviceChannelMapping.controlMappings.Add(globalControlMapping); globalControlMappings.Add(globalPerInputDeviceChannelMapping); primaryInputDeviceName = "Input Device 1"; LogicalInputDevice.createTrialConfiguration(logicalInputDeviceDict); LogicalOutputDevice.createTrialConfiguration(logicalOutputDeviceDict); SoundGenerator.createTrialConfiguration(soundGenerators); Mapping.createTrialConfiguration(mappings); MidiProgram.createTrialConfiguration(midiPrograms); Setlist.createTrialConfiguration(songDict, setlists); } catch (Exception e) { MessageBox.Show("Exception creating trial configurations: " + e); } }
private void completeSetlistEdit() { // Gather the changed fields into the temp Setlist object. (Edits to its Songs will have already been applied...) setlistBeingEdited.name = tbSetlistName.Text; // Bind the now completed Setlist setlistBeingEdited.bind(mapper.configuration.songDict, mapper.configuration.logicalInputDeviceDict, mapper.configuration.soundGenerators, mapper.configuration.mappings, mapper.configuration.primaryInputDevice); // Make the changes to the actual model objects if (creatingNewSetlist == true) { mapper.configuration.addSetlist(setlistBeingEdited); } else { mapper.configuration.deleteSetlistByName(originalSetlistName); mapper.configuration.addSetlist(setlistBeingEdited); // TBD: change any UI elements dependent on this setlist. } // The edit could change what's on the Show tab. Refresh it. if (currentSetlist.name == originalSetlistName) { currentSetlist = setlistBeingEdited; refreshShowControls(); } // Refresh the SetlistEditSelector in case this is a new setlist or its name changed refreshSetlistEditSelector(); // Clean up edit state setlistBeingEdited = null; originalSetlistName = ""; // Hide setlist edit controls pnlSetlistEdit.Visible = false; pnlSetlistSongSelector.Visible = false; // btnSetlistDel.Enabled = false; }
private void beginSetlistEdit(Setlist setlist) { // Prepare for Editing of Setlist setlistBeingEdited = new Setlist(setlist); // Make a deep (but unbound) copy of the Setlist that we'll edit. originalSetlistName = setlistBeingEdited.name; // Save orig name so we can find orig Setlist in model to update it. // Set the setlist editor UI fields with info from the selected setlist tbSetlistName.Text = setlistBeingEdited.name; // Refresh the list controls' content refreshLbSetlistSongs(); refreshSongsForSetlistsControl(); // Make note for commit-time that we're updating (not creating.) creatingNewSetlist = false; // Show the setlist editor controls. Hide the song selector in case it happened to be up for the previous setlist. (Any edits to its songs are implicity abandoned...) pnlSetlistEdit.Visible = true; pnlSetlistSongSelector.Visible = true; tbSetlistName.Select(); // btnSetlistDel.Enabled = true; }
private void deleteSetlistSelectedForEditing(string setlistName) { // Do the delete in the model mapper.configuration.deleteSetlistByName(setlistName); // Refresh the SetlistEditSelector to reflect the deletion refreshSetlistEditSelector(); if (currentSetlist.name.Equals(setlistName)) { currentSetlist = mapper.configuration.setlists.Find(sl => sl.name == "(All)"); refreshShowControls(); } // Clean up editor state setlistBeingEdited = null; originalSetlistName = ""; // Hide setlist edit controls in case they were open. pnlSetlistEdit.Visible = false; pnlSetlistSongSelector.Visible = false; // btnSetlistDel.Enabled = false; }
public static void createTrialConfiguration(Dictionary <String, Song> songDict, Setlist setList) { if (setList.name.Equals("Silas Knight Project")) { Song song = new Song(); song.name = "Josie"; song.artist = "Steely Dan"; song.chartFile = "Josie 2.rtf"; song.chartPage = 1; SongProgram.createTrialConfiguration(song); songDict.Add(song.name, song); setList.songTitles.Add(song.name); song = new Song(); song.name = "Celebration"; song.artist = "Kool"; song.chartFile = "Celebration.rtf"; SongProgram.createTrialConfiguration(song); songDict.Add(song.name, song); setList.songTitles.Add(song.name); } else if (setList.name.Equals("Cave Mollies")) { Song song = new Song(); song.name = "Jealous"; song.artist = "Black Crowes"; song.chartFile = "Jealous.rtf"; SongProgram.createTrialConfiguration(song); songDict.Add(song.name, song); setList.songTitles.Add(song.name); song = new Song(); song.name = "Loving Cup"; song.artist = "Stones"; song.chartFile = "Loving Cup.rtf"; SongProgram.createTrialConfiguration(song); songDict.Add(song.name, song); setList.songTitles.Add(song.name); } else { MessageBox.Show("Unknown setlist " + setList.name + " presented to Song.createTrialConfiguration"); } }
private void mbccSetlistEditSelector_Click(object sender, EventArgs e) { Setlist setlist = (Setlist)(((Button)sender).Tag); beginSetlistEdit(setlist); }