diff --git a/app/AnimeMatrix/Communication/Device.cs b/app/AnimeMatrix/Communication/Device.cs index 453d3369..9ee7a460 100644 --- a/app/AnimeMatrix/Communication/Device.cs +++ b/app/AnimeMatrix/Communication/Device.cs @@ -6,11 +6,17 @@ namespace GHelper.AnimeMatrix.Communication { public abstract class Device : IDisposable { - private static UsbProvider _usbProvider; + protected UsbProvider? _usbProvider; - private static ushort _vendorId; - private static ushort _productId; - private static int _maxFeatureReportLength; + protected ushort _vendorId; + protected ushort _productId; + protected int _maxFeatureReportLength; + + protected Device(ushort vendorId, ushort productId) + { + _vendorId = vendorId; + _productId = productId; + } protected Device(ushort vendorId, ushort productId, int maxFeatureReportLength) { @@ -20,7 +26,17 @@ namespace GHelper.AnimeMatrix.Communication SetProvider(); } - public void SetProvider() + public ushort VendorID() + { + return _vendorId; + } + + public ushort ProductID() + { + return _productId; + } + + public virtual void SetProvider() { _usbProvider = new WindowsUsbProvider(_vendorId, _productId, _maxFeatureReportLength); } @@ -36,7 +52,12 @@ namespace GHelper.AnimeMatrix.Communication public byte[] Get(Packet packet) => _usbProvider?.Get(packet.Data); - public void Dispose() + public void Read(byte[] data) + => _usbProvider?.Read(data); + public void Write(byte[] data) + => _usbProvider?.Write(data); + + public virtual void Dispose() { _usbProvider?.Dispose(); } diff --git a/app/AnimeMatrix/Communication/Platform/UsbProvider.cs b/app/AnimeMatrix/Communication/Platform/UsbProvider.cs index b7488b8c..05098e8e 100644 --- a/app/AnimeMatrix/Communication/Platform/UsbProvider.cs +++ b/app/AnimeMatrix/Communication/Platform/UsbProvider.cs @@ -1,6 +1,6 @@ namespace GHelper.AnimeMatrix.Communication.Platform { - internal abstract class UsbProvider : IDisposable + public abstract class UsbProvider : IDisposable { protected ushort VendorID { get; } protected ushort ProductID { get; } @@ -13,6 +13,8 @@ namespace GHelper.AnimeMatrix.Communication.Platform public abstract void Set(byte[] data); public abstract byte[] Get(byte[] data); + public abstract void Read(byte[] data); + public abstract void Write(byte[] data); public abstract void Dispose(); } diff --git a/app/AnimeMatrix/Communication/Platform/WindowsUsbProvider.cs b/app/AnimeMatrix/Communication/Platform/WindowsUsbProvider.cs index 23d6415f..1a8630fa 100644 --- a/app/AnimeMatrix/Communication/Platform/WindowsUsbProvider.cs +++ b/app/AnimeMatrix/Communication/Platform/WindowsUsbProvider.cs @@ -8,6 +8,27 @@ namespace GHelper.AnimeMatrix.Communication.Platform protected HidDevice HidDevice { get; } protected HidStream HidStream { get; } + public WindowsUsbProvider(ushort vendorId, ushort productId, string path, int timeout = 500) : base(vendorId, productId) + { + try + { + HidDevice = DeviceList.Local.GetHidDevices(vendorId, productId) + .First(x => x.DevicePath.Contains(path)); + } + catch + { + throw new IOException("HID device was not found on your machine."); + } + + var config = new OpenConfiguration(); + config.SetOption(OpenOption.Interruptible, true); + config.SetOption(OpenOption.Exclusive, false); + config.SetOption(OpenOption.Priority, 10); + HidStream = HidDevice.Open(config); + HidStream.ReadTimeout = timeout; + HidStream.WriteTimeout = timeout; + } + public WindowsUsbProvider(ushort vendorId, ushort productId, int maxFeatureReportLength) : base(vendorId, productId) { @@ -53,6 +74,23 @@ namespace GHelper.AnimeMatrix.Communication.Platform return data; } + public override void Read(byte[] data) + { + WrapException(() => + { + HidStream.Read(data); + }); + } + + public override void Write(byte[] data) + { + WrapException(() => + { + HidStream.Write(data); + HidStream.Flush(); + }); + } + public override void Dispose() { HidStream.Dispose(); diff --git a/app/AsusMouseSettings.Designer.cs b/app/AsusMouseSettings.Designer.cs new file mode 100644 index 00000000..c9323e25 --- /dev/null +++ b/app/AsusMouseSettings.Designer.cs @@ -0,0 +1,1051 @@ +namespace GHelper +{ + partial class AsusMouseSettings + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panelProfiles = new Panel(); + comboProfile = new UI.RComboBox(); + labelProfile = new Label(); + panelPerformance = new Panel(); + panelPerformanceOther = new Panel(); + comboBoxLiftOffDistance = new UI.RComboBox(); + labelLiftOffDistance = new Label(); + labelAngleAdjustmentValue = new Label(); + sliderAngleAdjustment = new UI.Slider(); + checkBoxAngleSnapping = new CheckBox(); + comboBoxPollingRate = new UI.RComboBox(); + labelPollingRate = new Label(); + panelDPISettings = new Panel(); + sliderDPI = new UI.Slider(); + tableLayoutPanel1 = new TableLayoutPanel(); + labelMinDPI = new Label(); + labelMaxDPI = new Label(); + numericUpDownCurrentDPI = new NumericUpDown(); + panelDPITile = new Panel(); + pictureDPIColor = new PictureBox(); + buttonDPIColor = new UI.RButton(); + labelDPI = new Label(); + tableDPI = new TableLayoutPanel(); + buttonDPI2 = new UI.RButton(); + buttonDPI1 = new UI.RButton(); + buttonDPI3 = new UI.RButton(); + buttonDPI4 = new UI.RButton(); + panelPerformanceHeader = new Panel(); + pictureKeyboard = new PictureBox(); + labelPerformance = new Label(); + panelLighting = new Panel(); + panelLightingContent = new Panel(); + comboBoxAnimationDirection = new UI.RComboBox(); + labelAnimationDirection = new Label(); + checkBoxRandomColor = new CheckBox(); + comboBoxAnimationSpeed = new UI.RComboBox(); + labelAnimationSpeed = new Label(); + pictureBoxLightingColor = new PictureBox(); + buttonLightingColor = new UI.RButton(); + comboBoxLightingMode = new UI.RComboBox(); + labelLightingMode = new Label(); + panelLightingHeader = new Panel(); + sliderBrightness = new UI.Slider(); + pictureBoxLighting = new PictureBox(); + labelLighting = new Label(); + panelEnergy = new Panel(); + labelLowBatteryWarningValue = new Label(); + comboBoxAutoPowerOff = new UI.RComboBox(); + sliderLowBatteryWarning = new UI.Slider(); + labelLowBatteryWarning = new Label(); + labelAutoPowerOff = new Label(); + panelEnergyHeader = new Panel(); + pictureBoxEnergy = new PictureBox(); + labelEnergy = new Label(); + tableLayoutProfiles = new TableLayoutPanel(); + panelBatteryState = new Panel(); + labelChargingState = new Label(); + labelBatteryState = new Label(); + pictureBoxBatteryState = new PictureBox(); + buttonSync = new UI.RButton(); + panelBottomButtons = new Panel(); + panelProfiles.SuspendLayout(); + panelPerformance.SuspendLayout(); + panelPerformanceOther.SuspendLayout(); + panelDPISettings.SuspendLayout(); + tableLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownCurrentDPI).BeginInit(); + panelDPITile.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureDPIColor).BeginInit(); + tableDPI.SuspendLayout(); + panelPerformanceHeader.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureKeyboard).BeginInit(); + panelLighting.SuspendLayout(); + panelLightingContent.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxLightingColor).BeginInit(); + panelLightingHeader.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxLighting).BeginInit(); + panelEnergy.SuspendLayout(); + panelEnergyHeader.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxEnergy).BeginInit(); + tableLayoutProfiles.SuspendLayout(); + panelBatteryState.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxBatteryState).BeginInit(); + panelBottomButtons.SuspendLayout(); + SuspendLayout(); + // + // panelProfiles + // + panelProfiles.Controls.Add(comboProfile); + panelProfiles.Controls.Add(labelProfile); + panelProfiles.Location = new Point(330, 3); + panelProfiles.MinimumSize = new Size(340, 0); + panelProfiles.Name = "panelProfiles"; + panelProfiles.Size = new Size(340, 51); + panelProfiles.TabIndex = 0; + // + // comboProfile + // + comboProfile.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; + comboProfile.BorderColor = Color.White; + comboProfile.ButtonColor = Color.FromArgb(255, 255, 255); + comboProfile.DropDownStyle = ComboBoxStyle.DropDownList; + comboProfile.FlatStyle = FlatStyle.Flat; + comboProfile.FormattingEnabled = true; + comboProfile.Location = new Point(98, 10); + comboProfile.Margin = new Padding(0); + comboProfile.Name = "comboProfile"; + comboProfile.Size = new Size(228, 33); + comboProfile.TabIndex = 43; + // + // labelProfile + // + labelProfile.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left; + labelProfile.AutoSize = true; + labelProfile.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelProfile.Location = new Point(3, 13); + labelProfile.Name = "labelProfile"; + labelProfile.Size = new Size(68, 25); + labelProfile.TabIndex = 41; + labelProfile.Text = "Profile"; + // + // panelPerformance + // + panelPerformance.AutoSize = true; + panelPerformance.Controls.Add(panelPerformanceOther); + panelPerformance.Controls.Add(panelDPISettings); + panelPerformance.Controls.Add(tableDPI); + panelPerformance.Controls.Add(panelPerformanceHeader); + panelPerformance.Dock = DockStyle.Top; + panelPerformance.Location = new Point(11, 68); + panelPerformance.Name = "panelPerformance"; + panelPerformance.Padding = new Padding(0, 11, 0, 25); + panelPerformance.Size = new Size(654, 408); + panelPerformance.TabIndex = 1; + // + // panelPerformanceOther + // + panelPerformanceOther.AutoSize = true; + panelPerformanceOther.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelPerformanceOther.Controls.Add(comboBoxLiftOffDistance); + panelPerformanceOther.Controls.Add(labelLiftOffDistance); + panelPerformanceOther.Controls.Add(labelAngleAdjustmentValue); + panelPerformanceOther.Controls.Add(sliderAngleAdjustment); + panelPerformanceOther.Controls.Add(checkBoxAngleSnapping); + panelPerformanceOther.Controls.Add(comboBoxPollingRate); + panelPerformanceOther.Controls.Add(labelPollingRate); + panelPerformanceOther.Dock = DockStyle.Top; + panelPerformanceOther.Location = new Point(0, 240); + panelPerformanceOther.Name = "panelPerformanceOther"; + panelPerformanceOther.Padding = new Padding(0, 11, 0, 11); + panelPerformanceOther.Size = new Size(654, 143); + panelPerformanceOther.TabIndex = 49; + // + // comboBoxLiftOffDistance + // + comboBoxLiftOffDistance.BorderColor = Color.White; + comboBoxLiftOffDistance.ButtonColor = Color.FromArgb(255, 255, 255); + comboBoxLiftOffDistance.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxLiftOffDistance.FlatStyle = FlatStyle.Flat; + comboBoxLiftOffDistance.FormattingEnabled = true; + comboBoxLiftOffDistance.Location = new Point(368, 99); + comboBoxLiftOffDistance.Margin = new Padding(16, 0, 16, 0); + comboBoxLiftOffDistance.Name = "comboBoxLiftOffDistance"; + comboBoxLiftOffDistance.Size = new Size(281, 33); + comboBoxLiftOffDistance.TabIndex = 49; + // + // labelLiftOffDistance + // + labelLiftOffDistance.Location = new Point(6, 99); + labelLiftOffDistance.Margin = new Padding(6, 0, 6, 0); + labelLiftOffDistance.Name = "labelLiftOffDistance"; + labelLiftOffDistance.Size = new Size(348, 33); + labelLiftOffDistance.TabIndex = 48; + labelLiftOffDistance.Text = "Lift Off Distance"; + // + // labelAngleAdjustmentValue + // + labelAngleAdjustmentValue.Location = new Point(598, 61); + labelAngleAdjustmentValue.Margin = new Padding(6, 0, 6, 0); + labelAngleAdjustmentValue.Name = "labelAngleAdjustmentValue"; + labelAngleAdjustmentValue.Size = new Size(48, 30); + labelAngleAdjustmentValue.TabIndex = 47; + labelAngleAdjustmentValue.Text = "0°"; + labelAngleAdjustmentValue.TextAlign = ContentAlignment.MiddleRight; + // + // sliderAngleAdjustment + // + sliderAngleAdjustment.AccessibleName = "DPI Slider"; + sliderAngleAdjustment.Location = new Point(397, 61); + sliderAngleAdjustment.Max = 20; + sliderAngleAdjustment.Min = -20; + sliderAngleAdjustment.Name = "sliderAngleAdjustment"; + sliderAngleAdjustment.Size = new Size(208, 30); + sliderAngleAdjustment.Step = 5; + sliderAngleAdjustment.TabIndex = 46; + sliderAngleAdjustment.TabStop = false; + sliderAngleAdjustment.Text = "sliderBattery"; + sliderAngleAdjustment.Value = 0; + // + // checkBoxAngleSnapping + // + checkBoxAngleSnapping.CheckAlign = ContentAlignment.MiddleRight; + checkBoxAngleSnapping.Location = new Point(6, 61); + checkBoxAngleSnapping.Margin = new Padding(6, 0, 6, 0); + checkBoxAngleSnapping.Name = "checkBoxAngleSnapping"; + checkBoxAngleSnapping.Size = new Size(384, 30); + checkBoxAngleSnapping.TabIndex = 45; + checkBoxAngleSnapping.Text = "Angle Snapping"; + checkBoxAngleSnapping.TextAlign = ContentAlignment.TopLeft; + checkBoxAngleSnapping.UseVisualStyleBackColor = true; + // + // comboBoxPollingRate + // + comboBoxPollingRate.BorderColor = Color.White; + comboBoxPollingRate.ButtonColor = Color.FromArgb(255, 255, 255); + comboBoxPollingRate.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPollingRate.FlatStyle = FlatStyle.Flat; + comboBoxPollingRate.FormattingEnabled = true; + comboBoxPollingRate.Location = new Point(368, 8); + comboBoxPollingRate.Margin = new Padding(16, 0, 16, 0); + comboBoxPollingRate.Name = "comboBoxPollingRate"; + comboBoxPollingRate.Size = new Size(281, 33); + comboBoxPollingRate.TabIndex = 44; + // + // labelPollingRate + // + labelPollingRate.Location = new Point(6, 9); + labelPollingRate.Margin = new Padding(6, 0, 6, 0); + labelPollingRate.Name = "labelPollingRate"; + labelPollingRate.Size = new Size(348, 30); + labelPollingRate.TabIndex = 45; + labelPollingRate.Text = "Polling Rate"; + // + // panelDPISettings + // + panelDPISettings.AutoSize = true; + panelDPISettings.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelDPISettings.Controls.Add(sliderDPI); + panelDPISettings.Controls.Add(tableLayoutPanel1); + panelDPISettings.Controls.Add(panelDPITile); + panelDPISettings.Dock = DockStyle.Top; + panelDPISettings.Location = new Point(0, 137); + panelDPISettings.Name = "panelDPISettings"; + panelDPISettings.Size = new Size(654, 103); + panelDPISettings.TabIndex = 44; + // + // sliderDPI + // + sliderDPI.AccessibleName = "DPI Slider"; + sliderDPI.Dock = DockStyle.Top; + sliderDPI.Location = new Point(0, 73); + sliderDPI.Max = 35000; + sliderDPI.Min = 100; + sliderDPI.Name = "sliderDPI"; + sliderDPI.Size = new Size(654, 30); + sliderDPI.Step = 50; + sliderDPI.TabIndex = 43; + sliderDPI.TabStop = false; + sliderDPI.Text = "sliderBattery"; + sliderDPI.Value = 2000; + // + // tableLayoutPanel1 + // + tableLayoutPanel1.AutoSize = true; + tableLayoutPanel1.AutoSizeMode = AutoSizeMode.GrowAndShrink; + tableLayoutPanel1.ColumnCount = 3; + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 38F)); + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 24F)); + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 38F)); + tableLayoutPanel1.Controls.Add(labelMinDPI, 0, 0); + tableLayoutPanel1.Controls.Add(labelMaxDPI, 2, 0); + tableLayoutPanel1.Controls.Add(numericUpDownCurrentDPI, 1, 0); + tableLayoutPanel1.Dock = DockStyle.Top; + tableLayoutPanel1.GrowStyle = TableLayoutPanelGrowStyle.FixedSize; + tableLayoutPanel1.Location = new Point(0, 40); + tableLayoutPanel1.Name = "tableLayoutPanel1"; + tableLayoutPanel1.RowCount = 1; + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + tableLayoutPanel1.Size = new Size(654, 33); + tableLayoutPanel1.TabIndex = 47; + // + // labelMinDPI + // + labelMinDPI.Dock = DockStyle.Fill; + labelMinDPI.ForeColor = SystemColors.GrayText; + labelMinDPI.Location = new Point(6, 0); + labelMinDPI.Margin = new Padding(6, 0, 6, 0); + labelMinDPI.Name = "labelMinDPI"; + labelMinDPI.Size = new Size(236, 33); + labelMinDPI.TabIndex = 45; + labelMinDPI.Text = "100"; + // + // labelMaxDPI + // + labelMaxDPI.Dock = DockStyle.Fill; + labelMaxDPI.ForeColor = SystemColors.GrayText; + labelMaxDPI.Location = new Point(410, 0); + labelMaxDPI.Margin = new Padding(6, 0, 6, 0); + labelMaxDPI.Name = "labelMaxDPI"; + labelMaxDPI.Size = new Size(238, 33); + labelMaxDPI.TabIndex = 46; + labelMaxDPI.Text = " 35000"; + labelMaxDPI.TextAlign = ContentAlignment.TopRight; + // + // numericUpDownCurrentDPI + // + numericUpDownCurrentDPI.BorderStyle = BorderStyle.None; + numericUpDownCurrentDPI.Dock = DockStyle.Fill; + numericUpDownCurrentDPI.Increment = new decimal(new int[] { 50, 0, 0, 0 }); + numericUpDownCurrentDPI.Location = new Point(251, 3); + numericUpDownCurrentDPI.Maximum = new decimal(new int[] { 35000, 0, 0, 0 }); + numericUpDownCurrentDPI.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + numericUpDownCurrentDPI.Name = "numericUpDownCurrentDPI"; + numericUpDownCurrentDPI.Size = new Size(150, 27); + numericUpDownCurrentDPI.TabIndex = 47; + numericUpDownCurrentDPI.TextAlign = HorizontalAlignment.Center; + numericUpDownCurrentDPI.Value = new decimal(new int[] { 2000, 0, 0, 0 }); + // + // panelDPITile + // + panelDPITile.Controls.Add(pictureDPIColor); + panelDPITile.Controls.Add(buttonDPIColor); + panelDPITile.Controls.Add(labelDPI); + panelDPITile.Dock = DockStyle.Top; + panelDPITile.Location = new Point(0, 0); + panelDPITile.Name = "panelDPITile"; + panelDPITile.Padding = new Padding(0, 5, 0, 5); + panelDPITile.Size = new Size(654, 40); + panelDPITile.TabIndex = 48; + // + // pictureDPIColor + // + pictureDPIColor.Anchor = AnchorStyles.Top | AnchorStyles.Right; + pictureDPIColor.Location = new Point(617, 11); + pictureDPIColor.Margin = new Padding(6); + pictureDPIColor.Name = "pictureDPIColor"; + pictureDPIColor.Size = new Size(15, 15); + pictureDPIColor.TabIndex = 46; + pictureDPIColor.TabStop = false; + // + // buttonDPIColor + // + buttonDPIColor.AccessibleName = "Keyboard Color"; + buttonDPIColor.Activated = false; + buttonDPIColor.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; + buttonDPIColor.AutoSize = true; + buttonDPIColor.BackColor = SystemColors.ButtonHighlight; + buttonDPIColor.BorderColor = Color.Transparent; + buttonDPIColor.BorderRadius = 2; + buttonDPIColor.FlatStyle = FlatStyle.Flat; + buttonDPIColor.ForeColor = SystemColors.ControlText; + buttonDPIColor.Location = new Point(460, 1); + buttonDPIColor.Margin = new Padding(3, 6, 3, 6); + buttonDPIColor.Name = "buttonDPIColor"; + buttonDPIColor.Secondary = false; + buttonDPIColor.Size = new Size(191, 37); + buttonDPIColor.TabIndex = 45; + buttonDPIColor.Text = Properties.Strings.Color; + buttonDPIColor.UseVisualStyleBackColor = false; + // + // labelDPI + // + labelDPI.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left; + labelDPI.AutoSize = true; + labelDPI.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); + labelDPI.Location = new Point(6, 5); + labelDPI.Margin = new Padding(6, 0, 6, 0); + labelDPI.Name = "labelDPI"; + labelDPI.Size = new Size(40, 25); + labelDPI.TabIndex = 34; + labelDPI.Text = "DPI"; + // + // tableDPI + // + tableDPI.AutoSize = true; + tableDPI.AutoSizeMode = AutoSizeMode.GrowAndShrink; + tableDPI.ColumnCount = 4; + tableDPI.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableDPI.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableDPI.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableDPI.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableDPI.Controls.Add(buttonDPI2, 0, 0); + tableDPI.Controls.Add(buttonDPI1, 0, 0); + tableDPI.Controls.Add(buttonDPI3, 1, 0); + tableDPI.Controls.Add(buttonDPI4, 2, 0); + tableDPI.Dock = DockStyle.Top; + tableDPI.Location = new Point(0, 41); + tableDPI.Margin = new Padding(6, 3, 6, 3); + tableDPI.Name = "tableDPI"; + tableDPI.RowCount = 1; + tableDPI.RowStyles.Add(new RowStyle(SizeType.Absolute, 96F)); + tableDPI.RowStyles.Add(new RowStyle(SizeType.Absolute, 96F)); + tableDPI.Size = new Size(654, 96); + tableDPI.TabIndex = 42; + // + // buttonDPI2 + // + buttonDPI2.AccessibleName = "DPI Setting 2"; + buttonDPI2.Activated = false; + buttonDPI2.BackColor = SystemColors.ControlLightLight; + buttonDPI2.BorderColor = Color.Transparent; + buttonDPI2.BorderRadius = 5; + buttonDPI2.Dock = DockStyle.Top; + buttonDPI2.FlatAppearance.BorderSize = 0; + buttonDPI2.FlatStyle = FlatStyle.Flat; + buttonDPI2.ForeColor = SystemColors.ControlText; + buttonDPI2.Image = Properties.Resources.lighting_dot_32; + buttonDPI2.ImageAlign = ContentAlignment.BottomCenter; + buttonDPI2.Location = new Point(166, 3); + buttonDPI2.Name = "buttonDPI2"; + buttonDPI2.Secondary = false; + buttonDPI2.Size = new Size(157, 90); + buttonDPI2.TabIndex = 4; + buttonDPI2.Text = "DPI 2\r\n1000"; + buttonDPI2.TextImageRelation = TextImageRelation.ImageAboveText; + buttonDPI2.UseVisualStyleBackColor = false; + // + // buttonDPI1 + // + buttonDPI1.AccessibleName = "DPI Setting 1"; + buttonDPI1.Activated = false; + buttonDPI1.BackColor = SystemColors.ControlLightLight; + buttonDPI1.BorderColor = Color.Transparent; + buttonDPI1.BorderRadius = 5; + buttonDPI1.CausesValidation = false; + buttonDPI1.Dock = DockStyle.Top; + buttonDPI1.FlatAppearance.BorderSize = 0; + buttonDPI1.FlatStyle = FlatStyle.Flat; + buttonDPI1.ForeColor = SystemColors.ControlText; + buttonDPI1.Image = Properties.Resources.lighting_dot_32; + buttonDPI1.Location = new Point(3, 3); + buttonDPI1.Name = "buttonDPI1"; + buttonDPI1.Secondary = false; + buttonDPI1.Size = new Size(157, 90); + buttonDPI1.TabIndex = 4; + buttonDPI1.Text = "DPI 1\r\n800"; + buttonDPI1.TextImageRelation = TextImageRelation.ImageAboveText; + buttonDPI1.UseVisualStyleBackColor = false; + // + // buttonDPI3 + // + buttonDPI3.AccessibleName = "DPI Setting 3"; + buttonDPI3.Activated = false; + buttonDPI3.BackColor = SystemColors.ControlLightLight; + buttonDPI3.BorderColor = Color.Transparent; + buttonDPI3.BorderRadius = 5; + buttonDPI3.Dock = DockStyle.Top; + buttonDPI3.FlatAppearance.BorderSize = 0; + buttonDPI3.FlatStyle = FlatStyle.Flat; + buttonDPI3.ForeColor = SystemColors.ControlText; + buttonDPI3.Image = Properties.Resources.lighting_dot_32; + buttonDPI3.ImageAlign = ContentAlignment.BottomCenter; + buttonDPI3.Location = new Point(329, 3); + buttonDPI3.Name = "buttonDPI3"; + buttonDPI3.Secondary = false; + buttonDPI3.Size = new Size(157, 90); + buttonDPI3.TabIndex = 5; + buttonDPI3.Text = "DPI 3\r\n1200"; + buttonDPI3.TextImageRelation = TextImageRelation.ImageAboveText; + buttonDPI3.UseVisualStyleBackColor = false; + // + // buttonDPI4 + // + buttonDPI4.AccessibleName = "DPI Setting 4"; + buttonDPI4.Activated = false; + buttonDPI4.BackColor = SystemColors.ControlLightLight; + buttonDPI4.BorderColor = Color.Transparent; + buttonDPI4.BorderRadius = 5; + buttonDPI4.Dock = DockStyle.Top; + buttonDPI4.FlatAppearance.BorderSize = 0; + buttonDPI4.FlatStyle = FlatStyle.Flat; + buttonDPI4.ForeColor = SystemColors.ControlText; + buttonDPI4.Image = Properties.Resources.lighting_dot_32; + buttonDPI4.ImageAlign = ContentAlignment.BottomCenter; + buttonDPI4.Location = new Point(492, 3); + buttonDPI4.Name = "buttonDPI4"; + buttonDPI4.Secondary = false; + buttonDPI4.Size = new Size(159, 90); + buttonDPI4.TabIndex = 6; + buttonDPI4.Text = "DPI 4\r\n1400"; + buttonDPI4.TextImageRelation = TextImageRelation.ImageAboveText; + buttonDPI4.UseVisualStyleBackColor = false; + // + // panelPerformanceHeader + // + panelPerformanceHeader.BackColor = SystemColors.ControlLight; + panelPerformanceHeader.Controls.Add(pictureKeyboard); + panelPerformanceHeader.Controls.Add(labelPerformance); + panelPerformanceHeader.Dock = DockStyle.Top; + panelPerformanceHeader.Location = new Point(0, 11); + panelPerformanceHeader.Name = "panelPerformanceHeader"; + panelPerformanceHeader.Size = new Size(654, 30); + panelPerformanceHeader.TabIndex = 41; + // + // pictureKeyboard + // + pictureKeyboard.BackgroundImage = Properties.Resources.icons8_mauszeiger_50; + pictureKeyboard.BackgroundImageLayout = ImageLayout.Zoom; + pictureKeyboard.Location = new Point(4, 0); + pictureKeyboard.Name = "pictureKeyboard"; + pictureKeyboard.Size = new Size(24, 24); + pictureKeyboard.TabIndex = 35; + pictureKeyboard.TabStop = false; + // + // labelPerformance + // + labelPerformance.AutoSize = true; + labelPerformance.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelPerformance.Location = new Point(33, 0); + labelPerformance.Margin = new Padding(6, 0, 6, 0); + labelPerformance.Name = "labelPerformance"; + labelPerformance.Size = new Size(120, 25); + labelPerformance.TabIndex = 34; + labelPerformance.Text = "Performance"; + // + // panelLighting + // + panelLighting.AutoSize = true; + panelLighting.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelLighting.Controls.Add(panelLightingContent); + panelLighting.Controls.Add(panelLightingHeader); + panelLighting.Dock = DockStyle.Top; + panelLighting.Location = new Point(11, 476); + panelLighting.Name = "panelLighting"; + panelLighting.Padding = new Padding(0, 0, 0, 25); + panelLighting.Size = new Size(654, 271); + panelLighting.TabIndex = 42; + // + // panelLightingContent + // + panelLightingContent.AutoSize = true; + panelLightingContent.Controls.Add(comboBoxAnimationDirection); + panelLightingContent.Controls.Add(labelAnimationDirection); + panelLightingContent.Controls.Add(checkBoxRandomColor); + panelLightingContent.Controls.Add(comboBoxAnimationSpeed); + panelLightingContent.Controls.Add(labelAnimationSpeed); + panelLightingContent.Controls.Add(pictureBoxLightingColor); + panelLightingContent.Controls.Add(buttonLightingColor); + panelLightingContent.Controls.Add(comboBoxLightingMode); + panelLightingContent.Controls.Add(labelLightingMode); + panelLightingContent.Dock = DockStyle.Top; + panelLightingContent.Location = new Point(0, 30); + panelLightingContent.Name = "panelLightingContent"; + panelLightingContent.Padding = new Padding(0, 0, 0, 11); + panelLightingContent.Size = new Size(654, 216); + panelLightingContent.TabIndex = 42; + // + // comboBoxAnimationDirection + // + comboBoxAnimationDirection.BorderColor = Color.White; + comboBoxAnimationDirection.ButtonColor = Color.FromArgb(255, 255, 255); + comboBoxAnimationDirection.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxAnimationDirection.FlatStyle = FlatStyle.Flat; + comboBoxAnimationDirection.FormattingEnabled = true; + comboBoxAnimationDirection.Location = new Point(366, 172); + comboBoxAnimationDirection.Margin = new Padding(16, 0, 16, 0); + comboBoxAnimationDirection.Name = "comboBoxAnimationDirection"; + comboBoxAnimationDirection.Size = new Size(284, 33); + comboBoxAnimationDirection.TabIndex = 54; + // + // labelAnimationDirection + // + labelAnimationDirection.Location = new Point(6, 172); + labelAnimationDirection.Margin = new Padding(6, 0, 6, 0); + labelAnimationDirection.Name = "labelAnimationDirection"; + labelAnimationDirection.Size = new Size(316, 33); + labelAnimationDirection.TabIndex = 55; + labelAnimationDirection.Text = "Animation Direction"; + // + // checkBoxRandomColor + // + checkBoxRandomColor.Location = new Point(520, 53); + checkBoxRandomColor.Margin = new Padding(6, 0, 6, 0); + checkBoxRandomColor.Name = "checkBoxRandomColor"; + checkBoxRandomColor.Size = new Size(128, 37); + checkBoxRandomColor.TabIndex = 53; + checkBoxRandomColor.Text = "Random"; + checkBoxRandomColor.UseVisualStyleBackColor = true; + // + // comboBoxAnimationSpeed + // + comboBoxAnimationSpeed.BorderColor = Color.White; + comboBoxAnimationSpeed.ButtonColor = Color.FromArgb(255, 255, 255); + comboBoxAnimationSpeed.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxAnimationSpeed.FlatStyle = FlatStyle.Flat; + comboBoxAnimationSpeed.FormattingEnabled = true; + comboBoxAnimationSpeed.Location = new Point(366, 130); + comboBoxAnimationSpeed.Margin = new Padding(16, 0, 16, 0); + comboBoxAnimationSpeed.Name = "comboBoxAnimationSpeed"; + comboBoxAnimationSpeed.Size = new Size(284, 33); + comboBoxAnimationSpeed.TabIndex = 51; + // + // labelAnimationSpeed + // + labelAnimationSpeed.Location = new Point(6, 130); + labelAnimationSpeed.Margin = new Padding(6, 0, 6, 0); + labelAnimationSpeed.Name = "labelAnimationSpeed"; + labelAnimationSpeed.Size = new Size(316, 33); + labelAnimationSpeed.TabIndex = 52; + labelAnimationSpeed.Text = "Animation Speed"; + // + // pictureBoxLightingColor + // + pictureBoxLightingColor.Anchor = AnchorStyles.Top | AnchorStyles.Right; + pictureBoxLightingColor.Location = new Point(480, 62); + pictureBoxLightingColor.Margin = new Padding(6); + pictureBoxLightingColor.Name = "pictureBoxLightingColor"; + pictureBoxLightingColor.Size = new Size(20, 20); + pictureBoxLightingColor.TabIndex = 50; + pictureBoxLightingColor.TabStop = false; + // + // buttonLightingColor + // + buttonLightingColor.AccessibleName = "Keyboard Color"; + buttonLightingColor.Activated = false; + buttonLightingColor.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonLightingColor.BackColor = SystemColors.ButtonHighlight; + buttonLightingColor.BorderColor = Color.Transparent; + buttonLightingColor.BorderRadius = 2; + buttonLightingColor.FlatStyle = FlatStyle.Flat; + buttonLightingColor.ForeColor = SystemColors.ControlText; + buttonLightingColor.Location = new Point(373, 53); + buttonLightingColor.Margin = new Padding(3, 6, 3, 6); + buttonLightingColor.Name = "buttonLightingColor"; + buttonLightingColor.Secondary = false; + buttonLightingColor.Size = new Size(141, 37); + buttonLightingColor.TabIndex = 49; + buttonLightingColor.Text = Properties.Strings.Color; + buttonLightingColor.TextAlign = ContentAlignment.MiddleLeft; + buttonLightingColor.UseVisualStyleBackColor = false; + // + // comboBoxLightingMode + // + comboBoxLightingMode.BorderColor = Color.White; + comboBoxLightingMode.ButtonColor = Color.FromArgb(255, 255, 255); + comboBoxLightingMode.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxLightingMode.FlatStyle = FlatStyle.Flat; + comboBoxLightingMode.FormattingEnabled = true; + comboBoxLightingMode.Location = new Point(367, 14); + comboBoxLightingMode.Margin = new Padding(16, 0, 16, 0); + comboBoxLightingMode.Name = "comboBoxLightingMode"; + comboBoxLightingMode.Size = new Size(284, 33); + comboBoxLightingMode.TabIndex = 46; + // + // labelLightingMode + // + labelLightingMode.Location = new Point(7, 14); + labelLightingMode.Margin = new Padding(6, 0, 6, 0); + labelLightingMode.Name = "labelLightingMode"; + labelLightingMode.Size = new Size(316, 33); + labelLightingMode.TabIndex = 47; + labelLightingMode.Text = "Lighting Mode"; + // + // panelLightingHeader + // + panelLightingHeader.BackColor = SystemColors.ControlLight; + panelLightingHeader.Controls.Add(sliderBrightness); + panelLightingHeader.Controls.Add(pictureBoxLighting); + panelLightingHeader.Controls.Add(labelLighting); + panelLightingHeader.Dock = DockStyle.Top; + panelLightingHeader.Location = new Point(0, 0); + panelLightingHeader.Name = "panelLightingHeader"; + panelLightingHeader.Size = new Size(654, 30); + panelLightingHeader.TabIndex = 41; + // + // sliderBrightness + // + sliderBrightness.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; + sliderBrightness.Location = new Point(367, 1); + sliderBrightness.Margin = new Padding(2); + sliderBrightness.Max = 100; + sliderBrightness.Min = 0; + sliderBrightness.Name = "sliderBrightness"; + sliderBrightness.Size = new Size(283, 27); + sliderBrightness.Step = 1; + sliderBrightness.TabIndex = 51; + sliderBrightness.Text = "sliderBrightness"; + sliderBrightness.Value = 25; + // + // pictureBoxLighting + // + pictureBoxLighting.BackgroundImage = Properties.Resources.backlight; + pictureBoxLighting.BackgroundImageLayout = ImageLayout.Zoom; + pictureBoxLighting.Location = new Point(4, 0); + pictureBoxLighting.Name = "pictureBoxLighting"; + pictureBoxLighting.Size = new Size(24, 24); + pictureBoxLighting.TabIndex = 35; + pictureBoxLighting.TabStop = false; + // + // labelLighting + // + labelLighting.AutoSize = true; + labelLighting.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelLighting.Location = new Point(33, 0); + labelLighting.Margin = new Padding(6, 0, 6, 0); + labelLighting.Name = "labelLighting"; + labelLighting.Size = new Size(82, 25); + labelLighting.TabIndex = 34; + labelLighting.Text = "Lighting"; + // + // panelEnergy + // + panelEnergy.AutoSize = true; + panelEnergy.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelEnergy.Controls.Add(labelLowBatteryWarningValue); + panelEnergy.Controls.Add(comboBoxAutoPowerOff); + panelEnergy.Controls.Add(sliderLowBatteryWarning); + panelEnergy.Controls.Add(labelLowBatteryWarning); + panelEnergy.Controls.Add(labelAutoPowerOff); + panelEnergy.Controls.Add(panelEnergyHeader); + panelEnergy.Dock = DockStyle.Top; + panelEnergy.Location = new Point(11, 747); + panelEnergy.Name = "panelEnergy"; + panelEnergy.Padding = new Padding(0, 0, 0, 25); + panelEnergy.Size = new Size(654, 143); + panelEnergy.TabIndex = 43; + // + // labelLowBatteryWarningValue + // + labelLowBatteryWarningValue.Location = new Point(601, 85); + labelLowBatteryWarningValue.Margin = new Padding(6, 0, 6, 0); + labelLowBatteryWarningValue.Name = "labelLowBatteryWarningValue"; + labelLowBatteryWarningValue.Size = new Size(48, 30); + labelLowBatteryWarningValue.TabIndex = 51; + labelLowBatteryWarningValue.Text = "20%"; + labelLowBatteryWarningValue.TextAlign = ContentAlignment.MiddleRight; + // + // comboBoxAutoPowerOff + // + comboBoxAutoPowerOff.BorderColor = Color.White; + comboBoxAutoPowerOff.ButtonColor = Color.FromArgb(255, 255, 255); + comboBoxAutoPowerOff.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxAutoPowerOff.FlatStyle = FlatStyle.Flat; + comboBoxAutoPowerOff.FormattingEnabled = true; + comboBoxAutoPowerOff.Location = new Point(362, 43); + comboBoxAutoPowerOff.Margin = new Padding(16, 0, 16, 0); + comboBoxAutoPowerOff.Name = "comboBoxAutoPowerOff"; + comboBoxAutoPowerOff.Size = new Size(284, 33); + comboBoxAutoPowerOff.TabIndex = 56; + // + // sliderLowBatteryWarning + // + sliderLowBatteryWarning.AccessibleName = "DPI Slider"; + sliderLowBatteryWarning.Location = new Point(362, 85); + sliderLowBatteryWarning.Max = 50; + sliderLowBatteryWarning.Min = 0; + sliderLowBatteryWarning.Name = "sliderLowBatteryWarning"; + sliderLowBatteryWarning.Size = new Size(243, 30); + sliderLowBatteryWarning.Step = 10; + sliderLowBatteryWarning.TabIndex = 50; + sliderLowBatteryWarning.TabStop = false; + sliderLowBatteryWarning.Text = "sliderBattery"; + sliderLowBatteryWarning.Value = 0; + // + // labelLowBatteryWarning + // + labelLowBatteryWarning.Location = new Point(7, 82); + labelLowBatteryWarning.Margin = new Padding(6, 0, 6, 0); + labelLowBatteryWarning.Name = "labelLowBatteryWarning"; + labelLowBatteryWarning.Size = new Size(316, 33); + labelLowBatteryWarning.TabIndex = 57; + labelLowBatteryWarning.Text = "Low Battery Warning"; + // + // labelAutoPowerOff + // + labelAutoPowerOff.Location = new Point(7, 43); + labelAutoPowerOff.Margin = new Padding(6, 0, 6, 0); + labelAutoPowerOff.Name = "labelAutoPowerOff"; + labelAutoPowerOff.Size = new Size(316, 33); + labelAutoPowerOff.TabIndex = 56; + labelAutoPowerOff.Text = "Auto Power Off"; + // + // panelEnergyHeader + // + panelEnergyHeader.BackColor = SystemColors.ControlLight; + panelEnergyHeader.Controls.Add(pictureBoxEnergy); + panelEnergyHeader.Controls.Add(labelEnergy); + panelEnergyHeader.Dock = DockStyle.Top; + panelEnergyHeader.Location = new Point(0, 0); + panelEnergyHeader.Name = "panelEnergyHeader"; + panelEnergyHeader.Size = new Size(654, 30); + panelEnergyHeader.TabIndex = 41; + // + // pictureBoxEnergy + // + pictureBoxEnergy.BackgroundImage = Properties.Resources.icons8_charging_battery_32; + pictureBoxEnergy.BackgroundImageLayout = ImageLayout.Zoom; + pictureBoxEnergy.Location = new Point(4, 0); + pictureBoxEnergy.Name = "pictureBoxEnergy"; + pictureBoxEnergy.Size = new Size(24, 24); + pictureBoxEnergy.TabIndex = 35; + pictureBoxEnergy.TabStop = false; + // + // labelEnergy + // + labelEnergy.AutoSize = true; + labelEnergy.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelEnergy.Location = new Point(33, 0); + labelEnergy.Margin = new Padding(6, 0, 6, 0); + labelEnergy.Name = "labelEnergy"; + labelEnergy.Size = new Size(71, 25); + labelEnergy.TabIndex = 34; + labelEnergy.Text = "Energy"; + // + // tableLayoutProfiles + // + tableLayoutProfiles.AutoSize = true; + tableLayoutProfiles.AutoSizeMode = AutoSizeMode.GrowAndShrink; + tableLayoutProfiles.ColumnCount = 2; + tableLayoutProfiles.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tableLayoutProfiles.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tableLayoutProfiles.Controls.Add(panelProfiles, 1, 0); + tableLayoutProfiles.Controls.Add(panelBatteryState, 0, 0); + tableLayoutProfiles.Dock = DockStyle.Top; + tableLayoutProfiles.Location = new Point(11, 11); + tableLayoutProfiles.Name = "tableLayoutProfiles"; + tableLayoutProfiles.RowCount = 1; + tableLayoutProfiles.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); + tableLayoutProfiles.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); + tableLayoutProfiles.Size = new Size(654, 57); + tableLayoutProfiles.TabIndex = 44; + // + // panelBatteryState + // + panelBatteryState.Controls.Add(labelChargingState); + panelBatteryState.Controls.Add(labelBatteryState); + panelBatteryState.Controls.Add(pictureBoxBatteryState); + panelBatteryState.Location = new Point(3, 3); + panelBatteryState.Name = "panelBatteryState"; + panelBatteryState.Size = new Size(300, 50); + panelBatteryState.TabIndex = 1; + // + // labelChargingState + // + labelChargingState.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left; + labelChargingState.AutoSize = true; + labelChargingState.Font = new Font("Segoe UI", 10F, FontStyle.Bold, GraphicsUnit.Point); + labelChargingState.Location = new Point(116, 10); + labelChargingState.Name = "labelChargingState"; + labelChargingState.Size = new Size(97, 28); + labelChargingState.TabIndex = 38; + labelChargingState.Text = "Charging"; + labelChargingState.TextAlign = ContentAlignment.MiddleLeft; + // + // labelBatteryState + // + labelBatteryState.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; + labelBatteryState.AutoSize = true; + labelBatteryState.Font = new Font("Segoe UI", 10F, FontStyle.Bold, GraphicsUnit.Point); + labelBatteryState.Location = new Point(45, 10); + labelBatteryState.Name = "labelBatteryState"; + labelBatteryState.Size = new Size(65, 28); + labelBatteryState.TabIndex = 37; + labelBatteryState.Text = "100%"; + labelBatteryState.TextAlign = ContentAlignment.MiddleRight; + // + // pictureBoxBatteryState + // + pictureBoxBatteryState.BackgroundImage = Properties.Resources.icons8_ladende_batterie_48; + pictureBoxBatteryState.BackgroundImageLayout = ImageLayout.Zoom; + pictureBoxBatteryState.Dock = DockStyle.Left; + pictureBoxBatteryState.Location = new Point(0, 0); + pictureBoxBatteryState.Name = "pictureBoxBatteryState"; + pictureBoxBatteryState.Size = new Size(39, 50); + pictureBoxBatteryState.TabIndex = 36; + pictureBoxBatteryState.TabStop = false; + // + // buttonSync + // + buttonSync.AccessibleName = "Keyboard Color"; + buttonSync.Activated = false; + buttonSync.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonSync.BackColor = SystemColors.ButtonHighlight; + buttonSync.BorderColor = Color.Transparent; + buttonSync.BorderRadius = 2; + buttonSync.FlatStyle = FlatStyle.Flat; + buttonSync.ForeColor = SystemColors.ControlText; + buttonSync.Location = new Point(358, 8); + buttonSync.Margin = new Padding(3, 6, 3, 6); + buttonSync.Name = "buttonSync"; + buttonSync.Secondary = false; + buttonSync.Size = new Size(292, 37); + buttonSync.TabIndex = 46; + buttonSync.Text = "Synchronize with Mouse"; + buttonSync.UseVisualStyleBackColor = false; + buttonSync.Click += ButtonSync_Click; + // + // panelBottomButtons + // + panelBottomButtons.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelBottomButtons.Controls.Add(buttonSync); + panelBottomButtons.Dock = DockStyle.Top; + panelBottomButtons.Location = new Point(11, 890); + panelBottomButtons.Name = "panelBottomButtons"; + panelBottomButtons.Size = new Size(654, 67); + panelBottomButtons.TabIndex = 47; + // + // AsusMouseSettings + // + AutoScaleDimensions = new SizeF(144F, 144F); + AutoScaleMode = AutoScaleMode.Dpi; + AutoScroll = true; + AutoSize = true; + AutoSizeMode = AutoSizeMode.GrowAndShrink; + ClientSize = new Size(676, 1030); + Controls.Add(panelBottomButtons); + Controls.Add(panelEnergy); + Controls.Add(panelLighting); + Controls.Add(panelPerformance); + Controls.Add(tableLayoutProfiles); + MaximizeBox = false; + MdiChildrenMinimizedAnchorBottom = false; + MinimizeBox = false; + MinimumSize = new Size(690, 600); + Name = "AsusMouseSettings"; + Padding = new Padding(11); + ShowIcon = false; + ShowInTaskbar = false; + Text = "Mouse Settings"; + panelProfiles.ResumeLayout(false); + panelProfiles.PerformLayout(); + panelPerformance.ResumeLayout(false); + panelPerformance.PerformLayout(); + panelPerformanceOther.ResumeLayout(false); + panelDPISettings.ResumeLayout(false); + panelDPISettings.PerformLayout(); + tableLayoutPanel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)numericUpDownCurrentDPI).EndInit(); + panelDPITile.ResumeLayout(false); + panelDPITile.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureDPIColor).EndInit(); + tableDPI.ResumeLayout(false); + panelPerformanceHeader.ResumeLayout(false); + panelPerformanceHeader.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureKeyboard).EndInit(); + panelLighting.ResumeLayout(false); + panelLighting.PerformLayout(); + panelLightingContent.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureBoxLightingColor).EndInit(); + panelLightingHeader.ResumeLayout(false); + panelLightingHeader.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxLighting).EndInit(); + panelEnergy.ResumeLayout(false); + panelEnergyHeader.ResumeLayout(false); + panelEnergyHeader.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxEnergy).EndInit(); + tableLayoutProfiles.ResumeLayout(false); + panelBatteryState.ResumeLayout(false); + panelBatteryState.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxBatteryState).EndInit(); + panelBottomButtons.ResumeLayout(false); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Panel panelProfiles; + private Label labelProfile; + private UI.RComboBox comboProfile; + private Panel panelPerformance; + private Panel panelPerformanceHeader; + private PictureBox pictureKeyboard; + private Label labelPerformance; + private Panel panelLighting; + private Panel panelLightingHeader; + private PictureBox pictureBoxLighting; + private Label labelLighting; + private Panel panelEnergy; + private Panel panelEnergyHeader; + private PictureBox pictureBoxEnergy; + private Label labelEnergy; + private TableLayoutPanel tableDPI; + private UI.RButton buttonDPI2; + private UI.RButton buttonDPI1; + private UI.RButton buttonDPI3; + private UI.RButton buttonDPI4; + private UI.Slider sliderDPI; + private Panel panelDPISettings; + private TableLayoutPanel tableLayoutPanel1; + private Label labelMinDPI; + private Label labelMaxDPI; + private Panel panelDPITile; + private Label labelDPI; + private TableLayoutPanel tableLayoutPollingRate; + private UI.RComboBox comboBoxPollingRate; + private UI.Slider sliderAngleAdjustment; + private CheckBox checkBoxAngleSnapping; + private Panel panelPerformanceOther; + private TableLayoutPanel tableLayoutProfiles; + private UI.RButton buttonDPIColor; + private PictureBox pictureDPIColor; + private UI.Slider sliderBrightness; + private Label labelPollingRate; + private Label labelAngleAdjustmentValue; + private Panel panelLightingContent; + private UI.RComboBox comboBoxLightingMode; + private Label labelLightingMode; + private PictureBox pictureBoxLightingColor; + private UI.RButton buttonLightingColor; + private CheckBox checkBoxRandomColor; + private UI.RComboBox comboBoxAnimationSpeed; + private Label labelAnimationSpeed; + private UI.RComboBox comboBoxAnimationDirection; + private Label labelAnimationDirection; + private UI.RComboBox comboBoxLiftOffDistance; + private Label labelLiftOffDistance; + private Label labelLowBatteryWarningValue; + private UI.RComboBox comboBoxAutoPowerOff; + private UI.Slider sliderLowBatteryWarning; + private Label labelLowBatteryWarning; + private Label labelAutoPowerOff; + private Panel panelBatteryState; + private Label labelChargingState; + private Label labelBatteryState; + private PictureBox pictureBoxBatteryState; + private UI.RButton buttonSync; + private Panel panelBottomButtons; + private NumericUpDown numericUpDownCurrentDPI; + } +} \ No newline at end of file diff --git a/app/AsusMouseSettings.cs b/app/AsusMouseSettings.cs new file mode 100644 index 00000000..e7a2d651 --- /dev/null +++ b/app/AsusMouseSettings.cs @@ -0,0 +1,630 @@ +using GHelper.Peripherals.Mouse; +using GHelper.UI; + +namespace GHelper +{ + public partial class AsusMouseSettings : RForm + { + private static Dictionary lightingModeNames = new Dictionary() + { + { LightingMode.Static,Properties.Strings.AuraStatic}, + { LightingMode.Breathing, Properties.Strings.AuraBreathe}, + { LightingMode.ColorCycle, Properties.Strings.AuraColorCycle}, + { LightingMode.Rainbow, Properties.Strings.AuraRainbow}, + { LightingMode.React, Properties.Strings.AuraReact}, + { LightingMode.Comet, Properties.Strings.AuraComet}, + { LightingMode.BatteryState, Properties.Strings.AuraBatteryState}, + { LightingMode.Off, Properties.Strings.MatrixOff}, + }; + private List supportedLightingModes = new List(); + + private readonly AsusMouse mouse; + private readonly RButton[] dpiButtons; + + private bool updateMouseDPI = true; + + public AsusMouseSettings(AsusMouse mouse) + { + this.mouse = mouse; + InitializeComponent(); + + dpiButtons = new RButton[] { buttonDPI1, buttonDPI2, buttonDPI3, buttonDPI4 }; + + + labelPollingRate.Text = Properties.Strings.PollingRate; + labelLighting.Text = Properties.Strings.Lighting; + labelEnergy.Text = Properties.Strings.EnergySettings; + labelPerformance.Text = Properties.Strings.MousePerformance; + checkBoxRandomColor.Text = Properties.Strings.AuraRandomColor; + labelLowBatteryWarning.Text = Properties.Strings.MouseLowBatteryWarning; + labelAutoPowerOff.Text = Properties.Strings.MouseAutoPowerOff; + buttonSync.Text = Properties.Strings.MouseSynchronize; + checkBoxAngleSnapping.Text = Properties.Strings.MouseAngleSnapping; + labelLiftOffDistance.Text = Properties.Strings.MouseLiftOffDistance; + labelChargingState.Text = "(" + Properties.Strings.Charging + ")"; + labelProfile.Text = Properties.Strings.Profile; + + InitTheme(); + + this.Text = mouse.GetDisplayName(); + + Shown += AsusMouseSettings_Shown; + FormClosing += AsusMouseSettings_FormClosing; + + mouse.Disconnect += Mouse_Disconnect; + mouse.BatteryUpdated += Mouse_BatteryUpdated; + comboProfile.DropDownClosed += ComboProfile_DropDownClosed; + + sliderDPI.ValueChanged += SliderDPI_ValueChanged; + numericUpDownCurrentDPI.ValueChanged += NumericUpDownCurrentDPI_ValueChanged; + sliderDPI.MouseUp += SliderDPI_MouseUp; + sliderDPI.MouseDown += SliderDPI_MouseDown; + buttonDPIColor.Click += ButtonDPIColor_Click; + buttonDPI1.Click += ButtonDPI_Click; + buttonDPI2.Click += ButtonDPI_Click; + buttonDPI3.Click += ButtonDPI_Click; + buttonDPI4.Click += ButtonDPI_Click; + + comboBoxPollingRate.DropDownClosed += ComboBoxPollingRate_DropDownClosed; + checkBoxAngleSnapping.CheckedChanged += CheckAngleSnapping_CheckedChanged; + sliderAngleAdjustment.ValueChanged += SliderAngleAdjustment_ValueChanged; + sliderAngleAdjustment.MouseUp += SliderAngleAdjustment_MouseUp; + comboBoxLiftOffDistance.DropDownClosed += ComboBoxLiftOffDistance_DropDownClosed; + + buttonLightingColor.Click += ButtonLightingColor_Click; + comboBoxLightingMode.DropDownClosed += ComboBoxLightingMode_DropDownClosed; + sliderBrightness.MouseUp += SliderBrightness_MouseUp; + comboBoxAnimationSpeed.DropDownClosed += ComboBoxAnimationSpeed_DropDownClosed; + comboBoxAnimationDirection.DropDownClosed += ComboBoxAnimationDirection_DropDownClosed; + checkBoxRandomColor.CheckedChanged += CheckBoxRandomColor_CheckedChanged; + + sliderLowBatteryWarning.ValueChanged += SliderLowBatteryWarning_ValueChanged; + sliderLowBatteryWarning.MouseUp += SliderLowBatteryWarning_MouseUp; + comboBoxAutoPowerOff.DropDownClosed += ComboBoxAutoPowerOff_DropDownClosed; + + InitMouseCapabilities(); + RefreshMouseData(); + } + + private void AsusMouseSettings_FormClosing(object? sender, FormClosingEventArgs e) + { + mouse.BatteryUpdated -= Mouse_BatteryUpdated; + mouse.Disconnect -= Mouse_Disconnect; + } + + private void Mouse_BatteryUpdated(object? sender, EventArgs e) + { + this.Invoke(delegate + { + VisualizeBatteryState(); + }); + + } + + private void ComboProfile_DropDownClosed(object? sender, EventArgs e) + { + mouse.SetProfile(comboProfile.SelectedIndex); + RefreshMouseData(); + } + + private void ComboBoxPollingRate_DropDownClosed(object? sender, EventArgs e) + { + mouse.SetPollingRate(mouse.SupportedPollingrates()[comboBoxPollingRate.SelectedIndex]); + } + + private void ButtonDPIColor_Click(object? sender, EventArgs e) + { + ColorDialog colorDlg = new ColorDialog + { + AllowFullOpen = true, + Color = pictureDPIColor.BackColor + }; + + if (colorDlg.ShowDialog() == DialogResult.OK) + { + AsusMouseDPI dpi = mouse.DpiSettings[mouse.DpiProfile - 1]; + dpi.Color = colorDlg.Color; + + mouse.SetDPIForProfile(dpi, mouse.DpiProfile); + + VisualizeDPIButtons(); + VisualizeCurrentDPIProfile(); + } + } + + private void ButtonDPI_Click(object? sender, EventArgs e) + { + int index = -1; + + for (int i = 0; i < dpiButtons.Length; ++i) + { + if (sender == dpiButtons[i]) + { + index = i; + break; + } + } + + if (index == -1) + { + //huh? + return; + } + + mouse.SetDPIProfile(index + 1); + VisualizeDPIButtons(); + VisualizeCurrentDPIProfile(); + } + + + private void CheckBoxRandomColor_CheckedChanged(object? sender, EventArgs e) + { + LightingSetting? ls = mouse.LightingSetting; + ls.RandomColor = checkBoxRandomColor.Checked; + + mouse.SetLightingSetting(ls); + VisusalizeLightingSettings(); + } + + private void ComboBoxAnimationDirection_DropDownClosed(object? sender, EventArgs e) + { + LightingSetting? ls = mouse.LightingSetting; + ls.AnimationDirection = (AnimationDirection)comboBoxAnimationDirection.SelectedIndex; + + mouse.SetLightingSetting(ls); + VisusalizeLightingSettings(); + } + + private void ComboBoxAnimationSpeed_DropDownClosed(object? sender, EventArgs e) + { + LightingSetting? ls = mouse.LightingSetting; + ls.AnimationSpeed = (AnimationSpeed)comboBoxAnimationSpeed.SelectedIndex; + + mouse.SetLightingSetting(ls); + VisusalizeLightingSettings(); + } + + private void SliderBrightness_MouseUp(object? sender, MouseEventArgs e) + { + LightingSetting? ls = mouse.LightingSetting; + ls.Brightness = sliderBrightness.Value; + + mouse.SetLightingSetting(ls); + } + + private void ComboBoxLightingMode_DropDownClosed(object? sender, EventArgs e) + { + LightingMode lm = supportedLightingModes[comboBoxLightingMode.SelectedIndex]; + + LightingSetting? ls = mouse.LightingSetting; + ls.LightingMode = lm; + + mouse.SetLightingSetting(ls); + VisusalizeLightingSettings(); + } + + private void ButtonLightingColor_Click(object? sender, EventArgs e) + { + ColorDialog colorDlg = new ColorDialog + { + AllowFullOpen = true, + Color = pictureBoxLightingColor.BackColor + }; + + if (colorDlg.ShowDialog() == DialogResult.OK) + { + LightingSetting? ls = mouse.LightingSetting; + ls.RGBColor = colorDlg.Color; + + mouse.SetLightingSetting(ls); + VisusalizeLightingSettings(); + } + } + + private void SliderLowBatteryWarning_ValueChanged(object? sender, EventArgs e) + { + labelLowBatteryWarningValue.Text = sliderLowBatteryWarning.Value.ToString() + "%"; + } + + private void SliderLowBatteryWarning_MouseUp(object? sender, MouseEventArgs e) + { + mouse.SetEnergySettings(sliderLowBatteryWarning.Value, mouse.PowerOffSetting); + } + + + private void ComboBoxAutoPowerOff_DropDownClosed(object? sender, EventArgs e) + { + object? obj = Enum.GetValues(typeof(PowerOffSetting)).GetValue(comboBoxAutoPowerOff.SelectedIndex); + if (obj is null) + { + return; + } + PowerOffSetting pos = (PowerOffSetting)obj; + + + mouse.SetEnergySettings(mouse.LowBatteryWarning, pos); + } + + private void SliderAngleAdjustment_ValueChanged(object? sender, EventArgs e) + { + labelAngleAdjustmentValue.Text = sliderAngleAdjustment.Value.ToString() + "°"; + } + + private void SliderAngleAdjustment_MouseUp(object? sender, MouseEventArgs e) + { + mouse.SetAngleAdjustment((short)sliderAngleAdjustment.Value); + } + + private void ComboBoxLiftOffDistance_DropDownClosed(object? sender, EventArgs e) + { + mouse.SetLiftOffDistance((LiftOffDistance)comboBoxLiftOffDistance.SelectedIndex); + } + + private void CheckAngleSnapping_CheckedChanged(object? sender, EventArgs e) + { + mouse.SetAngleSnapping(checkBoxAngleSnapping.Checked); + mouse.SetAngleAdjustment((short)sliderAngleAdjustment.Value); + } + + private void SliderDPI_ValueChanged(object? sender, EventArgs e) + { + numericUpDownCurrentDPI.Value = sliderDPI.Value; + UpdateMouseDPISettings(); + } + + private void NumericUpDownCurrentDPI_ValueChanged(object? sender, EventArgs e) + { + sliderDPI.Value = (int)numericUpDownCurrentDPI.Value; + } + + private void SliderDPI_MouseDown(object? sender, MouseEventArgs e) + { + updateMouseDPI = false; + } + + private void SliderDPI_MouseUp(object? sender, MouseEventArgs e) + { + updateMouseDPI = true; + UpdateMouseDPISettings(); + } + + private void UpdateMouseDPISettings() + { + if (!updateMouseDPI) + { + return; + } + AsusMouseDPI dpi = mouse.DpiSettings[mouse.DpiProfile - 1]; + dpi.DPI = (uint)sliderDPI.Value; + + mouse.SetDPIForProfile(dpi, mouse.DpiProfile); + + VisualizeDPIButtons(); + VisualizeCurrentDPIProfile(); + } + + private void Mouse_Disconnect(object? sender, EventArgs e) + { + //Mouse disconnected. Bye bye. + this.Invoke(delegate + { + this.Close(); + }); + + } + + private void RefreshMouseData() + { + mouse.SynchronizeDevice(); + if (!mouse.IsDeviceReady) + { + this.Invoke(delegate + { + this.Close(); + }); + return; + } + + + VisualizeMouseSettings(); + VisualizeBatteryState(); + } + + private void InitMouseCapabilities() + { + for (int i = 0; i < mouse.ProfileCount(); ++i) + { + String prf = Properties.Strings.Profile + " " + (i + 1); + comboProfile.Items.Add(prf); + } + + labelMinDPI.Text = mouse.MinDPI().ToString(); + labelMaxDPI.Text = mouse.MaxDPI().ToString(); + + sliderDPI.Max = mouse.MaxDPI(); + sliderDPI.Min = mouse.MinDPI(); + + numericUpDownCurrentDPI.Minimum = mouse.MinDPI(); + numericUpDownCurrentDPI.Maximum = mouse.MaxDPI(); + + + if (!mouse.HasDPIColors()) + { + buttonDPIColor.Visible = false; + pictureDPIColor.Visible = false; + buttonDPI1.Image = ControlHelper.TintImage(Properties.Resources.lighting_dot_24, Color.Red); + buttonDPI2.Image = ControlHelper.TintImage(Properties.Resources.lighting_dot_24, Color.Purple); + buttonDPI3.Image = ControlHelper.TintImage(Properties.Resources.lighting_dot_24, Color.Blue); + buttonDPI4.Image = ControlHelper.TintImage(Properties.Resources.lighting_dot_24, Color.Green); + + buttonDPI1.BorderColor = Color.Red; + buttonDPI1.BorderColor = Color.Purple; + buttonDPI1.BorderColor = Color.Blue; + buttonDPI1.BorderColor = Color.Green; + } + + if (mouse.CanSetPollingRate()) + { + foreach (PollingRate pr in mouse.SupportedPollingrates()) + { + comboBoxPollingRate.Items.Add(mouse.PollingRateDisplayString(pr)); + } + + } + else + { + comboBoxPollingRate.Visible = false; + labelPollingRate.Visible = false; + } + + if (!mouse.HasAngleSnapping()) + { + checkBoxAngleSnapping.Visible = false; + } + + if (!mouse.HasAngleTuning()) + { + labelAngleAdjustmentValue.Visible = false; + sliderAngleAdjustment.Visible = false; + } + + if (mouse.HasLiftOffSetting()) + { + comboBoxLiftOffDistance.Items.AddRange(new string[] { + Properties.Strings.Low, + Properties.Strings.High, + }); + } + else + { + comboBoxLiftOffDistance.Visible = false; + labelLiftOffDistance.Visible = false; + } + + if (mouse.DPIProfileCount() < 4) + { + for (int i = 3; i > mouse.DPIProfileCount() - 1; --i) + { + dpiButtons[i].Visible = false; + } + } + + if (!mouse.HasBattery()) + { + panelBatteryState.Visible = false; + } + + if (mouse.HasAutoPowerOff()) + { + comboBoxAutoPowerOff.Items.AddRange(new string[]{ + " 1 "+ Properties.Strings.Minute, + " 2 "+ Properties.Strings.Minutes, + " 3 "+ Properties.Strings.Minutes, + " 5 "+ Properties.Strings.Minutes, + "10 "+ Properties.Strings.Minutes, + Properties.Strings.Never, + }); + } + + if (!mouse.HasLowBatteryWarning()) + { + labelLowBatteryWarning.Visible = false; + labelLowBatteryWarningValue.Visible = false; + sliderLowBatteryWarning.Visible = false; + } + + if (!mouse.HasAutoPowerOff() && !mouse.HasLowBatteryWarning()) + { + panelEnergy.Visible = false; + } + + if (mouse.HasRGB()) + { + foreach (LightingMode lm in Enum.GetValues(typeof(LightingMode))) + { + if (mouse.IsLightingModeSupported(lm)) + { + comboBoxLightingMode.Items.Add(lightingModeNames.GetValueOrDefault(lm)); + supportedLightingModes.Add(lm); + } + } + + comboBoxAnimationDirection.Items.AddRange(new string[] { + Properties.Strings.AuraClockwise, + Properties.Strings.AuraCounterClockwise, + }); + + comboBoxAnimationSpeed.Items.AddRange(new string[] { + Properties.Strings.AuraSlow, + Properties.Strings.AuraNormal, + Properties.Strings.AuraFast + }); + } + else + { + panelLighting.Visible = false; + } + } + + + private void VisualizeMouseSettings() + { + comboProfile.SelectedIndex = mouse.Profile; + + VisualizeDPIButtons(); + VisualizeCurrentDPIProfile(); + VisusalizeLightingSettings(); + + if (mouse.CanSetPollingRate()) + { + int idx = mouse.PollingRateIndex(mouse.PollingRate); + if (idx == -1) + { + return; + } + comboBoxPollingRate.SelectedIndex = idx; + } + + if (mouse.HasAngleSnapping()) + { + checkBoxAngleSnapping.Checked = mouse.AngleSnapping; + } + + if (mouse.HasAngleTuning()) + { + sliderAngleAdjustment.Value = mouse.AngleAdjustmentDegrees; + } + + if (mouse.HasAutoPowerOff()) + { + if (mouse.PowerOffSetting == PowerOffSetting.Never) + { + comboBoxAutoPowerOff.SelectedIndex = comboBoxAutoPowerOff.Items.Count - 1; + } + else + { + comboBoxAutoPowerOff.SelectedIndex = (int)mouse.PowerOffSetting; + } + } + + if (mouse.HasLowBatteryWarning()) + { + sliderLowBatteryWarning.Value = mouse.LowBatteryWarning; + } + + if (mouse.HasLiftOffSetting()) + { + comboBoxLiftOffDistance.SelectedIndex = (int)mouse.LiftOffDistance; + } + } + + private void VisualizeBatteryState() + { + if (!mouse.HasBattery()) + { + return; + } + + labelBatteryState.Text = mouse.Battery + "%"; + labelChargingState.Visible = mouse.Charging; + + if (mouse.Charging) + { + pictureBoxBatteryState.BackgroundImage = ControlHelper.TintImage(Properties.Resources.icons8_ladende_batterie_48, foreMain); + } + else + { + pictureBoxBatteryState.BackgroundImage = ControlHelper.TintImage(Properties.Resources.icons8_batterie_voll_geladen_48, foreMain); + } + } + + private void VisusalizeLightingSettings() + { + if (!mouse.HasRGB()) + { + return; + } + + LightingSetting? ls = mouse.LightingSetting; + + if (ls is null) + { + //Lighting settings not loaded? + return; + } + + sliderBrightness.Value = ls.Brightness; + + checkBoxRandomColor.Visible = mouse.SupportsRandomColor(ls.LightingMode); + + pictureBoxLightingColor.Visible = mouse.SupportsColorSetting(ls.LightingMode); + buttonLightingColor.Visible = mouse.SupportsColorSetting(ls.LightingMode); + + comboBoxAnimationSpeed.Visible = mouse.SupportsAnimationSpeed(ls.LightingMode); + labelAnimationSpeed.Visible = mouse.SupportsAnimationSpeed(ls.LightingMode); + comboBoxAnimationDirection.Visible = mouse.SupportsAnimationDirection(ls.LightingMode); + labelAnimationDirection.Visible = mouse.SupportsAnimationDirection(ls.LightingMode); + + comboBoxLightingMode.SelectedIndex = supportedLightingModes.IndexOf(ls.LightingMode); + + if (mouse.SupportsRandomColor(ls.LightingMode)) + { + checkBoxRandomColor.Checked = ls.RandomColor; + buttonLightingColor.Visible = !ls.RandomColor; + } + + if (ls.RandomColor && mouse.SupportsRandomColor(ls.LightingMode)) + pictureBoxLightingColor.BackColor = Color.Transparent; + else + pictureBoxLightingColor.BackColor = ls.RGBColor; + + + comboBoxAnimationSpeed.SelectedIndex = (((int)ls.AnimationSpeed) - 5) / 2; + comboBoxAnimationDirection.SelectedIndex = (int)ls.AnimationDirection; + } + + + private void VisualizeDPIButtons() + { + if (mouse.HasDPIColors()) + { + for (int i = 0; i < mouse.DPIProfileCount() && i < 4; ++i) + { + AsusMouseDPI dpi = mouse.DpiSettings[i]; + dpiButtons[i].Image = ControlHelper.TintImage(Properties.Resources.lighting_dot_24, dpi.Color); + dpiButtons[i].Activated = (mouse.DpiProfile - 1) == i; + dpiButtons[i].BorderColor = dpi.Color; + dpiButtons[i].Text = "DPI " + (i + 1) + "\n" + dpi.DPI; + } + } + + } + + private void VisualizeCurrentDPIProfile() + { + AsusMouseDPI dpi = mouse.DpiSettings[mouse.DpiProfile - 1]; + sliderDPI.Value = (int)dpi.DPI; + pictureDPIColor.BackColor = dpi.Color; + } + + private void AsusMouseSettings_Shown(object? sender, EventArgs e) + { + + if (Height > Program.settingsForm.Height) + { + Top = Program.settingsForm.Top + Program.settingsForm.Height - Height; + } + else + { + Top = Program.settingsForm.Top; + } + + Left = Program.settingsForm.Left - Width - 5; + } + + private void ButtonSync_Click(object sender, EventArgs e) + { + RefreshMouseData(); + } + } +} diff --git a/app/AsusMouseSettings.resx b/app/AsusMouseSettings.resx new file mode 100644 index 00000000..a395bffc --- /dev/null +++ b/app/AsusMouseSettings.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/app/Peripherals/IPeripheral.cs b/app/Peripherals/IPeripheral.cs new file mode 100644 index 00000000..93f6a57c --- /dev/null +++ b/app/Peripherals/IPeripheral.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GHelper.Peripherals +{ + public enum PeripheralType + { + Mouse, + Keyboard + } + + public interface IPeripheral + { + public bool IsDeviceReady { get; } + public bool Wireless { get; } + public int Battery { get; } + public bool Charging { get; } + + public PeripheralType DeviceType(); + + public string GetDisplayName(); + + public bool HasBattery(); + + public void SynchronizeDevice(); + + public void ReadBattery(); + } +} diff --git a/app/Peripherals/Mouse/AsusMouse.cs b/app/Peripherals/Mouse/AsusMouse.cs new file mode 100644 index 00000000..dfb2b656 --- /dev/null +++ b/app/Peripherals/Mouse/AsusMouse.cs @@ -0,0 +1,1051 @@ +using GHelper.AnimeMatrix.Communication; +using GHelper.AnimeMatrix.Communication.Platform; +using System.Runtime.CompilerServices; +using System.Text; + +namespace GHelper.Peripherals.Mouse +{ + public enum PowerOffSetting + { + Minutes1 = 0, + Minutes2 = 1, + Minutes3 = 2, + Minutes5 = 3, + Minutes10 = 4, + Never = 0xFF + } + + public enum PollingRate + { + PR125Hz = 0, + PR250Hz = 1, + PR500Hz = 2, + PR1000Hz = 3, + PR2000Hz = 4, + PR4000Hz = 5, + PR8000Hz = 6, + PR16000Hz = 7 //for whenever that gets supported lol + } + + public enum LiftOffDistance + { + Low = 0, + High = 1 + } + public enum AnimationDirection + { + Clockwise = 0x0, + CounterClockwise = 0x1 + } + + public enum AnimationSpeed + { + Slow = 0x9, + Medium = 0x7, + Fast = 0x5 + } + public enum LightingMode + { + Off = 0xF0, + Static = 0x0, + Breathing = 0x1, + ColorCycle = 0x2, + Rainbow = 0x3, + React = 0x4, + Comet = 0x5, + BatteryState = 0x6 + } + + public class LightingSetting + { + public LightingSetting() + { + //Some Sane defaults + LightingMode = LightingMode.Static; + AnimationSpeed = AnimationSpeed.Medium; + AnimationDirection = AnimationDirection.Clockwise; + RandomColor = false; + Brightness = 25; + RGBColor = Color.Red; + } + + public LightingMode LightingMode { get; set; } + public int Brightness { get; set; } + public Color RGBColor { get; set; } + public bool RandomColor { get; set; } + public AnimationSpeed AnimationSpeed { get; set; } + + public AnimationDirection AnimationDirection { get; set; } + + public override string? ToString() + { + return "LightingMode: " + LightingMode + ", Color (" + RGBColor.R + ", " + RGBColor.G + ", " + RGBColor.B + + "), Brightness: " + Brightness + "%, LightingSpeed: " + AnimationSpeed + ", RandomColor:" + RandomColor + ", AnimationDirection:" + AnimationDirection; + } + } + + public class AsusMouseDPI + { + public AsusMouseDPI() + { + Color = Color.Red; + DPI = 800; + } + public Color Color { get; set; } + public uint DPI { get; set; } + public override string? ToString() + { + return "DPI: " + DPI + ", Color (" + Color.R + ", " + Color.G + ", " + Color.B + ")"; + } + } + + public abstract class AsusMouse : Device, IPeripheral + { + private static string[] POLLING_RATES = { "125 Hz", "250 Hz", "500 Hz", "1000 Hz", "2000 Hz", "4000 Hz", "8000 Hz", "16000 Hz" }; + + internal const int ASUS_MOUSE_PACKET_SIZE = 65; + + public event EventHandler? Disconnect; + public event EventHandler? BatteryUpdated; + + private readonly string path; + + public bool IsDeviceReady { get; protected set; } + public bool Wireless { get; protected set; } + public int Battery { get; protected set; } + public bool Charging { get; protected set; } + public LightingSetting? LightingSetting { get; protected set; } + public int LowBatteryWarning { get; protected set; } + public PowerOffSetting PowerOffSetting { get; protected set; } + public LiftOffDistance LiftOffDistance { get; protected set; } + public int DpiProfile { get; protected set; } + public AsusMouseDPI[] DpiSettings { get; protected set; } + public int Profile { get; protected set; } + public PollingRate PollingRate { get; protected set; } + public bool AngleSnapping { get; protected set; } + public short AngleAdjustmentDegrees { get; protected set; } + + public AsusMouse(ushort vendorId, ushort productId, string path, bool wireless) : base(vendorId, productId) + { + this.path = path; + this.Wireless = wireless; + DpiSettings = new AsusMouseDPI[1]; + } + + public override bool Equals(object? obj) + { + if (obj is not AsusMouse item) + { + return false; + } + + return this.VendorID().Equals(item.VendorID()) + && this.ProductID().Equals(item.ProductID()) + && this.path.Equals(item.path); + } + + public override int GetHashCode() + { + int hash = 23; + hash = hash * 31 + VendorID(); + hash = hash * 31 + ProductID(); + hash = hash * 31 + path.GetHashCode(); + return hash; + } + + public void Connect() + { + SetProvider(); + HidSharp.DeviceList.Local.Changed += Device_Changed; + } + + public override void Dispose() + { + HidSharp.DeviceList.Local.Changed -= Device_Changed; + base.Dispose(); + } + + private void Device_Changed(object? sender, HidSharp.DeviceListChangedEventArgs e) + { + //Use this to validate whether the device is still connected. + //If not, this will also initiate the disconnect and cleanup sequence. + CheckConnection(); + } + + //Override this for non battery devices to check whether the connection is still there + //This function should automatically disconnect the device in GHelper if the device is no longer there or the pipe is broken. + public virtual void CheckConnection() + { + ReadBattery(); + } + + public bool IsDeviceConnected() + { + try + { + HidSharp.DeviceList.Local.GetHidDevices(VendorID(), ProductID()) + .First(x => x.DevicePath.Contains(path)); + return true; + } + catch + { + return false; + } + } + + public override void SetProvider() + { + _usbProvider = new WindowsUsbProvider(_vendorId, _productId, path); + } + + protected virtual void OnDisconnect() + { + if (Disconnect is not null) + { + Disconnect(this, EventArgs.Empty); + } + } + + [MethodImpl(MethodImplOptions.Synchronized)] + protected virtual byte[]? WriteForResponse(byte[] packet) + { + byte[] response = new byte[ASUS_MOUSE_PACKET_SIZE]; + + try + { + Logger.WriteLine(GetDisplayName() + ": Sending packet: " + ByteArrayToString(packet)); + Write(packet); + + Read(response); + Logger.WriteLine(GetDisplayName() + ": Read packet: " + ByteArrayToString(response)); + } + catch (IOException e) + { + Logger.WriteLine(GetDisplayName() + ": Failed to read packet " + e.Message); + OnDisconnect(); + return null; + } + catch (System.TimeoutException e) + { + Logger.WriteLine(GetDisplayName() + ": Timeout reading packet " + e.Message); + return null; + } + catch (System.ObjectDisposedException e) + { + Logger.WriteLine(GetDisplayName() + ": Channel closed "); + OnDisconnect(); + return null; + } + + + return response; + } + public abstract string GetDisplayName(); + + public PeripheralType DeviceType() + { + return PeripheralType.Mouse; + } + + public virtual void SynchronizeDevice() + { + DpiSettings = new AsusMouseDPI[DPIProfileCount()]; + ReadBattery(); + if (HasBattery() && Battery <= 0 && Charging == false) + { + //Likely only the dongle connected and the mouse is either sleeping or turned off. + //The mouse will not respond with proper data, but empty responses at this point + IsDeviceReady = false; + return; + } + IsDeviceReady = true; + + ReadProfile(); + ReadDPI(); + ReadLightingSetting(); + ReadLiftOffDistance(); + ReadPollingRate(); + } + + // ------------------------------------------------------------------------------ + // Battery + // ------------------------------------------------------------------------------ + + public virtual bool HasBattery() + { + return true; + } + + public virtual bool HasAutoPowerOff() + { + return false; + } + + public virtual bool HasLowBatteryWarning() + { + return false; + } + + protected virtual byte[] GetBatteryReportPacket() + { + return new byte[] { 0x00, 0x12, 0x07 }; + } + + protected virtual int ParseBattery(byte[] packet) + { + if (packet[1] == 0x12 && packet[2] == 0x07) + { + return packet[5]; + } + + return -1; + } + protected virtual bool ParseChargingState(byte[] packet) + { + if (packet[1] == 0x12 && packet[2] == 0x07) + { + return packet[10] > 0; + } + + return false; + } + + protected virtual PowerOffSetting ParsePowerOffSetting(byte[] packet) + { + if (packet[1] == 0x12 && packet[2] == 0x07) + { + return (PowerOffSetting)packet[6]; + } + + return PowerOffSetting.Never; + } + protected virtual int ParseLowBatteryWarning(byte[] packet) + { + if (packet[1] == 0x12 && packet[2] == 0x07) + { + return packet[7]; + } + + return 0; + } + protected virtual byte[] GetUpdateEnergySettingsPacket(int lowBatteryWarning, PowerOffSetting powerOff) + { + return new byte[] { 0x00, 0x51, 0x37, 0x00, 0x00, (byte)powerOff, 0x00, (byte)lowBatteryWarning }; + } + + public void SetEnergySettings(int lowBatteryWarning, PowerOffSetting powerOff) + { + if (!HasAutoPowerOff() && !HasLowBatteryWarning()) + { + return; + } + + WriteForResponse(GetUpdateEnergySettingsPacket(lowBatteryWarning, powerOff)); + FlushSettings(); + + Logger.WriteLine(GetDisplayName() + ": Got Auto Power Off: " + powerOff + " - Low Battery Warnning at: " + lowBatteryWarning + "%"); + this.PowerOffSetting = powerOff; + this.LowBatteryWarning = lowBatteryWarning; + } + + public void ReadBattery() + { + if (!HasBattery() && !HasAutoPowerOff()) + { + return; + } + + byte[]? response = WriteForResponse(GetBatteryReportPacket()); + if (response is null) return; + + if (HasBattery()) + { + Battery = ParseBattery(response); + Charging = ParseChargingState(response); + + //If the device goes to standby it will not report battery state anymore. + IsDeviceReady = Battery > 0; + + Logger.WriteLine(GetDisplayName() + ": Got Battery Percentage " + Battery + "% - Charging:" + Charging); + + if (BatteryUpdated is not null) + { + BatteryUpdated(this, EventArgs.Empty); + } + } + + if (HasAutoPowerOff()) + { + PowerOffSetting = ParsePowerOffSetting(response); + } + + if (HasLowBatteryWarning()) + { + LowBatteryWarning = ParseLowBatteryWarning(response); + } + + if (HasLowBatteryWarning() || HasAutoPowerOff()) + { + Logger.WriteLine(GetDisplayName() + ": Got Auto Power Off: " + PowerOffSetting + " - Low Battery Warnning at: " + LowBatteryWarning + "%"); + } + + } + + // ------------------------------------------------------------------------------ + // Profiles + // ------------------------------------------------------------------------------ + public abstract int ProfileCount(); + + public virtual bool HasProfiles() + { + return true; + } + + protected virtual int ParseProfile(byte[] packet) + { + if (packet[1] == 0x12 && packet[2] == 0x00 && packet[3] == 0x00) + { + return packet[11]; + } + Logger.WriteLine(GetDisplayName() + ": Failed to decode active profile"); + return 1; + } + + protected virtual int ParseDPIProfile(byte[] packet) + { + if (packet[1] == 0x12 && packet[2] == 0x00 && packet[3] == 0x00) + { + return packet[12]; + } + Logger.WriteLine(GetDisplayName() + ": Failed to decode active profile"); + return 1; + } + + protected virtual byte[] GetReadProfilePacket() + { + return new byte[] { 0x00, 0x12, 0x00 }; + } + + protected virtual byte[] GetUpdateProfilePacket(int profile) + { + return new byte[] { 0x00, 0x50, 0x02, (byte)profile }; + } + + public void ReadProfile() + { + if (!HasProfiles()) + { + return; + } + + byte[]? response = WriteForResponse(GetReadProfilePacket()); + if (response is null) return; + + Profile = ParseProfile(response); + if (DPIProfileCount() > 1) + { + + DpiProfile = ParseDPIProfile(response); + } + Logger.WriteLine(GetDisplayName() + ": Active Profile " + (Profile + 1) + + ((DPIProfileCount() > 1 ? ", Active DPI Profile: " + DpiProfile : ""))); + } + + public void SetProfile(int profile) + { + if (!HasProfiles()) + { + return; + } + + if (profile > ProfileCount() || profile < 0) + { + Logger.WriteLine(GetDisplayName() + ": Profile:" + profile + " is invalid."); + return; + } + + WriteForResponse(GetUpdateProfilePacket(profile)); + FlushSettings(); + + Logger.WriteLine(GetDisplayName() + ": Profile set to " + profile); + this.Profile = profile; + } + + // ------------------------------------------------------------------------------ + // Polling Rate and Angle Snapping + // ------------------------------------------------------------------------------ + + + public virtual bool HasAngleSnapping() + { + return false; + } + public virtual bool HasAngleTuning() + { + return false; + } + + public virtual string PollingRateDisplayString(PollingRate pollingRate) + { + return POLLING_RATES[(int)pollingRate]; + } + + public virtual int PollingRateCount() + { + return SupportedPollingrates().Length; + } + + public virtual int PollingRateIndex(PollingRate pollingRate) + { + for (int i = 0; i < PollingRateCount(); ++i) + { + if (SupportedPollingrates()[i] == pollingRate) + { + return i; + } + } + return -1; + } + + + public virtual bool IsPollingRateSupported(PollingRate pollingRate) + { + return SupportedPollingrates().Contains(pollingRate); + } + + public abstract PollingRate[] SupportedPollingrates(); + + public virtual bool CanSetPollingRate() + { + return true; + } + + protected virtual byte[] GetReadPollingRatePacket() + { + return new byte[] { 0x00, 0x12, 0x04, 0x00 }; + } + + protected virtual byte[] GetUpdatePollingRatePacket(PollingRate pollingRate) + { + return new byte[] { 0x00, 0x51, 0x31, 0x04, 0x00, (byte)pollingRate }; + } + protected virtual byte[] GetUpdateAngleSnappingPacket(bool angleSnapping) + { + return new byte[] { 0x00, 0x51, 0x31, 0x06, 0x00, (byte)(angleSnapping ? 0x01 : 0x00) }; + } + protected virtual byte[] GetUpdateAngleAdjustmentPacket(short angleAdjustment) + { + return new byte[] { 0x00, 0x51, 0x31, 0x0B, 0x00, (byte)(angleAdjustment & 0xFF), (byte)((angleAdjustment >> 8) & 0xFF) }; + } + + protected virtual PollingRate ParsePollingRate(byte[] packet) + { + if (packet[1] == 0x12 && packet[2] == 0x04 && packet[3] == 0x00) + { + return (PollingRate)packet[13]; + } + + return PollingRate.PR125Hz; + } + + protected virtual bool ParseAngleSnapping(byte[] packet) + { + if (packet[1] == 0x12 && packet[2] == 0x04 && packet[3] == 0x00) + { + return packet[17] == 0x01; + } + + return false; + } + + protected virtual short ParseAngleAdjustment(byte[] packet) + { + if (packet[1] == 0x12 && packet[2] == 0x04 && packet[3] == 0x00) + { + return (short)(packet[20] << 8 | packet[19]); + } + + return 0; + } + + public void ReadPollingRate() + { + if (!CanSetPollingRate()) + { + return; + } + + byte[]? response = WriteForResponse(GetReadPollingRatePacket()); + if (response is null) return; + + PollingRate = ParsePollingRate(response); + Logger.WriteLine(GetDisplayName() + ": Pollingrate: " + PollingRateDisplayString(PollingRate) + " (" + PollingRate + ")"); + + if (HasAngleSnapping()) + { + AngleSnapping = ParseAngleSnapping(response); + if (HasAngleTuning()) + AngleAdjustmentDegrees = ParseAngleAdjustment(response); + + Logger.WriteLine(GetDisplayName() + ": Angle Snapping enabled: " + AngleSnapping + ", Angle Adjustment: " + AngleAdjustmentDegrees + "°"); + } + } + + public void SetPollingRate(PollingRate pollingRate) + { + if (!CanSetPollingRate()) + { + return; + } + + if (!IsPollingRateSupported(pollingRate)) + { + Logger.WriteLine(GetDisplayName() + ": Pollingrate:" + pollingRate + " is not supported by this mouse."); + return; + } + + WriteForResponse(GetUpdatePollingRatePacket(pollingRate)); + FlushSettings(); + + Logger.WriteLine(GetDisplayName() + ": Pollingrate set to " + PollingRateDisplayString(pollingRate)); + this.PollingRate = pollingRate; + } + + public void SetAngleSnapping(bool angleSnapping) + { + if (!HasAngleSnapping()) + { + return; + } + + WriteForResponse(GetUpdateAngleSnappingPacket(angleSnapping)); + FlushSettings(); + + Logger.WriteLine(GetDisplayName() + ": Angle Snapping set to " + angleSnapping); + this.AngleSnapping = angleSnapping; + } + + public void SetAngleAdjustment(short angleAdjustment) + { + if (!HasAngleTuning()) + { + return; + } + + if (angleAdjustment < -20 || angleAdjustment > 20) + { + Logger.WriteLine(GetDisplayName() + ": Angle Adjustment:" + angleAdjustment + " is outside of range [-20;20]."); + return; + } + + WriteForResponse(GetUpdateAngleAdjustmentPacket(angleAdjustment)); + FlushSettings(); + + Logger.WriteLine(GetDisplayName() + ": Angle Adjustment set to " + angleAdjustment); + this.AngleAdjustmentDegrees = angleAdjustment; + } + + // ------------------------------------------------------------------------------ + // DPI + // ------------------------------------------------------------------------------ + public abstract int DPIProfileCount(); + public virtual bool HasDPIColors() + { + return false; + } + + public virtual bool CanChangeDPIProfile() + { + return DPIProfileCount() > 1; + } + + public virtual int MaxDPI() + { + return 2000; + } + public virtual int MinDPI() + { + return 100; + } + + protected virtual byte[] GetChangeDPIProfilePacket(int profile) + { + return new byte[] { 0x00, 0x51, 0x31, 0x09, 0x00, (byte)profile }; + } + + //profiles start to count at 1 + public void SetDPIProfile(int profile) + { + if (!CanChangeDPIProfile()) + { + return; + } + + if (profile > DPIProfileCount() || profile < 1) + { + Logger.WriteLine(GetDisplayName() + ": DPI Profile:" + profile + " is invalid."); + return; + } + + //The first DPI profile is 1 + WriteForResponse(GetChangeDPIProfilePacket(profile)); + FlushSettings(); + + Logger.WriteLine(GetDisplayName() + ": DPI Profile set to " + profile); + this.DpiProfile = profile; + } + + protected virtual byte[] GetReadDPIPacket() + { + return new byte[] { 0x00, 0x12, 0x04, 0x02 }; + } + + protected virtual byte[]? GetUpdateDPIPacket(AsusMouseDPI dpi, int profile) + { + if (dpi is null) + { + return null; + } + if (dpi.DPI > MaxDPI() || dpi.DPI < MinDPI()) + { + return null; + } + ushort dpiEncoded = (ushort)((dpi.DPI - 50) / 50); + + if (HasDPIColors()) + { + return new byte[] { 0x00, 0x51, 0x31, (byte)(profile - 1), 0x00, (byte)(dpiEncoded & 0xFF), (byte)((dpiEncoded >> 8) & 0xFF), dpi.Color.R, dpi.Color.G, dpi.Color.B }; + } + else + { + return new byte[] { 0x00, 0x51, 0x31, (byte)(profile - 1), 0x00, (byte)(dpiEncoded & 0xFF), (byte)((dpiEncoded >> 8) & 0xFF) }; + } + + } + + protected virtual void ParseDPI(byte[] packet) + { + if (packet[1] != 0x12 || packet[2] != 0x04 || packet[3] != 0x02) + { + return; + } + + for (int i = 0; i < DPIProfileCount(); ++i) + { + if (DpiSettings[i] is null) + { + DpiSettings[i] = new AsusMouseDPI(); + } + + int offset = 5 + (i * 4); + + uint b1 = packet[offset]; + uint b2 = packet[offset + 1]; + + DpiSettings[i].DPI = (uint)(b2 << 8 | b1) * 50 + 50; + } + } + + protected virtual byte[] GetReadDPIColorsPacket() + { + return new byte[] { 0x00, 0x12, 0x04, 0x03 }; + } + + protected virtual void ParseDPIColors(byte[] packet) + { + if (packet[1] != 0x12 || packet[2] != 0x04 || packet[3] != 0x03) + { + return; + } + + for (int i = 0; i < DPIProfileCount(); ++i) + { + if (DpiSettings[i] is null) + { + DpiSettings[i] = new AsusMouseDPI(); + } + + int offset = 5 + (i * 3); + + DpiSettings[i].Color = Color.FromArgb(packet[offset], packet[offset + 1], packet[offset + 2]); + } + } + + public void ReadDPI() + { + byte[]? response = WriteForResponse(GetReadDPIPacket()); + if (response is null) return; + ParseDPI(response); + + if (HasDPIColors()) + { + response = WriteForResponse(GetReadDPIColorsPacket()); + if (response is null) return; + ParseDPIColors(response); + } + + for (int i = 0; i < DPIProfileCount(); ++i) + { + Logger.WriteLine(GetDisplayName() + ": Read DPI Setting " + (i + 1) + ": " + DpiSettings[i].ToString()); + } + + } + + public void SetDPIForProfile(AsusMouseDPI dpi, int profile) + { + if (profile > DPIProfileCount() || profile < 1) + { + Logger.WriteLine(GetDisplayName() + ": DPI Profile:" + profile + " is invalid."); + return; + } + + byte[]? packet = GetUpdateDPIPacket(dpi, profile); + if (packet == null) + { + Logger.WriteLine(GetDisplayName() + ": DPI setting for profile " + profile + " does not exist or is invalid."); + return; + } + WriteForResponse(packet); + FlushSettings(); + + Logger.WriteLine(GetDisplayName() + ": DPI for profile " + profile + " set to " + DpiSettings[profile - 1].DPI); + //this.DpiProfile = profile; + this.DpiSettings[profile - 1] = dpi; + } + + + + // ------------------------------------------------------------------------------ + // Lift-off Distance + // ------------------------------------------------------------------------------ + + public virtual bool HasLiftOffSetting() + { + return false; + } + + protected virtual byte[] GetReadLiftOffDistancePacket() + { + return new byte[] { 0x00, 0x12, 0x06 }; + } + + //This also resets the "calibration" to default. There is no seperate command to only set the lift off distance + protected virtual byte[] GetUpdateLiftOffDistancePacket(LiftOffDistance liftOffDistance) + { + return new byte[] { 0x00, 0x51, 0x35, 0xFF, 0x00, 0xFF, ((byte)liftOffDistance) }; + } + + protected virtual LiftOffDistance ParseLiftOffDistance(byte[] packet) + { + if (packet[1] != 0x12 || packet[2] != 0x06) + { + return LiftOffDistance.Low; + } + + return (LiftOffDistance)packet[8]; + } + + public void ReadLiftOffDistance() + { + if (!HasLiftOffSetting()) + { + return; + } + byte[]? response = WriteForResponse(GetReadLiftOffDistancePacket()); + if (response is null) return; + + LiftOffDistance = ParseLiftOffDistance(response); + + + Logger.WriteLine(GetDisplayName() + ": Read Lift Off Setting: " + LiftOffDistance); + } + + public void SetLiftOffDistance(LiftOffDistance liftOffDistance) + { + if (!HasLiftOffSetting()) + { + return; + } + + WriteForResponse(GetUpdateLiftOffDistancePacket(liftOffDistance)); + FlushSettings(); + + Logger.WriteLine(GetDisplayName() + ": Set Liftoff Distance to " + liftOffDistance); + this.LiftOffDistance = liftOffDistance; + } + + // ------------------------------------------------------------------------------ + // RGB + // ------------------------------------------------------------------------------ + + public virtual bool HasRGB() + { + return false; + } + + //Override to remap lighting mode IDs. + //From OpenRGB code it looks like some mice have different orders of the modes or do not support some modes at all. + protected virtual byte IndexForLightingMode(LightingMode lightingMode) + { + return ((byte)lightingMode); + } + + //Also override this for the reverse mapping + protected virtual LightingMode LightingModeForIndex(byte lightingMode) + { + //We do not support other mods. we treat them as off. True off is actually 0xF0. + if (lightingMode > 0x06) + { + return LightingMode.Off; + } + return ((LightingMode)lightingMode); + } + + //And this if not all modes are supported + public virtual bool IsLightingModeSupported(LightingMode lightingMode) + { + return true; + } + + public virtual bool SupportsRandomColor(LightingMode lightingMode) + { + return lightingMode == LightingMode.Comet; + } + + public virtual bool SupportsAnimationDirection(LightingMode lightingMode) + { + return lightingMode == LightingMode.Rainbow + || lightingMode == LightingMode.Comet; + } + public virtual bool SupportsAnimationSpeed(LightingMode lightingMode) + { + return lightingMode == LightingMode.Rainbow; + } + + public virtual bool SupportsColorSetting(LightingMode lightingMode) + { + return lightingMode == LightingMode.Static + || lightingMode == LightingMode.Breathing + || lightingMode == LightingMode.Comet + || lightingMode == LightingMode.React; + } + + protected virtual byte[] GetReadLightingModePacket() + { + return new byte[] { 0x00, 0x12, 0x03 }; + } + + protected virtual byte[] GetUpdateLightingModePacket(LightingSetting lightingSetting) + { + if (lightingSetting.Brightness < 0 || lightingSetting.Brightness > 100) + { + Logger.WriteLine(GetDisplayName() + ": Brightness " + lightingSetting.Brightness + " is out of range [0;100]. Setting to 25."); + lightingSetting.Brightness = 25; + } + if (!IsLightingModeSupported(lightingSetting.LightingMode)) + { + Logger.WriteLine(GetDisplayName() + ": Lighting Mode " + lightingSetting.LightingMode + " is not supported. Setting to Rainbow ;)"); + lightingSetting.LightingMode = LightingMode.Rainbow; + } + + return new byte[] { 0x00, 0x51, 0x28, 0x03, 0x00, + IndexForLightingMode(lightingSetting.LightingMode), + (byte)lightingSetting.Brightness, + lightingSetting.RGBColor.R, lightingSetting.RGBColor.G, lightingSetting.RGBColor.B, + (byte)lightingSetting.AnimationDirection, + (byte)(lightingSetting.RandomColor ? 0x01: 0x00), + (byte)lightingSetting.AnimationSpeed + }; + } + + protected virtual LightingSetting? ParseLightingSetting(byte[] packet) + { + if (packet[1] != 0x12 || packet[2] != 0x03) + { + return null; + } + + LightingSetting setting = new LightingSetting(); + + setting.LightingMode = LightingModeForIndex(packet[5]); + setting.Brightness = packet[6]; + + setting.RGBColor = Color.FromArgb(packet[7], packet[8], packet[9]); + setting.AnimationDirection = (AnimationDirection)packet[11]; + setting.RandomColor = packet[12] == 0x01; + setting.AnimationSpeed = (AnimationSpeed)packet[13]; + + //If the mouse reports 0, which it does when the current setting has no speed option, chose medium as default + if (setting.AnimationSpeed != AnimationSpeed.Fast + && setting.AnimationSpeed != AnimationSpeed.Medium + && setting.AnimationSpeed != AnimationSpeed.Slow) + { + setting.AnimationSpeed = AnimationSpeed.Medium; + } + + return setting; + } + + public void ReadLightingSetting() + { + if (!HasRGB()) + { + return; + } + byte[]? response = WriteForResponse(GetReadLightingModePacket()); + if (response is null) return; + + LightingSetting = ParseLightingSetting(response); + + if (LightingSetting is not null) + { + Logger.WriteLine(GetDisplayName() + ": Read RGB Setting" + LightingSetting.ToString()); + } + else + { + Logger.WriteLine(GetDisplayName() + ": Failed to read RGB Setting"); + } + } + + public void SetLightingSetting(LightingSetting lightingSetting) + { + if (!HasRGB() || lightingSetting is null) + { + return; + } + + WriteForResponse(GetUpdateLightingModePacket(lightingSetting)); + FlushSettings(); + + Logger.WriteLine(GetDisplayName() + ": Set RGB Setting " + lightingSetting.ToString()); + this.LightingSetting = lightingSetting; + } + + protected virtual byte[] GetSaveProfilePacket() + { + return new byte[] { 0x00, 0x50, 0x03 }; + } + + public void FlushSettings() + { + WriteForResponse(GetSaveProfilePacket()); + + Logger.WriteLine(GetDisplayName() + ": Settings Flushed "); + } + + public override string? ToString() + { + return ""; + + } + + + public static string ByteArrayToString(byte[] packet) + { + StringBuilder hex = new StringBuilder(packet.Length * 2); + foreach (byte b in packet) + hex.AppendFormat("{0:x2} ", b); + return hex.ToString(); + } + } +} diff --git a/app/Peripherals/Mouse/Models/ChakramX.cs b/app/Peripherals/Mouse/Models/ChakramX.cs new file mode 100644 index 00000000..f4ecde35 --- /dev/null +++ b/app/Peripherals/Mouse/Models/ChakramX.cs @@ -0,0 +1,102 @@ + +namespace GHelper.Peripherals.Mouse.Models +{ + public class ChakramX : AsusMouse + { + public ChakramX() : base(0x0B05, 0x1A1A, "mi_00", true) + { + } + + protected ChakramX(ushort vendorId, bool wireless) : base(0x0B05, vendorId, "mi_00", wireless) + { + } + + public override string GetDisplayName() + { + return "ROG Chakram X (Wireless)"; + } + + public override PollingRate[] SupportedPollingrates() + { + return new PollingRate[] { + PollingRate.PR250Hz, + PollingRate.PR500Hz, + PollingRate.PR1000Hz + }; + } + + public override bool HasAngleSnapping() + { + return true; + } + + public override int ProfileCount() + { + return 5; + } + + public override int DPIProfileCount() + { + return 4; + } + + public override int MaxDPI() + { + return 36_000; + } + + public override bool HasLiftOffSetting() + { + return true; + } + + public override bool HasRGB() + { + return true; + } + + public override bool HasAutoPowerOff() + { + return true; + } + + public override bool HasAngleTuning() + { + return true; + } + + public override bool HasLowBatteryWarning() + { + return true; + } + + public override bool HasDPIColors() + { + return true; + } + } + + public class ChakramXWired : ChakramX + { + public ChakramXWired() : base(0x1A18, false) + { + } + + public override string GetDisplayName() + { + return "ROG Chakram X (Wired)"; + } + + public override PollingRate[] SupportedPollingrates() + { + return new PollingRate[] { + PollingRate.PR250Hz, + PollingRate.PR500Hz, + PollingRate.PR1000Hz, + PollingRate.PR2000Hz, + PollingRate.PR4000Hz, + PollingRate.PR8000Hz + }; + } + } +} diff --git a/app/Peripherals/Mouse/Models/GladiusIII.cs b/app/Peripherals/Mouse/Models/GladiusIII.cs new file mode 100644 index 00000000..3459b457 --- /dev/null +++ b/app/Peripherals/Mouse/Models/GladiusIII.cs @@ -0,0 +1,90 @@ +namespace GHelper.Peripherals.Mouse.Models +{ + public class GladiusIII : AsusMouse + { + public GladiusIII() : base(0x0B05, 0x1A70, "mi_00", true) + { + } + + protected GladiusIII(ushort vendorId, bool wireless) : base(0x0B05, vendorId, "mi_00", wireless) + { + } + + public override int DPIProfileCount() + { + return 4; + } + + public override string GetDisplayName() + { + return "ROG Gladius III (Wireless)"; + } + + + public override PollingRate[] SupportedPollingrates() + { + return new PollingRate[] { + PollingRate.PR125Hz, + PollingRate.PR250Hz, + PollingRate.PR500Hz, + PollingRate.PR1000Hz + }; + } + + public override int ProfileCount() + { + return 5; + } + public override int MaxDPI() + { + return 36_000; + } + + public override bool HasLiftOffSetting() + { + return true; + } + + public override bool HasRGB() + { + return true; + } + + public override bool HasAutoPowerOff() + { + return true; + } + + public override bool HasAngleSnapping() + { + return true; + } + + public override bool HasAngleTuning() + { + return true; + } + + public override bool HasLowBatteryWarning() + { + return true; + } + + public override bool HasDPIColors() + { + return true; + } + } + + public class GladiusIIIWired : GladiusIII + { + public GladiusIIIWired() : base(0x1A72, false) + { + } + + public override string GetDisplayName() + { + return "ROG Gladius III (Wired)"; + } + } +} diff --git a/app/Peripherals/PeripheralsProvider.cs b/app/Peripherals/PeripheralsProvider.cs new file mode 100644 index 00000000..702c2631 --- /dev/null +++ b/app/Peripherals/PeripheralsProvider.cs @@ -0,0 +1,169 @@ +using GHelper.Peripherals.Mouse; +using GHelper.Peripherals.Mouse.Models; +using System.Runtime.CompilerServices; + +namespace GHelper.Peripherals +{ + public class PeripheralsProvider + { + public static object _LOCK = new object(); + + public static List ConnectedMice = new List(); + + public static event EventHandler? DeviceChanged; + + public static bool IsMouseConnected() + { + return ConnectedMice.Count > 0; + } + + //Expand if keyboards or other device get supported later. + public static bool IsAnyPeripheralConnect() + { + return IsMouseConnected(); + } + + public static List AllPeripherals() + { + List l = new List(); + l.AddRange(ConnectedMice); + + return l; + } + + public static void RefreshBatteryForAllDevices() + { + lock (_LOCK) + { + foreach (IPeripheral m in AllPeripherals()) + { + if (!m.IsDeviceReady) + { + //Try to sync the device if that hasn't been done yet + m.SynchronizeDevice(); + } + else + { + m.ReadBattery(); + } + } + } + + } + + public static void Disconnect(AsusMouse am) + { + lock (_LOCK) + { + ConnectedMice.Remove(am); + if (DeviceChanged is not null) + { + DeviceChanged(am, EventArgs.Empty); + } + } + } + + public static void Connect(AsusMouse am) + { + lock (_LOCK) + { + if (ConnectedMice.Contains(am)) + { + //Mouse already connected; + return; + } + try + { + am.Connect(); + } + catch (IOException e) + { + Logger.WriteLine(am.GetDisplayName() + " failed to connect to device: " + e); + return; + } + + am.Disconnect += Mouse_Disconnect; + + //The Mouse might needs a few ms to register all its subdevices or the sync will fail. + //Retry 3 times. Do not call this on main thread! It would block the UI + + int tries = 0; + while (!am.IsDeviceReady && tries < 3) + { + Thread.Sleep(250); + Logger.WriteLine(am.GetDisplayName() + " synchronising. Try " + (tries + 1)); + am.SynchronizeDevice(); + ++tries; + } + + ConnectedMice.Add(am); + Logger.WriteLine(am.GetDisplayName() + " added to the list: " + ConnectedMice.Count + " device are conneted."); + if (DeviceChanged is not null) + { + DeviceChanged(am, EventArgs.Empty); + } + UpdateSettingsView(); + } + } + + private static void Mouse_Disconnect(object? sender, EventArgs e) + { + if (sender is null) + { + return; + } + lock (_LOCK) + { + AsusMouse am = (AsusMouse)sender; + ConnectedMice.Remove(am); + Logger.WriteLine(am.GetDisplayName() + " reported disconnect. " + ConnectedMice.Count + " device are conneted."); + am.Dispose(); + UpdateSettingsView(); + } + } + + + private static void UpdateSettingsView() + { + Program.settingsForm.Invoke(delegate + { + Program.settingsForm.VisualizePeripherals(); + }); + } + + [MethodImpl(MethodImplOptions.Synchronized)] + public static void DetectAllAsusMice() + { + //Add one line for every supported mouse class here to support them. + DetectMouse(new ChakramX()); + DetectMouse(new ChakramXWired()); + DetectMouse(new GladiusIII()); + DetectMouse(new GladiusIIIWired()); + } + + public static void DetectMouse(AsusMouse am) + { + if (am.IsDeviceConnected() && !ConnectedMice.Contains(am)) + { + Logger.WriteLine("Detected a new ROG Chakram X. Connecting..."); + Connect(am); + } + } + + public static void RegisterForDeviceEvents() + { + HidSharp.DeviceList.Local.Changed += Device_Changed; + } + + public static void UnregisterForDeviceEvents() + { + HidSharp.DeviceList.Local.Changed -= Device_Changed; + } + + private static void Device_Changed(object? sender, HidSharp.DeviceListChangedEventArgs e) + { + Logger.WriteLine("HID Device Event: Checking for new ASUS Mice"); + Task task = Task.Run((Action)DetectAllAsusMice); + } + } +} diff --git a/app/Program.cs b/app/Program.cs index ed8f8bae..98cd85e7 100644 --- a/app/Program.cs +++ b/app/Program.cs @@ -4,6 +4,7 @@ using GHelper.Gpu; using GHelper.Helpers; using GHelper.Input; using GHelper.Mode; +using GHelper.Peripherals; using Microsoft.Win32; using Ryzen; using System.Diagnostics; @@ -112,6 +113,9 @@ namespace GHelper unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(settingsForm.Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE); + Task task = Task.Run((Action)PeripheralsProvider.DetectAllAsusMice); + PeripheralsProvider.RegisterForDeviceEvents(); + if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\') || action.Length > 0) { SettingsToggle(action); @@ -261,6 +265,7 @@ namespace GHelper static void OnExit(object sender, EventArgs e) { trayIcon.Visible = false; + PeripheralsProvider.UnregisterForDeviceEvents(); clamshellControl.UnregisterDisplayEvents(); NativeMethods.UnregisterPowerSettingNotification(unRegPowerNotify); Application.Exit(); diff --git a/app/Properties/Resources.Designer.cs b/app/Properties/Resources.Designer.cs index 7b788858..e151f4d0 100644 --- a/app/Properties/Resources.Designer.cs +++ b/app/Properties/Resources.Designer.cs @@ -140,6 +140,16 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_batterie_voll_geladen_48 { + get { + object obj = ResourceManager.GetObject("icons8_batterie_voll_geladen_48", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -280,6 +290,16 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_ladende_batterie_48 { + get { + object obj = ResourceManager.GetObject("icons8_ladende_batterie_48", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -320,6 +340,36 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_maus_32 { + get { + object obj = ResourceManager.GetObject("icons8_maus_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_maus_48 { + get { + object obj = ResourceManager.GetObject("icons8_maus_48", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_mauszeiger_50 { + get { + object obj = ResourceManager.GetObject("icons8_mauszeiger_50", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -521,7 +571,37 @@ namespace GHelper.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap lighting_dot_24 { + get { + object obj = ResourceManager.GetObject("lighting_dot_24", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap lighting_dot_32 { + get { + object obj = ResourceManager.GetObject("lighting_dot_32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap lighting_dot_48 { + get { + object obj = ResourceManager.GetObject("lighting_dot_48", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Icon ähnlich wie (Symbol). /// internal static System.Drawing.Icon standard { get { diff --git a/app/Properties/Resources.resx b/app/Properties/Resources.resx index ffee67b5..a732ee99 100644 --- a/app/Properties/Resources.resx +++ b/app/Properties/Resources.resx @@ -262,4 +262,28 @@ ..\Resources\icons8-software-32-white.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-maus-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icons8-maus-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icons8-mauszeiger-50.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icons8-batterie-voll-geladen-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icons8-ladende-batterie-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\lighting_dot_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\lighting_dot_48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\lighting_dot_24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/app/Properties/Strings.Designer.cs b/app/Properties/Strings.Designer.cs index 76e439e1..77290fe0 100644 --- a/app/Properties/Strings.Designer.cs +++ b/app/Properties/Strings.Designer.cs @@ -195,6 +195,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Battery State. + /// + internal static string AuraBatteryState { + get { + return ResourceManager.GetString("AuraBatteryState", resourceCulture); + } + } + /// /// Looks up a localized string similar to Breathe. /// @@ -204,6 +213,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Clockwise. + /// + internal static string AuraClockwise { + get { + return ResourceManager.GetString("AuraClockwise", resourceCulture); + } + } + /// /// Looks up a localized string similar to Color Cycle. /// @@ -213,6 +231,24 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Comet. + /// + internal static string AuraComet { + get { + return ResourceManager.GetString("AuraComet", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Counterclockwise. + /// + internal static string AuraCounterClockwise { + get { + return ResourceManager.GetString("AuraCounterClockwise", resourceCulture); + } + } + /// /// Looks up a localized string similar to Fast. /// @@ -240,6 +276,24 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Random. + /// + internal static string AuraRandomColor { + get { + return ResourceManager.GetString("AuraRandomColor", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to React. + /// + internal static string AuraReact { + get { + return ResourceManager.GetString("AuraReact", resourceCulture); + } + } + /// /// Looks up a localized string similar to Slow. /// @@ -503,6 +557,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Energy Settings. + /// + internal static string EnergySettings { + get { + return ResourceManager.GetString("EnergySettings", resourceCulture); + } + } + /// /// Looks up a localized string similar to Extra. /// @@ -701,6 +764,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to High. + /// + internal static string High { + get { + return ResourceManager.GetString("High", resourceCulture); + } + } + /// /// Looks up a localized string similar to Key Bindings. /// @@ -773,6 +845,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Lighting. + /// + internal static string Lighting { + get { + return ResourceManager.GetString("Lighting", resourceCulture); + } + } + /// /// Looks up a localized string similar to Logo. /// @@ -782,6 +863,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Low. + /// + internal static string Low { + get { + return ResourceManager.GetString("Low", resourceCulture); + } + } + /// /// Looks up a localized string similar to Audio Visualizer. /// @@ -881,6 +971,78 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Minute. + /// + internal static string Minute { + get { + return ResourceManager.GetString("Minute", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Minutes. + /// + internal static string Minutes { + get { + return ResourceManager.GetString("Minutes", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Angle Snapping. + /// + internal static string MouseAngleSnapping { + get { + return ResourceManager.GetString("MouseAngleSnapping", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Auto Power Off After. + /// + internal static string MouseAutoPowerOff { + get { + return ResourceManager.GetString("MouseAutoPowerOff", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lift Off Distance. + /// + internal static string MouseLiftOffDistance { + get { + return ResourceManager.GetString("MouseLiftOffDistance", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Low Battery Warning at. + /// + internal static string MouseLowBatteryWarning { + get { + return ResourceManager.GetString("MouseLowBatteryWarning", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Performance. + /// + internal static string MousePerformance { + get { + return ResourceManager.GetString("MousePerformance", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Synchronize with mouse. + /// + internal static string MouseSynchronize { + get { + return ResourceManager.GetString("MouseSynchronize", resourceCulture); + } + } + /// /// Looks up a localized string similar to Multizone. /// @@ -899,6 +1061,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Never. + /// + internal static string Never { + get { + return ResourceManager.GetString("Never", resourceCulture); + } + } + /// /// Looks up a localized string similar to New updates. /// @@ -916,6 +1087,15 @@ namespace GHelper.Properties { return ResourceManager.GetString("NoNewUpdates", resourceCulture); } } + + /// + /// Looks up a localized string similar to Not Connected. + /// + internal static string NotConnected { + get { + return ResourceManager.GetString("NotConnected", resourceCulture); + } + } /// /// Looks up a localized string similar to Open G-Helper window. @@ -980,6 +1160,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Peripherals. + /// + internal static string Peripherals { + get { + return ResourceManager.GetString("Peripherals", resourceCulture); + } + } + /// /// Looks up a localized string similar to Picture / Gif. /// @@ -998,6 +1187,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Polling Rate. + /// + internal static string PollingRate { + get { + return ResourceManager.GetString("PollingRate", resourceCulture); + } + } + /// /// Looks up a localized string similar to Power Limits. /// @@ -1025,6 +1223,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Profile. + /// + internal static string Profile { + get { + return ResourceManager.GetString("Profile", resourceCulture); + } + } + /// /// Looks up a localized string similar to Quit. /// diff --git a/app/Properties/Strings.resx b/app/Properties/Strings.resx index 2675997c..52715934 100644 --- a/app/Properties/Strings.resx +++ b/app/Properties/Strings.resx @@ -162,12 +162,24 @@ Asus Services Running + + Battery State + Breathe + + Clockwise + Color Cycle + + Comet + + + Counterclockwise + Fast @@ -177,6 +189,12 @@ Rainbow + + Random + + + React + Slow @@ -266,6 +284,9 @@ Do you still want to continue? NVIDIA Display Mode is not set to Optimus + + Energy Settings + Extra @@ -332,6 +353,9 @@ Do you still want to continue? Temperature Target + + High + Key Bindings @@ -356,9 +380,15 @@ Do you still want to continue? Lightbar + + Lighting + Logo + + Low + Audio Visualizer @@ -392,18 +422,48 @@ Do you still want to continue? 60Hz refresh rate to save battery + + Minute + + + Minutes + + + Angle Snapping + + + Auto Power Off After + + + Lift Off Distance + + + Low Battery Warning at + + + Performance + + + Synchronize with mouse + Multizone Mute Mic + + Never + New updates No new updates + + Not Connected + Open G-Helper window @@ -425,12 +485,18 @@ Do you still want to continue? Mode + + Peripherals + Picture / Gif Play / Pause + + Polling Rate + Power Limits @@ -440,6 +506,9 @@ Do you still want to continue? PrintScreen + + Profile + Quit diff --git a/app/Resources/icons8-batterie-voll-geladen-48.png b/app/Resources/icons8-batterie-voll-geladen-48.png new file mode 100644 index 00000000..96477f33 Binary files /dev/null and b/app/Resources/icons8-batterie-voll-geladen-48.png differ diff --git a/app/Resources/icons8-ladende-batterie-48.png b/app/Resources/icons8-ladende-batterie-48.png new file mode 100644 index 00000000..a1be3718 Binary files /dev/null and b/app/Resources/icons8-ladende-batterie-48.png differ diff --git a/app/Resources/icons8-maus-32.png b/app/Resources/icons8-maus-32.png new file mode 100644 index 00000000..cd252ce1 Binary files /dev/null and b/app/Resources/icons8-maus-32.png differ diff --git a/app/Resources/icons8-maus-48.png b/app/Resources/icons8-maus-48.png new file mode 100644 index 00000000..1970f46c Binary files /dev/null and b/app/Resources/icons8-maus-48.png differ diff --git a/app/Resources/icons8-mauszeiger-50.png b/app/Resources/icons8-mauszeiger-50.png new file mode 100644 index 00000000..90cbdaa3 Binary files /dev/null and b/app/Resources/icons8-mauszeiger-50.png differ diff --git a/app/Resources/lighting_dot_24.png b/app/Resources/lighting_dot_24.png new file mode 100644 index 00000000..24942616 Binary files /dev/null and b/app/Resources/lighting_dot_24.png differ diff --git a/app/Resources/lighting_dot_32.png b/app/Resources/lighting_dot_32.png new file mode 100644 index 00000000..382ed5f5 Binary files /dev/null and b/app/Resources/lighting_dot_32.png differ diff --git a/app/Resources/lighting_dot_48.png b/app/Resources/lighting_dot_48.png new file mode 100644 index 00000000..1520857e Binary files /dev/null and b/app/Resources/lighting_dot_48.png differ diff --git a/app/Settings.Designer.cs b/app/Settings.Designer.cs index 5393777c..087ecd89 100644 --- a/app/Settings.Designer.cs +++ b/app/Settings.Designer.cs @@ -97,6 +97,14 @@ namespace GHelper labelKeyboard = new Label(); labelVersion = new Label(); panelVersion = new Panel(); + panelPeripherals = new Panel(); + tableLayoutPeripherals = new TableLayoutPanel(); + buttonPeripheral3 = new RButton(); + buttonPeripheral2 = new RButton(); + buttonPeripheral1 = new RButton(); + panelPeripheralsTile = new Panel(); + picturePeripherals = new PictureBox(); + labelPeripherals = new Label(); panelMatrix.SuspendLayout(); tableLayoutMatrix.SuspendLayout(); panelMatrixTitle.SuspendLayout(); @@ -126,6 +134,10 @@ namespace GHelper panelKeyboardTitle.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureKeyboard).BeginInit(); panelVersion.SuspendLayout(); + panelPeripherals.SuspendLayout(); + tableLayoutPeripherals.SuspendLayout(); + panelPeripheralsTile.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)picturePeripherals).BeginInit(); SuspendLayout(); // // panelMatrix @@ -136,11 +148,11 @@ namespace GHelper panelMatrix.Controls.Add(panelMatrixTitle); panelMatrix.Controls.Add(checkMatrix); panelMatrix.Dock = DockStyle.Top; - panelMatrix.Location = new Point(11, 758); + panelMatrix.Location = new Point(8, 568); panelMatrix.Margin = new Padding(0); panelMatrix.Name = "panelMatrix"; - panelMatrix.Padding = new Padding(20, 20, 20, 11); - panelMatrix.Size = new Size(811, 171); + panelMatrix.Padding = new Padding(15, 15, 15, 8); + panelMatrix.Size = new Size(621, 149); panelMatrix.TabIndex = 4; // // tableLayoutMatrix @@ -156,12 +168,12 @@ namespace GHelper tableLayoutMatrix.Controls.Add(comboMatrixRunning, 1, 0); tableLayoutMatrix.Controls.Add(buttonMatrix, 2, 0); tableLayoutMatrix.Dock = DockStyle.Top; - tableLayoutMatrix.Location = new Point(20, 60); - tableLayoutMatrix.Margin = new Padding(8); + tableLayoutMatrix.Location = new Point(15, 45); + tableLayoutMatrix.Margin = new Padding(6); tableLayoutMatrix.Name = "tableLayoutMatrix"; tableLayoutMatrix.RowCount = 1; tableLayoutMatrix.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); - tableLayoutMatrix.Size = new Size(771, 60); + tableLayoutMatrix.Size = new Size(591, 60); tableLayoutMatrix.TabIndex = 43; // // comboMatrix @@ -171,12 +183,12 @@ namespace GHelper comboMatrix.Dock = DockStyle.Top; comboMatrix.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); comboMatrix.FormattingEnabled = true; - comboMatrix.ItemHeight = 32; + comboMatrix.ItemHeight = 25; comboMatrix.Items.AddRange(new object[] { Properties.Strings.MatrixOff, Properties.Strings.MatrixDim, Properties.Strings.MatrixMedium, Properties.Strings.MatrixBright }); - comboMatrix.Location = new Point(4, 11); - comboMatrix.Margin = new Padding(4, 11, 4, 8); + comboMatrix.Location = new Point(3, 8); + comboMatrix.Margin = new Padding(3, 8, 3, 6); comboMatrix.Name = "comboMatrix"; - comboMatrix.Size = new Size(249, 40); + comboMatrix.Size = new Size(191, 33); comboMatrix.TabIndex = 16; // // comboMatrixRunning @@ -186,12 +198,12 @@ namespace GHelper comboMatrixRunning.Dock = DockStyle.Top; comboMatrixRunning.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); comboMatrixRunning.FormattingEnabled = true; - comboMatrixRunning.ItemHeight = 32; + comboMatrixRunning.ItemHeight = 25; comboMatrixRunning.Items.AddRange(new object[] { Properties.Strings.MatrixBanner, Properties.Strings.MatrixLogo, Properties.Strings.MatrixPicture, Properties.Strings.MatrixClock, Properties.Strings.MatrixAudio }); - comboMatrixRunning.Location = new Point(261, 11); - comboMatrixRunning.Margin = new Padding(4, 11, 4, 8); + comboMatrixRunning.Location = new Point(200, 8); + comboMatrixRunning.Margin = new Padding(3, 8, 3, 6); comboMatrixRunning.Name = "comboMatrixRunning"; - comboMatrixRunning.Size = new Size(249, 40); + comboMatrixRunning.Size = new Size(191, 33); comboMatrixRunning.TabIndex = 17; // // buttonMatrix @@ -203,11 +215,11 @@ namespace GHelper buttonMatrix.Dock = DockStyle.Top; buttonMatrix.FlatAppearance.BorderSize = 0; buttonMatrix.FlatStyle = FlatStyle.Flat; - buttonMatrix.Location = new Point(518, 6); + buttonMatrix.Location = new Point(398, 6); buttonMatrix.Margin = new Padding(4, 6, 4, 6); buttonMatrix.Name = "buttonMatrix"; buttonMatrix.Secondary = true; - buttonMatrix.Size = new Size(249, 48); + buttonMatrix.Size = new Size(189, 48); buttonMatrix.TabIndex = 18; buttonMatrix.Text = Properties.Strings.PictureGif; buttonMatrix.UseVisualStyleBackColor = false; @@ -217,20 +229,18 @@ namespace GHelper panelMatrixTitle.Controls.Add(pictureMatrix); panelMatrixTitle.Controls.Add(labelMatrix); panelMatrixTitle.Dock = DockStyle.Top; - panelMatrixTitle.Location = new Point(20, 20); - panelMatrixTitle.Margin = new Padding(4); + panelMatrixTitle.Location = new Point(15, 15); panelMatrixTitle.Name = "panelMatrixTitle"; - panelMatrixTitle.Size = new Size(771, 40); + panelMatrixTitle.Size = new Size(591, 30); panelMatrixTitle.TabIndex = 45; // // pictureMatrix // pictureMatrix.BackgroundImage = Properties.Resources.icons8_matrix_32; pictureMatrix.BackgroundImageLayout = ImageLayout.Zoom; - pictureMatrix.Location = new Point(5, 0); - pictureMatrix.Margin = new Padding(4); + pictureMatrix.Location = new Point(4, 0); pictureMatrix.Name = "pictureMatrix"; - pictureMatrix.Size = new Size(32, 32); + pictureMatrix.Size = new Size(24, 24); pictureMatrix.TabIndex = 41; pictureMatrix.TabStop = false; // @@ -238,10 +248,10 @@ namespace GHelper // labelMatrix.AutoSize = true; labelMatrix.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - labelMatrix.Location = new Point(44, 0); - labelMatrix.Margin = new Padding(8, 0, 8, 0); + labelMatrix.Location = new Point(33, 0); + labelMatrix.Margin = new Padding(6, 0, 6, 0); labelMatrix.Name = "labelMatrix"; - labelMatrix.Size = new Size(170, 32); + labelMatrix.Size = new Size(128, 25); labelMatrix.TabIndex = 40; labelMatrix.Text = "Anime Matrix"; // @@ -249,10 +259,10 @@ namespace GHelper // checkMatrix.AutoSize = true; checkMatrix.ForeColor = SystemColors.GrayText; - checkMatrix.Location = new Point(27, 120); - checkMatrix.Margin = new Padding(8, 4, 8, 4); + checkMatrix.Location = new Point(20, 109); + checkMatrix.Margin = new Padding(6, 3, 6, 3); checkMatrix.Name = "checkMatrix"; - checkMatrix.Size = new Size(249, 36); + checkMatrix.Size = new Size(188, 29); checkMatrix.TabIndex = 19; checkMatrix.Text = Properties.Strings.TurnOffOnBattery; checkMatrix.UseVisualStyleBackColor = true; @@ -264,23 +274,22 @@ namespace GHelper panelBattery.Controls.Add(sliderBattery); panelBattery.Controls.Add(panelBatteryTitle); panelBattery.Dock = DockStyle.Top; - panelBattery.Location = new Point(11, 1069); + panelBattery.Location = new Point(8, 991); panelBattery.Margin = new Padding(0); panelBattery.Name = "panelBattery"; - panelBattery.Padding = new Padding(20, 20, 20, 7); - panelBattery.Size = new Size(811, 111); + panelBattery.Padding = new Padding(15, 15, 15, 5); + panelBattery.Size = new Size(621, 83); panelBattery.TabIndex = 5; // // sliderBattery // sliderBattery.AccessibleName = "Battery Charge Limit"; sliderBattery.Dock = DockStyle.Top; - sliderBattery.Location = new Point(20, 64); - sliderBattery.Margin = new Padding(4); + sliderBattery.Location = new Point(15, 48); sliderBattery.Max = 100; sliderBattery.Min = 40; sliderBattery.Name = "sliderBattery"; - sliderBattery.Size = new Size(771, 40); + sliderBattery.Size = new Size(591, 30); sliderBattery.Step = 5; sliderBattery.TabIndex = 20; sliderBattery.TabStop = false; @@ -293,20 +302,19 @@ namespace GHelper panelBatteryTitle.Controls.Add(pictureBattery); panelBatteryTitle.Controls.Add(labelBatteryTitle); panelBatteryTitle.Dock = DockStyle.Top; - panelBatteryTitle.Location = new Point(20, 20); - panelBatteryTitle.Margin = new Padding(4); + panelBatteryTitle.Location = new Point(15, 15); panelBatteryTitle.Name = "panelBatteryTitle"; - panelBatteryTitle.Padding = new Padding(0, 0, 0, 4); - panelBatteryTitle.Size = new Size(771, 44); + panelBatteryTitle.Padding = new Padding(0, 0, 0, 3); + panelBatteryTitle.Size = new Size(591, 33); panelBatteryTitle.TabIndex = 40; // // labelBattery // labelBattery.Anchor = AnchorStyles.Top | AnchorStyles.Right; - labelBattery.Location = new Point(432, 0); - labelBattery.Margin = new Padding(8, 0, 8, 0); + labelBattery.Location = new Point(337, 0); + labelBattery.Margin = new Padding(6, 0, 6, 0); labelBattery.Name = "labelBattery"; - labelBattery.Size = new Size(324, 36); + labelBattery.Size = new Size(243, 27); labelBattery.TabIndex = 39; labelBattery.Text = " "; labelBattery.TextAlign = ContentAlignment.TopRight; @@ -315,20 +323,19 @@ namespace GHelper // pictureBattery.BackgroundImage = Properties.Resources.icons8_charging_battery_32; pictureBattery.BackgroundImageLayout = ImageLayout.Zoom; - pictureBattery.Location = new Point(4, 2); - pictureBattery.Margin = new Padding(4); + pictureBattery.Location = new Point(3, 2); pictureBattery.Name = "pictureBattery"; - pictureBattery.Size = new Size(32, 32); + pictureBattery.Size = new Size(24, 24); pictureBattery.TabIndex = 38; pictureBattery.TabStop = false; // // labelBatteryTitle // labelBatteryTitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - labelBatteryTitle.Location = new Point(43, 0); - labelBatteryTitle.Margin = new Padding(8, 0, 8, 0); + labelBatteryTitle.Location = new Point(32, 0); + labelBatteryTitle.Margin = new Padding(6, 0, 6, 0); labelBatteryTitle.Name = "labelBatteryTitle"; - labelBatteryTitle.Size = new Size(467, 32); + labelBatteryTitle.Size = new Size(350, 24); labelBatteryTitle.TabIndex = 37; labelBatteryTitle.Text = "Battery Charge Limit"; // @@ -338,11 +345,11 @@ namespace GHelper panelFooter.AutoSizeMode = AutoSizeMode.GrowAndShrink; panelFooter.Controls.Add(tableButtons); panelFooter.Dock = DockStyle.Top; - panelFooter.Location = new Point(11, 1236); + panelFooter.Location = new Point(8, 1116); panelFooter.Margin = new Padding(0); panelFooter.Name = "panelFooter"; panelFooter.Padding = new Padding(20); - panelFooter.Size = new Size(811, 98); + panelFooter.Size = new Size(621, 98); panelFooter.TabIndex = 7; // // tableButtons @@ -360,7 +367,7 @@ namespace GHelper tableButtons.Name = "tableButtons"; tableButtons.RowCount = 1; tableButtons.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); - tableButtons.Size = new Size(771, 58); + tableButtons.Size = new Size(581, 58); tableButtons.TabIndex = 25; // // buttonUpdates @@ -378,7 +385,7 @@ namespace GHelper buttonUpdates.Margin = new Padding(4); buttonUpdates.Name = "buttonUpdates"; buttonUpdates.Secondary = true; - buttonUpdates.Size = new Size(248, 50); + buttonUpdates.Size = new Size(185, 50); buttonUpdates.TabIndex = 24; buttonUpdates.Text = "Updates"; buttonUpdates.TextImageRelation = TextImageRelation.ImageBeforeText; @@ -394,11 +401,11 @@ namespace GHelper buttonQuit.Dock = DockStyle.Top; buttonQuit.FlatStyle = FlatStyle.Flat; buttonQuit.Image = Properties.Resources.icons8_quit_32; - buttonQuit.Location = new Point(516, 4); + buttonQuit.Location = new Point(390, 4); buttonQuit.Margin = new Padding(4); buttonQuit.Name = "buttonQuit"; buttonQuit.Secondary = true; - buttonQuit.Size = new Size(251, 50); + buttonQuit.Size = new Size(187, 50); buttonQuit.TabIndex = 23; buttonQuit.Text = "Quit"; buttonQuit.TextAlign = ContentAlignment.MiddleRight; @@ -408,10 +415,10 @@ namespace GHelper // checkStartup // checkStartup.AutoSize = true; - checkStartup.Location = new Point(27, 12); + checkStartup.Location = new Point(27, 8); checkStartup.Margin = new Padding(8, 4, 8, 4); checkStartup.Name = "checkStartup"; - checkStartup.Size = new Size(206, 36); + checkStartup.Size = new Size(157, 29); checkStartup.TabIndex = 21; checkStartup.Text = Properties.Strings.RunOnStartup; checkStartup.UseVisualStyleBackColor = true; @@ -423,11 +430,11 @@ namespace GHelper panelPerformance.Controls.Add(tablePerf); panelPerformance.Controls.Add(panelCPUTitle); panelPerformance.Dock = DockStyle.Top; - panelPerformance.Location = new Point(11, 11); + panelPerformance.Location = new Point(8, 8); panelPerformance.Margin = new Padding(0); panelPerformance.Name = "panelPerformance"; - panelPerformance.Padding = new Padding(20); - panelPerformance.Size = new Size(811, 208); + panelPerformance.Padding = new Padding(15); + panelPerformance.Size = new Size(621, 156); panelPerformance.TabIndex = 0; // // tablePerf @@ -444,12 +451,12 @@ namespace GHelper tablePerf.Controls.Add(buttonTurbo, 2, 0); tablePerf.Controls.Add(buttonFans, 3, 0); tablePerf.Dock = DockStyle.Top; - tablePerf.Location = new Point(20, 60); - tablePerf.Margin = new Padding(8, 4, 8, 4); + tablePerf.Location = new Point(15, 45); + tablePerf.Margin = new Padding(6, 3, 6, 3); tablePerf.Name = "tablePerf"; tablePerf.RowCount = 1; - tablePerf.RowStyles.Add(new RowStyle(SizeType.Absolute, 128F)); - tablePerf.Size = new Size(771, 128); + tablePerf.RowStyles.Add(new RowStyle(SizeType.Absolute, 96F)); + tablePerf.Size = new Size(591, 96); tablePerf.TabIndex = 29; // // buttonSilent @@ -466,11 +473,10 @@ namespace GHelper buttonSilent.ForeColor = SystemColors.ControlText; buttonSilent.Image = Properties.Resources.icons8_bicycle_48__1_; buttonSilent.ImageAlign = ContentAlignment.BottomCenter; - buttonSilent.Location = new Point(4, 4); - buttonSilent.Margin = new Padding(4); + buttonSilent.Location = new Point(3, 3); buttonSilent.Name = "buttonSilent"; buttonSilent.Secondary = false; - buttonSilent.Size = new Size(184, 120); + buttonSilent.Size = new Size(141, 90); buttonSilent.TabIndex = 1; buttonSilent.Text = Properties.Strings.Silent; buttonSilent.TextImageRelation = TextImageRelation.ImageAboveText; @@ -489,11 +495,10 @@ namespace GHelper buttonBalanced.ForeColor = SystemColors.ControlText; buttonBalanced.Image = Properties.Resources.icons8_fiat_500_48; buttonBalanced.ImageAlign = ContentAlignment.BottomCenter; - buttonBalanced.Location = new Point(196, 4); - buttonBalanced.Margin = new Padding(4); + buttonBalanced.Location = new Point(150, 3); buttonBalanced.Name = "buttonBalanced"; buttonBalanced.Secondary = false; - buttonBalanced.Size = new Size(184, 120); + buttonBalanced.Size = new Size(141, 90); buttonBalanced.TabIndex = 1; buttonBalanced.Text = Properties.Strings.Balanced; buttonBalanced.TextImageRelation = TextImageRelation.ImageAboveText; @@ -512,11 +517,10 @@ namespace GHelper buttonTurbo.ForeColor = SystemColors.ControlText; buttonTurbo.Image = Properties.Resources.icons8_rocket_48; buttonTurbo.ImageAlign = ContentAlignment.BottomCenter; - buttonTurbo.Location = new Point(388, 4); - buttonTurbo.Margin = new Padding(4); + buttonTurbo.Location = new Point(297, 3); buttonTurbo.Name = "buttonTurbo"; buttonTurbo.Secondary = false; - buttonTurbo.Size = new Size(184, 120); + buttonTurbo.Size = new Size(141, 90); buttonTurbo.TabIndex = 2; buttonTurbo.Text = Properties.Strings.Turbo; buttonTurbo.TextImageRelation = TextImageRelation.ImageAboveText; @@ -534,11 +538,10 @@ namespace GHelper buttonFans.FlatStyle = FlatStyle.Flat; buttonFans.Image = Properties.Resources.icons8_fan_48; buttonFans.ImageAlign = ContentAlignment.BottomCenter; - buttonFans.Location = new Point(580, 4); - buttonFans.Margin = new Padding(4); + buttonFans.Location = new Point(444, 3); buttonFans.Name = "buttonFans"; buttonFans.Secondary = true; - buttonFans.Size = new Size(187, 120); + buttonFans.Size = new Size(144, 90); buttonFans.TabIndex = 3; buttonFans.Text = Properties.Strings.FansPower; buttonFans.TextImageRelation = TextImageRelation.ImageAboveText; @@ -550,10 +553,9 @@ namespace GHelper panelCPUTitle.Controls.Add(labelPerf); panelCPUTitle.Controls.Add(labelCPUFan); panelCPUTitle.Dock = DockStyle.Top; - panelCPUTitle.Location = new Point(20, 20); - panelCPUTitle.Margin = new Padding(4); + panelCPUTitle.Location = new Point(15, 15); panelCPUTitle.Name = "panelCPUTitle"; - panelCPUTitle.Size = new Size(771, 40); + panelCPUTitle.Size = new Size(591, 30); panelCPUTitle.TabIndex = 30; // // picturePerf @@ -561,10 +563,9 @@ namespace GHelper picturePerf.BackgroundImage = Properties.Resources.icons8_gauge_32; picturePerf.BackgroundImageLayout = ImageLayout.Zoom; picturePerf.InitialImage = null; - picturePerf.Location = new Point(8, 0); - picturePerf.Margin = new Padding(4); + picturePerf.Location = new Point(6, 0); picturePerf.Name = "picturePerf"; - picturePerf.Size = new Size(32, 32); + picturePerf.Size = new Size(24, 24); picturePerf.TabIndex = 35; picturePerf.TabStop = false; // @@ -572,10 +573,10 @@ namespace GHelper // labelPerf.AutoSize = true; labelPerf.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - labelPerf.Location = new Point(40, 0); - labelPerf.Margin = new Padding(8, 0, 8, 0); + labelPerf.Location = new Point(30, 0); + labelPerf.Margin = new Padding(6, 0, 6, 0); labelPerf.Name = "labelPerf"; - labelPerf.Size = new Size(234, 32); + labelPerf.Size = new Size(174, 25); labelPerf.TabIndex = 0; labelPerf.Text = "Performance Mode"; // @@ -583,10 +584,10 @@ namespace GHelper // labelCPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right; labelCPUFan.Cursor = Cursors.Hand; - labelCPUFan.Location = new Point(371, 0); - labelCPUFan.Margin = new Padding(8, 0, 8, 0); + labelCPUFan.Location = new Point(291, 0); + labelCPUFan.Margin = new Padding(6, 0, 6, 0); labelCPUFan.Name = "labelCPUFan"; - labelCPUFan.Size = new Size(400, 36); + labelCPUFan.Size = new Size(300, 27); labelCPUFan.TabIndex = 33; labelCPUFan.Text = " "; labelCPUFan.TextAlign = ContentAlignment.TopRight; @@ -599,21 +600,20 @@ namespace GHelper panelGPU.Controls.Add(tableGPU); panelGPU.Controls.Add(panelGPUTitle); panelGPU.Dock = DockStyle.Top; - panelGPU.Location = new Point(11, 219); + panelGPU.Location = new Point(8, 164); panelGPU.Margin = new Padding(0); panelGPU.Name = "panelGPU"; - panelGPU.Padding = new Padding(20, 20, 20, 0); - panelGPU.Size = new Size(811, 352); + panelGPU.Padding = new Padding(15, 15, 15, 0); + panelGPU.Size = new Size(621, 264); panelGPU.TabIndex = 1; // // labelTipGPU // labelTipGPU.Dock = DockStyle.Top; labelTipGPU.ForeColor = SystemColors.GrayText; - labelTipGPU.Location = new Point(20, 316); - labelTipGPU.Margin = new Padding(4, 0, 4, 0); + labelTipGPU.Location = new Point(15, 237); labelTipGPU.Name = "labelTipGPU"; - labelTipGPU.Size = new Size(771, 36); + labelTipGPU.Size = new Size(591, 27); labelTipGPU.TabIndex = 20; // // tableGPU @@ -632,13 +632,13 @@ namespace GHelper tableGPU.Controls.Add(buttonOptimized, 2, 0); tableGPU.Controls.Add(buttonUltimate, 2, 0); tableGPU.Dock = DockStyle.Top; - tableGPU.Location = new Point(20, 60); - tableGPU.Margin = new Padding(8, 4, 8, 4); + tableGPU.Location = new Point(15, 45); + tableGPU.Margin = new Padding(6, 3, 6, 3); tableGPU.Name = "tableGPU"; tableGPU.RowCount = 1; - tableGPU.RowStyles.Add(new RowStyle(SizeType.Absolute, 128F)); - tableGPU.RowStyles.Add(new RowStyle(SizeType.Absolute, 128F)); - tableGPU.Size = new Size(771, 256); + tableGPU.RowStyles.Add(new RowStyle(SizeType.Absolute, 96F)); + tableGPU.RowStyles.Add(new RowStyle(SizeType.Absolute, 96F)); + tableGPU.Size = new Size(591, 192); tableGPU.TabIndex = 16; // // buttonStopGPU @@ -654,11 +654,10 @@ namespace GHelper buttonStopGPU.ForeColor = SystemColors.ControlText; buttonStopGPU.Image = Properties.Resources.icons8_leaf_48; buttonStopGPU.ImageAlign = ContentAlignment.BottomCenter; - buttonStopGPU.Location = new Point(196, 4); - buttonStopGPU.Margin = new Padding(4); + buttonStopGPU.Location = new Point(150, 3); buttonStopGPU.Name = "buttonStopGPU"; buttonStopGPU.Secondary = false; - buttonStopGPU.Size = new Size(184, 120); + buttonStopGPU.Size = new Size(141, 90); buttonStopGPU.TabIndex = 4; buttonStopGPU.Text = "Stop GPU applications"; buttonStopGPU.TextImageRelation = TextImageRelation.ImageAboveText; @@ -679,11 +678,10 @@ namespace GHelper buttonEco.ForeColor = SystemColors.ControlText; buttonEco.Image = Properties.Resources.icons8_leaf_48; buttonEco.ImageAlign = ContentAlignment.BottomCenter; - buttonEco.Location = new Point(4, 4); - buttonEco.Margin = new Padding(4); + buttonEco.Location = new Point(3, 3); buttonEco.Name = "buttonEco"; buttonEco.Secondary = false; - buttonEco.Size = new Size(184, 120); + buttonEco.Size = new Size(141, 90); buttonEco.TabIndex = 4; buttonEco.Text = Properties.Strings.EcoMode; buttonEco.TextImageRelation = TextImageRelation.ImageAboveText; @@ -702,11 +700,10 @@ namespace GHelper buttonStandard.ForeColor = SystemColors.ControlText; buttonStandard.Image = Properties.Resources.icons8_spa_flower_48; buttonStandard.ImageAlign = ContentAlignment.BottomCenter; - buttonStandard.Location = new Point(388, 4); - buttonStandard.Margin = new Padding(4); + buttonStandard.Location = new Point(297, 3); buttonStandard.Name = "buttonStandard"; buttonStandard.Secondary = false; - buttonStandard.Size = new Size(184, 120); + buttonStandard.Size = new Size(141, 90); buttonStandard.TabIndex = 5; buttonStandard.Text = Properties.Strings.StandardMode; buttonStandard.TextImageRelation = TextImageRelation.ImageAboveText; @@ -724,11 +721,10 @@ namespace GHelper buttonXGM.ForeColor = SystemColors.ControlText; buttonXGM.Image = Properties.Resources.icons8_video_48; buttonXGM.ImageAlign = ContentAlignment.BottomCenter; - buttonXGM.Location = new Point(196, 132); - buttonXGM.Margin = new Padding(4); + buttonXGM.Location = new Point(150, 99); buttonXGM.Name = "buttonXGM"; buttonXGM.Secondary = false; - buttonXGM.Size = new Size(184, 120); + buttonXGM.Size = new Size(141, 90); buttonXGM.TabIndex = 8; buttonXGM.Text = "XG Mobile"; buttonXGM.TextImageRelation = TextImageRelation.ImageAboveText; @@ -747,11 +743,10 @@ namespace GHelper buttonOptimized.ForeColor = SystemColors.ControlText; buttonOptimized.Image = Properties.Resources.icons8_project_management_48__1_; buttonOptimized.ImageAlign = ContentAlignment.BottomCenter; - buttonOptimized.Location = new Point(4, 132); - buttonOptimized.Margin = new Padding(4); + buttonOptimized.Location = new Point(3, 99); buttonOptimized.Name = "buttonOptimized"; buttonOptimized.Secondary = false; - buttonOptimized.Size = new Size(184, 120); + buttonOptimized.Size = new Size(141, 90); buttonOptimized.TabIndex = 7; buttonOptimized.Text = Properties.Strings.Optimized; buttonOptimized.TextImageRelation = TextImageRelation.ImageAboveText; @@ -770,11 +765,10 @@ namespace GHelper buttonUltimate.ForeColor = SystemColors.ControlText; buttonUltimate.Image = Properties.Resources.icons8_game_controller_48; buttonUltimate.ImageAlign = ContentAlignment.BottomCenter; - buttonUltimate.Location = new Point(580, 4); - buttonUltimate.Margin = new Padding(4); + buttonUltimate.Location = new Point(444, 3); buttonUltimate.Name = "buttonUltimate"; buttonUltimate.Secondary = false; - buttonUltimate.Size = new Size(187, 120); + buttonUltimate.Size = new Size(144, 90); buttonUltimate.TabIndex = 6; buttonUltimate.Text = Properties.Strings.UltimateMode; buttonUltimate.TextImageRelation = TextImageRelation.ImageAboveText; @@ -786,20 +780,18 @@ namespace GHelper panelGPUTitle.Controls.Add(labelGPU); panelGPUTitle.Controls.Add(labelGPUFan); panelGPUTitle.Dock = DockStyle.Top; - panelGPUTitle.Location = new Point(20, 20); - panelGPUTitle.Margin = new Padding(4); + panelGPUTitle.Location = new Point(15, 15); panelGPUTitle.Name = "panelGPUTitle"; - panelGPUTitle.Size = new Size(771, 40); + panelGPUTitle.Size = new Size(591, 30); panelGPUTitle.TabIndex = 21; // // pictureGPU // pictureGPU.BackgroundImage = Properties.Resources.icons8_video_card_32; pictureGPU.BackgroundImageLayout = ImageLayout.Zoom; - pictureGPU.Location = new Point(8, 0); - pictureGPU.Margin = new Padding(4); + pictureGPU.Location = new Point(6, 0); pictureGPU.Name = "pictureGPU"; - pictureGPU.Size = new Size(32, 32); + pictureGPU.Size = new Size(24, 24); pictureGPU.TabIndex = 22; pictureGPU.TabStop = false; // @@ -807,20 +799,20 @@ namespace GHelper // labelGPU.AutoSize = true; labelGPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - labelGPU.Location = new Point(40, 0); - labelGPU.Margin = new Padding(8, 0, 8, 0); + labelGPU.Location = new Point(30, 0); + labelGPU.Margin = new Padding(6, 0, 6, 0); labelGPU.Name = "labelGPU"; - labelGPU.Size = new Size(136, 32); + labelGPU.Size = new Size(103, 25); labelGPU.TabIndex = 21; labelGPU.Text = "GPU Mode"; // // labelGPUFan // labelGPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right; - labelGPUFan.Location = new Point(371, 0); - labelGPUFan.Margin = new Padding(8, 0, 8, 0); + labelGPUFan.Location = new Point(291, 0); + labelGPUFan.Margin = new Padding(6, 0, 6, 0); labelGPUFan.Name = "labelGPUFan"; - labelGPUFan.Size = new Size(400, 35); + labelGPUFan.Size = new Size(300, 26); labelGPUFan.TabIndex = 20; labelGPUFan.Text = " "; labelGPUFan.TextAlign = ContentAlignment.TopRight; @@ -833,21 +825,20 @@ namespace GHelper panelScreen.Controls.Add(tableScreen); panelScreen.Controls.Add(panelScreenTitle); panelScreen.Dock = DockStyle.Top; - panelScreen.Location = new Point(11, 571); + panelScreen.Location = new Point(8, 428); panelScreen.Margin = new Padding(0); panelScreen.Name = "panelScreen"; - panelScreen.Padding = new Padding(20, 20, 20, 11); - panelScreen.Size = new Size(811, 187); + panelScreen.Padding = new Padding(15, 15, 15, 8); + panelScreen.Size = new Size(621, 140); panelScreen.TabIndex = 2; // // labelTipScreen // labelTipScreen.Dock = DockStyle.Top; labelTipScreen.ForeColor = SystemColors.GrayText; - labelTipScreen.Location = new Point(20, 140); - labelTipScreen.Margin = new Padding(4, 0, 4, 0); + labelTipScreen.Location = new Point(15, 105); labelTipScreen.Name = "labelTipScreen"; - labelTipScreen.Size = new Size(771, 36); + labelTipScreen.Size = new Size(591, 27); labelTipScreen.TabIndex = 24; // // tableScreen @@ -864,12 +855,12 @@ namespace GHelper tableScreen.Controls.Add(button120Hz, 2, 0); tableScreen.Controls.Add(buttonMiniled, 3, 0); tableScreen.Dock = DockStyle.Top; - tableScreen.Location = new Point(20, 60); - tableScreen.Margin = new Padding(8, 4, 8, 4); + tableScreen.Location = new Point(15, 45); + tableScreen.Margin = new Padding(6, 3, 6, 3); tableScreen.Name = "tableScreen"; tableScreen.RowCount = 1; - tableScreen.RowStyles.Add(new RowStyle(SizeType.Absolute, 80F)); - tableScreen.Size = new Size(771, 80); + tableScreen.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F)); + tableScreen.Size = new Size(591, 60); tableScreen.TabIndex = 23; // // buttonScreenAuto @@ -883,11 +874,10 @@ namespace GHelper buttonScreenAuto.FlatAppearance.BorderSize = 0; buttonScreenAuto.FlatStyle = FlatStyle.Flat; buttonScreenAuto.ForeColor = SystemColors.ControlText; - buttonScreenAuto.Location = new Point(4, 4); - buttonScreenAuto.Margin = new Padding(4); + buttonScreenAuto.Location = new Point(3, 3); buttonScreenAuto.Name = "buttonScreenAuto"; buttonScreenAuto.Secondary = false; - buttonScreenAuto.Size = new Size(184, 72); + buttonScreenAuto.Size = new Size(141, 54); buttonScreenAuto.TabIndex = 9; buttonScreenAuto.Text = Properties.Strings.AutoMode; buttonScreenAuto.UseVisualStyleBackColor = false; @@ -904,11 +894,10 @@ namespace GHelper button60Hz.FlatAppearance.BorderSize = 0; button60Hz.FlatStyle = FlatStyle.Flat; button60Hz.ForeColor = SystemColors.ControlText; - button60Hz.Location = new Point(196, 4); - button60Hz.Margin = new Padding(4); + button60Hz.Location = new Point(150, 3); button60Hz.Name = "button60Hz"; button60Hz.Secondary = false; - button60Hz.Size = new Size(184, 72); + button60Hz.Size = new Size(141, 54); button60Hz.TabIndex = 10; button60Hz.Text = "60Hz"; button60Hz.UseVisualStyleBackColor = false; @@ -924,11 +913,10 @@ namespace GHelper button120Hz.FlatAppearance.BorderSize = 0; button120Hz.FlatStyle = FlatStyle.Flat; button120Hz.ForeColor = SystemColors.ControlText; - button120Hz.Location = new Point(388, 4); - button120Hz.Margin = new Padding(4); + button120Hz.Location = new Point(297, 3); button120Hz.Name = "button120Hz"; button120Hz.Secondary = false; - button120Hz.Size = new Size(184, 72); + button120Hz.Size = new Size(141, 54); button120Hz.TabIndex = 11; button120Hz.Text = "120Hz + OD"; button120Hz.UseVisualStyleBackColor = false; @@ -944,11 +932,10 @@ namespace GHelper buttonMiniled.FlatAppearance.BorderSize = 0; buttonMiniled.FlatStyle = FlatStyle.Flat; buttonMiniled.ForeColor = SystemColors.ControlText; - buttonMiniled.Location = new Point(580, 4); - buttonMiniled.Margin = new Padding(4); + buttonMiniled.Location = new Point(444, 3); buttonMiniled.Name = "buttonMiniled"; buttonMiniled.Secondary = false; - buttonMiniled.Size = new Size(187, 72); + buttonMiniled.Size = new Size(144, 54); buttonMiniled.TabIndex = 12; buttonMiniled.Text = Properties.Strings.Multizone; buttonMiniled.UseVisualStyleBackColor = false; @@ -959,19 +946,18 @@ namespace GHelper panelScreenTitle.Controls.Add(pictureScreen); panelScreenTitle.Controls.Add(labelSreen); panelScreenTitle.Dock = DockStyle.Top; - panelScreenTitle.Location = new Point(20, 20); - panelScreenTitle.Margin = new Padding(4); + panelScreenTitle.Location = new Point(15, 15); panelScreenTitle.Name = "panelScreenTitle"; - panelScreenTitle.Size = new Size(771, 40); + panelScreenTitle.Size = new Size(591, 30); panelScreenTitle.TabIndex = 25; // // labelMidFan // labelMidFan.Anchor = AnchorStyles.Top | AnchorStyles.Right; - labelMidFan.Location = new Point(516, -3); - labelMidFan.Margin = new Padding(8, 0, 8, 0); + labelMidFan.Location = new Point(400, -2); + labelMidFan.Margin = new Padding(6, 0, 6, 0); labelMidFan.Name = "labelMidFan"; - labelMidFan.Size = new Size(253, 35); + labelMidFan.Size = new Size(190, 26); labelMidFan.TabIndex = 28; labelMidFan.Text = " "; labelMidFan.TextAlign = ContentAlignment.TopRight; @@ -980,10 +966,9 @@ namespace GHelper // pictureScreen.BackgroundImage = Properties.Resources.icons8_laptop_32; pictureScreen.BackgroundImageLayout = ImageLayout.Zoom; - pictureScreen.Location = new Point(5, 0); - pictureScreen.Margin = new Padding(4); + pictureScreen.Location = new Point(4, 0); pictureScreen.Name = "pictureScreen"; - pictureScreen.Size = new Size(32, 32); + pictureScreen.Size = new Size(24, 24); pictureScreen.TabIndex = 27; pictureScreen.TabStop = false; // @@ -991,10 +976,10 @@ namespace GHelper // labelSreen.AutoSize = true; labelSreen.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - labelSreen.Location = new Point(40, 0); - labelSreen.Margin = new Padding(8, 0, 8, 0); + labelSreen.Location = new Point(30, 0); + labelSreen.Margin = new Padding(6, 0, 6, 0); labelSreen.Name = "labelSreen"; - labelSreen.Size = new Size(176, 32); + labelSreen.Size = new Size(133, 25); labelSreen.TabIndex = 26; labelSreen.Text = "Laptop Screen"; // @@ -1005,11 +990,11 @@ namespace GHelper panelKeyboard.Controls.Add(tableLayoutKeyboard); panelKeyboard.Controls.Add(panelKeyboardTitle); panelKeyboard.Dock = DockStyle.Top; - panelKeyboard.Location = new Point(11, 929); + panelKeyboard.Location = new Point(8, 717); panelKeyboard.Margin = new Padding(0); panelKeyboard.Name = "panelKeyboard"; - panelKeyboard.Padding = new Padding(20); - panelKeyboard.Size = new Size(811, 140); + panelKeyboard.Padding = new Padding(15); + panelKeyboard.Size = new Size(621, 120); panelKeyboard.TabIndex = 3; // // tableLayoutKeyboard @@ -1024,12 +1009,12 @@ namespace GHelper tableLayoutKeyboard.Controls.Add(panelColor, 0, 0); tableLayoutKeyboard.Controls.Add(comboKeyboard, 0, 0); tableLayoutKeyboard.Dock = DockStyle.Top; - tableLayoutKeyboard.Location = new Point(20, 60); - tableLayoutKeyboard.Margin = new Padding(8); + tableLayoutKeyboard.Location = new Point(15, 45); + tableLayoutKeyboard.Margin = new Padding(6); tableLayoutKeyboard.Name = "tableLayoutKeyboard"; tableLayoutKeyboard.RowCount = 1; tableLayoutKeyboard.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); - tableLayoutKeyboard.Size = new Size(771, 60); + tableLayoutKeyboard.Size = new Size(591, 60); tableLayoutKeyboard.TabIndex = 39; // // buttonKeyboard @@ -1044,11 +1029,11 @@ namespace GHelper buttonKeyboard.FlatStyle = FlatStyle.Flat; buttonKeyboard.Image = Properties.Resources.icons8_settings_32; buttonKeyboard.ImageAlign = ContentAlignment.MiddleRight; - buttonKeyboard.Location = new Point(518, 6); + buttonKeyboard.Location = new Point(398, 6); buttonKeyboard.Margin = new Padding(4, 6, 4, 6); buttonKeyboard.Name = "buttonKeyboard"; buttonKeyboard.Secondary = true; - buttonKeyboard.Size = new Size(249, 48); + buttonKeyboard.Size = new Size(189, 48); buttonKeyboard.TabIndex = 37; buttonKeyboard.Text = Properties.Strings.Extra; buttonKeyboard.TextImageRelation = TextImageRelation.ImageBeforeText; @@ -1061,29 +1046,29 @@ namespace GHelper panelColor.Controls.Add(pictureColor); panelColor.Controls.Add(buttonKeyboardColor); panelColor.Dock = DockStyle.Fill; - panelColor.Location = new Point(261, 6); + panelColor.Location = new Point(201, 6); panelColor.Margin = new Padding(4, 6, 4, 6); panelColor.Name = "panelColor"; - panelColor.Size = new Size(249, 48); + panelColor.Size = new Size(189, 48); panelColor.TabIndex = 36; // // pictureColor2 // pictureColor2.Anchor = AnchorStyles.Top | AnchorStyles.Right; - pictureColor2.Location = new Point(189, 12); - pictureColor2.Margin = new Padding(8); + pictureColor2.Location = new Point(136, 20); + pictureColor2.Margin = new Padding(6); pictureColor2.Name = "pictureColor2"; - pictureColor2.Size = new Size(20, 20); + pictureColor2.Size = new Size(15, 15); pictureColor2.TabIndex = 41; pictureColor2.TabStop = false; // // pictureColor // pictureColor.Anchor = AnchorStyles.Top | AnchorStyles.Right; - pictureColor.Location = new Point(214, 12); - pictureColor.Margin = new Padding(8); + pictureColor.Location = new Point(154, 20); + pictureColor.Margin = new Padding(6); pictureColor.Name = "pictureColor"; - pictureColor.Size = new Size(20, 20); + pictureColor.Size = new Size(15, 15); pictureColor.TabIndex = 40; pictureColor.TabStop = false; // @@ -1101,7 +1086,7 @@ namespace GHelper buttonKeyboardColor.Margin = new Padding(4); buttonKeyboardColor.Name = "buttonKeyboardColor"; buttonKeyboardColor.Secondary = false; - buttonKeyboardColor.Size = new Size(249, 48); + buttonKeyboardColor.Size = new Size(189, 48); buttonKeyboardColor.TabIndex = 14; buttonKeyboardColor.Text = Properties.Strings.Color; buttonKeyboardColor.UseVisualStyleBackColor = false; @@ -1115,12 +1100,12 @@ namespace GHelper comboKeyboard.FlatStyle = FlatStyle.Flat; comboKeyboard.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); comboKeyboard.FormattingEnabled = true; - comboKeyboard.ItemHeight = 32; + comboKeyboard.ItemHeight = 25; comboKeyboard.Items.AddRange(new object[] { "Static", "Breathe", "Rainbow", "Strobe" }); - comboKeyboard.Location = new Point(4, 11); - comboKeyboard.Margin = new Padding(4, 11, 4, 8); + comboKeyboard.Location = new Point(3, 8); + comboKeyboard.Margin = new Padding(3, 8, 3, 6); comboKeyboard.Name = "comboKeyboard"; - comboKeyboard.Size = new Size(249, 40); + comboKeyboard.Size = new Size(191, 33); comboKeyboard.TabIndex = 13; // // panelKeyboardTitle @@ -1128,20 +1113,18 @@ namespace GHelper panelKeyboardTitle.Controls.Add(pictureKeyboard); panelKeyboardTitle.Controls.Add(labelKeyboard); panelKeyboardTitle.Dock = DockStyle.Top; - panelKeyboardTitle.Location = new Point(20, 20); - panelKeyboardTitle.Margin = new Padding(4); + panelKeyboardTitle.Location = new Point(15, 15); panelKeyboardTitle.Name = "panelKeyboardTitle"; - panelKeyboardTitle.Size = new Size(771, 40); + panelKeyboardTitle.Size = new Size(591, 30); panelKeyboardTitle.TabIndex = 40; // // pictureKeyboard // pictureKeyboard.BackgroundImage = Properties.Resources.icons8_keyboard_32__1_; pictureKeyboard.BackgroundImageLayout = ImageLayout.Zoom; - pictureKeyboard.Location = new Point(5, 0); - pictureKeyboard.Margin = new Padding(4); + pictureKeyboard.Location = new Point(4, 0); pictureKeyboard.Name = "pictureKeyboard"; - pictureKeyboard.Size = new Size(32, 32); + pictureKeyboard.Size = new Size(24, 24); pictureKeyboard.TabIndex = 35; pictureKeyboard.TabStop = false; // @@ -1149,10 +1132,10 @@ namespace GHelper // labelKeyboard.AutoSize = true; labelKeyboard.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - labelKeyboard.Location = new Point(44, 0); - labelKeyboard.Margin = new Padding(8, 0, 8, 0); + labelKeyboard.Location = new Point(33, 0); + labelKeyboard.Margin = new Padding(6, 0, 6, 0); labelKeyboard.Name = "labelKeyboard"; - labelKeyboard.Size = new Size(210, 32); + labelKeyboard.Size = new Size(158, 25); labelKeyboard.TabIndex = 34; labelKeyboard.Text = "Laptop Keyboard"; // @@ -1162,10 +1145,10 @@ namespace GHelper labelVersion.Cursor = Cursors.Hand; labelVersion.Font = new Font("Segoe UI", 9F, FontStyle.Underline, GraphicsUnit.Point); labelVersion.ForeColor = SystemColors.ControlDark; - labelVersion.Location = new Point(487, 12); + labelVersion.Location = new Point(396, 12); labelVersion.Margin = new Padding(8, 0, 8, 0); labelVersion.Name = "labelVersion"; - labelVersion.Size = new Size(300, 32); + labelVersion.Size = new Size(225, 24); labelVersion.TabIndex = 37; labelVersion.Text = "v.0"; labelVersion.TextAlign = ContentAlignment.TopRight; @@ -1175,34 +1158,172 @@ namespace GHelper panelVersion.Controls.Add(labelVersion); panelVersion.Controls.Add(checkStartup); panelVersion.Dock = DockStyle.Top; - panelVersion.Location = new Point(11, 1180); - panelVersion.Margin = new Padding(4); + panelVersion.Location = new Point(8, 1074); panelVersion.Name = "panelVersion"; - panelVersion.Size = new Size(811, 56); + panelVersion.Size = new Size(621, 42); panelVersion.TabIndex = 6; // + // panelPeripherals + // + panelPeripherals.AutoSize = true; + panelPeripherals.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelPeripherals.Controls.Add(tableLayoutPeripherals); + panelPeripherals.Controls.Add(panelPeripheralsTile); + panelPeripherals.Dock = DockStyle.Top; + panelPeripherals.Location = new Point(8, 837); + panelPeripherals.Margin = new Padding(0); + panelPeripherals.Name = "panelPeripherals"; + panelPeripherals.Padding = new Padding(15, 15, 15, 8); + panelPeripherals.Size = new Size(621, 154); + panelPeripherals.TabIndex = 4; + // + // tableLayoutPeripherals + // + tableLayoutPeripherals.AutoSize = true; + tableLayoutPeripherals.AutoSizeMode = AutoSizeMode.GrowAndShrink; + tableLayoutPeripherals.ColumnCount = 3; + tableLayoutPeripherals.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableLayoutPeripherals.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableLayoutPeripherals.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableLayoutPeripherals.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableLayoutPeripherals.Controls.Add(buttonPeripheral3, 0, 0); + tableLayoutPeripherals.Controls.Add(buttonPeripheral2, 0, 0); + tableLayoutPeripherals.Controls.Add(buttonPeripheral1, 0, 0); + tableLayoutPeripherals.Dock = DockStyle.Top; + tableLayoutPeripherals.Location = new Point(15, 45); + tableLayoutPeripherals.Margin = new Padding(6); + tableLayoutPeripherals.Name = "tableLayoutPeripherals"; + tableLayoutPeripherals.RowCount = 1; + tableLayoutPeripherals.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + tableLayoutPeripherals.Size = new Size(591, 101); + tableLayoutPeripherals.TabIndex = 43; + // + // buttonPeripheral3 + // + buttonPeripheral3.AccessibleName = "Peripheral 3"; + buttonPeripheral3.Activated = false; + buttonPeripheral3.BackColor = SystemColors.ControlLightLight; + buttonPeripheral3.BorderColor = Color.Transparent; + buttonPeripheral3.BorderRadius = 5; + buttonPeripheral3.CausesValidation = false; + buttonPeripheral3.Dock = DockStyle.Top; + buttonPeripheral3.FlatAppearance.BorderSize = 0; + buttonPeripheral3.FlatStyle = FlatStyle.Flat; + buttonPeripheral3.Font = new Font("Segoe UI", 8F, FontStyle.Regular, GraphicsUnit.Point); + buttonPeripheral3.ForeColor = SystemColors.ControlText; + buttonPeripheral3.Image = Properties.Resources.icons8_maus_48; + buttonPeripheral3.ImageAlign = ContentAlignment.MiddleLeft; + buttonPeripheral3.Location = new Point(397, 3); + buttonPeripheral3.Name = "buttonPeripheral3"; + buttonPeripheral3.Secondary = false; + buttonPeripheral3.Size = new Size(191, 95); + buttonPeripheral3.TabIndex = 22; + buttonPeripheral3.Text = "Mouse 3"; + buttonPeripheral3.TextImageRelation = TextImageRelation.ImageBeforeText; + buttonPeripheral3.UseVisualStyleBackColor = false; + // + // buttonPeripheral2 + // + buttonPeripheral2.AccessibleName = "Peripheral 2"; + buttonPeripheral2.Activated = false; + buttonPeripheral2.BackColor = SystemColors.ControlLightLight; + buttonPeripheral2.BorderColor = Color.Transparent; + buttonPeripheral2.BorderRadius = 5; + buttonPeripheral2.CausesValidation = false; + buttonPeripheral2.Dock = DockStyle.Top; + buttonPeripheral2.FlatAppearance.BorderSize = 0; + buttonPeripheral2.FlatStyle = FlatStyle.Flat; + buttonPeripheral2.Font = new Font("Segoe UI", 8F, FontStyle.Regular, GraphicsUnit.Point); + buttonPeripheral2.ForeColor = SystemColors.ControlText; + buttonPeripheral2.Image = Properties.Resources.icons8_maus_48; + buttonPeripheral2.ImageAlign = ContentAlignment.MiddleLeft; + buttonPeripheral2.Location = new Point(200, 3); + buttonPeripheral2.Name = "buttonPeripheral2"; + buttonPeripheral2.Secondary = false; + buttonPeripheral2.Size = new Size(191, 95); + buttonPeripheral2.TabIndex = 19; + buttonPeripheral2.Text = "Mouse 2"; + buttonPeripheral2.TextImageRelation = TextImageRelation.ImageBeforeText; + buttonPeripheral2.UseVisualStyleBackColor = false; + // + // buttonPeripheral1 + // + buttonPeripheral1.AccessibleName = "Peripheral 1"; + buttonPeripheral1.Activated = false; + buttonPeripheral1.BackColor = SystemColors.ControlLightLight; + buttonPeripheral1.BorderColor = Color.Transparent; + buttonPeripheral1.BorderRadius = 5; + buttonPeripheral1.CausesValidation = false; + buttonPeripheral1.Dock = DockStyle.Top; + buttonPeripheral1.FlatAppearance.BorderSize = 0; + buttonPeripheral1.FlatStyle = FlatStyle.Flat; + buttonPeripheral1.Font = new Font("Segoe UI", 8F, FontStyle.Regular, GraphicsUnit.Point); + buttonPeripheral1.ForeColor = SystemColors.ControlText; + buttonPeripheral1.Image = Properties.Resources.icons8_maus_48; + buttonPeripheral1.ImageAlign = ContentAlignment.MiddleLeft; + buttonPeripheral1.Location = new Point(3, 3); + buttonPeripheral1.Name = "buttonPeripheral1"; + buttonPeripheral1.Secondary = false; + buttonPeripheral1.Size = new Size(191, 95); + buttonPeripheral1.TabIndex = 20; + buttonPeripheral1.Text = "Mouse 1"; + buttonPeripheral1.TextImageRelation = TextImageRelation.ImageBeforeText; + buttonPeripheral1.UseVisualStyleBackColor = false; + // + // panelPeripheralsTile + // + panelPeripheralsTile.Controls.Add(picturePeripherals); + panelPeripheralsTile.Controls.Add(labelPeripherals); + panelPeripheralsTile.Dock = DockStyle.Top; + panelPeripheralsTile.Location = new Point(15, 15); + panelPeripheralsTile.Name = "panelPeripheralsTile"; + panelPeripheralsTile.Size = new Size(591, 30); + panelPeripheralsTile.TabIndex = 45; + // + // picturePeripherals + // + picturePeripherals.BackgroundImage = Properties.Resources.icons8_maus_48; + picturePeripherals.BackgroundImageLayout = ImageLayout.Zoom; + picturePeripherals.Location = new Point(4, 0); + picturePeripherals.Name = "picturePeripherals"; + picturePeripherals.Size = new Size(24, 24); + picturePeripherals.TabIndex = 41; + picturePeripherals.TabStop = false; + // + // labelPeripherals + // + labelPeripherals.AutoSize = true; + labelPeripherals.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelPeripherals.Location = new Point(33, 0); + labelPeripherals.Margin = new Padding(6, 0, 6, 0); + labelPeripherals.Name = "labelPeripherals"; + labelPeripherals.Size = new Size(106, 25); + labelPeripherals.TabIndex = 40; + labelPeripherals.Text = "Peripherals"; + // // SettingsForm // - AutoScaleDimensions = new SizeF(192F, 192F); + AutoScaleDimensions = new SizeF(144F, 144F); AutoScaleMode = AutoScaleMode.Dpi; AutoSize = true; AutoSizeMode = AutoSizeMode.GrowAndShrink; - ClientSize = new Size(833, 1320); + ClientSize = new Size(637, 1185); Controls.Add(panelFooter); Controls.Add(panelVersion); Controls.Add(panelBattery); + Controls.Add(panelPeripherals); Controls.Add(panelKeyboard); Controls.Add(panelMatrix); Controls.Add(panelScreen); Controls.Add(panelGPU); Controls.Add(panelPerformance); - Margin = new Padding(8, 4, 8, 4); + Margin = new Padding(6, 3, 6, 3); MaximizeBox = false; MdiChildrenMinimizedAnchorBottom = false; MinimizeBox = false; - MinimumSize = new Size(823, 71); + MinimumSize = new Size(623, 67); Name = "SettingsForm"; - Padding = new Padding(11); + Padding = new Padding(8); ShowIcon = false; StartPosition = FormStartPosition.CenterScreen; Text = "G-Helper"; @@ -1248,6 +1369,12 @@ namespace GHelper ((System.ComponentModel.ISupportInitialize)pictureKeyboard).EndInit(); panelVersion.ResumeLayout(false); panelVersion.PerformLayout(); + panelPeripherals.ResumeLayout(false); + panelPeripherals.PerformLayout(); + tableLayoutPeripherals.ResumeLayout(false); + panelPeripheralsTile.ResumeLayout(false); + panelPeripheralsTile.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)picturePeripherals).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -1319,6 +1446,14 @@ namespace GHelper private RButton buttonStopGPU; private TableLayoutPanel tableButtons; private RButton buttonUpdates; + private Panel panelPeripherals; + private TableLayoutPanel tableLayoutPeripherals; + private Panel panelPeripheralsTile; + private PictureBox picturePeripherals; + private Label labelPeripherals; + private RButton buttonPeripheral2; + private RButton buttonPeripheral3; + private RButton buttonPeripheral1; private RButton buttonKeyboard; } } \ No newline at end of file diff --git a/app/Settings.cs b/app/Settings.cs index 62e36d89..e85bf3a0 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -6,6 +6,8 @@ using GHelper.Gpu; using GHelper.Helpers; using GHelper.Input; using GHelper.Mode; +using GHelper.Peripherals; +using GHelper.Peripherals.Mouse; using GHelper.UI; using System.Diagnostics; using System.Timers; @@ -70,6 +72,7 @@ namespace GHelper labelKeyboard.Text = Properties.Strings.LaptopKeyboard; labelMatrix.Text = Properties.Strings.AnimeMatrix; labelBatteryTitle.Text = Properties.Strings.BatteryChargeLimit; + labelPeripherals.Text = Properties.Strings.Peripherals; checkMatrix.Text = Properties.Strings.TurnOffOnBattery; checkStartup.Text = Properties.Strings.RunOnStartup; @@ -181,11 +184,22 @@ namespace GHelper labelBattery.MouseLeave += PanelBattery_MouseLeave; labelBatteryTitle.MouseLeave += PanelBattery_MouseLeave; + buttonPeripheral1.Click += ButtonPeripheral_Click; + buttonPeripheral2.Click += ButtonPeripheral_Click; + buttonPeripheral3.Click += ButtonPeripheral_Click; + Text = "G-Helper " + (ProcessHelper.IsUserAdministrator() ? "—" : "-") + " " + AppConfig.GetModelShort(); TopMost = AppConfig.Is("topmost"); + //This will auto position the window again when it resizes. Might mess with position if people drag the window somewhere else. + this.Resize += SettingsForm_Resize; SetContextMenu(); + } + private void SettingsForm_Resize(object? sender, EventArgs e) + { + Left = Screen.FromControl(this).WorkingArea.Width - 10 - Width; + Top = Screen.FromControl(this).WorkingArea.Height - 10 - Height; } private void PanelBattery_MouseEnter(object? sender, EventArgs e) @@ -815,6 +829,7 @@ namespace GHelper gpuTemp = $": {HardwareControl.gpuTemp}°C"; } + PeripheralsProvider.RefreshBatteryForAllDevices(); Program.settingsForm.BeginInvoke(delegate { @@ -824,6 +839,7 @@ namespace GHelper labelMidFan.Text = "Mid " + HardwareControl.midFan; if (!batteryMouseOver) labelBattery.Text = battery; + VisualizePeripherals(); }); string trayTip = "CPU" + cpuTemp + " " + HardwareControl.cpuFan; @@ -1058,6 +1074,92 @@ namespace GHelper } + public void VisualizePeripherals() + { + if (!PeripheralsProvider.IsAnyPeripheralConnect()) + { + panelPeripherals.Visible = false; + return; + } + + Button[] buttons = new Button[] { buttonPeripheral1, buttonPeripheral2, buttonPeripheral3 }; + + //we only support 4 devces for now. Who has more than 4 mice connected to the same PC anyways.... + List lp = PeripheralsProvider.AllPeripherals(); + + for (int i = 0; i < lp.Count && i < buttons.Length; ++i) + { + IPeripheral m = lp.ElementAt(i); + Button b = buttons[i]; + + if (m.IsDeviceReady) + { + b.Text = m.GetDisplayName() + "\n" + m.Battery + "%" + + (m.Charging ? "(" + Properties.Strings.Charging + ")" : ""); + b.Enabled = true; + } + else + { + //Mouse is either not connected or in standby + b.Text = m.GetDisplayName() + "\n(" + Properties.Strings.NotConnected + ")"; + b.Enabled = false; + } + + switch (m.DeviceType()) + { + case PeripheralType.Mouse: + b.Image = ControlHelper.TintImage(Properties.Resources.icons8_maus_32, b.ForeColor); + break; + + case PeripheralType.Keyboard: + b.Image = ControlHelper.TintImage(Properties.Resources.icons8_keyboard_32, b.ForeColor); + break; + } + + b.Visible = true; + } + + for (int i = lp.Count; i < buttons.Length; ++i) + { + buttons[i].Visible = false; + } + + panelPeripherals.Visible = true; + } + + private void ButtonPeripheral_Click(object? sender, EventArgs e) + { + int index = 0; + if (sender == buttonPeripheral2) index = 1; + if (sender == buttonPeripheral3) index = 2; + + IPeripheral iph = PeripheralsProvider.AllPeripherals().ElementAt(index); + + if (iph is null) + { + //Can only happen when the user hits the button in the exact moment a device is disconnected. + return; + } + + if (iph.DeviceType() == PeripheralType.Mouse) + { + AsusMouse? am = iph as AsusMouse; + if (am is null) + { + //Should not happen if all device classes are implemented correctly. But better safe than sorry. + return; + } + AsusMouseSettings s = new AsusMouseSettings(am); + if (!s.IsDisposed) + { + s.Show(); + } + + } + + + + } } diff --git a/app/UI/ControlHelper.cs b/app/UI/ControlHelper.cs index 3d784f98..d384497f 100644 --- a/app/UI/ControlHelper.cs +++ b/app/UI/ControlHelper.cs @@ -77,6 +77,12 @@ public static class ControlHelper combo.ButtonColor = RForm.buttonMain; combo.ArrowColor = RForm.foreMain; } + var numbericUpDown = control as NumericUpDown; + if(numbericUpDown is not null) + { + numbericUpDown.ForeColor = RForm.foreMain; + numbericUpDown.BackColor = RForm.buttonMain; + } var gb = control as GroupBox; if (gb != null) @@ -172,4 +178,20 @@ public static class ControlHelper } + public static Image TintImage(Image image, Color tintColor) + { + var pic = new Bitmap(image); + + for (int y = 0; (y <= (pic.Height - 1)); y++) + { + for (int x = 0; (x <= (pic.Width - 1)); x++) + { + Color col = pic.GetPixel(x, y); + pic.SetPixel(x, y, Color.FromArgb(col.A, tintColor.R, tintColor.G, tintColor.B)); + } + } + + return pic; + } + }