From 5bdd99763a7c633e6d27752aa1cb33f34ef6019f Mon Sep 17 00:00:00 2001 From: Den Delimarsky <1389609+dend@users.noreply.github.com> Date: Tue, 3 Aug 2021 22:22:19 -0700 Subject: [PATCH] Update with the latest SDK version --- .../DeckSurf.Plugin.Barn/Commands/LaunchApplication.cs | 5 ++++- .../DeckSurf.Plugin.Barn/Commands/ShowCPUUsage.cs | 9 +++++---- src/DeckSurf/DeckSurf.Plugin.Barn/Commands/SnakeGame.cs | 4 ++-- .../DeckSurf.Plugin.Barn/DeckSurf.Plugin.Barn.csproj | 2 +- src/DeckSurf/DeckSurf.Plugin.Barn/Plugin.cs | 2 +- src/DeckSurf/DeckSurf/DeckSurf.csproj | 4 ++-- src/DeckSurf/DeckSurf/Extensibility/Loader.cs | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/DeckSurf/DeckSurf.Plugin.Barn/Commands/LaunchApplication.cs b/src/DeckSurf/DeckSurf.Plugin.Barn/Commands/LaunchApplication.cs index eefe3c1..ad2c282 100644 --- a/src/DeckSurf/DeckSurf.Plugin.Barn/Commands/LaunchApplication.cs +++ b/src/DeckSurf/DeckSurf.Plugin.Barn/Commands/LaunchApplication.cs @@ -25,7 +25,10 @@ public void ExecuteOnActivation(CommandMapping mappedCommand, ConnectedDevice ma { var icon = ImageHelpers.GetFileIcon(mappedCommand.CommandArguments, DeviceConstants.XLButtonSize, DeviceConstants.XLButtonSize, SIIGBF.SIIGBF_ICONONLY | SIIGBF.SIIGBF_CROPTOSQUARE); var byteContent = ImageHelpers.GetImageBuffer(icon); - DeviceManager.SetKey(mappedDevice, mappedCommand.ButtonIndex, byteContent); + + // TODO: Make sure that this works beyond the XL model. + var resizedByteContent = ImageHelpers.ResizeImage(byteContent, DeviceConstants.XLButtonSize, DeviceConstants.XLButtonSize); + mappedDevice.SetKey(mappedCommand.ButtonIndex, resizedByteContent); } catch { diff --git a/src/DeckSurf/DeckSurf.Plugin.Barn/Commands/ShowCPUUsage.cs b/src/DeckSurf/DeckSurf.Plugin.Barn/Commands/ShowCPUUsage.cs index 7f90b0f..f23126b 100644 --- a/src/DeckSurf/DeckSurf.Plugin.Barn/Commands/ShowCPUUsage.cs +++ b/src/DeckSurf/DeckSurf.Plugin.Barn/Commands/ShowCPUUsage.cs @@ -17,8 +17,8 @@ class ShowCPUUsage : IDSCommand private const string CounterName = "% Processor Time"; private const string InstanceName = "_Total"; - public string Name => "Launch Application"; - public string Description => "Launches an application on the machine."; + public string Name => "Show CPU Usage"; + public string Description => "Shows % of the CPU being used."; public void ExecuteOnAction(CommandMapping mappedCommand, ConnectedDevice mappedDevice, int activatingButton = -1) { @@ -33,14 +33,15 @@ public void ExecuteOnActivation(CommandMapping mappedCommand, ConnectedDevice ma var randomIconFromText = IconGenerator.GenerateTestImageFromText(GetCPUUsage().ToString() + "%", new Font("Bahnschrift", 94), Color.Red, Color.Black); var resizeImage = ImageHelpers.ResizeImage(ImageHelpers.GetImageBuffer(randomIconFromText), DeviceConstants.XLButtonSize, DeviceConstants.XLButtonSize); - DeviceManager.SetKey(mappedDevice, mappedCommand.ButtonIndex, resizeImage); + mappedDevice.SetKey(mappedCommand.ButtonIndex, resizeImage); }; cpuUsageTimer.Start(); } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Intended to work on Windows only at this time.")] private static int GetCPUUsage() { - PerformanceCounter perfCounter = new(CategoryName, CounterName, InstanceName); + PerformanceCounter perfCounter = new(categoryName: CategoryName, counterName: CounterName, instanceName: InstanceName); // Dummy call because PerformanceCounter will always start with zero. perfCounter.NextValue(); Thread.Sleep(1000); diff --git a/src/DeckSurf/DeckSurf.Plugin.Barn/Commands/SnakeGame.cs b/src/DeckSurf/DeckSurf.Plugin.Barn/Commands/SnakeGame.cs index c0bea37..66e1c0b 100644 --- a/src/DeckSurf/DeckSurf.Plugin.Barn/Commands/SnakeGame.cs +++ b/src/DeckSurf/DeckSurf.Plugin.Barn/Commands/SnakeGame.cs @@ -78,7 +78,7 @@ public void ExecuteOnActivation(CommandMapping mappedCommand, ConnectedDevice ma Timer timer = new(1000); timer.Elapsed += (s, e) => { - DeviceManager.SetKey(mappedDevice, UpdateSnakePosition(_direction), DeviceConstants.XLDefaultBlackButton); + mappedDevice.SetKey(UpdateSnakePosition(_direction), DeviceConstants.XLDefaultBlackButton); UpdateSnakeRendering(mappedDevice); }; timer.Start(); @@ -121,7 +121,7 @@ private void UpdateSnakeRendering(ConnectedDevice mappedDevice) { foreach (var snakeNode in _snake) { - DeviceManager.SetKey(mappedDevice, snakeNode, DeviceConstants.XLDefaultWhiteButton); + mappedDevice.SetKey(snakeNode, DeviceConstants.XLDefaultWhiteButton); } } } diff --git a/src/DeckSurf/DeckSurf.Plugin.Barn/DeckSurf.Plugin.Barn.csproj b/src/DeckSurf/DeckSurf.Plugin.Barn/DeckSurf.Plugin.Barn.csproj index e30bdad..896cfd5 100644 --- a/src/DeckSurf/DeckSurf.Plugin.Barn/DeckSurf.Plugin.Barn.csproj +++ b/src/DeckSurf/DeckSurf.Plugin.Barn/DeckSurf.Plugin.Barn.csproj @@ -18,7 +18,7 @@ - + diff --git a/src/DeckSurf/DeckSurf.Plugin.Barn/Plugin.cs b/src/DeckSurf/DeckSurf.Plugin.Barn/Plugin.cs index 25e6f4f..62cf62b 100644 --- a/src/DeckSurf/DeckSurf.Plugin.Barn/Plugin.cs +++ b/src/DeckSurf/DeckSurf.Plugin.Barn/Plugin.cs @@ -11,7 +11,7 @@ public class Plugin : IDSPlugin private PluginMetadata _metadata = new() { Author = "Den Delimarsky", - Id = "Deck.Surf.Plugin.Barn", + Id = "DeckSurf.Plugin.Barn", Version = "0.0.1-alpha", Website = "https://github.com/dend/piglet" }; diff --git a/src/DeckSurf/DeckSurf/DeckSurf.csproj b/src/DeckSurf/DeckSurf/DeckSurf.csproj index 875d371..472a474 100644 --- a/src/DeckSurf/DeckSurf/DeckSurf.csproj +++ b/src/DeckSurf/DeckSurf/DeckSurf.csproj @@ -22,8 +22,8 @@ - - + + diff --git a/src/DeckSurf/DeckSurf/Extensibility/Loader.cs b/src/DeckSurf/DeckSurf/Extensibility/Loader.cs index aa26efc..a08b0f7 100644 --- a/src/DeckSurf/DeckSurf/Extensibility/Loader.cs +++ b/src/DeckSurf/DeckSurf/Extensibility/Loader.cs @@ -17,7 +17,7 @@ internal static IEnumerable Load() { var builder = new ContainerBuilder(); - Regex assemblyPattern = new Regex(@"Deck\.Surf\.Plugin\..+\.dll"); + Regex assemblyPattern = new Regex(@"DeckSurf\.Plugin\..+\.dll"); var pluginPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "plugins"); var assemblies = Directory.EnumerateFiles(pluginPath, "*.dll", SearchOption.AllDirectories)