From 55f7772571cff91e74e053808040d7bc96b232b4 Mon Sep 17 00:00:00 2001 From: Victor_Grycuk Date: Thu, 27 Apr 2023 21:51:42 -0300 Subject: [PATCH] Add configurable refresh rate --- .../streamdeck-magnifier/Magnifier.cs | 8 +++++++- .../streamdeck-magnifier/MagnifierSettings.cs | 5 ++++- .../PropertyInspector/MagnifierPI.html | 14 +++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/streamdeck-magnifier/streamdeck-magnifier/Magnifier.cs b/streamdeck-magnifier/streamdeck-magnifier/Magnifier.cs index c57148c..4b1f03f 100644 --- a/streamdeck-magnifier/streamdeck-magnifier/Magnifier.cs +++ b/streamdeck-magnifier/streamdeck-magnifier/Magnifier.cs @@ -23,7 +23,7 @@ public Magnifier(SDConnection connection, InitialPayload payload) : base(connect ? MagnifierSettings.CreateDefaultSettings() : payload.Settings.ToObject(); - Timer = new Timer(10); + Timer = new Timer(settings.RefreshRate); Timer.Elapsed += new ElapsedEventHandler(UpdateKey); Timer.Enabled = false; Timer.Start(); @@ -75,6 +75,7 @@ public override void ReceivedSettings(ReceivedSettingsPayload payload) { Tools.AutoPopulateSettings(settings, payload.Settings); ParseZoomLevel(); + UpdateRefreshRate(); SaveSettings(); } @@ -96,5 +97,10 @@ private void ParseZoomLevel() Logger.Instance.LogMessage(TracingLevel.ERROR, "Cannot parse: " + settings.PIZoomLevel); } } + + private void UpdateRefreshRate() + { + Timer.Interval = settings.RefreshRate; + } } } \ No newline at end of file diff --git a/streamdeck-magnifier/streamdeck-magnifier/MagnifierSettings.cs b/streamdeck-magnifier/streamdeck-magnifier/MagnifierSettings.cs index 8ee64c7..17f29f6 100644 --- a/streamdeck-magnifier/streamdeck-magnifier/MagnifierSettings.cs +++ b/streamdeck-magnifier/streamdeck-magnifier/MagnifierSettings.cs @@ -6,7 +6,7 @@ internal class MagnifierSettings { public static MagnifierSettings CreateDefaultSettings() { - var instance = new MagnifierSettings { ZoomLevel = 2 }; + var instance = new MagnifierSettings { ZoomLevel = 2, RefreshRate = 100 }; return instance; } @@ -17,5 +17,8 @@ public static MagnifierSettings CreateDefaultSettings() public bool UseCrosshair { get; set; } public int ZoomLevel { get; set; } + + [JsonProperty(PropertyName = "refreshRate")] + public int RefreshRate { get; set; } } } diff --git a/streamdeck-magnifier/streamdeck-magnifier/PropertyInspector/MagnifierPI.html b/streamdeck-magnifier/streamdeck-magnifier/PropertyInspector/MagnifierPI.html index bc9e368..2e9d1f8 100644 --- a/streamdeck-magnifier/streamdeck-magnifier/PropertyInspector/MagnifierPI.html +++ b/streamdeck-magnifier/streamdeck-magnifier/PropertyInspector/MagnifierPI.html @@ -14,13 +14,17 @@
Select Type
+
+
Refresh Rate
+ +
Show Crosshair