Ejemplo n.º 1
0
        /****************
        * Constructors *
        ****************/

        #region Public Constructors

        /// <summary>Initializes a new instance of the MidiSysExEventDialog class.</summary>
        /// <param name="sysExEvent">
        /// MidiSysExEvent object representing the MIDI system exclusive
        /// (SysEx) message/event to edit, or null to create a new one.
        /// </param>
        public MidiSysExEventDialog(MidiSysExEvent sysExEvent)
            : base(sysExEvent)
        {
            int i = this.ControlCount;

            /* Initialize the "Escape" check box. */
            this.EscapeCheckBox = UI.CreateCheckBox(++i, MarginType.Standard, Properties.Resources.Escape, null);

            /* Initialize the "Data" controls. */
            this.DataLabel = UI.CreateLabel(MarginType.Standard, Properties.Resources.Data, true);
            DockPanel panel = MidiEventDialog.CreateDataPanel(ref this.DataHexTextBox, ref this.DataCommentTextBox, ++i);

            this.DataHexTextBox.TextChanged   += this.DataHexTextBox_TextChanged;
            this.DataCommentTextBox.IsReadOnly = true;
            this.DataLabel.Target = this.DataHexTextBox;

            /* Build out the window and its content. */
            this.AddUIElement(this.EscapeCheckBox);
            this.AddUIElement(this.DataLabel);
            this.AddUIElement(panel);
            this.BuildOut(UI.ClientWidth, MidiSysExEventDialog.TitleString);

            /* The OK button should start out disabled and stay that way until all required input is entered. */
            this.OkButton.IsEnabled = false;

            /* If a MidiSysExEvent object was supplied, use it to set initial values. */
            if (this.ForNewItem)
            {
                return;
            }
            this.DeltaTime = sysExEvent.DeltaTime;
            this.EscapeCheckBox.IsChecked = sysExEvent.Escape;
            this.DataHexTextBox.Text      = this.Hex = Midi.FormatHex(sysExEvent.Data, 0, sysExEvent.Data.Length);
        }
Ejemplo n.º 2
0
        /****************
        * Constructors *
        ****************/

        #region Public Constructors

        /// <summary>Initializes a new instance of the MidiMetaEventDialog class.</summary>
        /// <param name="metaEvent">
        /// MidiMetaEvent object representing the MIDI meta-event to edit, or null to create a new one.
        /// </param>
        public MidiMetaEventDialog(MidiMetaEvent metaEvent)
            : base(metaEvent)
        {
            int       i = this.ControlCount;
            DockPanel typePanel, dataPanel;

            /* Initialize the "Type" controls. */
            this.TypeLabel = UI.CreateLabel(MarginType.Standard, Properties.Resources.Type, true);
            typePanel      = MidiEventDialog.CreateDataBytePanel(ref this.TypeTextBox, ref this.TypeTextBlock, ++i);
            this.TypeTextBox.TextChanged += this.TypeTextBox_TextChanged;
            this.TypeLabel.Target         = this.TypeTextBox;

            /* Initialize the "Data" controls. */
            Label label = UI.CreateLabel(MarginType.Standard, Properties.Resources.Data, true);

            dataPanel = MidiEventDialog.CreateDataPanel(ref this.DataHexTextBox, ref this.DataCommentTextBox, ++i);
            this.DataHexTextBox.TextChanged     += this.DataHexTextBox_TextChanged;
            this.DataCommentTextBox.TextChanged += this.DataCommentTextBox_TextChanged;
            label.Target = this.DataHexTextBox;

            /* Build out the window and its content. */
            this.AddUIElement(this.TypeLabel);
            this.AddUIElement(typePanel);
            this.AddUIElement(label);
            this.AddUIElement(dataPanel);
            this.BuildOut(UI.ClientWidth, MidiMetaEventDialog.TitleString);

            /* The OK button should start out disabled and stay that way until all required input is entered. */
            this.OkButton.IsEnabled = false;

            /* If a MidiMetaEvent object was supplied, use it to set initial values. */
            if (this.ForNewItem)
            {
                return;
            }
            this.DeltaTime           = metaEvent.DeltaTime;
            this.TypeTextBox.Text    = metaEvent.Type.ToString();
            this.NoValidation        = true;
            this.DataHexTextBox.Text = this.Hex = Midi.FormatHex(metaEvent.Data, 0, metaEvent.Data.Length);
            this.NoValidation        = false;
        }