Ejemplo n.º 1
0
        /// <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);
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public static ReturnValues Enumerate(EnumerateCallback pfnCallback)
 {
     return((ReturnValues)DirectOutput_Enumerate(pfnCallback, IntPtr.Zero));
 }
Ejemplo n.º 4
0
 static extern IntPtr DirectOutput_Enumerate([MarshalAs(UnmanagedType.FunctionPtr)] EnumerateCallback pfnCallback, IntPtr pvParam);
Ejemplo n.º 5
0
 public PHYSFS_EnumerateCallbackResult Enumerate(ref TestData data, string dirname, EnumerateCallback callback, string origDir)
 {
     Debug.WriteLine("enumerating");
     return(PHYSFS_EnumerateCallbackResult.PHYSFS_ENUM_STOP);
 }
Ejemplo n.º 6
0
 /// <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);
 }