Skip to content

Commit d659991

Browse files
committed
Merge branch 'main' into issue-339
2 parents b3d951f + 5f4bcb8 commit d659991

File tree

105 files changed

+15714
-4372
lines changed

Some content is hidden

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

105 files changed

+15714
-4372
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1414
<UseArtifactsOutput>true</UseArtifactsOutput>
1515
<PackageIcon>icon.png</PackageIcon>
16-
<VersionPrefix>0.6.1</VersionPrefix>
16+
<VersionPrefix>0.7.0</VersionPrefix>
1717
<VersionSuffix></VersionSuffix>
1818
<LangVersion>10.0</LangVersion>
1919
<Features>strict</Features>

OpenEphys.Onix1.Design/Bno055Dialog.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

OpenEphys.Onix1.Design/ChannelConfigurationDialog.Designer.cs

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

OpenEphys.Onix1.Design/ChannelConfigurationDialog.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace OpenEphys.Onix1.Design
1414
/// Within, there are a number of useful methods for initializing, resizing, and drawing channels.
1515
/// Each device must implement their own ChannelConfigurationDialog.
1616
/// </summary>
17-
public abstract partial class ChannelConfigurationDialog : Form
17+
public partial class ChannelConfigurationDialog : Form
1818
{
1919
internal event EventHandler OnResizeZedGraph;
2020
internal event EventHandler OnDrawProbeGroup;
@@ -25,6 +25,12 @@ public abstract partial class ChannelConfigurationDialog : Form
2525

2626
internal readonly bool[] SelectedContacts = null;
2727

28+
[Obsolete("Designer only.", true)]
29+
ChannelConfigurationDialog()
30+
{
31+
InitializeComponent();
32+
}
33+
2834
/// <summary>
2935
/// Constructs the dialog window using the given probe group, and plots all contacts after loading.
3036
/// </summary>
@@ -85,7 +91,10 @@ public ChannelConfigurationDialog(ProbeGroup probeGroup)
8591
/// </code>
8692
/// </example>
8793
/// <returns>Returns an object that inherits from <see cref="ProbeInterface.NET.ProbeGroup"/></returns>
88-
internal abstract ProbeGroup DefaultChannelLayout();
94+
internal virtual ProbeGroup DefaultChannelLayout()
95+
{
96+
throw new NotImplementedException();
97+
}
8998

9099
internal virtual void LoadDefaultChannelLayout()
91100
{

OpenEphys.Onix1.Design/CustomMessageBox.Designer.cs

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

OpenEphys.Onix1.Design/DesignHelper.cs

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using System.Windows.Forms;
6+
using System.Reflection;
67
using Newtonsoft.Json;
78

89
namespace OpenEphys.Onix1.Design
@@ -95,7 +96,7 @@ public static IEnumerable<Control> GetTopLevelControls(this Control root)
9596
/// </summary>
9697
/// <param name="thisForm"></param>
9798
/// <param name="childForm"></param>
98-
public static void AddMenuItemsFromDialogToFileOption(this Form thisForm, Form childForm)
99+
public static Form AddMenuItemsFromDialogToFileOption(this Form thisForm, Form childForm)
99100
{
100101
const string FileString = "File";
101102

@@ -130,6 +131,8 @@ public static void AddMenuItemsFromDialogToFileOption(this Form thisForm, Form c
130131
}
131132
}
132133
}
134+
135+
return thisForm;
133136
}
134137

135138
/// <summary>
@@ -139,7 +142,7 @@ public static void AddMenuItemsFromDialogToFileOption(this Form thisForm, Form c
139142
/// <param name="thisForm"></param>
140143
/// <param name="childForm"></param>
141144
/// <param name="subMenuName"></param>
142-
public static void AddMenuItemsFromDialogToFileOption(this Form thisForm, Form childForm, string subMenuName)
145+
public static Form AddMenuItemsFromDialogToFileOption(this Form thisForm, Form childForm, string subMenuName)
143146
{
144147
const string FileString = "File";
145148

@@ -181,6 +184,58 @@ public static void AddMenuItemsFromDialogToFileOption(this Form thisForm, Form c
181184

182185
thisFileMenuItem.DropDownItems.Add(newChildMenuItems);
183186
}
187+
188+
return thisForm;
189+
}
190+
191+
public static Form AddDialogToTab(this Form form, TabPage tabPage)
192+
{
193+
tabPage.Controls.Add(form);
194+
form.Show();
195+
196+
return form;
197+
}
198+
199+
public static Form AddDialogToPanel(this Form form, Panel panel)
200+
{
201+
panel.Controls.Add(form);
202+
form.Show();
203+
204+
return form;
205+
}
206+
207+
public static Form SetChildFormProperties(this Form child, Form parent)
208+
{
209+
child.TopLevel = false;
210+
child.FormBorderStyle = FormBorderStyle.None;
211+
child.Dock = DockStyle.Fill;
212+
child.Parent = parent;
213+
214+
return child;
215+
}
216+
217+
internal static readonly IEnumerable<string> PropertiesToIgnore = new[] { "DeviceName", "DeviceAddress" };
218+
219+
public static void CopyProperties<T>(T source, T target, IEnumerable<string> propertiesToIgnore = null) where T : class
220+
{
221+
if (source == null || target == null)
222+
throw new NullReferenceException("Null objects cannot have their properties copied from/to.");
223+
224+
var properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
225+
226+
propertiesToIgnore ??= Array.Empty<string>();
227+
228+
foreach (var property in properties)
229+
{
230+
if (propertiesToIgnore.Contains(property.Name))
231+
continue;
232+
233+
if (property.CanRead && property.CanWrite)
234+
{
235+
var value = property.GetValue(source);
236+
property.SetValue(target, value);
237+
}
238+
}
184239
}
185240
}
186241
}
Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
1-
using System.Windows.Forms;
1+
using System;
2+
using System.Windows.Forms;
23

34
namespace OpenEphys.Onix1.Design
45
{
56
/// <summary>
67
/// Abstract form that implements a very basic GUI consisting of a single property grid and
78
/// two buttons (OK / Cancel).
89
/// </summary>
9-
public abstract partial class GenericDeviceDialog : Form
10+
public partial class GenericDeviceDialog : Form
1011
{
12+
internal object Device
13+
{
14+
get => propertyGrid.SelectedObject;
15+
set => propertyGrid.SelectedObject = value;
16+
}
17+
1118
/// <summary>
1219
/// Initializes a new instance of <see cref="GenericDeviceDialog"/>.
1320
/// </summary>
14-
public GenericDeviceDialog()
21+
public GenericDeviceDialog(object device)
1522
{
1623
InitializeComponent();
24+
25+
Shown += FormShown;
26+
Device = device;
27+
}
28+
29+
void FormShown(object sender, EventArgs e)
30+
{
31+
if (!TopLevel)
32+
{
33+
tableLayoutPanel1.Controls.Remove(flowLayoutPanel1);
34+
tableLayoutPanel1.RowCount = 1;
35+
36+
MaximumSize = new System.Drawing.Size(0, 0);
37+
}
1738
}
1839
}
1940
}

0 commit comments

Comments
 (0)