Skip to content

Commit

Permalink
Merge branch 'feature/0.62.1_updates'
Browse files Browse the repository at this point in the history
  • Loading branch information
oddbear committed May 2, 2023
2 parents 327d927 + a629765 commit 2a83778
Show file tree
Hide file tree
Showing 132 changed files with 900 additions and 1,783 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Loupedeck.PowerToysPlugin.Helpers;
using Loupedeck.PowerToysPlugin.Models.AlwaysOnTop;
using Loupedeck.PowerToysPlugin.Services;

namespace Loupedeck.PowerToysPlugin.Commands.AlwaysOnTop
Expand All @@ -8,7 +7,6 @@ class AlwaysOnTopActivateCommand : PluginDynamicCommand
{
private PowerToysPlugin _plugin;
private AlwaysOnTopService _service;
private AlwaysOnTopSettings _currentSettings;

public AlwaysOnTopActivateCommand()
: base("Activate Always On Top",
Expand All @@ -27,9 +25,7 @@ protected override bool OnLoad()
_service = _plugin.AlwaysOnTopService;
if (_service is null)
return false;

_currentSettings = _service.GetSettings();


return true;
}

Expand Down
27 changes: 5 additions & 22 deletions PowerToysPlugin/Commands/Awake/AwakeKeepScreenOnToggleCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Loupedeck.PowerToysPlugin.Helpers;
using Loupedeck.PowerToysPlugin.Models.Awake;
using Loupedeck.PowerToysPlugin.Services;

namespace Loupedeck.PowerToysPlugin.Commands.Awake
Expand All @@ -8,7 +7,6 @@ class AwakeKeepScreenOnToggleCommand : PluginDynamicCommand
{
private PowerToysPlugin _plugin;
private AwakeService _service;
private AwakeSettings _currentSettings;

public AwakeKeepScreenOnToggleCommand()
: base("Toggle Keep screen on",
Expand All @@ -27,39 +25,24 @@ protected override bool OnLoad()
_service = _plugin.AwakeService;
if (_service is null)
return false;

_currentSettings = _service.GetSettings();
_service.SettingsUpdated += AwakeServiceOnSettingsUpdated;

_service.KeepDisplayOn_ChangedEvent += base.ActionImageChanged;

return true;
}

private void AwakeServiceOnSettingsUpdated(object sender, AwakeSettings e)
{
_currentSettings = e;
base.ActionImageChanged();
}

protected override void RunCommand(string actionParameter)
{
if (_currentSettings is null)
return;

_currentSettings.Properties.AwakeKeepDisplayOn = !_currentSettings.Properties.AwakeKeepDisplayOn;
_service.UpdateSettings(_currentSettings);
base.ActionImageChanged();
_service.Toggle();
}

protected override BitmapImage GetCommandImage(string actionParameter, PluginImageSize imageSize)
{
if (_currentSettings is null)
return null;

using (var bitmapBuilder = new BitmapBuilder(imageSize))
{
bitmapBuilder.Clear(new BitmapColor(0x00, 0x19, 0x7C));

var path = _currentSettings.Properties.AwakeKeepDisplayOn
var path = _service.KeepDisplayOnState()
? "Loupedeck.PowerToysPlugin.Resources.Modules.Awake.on-80.png"
: "Loupedeck.PowerToysPlugin.Resources.Modules.Awake.off-80.png";

Expand All @@ -76,7 +59,7 @@ protected override BitmapImage GetCommandImage(string actionParameter, PluginIma

protected override string GetCommandDisplayName(string actionParameter, PluginImageSize imageSize)
{
var state = _currentSettings.Properties.AwakeKeepDisplayOn ? "On" : "Off";
var state = _service.KeepDisplayOnState() ? "On" : "Off";
return $"Awake: {state}";
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Loupedeck.PowerToysPlugin.Helpers;
using Loupedeck.PowerToysPlugin.Models.ColorPicker;
using Loupedeck.PowerToysPlugin.Services;

namespace Loupedeck.PowerToysPlugin.Commands.ColorPicker
Expand All @@ -8,7 +7,6 @@ class ColorPickerActivateCommand : PluginDynamicCommand
{
private PowerToysPlugin _plugin;
private ColorPickerService _service;
private ColorPickerSettings _currentSettings;

public ColorPickerActivateCommand()
: base("Activate ColorPicker",
Expand All @@ -27,9 +25,7 @@ protected override bool OnLoad()
_service = _plugin.ColorPickerService;
if (_service is null)
return false;

_currentSettings = _service.GetSettings();


return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Loupedeck.PowerToysPlugin.Helpers;
using Loupedeck.PowerToysPlugin.Models.FancyZones;
using Loupedeck.PowerToysPlugin.Services;

namespace Loupedeck.PowerToysPlugin.Commands.FancyZones
Expand All @@ -8,7 +7,6 @@ class FancyZonesActivateCommand : PluginDynamicCommand
{
private PowerToysPlugin _plugin;
private FancyZonesService _service;
private FancyZonesSettings _currentSettings;

public FancyZonesActivateCommand()
: base("Open Layout Editor",
Expand All @@ -27,8 +25,7 @@ protected override bool OnLoad()
_service = _plugin.FancyZonesService;
if (_service is null)
return false;

_currentSettings = _service.GetSettings();

_service.IsRunningUpdated += ServiceOnIsRunningUpdated;

return true;
Expand Down
68 changes: 68 additions & 0 deletions PowerToysPlugin/Commands/FancyZones/FancyZonesNextWindowCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Loupedeck.PowerToysPlugin.Helpers;
using Loupedeck.PowerToysPlugin.Services;

namespace Loupedeck.PowerToysPlugin.Commands.FancyZones
{
class FancyZonesNextWindowCommand : PluginDynamicCommand
{
private PowerToysPlugin _plugin;
private FancyZonesService _service;

public FancyZonesNextWindowCommand()
: base("Next Window",
"Presses the assigned keyboard shortcuts to next window.",
"Fancy Zones")
{
//
}

protected override bool OnLoad()
{
_plugin = base.Plugin as PowerToysPlugin;
if (_plugin is null)
return false;

_service = _plugin.FancyZonesService;
if (_service is null)
return false;

_service.IsRunningUpdated += ServiceOnIsRunningUpdated;

return true;
}

private void ServiceOnIsRunningUpdated(object sender, bool e)
{
base.ActionImageChanged();
}

protected override void RunCommand(string actionParameter)
{
_service.NextWindow();
}

protected override BitmapImage GetCommandImage(string actionParameter, PluginImageSize imageSize)
{
using (var bitmapBuilder = new BitmapBuilder(imageSize))
{
bitmapBuilder.Clear(new BitmapColor(0x00, 0x19, 0x7C));

var path = "Loupedeck.PowerToysPlugin.Resources.Modules.FancyZones.next-80.png";

var background = ResourceHelper.GetBackgroundImage(path);
bitmapBuilder.SetBackgroundImage(background);

bitmapBuilder.Translate(0, 20);
var text = GetCommandDisplayName(actionParameter, imageSize);
bitmapBuilder.DrawText(text, BitmapColor.White, 10);

return bitmapBuilder.ToImage();
}
}

protected override string GetCommandDisplayName(string actionParameter, PluginImageSize imageSize)
{
return "Next Window";
}
}
}
68 changes: 68 additions & 0 deletions PowerToysPlugin/Commands/FancyZones/FancyZonesPrevWindowCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Loupedeck.PowerToysPlugin.Helpers;
using Loupedeck.PowerToysPlugin.Services;

namespace Loupedeck.PowerToysPlugin.Commands.FancyZones
{
class FancyZonesPrevWindowCommand : PluginDynamicCommand
{
private PowerToysPlugin _plugin;
private FancyZonesService _service;

public FancyZonesPrevWindowCommand()
: base("Prev Window",
"Presses the assigned keyboard shortcuts to prev window.",
"Fancy Zones")
{
//
}

protected override bool OnLoad()
{
_plugin = base.Plugin as PowerToysPlugin;
if (_plugin is null)
return false;

_service = _plugin.FancyZonesService;
if (_service is null)
return false;

_service.IsRunningUpdated += ServiceOnIsRunningUpdated;

return true;
}

private void ServiceOnIsRunningUpdated(object sender, bool e)
{
base.ActionImageChanged();
}

protected override void RunCommand(string actionParameter)
{
_service.PrevWindow();
}

protected override BitmapImage GetCommandImage(string actionParameter, PluginImageSize imageSize)
{
using (var bitmapBuilder = new BitmapBuilder(imageSize))
{
bitmapBuilder.Clear(new BitmapColor(0x00, 0x19, 0x7C));

var path = "Loupedeck.PowerToysPlugin.Resources.Modules.FancyZones.prev-80.png";

var background = ResourceHelper.GetBackgroundImage(path);
bitmapBuilder.SetBackgroundImage(background);

bitmapBuilder.Translate(0, 20);
var text = GetCommandDisplayName(actionParameter, imageSize);
bitmapBuilder.DrawText(text, BitmapColor.White, 10);

return bitmapBuilder.ToImage();
}
}

protected override string GetCommandDisplayName(string actionParameter, PluginImageSize imageSize)
{
return "Prev Window";
}
}
}
61 changes: 61 additions & 0 deletions PowerToysPlugin/Commands/MeasureTool/MeasureToolCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Loupedeck.PowerToysPlugin.Helpers;
using Loupedeck.PowerToysPlugin.Services;

namespace Loupedeck.PowerToysPlugin.Commands.MeasureTool
{
class MeasureToolCommand : PluginDynamicCommand
{
private PowerToysPlugin _plugin;
private MeasureToolService _service;

public MeasureToolCommand()
: base("Enable Screen Ruler",
"Enable Screen Ruler",
"MeasureTool")
{
//
}

protected override bool OnLoad()
{
_plugin = base.Plugin as PowerToysPlugin;
if (_plugin is null)
return false;

_service = _plugin.MeasureToolService;
if (_service is null)
return false;

return true;
}

protected override void RunCommand(string actionParameter)
{
_service.Activate();
}

protected override BitmapImage GetCommandImage(string actionParameter, PluginImageSize imageSize)
{
using (var bitmapBuilder = new BitmapBuilder(imageSize))
{
bitmapBuilder.Clear(new BitmapColor(0x00, 0x19, 0x7C));

var path = "Loupedeck.PowerToysPlugin.Resources.Modules.MeasureTool.icon-80.png";

var background = ResourceHelper.GetBackgroundImage(path);
bitmapBuilder.SetBackgroundImage(background);

bitmapBuilder.Translate(0, 20);
var text = GetCommandDisplayName(actionParameter, imageSize);
bitmapBuilder.DrawText(text, BitmapColor.White, 10);

return bitmapBuilder.ToImage();
}
}

protected override string GetCommandDisplayName(string actionParameter, PluginImageSize imageSize)
{
return "Screen Ruler";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Loupedeck.PowerToysPlugin.Helpers;
using Loupedeck.PowerToysPlugin.Models.MouseHighlighter;
using Loupedeck.PowerToysPlugin.Services;

namespace Loupedeck.PowerToysPlugin.Commands.MouseHighlighter
Expand All @@ -8,7 +7,6 @@ class MouseHighlighterActivateCommand : PluginDynamicCommand
{
private PowerToysPlugin _plugin;
private MouseHighlighterService _service;
private MouseHighlighterSettings _currentSettings;

public MouseHighlighterActivateCommand()
: base("Activate Mouse Clicks",
Expand All @@ -27,9 +25,7 @@ protected override bool OnLoad()
_service = _plugin.MouseHighlighterService;
if (_service is null)
return false;

_currentSettings = _service.GetSettings();


return true;
}

Expand Down
Loading

0 comments on commit 2a83778

Please sign in to comment.