/**************** * 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); }
/**************** * 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; }
/**************** * Constructors * ****************/ #region Public Constructors /// <summary>Initializes a new instance of the MidiEventDialog class.</summary> /// <param name="channelEvent"> /// MidiChannelEvent object representing the MIDI channel message/event to edit, or null to create a new one. /// </param> public MidiChannelEventDialog(MidiChannelEvent channelEvent) : base(channelEvent) { int i = this.ControlCount; DockPanel panel1, panel2; /* Initialize the "Running status" check box. */ this.RunningStatusCheckBox = UI.CreateCheckBox(++i, MarginType.Standard, Properties.Resources.RunningStatus, null); this.RunningStatusCheckBox.Checked += this.RunningStatusCheckBox_Checked; this.RunningStatusCheckBox.Unchecked += this.RunningStatusCheckBox_Checked; /* Initialize the "Message type" label. */ this.MessageTypeLabel = UI.CreateLabel(MarginType.Standard, Properties.Resources.MessageType, true); /* Initialize the "Message type" combo box. */ this.MessageTypeComboBox = new ComboBox(); this.MessageTypeComboBox.TabIndex = ++i; this.MessageTypeComboBox.Margin = new Thickness(UI.TripleSpace, UI.HalfSpace, UI.TripleSpace, UI.UnitSpace); foreach (MidiMessageType messageType in MidiChannelEventDialog.MessageTypes) { string s = MidiChannelEvent.GetTypeComment(messageType); this.MessageTypeComboBox.Items.Add(s); } this.MessageTypeComboBox.SelectionChanged += MessageTypeComboBox_SelectionChanged; this.MessageTypeLabel.Target = this.MessageTypeComboBox; /* Initialize the "Channel" label. */ this.ChannelLabel = UI.CreateLabel(MarginType.Standard, Properties.Resources.Channel, true); /* Initialize the "Channel" text box. */ this.ChannelTextBox = new TextBox(); this.ChannelTextBox.TabIndex = ++i; this.ChannelTextBox.Margin = new Thickness(UI.TripleSpace, UI.HalfSpace, UI.TripleSpace, UI.UnitSpace); this.ChannelTextBox.TextAlignment = TextAlignment.Right; this.ChannelTextBox.GotFocus += UI.TextBox_GotFocus; this.ChannelTextBox.TextChanged += this.ChannelTextBox_TextChanged; this.ChannelLabel.Target = this.ChannelTextBox; /* Initialize the "Data 1" controls. */ this.Data1Label = UI.CreateLabel(MarginType.Standard, Properties.Resources.Data1, true); panel1 = MidiEventDialog.CreateDataBytePanel(ref this.Data1TextBox, ref this.Data1TextBlock, ++i); this.Data1TextBox.TextChanged += this.Data1TextBox_TextChanged; this.Data1Label.Target = this.Data1TextBox; /* Initialize the "Data 2" controls. */ this.Data2Label = UI.CreateLabel(MarginType.Standard, Properties.Resources.Data2, true); panel2 = MidiEventDialog.CreateDataBytePanel(ref this.Data2TextBox, ref this.Data2TextBlock, ++i); this.Data2TextBox.TextChanged += this.Data2TextBox_TextChanged; this.Data2Label.Target = this.Data2TextBox; /* Build out the window and its content. */ this.AddUIElement(this.RunningStatusCheckBox); this.AddUIElement(this.MessageTypeLabel); this.AddUIElement(this.MessageTypeComboBox); this.AddUIElement(this.ChannelLabel); this.AddUIElement(this.ChannelTextBox); this.AddUIElement(this.Data1Label); this.AddUIElement(panel1); this.AddUIElement(this.Data2Label); this.AddUIElement(panel2); this.BuildOut(MidiChannelEventDialog.ClientWidth, MidiChannelEventDialog.TitleString); /* The OK button should start out disabled and stay that way until all required input is entered. */ this.OkButton.IsEnabled = false; /* If a MidiChannelEvent object was supplied, use it to set initial values. */ if (this.ForNewItem) { return; } this.DeltaTime = channelEvent.DeltaTime; this.RunningStatusCheckBox.IsEnabled = false; this.RunningStatusCheckBox.IsChecked = channelEvent.RunningStatus; this.MessageTypeComboBox.SelectedItem = MidiChannelEvent.GetTypeComment(channelEvent.MessageType); this.ChannelTextBox.Text = channelEvent.Channel.ToString(); this.Data1TextBox.Text = channelEvent.Data1.ToString(); if (!MidiChannelEvent.HasData2(channelEvent.MessageType)) { return; } this.Data2TextBox.Text = channelEvent.Data2.ToString(); }