mirror of
https://github.com/Macro-Deck-App/Macro-Deck.git
synced 2026-05-06 21:51:04 +08:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="AdvancedSharpAdbClient" Version="3.3.12" />
|
||||
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageVersion Include="Cottle" Version="2.0.10" />
|
||||
<PackageVersion Include="Dax-FCTB" Version="2.16.26.120" />
|
||||
@@ -11,10 +12,10 @@
|
||||
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
||||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageVersion Include="sharpadbclient" Version="2.3.23" />
|
||||
<PackageVersion Include="QRCoder" Version="1.5.1" />
|
||||
<PackageVersion Include="sqlite-net-pcl" Version="1.8.116" />
|
||||
<PackageVersion Include="System.Collections" Version="4.3.0" />
|
||||
<PackageVersion Include="System.Drawing.Common" Version="8.0.0" />
|
||||
<PackageVersion Include="System.Drawing.Common" Version="8.0.4" />
|
||||
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
|
||||
@@ -40,6 +40,12 @@ public class MainConfiguration
|
||||
[JsonProperty("Update.InstallBeta")]
|
||||
public bool UpdateBetaVersions { get; set; }
|
||||
|
||||
[JsonProperty("Connection.Adb.Enabled")]
|
||||
public bool EnableAdbServer { get; set; } = true;
|
||||
|
||||
[JsonProperty("Connection.Adb.AutoStartApp")]
|
||||
public bool EnableAdbAutoStartApp { get; set; } = true;
|
||||
|
||||
[JsonProperty("Connection.Ssl.Enabled")]
|
||||
public bool EnableSsl { get; set; }
|
||||
|
||||
|
||||
20
MacroDeck/DataTypes/QrCode/QuickConnectQrCodeData.cs
Normal file
20
MacroDeck/DataTypes/QrCode/QuickConnectQrCodeData.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace SuchByte.MacroDeck.DataTypes.QrCode;
|
||||
|
||||
public class QuickConnectQrCodeData
|
||||
{
|
||||
public string InstanceName { get; set; }
|
||||
|
||||
public List<string> NetworkInterfaces { get; set; }
|
||||
|
||||
public int Port { get; set; }
|
||||
|
||||
public bool Ssl { get; set; }
|
||||
|
||||
public QuickConnectQrCodeData(string instanceName, List<string> networkInterfaces, int port, bool ssl)
|
||||
{
|
||||
InstanceName = instanceName;
|
||||
NetworkInterfaces = networkInterfaces;
|
||||
Port = port;
|
||||
Ssl = ssl;
|
||||
}
|
||||
}
|
||||
205
MacroDeck/GUI/MainWindow.Designer.cs
generated
205
MacroDeck/GUI/MainWindow.Designer.cs
generated
@@ -59,6 +59,7 @@ namespace SuchByte.MacroDeck.GUI
|
||||
lblVersion = new Label();
|
||||
contentPanel = new BufferedPanel();
|
||||
contentButtonPanel = new FlowLayoutPanel();
|
||||
btnNotifications = new NotificationButton();
|
||||
btnDeck = new ContentSelectorButton();
|
||||
panel1 = new Panel();
|
||||
btnExtensions = new ContentSelectorButton();
|
||||
@@ -67,12 +68,9 @@ namespace SuchByte.MacroDeck.GUI
|
||||
panel2 = new Panel();
|
||||
btnSettings = new ContentSelectorButton();
|
||||
lblNumClientsConnected = new Label();
|
||||
label1 = new Label();
|
||||
lblPort = new Label();
|
||||
lblIpAddressHostname = new Label();
|
||||
navigation = new RoundedPanel();
|
||||
btnNotifications = new NotificationButton();
|
||||
hosts = new RoundedComboBox();
|
||||
qrCodeBox = new PictureBox();
|
||||
label1 = new Label();
|
||||
contentButtonPanel.SuspendLayout();
|
||||
((ISupportInitialize)btnDeck).BeginInit();
|
||||
((ISupportInitialize)btnExtensions).BeginInit();
|
||||
@@ -80,6 +78,7 @@ namespace SuchByte.MacroDeck.GUI
|
||||
((ISupportInitialize)btnVariables).BeginInit();
|
||||
((ISupportInitialize)btnSettings).BeginInit();
|
||||
navigation.SuspendLayout();
|
||||
((ISupportInitialize)qrCodeBox).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// lblSafeMode
|
||||
@@ -89,29 +88,31 @@ namespace SuchByte.MacroDeck.GUI
|
||||
//
|
||||
// lblVersion
|
||||
//
|
||||
lblVersion.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
lblVersion.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
lblVersion.Font = new Font("Tahoma", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0);
|
||||
lblVersion.ForeColor = Color.White;
|
||||
lblVersion.Location = new Point(2, 603);
|
||||
lblVersion.Location = new Point(1046, 613);
|
||||
lblVersion.Margin = new Padding(9, 0, 9, 0);
|
||||
lblVersion.Name = "lblVersion";
|
||||
lblVersion.Size = new Size(328, 30);
|
||||
lblVersion.Size = new Size(154, 20);
|
||||
lblVersion.TabIndex = 3;
|
||||
lblVersion.Text = "2.0.0";
|
||||
lblVersion.TextAlign = ContentAlignment.MiddleLeft;
|
||||
lblVersion.TextAlign = ContentAlignment.MiddleRight;
|
||||
lblVersion.UseMnemonic = false;
|
||||
//
|
||||
// contentPanel
|
||||
//
|
||||
contentPanel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
contentPanel.Location = new Point(69, 94);
|
||||
contentPanel.Location = new Point(65, 42);
|
||||
contentPanel.Margin = new Padding(9, 4, 9, 4);
|
||||
contentPanel.Name = "contentPanel";
|
||||
contentPanel.Size = new Size(1131, 509);
|
||||
contentPanel.Size = new Size(981, 591);
|
||||
contentPanel.TabIndex = 4;
|
||||
//
|
||||
// contentButtonPanel
|
||||
//
|
||||
contentButtonPanel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
contentButtonPanel.Controls.Add(btnNotifications);
|
||||
contentButtonPanel.Controls.Add(btnDeck);
|
||||
contentButtonPanel.Controls.Add(panel1);
|
||||
contentButtonPanel.Controls.Add(btnExtensions);
|
||||
@@ -119,21 +120,45 @@ namespace SuchByte.MacroDeck.GUI
|
||||
contentButtonPanel.Controls.Add(btnVariables);
|
||||
contentButtonPanel.Controls.Add(panel2);
|
||||
contentButtonPanel.FlowDirection = FlowDirection.TopDown;
|
||||
contentButtonPanel.Location = new Point(8, 9);
|
||||
contentButtonPanel.Location = new Point(8, 7);
|
||||
contentButtonPanel.Margin = new Padding(0);
|
||||
contentButtonPanel.Name = "contentButtonPanel";
|
||||
contentButtonPanel.Size = new Size(45, 470);
|
||||
contentButtonPanel.Size = new Size(45, 528);
|
||||
contentButtonPanel.TabIndex = 5;
|
||||
//
|
||||
// btnNotifications
|
||||
//
|
||||
btnNotifications.BorderRadius = 8;
|
||||
btnNotifications.Cursor = Cursors.Hand;
|
||||
btnNotifications.FlatAppearance.BorderSize = 0;
|
||||
btnNotifications.FlatStyle = FlatStyle.Flat;
|
||||
btnNotifications.Font = new Font("Tahoma", 8F);
|
||||
btnNotifications.ForeColor = Color.White;
|
||||
btnNotifications.HoverColor = Color.Empty;
|
||||
btnNotifications.Icon = Properties.Resources.Bell;
|
||||
btnNotifications.Location = new Point(0, 4);
|
||||
btnNotifications.Margin = new Padding(0, 4, 0, 4);
|
||||
btnNotifications.Name = "btnNotifications";
|
||||
btnNotifications.NotificationCount = 0;
|
||||
btnNotifications.Progress = 0;
|
||||
btnNotifications.ProgressColor = Color.FromArgb(0, 103, 205);
|
||||
btnNotifications.Size = new Size(44, 44);
|
||||
btnNotifications.TabIndex = 16;
|
||||
btnNotifications.UseVisualStyleBackColor = true;
|
||||
btnNotifications.UseWindowsAccentColor = false;
|
||||
btnNotifications.Visible = false;
|
||||
btnNotifications.WriteProgress = true;
|
||||
btnNotifications.Click += BtnNotifications_Click;
|
||||
//
|
||||
// btnDeck
|
||||
//
|
||||
btnDeck.BackColor = Color.Transparent;
|
||||
btnDeck.BackgroundImage = Properties.Resources.deck;
|
||||
btnDeck.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
btnDeck.Cursor = Cursors.Hand;
|
||||
btnDeck.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
btnDeck.Font = new Font("Tahoma", 9.75F);
|
||||
btnDeck.ForeColor = Color.White;
|
||||
btnDeck.Location = new Point(0, 0);
|
||||
btnDeck.Location = new Point(0, 52);
|
||||
btnDeck.Margin = new Padding(0, 0, 0, 6);
|
||||
btnDeck.Name = "btnDeck";
|
||||
btnDeck.Selected = false;
|
||||
@@ -145,7 +170,7 @@ namespace SuchByte.MacroDeck.GUI
|
||||
// panel1
|
||||
//
|
||||
panel1.BackColor = Color.Silver;
|
||||
panel1.Location = new Point(0, 54);
|
||||
panel1.Location = new Point(0, 106);
|
||||
panel1.Margin = new Padding(0, 4, 0, 4);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(66, 3);
|
||||
@@ -157,9 +182,9 @@ namespace SuchByte.MacroDeck.GUI
|
||||
btnExtensions.BackgroundImage = Properties.Resources.Package_Manager_icon;
|
||||
btnExtensions.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
btnExtensions.Cursor = Cursors.Hand;
|
||||
btnExtensions.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
btnExtensions.Font = new Font("Tahoma", 9.75F);
|
||||
btnExtensions.ForeColor = Color.White;
|
||||
btnExtensions.Location = new Point(0, 67);
|
||||
btnExtensions.Location = new Point(0, 119);
|
||||
btnExtensions.Margin = new Padding(0, 6, 0, 6);
|
||||
btnExtensions.Name = "btnExtensions";
|
||||
btnExtensions.Selected = false;
|
||||
@@ -174,9 +199,9 @@ namespace SuchByte.MacroDeck.GUI
|
||||
btnDeviceManager.BackgroundImage = Properties.Resources.device_manager;
|
||||
btnDeviceManager.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
btnDeviceManager.Cursor = Cursors.Hand;
|
||||
btnDeviceManager.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
btnDeviceManager.Font = new Font("Tahoma", 9.75F);
|
||||
btnDeviceManager.ForeColor = Color.White;
|
||||
btnDeviceManager.Location = new Point(0, 123);
|
||||
btnDeviceManager.Location = new Point(0, 175);
|
||||
btnDeviceManager.Margin = new Padding(0, 6, 0, 6);
|
||||
btnDeviceManager.Name = "btnDeviceManager";
|
||||
btnDeviceManager.Selected = false;
|
||||
@@ -191,9 +216,9 @@ namespace SuchByte.MacroDeck.GUI
|
||||
btnVariables.BackgroundImage = Properties.Resources.variables;
|
||||
btnVariables.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
btnVariables.Cursor = Cursors.Hand;
|
||||
btnVariables.Font = new Font("Tahoma", 12.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
btnVariables.Font = new Font("Tahoma", 12.75F);
|
||||
btnVariables.ForeColor = Color.White;
|
||||
btnVariables.Location = new Point(0, 179);
|
||||
btnVariables.Location = new Point(0, 231);
|
||||
btnVariables.Margin = new Padding(0, 6, 0, 6);
|
||||
btnVariables.Name = "btnVariables";
|
||||
btnVariables.Selected = false;
|
||||
@@ -206,7 +231,7 @@ namespace SuchByte.MacroDeck.GUI
|
||||
// panel2
|
||||
//
|
||||
panel2.BackColor = Color.Silver;
|
||||
panel2.Location = new Point(0, 233);
|
||||
panel2.Location = new Point(0, 285);
|
||||
panel2.Margin = new Padding(0, 4, 0, 4);
|
||||
panel2.Name = "panel2";
|
||||
panel2.Size = new Size(66, 3);
|
||||
@@ -219,9 +244,9 @@ namespace SuchByte.MacroDeck.GUI
|
||||
btnSettings.BackgroundImage = Properties.Resources.settings;
|
||||
btnSettings.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
btnSettings.Cursor = Cursors.Hand;
|
||||
btnSettings.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
btnSettings.Font = new Font("Tahoma", 9.75F);
|
||||
btnSettings.ForeColor = Color.White;
|
||||
btnSettings.Location = new Point(8, 511);
|
||||
btnSettings.Location = new Point(8, 541);
|
||||
btnSettings.Margin = new Padding(12, 6, 12, 6);
|
||||
btnSettings.Name = "btnSettings";
|
||||
btnSettings.Selected = false;
|
||||
@@ -233,59 +258,17 @@ namespace SuchByte.MacroDeck.GUI
|
||||
// lblNumClientsConnected
|
||||
//
|
||||
lblNumClientsConnected.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
lblNumClientsConnected.Font = new Font("Tahoma", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblNumClientsConnected.Font = new Font("Tahoma", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0);
|
||||
lblNumClientsConnected.ForeColor = Color.White;
|
||||
lblNumClientsConnected.Location = new Point(936, 606);
|
||||
lblNumClientsConnected.Location = new Point(1046, 593);
|
||||
lblNumClientsConnected.Margin = new Padding(9, 0, 9, 0);
|
||||
lblNumClientsConnected.Name = "lblNumClientsConnected";
|
||||
lblNumClientsConnected.Size = new Size(264, 27);
|
||||
lblNumClientsConnected.Size = new Size(154, 20);
|
||||
lblNumClientsConnected.TabIndex = 8;
|
||||
lblNumClientsConnected.Text = "0 clients connected";
|
||||
lblNumClientsConnected.TextAlign = ContentAlignment.MiddleRight;
|
||||
lblNumClientsConnected.UseMnemonic = false;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
label1.AutoSize = true;
|
||||
label1.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
label1.Location = new Point(1094, 44);
|
||||
label1.Margin = new Padding(9, 0, 9, 0);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(15, 19);
|
||||
label1.TabIndex = 10;
|
||||
label1.Text = ":";
|
||||
label1.UseMnemonic = false;
|
||||
//
|
||||
// lblPort
|
||||
//
|
||||
lblPort.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
lblPort.BackColor = Color.FromArgb(45, 45, 45);
|
||||
lblPort.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblPort.ForeColor = Color.White;
|
||||
lblPort.Location = new Point(1127, 37);
|
||||
lblPort.Margin = new Padding(9, 0, 9, 0);
|
||||
lblPort.Name = "lblPort";
|
||||
lblPort.Size = new Size(69, 32);
|
||||
lblPort.TabIndex = 11;
|
||||
lblPort.Text = "8191";
|
||||
lblPort.TextAlign = ContentAlignment.MiddleLeft;
|
||||
lblPort.UseMnemonic = false;
|
||||
//
|
||||
// lblIpAddressHostname
|
||||
//
|
||||
lblIpAddressHostname.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
lblIpAddressHostname.Font = new Font("Tahoma", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblIpAddressHostname.ForeColor = Color.White;
|
||||
lblIpAddressHostname.Location = new Point(225, 42);
|
||||
lblIpAddressHostname.Margin = new Padding(9, 0, 9, 0);
|
||||
lblIpAddressHostname.Name = "lblIpAddressHostname";
|
||||
lblIpAddressHostname.Size = new Size(468, 27);
|
||||
lblIpAddressHostname.TabIndex = 13;
|
||||
lblIpAddressHostname.Text = "IP address/hostname : Port";
|
||||
lblIpAddressHostname.TextAlign = ContentAlignment.MiddleRight;
|
||||
lblIpAddressHostname.UseMnemonic = false;
|
||||
//
|
||||
// navigation
|
||||
//
|
||||
navigation.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
@@ -295,50 +278,32 @@ namespace SuchByte.MacroDeck.GUI
|
||||
navigation.Location = new Point(0, 42);
|
||||
navigation.Margin = new Padding(0);
|
||||
navigation.Name = "navigation";
|
||||
navigation.Size = new Size(60, 561);
|
||||
navigation.Size = new Size(60, 591);
|
||||
navigation.TabIndex = 15;
|
||||
//
|
||||
// btnNotifications
|
||||
// qrCodeBox
|
||||
//
|
||||
btnNotifications.BorderRadius = 8;
|
||||
btnNotifications.Cursor = Cursors.Hand;
|
||||
btnNotifications.FlatAppearance.BorderSize = 0;
|
||||
btnNotifications.FlatStyle = FlatStyle.Flat;
|
||||
btnNotifications.Font = new Font("Tahoma", 8F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
btnNotifications.ForeColor = Color.White;
|
||||
btnNotifications.HoverColor = Color.Empty;
|
||||
btnNotifications.Icon = Properties.Resources.Bell;
|
||||
btnNotifications.Location = new Point(69, 42);
|
||||
btnNotifications.Margin = new Padding(4);
|
||||
btnNotifications.Name = "btnNotifications";
|
||||
btnNotifications.NotificationCount = 0;
|
||||
btnNotifications.Padding = new Padding(0, 4, 4, 0);
|
||||
btnNotifications.Progress = 0;
|
||||
btnNotifications.ProgressColor = Color.FromArgb(0, 103, 205);
|
||||
btnNotifications.Size = new Size(44, 44);
|
||||
btnNotifications.TabIndex = 16;
|
||||
btnNotifications.UseVisualStyleBackColor = true;
|
||||
btnNotifications.UseWindowsAccentColor = false;
|
||||
btnNotifications.Visible = false;
|
||||
btnNotifications.WriteProgress = true;
|
||||
btnNotifications.Click += BtnNotifications_Click;
|
||||
qrCodeBox.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
qrCodeBox.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
qrCodeBox.Location = new Point(1058, 66);
|
||||
qrCodeBox.Name = "qrCodeBox";
|
||||
qrCodeBox.Size = new Size(130, 130);
|
||||
qrCodeBox.TabIndex = 17;
|
||||
qrCodeBox.TabStop = false;
|
||||
//
|
||||
// hosts
|
||||
// label1
|
||||
//
|
||||
hosts.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
hosts.BackColor = Color.FromArgb(65, 65, 65);
|
||||
hosts.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
hosts.Font = new Font("Tahoma", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
hosts.Icon = null;
|
||||
hosts.Location = new Point(706, 41);
|
||||
hosts.Margin = new Padding(4);
|
||||
hosts.Name = "hosts";
|
||||
hosts.Padding = new Padding(12, 3, 12, 3);
|
||||
hosts.SelectedIndex = -1;
|
||||
hosts.SelectedItem = null;
|
||||
hosts.Size = new Size(375, 28);
|
||||
hosts.TabIndex = 17;
|
||||
hosts.SelectedIndexChanged += Hosts_SelectedIndexChanged;
|
||||
label1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
label1.Font = new Font("Tahoma", 9.75F, FontStyle.Bold, GraphicsUnit.Point, 0);
|
||||
label1.ForeColor = Color.White;
|
||||
label1.Location = new Point(1046, 42);
|
||||
label1.Margin = new Padding(9, 0, 9, 0);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(154, 20);
|
||||
label1.TabIndex = 18;
|
||||
label1.Text = "Quick Setup";
|
||||
label1.TextAlign = ContentAlignment.MiddleCenter;
|
||||
label1.UseMnemonic = false;
|
||||
//
|
||||
// MainWindow
|
||||
//
|
||||
@@ -346,12 +311,9 @@ namespace SuchByte.MacroDeck.GUI
|
||||
AutoScaleMode = AutoScaleMode.Dpi;
|
||||
BackColor = Color.FromArgb(45, 45, 45);
|
||||
ClientSize = new Size(1200, 635);
|
||||
Controls.Add(hosts);
|
||||
Controls.Add(btnNotifications);
|
||||
Controls.Add(navigation);
|
||||
Controls.Add(lblIpAddressHostname);
|
||||
Controls.Add(lblPort);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(qrCodeBox);
|
||||
Controls.Add(navigation);
|
||||
Controls.Add(lblNumClientsConnected);
|
||||
Controls.Add(contentPanel);
|
||||
Controls.Add(lblVersion);
|
||||
@@ -366,12 +328,9 @@ namespace SuchByte.MacroDeck.GUI
|
||||
Controls.SetChildIndex(lblVersion, 0);
|
||||
Controls.SetChildIndex(contentPanel, 0);
|
||||
Controls.SetChildIndex(lblNumClientsConnected, 0);
|
||||
Controls.SetChildIndex(label1, 0);
|
||||
Controls.SetChildIndex(lblPort, 0);
|
||||
Controls.SetChildIndex(lblIpAddressHostname, 0);
|
||||
Controls.SetChildIndex(navigation, 0);
|
||||
Controls.SetChildIndex(btnNotifications, 0);
|
||||
Controls.SetChildIndex(hosts, 0);
|
||||
Controls.SetChildIndex(qrCodeBox, 0);
|
||||
Controls.SetChildIndex(label1, 0);
|
||||
contentButtonPanel.ResumeLayout(false);
|
||||
((ISupportInitialize)btnDeck).EndInit();
|
||||
((ISupportInitialize)btnExtensions).EndInit();
|
||||
@@ -379,8 +338,8 @@ namespace SuchByte.MacroDeck.GUI
|
||||
((ISupportInitialize)btnVariables).EndInit();
|
||||
((ISupportInitialize)btnSettings).EndInit();
|
||||
navigation.ResumeLayout(false);
|
||||
((ISupportInitialize)qrCodeBox).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -393,13 +352,11 @@ namespace SuchByte.MacroDeck.GUI
|
||||
private ContentSelectorButton btnDeviceManager;
|
||||
private Label lblNumClientsConnected;
|
||||
private ContentSelectorButton btnVariables;
|
||||
private Label label1;
|
||||
private Label lblPort;
|
||||
private Label lblIpAddressHostname;
|
||||
private Panel panel1;
|
||||
private Panel panel2;
|
||||
private RoundedPanel navigation;
|
||||
private NotificationButton btnNotifications;
|
||||
private RoundedComboBox hosts;
|
||||
private PictureBox qrCodeBox;
|
||||
private Label label1;
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,6 @@ public partial class MainWindow : Form
|
||||
|
||||
private void UpdateTranslation()
|
||||
{
|
||||
lblIpAddressHostname.Text = LanguageManager.Strings.IpAddressHostNamePort;
|
||||
}
|
||||
|
||||
private void LanguageChanged(object? sender, EventArgs e)
|
||||
@@ -115,7 +114,6 @@ public partial class MainWindow : Form
|
||||
{
|
||||
Application.DoEvents();
|
||||
RefreshPluginsLabels();
|
||||
LoadHosts();
|
||||
|
||||
if (MacroDeck.SafeMode)
|
||||
{
|
||||
@@ -138,6 +136,8 @@ public partial class MainWindow : Form
|
||||
using var updateAvailableDialog = new UpdateAvailableDialog(updateApiVersionInfo);
|
||||
updateAvailableDialog.ShowDialog();
|
||||
}
|
||||
|
||||
this.qrCodeBox.BackgroundImage = QrCodeService.Instance.GetQuickSetupQrCode();
|
||||
}
|
||||
|
||||
private void MainWindow_Load(object? sender, EventArgs e)
|
||||
@@ -158,26 +158,6 @@ public partial class MainWindow : Form
|
||||
CenterToScreen();
|
||||
}
|
||||
|
||||
private void LoadHosts()
|
||||
{
|
||||
hosts.SelectedIndexChanged -= Hosts_SelectedIndexChanged;
|
||||
foreach (var networkInterface in NetworkInterface.GetAllNetworkInterfaces())
|
||||
{
|
||||
var ipAddress = networkInterface
|
||||
.GetIPProperties()
|
||||
.UnicastAddresses
|
||||
.FirstOrDefault(x => x.Address.AddressFamily == AddressFamily.InterNetwork)
|
||||
?.Address
|
||||
.ToString();
|
||||
if (!string.IsNullOrWhiteSpace(ipAddress))
|
||||
{
|
||||
hosts.Items.Add(ipAddress);
|
||||
}
|
||||
}
|
||||
hosts.Text = MacroDeck.Configuration.HostAddress;
|
||||
hosts.SelectedIndexChanged += Hosts_SelectedIndexChanged;
|
||||
}
|
||||
|
||||
private void NotificationsChanged(object? sender, EventArgs e)
|
||||
{
|
||||
btnNotifications.NotificationCount = NotificationManager.Notifications.Count;
|
||||
@@ -254,7 +234,7 @@ public partial class MainWindow : Form
|
||||
{
|
||||
_notificationsList = new NotificationsList
|
||||
{
|
||||
Location = btnNotifications.Location with { Y = btnNotifications.Location.Y + btnNotifications.Height }
|
||||
Location = btnNotifications.Location with { Y = btnNotifications.Location.Y + btnNotifications.Height, X = btnNotifications.Location.X + btnNotifications.Size.Width + 20 }
|
||||
};
|
||||
_notificationsList.OnCloseRequested += (_, _) =>
|
||||
{
|
||||
@@ -272,10 +252,4 @@ public partial class MainWindow : Form
|
||||
_notificationsList.BringToFront();
|
||||
}
|
||||
}
|
||||
|
||||
private void Hosts_SelectedIndexChanged(object? sender, EventArgs e)
|
||||
{
|
||||
MacroDeck.Configuration.HostAddress = hosts.Text;
|
||||
MacroDeck.Configuration.Save(ApplicationPaths.MainConfigFilePath);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,64 @@
|
||||
<root>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
109
MacroDeck/GUI/MainWindowViews/SettingsView.Designer.cs
generated
109
MacroDeck/GUI/MainWindowViews/SettingsView.Designer.cs
generated
@@ -45,6 +45,9 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
lblBehaviour = new Label();
|
||||
lblGeneral = new Label();
|
||||
tabConnection = new TabPage();
|
||||
checkAutoStartUsb = new CheckBox();
|
||||
checkEnableAdb = new CheckBox();
|
||||
label5 = new Label();
|
||||
btnApplySslConfiguration = new ButtonPrimary();
|
||||
btnBrowseCertificatePath = new ButtonPrimary();
|
||||
label4 = new Label();
|
||||
@@ -104,7 +107,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
verticalTabControl.Controls.Add(tabUpdater);
|
||||
verticalTabControl.Controls.Add(tabBackups);
|
||||
verticalTabControl.Controls.Add(tabAbout);
|
||||
verticalTabControl.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
verticalTabControl.Font = new Font("Tahoma", 12F);
|
||||
verticalTabControl.ImageList = tabIcons;
|
||||
verticalTabControl.ItemSize = new Size(44, 200);
|
||||
verticalTabControl.Location = new Point(3, 3);
|
||||
@@ -124,7 +127,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
tabGeneral.Controls.Add(checkStartWindows);
|
||||
tabGeneral.Controls.Add(lblBehaviour);
|
||||
tabGeneral.Controls.Add(lblGeneral);
|
||||
tabGeneral.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
tabGeneral.Font = new Font("Tahoma", 12F);
|
||||
tabGeneral.ForeColor = Color.White;
|
||||
tabGeneral.Location = new Point(204, 4);
|
||||
tabGeneral.Name = "tabGeneral";
|
||||
@@ -138,7 +141,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
language.BackColor = Color.FromArgb(65, 65, 65);
|
||||
language.Cursor = Cursors.Hand;
|
||||
language.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
language.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
language.Font = new Font("Tahoma", 12F);
|
||||
language.ForeColor = Color.White;
|
||||
language.Icon = null;
|
||||
language.Location = new Point(12, 222);
|
||||
@@ -153,7 +156,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// lblLanguage
|
||||
//
|
||||
lblLanguage.AutoSize = true;
|
||||
lblLanguage.Font = new Font("Tahoma", 14.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblLanguage.Font = new Font("Tahoma", 14.25F);
|
||||
lblLanguage.ForeColor = Color.Gray;
|
||||
lblLanguage.Location = new Point(3, 198);
|
||||
lblLanguage.Name = "lblLanguage";
|
||||
@@ -177,7 +180,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// lblBehaviour
|
||||
//
|
||||
lblBehaviour.AutoSize = true;
|
||||
lblBehaviour.Font = new Font("Tahoma", 14.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblBehaviour.Font = new Font("Tahoma", 14.25F);
|
||||
lblBehaviour.ForeColor = Color.Gray;
|
||||
lblBehaviour.Location = new Point(3, 63);
|
||||
lblBehaviour.Name = "lblBehaviour";
|
||||
@@ -189,7 +192,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// lblGeneral
|
||||
//
|
||||
lblGeneral.AutoSize = true;
|
||||
lblGeneral.Font = new Font("Tahoma", 15.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblGeneral.Font = new Font("Tahoma", 15.75F);
|
||||
lblGeneral.Location = new Point(3, 0);
|
||||
lblGeneral.Name = "lblGeneral";
|
||||
lblGeneral.Size = new Size(84, 25);
|
||||
@@ -200,6 +203,9 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// tabConnection
|
||||
//
|
||||
tabConnection.BackColor = Color.FromArgb(45, 45, 45);
|
||||
tabConnection.Controls.Add(checkAutoStartUsb);
|
||||
tabConnection.Controls.Add(checkEnableAdb);
|
||||
tabConnection.Controls.Add(label5);
|
||||
tabConnection.Controls.Add(btnApplySslConfiguration);
|
||||
tabConnection.Controls.Add(btnBrowseCertificatePath);
|
||||
tabConnection.Controls.Add(label4);
|
||||
@@ -212,7 +218,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
tabConnection.Controls.Add(port);
|
||||
tabConnection.Controls.Add(lblPort);
|
||||
tabConnection.Controls.Add(lblConnection);
|
||||
tabConnection.Font = new Font("Tahoma", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
tabConnection.Font = new Font("Tahoma", 9F);
|
||||
tabConnection.ForeColor = Color.White;
|
||||
tabConnection.Location = new Point(204, 4);
|
||||
tabConnection.Name = "tabConnection";
|
||||
@@ -220,13 +226,49 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
tabConnection.TabIndex = 3;
|
||||
tabConnection.Text = "Connection";
|
||||
//
|
||||
// checkAutoStartUsb
|
||||
//
|
||||
checkAutoStartUsb.AutoSize = true;
|
||||
checkAutoStartUsb.Font = new Font("Tahoma", 12F);
|
||||
checkAutoStartUsb.Location = new Point(14, 395);
|
||||
checkAutoStartUsb.Name = "checkAutoStartUsb";
|
||||
checkAutoStartUsb.Size = new Size(532, 23);
|
||||
checkAutoStartUsb.TabIndex = 27;
|
||||
checkAutoStartUsb.Text = "Automatically wake screen and start Macro Deck Client when connected";
|
||||
checkAutoStartUsb.UseMnemonic = false;
|
||||
checkAutoStartUsb.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkEnableAdb
|
||||
//
|
||||
checkEnableAdb.AutoSize = true;
|
||||
checkEnableAdb.Font = new Font("Tahoma", 12F);
|
||||
checkEnableAdb.Location = new Point(14, 366);
|
||||
checkEnableAdb.Name = "checkEnableAdb";
|
||||
checkEnableAdb.Size = new Size(520, 23);
|
||||
checkEnableAdb.TabIndex = 26;
|
||||
checkEnableAdb.Text = "Enable Android Debug Bridge (Required for Android USB connection)";
|
||||
checkEnableAdb.UseMnemonic = false;
|
||||
checkEnableAdb.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Font = new Font("Tahoma", 14.25F);
|
||||
label5.ForeColor = Color.Gray;
|
||||
label5.Location = new Point(5, 340);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(44, 23);
|
||||
label5.TabIndex = 25;
|
||||
label5.Text = "USB";
|
||||
label5.UseMnemonic = false;
|
||||
//
|
||||
// btnApplySslConfiguration
|
||||
//
|
||||
btnApplySslConfiguration.BorderRadius = 8;
|
||||
btnApplySslConfiguration.Cursor = Cursors.Hand;
|
||||
btnApplySslConfiguration.FlatAppearance.BorderSize = 0;
|
||||
btnApplySslConfiguration.FlatStyle = FlatStyle.Flat;
|
||||
btnApplySslConfiguration.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
btnApplySslConfiguration.Font = new Font("Tahoma", 9.75F);
|
||||
btnApplySslConfiguration.ForeColor = Color.White;
|
||||
btnApplySslConfiguration.HoverColor = Color.FromArgb(0, 89, 184);
|
||||
btnApplySslConfiguration.Icon = null;
|
||||
@@ -249,7 +291,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
btnBrowseCertificatePath.Cursor = Cursors.Hand;
|
||||
btnBrowseCertificatePath.FlatAppearance.BorderSize = 0;
|
||||
btnBrowseCertificatePath.FlatStyle = FlatStyle.Flat;
|
||||
btnBrowseCertificatePath.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
btnBrowseCertificatePath.Font = new Font("Tahoma", 9.75F);
|
||||
btnBrowseCertificatePath.ForeColor = Color.White;
|
||||
btnBrowseCertificatePath.HoverColor = Color.FromArgb(0, 89, 184);
|
||||
btnBrowseCertificatePath.Icon = null;
|
||||
@@ -268,7 +310,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.Font = new Font("Tahoma", 11.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
label4.Font = new Font("Tahoma", 11.25F);
|
||||
label4.Location = new Point(17, 258);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(159, 30);
|
||||
@@ -280,7 +322,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// certificatePassword
|
||||
//
|
||||
certificatePassword.BackColor = Color.FromArgb(65, 65, 65);
|
||||
certificatePassword.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
certificatePassword.Font = new Font("Tahoma", 12F);
|
||||
certificatePassword.Icon = null;
|
||||
certificatePassword.Location = new Point(182, 258);
|
||||
certificatePassword.MaxCharacters = 32767;
|
||||
@@ -299,7 +341,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.Font = new Font("Tahoma", 11.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
label3.Font = new Font("Tahoma", 11.25F);
|
||||
label3.Location = new Point(17, 222);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(159, 30);
|
||||
@@ -311,7 +353,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// certificatePath
|
||||
//
|
||||
certificatePath.BackColor = Color.FromArgb(65, 65, 65);
|
||||
certificatePath.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
certificatePath.Font = new Font("Tahoma", 12F);
|
||||
certificatePath.Icon = null;
|
||||
certificatePath.Location = new Point(182, 222);
|
||||
certificatePath.MaxCharacters = 32767;
|
||||
@@ -331,7 +373,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// checkEnableSsl
|
||||
//
|
||||
checkEnableSsl.AutoSize = true;
|
||||
checkEnableSsl.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
checkEnableSsl.Font = new Font("Tahoma", 12F);
|
||||
checkEnableSsl.Location = new Point(12, 193);
|
||||
checkEnableSsl.Name = "checkEnableSsl";
|
||||
checkEnableSsl.Size = new Size(106, 23);
|
||||
@@ -343,7 +385,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// labelSsl
|
||||
//
|
||||
labelSsl.AutoSize = true;
|
||||
labelSsl.Font = new Font("Tahoma", 14.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
labelSsl.Font = new Font("Tahoma", 14.25F);
|
||||
labelSsl.ForeColor = Color.Gray;
|
||||
labelSsl.Location = new Point(3, 167);
|
||||
labelSsl.Name = "labelSsl";
|
||||
@@ -358,7 +400,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
btnChangePort.Cursor = Cursors.Hand;
|
||||
btnChangePort.FlatAppearance.BorderSize = 0;
|
||||
btnChangePort.FlatStyle = FlatStyle.Flat;
|
||||
btnChangePort.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
btnChangePort.Font = new Font("Tahoma", 9.75F);
|
||||
btnChangePort.ForeColor = Color.White;
|
||||
btnChangePort.HoverColor = Color.FromArgb(0, 89, 184);
|
||||
btnChangePort.Icon = null;
|
||||
@@ -379,7 +421,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
//
|
||||
port.BackColor = Color.FromArgb(65, 65, 65);
|
||||
port.BorderStyle = BorderStyle.FixedSingle;
|
||||
port.Font = new Font("Tahoma", 11.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
port.Font = new Font("Tahoma", 11.25F);
|
||||
port.ForeColor = Color.White;
|
||||
port.Location = new Point(13, 89);
|
||||
port.Maximum = new decimal(new int[] { 65535, 0, 0, 0 });
|
||||
@@ -391,7 +433,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// lblPort
|
||||
//
|
||||
lblPort.AutoSize = true;
|
||||
lblPort.Font = new Font("Tahoma", 14.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblPort.Font = new Font("Tahoma", 14.25F);
|
||||
lblPort.ForeColor = Color.Gray;
|
||||
lblPort.Location = new Point(3, 63);
|
||||
lblPort.Name = "lblPort";
|
||||
@@ -403,7 +445,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// lblConnection
|
||||
//
|
||||
lblConnection.AutoSize = true;
|
||||
lblConnection.Font = new Font("Tahoma", 15.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblConnection.Font = new Font("Tahoma", 15.75F);
|
||||
lblConnection.Location = new Point(3, 0);
|
||||
lblConnection.Name = "lblConnection";
|
||||
lblConnection.Size = new Size(116, 25);
|
||||
@@ -421,7 +463,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
tabUpdater.Controls.Add(lblInstalledVersion);
|
||||
tabUpdater.Controls.Add(lblInstalledVersionLabel);
|
||||
tabUpdater.Controls.Add(lblUpdates);
|
||||
tabUpdater.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
tabUpdater.Font = new Font("Tahoma", 12F);
|
||||
tabUpdater.ForeColor = Color.White;
|
||||
tabUpdater.Location = new Point(204, 4);
|
||||
tabUpdater.Name = "tabUpdater";
|
||||
@@ -432,7 +474,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Font = new Font("Tahoma", 14.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
label2.Font = new Font("Tahoma", 14.25F);
|
||||
label2.ForeColor = Color.Gray;
|
||||
label2.Location = new Point(3, 63);
|
||||
label2.Name = "label2";
|
||||
@@ -469,7 +511,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
btnCheckUpdates.Cursor = Cursors.Hand;
|
||||
btnCheckUpdates.FlatAppearance.BorderSize = 0;
|
||||
btnCheckUpdates.FlatStyle = FlatStyle.Flat;
|
||||
btnCheckUpdates.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
btnCheckUpdates.Font = new Font("Tahoma", 9.75F);
|
||||
btnCheckUpdates.ForeColor = Color.White;
|
||||
btnCheckUpdates.HoverColor = Color.FromArgb(0, 89, 184);
|
||||
btnCheckUpdates.Icon = null;
|
||||
@@ -509,7 +551,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// lblUpdates
|
||||
//
|
||||
lblUpdates.AutoSize = true;
|
||||
lblUpdates.Font = new Font("Tahoma", 15.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblUpdates.Font = new Font("Tahoma", 15.75F);
|
||||
lblUpdates.Location = new Point(3, 0);
|
||||
lblUpdates.Name = "lblUpdates";
|
||||
lblUpdates.Size = new Size(88, 25);
|
||||
@@ -537,7 +579,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
btnCreateBackup.Cursor = Cursors.Hand;
|
||||
btnCreateBackup.FlatAppearance.BorderSize = 0;
|
||||
btnCreateBackup.FlatStyle = FlatStyle.Flat;
|
||||
btnCreateBackup.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
btnCreateBackup.Font = new Font("Tahoma", 9.75F);
|
||||
btnCreateBackup.ForeColor = Color.White;
|
||||
btnCreateBackup.HoverColor = Color.FromArgb(0, 89, 184);
|
||||
btnCreateBackup.Icon = null;
|
||||
@@ -565,7 +607,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
// lblBackups
|
||||
//
|
||||
lblBackups.AutoSize = true;
|
||||
lblBackups.Font = new Font("Tahoma", 15.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblBackups.Font = new Font("Tahoma", 15.75F);
|
||||
lblBackups.Location = new Point(3, 0);
|
||||
lblBackups.Name = "lblBackups";
|
||||
lblBackups.Size = new Size(89, 25);
|
||||
@@ -589,7 +631,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
tabAbout.Controls.Add(lblDeveloped);
|
||||
tabAbout.Controls.Add(lblMacroDeck);
|
||||
tabAbout.Controls.Add(pictureBox1);
|
||||
tabAbout.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
tabAbout.Font = new Font("Tahoma", 12F);
|
||||
tabAbout.ForeColor = Color.White;
|
||||
tabAbout.Location = new Point(204, 4);
|
||||
tabAbout.Name = "tabAbout";
|
||||
@@ -613,7 +655,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.Font = new Font("Tahoma", 11.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
label1.Font = new Font("Tahoma", 11.25F);
|
||||
label1.Location = new Point(219, 226);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(485, 18);
|
||||
@@ -624,7 +666,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
//
|
||||
// lblTranslationBy
|
||||
//
|
||||
lblTranslationBy.Font = new Font("Tahoma", 11.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblTranslationBy.Font = new Font("Tahoma", 11.25F);
|
||||
lblTranslationBy.Location = new Point(219, 164);
|
||||
lblTranslationBy.Name = "lblTranslationBy";
|
||||
lblTranslationBy.Size = new Size(485, 18);
|
||||
@@ -639,7 +681,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
btnLicenses.Cursor = Cursors.Hand;
|
||||
btnLicenses.FlatAppearance.BorderSize = 0;
|
||||
btnLicenses.FlatStyle = FlatStyle.Flat;
|
||||
btnLicenses.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
btnLicenses.Font = new Font("Tahoma", 9.75F);
|
||||
btnLicenses.ForeColor = Color.White;
|
||||
btnLicenses.HoverColor = Color.FromArgb(0, 89, 184);
|
||||
btnLicenses.Icon = null;
|
||||
@@ -718,7 +760,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
//
|
||||
// lblDeveloped
|
||||
//
|
||||
lblDeveloped.Font = new Font("Tahoma", 11.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblDeveloped.Font = new Font("Tahoma", 11.25F);
|
||||
lblDeveloped.Location = new Point(219, 206);
|
||||
lblDeveloped.Name = "lblDeveloped";
|
||||
lblDeveloped.Size = new Size(485, 18);
|
||||
@@ -729,7 +771,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
//
|
||||
// lblMacroDeck
|
||||
//
|
||||
lblMacroDeck.Font = new Font("Tahoma", 21.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
lblMacroDeck.Font = new Font("Tahoma", 21.75F);
|
||||
lblMacroDeck.ForeColor = Color.LightGray;
|
||||
lblMacroDeck.Location = new Point(3, 3);
|
||||
lblMacroDeck.Name = "lblMacroDeck";
|
||||
@@ -766,7 +808,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
AutoScaleMode = AutoScaleMode.Dpi;
|
||||
BackColor = Color.FromArgb(45, 45, 45);
|
||||
Controls.Add(verticalTabControl);
|
||||
Font = new Font("Tahoma", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
Font = new Font("Tahoma", 9F);
|
||||
Name = "SettingsView";
|
||||
Size = new Size(1137, 540);
|
||||
Load += Settings_Load;
|
||||
@@ -835,5 +877,8 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents
|
||||
private RoundedTextBox certificatePath;
|
||||
private CheckBox checkEnableSsl;
|
||||
private Label labelSsl;
|
||||
private CheckBox checkEnableAdb;
|
||||
private Label label5;
|
||||
private CheckBox checkAutoStartUsb;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,22 @@ public partial class SettingsView : UserControl
|
||||
checkEnableSsl.Checked = MacroDeck.Configuration.EnableSsl;
|
||||
certificatePath.Text = MacroDeck.Configuration.SslCertificatePath;
|
||||
certificatePassword.Text = MacroDeck.Configuration.SslCertificatePassword;
|
||||
checkEnableAdb.Checked = MacroDeck.Configuration.EnableAdbServer;
|
||||
checkAutoStartUsb.Checked = MacroDeck.Configuration.EnableAdbAutoStartApp;
|
||||
checkEnableAdb.CheckedChanged += CheckEnableAdb_CheckedChanged;
|
||||
checkAutoStartUsb.CheckedChanged += CheckAutoStartUsb_CheckedChanged;
|
||||
}
|
||||
|
||||
private void CheckAutoStartUsb_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
MacroDeck.Configuration.EnableAdbAutoStartApp = checkAutoStartUsb.Checked;
|
||||
MacroDeck.Configuration.Save(ApplicationPaths.MainConfigFilePath);
|
||||
}
|
||||
|
||||
private void CheckEnableAdb_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
MacroDeck.Configuration.EnableAdbServer = checkEnableAdb.Checked;
|
||||
MacroDeck.Configuration.Save(ApplicationPaths.MainConfigFilePath);
|
||||
}
|
||||
|
||||
private void LoadAutoStart()
|
||||
|
||||
@@ -1,4 +1,64 @@
|
||||
<root>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
@@ -65,7 +125,7 @@
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
|
||||
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
|
||||
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAfg4AAAJNU0Z0AUkBTAIBAQUB
|
||||
AAGQAQABkAEAATABAAEwAQAE/wEFAQAI/wFCAU0BdgcAAXYDAAEoAwABwAMAAWADAAEBAQABBAYAASQY
|
||||
AAGoAQABqAEAATABAAEwAQAE/wEFAQAI/wFCAU0BdgcAAXYDAAEoAwABwAMAAWADAAEBAQABBAYAASQY
|
||||
AAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8B
|
||||
AAL/AgAD//8A/wD/AA0AAQ8C/10AAQ8D/1wAAQ8D/wHwWwABDwT/AfBaAAEPBf9aAAEPAv8B8AEPAf9a
|
||||
AAEPAv8B8FwAAQ8C/wHwXQAD/10AA/9dAAP/XQAD/10AAQ8C/wHwXAABDwL/AfBcAAEPAv8B8FoAAQ8B
|
||||
|
||||
@@ -103,7 +103,7 @@ public class MacroDeck : NativeWindow
|
||||
SearchNetworkInterfaces();
|
||||
MacroDeckServer.Start(StartParameters.Port <= 0 ? Configuration.HostPort : StartParameters.Port);
|
||||
BroadcastServer.Start();
|
||||
ADBServerHelper.Initialize();
|
||||
Task.Run(async () => await AdbServerHelper.Initialize());
|
||||
|
||||
ProfileManager.AddVariableChangedListener();
|
||||
ProfileManager.AddWindowFocusChangedListener();
|
||||
@@ -114,7 +114,7 @@ public class MacroDeck : NativeWindow
|
||||
TrayIcon.SetupTrayIcon(TrayIconContextMenu,
|
||||
ShowMainWindow,
|
||||
() => RestartMacroDeck(string.Join(" ", StartParameters)),
|
||||
Exit);
|
||||
Exit);
|
||||
|
||||
using (_mainWindow = new MainWindow())
|
||||
{
|
||||
@@ -243,7 +243,7 @@ public class MacroDeck : NativeWindow
|
||||
using var msgBox = new GUI.CustomControls.MessageBox();
|
||||
if (msgBox.ShowDialog(LanguageManager.Strings.MacroDeckNeedsARestart, LanguageManager.Strings.MacroDeckMustBeRestartedForTheChanges, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
MacroDeck.RestartMacroDeck();
|
||||
RestartMacroDeck();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +318,6 @@ public class MacroDeck : NativeWindow
|
||||
|
||||
public static void Exit()
|
||||
{
|
||||
ADBServerHelper.Kill();
|
||||
Environment.Exit(0);
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<SelfContained>true</SelfContained>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<Nullable>disable</Nullable>
|
||||
<Nullable>annotations</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -40,6 +40,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AdvancedSharpAdbClient" />
|
||||
<PackageReference Include="CommandLineParser" />
|
||||
<PackageReference Include="Cottle" />
|
||||
<PackageReference Include="Dax-FCTB" />
|
||||
@@ -48,7 +49,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
|
||||
<PackageReference Include="Microsoft.Win32.Registry" />
|
||||
<PackageReference Include="Newtonsoft.Json" />
|
||||
<PackageReference Include="sharpadbclient" />
|
||||
<PackageReference Include="QRCoder" />
|
||||
<PackageReference Include="sqlite-net-pcl" />
|
||||
<PackageReference Include="System.Collections" />
|
||||
<PackageReference Include="System.Drawing.Common" />
|
||||
|
||||
@@ -4,6 +4,7 @@ using SuchByte.MacroDeck.Startup;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using SuchByte.MacroDeck.Server;
|
||||
|
||||
namespace SuchByte.MacroDeck;
|
||||
|
||||
@@ -19,6 +20,7 @@ internal class Program
|
||||
// Register exception event handlers
|
||||
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
||||
Application.ThreadException += ApplicationThreadException;
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
|
||||
|
||||
|
||||
@@ -29,7 +31,7 @@ internal class Program
|
||||
|
||||
MacroDeck.Start(startParameters);
|
||||
}
|
||||
|
||||
|
||||
private static void CheckRunningInstance(int ignoredPid)
|
||||
{
|
||||
var proc = Process.GetCurrentProcess();
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using SharpAdbClient;
|
||||
using SuchByte.MacroDeck.Enums;
|
||||
using SuchByte.MacroDeck.Logging;
|
||||
using SuchByte.MacroDeck.Startup;
|
||||
|
||||
namespace SuchByte.MacroDeck.Server;
|
||||
|
||||
public class AdbDeviceConnectionStateChangedEventArgs : EventArgs
|
||||
{
|
||||
public DeviceData Device { get; set; }
|
||||
|
||||
public AdbDeviceConnectionState ConnectionState { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class ADBServerHelper
|
||||
{
|
||||
|
||||
private static IAdbServer? _adbServer;
|
||||
|
||||
private static IAdbClient? _adbClient;
|
||||
|
||||
private static string _adbFolderName = "Android Debug Bridge";
|
||||
|
||||
private static string _adbPath = Path.Combine(ApplicationPaths.MainDirectoryPath, _adbFolderName, "adb.exe");
|
||||
|
||||
public static EventHandler<AdbDeviceConnectionStateChangedEventArgs>? OnDeviceConnectionStateChanged;
|
||||
|
||||
public static bool ServerRunning => _adbServer != null && _adbClient != null && _adbServer.GetStatus().IsRunning;
|
||||
|
||||
public static List<DeviceData> Devices => _adbClient?.GetDevices() ?? new List<DeviceData>();
|
||||
|
||||
public static void Kill()
|
||||
{
|
||||
try
|
||||
{
|
||||
_adbClient?.KillAdb();
|
||||
var processes = Process.GetProcessesByName("adb").ToArray();
|
||||
foreach (var process in processes)
|
||||
{
|
||||
process.Kill();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MacroDeckLogger.Warning($"Failed to kill adb\n{ex}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (!File.Exists(_adbPath))
|
||||
{
|
||||
MacroDeckLogger.Warning(typeof(ADBServerHelper), $"Cannot start adb server at {_adbPath}: File not found");
|
||||
return;
|
||||
}
|
||||
|
||||
MacroDeckLogger.Info(typeof(ADBServerHelper), $"Starting ADB server using {_adbPath}");
|
||||
|
||||
_adbClient = new AdbClient();
|
||||
_adbServer = new AdbServer(_adbClient, Factories.AdbCommandLineClientFactory);
|
||||
var result = _adbServer.StartServer(_adbPath, true);
|
||||
if (result != StartServerResult.Started)
|
||||
{
|
||||
MacroDeckLogger.Info(typeof(ADBServerHelper), "Unable to start ADB server");
|
||||
}
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var monitor = new DeviceMonitor(new AdbSocket(new IPEndPoint(IPAddress.Loopback, AdbClient.AdbServerPort)));
|
||||
monitor.DeviceConnected += Monitor_DeviceConnected;
|
||||
monitor.DeviceDisconnected += Monitor_DeviceDisconnected;
|
||||
monitor.Start();
|
||||
});
|
||||
|
||||
|
||||
foreach (var device in _adbClient.GetDevices())
|
||||
{
|
||||
MacroDeckLogger.Info(typeof(ADBServerHelper), $"Found {device.Name}");
|
||||
StartReverseForward(device);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Monitor_DeviceDisconnected(object sender, DeviceDataEventArgs e)
|
||||
{
|
||||
MacroDeckLogger.Info(typeof(ADBServerHelper), $"{e.Device.Name} disconnected");
|
||||
OnDeviceConnectionStateChanged?.Invoke(null, new AdbDeviceConnectionStateChangedEventArgs
|
||||
{
|
||||
Device = e.Device,
|
||||
ConnectionState = AdbDeviceConnectionState.DISCONNECTED
|
||||
});
|
||||
}
|
||||
|
||||
private static void Monitor_DeviceConnected(object sender, DeviceDataEventArgs e)
|
||||
{
|
||||
MacroDeckLogger.Info(typeof(ADBServerHelper), $"{e.Device.Name} connected");
|
||||
OnDeviceConnectionStateChanged?.Invoke(null, new AdbDeviceConnectionStateChangedEventArgs
|
||||
{
|
||||
Device = e.Device,
|
||||
ConnectionState = AdbDeviceConnectionState.CONNECTED
|
||||
});
|
||||
StartReverseForward(e.Device);
|
||||
}
|
||||
|
||||
private static void StartReverseForward(DeviceData device)
|
||||
{
|
||||
try
|
||||
{
|
||||
_adbClient?.CreateReverseForward(device, $"tcp:{MacroDeck.Configuration.HostPort}", $"tcp:{MacroDeck.Configuration.HostPort}", true);
|
||||
} catch (Exception ex)
|
||||
{
|
||||
MacroDeckLogger.Warning(typeof(ADBServerHelper), $"Unable to start reverse forward on {device?.Name}: {ex.Message}");
|
||||
}
|
||||
MacroDeckLogger.Info(typeof(ADBServerHelper), $"Started reverse forward on {device?.Name}");
|
||||
}
|
||||
|
||||
}
|
||||
195
MacroDeck/Server/AdbServerHelper.cs
Normal file
195
MacroDeck/Server/AdbServerHelper.cs
Normal file
@@ -0,0 +1,195 @@
|
||||
using System.IO;
|
||||
using AdvancedSharpAdbClient;
|
||||
using AdvancedSharpAdbClient.DeviceCommands;
|
||||
using AdvancedSharpAdbClient.Models;
|
||||
using AdvancedSharpAdbClient.Receivers;
|
||||
using SuchByte.MacroDeck.Logging;
|
||||
using SuchByte.MacroDeck.Startup;
|
||||
|
||||
namespace SuchByte.MacroDeck.Server;
|
||||
|
||||
public class AdbServerHelper
|
||||
{
|
||||
private static AdbServer? _adbServer;
|
||||
|
||||
private const string AdbFolderName = "Android Debug Bridge";
|
||||
|
||||
private static readonly string AdbPath = Path.Combine(ApplicationPaths.MainDirectoryPath, AdbFolderName, "adb.exe");
|
||||
|
||||
public static async Task Initialize()
|
||||
{
|
||||
if (!MacroDeck.Configuration.EnableAdbServer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!File.Exists(AdbPath))
|
||||
{
|
||||
MacroDeckLogger.Warning(typeof(AdbServerHelper), $"Cannot start adb server at {AdbPath}: File not found");
|
||||
return;
|
||||
}
|
||||
|
||||
MacroDeckLogger.Info(typeof(AdbServerHelper), $"Starting ADB server using {AdbPath}");
|
||||
|
||||
_adbServer = new AdbServer();
|
||||
var result = await _adbServer.StartServerAsync(AdbPath, true);
|
||||
if (result != StartServerResult.Started)
|
||||
{
|
||||
MacroDeckLogger.Info(typeof(AdbServerHelper), "Unable to start ADB server");
|
||||
}
|
||||
|
||||
var monitor = new DeviceMonitor(new AdbSocket(AdbClient.AdbServerEndPoint));
|
||||
monitor.DeviceConnected += Monitor_DeviceConnected;
|
||||
monitor.DeviceDisconnected += Monitor_DeviceDisconnected;
|
||||
await monitor.StartAsync();
|
||||
}
|
||||
|
||||
private static async Task RunForDevice(string serial, Func<AdbClient, DeviceData, Task> action)
|
||||
{
|
||||
var adbClient = await GetAdbClient();
|
||||
if (adbClient is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var device = await GetDevice(adbClient, serial);
|
||||
if (!device.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await action(adbClient, device.Value);
|
||||
}
|
||||
|
||||
private static async Task<DeviceData?> GetDevice(AdbClient adbDeviceClient, string serial)
|
||||
{
|
||||
var devices = await adbDeviceClient.GetDevicesAsync();
|
||||
return devices.FirstOrDefault(x => x.Serial.Equals(serial));
|
||||
}
|
||||
|
||||
private static async Task<AdbClient?> GetAdbClient()
|
||||
{
|
||||
var serverEndpoint = GetAdbServerEndpoint();
|
||||
if (serverEndpoint is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var adbClient = new AdbClient();
|
||||
await adbClient.ConnectAsync(serverEndpoint);
|
||||
return adbClient;
|
||||
}
|
||||
|
||||
private static string? GetAdbServerEndpoint()
|
||||
{
|
||||
var adbServerEndpoint = _adbServer?.EndPoint.ToString();
|
||||
if (adbServerEndpoint is not null)
|
||||
{
|
||||
return adbServerEndpoint;
|
||||
}
|
||||
|
||||
MacroDeckLogger.Info(typeof(AdbServerHelper), "Endpoint was null");
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private static void Monitor_DeviceDisconnected(object sender, DeviceDataEventArgs e)
|
||||
{
|
||||
MacroDeckLogger.Info(typeof(AdbServerHelper), $"{e.Device.Name} disconnected");
|
||||
}
|
||||
|
||||
private static async void Monitor_DeviceConnected(object sender, DeviceDataEventArgs e)
|
||||
{
|
||||
if (e.Device.Serial.StartsWith("127.0.0.1"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MacroDeckLogger.Info(typeof(AdbServerHelper), $"{e.Device.Name} connected");
|
||||
await RunForDevice(e.Device.Serial, async (adbDeviceClient, deviceData) =>
|
||||
{
|
||||
await StartMacroDeckClient(adbDeviceClient, deviceData);
|
||||
await StartReverseForward(adbDeviceClient, deviceData);
|
||||
});
|
||||
}
|
||||
|
||||
private static async Task<bool> IsDeviceOnline(DeviceData device)
|
||||
{
|
||||
var timeoutTask = Task.Delay(TimeSpan.FromSeconds(20));
|
||||
|
||||
await Task.WhenAny([timeoutTask, WaitForDeviceOnline()]);
|
||||
|
||||
if (device.State == DeviceState.Online)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
MacroDeckLogger.Info(typeof(AdbServerHelper), $"Device {device.Serial} is still not online - {device.State}");
|
||||
return false;
|
||||
|
||||
async Task WaitForDeviceOnline()
|
||||
{
|
||||
while (device.State != DeviceState.Online)
|
||||
{
|
||||
await Task.Delay(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task ExitMacroDeckClient(AdbClient adbDeviceClient, DeviceData device)
|
||||
{
|
||||
var deviceIsOnline = await IsDeviceOnline(device);
|
||||
if (!deviceIsOnline)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await adbDeviceClient.ExecuteRemoteCommandAsync("am force-stop com.suchbyte.macrodeck",
|
||||
device,
|
||||
new ConsoleOutputReceiver());
|
||||
await adbDeviceClient.SendKeyEventAsync(device, "KEYCODE_SLEEP");
|
||||
}
|
||||
|
||||
private static async Task StartMacroDeckClient(AdbClient adbDeviceClient, DeviceData device)
|
||||
{
|
||||
if (!MacroDeck.Configuration.EnableAdbAutoStartApp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var deviceIsOnline = await IsDeviceOnline(device);
|
||||
if (!deviceIsOnline)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await adbDeviceClient.SendKeyEventAsync(device, "KEYCODE_WAKEUP");
|
||||
await adbDeviceClient.ExecuteRemoteCommandAsync("am start -n com.suchbyte.macrodeck/.MainActivity",
|
||||
device,
|
||||
new ConsoleOutputReceiver());
|
||||
}
|
||||
|
||||
private static async Task StartReverseForward(AdbClient adbDeviceClient, DeviceData device)
|
||||
{
|
||||
var deviceIsOnline = await IsDeviceOnline(device);
|
||||
if (!deviceIsOnline)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await adbDeviceClient.CreateReverseForwardAsync(
|
||||
device,
|
||||
$"tcp:{MacroDeck.Configuration.HostPort}",
|
||||
$"tcp:{MacroDeck.Configuration.HostPort}",
|
||||
true);
|
||||
|
||||
MacroDeckLogger.Info(typeof(AdbServerHelper), $"Started reverse forward on {device.Name}");
|
||||
} catch (Exception ex)
|
||||
{
|
||||
MacroDeckLogger.Warning(typeof(AdbServerHelper),
|
||||
$"Unable to start reverse forward on {device.Name}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
60
MacroDeck/Services/QrCodeService.cs
Normal file
60
MacroDeck/Services/QrCodeService.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.IO;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Text.Json;
|
||||
using QRCoder;
|
||||
using SuchByte.MacroDeck.DataTypes.QrCode;
|
||||
using SuchByte.MacroDeck.Logging;
|
||||
|
||||
namespace SuchByte.MacroDeck.Services;
|
||||
|
||||
public class QrCodeService
|
||||
{
|
||||
public static readonly QrCodeService Instance = new();
|
||||
|
||||
private byte[]? _quickSetupQrCode;
|
||||
|
||||
public Image GetQuickSetupQrCode()
|
||||
{
|
||||
if (_quickSetupQrCode is not null)
|
||||
{
|
||||
return FromSavedBytes();
|
||||
}
|
||||
|
||||
var networkInterfaces = new List<string>();
|
||||
try
|
||||
{
|
||||
networkInterfaces.AddRange(NetworkInterface.GetAllNetworkInterfaces()
|
||||
.Select(adapter => adapter.GetIPProperties()
|
||||
.UnicastAddresses.FirstOrDefault(x => x.Address.AddressFamily == AddressFamily.InterNetwork)
|
||||
?.Address.ToString())
|
||||
.Where(address => !string.IsNullOrWhiteSpace(address) && address != "127.0.0.1"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MacroDeckLogger.Warning($"Error while searching for network interfaces\n{ex.Message}");
|
||||
}
|
||||
|
||||
var data = new QuickConnectQrCodeData(Environment.MachineName,
|
||||
networkInterfaces,
|
||||
MacroDeck.Configuration.HostPort,
|
||||
MacroDeck.Configuration.EnableSsl);
|
||||
|
||||
var dataJson = JsonSerializer.Serialize(data);
|
||||
var dataBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(dataJson));
|
||||
var qrCodeLink = $"https://macro-deck.app/quick-setup/{dataBase64}";
|
||||
|
||||
using var qrGenerator = new QRCodeGenerator();
|
||||
using var qrCodeData = qrGenerator.CreateQrCode(qrCodeLink, QRCodeGenerator.ECCLevel.L);
|
||||
using var qrCode = new BitmapByteQRCode(qrCodeData);
|
||||
|
||||
_quickSetupQrCode = qrCode.GetGraphic(20);
|
||||
return FromSavedBytes();
|
||||
|
||||
Image FromSavedBytes()
|
||||
{
|
||||
using var ms = new MemoryStream(_quickSetupQrCode);
|
||||
return Image.FromStream(ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user