Stop GPU apps button

This commit is contained in:
Serge
2023-06-24 13:08:06 +02:00
parent 96dc22072a
commit 7f6bdda39a
9 changed files with 88 additions and 39 deletions

View File

@@ -132,14 +132,14 @@ namespace GHelper
labelFansResult.Visible = false;
trackUV.Minimum = Undervolter.MinCPUUV;
trackUV.Maximum = Undervolter.MaxCPUUV;
trackUV.Minimum = RyzenControl.MinCPUUV;
trackUV.Maximum = RyzenControl.MaxCPUUV;
trackUViGPU.Minimum = Undervolter.MinIGPUUV;
trackUViGPU.Maximum = Undervolter.MaxIGPUUV;
trackUViGPU.Minimum = RyzenControl.MinIGPUUV;
trackUViGPU.Maximum = RyzenControl.MaxIGPUUV;
trackTemp.Minimum = Undervolter.MinTemp;
trackTemp.Maximum = Undervolter.MaxTemp;
trackTemp.Minimum = RyzenControl.MinTemp;
trackTemp.Maximum = RyzenControl.MaxTemp;
FillModes();
@@ -270,7 +270,7 @@ namespace GHelper
labelTemp.Text = trackTemp.Value.ToString() + "°C";
buttonAdvanced.Visible = Undervolter.IsAMD();
buttonAdvanced.Visible = RyzenControl.IsAMD();
}
@@ -622,7 +622,7 @@ namespace GHelper
public void InitPower(bool changed = false)
{
bool modeA0 = (Program.acpi.DeviceGet(AsusACPI.PPT_TotalA0) >= 0 || Undervolter.IsAMD());
bool modeA0 = (Program.acpi.DeviceGet(AsusACPI.PPT_TotalA0) >= 0 || RyzenControl.IsAMD());
bool modeB0 = Program.acpi.IsAllAmdPPT();
bool modeC1 = Program.acpi.DeviceGet(AsusACPI.PPT_APUC1) >= 0;

View File

@@ -74,7 +74,7 @@ namespace GHelper
Application.EnableVisualStyles();
HardwareControl.RecreateGpuControl();
Undervolter.Init();
RyzenControl.Init();
var ds = settingsForm.Handle;

View File

@@ -1124,6 +1124,15 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Stop GPU Applications.
/// </summary>
internal static string StopGPUApps {
get {
return ResourceManager.GetString("StopGPUApps", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Stopping Services.
/// </summary>

View File

@@ -473,6 +473,9 @@ Do you still want to continue?</value>
<data name="Stop" xml:space="preserve">
<value>Stop</value>
</data>
<data name="StopGPUApps" xml:space="preserve">
<value>Stop GPU Applications</value>
</data>
<data name="StoppingServices" xml:space="preserve">
<value>Stopping Services</value>
</data>

View File

@@ -8,7 +8,7 @@ using System.Management;
namespace Ryzen
{
internal class Undervolter
internal class RyzenControl
{
public const int MinCPUUV = -30;

View File

@@ -22,7 +22,7 @@ namespace Ryzen
//RAPHAEL/DRAGON RANGE - 10
public static Smu RyzenAccess = new Smu(false);
public static int FAMID = Undervolter.FAMID;
public static int FAMID = RyzenControl.FAMID;
//STAMP Limit

View File

@@ -97,6 +97,7 @@ namespace GHelper
labelVersion = new Label();
labelModel = new Label();
panelVersion = new Panel();
buttonStopGPU = new RButton();
panelMatrix.SuspendLayout();
tableLayoutMatrix.SuspendLayout();
panelMatrixTitle.SuspendLayout();
@@ -592,6 +593,7 @@ namespace GHelper
tableGPU.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableGPU.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableGPU.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableGPU.Controls.Add(buttonStopGPU, 0, 0);
tableGPU.Controls.Add(buttonEco, 0, 0);
tableGPU.Controls.Add(buttonStandard, 1, 0);
tableGPU.Controls.Add(buttonXGM, 2, 0);
@@ -664,11 +666,11 @@ namespace GHelper
buttonXGM.ForeColor = SystemColors.ControlText;
buttonXGM.Image = Properties.Resources.icons8_video_48;
buttonXGM.ImageAlign = ContentAlignment.BottomCenter;
buttonXGM.Location = new Point(4, 132);
buttonXGM.Location = new Point(580, 4);
buttonXGM.Margin = new Padding(4);
buttonXGM.Name = "buttonXGM";
buttonXGM.Secondary = false;
buttonXGM.Size = new Size(184, 120);
buttonXGM.Size = new Size(186, 120);
buttonXGM.TabIndex = 2;
buttonXGM.Text = "XG Mobile";
buttonXGM.TextImageRelation = TextImageRelation.ImageAboveText;
@@ -687,11 +689,11 @@ namespace GHelper
buttonOptimized.ForeColor = SystemColors.ControlText;
buttonOptimized.Image = Properties.Resources.icons8_project_management_48__1_;
buttonOptimized.ImageAlign = ContentAlignment.BottomCenter;
buttonOptimized.Location = new Point(580, 4);
buttonOptimized.Location = new Point(388, 4);
buttonOptimized.Margin = new Padding(4);
buttonOptimized.Name = "buttonOptimized";
buttonOptimized.Secondary = false;
buttonOptimized.Size = new Size(186, 120);
buttonOptimized.Size = new Size(184, 120);
buttonOptimized.TabIndex = 3;
buttonOptimized.Text = Properties.Strings.Optimized;
buttonOptimized.TextImageRelation = TextImageRelation.ImageAboveText;
@@ -709,7 +711,7 @@ namespace GHelper
buttonUltimate.ForeColor = SystemColors.ControlText;
buttonUltimate.Image = Properties.Resources.icons8_game_controller_48;
buttonUltimate.ImageAlign = ContentAlignment.BottomCenter;
buttonUltimate.Location = new Point(388, 4);
buttonUltimate.Location = new Point(4, 132);
buttonUltimate.Margin = new Padding(4);
buttonUltimate.Name = "buttonUltimate";
buttonUltimate.Secondary = false;
@@ -1118,6 +1120,30 @@ namespace GHelper
panelVersion.Size = new Size(810, 57);
panelVersion.TabIndex = 41;
//
// buttonStopGPU
//
buttonStopGPU.Activated = false;
buttonStopGPU.BackColor = SystemColors.ControlLightLight;
buttonStopGPU.BorderColor = Color.Transparent;
buttonStopGPU.BorderRadius = 5;
buttonStopGPU.CausesValidation = false;
buttonStopGPU.Dock = DockStyle.Top;
buttonStopGPU.FlatAppearance.BorderSize = 0;
buttonStopGPU.FlatStyle = FlatStyle.Flat;
buttonStopGPU.ForeColor = SystemColors.ControlText;
buttonStopGPU.Image = Properties.Resources.icons8_leaf_48;
buttonStopGPU.ImageAlign = ContentAlignment.BottomCenter;
buttonStopGPU.Location = new Point(196, 132);
buttonStopGPU.Margin = new Padding(4);
buttonStopGPU.Name = "buttonStopGPU";
buttonStopGPU.Secondary = false;
buttonStopGPU.Size = new Size(184, 120);
buttonStopGPU.TabIndex = 4;
buttonStopGPU.Text = "Stop GPU applications";
buttonStopGPU.TextImageRelation = TextImageRelation.ImageAboveText;
buttonStopGPU.UseVisualStyleBackColor = false;
buttonStopGPU.Visible = false;
//
// SettingsForm
//
AutoScaleDimensions = new SizeF(192F, 192F);
@@ -1255,5 +1281,6 @@ namespace GHelper
private Panel panelVersion;
private Label labelVersion;
private Label labelModel;
private RButton buttonStopGPU;
}
}

View File

@@ -54,7 +54,7 @@ namespace GHelper
buttonUltimate.Text = Properties.Strings.UltimateMode;
buttonStandard.Text = Properties.Strings.StandardMode;
buttonOptimized.Text = Properties.Strings.Optimized;
buttonStopGPU.Text = Properties.Strings.StopGPUApps;
buttonScreenAuto.Text = Properties.Strings.AutoMode;
buttonMiniled.Text = Properties.Strings.Multizone;
@@ -102,6 +102,7 @@ namespace GHelper
buttonStandard.Click += ButtonStandard_Click;
buttonUltimate.Click += ButtonUltimate_Click;
buttonOptimized.Click += ButtonOptimized_Click;
buttonStopGPU.Click += ButtonStopGPU_Click;
VisibleChanged += SettingsForm_VisibleChanged;
@@ -186,6 +187,7 @@ namespace GHelper
}
private void SettingsForm_VisibleChanged(object? sender, EventArgs e)
{
aTimer.Enabled = this.Visible;
@@ -988,6 +990,12 @@ namespace GHelper
SetGPUMode(AsusACPI.GPUModeEco);
}
private void ButtonStopGPU_Click(object? sender, EventArgs e)
{
HardwareControl.KillGPUApps();
}
public async void RefreshSensors(bool force = false)
{
@@ -1059,7 +1067,7 @@ namespace GHelper
Program.acpi.DeviceSet(AsusACPI.PPT_APUA3, limit_total, "PowerLimit A3");
customPower = limit_total;
}
else if (Undervolter.IsAMD())
else if (RyzenControl.IsAMD())
{
if (ProcessHelper.IsUserAdministrator())
@@ -1165,7 +1173,7 @@ namespace GHelper
return;
}
if (!Undervolter.IsAMD()) return;
if (!RyzenControl.IsAMD()) return;
int cpuUV = AppConfig.GetMode("cpu_uv", 0);
int igpuUV = AppConfig.GetMode("igpu_uv", 0);
@@ -1173,17 +1181,17 @@ namespace GHelper
try
{
if (cpuUV >= Undervolter.MinCPUUV && cpuUV <= Undervolter.MaxCPUUV)
if (cpuUV >= RyzenControl.MinCPUUV && cpuUV <= RyzenControl.MaxCPUUV)
{
SendCommand.set_coall(cpuUV);
}
if (igpuUV >= Undervolter.MinIGPUUV && igpuUV <= Undervolter.MaxIGPUUV)
if (igpuUV >= RyzenControl.MinIGPUUV && igpuUV <= RyzenControl.MaxIGPUUV)
{
SendCommand.set_cogfx(igpuUV);
}
if (cpuTemp >= Undervolter.MinTemp && cpuTemp <= Undervolter.MaxTemp)
if (cpuTemp >= RyzenControl.MinTemp && cpuTemp <= RyzenControl.MaxTemp)
{
SendCommand.set_tctl_temp((uint)cpuTemp);
SendCommand.set_apu_skin_temp_limit((uint)cpuTemp);
@@ -1544,20 +1552,6 @@ namespace GHelper
return true;
}
private void UltimateUI(bool ultimate)
{
if (!ultimate)
{
tableGPU.Controls.Remove(buttonUltimate);
tablePerf.ColumnCount = 0;
tableGPU.ColumnCount = 0;
tableScreen.ColumnCount = 0;
menuUltimate.Visible = false;
}
//tableLayoutMatrix.ColumnCount = 0;
}
public void InitXGM()
{
bool connected = Program.acpi.IsXGConnected();
@@ -1608,12 +1602,28 @@ namespace GHelper
else
GpuMode = AsusACPI.GPUModeStandard;
UltimateUI(mux == 1);
// Ultimate mode not suported
if (mux != 1)
{
tableGPU.Controls.Remove(buttonUltimate);
tablePerf.ColumnCount = 0;
tableGPU.ColumnCount = 0;
tableScreen.ColumnCount = 0;
menuUltimate.Visible = false;
}
if (eco < 0 && mux < 0)
{
isGpuSection = tableGPU.Visible = false;
isGpuSection = false;
buttonEco.Visible = false;
buttonStandard.Visible = false;
buttonUltimate.Visible = false;
buttonOptimized.Visible = false;
buttonStopGPU.Visible = true;
SetContextMenu();
if (HardwareControl.FormatFan(Program.acpi.DeviceGet(AsusACPI.GPU_Fan)) is null) panelGPU.Visible = false;
}

View File

@@ -74,7 +74,7 @@ namespace GHelper
public Updates()
{
InitializeComponent();
InitTheme();
InitTheme(true);
LoadUpdates();