|
|
|
|
|
| |
// / This HTML file was produced by the ProjectPublisher WebService, By Asaf Shelly / //
// / WebService URL is: http://Services.AsyncOp.com/ProjectPublisher/ProjectPublisherWSvc.asmx / //
// / Learn more and find the source code here: http://AsyncOp.com / //
using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WinUSBDeviceAPI;
namespace WinUSBDevice
{
public partial class WinUSBNotificationWindow : Form, WinUSBDeviceAPINotification
{
public WinUSBNotificationWindow()
{
InitializeComponent();
}
protected override void WndProc(ref Message msg)
{
if (winUsbDeviceApi != null) winUsbDeviceApi.WndProc(ref msg);
base.WndProc(ref msg);
}
private WinUsbDeviceApi winUsbDeviceApi = null;
public WinUsbDeviceApi WinUsbDevice { get { return winUsbDeviceApi; } }
WinUSBNotifyDevice winUSBNotifyDevice = null;
public static WinUSBNotificationWindow NotifierCreate(Guid deviceGuid, WinUSBNotifyDevice deviceEventTarget)
{
WinUSBNotificationWindow retval = new WinUSBNotificationWindow();
retval.winUSBNotifyDevice = deviceEventTarget;
retval.winUsbDeviceApi = new WinUsbDeviceApi(deviceGuid);
retval.Show();
retval.winUsbDeviceApi.Activate(retval);
retval.Hide();
return (retval);
}
public static void NotifierDestroy(ref WinUSBNotificationWindow notifierWindow)
{
if (null == notifierWindow) throw (new InvalidOperationException("WinUSBNotificationWindow.NotifierDestroy called with a null WinUSBNotificationWindow"));
notifierWindow.Show();
notifierWindow.winUsbDeviceApi.Deactivate();
notifierWindow.Hide();
notifierWindow.Close();
notifierWindow = null;
}
protected ReadCompletionDelegate[] ReadCompletion=new ReadCompletionDelegate[8];
protected WriteCompletionDelegate[] WriteCompletion=new WriteCompletionDelegate[8];
public void RegisterReadCompletion(byte endpointNumber, ReadCompletionDelegate readCompletionDelegate)
{
if ((endpointNumber < 1) || (endpointNumber > 8)) return;
ReadCompletion[endpointNumber] += readCompletionDelegate;
}
public void UnregisterReadCompletion(byte endpointNumber, ReadCompletionDelegate readCompletionDelegate)
{
if ((endpointNumber < 1) || (endpointNumber > 8)) return;
ReadCompletion[endpointNumber] -= readCompletionDelegate;
}
public void RegisterWriteCompletion(byte endpointNumber, WriteCompletionDelegate writeCompletionDelegate)
{
if ((endpointNumber < 1) || (endpointNumber > 8)) return;
WriteCompletion[endpointNumber] += writeCompletionDelegate;
}
public void UnregisterWriteCompletion(byte endpointNumber, WriteCompletionDelegate writeCompletionDelegate)
{
if ((endpointNumber < 1) || (endpointNumber > 8)) return;
WriteCompletion[endpointNumber] -= writeCompletionDelegate;
}
#region WinUSBDeviceNotification Members
public void OnDeviceAttach()
{
winUSBNotifyDevice.OnDeviceAttach();
}
public void OnDeviceDetach()
{
winUSBNotifyDevice.OnDeviceDetach();
}
public void OnReadCompletion(int ep, byte[] buffer, int lastErrorCode, object userContext)
{
if (ReadCompletion[ep] != null) ReadCompletion[ep](buffer, lastErrorCode, userContext);
}
public void OnWriteCompletion(int ep, int byteCount, int lastErrorCode, object userContext)
{
if (WriteCompletion[ep] != null) WriteCompletion[ep](byteCount, lastErrorCode, userContext);
}
#endregion
}
}
|
|
|
| |
|
|
| |
|
|
|
|
|
|