Skip to content

Commit

Permalink
Account for multiple probes when grabbing contact index
Browse files Browse the repository at this point in the history
  • Loading branch information
bparks13 committed Nov 12, 2024
1 parent 61483a1 commit ac1a5bc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions OpenEphys.Onix1.Design/ChannelConfigurationDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,13 +1270,16 @@ private void ToggleSelectedContact(ContactTag tag)
SetSelectedContact(tag, !GetContactStatus(tag));
}

private int GetContactIndex(ContactTag tag)
{
return tag.ProbeIndex == 0
? tag.ContactIndex
: tag.ContactIndex + ProbeGroup.Probes.Take(tag.ProbeIndex).Aggregate(0, (total, next) => total + next.NumberOfContacts);
}

private void SetSelectedContact(ContactTag contactTag, bool status)
{
var index = contactTag.ProbeIndex == 0
? contactTag.ContactIndex
: contactTag.ContactIndex + ProbeGroup.Probes
.Take(contactTag.ProbeIndex)
.Aggregate(0, (total, next) => total + next.NumberOfContacts);
var index = GetContactIndex(contactTag);

SetSelectedContact(index, status);
}
Expand All @@ -1303,7 +1306,9 @@ private bool GetContactStatus(ContactTag tag)
MessageBox.Show($"Error: Attempted to check status of an object that is not a contact.", "Invalid Object Selected");
}

return SelectedContacts[tag.ContactIndex];
var index = GetContactIndex(tag);

return SelectedContacts[index];
}

private static PointD TransformPixelsToCoordinates(Point pixels, GraphPane graphPane)
Expand Down

0 comments on commit ac1a5bc

Please sign in to comment.