mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2026-11-11 13:06:24 +00:00
Refactored brushes, gradients, effects and the keyboard to uncouple them
This commit is contained in:
1 parent
5fc7abc9db
commit
630090ac6f
20 files changed
+79
-62
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CUE.NET.Helper;
|
using CUE.NET.Helper;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Brushes
|
namespace CUE.NET.Brushes
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a basic brush.
|
/// Represents a basic brush.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Brushes
|
namespace CUE.NET.Brushes
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a basic brush.
|
/// Represents a basic brush.
|
||||||
@@ -4,10 +4,10 @@
|
|||||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CUE.NET.Devices.Keyboard.Brushes.Gradient;
|
using CUE.NET.Gradients;
|
||||||
using CUE.NET.Helper;
|
using CUE.NET.Helper;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Brushes
|
namespace CUE.NET.Brushes
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a brush drawing a linear gradient.
|
/// Represents a brush drawing a linear gradient.
|
||||||
@@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CUE.NET.Devices.Keyboard.Brushes.Gradient;
|
using CUE.NET.Gradients;
|
||||||
using CUE.NET.Helper;
|
using CUE.NET.Helper;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Brushes
|
namespace CUE.NET.Brushes
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a brush drawing a radial gradient around a center point.
|
/// Represents a brush drawing a radial gradient around a center point.
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CUE.NET.Helper;
|
using CUE.NET.Helper;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Brushes
|
namespace CUE.NET.Brushes
|
||||||
{
|
{
|
||||||
//TODO DarthAffe 30.09.2015: Like this the brush seems kinda useless. Think about making it cool.
|
//TODO DarthAffe 30.09.2015: Like this the brush seems kinda useless. Think about making it cool.
|
||||||
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Brushes
|
namespace CUE.NET.Brushes
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a brush drawing only a single color.
|
/// Represents a brush drawing only a single color.
|
||||||
+15
-15
@@ -46,20 +46,20 @@
|
|||||||
<Compile Include="Devices\Generic\Enums\CorsairDeviceCaps.cs" />
|
<Compile Include="Devices\Generic\Enums\CorsairDeviceCaps.cs" />
|
||||||
<Compile Include="Devices\Generic\Enums\CorsairDeviceType.cs" />
|
<Compile Include="Devices\Generic\Enums\CorsairDeviceType.cs" />
|
||||||
<Compile Include="Devices\Generic\OnExceptionEventArgs.cs" />
|
<Compile Include="Devices\Generic\OnExceptionEventArgs.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Brushes\AbstractBrush.cs" />
|
<Compile Include="Brushes\AbstractBrush.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Brushes\Gradient\AbstractGradient.cs" />
|
<Compile Include="Gradients\AbstractGradient.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Brushes\Gradient\GradientStop.cs" />
|
<Compile Include="Gradients\GradientStop.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Brushes\Gradient\IGradient.cs" />
|
<Compile Include="Gradients\IGradient.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Brushes\Gradient\RainbowGradient.cs" />
|
<Compile Include="Gradients\RainbowGradient.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Brushes\IBrush.cs" />
|
<Compile Include="Brushes\IBrush.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Brushes\LinearGradientBrush.cs" />
|
<Compile Include="Brushes\LinearGradientBrush.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Brushes\RadialGradientBrush.cs" />
|
<Compile Include="Brushes\RadialGradientBrush.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Brushes\RandomColorBrush.cs" />
|
<Compile Include="Brushes\RandomColorBrush.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Brushes\SolidColorBrush.cs" />
|
<Compile Include="Brushes\SolidColorBrush.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Effects\AbstractEffect.cs" />
|
<Compile Include="Effects\AbstractEffect.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Effects\FlashEffect.cs" />
|
<Compile Include="Effects\FlashEffect.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Effects\IEffect.cs" />
|
<Compile Include="Effects\IEffect.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Effects\EffectTimeContainer.cs" />
|
<Compile Include="Effects\EffectTimeContainer.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Enums\CorsairLogicalKeyboardLayout.cs" />
|
<Compile Include="Devices\Keyboard\Enums\CorsairLogicalKeyboardLayout.cs" />
|
||||||
<Compile Include="Devices\Headset\Enums\CorsairHeadsetLedId.cs" />
|
<Compile Include="Devices\Headset\Enums\CorsairHeadsetLedId.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Enums\CorsairKeyboardKeyId.cs" />
|
<Compile Include="Devices\Keyboard\Enums\CorsairKeyboardKeyId.cs" />
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
<Compile Include="Devices\Mouse\CorsairMouse.cs" />
|
<Compile Include="Devices\Mouse\CorsairMouse.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Extensions\KeyGroupExtension.cs" />
|
<Compile Include="Devices\Keyboard\Extensions\KeyGroupExtension.cs" />
|
||||||
<Compile Include="Helper\ColorHelper.cs" />
|
<Compile Include="Helper\ColorHelper.cs" />
|
||||||
<Compile Include="Devices\Keyboard\Brushes\Gradient\LinearGradient.cs" />
|
<Compile Include="Gradients\LinearGradient.cs" />
|
||||||
<Compile Include="Helper\GradientHelper.cs" />
|
<Compile Include="Helper\GradientHelper.cs" />
|
||||||
<Compile Include="Helper\RectangleHelper.cs" />
|
<Compile Include="Helper\RectangleHelper.cs" />
|
||||||
<Compile Include="Native\_CorsairDeviceInfo.cs" />
|
<Compile Include="Native\_CorsairDeviceInfo.cs" />
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace CUE.NET.Devices.Generic.Enums
|
using CUE.NET.Effects;
|
||||||
|
|
||||||
|
namespace CUE.NET.Devices.Generic.Enums
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains list of available update modes.
|
/// Contains list of available update modes.
|
||||||
@@ -12,7 +14,7 @@
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The device will perform automatic updates at the rate set in <see cref="CUE.NET.Devices.ICueDevice.UpdateFrequency" />
|
/// The device will perform automatic updates at the rate set in <see cref="CUE.NET.Devices.ICueDevice.UpdateFrequency" />
|
||||||
/// as long as an <see cref="CUE.NET.Devices.Keyboard.Effects.IEffect" /> is attached.
|
/// as long as an <see cref="IEffect" /> is attached.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
AutoOnEffect,
|
AutoOnEffect,
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ using System.Collections.ObjectModel;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using CUE.NET.Brushes;
|
||||||
using CUE.NET.Devices.Generic;
|
using CUE.NET.Devices.Generic;
|
||||||
using CUE.NET.Devices.Keyboard.Brushes;
|
|
||||||
using CUE.NET.Devices.Keyboard.Effects;
|
|
||||||
using CUE.NET.Devices.Keyboard.Enums;
|
using CUE.NET.Devices.Keyboard.Enums;
|
||||||
using CUE.NET.Devices.Keyboard.Keys;
|
using CUE.NET.Devices.Keyboard.Keys;
|
||||||
|
using CUE.NET.Effects;
|
||||||
using CUE.NET.Helper;
|
using CUE.NET.Helper;
|
||||||
using CUE.NET.Native;
|
using CUE.NET.Native;
|
||||||
|
|
||||||
@@ -188,7 +188,9 @@ namespace CUE.NET.Devices.Keyboard
|
|||||||
effect.TicksAtLastUpdate = currentTicks;
|
effect.TicksAtLastUpdate = currentTicks;
|
||||||
effect.Effect.Update(deltaTime);
|
effect.Effect.Update(deltaTime);
|
||||||
|
|
||||||
ApplyBrush((effect.Effect.KeyList ?? this).ToList(), effect.Effect.EffectBrush);
|
//TODO DarthAffe 18.10.2015: This is really dirty and might have a really negative performance impact - find a better solution.
|
||||||
|
IEnumerable<CorsairKey> keys = effect.Effect?.LedList?.Select(x => this.FirstOrDefault(y => y.Led == x));
|
||||||
|
ApplyBrush((keys ?? this).ToList(), effect.Effect.EffectBrush);
|
||||||
|
|
||||||
if (effect.Effect.IsDone)
|
if (effect.Effect.IsDone)
|
||||||
effectsToRemove.Add(effect.Effect);
|
effectsToRemove.Add(effect.Effect);
|
||||||
@@ -215,6 +217,11 @@ namespace CUE.NET.Devices.Keyboard
|
|||||||
catch (Exception ex) { ManageException(ex); }
|
catch (Exception ex) { ManageException(ex); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<CorsairLed> GetLeds()
|
||||||
|
{
|
||||||
|
return this.Select(x => x.Led);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using CUE.NET.Devices.Keyboard.Brushes;
|
using System.Linq;
|
||||||
|
using CUE.NET.Brushes;
|
||||||
|
using CUE.NET.Devices.Generic;
|
||||||
using CUE.NET.Devices.Keyboard.Extensions;
|
using CUE.NET.Devices.Keyboard.Extensions;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Keys
|
namespace CUE.NET.Devices.Keyboard.Keys
|
||||||
@@ -49,6 +51,15 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
|||||||
this.Attach();
|
this.Attach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
public IEnumerable<CorsairLed> GetLeds()
|
||||||
|
{
|
||||||
|
return GetGroupKeys().Select(x => x.Led);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list containing the keys from this group.
|
/// Gets a list containing the keys from this group.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using CUE.NET.Devices.Keyboard.Brushes;
|
using CUE.NET.Brushes;
|
||||||
|
using CUE.NET.Devices.Generic;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Keys
|
namespace CUE.NET.Devices.Keyboard.Keys
|
||||||
{
|
{
|
||||||
@@ -19,5 +20,11 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
|||||||
/// Gets or sets the z-index of this keygroup to allow ordering them before drawing. (lowest first) (default: 0)
|
/// Gets or sets the z-index of this keygroup to allow ordering them before drawing. (lowest first) (default: 0)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int ZIndex { get; set; }
|
int ZIndex { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a list containing all LEDs of this group.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The list containing all LEDs of this group.</returns>
|
||||||
|
IEnumerable<CorsairLed> GetLeds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
// ReSharper disable MemberCanBePrivate.Global
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using CUE.NET.Brushes;
|
||||||
using CUE.NET.Devices.Keyboard.Brushes;
|
using CUE.NET.Devices.Generic;
|
||||||
using CUE.NET.Devices.Keyboard.Keys;
|
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Effects
|
namespace CUE.NET.Effects
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a basic effect.
|
/// Represents a basic effect.
|
||||||
@@ -15,9 +14,9 @@ namespace CUE.NET.Devices.Keyboard.Effects
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the list of keys to which the effect applies.
|
/// Gets or sets the list of LEDSs to which the effect applies.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<CorsairKey> KeyList { get; protected set; }
|
public IEnumerable<CorsairLed> LedList { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the brush which is drawn by the effect.
|
/// Gets the brush which is drawn by the effect.
|
||||||
@@ -38,15 +37,6 @@ namespace CUE.NET.Devices.Keyboard.Effects
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the list of keys to which the effect applies.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="keyGroup"></param>
|
|
||||||
public void SetTarget(IKeyGroup keyGroup)
|
|
||||||
{
|
|
||||||
KeyList = keyGroup.Keys.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the effect.
|
/// Updates the effect.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -54,13 +44,13 @@ namespace CUE.NET.Devices.Keyboard.Effects
|
|||||||
public abstract void Update(float deltaTime);
|
public abstract void Update(float deltaTime);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hook which is called when the effect is attached to a keyboard.
|
/// Hook which is called when the effect is attached to a device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void OnAttach()
|
public virtual void OnAttach()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hook which is called when the effect is detached from a keyboard.
|
/// Hook which is called when the effect is detached from a device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void OnDetach()
|
public virtual void OnDetach()
|
||||||
{ }
|
{ }
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
// ReSharper disable MemberCanBePrivate.Global
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Effects
|
namespace CUE.NET.Effects
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a wrapped effect with additional time information.
|
/// Represents a wrapped effect with additional time information.
|
||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CUE.NET.Devices.Keyboard.Brushes;
|
using CUE.NET.Brushes;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Effects
|
namespace CUE.NET.Effects
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents an effect which allows to flash an brush by modifying his opacity.
|
/// Represents an effect which allows to flash an brush by modifying his opacity.
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using CUE.NET.Devices.Keyboard.Brushes;
|
using CUE.NET.Brushes;
|
||||||
using CUE.NET.Devices.Keyboard.Keys;
|
using CUE.NET.Devices.Generic;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Effects
|
namespace CUE.NET.Effects
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a basic effect.
|
/// Represents a basic effect.
|
||||||
@@ -12,9 +12,9 @@ namespace CUE.NET.Devices.Keyboard.Effects
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the list of keys to which the effect applies.
|
/// Gets or sets the list of LEDs to which the effect applies.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IEnumerable<CorsairKey> KeyList { get; }
|
IEnumerable<CorsairLed> LedList { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the brush which is drawn by the effect.
|
/// Gets the brush which is drawn by the effect.
|
||||||
@@ -42,12 +42,12 @@ namespace CUE.NET.Devices.Keyboard.Effects
|
|||||||
void Update(float deltaTime);
|
void Update(float deltaTime);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hook which is called when the effect is attached to a keyboard.
|
/// Hook which is called when the effect is attached to a device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnAttach();
|
void OnAttach();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hook which is called when the effect is detached from a keyboard.
|
/// Hook which is called when the effect is detached from a device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnDetach();
|
void OnDetach();
|
||||||
|
|
||||||
+1
-1
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
namespace CUE.NET.Gradients
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a basic gradient.
|
/// Represents a basic gradient.
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
namespace CUE.NET.Gradients
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a stop on a gradient.
|
/// Represents a stop on a gradient.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
namespace CUE.NET.Gradients
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a basic gradient.
|
/// Represents a basic gradient.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
namespace CUE.NET.Gradients
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a linear interpolated gradient with n stops.
|
/// Represents a linear interpolated gradient with n stops.
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using CUE.NET.Helper;
|
using CUE.NET.Helper;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Brushes.Gradient
|
namespace CUE.NET.Gradients
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a rainbow gradient which circles through all color colors of the HUE-color-space.<br />
|
/// Represents a rainbow gradient which circles through all color colors of the HUE-color-space.<br />
|
||||||
Reference in new issue
Block a user