Exemplo n.º 1
0
        /// <summary>
        /// Creates a standard mouse effect with the specified parameters.
        /// </summary>
        /// <param name="effectType">The type of effect to create.</param>
        /// <param name="param">Context-sensitive effect parameter.</param>
        /// <returns>A <see cref="Guid" /> for the created effect.</returns>
        /// <seealso cref="NativeSdkMethods.CreateMouseEffect" />
        private Guid CreateMouseEffect(Effects.Mouse.MouseEffectType effectType, IntPtr param)
        {
            var guid   = Guid.Empty;
            var result = _nativeSdkMethods.CreateMouseEffect(effectType, param, ref guid);

            if (!result)
            {
                throw new NativeCallException("CreateMouseEffect", result);
            }
            return(guid);
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        /// <summary>
        /// Helper method for creating mouse 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> CreateMouseEffectAsync <T>(Effects.Mouse.MouseEffectType effectType, T data) where T : struct
        {
            var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(data));

            Marshal.StructureToPtr(data, ptr, false);
            try
            {
                return(Task.FromResult(CreateMouseEffect(effectType, ptr)));
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }
        }
Exemplo n.º 3
0
 /// <inheritdoc />
 /// <summary>
 /// Creates a new mouse effect with the specified effect data by sending a POST request to the mouse 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> CreateMouseEffectAsync <T>(Effects.Mouse.MouseEffectType effectType, T data) where T : struct
 {
     return(await CreateEffectAsync("/mouse", data).ConfigureAwait(false));
 }
Exemplo n.º 4
0
 /// <inheritdoc />
 /// <summary>
 /// Creates a new mouse effect without any effect data by sending a POST request to the mouse 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> CreateMouseEffectAsync(Effects.Mouse.MouseEffectType effectType)
 {
     return(await CreateEffectAsync("/mouse", new EffectData(effectType)).ConfigureAwait(false));
 }
Exemplo n.º 5
0
 /// <inheritdoc />
 /// <summary>
 /// Creates a new mouse 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> CreateMouseEffectAsync(Effects.Mouse.MouseEffectType effectType)
 {
     return(Task.FromResult(CreateMouseEffect(effectType, IntPtr.Zero)));
 }