diff --git a/app/Extra.Designer.cs b/app/Extra.Designer.cs index b5210eb0..f5316c03 100644 --- a/app/Extra.Designer.cs +++ b/app/Extra.Designer.cs @@ -110,6 +110,10 @@ namespace GHelper checkVariBright = new CheckBox(); checkGpuApps = new CheckBox(); checkFnLock = new CheckBox(); + panelPower = new Panel(); + numericHibernateAfter = new NumericUpDown(); + labelHibernateAfter = new Label(); + pictureHibernate = new PictureBox(); panelServices.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureService).BeginInit(); panelBindingsHeader.SuspendLayout(); @@ -129,6 +133,9 @@ namespace GHelper ((System.ComponentModel.ISupportInitialize)pictureLog).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureSettings).BeginInit(); panelSettings.SuspendLayout(); + panelPower.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericHibernateAfter).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pictureHibernate).BeginInit(); SuspendLayout(); // // panelServices @@ -139,10 +146,10 @@ namespace GHelper panelServices.Controls.Add(labelServices); panelServices.Controls.Add(buttonServices); panelServices.Dock = DockStyle.Top; - panelServices.Location = new Point(15, 1267); + panelServices.Location = new Point(15, 1341); panelServices.Name = "panelServices"; panelServices.Size = new Size(983, 75); - panelServices.TabIndex = 4; + panelServices.TabIndex = 5; // // pictureService // @@ -1173,15 +1180,58 @@ namespace GHelper checkFnLock.Text = "Process Fn+F hotkeys without Fn"; checkFnLock.UseVisualStyleBackColor = true; // + // panelPower + // + panelPower.Controls.Add(numericHibernateAfter); + panelPower.Controls.Add(labelHibernateAfter); + panelPower.Controls.Add(pictureHibernate); + panelPower.Dock = DockStyle.Top; + panelPower.Location = new Point(15, 1267); + panelPower.Name = "panelPower"; + panelPower.Size = new Size(983, 74); + panelPower.TabIndex = 4; + // + // numericHibernateAfter + // + numericHibernateAfter.AccessibleName = "Minutes till Hibernation in sleep"; + numericHibernateAfter.Anchor = AnchorStyles.Top | AnchorStyles.Right; + numericHibernateAfter.Increment = new decimal(new int[] { 10, 0, 0, 0 }); + numericHibernateAfter.Location = new Point(810, 21); + numericHibernateAfter.Margin = new Padding(4, 3, 4, 3); + numericHibernateAfter.Maximum = new decimal(new int[] { 3000000, 0, 0, 0 }); + numericHibernateAfter.Name = "numericHibernateAfter"; + numericHibernateAfter.Size = new Size(152, 39); + numericHibernateAfter.TabIndex = 1; + // + // labelHibernateAfter + // + labelHibernateAfter.AutoSize = true; + labelHibernateAfter.Location = new Point(59, 21); + labelHibernateAfter.Margin = new Padding(4, 0, 4, 0); + labelHibernateAfter.Name = "labelHibernateAfter"; + labelHibernateAfter.Size = new Size(457, 32); + labelHibernateAfter.TabIndex = 45; + labelHibernateAfter.Text = "Minutes till Hibernation in sleep (0 - OFF)"; + // + // pictureHibernate + // + pictureHibernate.BackgroundImage = Resources.icons8_hibernate_32; + pictureHibernate.BackgroundImageLayout = ImageLayout.Zoom; + pictureHibernate.Location = new Point(20, 21); + pictureHibernate.Name = "pictureHibernate"; + pictureHibernate.Size = new Size(32, 32); + pictureHibernate.TabIndex = 22; + pictureHibernate.TabStop = false; + // // Extra // AutoScaleDimensions = new SizeF(192F, 192F); AutoScaleMode = AutoScaleMode.Dpi; - AutoScroll = true; AutoSize = true; AutoSizeMode = AutoSizeMode.GrowAndShrink; ClientSize = new Size(1013, 1431); Controls.Add(panelServices); + Controls.Add(panelPower); Controls.Add(panelSettings); Controls.Add(panelSettingsHeader); Controls.Add(panelBacklight); @@ -1193,7 +1243,7 @@ namespace GHelper MaximizeBox = false; MdiChildrenMinimizedAnchorBottom = false; MinimizeBox = false; - MinimumSize = new Size(1033, 71); + MinimumSize = new Size(1033, 0); Name = "Extra"; Padding = new Padding(15); ShowIcon = false; @@ -1227,6 +1277,10 @@ namespace GHelper ((System.ComponentModel.ISupportInitialize)pictureSettings).EndInit(); panelSettings.ResumeLayout(false); panelSettings.PerformLayout(); + panelPower.ResumeLayout(false); + panelPower.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)numericHibernateAfter).EndInit(); + ((System.ComponentModel.ISupportInitialize)pictureHibernate).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -1312,5 +1366,9 @@ namespace GHelper private RComboBox comboFNE; private TextBox textFNE; private Slider slider1; + private Panel panelPower; + private PictureBox pictureHibernate; + private Label labelHibernateAfter; + private NumericUpDown numericHibernateAfter; } } \ No newline at end of file diff --git a/app/Extra.cs b/app/Extra.cs index 6272a845..1f623b32 100644 --- a/app/Extra.cs +++ b/app/Extra.cs @@ -2,6 +2,7 @@ using GHelper.Gpu.AMD; using GHelper.Helpers; using GHelper.Input; +using GHelper.Mode; using GHelper.UI; using System.Diagnostics; @@ -127,6 +128,7 @@ namespace GHelper labelBacklightLogo.Text = Properties.Strings.Logo; checkGpuApps.Text = Properties.Strings.KillGpuApps; + labelHibernateAfter.Text = Properties.Strings.HibernateAfter; Text = Properties.Strings.ExtraSettings; @@ -322,6 +324,36 @@ namespace GHelper InitVariBright(); InitServices(); + InitHibernate(); + } + + private void InitHibernate() + { + try + { + Task.Run(() => + { + int hibernate = PowerNative.GetHibernateAfter(); + if (hibernate < 0 || hibernate > numericHibernateAfter.Maximum) hibernate = 0; + BeginInvoke(delegate + { + numericHibernateAfter.Value = hibernate; + numericHibernateAfter.ValueChanged += NumericHibernateAfter_ValueChanged; + }); + }); + + } + catch (Exception ex) + { + panelPower.Visible = false; + Logger.WriteLine(ex.ToString()); + } + + } + + private void NumericHibernateAfter_ValueChanged(object? sender, EventArgs e) + { + PowerNative.SetHibernateAfter((int)numericHibernateAfter.Value); } private void PictureLog_Click(object? sender, EventArgs e) @@ -406,6 +438,7 @@ namespace GHelper { try { + using (var amdControl = new AmdGpuControl()) { int variBrightSupported = 0, VariBrightEnabled; diff --git a/app/Extra.resx b/app/Extra.resx index a395bffc..af32865e 100644 --- a/app/Extra.resx +++ b/app/Extra.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object] diff --git a/app/GHelper.csproj b/app/GHelper.csproj index c252a4a2..3d027eff 100644 --- a/app/GHelper.csproj +++ b/app/GHelper.csproj @@ -15,7 +15,7 @@ AnyCPU False True - 0.107 + 0.108 diff --git a/app/Mode/PowerNative.cs b/app/Mode/PowerNative.cs index ae70ee60..23cdc30c 100644 --- a/app/Mode/PowerNative.cs +++ b/app/Mode/PowerNative.cs @@ -223,5 +223,38 @@ namespace GHelper.Mode Logger.WriteLine("Changed Lid Action to " + action); } + + public static int GetHibernateAfter() + { + Guid activeSchemeGuid = GetActiveScheme(); + IntPtr seconds; + PowerReadDCValueIndex(IntPtr.Zero, + activeSchemeGuid, + GUID_SLEEP_SUBGROUP, + GUID_HIBERNATEIDLE, out seconds); + + Logger.WriteLine("Hibernate after " + seconds); + return (seconds.ToInt32() / 60); + } + + + public static void SetHibernateAfter(int minutes) + { + int seconds = minutes * 60; + + Guid activeSchemeGuid = GetActiveScheme(); + var hrAC = PowerWriteDCValueIndex( + IntPtr.Zero, + activeSchemeGuid, + GUID_SLEEP_SUBGROUP, + GUID_HIBERNATEIDLE, + seconds); + + PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid); + + Logger.WriteLine("Setting Hibernate after " + seconds + ": " + (hrAC == 0 ? "OK" : hrAC)); + } + + } } diff --git a/app/Properties/Resources.Designer.cs b/app/Properties/Resources.Designer.cs index e151f4d0..52eb7f23 100644 --- a/app/Properties/Resources.Designer.cs +++ b/app/Properties/Resources.Designer.cs @@ -270,6 +270,16 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_hibernate_32 { + get { + object obj = ResourceManager.GetObject("icons8-hibernate-32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -571,7 +581,7 @@ namespace GHelper.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap lighting_dot_24 { get { @@ -581,7 +591,7 @@ namespace GHelper.Properties { } /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap lighting_dot_32 { get { @@ -601,7 +611,7 @@ namespace GHelper.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Icon ähnlich wie (Symbol). + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// internal static System.Drawing.Icon standard { get { diff --git a/app/Properties/Resources.resx b/app/Properties/Resources.resx index a732ee99..0e039773 100644 --- a/app/Properties/Resources.resx +++ b/app/Properties/Resources.resx @@ -148,24 +148,30 @@ ..\Resources\icons8-charging-battery-32.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\icons8-touchpad-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-automation-32.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-help-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-software-32-white.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-add-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-game-controller-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-video-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\icons8-refresh-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -178,12 +184,18 @@ ..\Resources\icons8-charged-battery-96.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 + ..\Resources\icons8-bicycle-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\brightness-down.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-charging-battery-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -193,6 +205,9 @@ ..\Resources\icons8-video-card-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\icons8-rocket-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -202,8 +217,8 @@ ..\Resources\backlight-up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-spa-flower-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-video-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-save-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -220,9 +235,15 @@ ..\Resources\icons8-fan-48.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-remove-64.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-matrix-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -244,6 +265,9 @@ ..\Resources\ultimate.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-spa-flower-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\backlight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -256,34 +280,13 @@ ..\Resources\icons8-laptop-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-rocket-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\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\icons8-rocket-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 + + ..\Resources\icons8-hibernate-32.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 4862ed01..97eb6003 100644 --- a/app/Properties/Strings.Designer.cs +++ b/app/Properties/Strings.Designer.cs @@ -827,6 +827,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Minutes till Hibernation in sleep on battery (0 - OFF). + /// + internal static string HibernateAfter { + get { + return ResourceManager.GetString("HibernateAfter", resourceCulture); + } + } + /// /// Looks up a localized string similar to High. /// diff --git a/app/Properties/Strings.resx b/app/Properties/Strings.resx index 65ff5a29..b937a4a9 100644 --- a/app/Properties/Strings.resx +++ b/app/Properties/Strings.resx @@ -374,6 +374,9 @@ Do you still want to continue? Temperature Target + + Minutes till Hibernation in sleep on battery (0 - OFF) + High diff --git a/app/Resources/icons8-hibernate-32.png b/app/Resources/icons8-hibernate-32.png new file mode 100644 index 00000000..e6ef0630 Binary files /dev/null and b/app/Resources/icons8-hibernate-32.png differ diff --git a/app/global.json b/app/global.json index 112677b9..fb34cf6b 100644 --- a/app/global.json +++ b/app/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "7.0.306" + "version": "7.0.400" } } \ No newline at end of file