Skip to content

Commit e5e5a97

Browse files
authored
Merge pull request #231 from open-ephys/issue-106-gui
Add GUI for Neuropixels V1e
2 parents 79e3842 + a9236bc commit e5e5a97

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+6244
-153
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PackageIcon>icon.png</PackageIcon>
1616
<VersionPrefix>0.2.0</VersionPrefix>
1717
<VersionSuffix></VersionSuffix>
18-
<LangVersion>9.0</LangVersion>
18+
<LangVersion>10.0</LangVersion>
1919
<Features>strict</Features>
2020
</PropertyGroup>
2121

OpenEphys.Onix1.Design/Bno055Dialog.Designer.cs

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
3+
namespace OpenEphys.Onix1.Design
4+
{
5+
/// <summary>
6+
/// Simple dialog that attaches the <see cref="ConfigureBno055"/> to a property grid.
7+
/// </summary>
8+
public partial class Bno055Dialog : GenericDeviceDialog
9+
{
10+
/// <summary>
11+
/// Gets or sets the <see cref="ConfigureBno055"/>, allowing for changes made in the dialog to be reflected in the main editor.
12+
/// </summary>
13+
public ConfigureBno055 ConfigureNode
14+
{
15+
get => (ConfigureBno055)propertyGrid.SelectedObject;
16+
set => propertyGrid.SelectedObject = value;
17+
}
18+
19+
/// <summary>
20+
/// Initializes a new dialog for the <see cref="ConfigureBno055"/> operator.
21+
/// </summary>
22+
/// <param name="configureNode"></param>
23+
public Bno055Dialog(ConfigureBno055 configureNode)
24+
{
25+
InitializeComponent();
26+
Shown += FormShown;
27+
28+
ConfigureNode = new(configureNode);
29+
}
30+
31+
private void FormShown(object sender, EventArgs e)
32+
{
33+
if (!TopLevel)
34+
{
35+
splitContainer1.Panel2Collapsed = true;
36+
splitContainer1.Panel2.Hide();
37+
38+
MaximumSize = new System.Drawing.Size(0, 0);
39+
}
40+
}
41+
}
42+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Bonsai.Design;
2+
using System.ComponentModel;
3+
using System.Windows.Forms;
4+
using System;
5+
6+
namespace OpenEphys.Onix1.Design
7+
{
8+
/// <summary>
9+
/// Class that opens a new dialog for a <see cref="ConfigureBno055"/>.
10+
/// </summary>
11+
public class Bno055Editor : WorkflowComponentEditor
12+
{
13+
/// <inheritdoc/>
14+
public override bool EditComponent(ITypeDescriptorContext context, object component, IServiceProvider provider, IWin32Window owner)
15+
{
16+
if (provider != null)
17+
{
18+
var editorState = (IWorkflowEditorState)provider.GetService(typeof(IWorkflowEditorState));
19+
if (editorState != null && !editorState.WorkflowRunning && component is ConfigureBno055 configureBno055)
20+
{
21+
using var editorDialog = new Bno055Dialog(configureBno055);
22+
23+
if (editorDialog.ShowDialog() == DialogResult.OK)
24+
{
25+
configureBno055.Enable = editorDialog.ConfigureNode.Enable;
26+
27+
return true;
28+
}
29+
}
30+
}
31+
32+
return false;
33+
}
34+
}
35+
}

OpenEphys.Onix1.Design/ChannelConfigurationDialog.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public ChannelConfigurationDialog(ProbeGroup probeGroup)
4444

4545
SelectedContacts = new bool[ChannelConfiguration.NumberOfContacts];
4646

47+
ReferenceContacts = new List<int>();
48+
4749
zedGraphChannels.MouseDownEvent += MouseDownEvent;
4850
zedGraphChannels.MouseMoveEvent += MouseMoveEvent;
4951
zedGraphChannels.MouseUpEvent += MouseUpEvent;
@@ -630,10 +632,34 @@ internal virtual void HighlightEnabledContacts()
630632

631633
foreach (var contact in contactsToEnable)
632634
{
633-
var tag = (ContactTag)contact.Tag;
635+
contact.Fill.Color = EnabledContactFill;
636+
}
637+
}
638+
639+
HighlightReferenceContacts();
640+
}
634641

635-
contact.Fill.Color = ReferenceContacts.Any(x => x == tag.ContactIndex) ? ReferenceContactFill : EnabledContactFill;
642+
internal void HighlightReferenceContacts()
643+
{
644+
if (ChannelConfiguration == null)
645+
return;
646+
647+
var contactObjects = zedGraphChannels.GraphPane.GraphObjList.OfType<BoxObj>()
648+
.Where(c => c is not PolyObj);
649+
650+
var referenceContacts = contactObjects.Where(c =>
651+
{
652+
if (c.Tag is ContactTag tag)
653+
{
654+
return ReferenceContacts.Any(r => tag.ContactIndex == r);
636655
}
656+
657+
return false;
658+
});
659+
660+
foreach (var contact in referenceContacts)
661+
{
662+
contact.Fill.Color = ReferenceContactFill;
637663
}
638664
}
639665

@@ -1079,7 +1105,6 @@ private bool MouseMoveEvent(ZedGraphControl sender, MouseEventArgs e)
10791105
private bool MouseUpEvent(ZedGraphControl sender, MouseEventArgs e)
10801106
{
10811107
sender.Cursor = Cursors.Arrow;
1082-
10831108
if (e.Button == MouseButtons.Left)
10841109
{
10851110
if (sender.GraphPane.GraphObjList[SelectionAreaTag] is BoxObj selectionArea && selectionArea != null && ChannelConfiguration != null)
@@ -1095,7 +1120,6 @@ private bool MouseUpEvent(ZedGraphControl sender, MouseEventArgs e)
10951120
{
10961121
var x = c.Location.X + c.Location.Width / 2;
10971122
var y = c.Location.Y - c.Location.Height / 2;
1098-
10991123
return c is not PolyObj &&
11001124
x >= rect.X &&
11011125
x <= rect.X + rect.Width &&

OpenEphys.Onix1.Design/ContactTag.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22

33
namespace OpenEphys.Onix1.Design
44
{

OpenEphys.Onix1.Design/DesignHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;

OpenEphys.Onix1.Design/NeuropixelsV1eBno055Dialog.Designer.cs

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
3+
namespace OpenEphys.Onix1.Design
4+
{
5+
/// <summary>
6+
/// Partial class to create a GUI for <see cref="ConfigureNeuropixelsV1eBno055"/>.
7+
/// </summary>
8+
public partial class NeuropixelsV1eBno055Dialog : GenericDeviceDialog
9+
{
10+
/// <summary>
11+
/// Gets or sets the <see cref="ConfigureNeuropixelsV1eBno055"/> object attached to
12+
/// the property grid.
13+
/// </summary>
14+
public ConfigureNeuropixelsV1eBno055 ConfigureNode
15+
{
16+
get => (ConfigureNeuropixelsV1eBno055)propertyGrid.SelectedObject;
17+
set => propertyGrid.SelectedObject = value;
18+
}
19+
20+
/// <summary>
21+
/// Initializes a new <see cref="NeuropixelsV1eBno055Dialog"/> instance with the given
22+
/// <see cref="ConfigureNeuropixelsV1eBno055"/> object.
23+
/// </summary>
24+
/// <param name="configureNode">A <see cref="ConfigureNeuropixelsV1eBno055"/> object that contains configuration settings.</param>
25+
public NeuropixelsV1eBno055Dialog(ConfigureNeuropixelsV1eBno055 configureNode)
26+
{
27+
InitializeComponent();
28+
Shown += FormShown;
29+
30+
ConfigureNode = new(configureNode);
31+
}
32+
33+
private void FormShown(object sender, EventArgs e)
34+
{
35+
if (!TopLevel)
36+
{
37+
splitContainer1.Panel2Collapsed = true;
38+
splitContainer1.Panel2.Hide();
39+
}
40+
}
41+
}
42+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.ComponentModel;
3+
using Bonsai.Design;
4+
using System.Windows.Forms;
5+
6+
namespace OpenEphys.Onix1.Design
7+
{
8+
internal class NeuropixelsV1eBno055Editor : WorkflowComponentEditor
9+
{
10+
public override bool EditComponent(ITypeDescriptorContext context, object component, IServiceProvider provider, IWin32Window owner)
11+
{
12+
if (provider != null)
13+
{
14+
var editorState = (IWorkflowEditorState)provider.GetService(typeof(IWorkflowEditorState));
15+
if (editorState != null && !editorState.WorkflowRunning && component is ConfigureNeuropixelsV1eBno055 configureBno055)
16+
{
17+
using var editorDialog = new NeuropixelsV1eBno055Dialog(configureBno055);
18+
19+
if (editorDialog.ShowDialog() == DialogResult.OK)
20+
{
21+
configureBno055.Enable = editorDialog.ConfigureNode.Enable;
22+
23+
return true;
24+
}
25+
}
26+
}
27+
28+
return false;
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)