VoiDPlugins/Binding/ScriptRunner/ScriptRunner.cs

111 lines
2.8 KiB
C#
Raw Normal View History

2021-04-21 21:46:00 +08:00
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using OpenTabletDriver.Plugin;
using OpenTabletDriver.Plugin.Attributes;
2021-04-21 21:46:00 +08:00
using OpenTabletDriver.Plugin.Tablet;
2020-12-13 04:59:00 +08:00
namespace VoiDPlugins.Binding.ScriptRunner
{
[PluginName("Script Runner")]
2021-04-21 21:46:00 +08:00
public class ScriptRunner : IBinding
{
2021-04-21 23:17:34 +08:00
public static string[] ValidIndexes = Enumerable.Range(0, 10).Select(i => i.ToString()).ToArray();
2020-12-17 00:56:23 +08:00
2021-04-21 23:17:34 +08:00
private List<string> ScriptPathList = new List<string>(10);
2021-04-21 21:46:00 +08:00
[Property("Script Index"), PropertyValidated(nameof(ValidIndexes))]
public string ScriptIndex { set; get; }
[Property("Script Path 0")]
public string ScriptPath0
{
get => ScriptPathList[0];
2021-04-21 21:46:00 +08:00
set => ScriptPathList[0] = value;
}
[Property("Script Path 1")]
public string ScriptPath1
{
get => ScriptPathList[1];
2021-04-21 21:46:00 +08:00
set => ScriptPathList[1] = value;
}
[Property("Script Path 2")]
public string ScriptPath2
{
get => ScriptPathList[2];
2021-04-21 21:46:00 +08:00
set => ScriptPathList[2] = value;
}
[Property("Script Path 3")]
public string ScriptPath3
{
get => ScriptPathList[3];
2021-04-21 21:46:00 +08:00
set => ScriptPathList[3] = value;
}
[Property("Script Path 4")]
public string ScriptPath4
{
get => ScriptPathList[4];
2021-04-21 21:46:00 +08:00
set => ScriptPathList[4] = value;
}
[Property("Script Path 5")]
public string ScriptPath5
{
get => ScriptPathList[5];
2021-04-21 21:46:00 +08:00
set => ScriptPathList[5] = value;
}
[Property("Script Path 6")]
public string ScriptPath6
{
get => ScriptPathList[6];
2021-04-21 21:46:00 +08:00
set => ScriptPathList[6] = value;
}
[Property("Script Path 7")]
public string ScriptPath7
{
get => ScriptPathList[7];
2021-04-21 21:46:00 +08:00
set => ScriptPathList[7] = value;
}
[Property("Script Path 8")]
public string ScriptPath8
{
get => ScriptPathList[8];
2021-04-21 21:46:00 +08:00
set => ScriptPathList[8] = value;
}
[Property("Script Path 9")]
public string ScriptPath9
{
get => ScriptPathList[9];
2021-04-21 21:46:00 +08:00
set => ScriptPathList[9] = value;
}
public void Press(IDeviceReport report)
{
try
{
var process = new Process
{
StartInfo = new ProcessStartInfo(ScriptPathList[int.Parse(ScriptIndex)])
{
UseShellExecute = true
}
};
process.Start();
}
catch { }
}
public void Release(IDeviceReport report)
{
return;
}
}
}