Here's a small example (I'm blind coding, it might have some syntax error): For Channel, you need to raise an event whenever the checkbox is checked:
public event SoloChangedHandler SoloChanged; // Your event
public delegate void SoloChangedHandler(Channel sender); // Your event delegate
private void OnSoloChanged()
{
if (SoloChanged != null)
SoloChanged(this);
}
private void chkSolo_Checked(object sender, EventArgs e)
{
OnSoloChanged(); //Raise your event
}
public bool IsSolo
{
get { return chkSolo.Checked; }
set { chkSolo.Checked = value; }
}
For Mixer, you need to either keep a reference on the selected Channel, or the index, or both:
private int selectedIndex = -1;
private Channel selectedChannel;
private void ctrlSolo_SoloChanged(Channel sender)
{
if (sender.IsSolo)
{
this.selectedIndex = this.Controls.GetChildIndex(sender);
this.selectedChannel = sender;
foreach (Channel channel in this.Controls)
{
if (channel != sender)
{
channel.IsSolo = false; //Or you can move this to the Channel control, set it to false whenever mute is true
channel.IsMute = true;
}
}
}
else
{
this.selectedIndex = -1;
this.selectedChannel = null;
foreach (Channel channel in this.Controls)
{
channel.IsSolo = false;
channel.IsMute = false;
}
}
}
That's it. Now you just need to add properties to access the collection of Channels, the SelectedIndex, and the SelectedChannel. Hope that helps! Edbert Sydney, Australia