Skip to content

Commit

Permalink
Redesign Settings form layout for auto alignment and auto-resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
irusanov committed Sep 5, 2019
1 parent 2851a06 commit d35bdf8
Show file tree
Hide file tree
Showing 6 changed files with 717 additions and 402 deletions.
2 changes: 1 addition & 1 deletion NotificationIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public enum PerfEnh { None = 0, Default, Level1, Level2, Level3_OC };
public static bool SettingsSaved;

public static UInt64[] Pstate;
public static int Pstates = 1;
public static int Pstates = 3;

public static bool ZenC6Core;
public static bool ZenC6Package;
Expand Down
1,044 changes: 667 additions & 377 deletions SettingsForm.Designer.cs

Large diffs are not rendered by default.

54 changes: 40 additions & 14 deletions SettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial class SettingsForm : Form
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();

private const int PSTATES = 1;
private const int PSTATES = 3;
private const int FID_MAX = 0xFF;
private const int FID_MIN = 0x10;
private const int VID_MAX = 0xA9;
Expand Down Expand Up @@ -121,30 +121,30 @@ public SettingsForm()
// FID combobox
PstateFid[i] = new ComboBox
{
Size = new System.Drawing.Size(120, 20),
Location = new System.Drawing.Point(10, 7 + i * 25)
Size = new System.Drawing.Size(115, 20),
Location = new System.Drawing.Point(7, 7 + i * 25)
};
this.splitContainer1.Panel2.Controls.Add(PstateFid[i]);
this.panelManualMode.Controls.Add(PstateFid[i]);

// DID combobox
PstateDid[i] = new ComboBox
{
Size = new System.Drawing.Size(50, 20),
Location = new System.Drawing.Point(135, 7 + i * 25),
Location = new System.Drawing.Point(130, 7 + i * 25),
Enabled = false
};
foreach (CustomListItem item in DIVIDERS)
{
PstateDid[i].Items.Add(item);
}
PstateDid[i].SelectedIndexChanged += UpdateFids;
this.splitContainer1.Panel2.Controls.Add(PstateDid[i]);
this.panelManualMode.Controls.Add(PstateDid[i]);

// VID combobox
PstateVid[i] = new ComboBox
{
Size = new System.Drawing.Size(80, 20),
Location = new System.Drawing.Point(190, 7 + i * 25)
Size = new System.Drawing.Size(77, 20),
Location = new System.Drawing.Point(188, 7 + i * 25)
};
int k = 0;
for (byte j = VID_MIN; j <= VID_MAX; j++)
Expand All @@ -153,9 +153,15 @@ public SettingsForm()
CustomListItem item = new CustomListItem(k++, j, voltage.ToString("F3") + "V");
PstateVid[i].Items.Add(item);
}
this.splitContainer1.Panel2.Controls.Add(PstateVid[i]);
this.panelManualMode.Controls.Add(PstateVid[i]);
}

Label test = new Label
{
Text = "Auto Mode Panel"
};
this.panelAutoMode.Controls.Add(test);

foreach (CustomListItem item in PERFBIAS)
{
comboBoxPerfbias.Items.Add(item);
Expand Down Expand Up @@ -234,7 +240,9 @@ public void ResetValues()
checkBoxC6Package.Checked = Convert.ToBoolean(NotificationIcon.ZenC6Package);
checkBoxCpb.Checked = Convert.ToBoolean(NotificationIcon.ZenCorePerfBoost);

checkBoxOc.Checked = Convert.ToBoolean(NotificationIcon.ZenOc);
bool isManual = Convert.ToBoolean(NotificationIcon.ZenOc);
radioAutoControl.Checked = !isManual;
radioManualControl.Checked = isManual;

textBoxPPT.Text = NotificationIcon.ZenPPT.ToString();
textBoxTDC.Text = NotificationIcon.ZenTDC.ToString();
Expand Down Expand Up @@ -302,7 +310,7 @@ void ButtonApplyClick(object sender, EventArgs e)
for (int i = 0; i < PstateFid.Length; i++)
{
// UInt64 en = Convert.ToUInt64(PstateEn[i].Checked);
UInt64 en = Convert.ToUInt64(checkBoxOc.Checked);
UInt64 en = Convert.ToUInt64(radioManualControl.Checked);
UInt64 fid = Convert.ToUInt64(((CustomListItem)PstateFid[i].SelectedItem).value);
UInt64 did = Convert.ToUInt64(((CustomListItem)PstateDid[i].SelectedItem).value);
UInt64 vid = Convert.ToUInt64(((CustomListItem)PstateVid[i].SelectedItem).value);
Expand All @@ -314,8 +322,8 @@ void ButtonApplyClick(object sender, EventArgs e)

NotificationIcon.di.MemWrite(DataInterface.REG_P0 + i, ps);

PstateFid[i].Enabled = checkBoxOc.Checked;
PstateVid[i].Enabled = checkBoxOc.Checked;
PstateFid[i].Enabled = radioManualControl.Checked;
PstateVid[i].Enabled = radioManualControl.Checked;
}

UInt64 flags = 0;
Expand All @@ -325,7 +333,7 @@ void ButtonApplyClick(object sender, EventArgs e)
if (checkBoxC6Core.Checked) flags |= DataInterface.FLAG_C6CORE;
if (checkBoxC6Package.Checked) flags |= DataInterface.FLAG_C6PACKAGE;
if (checkBoxCpb.Checked) flags |= DataInterface.FLAG_CPB;
if (checkBoxOc.Checked) flags |= DataInterface.FLAG_OC;
if (radioManualControl.Checked) flags |= DataInterface.FLAG_OC;

if (!int.TryParse(textBoxPPT.Text, out int ppt))
{
Expand Down Expand Up @@ -460,5 +468,23 @@ private void comboBoxPerfenh_SelectedIndexChanged(object sender, EventArgs e)
break;
}
}

private void RadioAutoControl_CheckedChanged(object sender, EventArgs e)
{
if (radioAutoControl.Checked)
{
panelAutoMode.Show();
panelManualMode.Hide();
}
}

private void RadioManualControl_CheckedChanged(object sender, EventArgs e)
{
if (radioManualControl.Checked)
{
panelManualMode.Show();
panelAutoMode.Hide();
}
}
}
}
15 changes: 7 additions & 8 deletions ZenStates.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{F4267FC9-31E2-4D53-A4C3-C05000BA6BDF}</ProjectGuid>
Expand Down Expand Up @@ -104,19 +104,19 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DataInterface.cs" />
<Compile Include="SettingsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SettingsForm.Designer.cs">
<DependentUpon>SettingsForm.cs</DependentUpon>
</Compile>
<Compile Include="NotificationIcon.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="SettingsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SettingsForm.Designer.cs">
<DependentUpon>SettingsForm.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="NotificationIcon.resx">
Expand All @@ -129,7 +129,6 @@
</EmbeddedResource>
<EmbeddedResource Include="SettingsForm.resx">
<DependentUpon>SettingsForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ZenStatesSrv/CPUHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public enum PerfBias { Auto, None, Cinebench_R11p5, Cinebench_R15, Geekbench_3 }
public bool SettingsSaved = false;
public bool ShutdownUnclean = false;

public static int NumPstates = 1;
public static int NumPstates = 3;

public UInt64[] PstateAtStart;
public bool ZenC6CoreAtStart = false;
Expand Down
2 changes: 1 addition & 1 deletion ZenStatesSrv/ZenStatesSrv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public static extern Boolean ChangeServiceConfig(
String lpPassword,
String lpDisplayName);

[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Auto)]
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
static extern IntPtr OpenService(
IntPtr hSCManager, string lpServiceName, uint dwDesiredAccess);

Expand Down

0 comments on commit d35bdf8

Please sign in to comment.