Refactoring

This commit is contained in:
Václav Španinger 2024-09-09 13:56:27 -07:00
parent b26a183624
commit 8051318d25
3 changed files with 25 additions and 25 deletions

View File

@ -8,17 +8,31 @@ namespace FakeeDeck.ButtonType
{ {
internal class Button internal class Button
{ {
public static string getButton(string Key) public static string getButtonHTML(string icon, string image, string name, string action, Dictionary<string, string> parameters)
{ {
return string body = "<div class=\"m-2\">";
"<div class=\"m-2\">" + body += "<form style=\"margin-bottom: 0px;\" method=\"post\" action=\"" + action + "\">";
" <form style=\"margin-bottom: 0px;\" method=\"post\" action=\"button\\stratogem\">" +
" <input type=\"hidden\" name=\"stratogem\" value=>" + foreach (var parameter in parameters)
" <input style=\"background-size: cover; ; width: 150px;height: 150px;background-color: aquamarine;\" type=\"submit\" value=\"\">" + {
" </form>" + body += "<input type=\"hidden\" name=\"" + parameter.Key + "\" value=\"" + parameter.Value + "\">";
"</div>"; }
body += "<button type=\"submit\" value=\"submit\" style=\"background-size: cover; " + (!string.IsNullOrEmpty(image) ? "background-image: url('" + image + "');" : "") + " width: 150px;height: 150px; background-color: aquamarine;\" >";
body += (!string.IsNullOrEmpty(icon) ? "<i class=\"fa-solid " + icon + "\"></i>" : name);
body += "</button>";
body += "</form>";
body += "</div>";
return body;
} }
public static string getButton(string Key)
{
return ""; //getButtonHTML(null, "https://docs.itego.cz/uploads/images/system/2022-04/OdRTPJ4iTTInmhdP-jagq7dfjpi2lilfg-imageedit-2-6604933313.gif");
}
public static bool invokeAction(string Key) public static bool invokeAction(string Key)
{ {
return false; return false;

View File

@ -49,13 +49,7 @@ namespace FakeeDeck.ButtonType
public static string getButton(string Key) public static string getButton(string Key)
{ {
return return getButtonHTML(null, stratogemsIcons[Key].ToString(), Key, "button\\HelldiversTwoMacro", new Dictionary<string, string>() { { "stratogem", Key } });
"<div class=\"m-2\">" +
" <form style=\"margin-bottom: 0px;\" method=\"post\" action=\"button\\HelldiversTwoMacro\">" +
" <input type=\"hidden\" name=\"stratogem\" value=\"" + Key + "\">" +
" <input style=\"background-size: cover; background-image: url('" + stratogemsIcons[Key].ToString() + "'); width: 150px;height: 150px;background-color: aquamarine;\" type=\"submit\" value=\"" + FirstLetterToUpper(Key) + "\">" +
" </form>" +
"</div>";
} }
public static bool invokeAction(string stratogem) public static bool invokeAction(string stratogem)

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace FakeeDeck.ButtonType namespace FakeeDeck.ButtonType
{ {
internal class MediaMacro internal class MediaMacro : Button
{ {
public static Dictionary<string, uint[]> mediaControls = new Dictionary<string, uint[]> public static Dictionary<string, uint[]> mediaControls = new Dictionary<string, uint[]>
{ {
@ -22,15 +22,7 @@ namespace FakeeDeck.ButtonType
public static string getButton(string Key) public static string getButton(string Key)
{ {
return return getButtonHTML(mediaIcons[Key], null, Key, "button\\MediaMacro", new Dictionary<string, string>() { { "control_action", Key } });
"<div class=\"m-2\">" +
" <form style=\"margin-bottom: 0px;\" method=\"post\" action=\"button\\MediaMacro\">" +
" <input type=\"hidden\" name=\"control_action\" value=\"" + Key + "\">" +
" <button type=\"submit\" value=\"" + Key + "\" style=\"width: 150px;height: 150px;background-color: aquamarine;\" >" +
" <i class=\"fa-solid "+ mediaIcons[Key] +"\"></i>" +
" </button>" +
" </form>" +
"</div>";
} }
public static bool invokeAction(string control_action) public static bool invokeAction(string control_action)