public Project ShowDialog(FamiStudioForm parent) { if (dialog != null && dialog.ShowDialog(parent) == DialogResult.OK) { var expansion = dialog.Properties.GetSelectedIndex(0); var polyphony = dialog.Properties.GetSelectedIndex(1); var measuresPerPattern = dialog.Properties.GetPropertyValue <int>(2); var velocityAsVolume = dialog.Properties.GetPropertyValue <bool>(3); var pal = expansion != ExpansionType.None ? false : dialog.Properties.GetPropertyValue <bool>(4); return(new MidiFileReader().Load(filename, expansion, pal, channelSources, velocityAsVolume, polyphony, measuresPerPattern)); } return(null); }
private void MidiInstrumentDoubleClick(PropertyPage props, int propertyIndex, int itemIndex, int columnIndex) { Debug.Assert(midiInstrumentMapping != null); var dlg = new PropertyDialog(400, true, true, dialog); dlg.Properties.AddDropDownList("MIDI Instrument:", MidiFileReader.MidiInstrumentNames, MidiFileReader.MidiInstrumentNames[midiInstrumentMapping[itemIndex]]); // 0 dlg.Properties.Build(); if (dlg.ShowDialog(null) == DialogResult.OK) { midiInstrumentMapping[itemIndex] = dlg.Properties.GetSelectedIndex(0); UpdateMidiInstrumentMapping(); } }
void QwertyListDoubleClicked(PropertyPage props, int propertyIndex, int itemIndex, int columnIndex) { if (columnIndex < 2) { return; } var dlg = new PropertyDialog(300, false, true, dialog); dlg.Properties.AddLabel(null, "Press the new key or ESC to cancel."); dlg.Properties.Build(); // TODO : Make this cross-platform. #if FAMISTUDIO_WINDOWS dlg.KeyDown += (sender, e) => { if (PlatformUtils.KeyCodeToString((int)e.KeyCode) != null) { if (e.KeyCode != Keys.Escape) { AssignQwertyKey(itemIndex, columnIndex - 2, (int)e.KeyCode); } dlg.Close(); } }; #else dlg.KeyPressEvent += (o, args) => { // These 2 keys are used by the QWERTY input. if (args.Event.Key != Gdk.Key.Tab && args.Event.Key != Gdk.Key.BackSpace && PlatformUtils.KeyCodeToString((int)args.Event.Key) != null) { if (args.Event.Key != Gdk.Key.Escape) { AssignQwertyKey(itemIndex, columnIndex - 2, (int)args.Event.Key); } dlg.Accept(); } }; #endif dlg.ShowDialog(null); pages[(int)ConfigSection.QWERTY].UpdateMultiColumnList(1, GetQwertyMappingStrings()); }
void MappingListDoubleClicked(PropertyPage props, int propertyIndex, int itemIndex, int columnIndex) { var src = channelSources[itemIndex]; var srcNames = GetSourceNames(src.type); var allowChannel10Mapping = src.type == MidiSourceType.Channel && src.index == 9; var dlg = new PropertyDialog(300, true, true, dialog); dlg.Properties.AddDropDownList("Source Type:", MidiSourceType.Names, MidiSourceType.Names[src.type]); // 0 dlg.Properties.AddDropDownList("Source:", srcNames, srcNames[src.index]); // 1 dlg.Properties.AddLabel(null, "Channel 10 keys:"); // 2 dlg.Properties.AddCheckBoxList(null, MidiFileReader.MidiDrumKeyNames, GetSelectedChannel10Keys(src)); // 3 dlg.Properties.AddButton(null, "Select All", SelectClicked); // 4 dlg.Properties.AddButton(null, "Select None", SelectClicked); // 5 dlg.Properties.Build(); dlg.Properties.PropertyChanged += MappingProperties_PropertyChanged; dlg.Properties.SetPropertyEnabled(1, src.type != MidiSourceType.None); dlg.Properties.SetPropertyEnabled(3, src.type != MidiSourceType.None && allowChannel10Mapping); dlg.Properties.SetPropertyEnabled(4, src.type != MidiSourceType.None && allowChannel10Mapping); dlg.Properties.SetPropertyEnabled(5, src.type != MidiSourceType.None && allowChannel10Mapping); if (dlg.ShowDialog(null) == DialogResult.OK) { var sourceType = MidiSourceType.GetValueForName(dlg.Properties.GetPropertyValue <string>(0)); var sourceName = dlg.Properties.GetPropertyValue <string>(1); var keysBool = dlg.Properties.GetPropertyValue <bool[]>(3); src.type = sourceType; src.index = sourceType == MidiSourceType.None ? 0 : (Utils.ParseIntWithTrailingGarbage(sourceName.Substring(sourceType == MidiSourceType.Track ? 6 : 8)) - 1); src.keys = 0ul; for (int i = 0; i < keysBool.Length; i++) { if (keysBool[i]) { src.keys |= (1ul << i); } } UpdateListView(); } }
protected override void OnMouseDoubleClick(MouseEventArgs e) { base.OnMouseDoubleClick(e); var buttonIdx = GetButtonAtCoord(e.X, e.Y, out var subButtonType); if (buttonIdx >= 0) { var button = buttons[buttonIdx]; if (button.type == ButtonType.ProjectSettings) { var project = App.Project; var dlg = new PropertyDialog(PointToScreen(new Point(e.X, e.Y)), 250, true); dlg.Properties.AddString("Title :", project.Name, 31); // 0 dlg.Properties.AddString("Author :", project.Author, 31); // 1 dlg.Properties.AddString("Copyright :", project.Copyright, 31); // 2 dlg.Properties.Build(); if (dlg.ShowDialog() == DialogResult.OK) { App.UndoRedoManager.BeginTransaction(TransactionScope.Project); project.Name = dlg.Properties.GetPropertyValue <string>(0); project.Author = dlg.Properties.GetPropertyValue <string>(1); project.Copyright = dlg.Properties.GetPropertyValue <string>(2); App.UndoRedoManager.EndTransaction(); ConditionalInvalidate(); } } else if (button.type == ButtonType.Song) { var song = button.song; var dlg = new PropertyDialog(PointToScreen(new Point(e.X, e.Y)), 200, true); dlg.Properties.AddColoredString(song.Name, song.Color); // 0 dlg.Properties.AddIntegerRange("Tempo :", song.Tempo, 32, 255); // 1 dlg.Properties.AddIntegerRange("Speed :", song.Speed, 1, 31); // 2 dlg.Properties.AddIntegerRange("Pattern Length :", song.PatternLength, 16, 256); // 3 dlg.Properties.AddDomainRange("Bar Length :", GenerateBarLengths(song.PatternLength), song.BarLength); // 4 dlg.Properties.AddIntegerRange("Song Length :", song.Length, 1, 128); // 5 dlg.Properties.AddColor(song.Color); // 6 dlg.Properties.Build(); dlg.Properties.PropertyChanged += Properties_PropertyChanged; if (dlg.ShowDialog() == DialogResult.OK) { App.UndoRedoManager.BeginTransaction(TransactionScope.Project); App.Stop(); App.Seek(0); var newName = dlg.Properties.GetPropertyValue <string>(0); if (App.Project.RenameSong(song, newName)) { song.Color = dlg.Properties.GetPropertyValue <System.Drawing.Color>(6); song.Tempo = dlg.Properties.GetPropertyValue <int>(1); song.Speed = dlg.Properties.GetPropertyValue <int>(2); song.Length = dlg.Properties.GetPropertyValue <int>(5); song.PatternLength = dlg.Properties.GetPropertyValue <int>(3); song.BarLength = dlg.Properties.GetPropertyValue <int>(4); SongModified?.Invoke(song); App.UndoRedoManager.EndTransaction(); RefreshButtons(); } else { App.UndoRedoManager.AbortTransaction(); SystemSounds.Beep.Play(); } ConditionalInvalidate(); } } else if (button.type == ButtonType.Instrument && button.instrument != null) { var instrument = button.instrument; if (subButtonType == SubButtonType.Max) { var dlg = new PropertyDialog(PointToScreen(new Point(e.X, e.Y)), 160, true); dlg.Properties.AddColoredString(instrument.Name, instrument.Color); dlg.Properties.AddColor(instrument.Color); dlg.Properties.Build(); if (dlg.ShowDialog() == DialogResult.OK) { var newName = dlg.Properties.GetPropertyValue <string>(0); App.UndoRedoManager.BeginTransaction(TransactionScope.Project); if (App.Project.RenameInstrument(instrument, newName)) { instrument.Color = dlg.Properties.GetPropertyValue <System.Drawing.Color>(1); InstrumentColorChanged?.Invoke(instrument); RefreshButtons(); ConditionalInvalidate(); App.UndoRedoManager.EndTransaction(); } else { App.UndoRedoManager.AbortTransaction(); SystemSounds.Beep.Play(); } } } } } }
public DialogResult ShowDialog() { return(dialog.ShowDialog(parentForm)); }
protected override void OnMouseDoubleClick(MouseEventArgs e) { base.OnMouseDoubleClick(e); var buttonIdx = GetButtonAtCoord(e.X, e.Y, out var subButtonType); if (buttonIdx >= 0) { var button = buttons[buttonIdx]; if (button.type == ButtonType.ProjectSettings) { var project = App.Project; var dlg = new PropertyDialog(PointToScreen(new Point(e.X, e.Y)), 280, true); dlg.Properties.AddString("Title :", project.Name, 31); // 0 dlg.Properties.AddString("Author :", project.Author, 31); // 1 dlg.Properties.AddString("Copyright :", project.Copyright, 31); // 2 dlg.Properties.AddStringList("Expansion Audio:", Project.ExpansionNames, project.ExpansionAudioName); // 3 dlg.Properties.Build(); if (dlg.ShowDialog() == DialogResult.OK) { App.UndoRedoManager.BeginTransaction(TransactionScope.Project); project.Name = dlg.Properties.GetPropertyValue <string>(0); project.Author = dlg.Properties.GetPropertyValue <string>(1); project.Copyright = dlg.Properties.GetPropertyValue <string>(2); var expansion = Array.IndexOf(Project.ExpansionNames, dlg.Properties.GetPropertyValue <string>(3)); if (expansion != project.ExpansionAudio) { if (project.ExpansionAudio == Project.ExpansionNone || PlatformUtils.MessageBox($"Switching expansion audio will delete all instruments and channels using the old expansion?", "Change expansion audio", MessageBoxButtons.YesNo) == DialogResult.Yes) { App.StopInstrumentPlayer(); project.SetExpansionAudio(expansion); ExpansionAudioChanged?.Invoke(); App.StartInstrumentPlayer(); Reset(); } } App.UndoRedoManager.EndTransaction(); ConditionalInvalidate(); } } else if (button.type == ButtonType.Song) { var song = button.song; var dlg = new PropertyDialog(PointToScreen(new Point(e.X, e.Y)), 200, true); dlg.Properties.AddColoredString(song.Name, song.Color); // 0 dlg.Properties.AddIntegerRange("Tempo :", song.Tempo, 32, 255); // 1 dlg.Properties.AddIntegerRange("Speed :", song.Speed, 1, 31); // 2 dlg.Properties.AddIntegerRange("Pattern Length :", song.PatternLength, 16, 256); // 3 dlg.Properties.AddDomainRange("Bar Length :", GenerateBarLengths(song.PatternLength), song.BarLength); // 4 dlg.Properties.AddIntegerRange("Song Length :", song.Length, 1, 128); // 5 dlg.Properties.AddColor(song.Color); // 6 dlg.Properties.Build(); dlg.Properties.PropertyChanged += Properties_PropertyChanged; if (dlg.ShowDialog() == DialogResult.OK) { App.UndoRedoManager.BeginTransaction(TransactionScope.Project); App.Stop(); App.Seek(0); var newName = dlg.Properties.GetPropertyValue <string>(0); if (App.Project.RenameSong(song, newName)) { song.Color = dlg.Properties.GetPropertyValue <System.Drawing.Color>(6); song.Tempo = dlg.Properties.GetPropertyValue <int>(1); song.Speed = dlg.Properties.GetPropertyValue <int>(2); song.SetLength(dlg.Properties.GetPropertyValue <int>(5)); song.SetPatternLength(dlg.Properties.GetPropertyValue <int>(3)); song.SetBarLength(dlg.Properties.GetPropertyValue <int>(4)); SongModified?.Invoke(song); App.UndoRedoManager.EndTransaction(); RefreshButtons(); } else { App.UndoRedoManager.AbortTransaction(); SystemSounds.Beep.Play(); } ConditionalInvalidate(); } } else if (button.type == ButtonType.Instrument && button.instrument != null) { var instrument = button.instrument; if (subButtonType == SubButtonType.Max) { var dlg = new PropertyDialog(PointToScreen(new Point(e.X, e.Y)), 160, true); dlg.Properties.AddColoredString(instrument.Name, instrument.Color); // 0 dlg.Properties.AddColor(instrument.Color); // 1 dlg.Properties.AddBoolean("Relative pitch:", instrument.Envelopes[Envelope.Pitch].Relative); // 2 dlg.Properties.Build(); if (dlg.ShowDialog() == DialogResult.OK) { var newName = dlg.Properties.GetPropertyValue <string>(0); App.UndoRedoManager.BeginTransaction(TransactionScope.Project); if (App.Project.RenameInstrument(instrument, newName)) { instrument.Color = dlg.Properties.GetPropertyValue <System.Drawing.Color>(1); instrument.Envelopes[Envelope.Pitch].Relative = dlg.Properties.GetPropertyValue <bool>(2); InstrumentColorChanged?.Invoke(instrument); RefreshButtons(); ConditionalInvalidate(); App.UndoRedoManager.EndTransaction(); } else { App.UndoRedoManager.AbortTransaction(); SystemSounds.Beep.Play(); } } } } } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); bool left = e.Button.HasFlag(MouseButtons.Left); bool middle = e.Button.HasFlag(MouseButtons.Middle) || (e.Button.HasFlag(MouseButtons.Left) && ModifierKeys.HasFlag(Keys.Alt)); bool right = e.Button.HasFlag(MouseButtons.Right); var buttonIdx = GetButtonAtCoord(e.X, e.Y, out var subButtonType); if (buttonIdx >= 0) { var button = buttons[buttonIdx]; if (left) { if (button.type == ButtonType.SongHeader) { if (subButtonType == SubButtonType.Add) { App.UndoRedoManager.BeginTransaction(TransactionScope.Project); App.Project.CreateSong(); App.UndoRedoManager.EndTransaction(); RefreshButtons(); ConditionalInvalidate(); } } else if (button.type == ButtonType.Song) { if (button.song != selectedSong) { selectedSong = button.song; SongSelected?.Invoke(selectedSong); ConditionalInvalidate(); } } else if (button.type == ButtonType.InstrumentHeader) { if (subButtonType == SubButtonType.Add) { var instrumentType = Project.ExpansionNone; if (App.Project.NeedsExpansionInstruments) { var expNames = new[] { Project.ExpansionNames[Project.ExpansionNone], App.Project.ExpansionAudioName }; var dlg = new PropertyDialog(PointToScreen(new Point(e.X, e.Y)), 240, true); dlg.Properties.AddStringList("Expansion:", expNames, Project.ExpansionNames[Project.ExpansionNone]); // 0 dlg.Properties.Build(); if (dlg.ShowDialog() == DialogResult.OK) { instrumentType = dlg.Properties.GetPropertyValue <string>(0) == Project.ExpansionNames[Project.ExpansionNone] ? Project.ExpansionNone : App.Project.ExpansionAudio; } else { return; } } App.UndoRedoManager.BeginTransaction(TransactionScope.Project); App.Project.CreateInstrument(instrumentType); App.UndoRedoManager.EndTransaction(); RefreshButtons(); ConditionalInvalidate(); } if (subButtonType == SubButtonType.LoadInstrument) { var filename = PlatformUtils.ShowOpenFileDialog("Open File", "Fami Tracker Instrument (*.fti)|*.fti"); if (filename != null) { App.UndoRedoManager.BeginTransaction(TransactionScope.Project); var instrument = FamitrackerInstrumentFile.CreateFromFile(App.Project, filename); if (instrument == null) { App.UndoRedoManager.AbortTransaction(); } else { App.UndoRedoManager.EndTransaction(); } } RefreshButtons(); ConditionalInvalidate(); } } else if (button.type == ButtonType.Instrument) { selectedInstrument = button.instrument; if (selectedInstrument != null) { instrumentDrag = selectedInstrument; mouseDragY = e.Y; } if (subButtonType == SubButtonType.Volume) { InstrumentEdited?.Invoke(selectedInstrument, Envelope.Volume); envelopeDragIdx = Envelope.Volume; } else if (subButtonType == SubButtonType.Pitch) { InstrumentEdited?.Invoke(selectedInstrument, Envelope.Pitch); envelopeDragIdx = Envelope.Pitch; } else if (subButtonType == SubButtonType.Arpeggio) { InstrumentEdited?.Invoke(selectedInstrument, Envelope.Arpeggio); envelopeDragIdx = Envelope.Arpeggio; } else if (subButtonType == SubButtonType.DPCM) { InstrumentEdited?.Invoke(selectedInstrument, Envelope.Max); } else if (subButtonType == SubButtonType.DutyCycle) { selectedInstrument.DutyCycle = (selectedInstrument.DutyCycle + 1) % selectedInstrument.DutyCycleRange; } InstrumentSelected?.Invoke(selectedInstrument); ConditionalInvalidate(); } } else if (right) { if (button.type == ButtonType.Song && App.Project.Songs.Count > 1) { var song = button.song; if (PlatformUtils.MessageBox($"Are you sure you want to delete '{song.Name}' ?", "Delete song", MessageBoxButtons.YesNo) == DialogResult.Yes) { bool selectNewSong = song == selectedSong; App.Stop(); App.UndoRedoManager.BeginTransaction(TransactionScope.Project); App.Project.DeleteSong(song); if (selectNewSong) { selectedSong = App.Project.Songs[0]; } SongSelected?.Invoke(selectedSong); App.UndoRedoManager.EndTransaction(); RefreshButtons(); ConditionalInvalidate(); } } else if (button.type == ButtonType.Instrument && button.instrument != null) { var instrument = button.instrument; if (subButtonType == SubButtonType.Arpeggio || subButtonType == SubButtonType.Pitch || subButtonType == SubButtonType.Volume) { int envType = Envelope.Volume; switch (subButtonType) { case SubButtonType.Arpeggio: envType = Envelope.Arpeggio; break; case SubButtonType.Pitch: envType = Envelope.Pitch; break; } App.UndoRedoManager.BeginTransaction(TransactionScope.Instrument, instrument.Id); instrument.Envelopes[envType].Length = 0; App.UndoRedoManager.EndTransaction(); ConditionalInvalidate(); } else if (subButtonType == SubButtonType.Max) { if (PlatformUtils.MessageBox($"Are you sure you want to delete '{instrument.Name}' ? All notes using this instrument will be deleted.", "Delete intrument", MessageBoxButtons.YesNo) == DialogResult.Yes) { bool selectNewInstrument = instrument == selectedInstrument; App.StopInstrumentNoteAndWait(); App.UndoRedoManager.BeginTransaction(TransactionScope.Project); App.Project.DeleteInstrument(instrument); if (selectNewInstrument) { selectedInstrument = App.Project.Instruments.Count > 0 ? App.Project.Instruments[0] : null; } SongSelected?.Invoke(selectedSong); InstrumentDeleted?.Invoke(instrument); App.UndoRedoManager.EndTransaction(); RefreshButtons(); ConditionalInvalidate(); } } } } } if (middle) { mouseLastY = e.Y; } }
public DialogResult ShowDialog(FamiStudioForm parent) { return(dialog.ShowDialog(parent)); }
public DialogResult ShowDialog() { return(dialog.ShowDialog()); }