2020-10-15 03:50:00 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using OpenTabletDriver.Plugin;
|
|
|
|
|
using OpenTabletDriver.Plugin.Attributes;
|
|
|
|
|
|
2020-12-13 04:59:00 +08:00
|
|
|
|
namespace VoiDPlugins.Binding.ScriptRunner
|
2020-10-15 03:50:00 +01:00
|
|
|
|
{
|
|
|
|
|
internal static class ScriptRunnerHelper
|
|
|
|
|
{
|
2020-10-15 15:39:08 +01:00
|
|
|
|
public static List<string> ScriptPathList = Enumerable.Repeat("", 10).ToList();
|
2020-10-15 03:50:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PluginName("Script Runner")]
|
|
|
|
|
public class ScriptRunner : ITool, IValidateBinding, IBinding
|
|
|
|
|
{
|
2020-10-15 15:39:08 +01:00
|
|
|
|
public List<string> ScriptPathList = ScriptRunnerHelper.ScriptPathList;
|
2020-10-15 03:50:00 +01:00
|
|
|
|
public string[] ValidProperties
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
string[] Properties = new string[10];
|
|
|
|
|
for (int index = 0; index <= 9; index++)
|
|
|
|
|
{
|
2020-10-15 09:06:41 +01:00
|
|
|
|
Properties[index] = $"{index}";
|
2020-10-15 03:50:00 +01:00
|
|
|
|
}
|
|
|
|
|
return Properties;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public string Property { set; get; }
|
2020-10-15 15:39:08 +01:00
|
|
|
|
public Action Press => (Action)(() => RunScript(ScriptPathList[Int32.Parse(Property)]));
|
2020-12-13 04:59:00 +08:00
|
|
|
|
private static void RunScript(string path)
|
2020-10-15 03:50:00 +01:00
|
|
|
|
{
|
2020-10-15 15:39:08 +01:00
|
|
|
|
try
|
2020-10-15 03:50:00 +01:00
|
|
|
|
{
|
2020-10-15 15:39:08 +01:00
|
|
|
|
new Process
|
2020-10-15 03:50:00 +01:00
|
|
|
|
{
|
2020-10-15 15:39:08 +01:00
|
|
|
|
StartInfo = new ProcessStartInfo(path)
|
|
|
|
|
{
|
|
|
|
|
UseShellExecute = true
|
|
|
|
|
}
|
|
|
|
|
}.Start();
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
2020-10-15 03:50:00 +01:00
|
|
|
|
}
|
|
|
|
|
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; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|