mirror of
https://github.com/vale981/VoiDPlugins
synced 2025-03-05 09:11:38 -05:00
Merge pull request #6 from skyborgff/ScriptRunner
ScriptRunner allows the user to run script / files.
This commit is contained in:
commit
bd0f1a1a89
4 changed files with 147 additions and 1 deletions
|
@ -1 +1 @@
|
|||
Subproject commit b21107772e9605316cc7179f9163b651ac73ae76
|
||||
Subproject commit 84261d8d8a90c5df4b5a1a38099212dec02a4f4f
|
123
ScriptRunner/ScriptRunner.cs
Normal file
123
ScriptRunner/ScriptRunner.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using OpenTabletDriver.Plugin;
|
||||
using OpenTabletDriver.Plugin.Tablet;
|
||||
using OpenTabletDriver.Plugin.Attributes;
|
||||
using System.Collections;
|
||||
|
||||
namespace ScriptRunner
|
||||
{
|
||||
internal static class ScriptRunnerHelper
|
||||
{
|
||||
public static List<string> ScriptPathList = Enumerable.Repeat("", 10).ToList();
|
||||
}
|
||||
|
||||
[PluginName("Script Runner")]
|
||||
public class ScriptRunner : ITool, IValidateBinding, IBinding
|
||||
{
|
||||
public List<string> ScriptPathList = ScriptRunnerHelper.ScriptPathList;
|
||||
public string[] ValidProperties
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] Properties = new string[10];
|
||||
for (int index = 0; index <= 9; index++)
|
||||
{
|
||||
Properties[index] = $"{index}";
|
||||
}
|
||||
return Properties;
|
||||
}
|
||||
}
|
||||
public string Property { set; get; }
|
||||
public Action Press => (Action)(() => RunScript(ScriptPathList[Int32.Parse(Property)]));
|
||||
private void RunScript(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo(path)
|
||||
{
|
||||
UseShellExecute = true
|
||||
}
|
||||
}.Start();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
public Action Release => (Action)(() => { });
|
||||
public bool Initialize() { return true; }
|
||||
public void Dispose() { }
|
||||
|
||||
[Property("Script Path 0")]
|
||||
public string ScriptPath0
|
||||
{
|
||||
get => ScriptPathList[0];
|
||||
set { ScriptPathList[0] = value; }
|
||||
}
|
||||
|
||||
[Property("Script Path 1")]
|
||||
public string ScriptPath1
|
||||
{
|
||||
get => ScriptPathList[1];
|
||||
set { ScriptPathList[1] = value; }
|
||||
}
|
||||
|
||||
[Property("Script Path 2")]
|
||||
public string ScriptPath2
|
||||
{
|
||||
get => ScriptPathList[2];
|
||||
set { ScriptPathList[2] = value; }
|
||||
}
|
||||
|
||||
[Property("Script Path 3")]
|
||||
public string ScriptPath3
|
||||
{
|
||||
get => ScriptPathList[3];
|
||||
set { ScriptPathList[3] = value; }
|
||||
}
|
||||
|
||||
[Property("Script Path 4")]
|
||||
public string ScriptPath4
|
||||
{
|
||||
get => ScriptPathList[4];
|
||||
set { ScriptPathList[4] = value; }
|
||||
}
|
||||
|
||||
[Property("Script Path 5")]
|
||||
public string ScriptPath5
|
||||
{
|
||||
get => ScriptPathList[5];
|
||||
set { ScriptPathList[5] = value; }
|
||||
}
|
||||
|
||||
[Property("Script Path 6")]
|
||||
public string ScriptPath6
|
||||
{
|
||||
get => ScriptPathList[6];
|
||||
set { ScriptPathList[6] = value; }
|
||||
}
|
||||
|
||||
[Property("Script Path 7")]
|
||||
public string ScriptPath7
|
||||
{
|
||||
get => ScriptPathList[7];
|
||||
set { ScriptPathList[7] = value; }
|
||||
}
|
||||
|
||||
[Property("Script Path 8")]
|
||||
public string ScriptPath8
|
||||
{
|
||||
get => ScriptPathList[8];
|
||||
set { ScriptPathList[8] = value; }
|
||||
}
|
||||
|
||||
[Property("Script Path 9")]
|
||||
public string ScriptPath9
|
||||
{
|
||||
get => ScriptPathList[9];
|
||||
set { ScriptPathList[9] = value; }
|
||||
}
|
||||
}
|
||||
}
|
17
ScriptRunner/ScriptRunner.csproj
Normal file
17
ScriptRunner/ScriptRunner.csproj
Normal file
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<DebugType>none</DebugType>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<CopyOutputSymbolsToOutputDirectory>false</CopyOutputSymbolsToOutputDirectory>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../.modules/OpenTabletDriver/OpenTabletDriver.Plugin/OpenTabletDriver.Plugin.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MeL", "MeL\MeL.csproj", "{F
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrecisionControl", "PrecisionControl\PrecisionControl.csproj", "{3315D19C-54CB-4947-8CF5-54953870FB4F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptRunner", "ScriptRunner\ScriptRunner.csproj", "{7B727343-91A8-44DA-AF2A-9FC8A0986AA4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -45,6 +47,10 @@ Global
|
|||
{3315D19C-54CB-4947-8CF5-54953870FB4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3315D19C-54CB-4947-8CF5-54953870FB4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3315D19C-54CB-4947-8CF5-54953870FB4F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7B727343-91A8-44DA-AF2A-9FC8A0986AA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7B727343-91A8-44DA-AF2A-9FC8A0986AA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7B727343-91A8-44DA-AF2A-9FC8A0986AA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7B727343-91A8-44DA-AF2A-9FC8A0986AA4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
Loading…
Add table
Reference in a new issue