/// <summary> /// Enumerate all currently attached DirectOutput devices. /// </summary> /// <param name="callback">Callback delegate to be called for each detected device.</param> /// <remarks> /// This function has changed from previous releases. /// </remarks> /// <exception cref="HResultException"></exception> public void Enumerate(EnumerateCallback callback) { HResult retVal = enumerate(callback, new IntPtr()); if (retVal != HResultException.S_OK) { Dictionary <HResult, String> errorsMap = new Dictionary <HResult, String>() { { HResultException.E_HANDLE, "DirectOutput was not initialized." } }; throw new HResultException(retVal, errorsMap); } }
public void Enumerate(string dirName, EnumerateCallback callback) { if (callback == null) { throw new ArgumentNullException(nameof(callback)); } // Interop callback wrapper PHYSFS_EnumerateCallbackResult enumerateCallback(IntPtr data, string origDir, string fname) { return(callback(origDir, fname)); } int ret = Interop.PHYSFS_enumerate(dirName, enumerateCallback, d: IntPtr.Zero); CheckReturnValue(ret); }
public static ReturnValues Enumerate(EnumerateCallback pfnCallback) { return((ReturnValues)DirectOutput_Enumerate(pfnCallback, IntPtr.Zero)); }
static extern IntPtr DirectOutput_Enumerate([MarshalAs(UnmanagedType.FunctionPtr)] EnumerateCallback pfnCallback, IntPtr pvParam);
public PHYSFS_EnumerateCallbackResult Enumerate(ref TestData data, string dirname, EnumerateCallback callback, string origDir) { Debug.WriteLine("enumerating"); return(PHYSFS_EnumerateCallbackResult.PHYSFS_ENUM_STOP); }
/// <summary> /// This method registers the following delegate: /// /// <code> /// public delegate void EnumerateCallback(string uid, string name, byte stackID, bool isNew) /// </code> /// /// The callback receives four parameters: /// /// <code> /// * *uid*: The UID of the device. /// * *name*: The name of the device (includes "Brick" or "Bricklet" and a version number). /// * *stackID*: The stack ID of the device (you can find out the position in a stack with this). /// * *isNew*: True if the device is added, false if it is removed. /// </code> /// /// There are three different possibilities for the callback to be called. /// Firstly, the callback is called with all currently available devices in the /// IP connection (with *isNew* true). Secondly, the callback is called if /// a new Brick is plugged in via USB (with *isNew* true) and lastly it is /// called if a Brick is unplugged (with *isNew* false). /// /// It should be possible to implement "plug 'n play" functionality with this /// (as is done in Brick Viewer). /// </summary> public void Enumerate(EnumerateCallback enumerateCallback) { this.enumerateCallback = enumerateCallback; byte[] data = new byte[4]; LEConverter.To(BROADCAST_ADDRESS, 0, data); LEConverter.To(FUNCTION_ENUMERATE, 1, data); LEConverter.To((ushort)4, 2, data); Write(data); }