From 8095492aac6408c5bfb8328c60b9a0dc1ed69f8a Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Fri, 25 Sep 2020 16:10:08 -0400 Subject: [PATCH] remove NotePropertiesDialog in favor of using SettingsDialog --- .../Dialogs/NotePropertiesDialog.cs | 73 ------------------- .../Views/PianoRoll/PianoRollView.cs | 41 +++++------ ...or.Plugins.Multimedia.UserInterface.csproj | 2 - 3 files changed, 18 insertions(+), 98 deletions(-) delete mode 100644 Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/Editors/Multimedia/Audio/Synthesized/Dialogs/NotePropertiesDialog.cs diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/Editors/Multimedia/Audio/Synthesized/Dialogs/NotePropertiesDialog.cs b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/Editors/Multimedia/Audio/Synthesized/Dialogs/NotePropertiesDialog.cs deleted file mode 100644 index ce2d58f8..00000000 --- a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/Editors/Multimedia/Audio/Synthesized/Dialogs/NotePropertiesDialog.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -// NotePropertiesDialog.cs - provides a UWT Dialog that modifies the properties of a SynthesizedAudioCommandNote -// -// Author: -// Mike Becker -// -// Copyright (c) 2019-2020 Mike Becker -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using MBS.Framework.UserInterface; -using MBS.Framework.UserInterface.Controls; -using MBS.Framework.UserInterface.Layouts; -using UniversalEditor.ObjectModels.Multimedia.Audio.Synthesized; - -namespace UniversalEditor.Editors.Multimedia.Audio.Synthesized.Dialogs -{ - /// - /// Provides a UWT -based that modifies the properties of a - /// . - /// - [ContainerLayout("~/Editors/Multimedia/Synthesized/Dialogs/NotePropertiesDialog.glade")] - public class NotePropertiesDialog : CustomDialog - { - private TextBox txtNoteValue; - private TextBox txtLyric; - private TextBox txtPhoneme; - private NumericTextBox txtNoteOn; - private NumericTextBox txtNoteOff; - - private Button cmdOK; - - public string Lyric { get; set; } = null; - public string Phoneme { get; set; } = null; - public double NoteOn { get; set; } = 0.0; - public double NoteOff { get; set; } = 0.0; - - protected override void OnCreated(EventArgs e) - { - base.OnCreated(e); - DefaultButton = cmdOK; - - txtLyric.Text = Lyric; - txtPhoneme.Text = Phoneme; - txtNoteOn.Value = NoteOn; - txtNoteOff.Value = NoteOff; - } - - [EventHandler(nameof(cmdOK), "Click")] - private void cmdOK_Click(object sender, EventArgs e) - { - Lyric = txtLyric.Text; - Phoneme = txtPhoneme.Text; - NoteOn = txtNoteOn.Value; - NoteOff = txtNoteOff.Value; - - DialogResult = DialogResult.OK; - Close(); - } - } -} diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/Editors/Multimedia/Audio/Synthesized/Views/PianoRoll/PianoRollView.cs b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/Editors/Multimedia/Audio/Synthesized/Views/PianoRoll/PianoRollView.cs index 6dda366a..f3ce0fb8 100644 --- a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/Editors/Multimedia/Audio/Synthesized/Views/PianoRoll/PianoRollView.cs +++ b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/Editors/Multimedia/Audio/Synthesized/Views/PianoRoll/PianoRollView.cs @@ -26,12 +26,12 @@ using System.Linq; using MBS.Framework.Drawing; using MBS.Framework.UserInterface; using MBS.Framework.UserInterface.Controls; +using MBS.Framework.UserInterface.Dialogs; using MBS.Framework.UserInterface.Drawing; using MBS.Framework.UserInterface.Input.Keyboard; using MBS.Framework.UserInterface.Input.Mouse; using MBS.Framework.UserInterface.Layouts; -using UniversalEditor.Editors.Multimedia.Audio.Synthesized.Dialogs; using UniversalEditor.ObjectModels.Multimedia.Audio.Synthesized; using UniversalEditor.UserInterface; @@ -739,18 +739,6 @@ namespace UniversalEditor.Editors.Multimedia.Audio.Synthesized.Views.PianoRoll { SynthesizedAudioCommandNote note = (cmd as SynthesizedAudioCommandNote); LyricEditNote(note); - - // ShowNotePropertiesDialog(note); - /* - txtLyric.Location = rect.Location; - txtLyric.Size = rect.Size; - txtLyric.Text = note.Lyric; - - txtLyric.Enabled = true; - txtLyric.Visible = true; - - txtLyric.Focus(); - */ } } } @@ -777,20 +765,27 @@ namespace UniversalEditor.Editors.Multimedia.Audio.Synthesized.Views.PianoRoll if (note == null) return; - // FIXME: ParentWindow is null, probably because this isn't a "normal" parented control but rather it's inside a DockingWindow... - NotePropertiesDialog dlg = new NotePropertiesDialog(); - dlg.Lyric = note.Lyric; - dlg.Phoneme = note.Phoneme; - dlg.NoteOn = (double)note.Position; - dlg.NoteOff = note.Position + note.Length; + SettingsDialog dlg = new SettingsDialog(new SettingsProvider[] + { + new CustomSettingsProvider(new SettingsGroup[] + { + new SettingsGroup("General", new Setting[] + { + new TextSetting("Lyric", "_Lyric", note.Lyric), + new TextSetting("Phoneme", "_Phoneme", note.Phoneme), + new RangeSetting("NoteOn", "Note o_n", note.Position), + new RangeSetting("NoteOff", "Note o_ff", (decimal)(note.Position + note.Length)) + }) + }) + }); if (dlg.ShowDialog(ParentWindow) == DialogResult.OK) { ((Parent as PianoRollView).Parent as Editor).BeginEdit(); - note.Lyric = dlg.Lyric; - note.Phoneme = dlg.Phoneme; - note.Position = (int)dlg.NoteOn; - note.Length = dlg.NoteOff - dlg.NoteOn; + note.Lyric = dlg.SettingsProviders[0].SettingsGroups[0].Settings[0].GetValue(); + note.Phoneme = dlg.SettingsProviders[0].SettingsGroups[0].Settings[1].GetValue(); + note.Position = (int)dlg.SettingsProviders[0].SettingsGroups[0].Settings[2].GetValue(); + note.Length = (double)(dlg.SettingsProviders[0].SettingsGroups[0].Settings[3].GetValue() - dlg.SettingsProviders[0].SettingsGroups[0].Settings[2].GetValue()); ((Parent as PianoRollView).Parent as Editor).EndEdit(); } diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface.csproj b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface.csproj index c04db7ad..9dbdb13c 100644 --- a/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface.csproj +++ b/Plugins.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface/UniversalEditor.Plugins.Multimedia.UserInterface.csproj @@ -46,7 +46,6 @@ - @@ -72,7 +71,6 @@ -