From be9952441780f903f2b307127b8ec75879cdd66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Ferreira?= Date: Thu, 15 Oct 2020 15:12:30 +0100 Subject: [PATCH] Rewrite and rename Detail mode / Precision Control Merged the two classes into one, and renamed plugin --- DetailMode/DetailMode.cs | 38 --------------- DetailMode/DetailMode.sln | 25 ---------- OTDPlugins.sln | 2 +- PrecisionControl/PrecisionControl.cs | 48 +++++++++++++++++++ .../PrecisionControl.csproj | 1 - 5 files changed, 49 insertions(+), 65 deletions(-) delete mode 100644 DetailMode/DetailMode.cs delete mode 100644 DetailMode/DetailMode.sln create mode 100644 PrecisionControl/PrecisionControl.cs rename DetailMode/DetailMode.csproj => PrecisionControl/PrecisionControl.csproj (90%) diff --git a/DetailMode/DetailMode.cs b/DetailMode/DetailMode.cs deleted file mode 100644 index 2a415fa..0000000 --- a/DetailMode/DetailMode.cs +++ /dev/null @@ -1,38 +0,0 @@ -using OpenTabletDriver.Plugin; -using OpenTabletDriver.Plugin.Tablet; -using OpenTabletDriver.Plugin.Attributes; -using System; -using System.Numerics; - -namespace DetailMode -{ - [PluginName("Detail Mode")] - public class DetailBinding : IBinding - { - public string Property { set; get; } - public Action Press => (Action) (() => - { - DetailFilter.IsActive = !DetailFilter.IsActive; - DetailFilter.SetPosition = true; - }); - public Action Release => (Action) (() => DetailFilter.SetPosition = false); - } - - public class DetailFilter : IFilter - { - public static Vector2 StartingPoint; - public static bool IsActive { set; get; } - public static bool SetPosition { set; get; } - public Vector2 Filter(Vector2 OriginalPoint) - { - if (DetailFilter.SetPosition && Info.Driver.OutputMode is OpenTabletDriver.Plugin.Output.AbsoluteOutputMode) - DetailFilter.StartingPoint = new Vector2(OriginalPoint.X, OriginalPoint.Y); - return DetailFilter.IsActive ? new Vector2(OriginalPoint.X * this.Scale + DetailFilter.StartingPoint.X, OriginalPoint.Y * this.Scale + DetailFilter.StartingPoint.Y) : OriginalPoint; - } - - [SliderProperty("Detail Multiplier", 0.0f, 10f, 0.3f)] - public float Scale { get; set; } - - public FilterStage FilterStage => FilterStage.PostTranspose; - } -} diff --git a/DetailMode/DetailMode.sln b/DetailMode/DetailMode.sln deleted file mode 100644 index 57c67fc..0000000 --- a/DetailMode/DetailMode.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30524.135 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DetailMode", "DetailMode.csproj", "{C51EE48C-0A9E-4815-ADA0-D6A2EBA08019}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C51EE48C-0A9E-4815-ADA0-D6A2EBA08019}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C51EE48C-0A9E-4815-ADA0-D6A2EBA08019}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C51EE48C-0A9E-4815-ADA0-D6A2EBA08019}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C51EE48C-0A9E-4815-ADA0-D6A2EBA08019}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {C6807CAA-BD69-4297-8422-7C5B8DEFA539} - EndGlobalSection -EndGlobal diff --git a/OTDPlugins.sln b/OTDPlugins.sln index 1cd36e1..4129354 100644 --- a/OTDPlugins.sln +++ b/OTDPlugins.sln @@ -13,7 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VMultiMode", "VMultiMode\VM EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MeL", "MeL\MeL.csproj", "{F0931C43-4A63-4CDB-9B5F-A8DC50557109}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DetailMode", "DetailMode\DetailMode.csproj", "{3315D19C-54CB-4947-8CF5-54953870FB4F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecisionControl", "PrecisionControl\PrecisionControl.csproj", "{3315D19C-54CB-4947-8CF5-54953870FB4F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/PrecisionControl/PrecisionControl.cs b/PrecisionControl/PrecisionControl.cs new file mode 100644 index 0000000..3711803 --- /dev/null +++ b/PrecisionControl/PrecisionControl.cs @@ -0,0 +1,48 @@ +using OpenTabletDriver.Plugin; +using OpenTabletDriver.Plugin.Tablet; +using OpenTabletDriver.Plugin.Attributes; +using System; +using System.Numerics; +using System.Linq; + +namespace PrecisionControl +{ + [PluginName("Precision Control")] + public class PrecisionControl: IBinding, IValidateBinding, IFilter + { + public static Vector2 StartingPoint; + public float _Scale; + public static bool IsActive { set; get; } + public static bool SetPosition { set; get; } + public string Property { set; get; } + + public Action Press => (Action)(() => + { + IsActive = !IsActive; + SetPosition = true; + }); + + public Action Release => (Action)(() => SetPosition = false); + + public string[] ValidProperties + { + get { return new[]{ "Toggle Precision Control" }; } + } + + public Vector2 Filter(Vector2 OriginalPoint) + { + if (SetPosition && Info.Driver.OutputMode is OpenTabletDriver.Plugin.Output.AbsoluteOutputMode) + StartingPoint = new Vector2(OriginalPoint.X, OriginalPoint.Y); + return IsActive ? new Vector2(OriginalPoint.X * Scale + StartingPoint.X, OriginalPoint.Y * Scale + StartingPoint.Y) : OriginalPoint; + } + + [SliderProperty("Precision Multiplier", 0.0f, 10f, 0.3f)] + public float Scale + { + get => _Scale; + set { _Scale = value; } + } + + public FilterStage FilterStage => FilterStage.PostTranspose; + } +} diff --git a/DetailMode/DetailMode.csproj b/PrecisionControl/PrecisionControl.csproj similarity index 90% rename from DetailMode/DetailMode.csproj rename to PrecisionControl/PrecisionControl.csproj index dbab7f5..a0633e8 100644 --- a/DetailMode/DetailMode.csproj +++ b/PrecisionControl/PrecisionControl.csproj @@ -12,7 +12,6 @@ -