using VoiceCat.Interop; namespace VoiceCat.App.Forms; /// /// Per-remote-user gain, mute, and noise reduction settings. /// Changes are applied in real-time as the user adjusts controls — no OK/Cancel round-trip /// for gain and mute (the close button just dismisses). The settings live in the core and /// are not persisted across sessions. /// public sealed class PerUserTuningDialog : Form { private readonly VoiceCatClient _client; private readonly uint _userId; private readonly TrackBar _trkGain; private readonly Label _lblGainValue; private readonly CheckBox _chkMute; private readonly CheckBox _chkNr; public PerUserTuningDialog(VoiceCatClient client, uint userId, string nickname) { _client = client; _userId = userId; // ── Controls ────────────────────────────────────────────────────────── var lblTitle = new Label { Text = $"Settings for {nickname}", AutoSize = true, Font = new Font(Font, FontStyle.Bold), Location = new Point(12, 12), TabIndex = 0, }; var lblGainLabel = new Label { Text = "&Gain:", AutoSize = true, Location = new Point(12, 46), TabIndex = 1, }; _trkGain = new TrackBar { AccessibleName = "Gain", AccessibleDescription = "Volume level for this user. 100 is normal (1.0×), 200 is double.", Location = new Point(55, 38), Size = new Size(220, 45), Minimum = 0, Maximum = 200, Value = 100, TickFrequency = 25, SmallChange = 5, LargeChange = 25, TabIndex = 2, }; _lblGainValue = new Label { Text = "100% (1.0×)", AutoSize = true, Location = new Point(280, 46), TabIndex = 3, }; _chkMute = new CheckBox { Text = "&Mute this user", AutoSize = true, Location = new Point(12, 92), TabIndex = 4, }; _chkNr = new CheckBox { Text = "&Noise reduction (planned — currently passthrough)", AutoSize = true, Location = new Point(12, 118), TabIndex = 5, }; var btnClose = new Button { Text = "&Close", DialogResult = DialogResult.OK, Location = new Point(296, 152), Size = new Size(75, 27), TabIndex = 6, }; // ── Wire events ─────────────────────────────────────────────────────── _trkGain.Scroll += (_, _) => { float gain = _trkGain.Value / 100f; _lblGainValue.Text = $"{_trkGain.Value}% ({gain:F1}×)"; ApplySettings(); }; _chkMute.CheckedChanged += (_, _) => ApplySettings(); _chkNr.CheckedChanged += (_, _) => ApplySettings(); // ── Form ────────────────────────────────────────────────────────────── AcceptButton = btnClose; AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(384, 192); Controls.AddRange([lblTitle, lblGainLabel, _trkGain, _lblGainValue, _chkMute, _chkNr, btnClose]); FormBorderStyle = FormBorderStyle.FixedDialog; MaximizeBox = false; MinimizeBox = false; StartPosition = FormStartPosition.CenterParent; Text = $"User settings — {nickname}"; } private void ApplySettings() { float gain = _trkGain.Value / 100f; bool muted = _chkMute.Checked; bool nr = _chkNr.Checked; // Apply to all of this user's streams var streams = _client.ListUserStreams(_userId); foreach (var s in streams) _client.SetRemoteStream(_userId, s.StreamId, gain, muted, nr); } }