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 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(); } } } } } }
protected override void OnMouseDoubleClick(MouseEventArgs e) { base.OnMouseDoubleClick(e); var buttonIndex = (e.Y + scrollY) / ButtonSizeY; var songIndex = buttonIndex - 1; var instrumentIndex = buttonIndex - (App.Project.Songs.Count + 2); if (songIndex >= 0 && songIndex < App.Project.Songs.Count) { var song = App.Project.Songs[songIndex]; var dlg = new SongEditDialog(song) { StartPosition = FormStartPosition.Manual, Location = PointToScreen(new System.Drawing.Point(e.X - 210, e.Y)) }; if (dlg.ShowDialog() == DialogResult.OK) { App.UndoRedoManager.BeginTransaction(TransactionScope.Project); App.Stop(); App.Seek(0); if (App.Project.RenameSong(song, dlg.NewName)) { song.Color = dlg.NewColor; song.Tempo = dlg.NewTempo; song.Speed = dlg.NewSpeed; song.Length = dlg.NewSongLength; song.PatternLength = dlg.NewPatternLength; song.BarLength = dlg.NewBarLength; ConditionalInvalidate(); SongModified?.Invoke(song); } App.UndoRedoManager.EndTransaction(); } } else if (instrumentIndex > 0 && instrumentIndex <= App.Project.Instruments.Count) { var instrument = App.Project.Instruments[instrumentIndex - 1]; var shiftY = (buttonIndex * ButtonSizeY - scrollY); var volRect = GetButtonRect(4, shiftY); if (e.X < volRect.Left) { var dlg = new RenameColorDialog(instrument.Name, instrument.Color) { StartPosition = FormStartPosition.Manual, Location = PointToScreen(new System.Drawing.Point(e.X - 160, e.Y)) }; if (dlg.ShowDialog() == DialogResult.OK) { App.UndoRedoManager.BeginTransaction(TransactionScope.Project); if (App.Project.RenameInstrument(instrument, dlg.NewName)) { instrument.Color = dlg.NewColor; InstrumentColorChanged?.Invoke(instrument); ConditionalInvalidate(); } App.UndoRedoManager.EndTransaction(); } } } }