void ArgumentChanged(object sender, EventArgs e) { for (int i = 0; i < 3; i++) { if (sender == argNumerics[i]) { var se = events[listView.SelectedIndices[0]]; object value = argNumerics[i].Value; var m = se.Command.GetType().GetMember(argLabels[i].Text)[0]; if (m is FieldInfo f) f.SetValue(se.Command, Convert.ChangeType(value, f.FieldType)); else if (m is PropertyInfo p) p.SetValue(se.Command, Convert.ChangeType(value, p.PropertyType)); SongPlayer.RefreshSong(); var control = ActiveControl; int index = listView.SelectedIndex; LoadTrack(currentTrack); SelectItem(index); control.Select(); return; } } }
void RemoveEvent(object sender, EventArgs e) { if (listView.SelectedIndex == -1) return; SongPlayer.Song.RemoveEvent(currentTrack, listView.SelectedIndex); SongPlayer.RefreshSong(); LoadTrack(currentTrack); }
void AddEvent(object sender, EventArgs e) { var cmd = (ICommand)Activator.CreateInstance(Engine.GetCommands()[commandsBox.SelectedIndex].GetType()); var ev = new SongEvent(0xFFFFFFFF, cmd); int index = listView.SelectedIndex + 1; SongPlayer.Song.InsertEvent(ev, currentTrack, index); SongPlayer.RefreshSong(); LoadTrack(currentTrack); SelectItem(index); }
void ApplyRemap(bool from) { bool changed = false; string remap = (string)remapsBox.SelectedItem; foreach (var track in SongPlayer.Song.Commands) foreach (var ev in track) if (ev.Command is VoiceCommand voice) { voice.Voice = Config.GetRemap(voice.Voice, remap, from); changed = true; } if (changed) { SongPlayer.RefreshSong(); LoadTrack(currentTrack); } }
void ChangeEvents(object sender, EventArgs e) { bool changed = false; foreach (var ev in events) if (sender == trackChangeVoicesButton && ev.Command is VoiceCommand voice && voice.Voice == trackVoiceArgs[0].Value) { voice.Voice = (byte)tvArgs[1].Value; if (sender == changeVoicesButton && ev.Command is VoiceCommand voice)// && voice.Voice == trackVoiceDetails[0].Value) { voice.Voice = (byte)trackVoiceDetails[1].Value; trackVoiceDetails[0].Value = (decimal)voice.Voice; voice.Voice = (byte)trackVoiceArgs[1].Value; changed = true; } if (changed) { SongPlayer.RefreshSong(); LoadTrack(currentTrack); } } void ChangeAllEvents(object sender, EventArgs e) { bool changed = false; foreach (var track in SongPlayer.Song.Commands) foreach (var ev in track) if (sender == globalChangeVoicesButton && ev.Command is VoiceCommand voice && voice.Voice == globalVoiceArgs[0].Value) { voice.Voice = (byte)globalVoiceArgs[1].Value; changed = true; } if (changed) { SongPlayer.RefreshSong(); LoadTrack(currentTrack); } } void LoadTrack(int track) { currentTrack = track; events = SongPlayer.Song.Commands[track]; listView.SetObjects(events); SelectedIndexChanged(null, null); } void TracksBox_SelectedIndexChanged(object sender, EventArgs e) => LoadTrack(tracksBox.SelectedIndex);