From ac1a5bcec60ba86ba0e5042a2c84d863b322ee54 Mon Sep 17 00:00:00 2001 From: bparks13 Date: Tue, 12 Nov 2024 14:49:21 -0500 Subject: [PATCH] Account for multiple probes when grabbing contact index --- .../ChannelConfigurationDialog.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/OpenEphys.Onix1.Design/ChannelConfigurationDialog.cs b/OpenEphys.Onix1.Design/ChannelConfigurationDialog.cs index 850f577..aa4100b 100644 --- a/OpenEphys.Onix1.Design/ChannelConfigurationDialog.cs +++ b/OpenEphys.Onix1.Design/ChannelConfigurationDialog.cs @@ -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); } @@ -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)