Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide PolledBno055 properties when embedded in a headstage #369

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OpenEphys.Onix1.Design/NeuropixelsV1eHeadstageEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public override bool EditComponent(ITypeDescriptorContext context, object compon

if (editorDialog.ShowDialog() == DialogResult.OK)
{
configureHeadstage.Bno055.Enable = editorDialog.DialogBno055.ConfigureNode.Enable;
configureHeadstage.Bno055.Enable = editorDialog.DialogBno055.Bno055.Enable;

configureHeadstage.NeuropixelsV1e.AdcCalibrationFile = editorDialog.DialogNeuropixelsV1e.ConfigureNode.AdcCalibrationFile;
configureHeadstage.NeuropixelsV1e.GainCalibrationFile = editorDialog.DialogNeuropixelsV1e.ConfigureNode.GainCalibrationFile;
Expand Down
2 changes: 1 addition & 1 deletion OpenEphys.Onix1.Design/NeuropixelsV1fHeadstageDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial class NeuropixelsV1fHeadstageDialog : Form
/// </summary>
/// <param name="configureNeuropixelsV1A">Configuration settings for <see cref="ConfigureNeuropixelsV1f"/> A.</param>
/// <param name="configureNeuropixelsV1B">Configuration settings for <see cref="ConfigureNeuropixelsV1f"/> B</param>
/// <param name="configureBno055">Configuration settings for a <see cref="PolledBno055"/>.</param>
/// <param name="configureBno055">Configuration settings for a <see cref="Onix1.PolledBno055"/>.</param>
public NeuropixelsV1fHeadstageDialog(ConfigureNeuropixelsV1f configureNeuropixelsV1A, ConfigureNeuropixelsV1f configureNeuropixelsV1B, ConfigureBno055 configureBno055)
{
InitializeComponent();
Expand Down
4 changes: 2 additions & 2 deletions OpenEphys.Onix1.Design/NeuropixelsV2eHeadstageEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public override bool EditComponent(ITypeDescriptorContext context, object compon

if (editorDialog.ShowDialog() == DialogResult.OK)
{
configureV2eHeadstage.Bno055.Enable = editorDialog.DialogBno055.ConfigureNode.Enable;
configureV2eHeadstage.Bno055.Enable = editorDialog.DialogBno055.Bno055.Enable;

configureV2eHeadstage.NeuropixelsV2e.Enable = editorDialog.DialogNeuropixelsV2e.ConfigureNode.Enable;
configureV2eHeadstage.NeuropixelsV2e.ProbeConfigurationA = editorDialog.DialogNeuropixelsV2e.ConfigureNode.ProbeConfigurationA;
Expand All @@ -40,7 +40,7 @@ public override bool EditComponent(ITypeDescriptorContext context, object compon

if (editorDialog.ShowDialog() == DialogResult.OK)
{
configureV2eBetaHeadstage.Bno055.Enable = editorDialog.DialogBno055.ConfigureNode.Enable;
configureV2eBetaHeadstage.Bno055.Enable = editorDialog.DialogBno055.Bno055.Enable;

configureV2eBetaHeadstage.NeuropixelsV2eBeta.Enable = editorDialog.DialogNeuropixelsV2e.ConfigureNode.Enable;
configureV2eBetaHeadstage.NeuropixelsV2eBeta.ProbeConfigurationA = editorDialog.DialogNeuropixelsV2e.ConfigureNode.ProbeConfigurationA;
Expand Down
45 changes: 38 additions & 7 deletions OpenEphys.Onix1.Design/PolledBno055Dialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;

namespace OpenEphys.Onix1.Design
{
Expand All @@ -11,23 +12,32 @@ public partial class PolledBno055Dialog : GenericDeviceDialog
/// Gets or sets the <see cref="ConfigurePolledBno055"/> object attached to
/// the property grid.
/// </summary>
public ConfigurePolledBno055 ConfigureNode
{
get => (ConfigurePolledBno055)propertyGrid.SelectedObject;
set => propertyGrid.SelectedObject = value;
}
internal InternalPolledBno055 Bno055 { get; set; }

/// <summary>
/// Initializes a new <see cref="PolledBno055Dialog"/> instance with the given
/// <see cref="ConfigurePolledBno055"/> object.
/// </summary>
/// <param name="configureNode">A <see cref="ConfigurePolledBno055"/> object that contains configuration settings.</param>
public PolledBno055Dialog(ConfigurePolledBno055 configureNode)
/// <param name="allFieldsEditable">
/// Boolean that is true if this <see cref="ConfigurePolledBno055"/> should be allowed to
/// edit the <see cref="ConfigurePolledBno055.AxisMap"/> and <see cref="ConfigurePolledBno055.AxisSign"/>
/// properties. It is set to false when called from headstage editors.</param>
public PolledBno055Dialog(ConfigurePolledBno055 configureNode, bool allFieldsEditable = false)
{
InitializeComponent();
Shown += FormShown;

ConfigureNode = new(configureNode);
Bno055 = new(configureNode);

if (allFieldsEditable)
{
propertyGrid.SelectedObject = Bno055.Bno055;
}
else
{
propertyGrid.SelectedObject = Bno055;
}
}

private void FormShown(object sender, EventArgs e)
Expand All @@ -41,4 +51,25 @@ private void FormShown(object sender, EventArgs e)
}
}
}

internal class InternalPolledBno055
{
[TypeConverter(typeof(PolledBno055SingleDeviceFactoryConverter))]
[Category(DeviceFactory.ConfigurationCategory)]
public ConfigurePolledBno055 Bno055 { get; set; }

public InternalPolledBno055(ConfigurePolledBno055 polledBno)
{
Bno055 = polledBno;
}

[Browsable(false)]
public bool Enable { get => Bno055.Enable; }

[Browsable(false)]
public string DeviceName { get => Bno055.DeviceName; }

[Browsable(false)]
public uint DeviceAddress { get => Bno055.DeviceAddress; }
}
}
10 changes: 6 additions & 4 deletions OpenEphys.Onix1.Design/PolledBno055Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ public override bool EditComponent(ITypeDescriptorContext context, object compon
var editorState = (IWorkflowEditorState)provider.GetService(typeof(IWorkflowEditorState));
if (editorState != null && !editorState.WorkflowRunning && component is ConfigurePolledBno055 configureBno055)
{
using var editorDialog = new PolledBno055Dialog(configureBno055);
using var editorDialog = new PolledBno055Dialog(configureBno055, true);

if (editorDialog.ShowDialog() == DialogResult.OK)
{
configureBno055.Enable = editorDialog.ConfigureNode.Enable;
configureBno055.DeviceAddress = editorDialog.ConfigureNode.DeviceAddress;
configureBno055.DeviceName = editorDialog.ConfigureNode.DeviceName;
configureBno055.Enable = editorDialog.Bno055.Enable;
configureBno055.DeviceAddress = editorDialog.Bno055.DeviceAddress;
configureBno055.DeviceName = editorDialog.Bno055.DeviceName;
configureBno055.AxisMap = editorDialog.Bno055.Bno055.AxisMap;
configureBno055.AxisSign = editorDialog.Bno055.Bno055.AxisSign;

return true;
}
Expand Down
3 changes: 3 additions & 0 deletions OpenEphys.Onix1/ConfigurePolledBno055.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("OpenEphys.Onix1.Design")]

namespace OpenEphys.Onix1
{
Expand Down