Skip to content

Commit

Permalink
Update with the latest SDK version
Browse files Browse the repository at this point in the history
  • Loading branch information
dend committed Aug 4, 2021
1 parent 45174ff commit 5bdd997
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
9 changes: 5 additions & 4 deletions src/DeckSurf/DeckSurf.Plugin.Barn/Commands/ShowCPUUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/DeckSurf/DeckSurf.Plugin.Barn/Commands/SnakeGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DeckSurf.SDK" Version="0.0.2" />
<PackageReference Include="DeckSurf.SDK" Version="0.0.3" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="6.0.0-preview.6.21352.12" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/DeckSurf/DeckSurf.Plugin.Barn/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};
Expand Down
4 changes: 2 additions & 2 deletions src/DeckSurf/DeckSurf/DeckSurf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

<ItemGroup>
<PackageReference Include="Autofac" Version="6.2.0" />
<PackageReference Include="DeckSurf.SDK" Version="0.0.2" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21216.1" />
<PackageReference Include="DeckSurf.SDK" Version="0.0.3" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21308.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/DeckSurf/DeckSurf/Extensibility/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal static IEnumerable<T> Load<T>()
{
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)
Expand Down

0 comments on commit 5bdd997

Please sign in to comment.