/****************
        * 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);
        }
Beispiel #2
0
        private void DataCommentTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            /* Prevent unnecessary recursion. */
            if (this.NoValidation)
            {
                return;
            }
            this.NoValidation = true;

            /* Populate hex box based on text/character/string input. */
            int i, n = this.DataCommentTextBox.Text.Length;

            byte[] bytes = new byte[n];
            for (i = 0; i < n; ++i)
            {
                bytes[i] = (byte)this.DataCommentTextBox.Text[i];
            }
            this.DataHexTextBox.Text = Midi.FormatHex(bytes, 0, n);
            this.NoValidation        = false;
        }
Beispiel #3
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;
        }
Beispiel #4
0
 /// <summary>Represents a portion of this file's byte array in hexadecimal format.</summary>
 /// <param name="offset">Offset into the byte array at which to start reading.</param>
 /// <param name="length">The number of bytes to read.</param>
 /// <returns>Representation of the specified portion of the byte array in hexadecimal format.</returns>
 public string FormatHex(int offset, int length)
 {
     return(Midi.FormatHex(this.Bytes, offset, length));
 }