Process Starting
This commit is contained in:
parent
6ab18fdf70
commit
7fb6b4c89c
47
FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs
Normal file
47
FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using static System.Text.Json.JsonElement;
|
||||
|
||||
namespace FakeDeck.ButtonType
|
||||
{
|
||||
class ProcessMacro : Button
|
||||
{
|
||||
public static string getButton(string process, string arguments = "", string? icon = null, string? image = null)
|
||||
{
|
||||
Dictionary<string, string> parameters = new Dictionary<string, string>() { { "process", process } };
|
||||
if (!string.IsNullOrEmpty(arguments))
|
||||
{
|
||||
parameters.Add("arguments", arguments);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(icon) || !string.IsNullOrEmpty(image))
|
||||
{
|
||||
process = null;
|
||||
}
|
||||
|
||||
return getButtonHTML(icon, image, process, "button\\ProcessMacro", null, parameters);
|
||||
}
|
||||
|
||||
public static bool invokeAction(string process, string arguments = "")
|
||||
{
|
||||
if (!System.IO.File.ReadAllText("./configuration.yaml").Contains(process))
|
||||
{
|
||||
Debug.WriteLine("not known process");
|
||||
return true;
|
||||
}
|
||||
|
||||
Process notePad = new Process();
|
||||
notePad.StartInfo.FileName = process;
|
||||
notePad.StartInfo.Arguments = arguments;
|
||||
notePad.Start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -14,19 +14,19 @@ namespace FakeDeck.Class
|
||||
{
|
||||
private static string cachePath = "./cache/";
|
||||
public static string pageHeader =
|
||||
"<!DOCTYPE>" +
|
||||
"<html lang=\"en\">" +
|
||||
" <head>" +
|
||||
" <title>HttpListener Example</title>" +
|
||||
" <meta charset=\"utf-8\">" +
|
||||
" <meta name = \"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=yes\">" +
|
||||
" <link href=\"https://yarnpkg.com/en/package/normalize.css\" rel=\"stylesheet\">" +
|
||||
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css\" rel=\"stylesheet\">" +
|
||||
" <link href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css\" rel=\"stylesheet\">" +
|
||||
" <link href=\"StaticFiles/style.css\" rel=\"stylesheet\">" +
|
||||
" </head>" +
|
||||
" <body>" +
|
||||
" <div id=\"main\" class=\"d-flex flex-wrap\" style=\"transform-origin: left top;\">";
|
||||
"<!DOCTYPE>" +
|
||||
"<html lang=\"en\">" +
|
||||
" <head>" +
|
||||
" <title>HttpListener Example</title>" +
|
||||
" <meta charset=\"utf-8\">" +
|
||||
" <meta name = \"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=yes\">" +
|
||||
" <link href=\"https://yarnpkg.com/en/package/normalize.css\" rel=\"stylesheet\">" +
|
||||
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css\" rel=\"stylesheet\">" +
|
||||
" <link href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css\" rel=\"stylesheet\">" +
|
||||
" <link href=\"StaticFiles/style.css\" rel=\"stylesheet\">" +
|
||||
" </head>" +
|
||||
" <body>" +
|
||||
" <div id=\"main\" class=\"d-flex flex-wrap\" style=\"transform-origin: left top;\">";
|
||||
public static string pageFooter =
|
||||
" </div>" +
|
||||
" <script src=\"StaticFiles/app.js\"></script>" +
|
||||
@ -161,7 +161,13 @@ namespace FakeDeck.Class
|
||||
string pageContent = "";
|
||||
foreach (JsonElement button in selectedPage.GetProperty("buttons").EnumerateArray())
|
||||
{
|
||||
pageContent += AbstractionHelper.getButtonVisual(button);
|
||||
try
|
||||
{
|
||||
pageContent += AbstractionHelper.getButtonVisual(button);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (Directory.Exists(cachePath))
|
||||
|
@ -108,6 +108,22 @@ pages:
|
||||
|
||||
- page: media
|
||||
buttons:
|
||||
- button: notepad
|
||||
function: ProcessMacro
|
||||
parameters:
|
||||
- name: process
|
||||
value: "notepad.exe"
|
||||
- name: image
|
||||
value: "https://www.club386.com/wp-content/uploads/2021/12/notepad-icon-696x632.jpg"
|
||||
|
||||
- button: cmd
|
||||
function: ProcessMacro
|
||||
parameters:
|
||||
- name: process
|
||||
value: "cmd.exe"
|
||||
- name: image
|
||||
value: "https://winaero.com/blog/wp-content/uploads/2019/06/WIndows-Terminal-icon.png"
|
||||
|
||||
- button: mute
|
||||
function: MediaMacro
|
||||
parameters:
|
||||
|
Loading…
Reference in New Issue
Block a user