/// <summary> /// Creates a standard keypad effect with the specified parameters. /// </summary> /// <param name="effectType">The type of effect to create.</param> /// <param name="param">Effect-specific parameters.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> private Guid CreateKeypadEffect(Effects.Keypad.KeypadEffectType effectType, IntPtr param) { var guid = Guid.Empty; var result = _nativeSdkMethods.CreateKeypadEffect(effectType, param, ref guid); if (!result) { throw new NativeCallException("CreateKeypadEffect", result); } return(guid); }
/// <inheritdoc /> /// <summary> /// Helper method for creating keypad effects with parameter struct. /// </summary> /// <typeparam name="T">The effect struct type.</typeparam> /// <param name="effectType">The type of effect to create.</param> /// <param name="data">Effect options struct.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> public Task <Guid> CreateKeypadEffectAsync <T>(Effects.Keypad.KeypadEffectType effectType, T data) where T : struct { var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(data)); Marshal.StructureToPtr(data, ptr, false); try { return(Task.FromResult(CreateKeypadEffect(effectType, ptr))); } finally { Marshal.FreeHGlobal(ptr); } }
/// <inheritdoc /> /// <summary> /// Creates a new keypad effect with the specified effect data by sending a POST request to the keypad API. /// </summary> /// <typeparam name="T">The effect struct type.</typeparam> /// <param name="effectType">The type of effect to create.</param> /// <param name="data">Effect options struct.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> public async Task <Guid> CreateKeypadEffectAsync <T>(Effects.Keypad.KeypadEffectType effectType, T data) where T : struct { return(await CreateEffectAsync("/keypad", data).ConfigureAwait(false)); }
/// <inheritdoc /> /// <summary> /// Creates a new keypad effect without any effect data by sending a POST request to the keypad API. /// </summary> /// <param name="effectType">THe type of effect to create.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> public async Task <Guid> CreateKeypadEffectAsync(Effects.Keypad.KeypadEffectType effectType) { return(await CreateEffectAsync("/keypad", new EffectData(effectType)).ConfigureAwait(false)); }
/// <inheritdoc /> /// <summary> /// Creates a new keypad effect without any effect data. /// </summary> /// <param name="effectType">THe type of effect to create.</param> /// <returns>A <see cref="Guid" /> for the created effect.</returns> public Task <Guid> CreateKeypadEffectAsync(Effects.Keypad.KeypadEffectType effectType) { return(Task.FromResult(CreateKeypadEffect(effectType, IntPtr.Zero))); }