
M74050
1/4M IMAGING SPECTROGRAPHS
63
18.3 C# USERS
This demonstrates how to call the DLL in C# .NET.
Below the code is how to add a DLL Reference to a .NET project.
Summary:
1. Add Code Reference to both the Cornerstone DLL and the CyUSB (Cypress) DLL
2.
In the Form Designer file {Form.D} add the ‘using’ sections
3. {Form.D} Create new Cornerstone object
4. {Form.D} (optional)
Changes to (Form Designer) file:
//…
using CyUSB;
using CornerstoneDll;
namespace CornerstoneApp
{
partial class MainForm
{
/// <summary>
//….
USBDeviceList usbDevices;
CyUSBDevice cornerstone;
Cornerstone cs = new Cornerstone(true);
Int32 deviceCount = 0;
public MainForm()
{
InitializeComponent();
// This is C# standard form init function
connect();
usbDevices.DeviceAt= new EventHandler(usbDevices_DeviceAttached);
usbDevices.DeviceR= new EventHandler(usbDevices_DeviceRemoved)
}
/// These two functions below handle dynamic USB plug and unplug events
void usbDevices_DeviceRemoved(object sender, EventArgs e)
{
USBEventArgs usbEvent = e as USBEventArgs;