servicepoint/crates/servicepoint_binding_cs/ServicePoint/Command.cs

133 lines
3.4 KiB
C#
Raw Normal View History

2024-05-13 00:17:40 +02:00
using System.Diagnostics.CodeAnalysis;
using ServicePoint.BindGen;
2024-05-13 00:17:40 +02:00
namespace ServicePoint;
2024-05-13 00:17:40 +02:00
public sealed class Command : SpNativeInstance<BindGen.Command>
2024-05-13 00:17:40 +02:00
{
public static bool TryFromPacket(Packet packet, [MaybeNullWhen(false)] out Command command)
2024-05-13 00:17:40 +02:00
{
unsafe
{
var result = NativeMethods.sp_command_try_from_packet(packet.Into());
if (result == null)
{
command = null;
return false;
}
command = new Command(result);
return true;
2024-05-13 00:17:40 +02:00
}
}
public Command Clone()
2024-05-13 00:17:40 +02:00
{
unsafe
{
return new Command(NativeMethods.sp_command_clone(Instance));
2024-05-13 00:17:40 +02:00
}
}
public static Command Clear()
{
unsafe
{
return new Command(NativeMethods.sp_command_clear());
2024-05-13 00:17:40 +02:00
}
}
public static Command HardReset()
{
unsafe
{
return new Command(NativeMethods.sp_command_hard_reset());
2024-05-13 00:17:40 +02:00
}
}
public static Command FadeOut()
{
unsafe
{
return new Command(NativeMethods.sp_command_fade_out());
2024-05-13 00:17:40 +02:00
}
}
public static Command Brightness(byte brightness)
{
unsafe
{
return new Command(NativeMethods.sp_command_brightness(brightness));
2024-05-13 00:17:40 +02:00
}
}
2024-06-23 16:30:45 +02:00
public static Command CharBrightness(int x, int y, BrightnessGrid grid)
2024-05-13 00:17:40 +02:00
{
unsafe
{
return new Command(NativeMethods.sp_command_char_brightness((ushort)x, (ushort)y, grid.Into()));
2024-05-13 00:17:40 +02:00
}
}
public static Command BitmapLinear(int offset, BitVec bitVec, CompressionCode compressionCode)
{
unsafe
{
return new Command(
NativeMethods.sp_command_bitmap_linear((ushort)offset, bitVec.Into(), compressionCode));
2024-05-13 00:17:40 +02:00
}
}
public static Command BitmapLinearAnd(int offset, BitVec bitVec, CompressionCode compressionCode)
{
unsafe
{
return new Command(
NativeMethods.sp_command_bitmap_linear_and((ushort)offset, bitVec.Into(), compressionCode));
2024-05-13 00:17:40 +02:00
}
}
public static Command BitmapLinearOr(int offset, BitVec bitVec, CompressionCode compressionCode)
{
unsafe
{
return new Command(
NativeMethods.sp_command_bitmap_linear_or((ushort)offset, bitVec.Into(), compressionCode));
2024-05-13 00:17:40 +02:00
}
}
public static Command BitmapLinearXor(int offset, BitVec bitVec, CompressionCode compressionCode)
{
unsafe
{
return new Command(
NativeMethods.sp_command_bitmap_linear_xor((ushort)offset, bitVec.Into(), compressionCode));
2024-05-13 00:17:40 +02:00
}
}
2024-05-16 23:12:03 +02:00
public static Command BitmapLinearWin(int x, int y, PixelGrid pixelGrid, CompressionCode compression)
2024-05-13 00:17:40 +02:00
{
unsafe
{
return new Command(NativeMethods.sp_command_bitmap_linear_win((ushort)x, (ushort)y, pixelGrid.Into(), compression));
2024-05-13 00:17:40 +02:00
}
}
2024-06-23 16:30:45 +02:00
public static Command Cp437Data(int x, int y, Cp437Grid byteGrid)
2024-05-13 00:17:40 +02:00
{
unsafe
{
return new Command(NativeMethods.sp_command_cp437_data((ushort)x, (ushort)y, byteGrid.Into()));
2024-05-13 00:17:40 +02:00
}
}
private unsafe Command(BindGen.Command* instance) : base(instance)
{
}
private protected override unsafe void Dealloc()
2024-05-13 00:17:40 +02:00
{
NativeMethods.sp_command_dealloc(Instance);
2024-05-13 00:17:40 +02:00
}
}