Skip to content

Commit bb9470b

Browse files
committed
Refactor dialogs
- Allow inherited dialogs to render in designer - Refactor dialog initialization to streamline child form properties and enhance readability - Use reflection to copy properties automatically
1 parent aa970af commit bb9470b

36 files changed

+677
-393
lines changed

OpenEphys.Onix1.Design/Bno055Dialog.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,8 @@ public ConfigureBno055 ConfigureNode
2323
public Bno055Dialog(ConfigureBno055 configureNode)
2424
{
2525
InitializeComponent();
26-
Shown += FormShown;
2726

2827
ConfigureNode = new(configureNode);
2928
}
30-
31-
private void FormShown(object sender, EventArgs e)
32-
{
33-
if (!TopLevel)
34-
{
35-
tableLayoutPanel1.Controls.Remove(flowLayoutPanel1);
36-
tableLayoutPanel1.RowCount = 1;
37-
38-
MaximumSize = new System.Drawing.Size(0, 0);
39-
}
40-
}
4129
}
4230
}

OpenEphys.Onix1.Design/Bno055Editor.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,22 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide
2626
var editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
2727
var editorState = (IWorkflowEditorState)provider.GetService(typeof(IWorkflowEditorState));
2828

29-
ConfigureBno055 configureBno055;
29+
ConfigureBno055 configureNode;
3030

3131
if (context.Instance.GetType() == typeof(ConfigureBno055))
32-
configureBno055 = (ConfigureBno055)context.Instance;
32+
configureNode = (ConfigureBno055)context.Instance;
3333
else if (value.GetType() == typeof(ConfigureBno055))
34-
configureBno055 = (ConfigureBno055)value;
34+
configureNode = (ConfigureBno055)value;
3535
else
3636
throw new Exception("Invalid input given to Bno055Editor.");
3737

3838
if (editorService != null && editorState != null && !editorState.WorkflowRunning)
3939
{
40-
using var editorDialog = new Bno055Dialog(configureBno055);
40+
using var editorDialog = new Bno055Dialog(configureNode);
4141

4242
if (editorDialog.ShowDialog() == DialogResult.OK)
4343
{
44-
configureBno055.Enable = editorDialog.ConfigureNode.Enable;
45-
configureBno055.DeviceAddress = editorDialog.ConfigureNode.DeviceAddress;
46-
configureBno055.DeviceName = editorDialog.ConfigureNode.DeviceName;
44+
DesignHelper.CopyProperties(editorDialog.ConfigureNode, configureNode);
4745
}
4846
}
4947
}

OpenEphys.Onix1.Design/ChannelConfigurationDialog.Designer.cs

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)