using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; using Robust.Shared.Input; namespace Content.Client.Instruments.UI; [GenerateTypedNameReferences] public sealed partial class ChannelItem : Control { /// /// Raised when a channel is toggled by the user. /// public event Action? SwitchFilteredChannel; /// /// MIDI channel ID this item is assigned to. /// public int ChannelId { get; set { field = value; ChannelNumberLabel.Text = (value + 1).ToString(); } } /// /// UI state (on/off) of this channel item. /// public bool ChannelState { get => ChannelEnableSwitchButton.Pressed; set => ChannelEnableSwitchButton.Pressed = value; } /// /// Name of this channel item in the UI. /// public string? ChannelName { get => ChannelNameLabel.Text; set => ChannelNameLabel.Text = value; } public ChannelItem() { RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); ChannelEnableSwitchButton.OnPressed += OnChannelEnableSwitchButtonPressed; MouseFilter = MouseFilterMode.Stop; } protected override void KeyBindUp(GUIBoundKeyEventArgs args) { base.KeyBindUp(args); if (args.Function != EngineKeyFunctions.UIClick) return; ChannelState = !ChannelState; SwitchFilteredChannel?.Invoke(ChannelId, ChannelState); } private void OnChannelEnableSwitchButtonPressed(BaseButton.ButtonEventArgs obj) { SwitchFilteredChannel?.Invoke(ChannelId, ChannelState); } }