IF ELSE question

Consider the following setup:

3 lights, 3 circuits, all connected to a different relays.

2 buttons.

On the press of button 1 I want lights A and B to come on.

On the press of button 2 I want lights B and C to come on.

BUT

When I press button 1 again, to turn off the lights, and button 2 was pressed in the meantime (i.e. B and C are on), then only light A should turn of.

So in pseudo code:

[code]
//I have a C# background…
button1.OnPress(() =>
{
if (turnOn) { /* */ }
else
{
if (!lightC.IsOn)
{
lightB.TurnOff(); // only turn off lightB when C is not on.
}

    // always turn off light A
    lightA.TurnOff();
}

});[/code]

This is not a direct answer to the question, but concerns a similar problem, maybe it can serve as inspiration?