Project initial upload

This commit is contained in:
NinjaPug
2025-03-28 11:31:30 -04:00
parent 9d80c6a125
commit 553849d67f
24 changed files with 6585 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
namespace PCPalConfigurator
{
public class ConfigData
{
public string LastUsedPort { get; set; }
public string ScreenType { get; set; }
public string Line1Selection { get; set; }
public string Line1CustomText { get; set; }
public string Line2Selection { get; set; }
public string Line2CustomText { get; set; }
public string Line1PostText { get; set; }
public string Line2PostText { get; set; }
}
}

View File

@@ -0,0 +1,148 @@
namespace PCPalConfigurator
{
partial class ConfiguratorForm
{
private System.ComponentModel.IContainer components = null;
private TabControl tabControl;
private TabPage tab1602;
private TabPage tabTFT;
private TabPage tabAbout;
private ComboBox cmbLine1;
private TextBox txtLine1;
private TextBox txtLine1Post;
private ComboBox cmbLine2;
private TextBox txtLine2;
private TextBox txtLine2Post;
private Button btnApply;
private Label lblLine1;
private Label lblLine1Prefix;
private Label lblLine1Suffix;
private Label lblLine2;
private Label lblLine2Prefix;
private Label lblLine2Suffix;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.tabControl = new TabControl();
this.tab1602 = new TabPage("1602 LCD");
this.tabTFT = new TabPage("4.6\" TFT LCD");
this.tabAbout = new TabPage("About");
this.cmbLine1 = new ComboBox();
this.txtLine1 = new TextBox();
this.txtLine1Post = new TextBox();
this.cmbLine2 = new ComboBox();
this.txtLine2 = new TextBox();
this.txtLine2Post = new TextBox();
this.btnApply = new Button();
this.lblLine1 = new Label();
this.lblLine1Prefix = new Label();
this.lblLine1Suffix = new Label();
this.lblLine2 = new Label();
this.lblLine2Prefix = new Label();
this.lblLine2Suffix = new Label();
// === TabControl ===
this.tabControl.Location = new System.Drawing.Point(10, 10);
this.tabControl.Size = new System.Drawing.Size(620, 280);
this.tabControl.TabPages.Add(this.tab1602);
this.tabControl.TabPages.Add(this.tabTFT);
this.tabControl.TabPages.Add(this.tabAbout);
this.Controls.Add(this.tabControl);
// === Line 1 UI ===
this.lblLine1.Text = "Line 1:";
this.lblLine1.Location = new System.Drawing.Point(20, 20);
this.lblLine1.AutoSize = true;
this.cmbLine1.Location = new System.Drawing.Point(100, 18);
this.cmbLine1.Size = new System.Drawing.Size(200, 21);
this.lblLine1Prefix.Text = "Prefix:";
this.lblLine1Prefix.Location = new System.Drawing.Point(20, 50);
this.lblLine1Prefix.AutoSize = true;
this.txtLine1.Location = new System.Drawing.Point(100, 48);
this.txtLine1.Size = new System.Drawing.Size(200, 21);
this.lblLine1Suffix.Text = "Suffix / Units:";
this.lblLine1Suffix.Location = new System.Drawing.Point(320, 50);
this.lblLine1Suffix.AutoSize = true;
this.txtLine1Post.Location = new System.Drawing.Point(420, 48);
this.txtLine1Post.Size = new System.Drawing.Size(120, 21);
// === Line 2 UI ===
this.lblLine2.Text = "Line 2:";
this.lblLine2.Location = new System.Drawing.Point(20, 90);
this.lblLine2.AutoSize = true;
this.cmbLine2.Location = new System.Drawing.Point(100, 88);
this.cmbLine2.Size = new System.Drawing.Size(200, 21);
this.lblLine2Prefix.Text = "Prefix:";
this.lblLine2Prefix.Location = new System.Drawing.Point(20, 120);
this.lblLine2Prefix.AutoSize = true;
this.txtLine2.Location = new System.Drawing.Point(100, 118);
this.txtLine2.Size = new System.Drawing.Size(200, 21);
this.lblLine2Suffix.Text = "Suffix / Units:";
this.lblLine2Suffix.Location = new System.Drawing.Point(320, 120);
this.lblLine2Suffix.AutoSize = true;
this.txtLine2Post.Location = new System.Drawing.Point(420, 118);
this.txtLine2Post.Size = new System.Drawing.Size(120, 21);
// === Apply Button ===
this.btnApply.Text = "Apply";
this.btnApply.Location = new System.Drawing.Point(20, 170);
this.btnApply.Size = new System.Drawing.Size(100, 30);
this.btnApply.Click += new System.EventHandler(this.btnApply_Click);
// === Add to 1602 Tab ===
this.tab1602.Controls.AddRange(new Control[]
{
lblLine1, cmbLine1, lblLine1Prefix, txtLine1, lblLine1Suffix, txtLine1Post,
lblLine2, cmbLine2, lblLine2Prefix, txtLine2, lblLine2Suffix, txtLine2Post,
btnApply
});
// === TFT Tab Placeholder ===
Label lblTFT = new Label()
{
Text = "TFT configuration coming soon...",
Location = new System.Drawing.Point(20, 20),
AutoSize = true
};
this.tabTFT.Controls.Add(lblTFT);
// === About Tab ===
Label lblAbout = new Label()
{
Text = "PCPal Display Configurator\nFor ThermalTake Tower XXX\nVersion 1.0.0\n© 2025 Christopher Koch aka NinjaPug",
Location = new System.Drawing.Point(20, 20),
AutoSize = true
};
this.tabAbout.Controls.Add(lblAbout);
// === Form ===
this.Text = "Display Configurator";
this.ClientSize = new System.Drawing.Size(640, 300);
this.ResumeLayout(false);
this.PerformLayout();
}
}
}

View File

@@ -0,0 +1,120 @@
using System;
using System.IO;
using System.Windows.Forms;
using Newtonsoft.Json;
using LibreHardwareMonitor.Hardware;
using PCPalConfigurator;
namespace PCPalConfigurator
{
public partial class ConfiguratorForm : Form
{
private ConfigData config;
private readonly string ConfigFile = GetConfigPath();
private Computer computer;
public ConfiguratorForm()
{
InitializeComponent();
InitHardware();
LoadConfig();
}
private void InitHardware()
{
computer = new Computer
{
IsCpuEnabled = true,
IsGpuEnabled = true,
IsMemoryEnabled = true,
IsMotherboardEnabled = true,
IsControllerEnabled = true,
IsStorageEnabled = true
};
computer.Open();
PopulateSensorOptions();
}
private static string GetConfigPath()
{
string folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ESP32Display");
Directory.CreateDirectory(folder);
return Path.Combine(folder, "config.json");
}
private void LoadConfig()
{
if (File.Exists(ConfigFile))
{
string json = File.ReadAllText(ConfigFile);
config = JsonConvert.DeserializeObject<ConfigData>(json) ?? new ConfigData();
ApplyConfig();
}
else
{
config = new ConfigData();
}
}
private void ApplyConfig()
{
cmbLine1.SelectedItem = config.Line1Selection;
txtLine1.Text = config.Line1CustomText;
txtLine1Post.Text = config.Line1PostText;
cmbLine2.SelectedItem = config.Line2Selection;
txtLine2.Text = config.Line2CustomText;
txtLine2Post.Text = config.Line2PostText;
}
private void SaveConfig()
{
// ScreenType based on selected tab
if (tabControl.SelectedTab == tab1602)
config.ScreenType = "1602";
else if (tabControl.SelectedTab == tabTFT)
config.ScreenType = "TFT4_6";
config.Line1Selection = cmbLine1.SelectedItem?.ToString();
config.Line1CustomText = txtLine1.Text;
config.Line1PostText = txtLine1Post.Text;
config.Line2Selection = cmbLine2.SelectedItem?.ToString();
config.Line2CustomText = txtLine2.Text;
config.Line2PostText = txtLine2Post.Text;
string json = JsonConvert.SerializeObject(config, Formatting.Indented);
File.WriteAllText(ConfigFile, json);
MessageBox.Show("Settings saved!");
}
private void btnApply_Click(object sender, EventArgs e)
{
SaveConfig();
}
private void PopulateSensorOptions()
{
cmbLine1.Items.Clear();
cmbLine2.Items.Clear();
foreach (var hardware in computer.Hardware)
{
hardware.Update();
foreach (var sensor in hardware.Sensors)
{
if (sensor.SensorType == SensorType.Load ||
sensor.SensorType == SensorType.Temperature ||
sensor.SensorType == SensorType.Data ||
sensor.SensorType == SensorType.Fan)
{
string option = $"{hardware.HardwareType}: {sensor.Name} ({sensor.SensorType})";
cmbLine1.Items.Add(option);
cmbLine2.Items.Add(option);
}
}
}
cmbLine1.Items.Add("Custom Text");
cmbLine2.Items.Add("Custom Text");
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="LibreHardwareMonitorLib" Version="0.9.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Update="ConfiguratorForm.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35828.75 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PCPalConfigurator", "PCPalConfigurator.csproj", "{DC3430AF-194C-4FA9-A675-DE0C22E3A160}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DC3430AF-194C-4FA9-A675-DE0C22E3A160}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DC3430AF-194C-4FA9-A675-DE0C22E3A160}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DC3430AF-194C-4FA9-A675-DE0C22E3A160}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DC3430AF-194C-4FA9-A675-DE0C22E3A160}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B16D071E-66FA-43E7-AF92-3D54286834FF}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,14 @@
namespace PCPalConfigurator
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ConfiguratorForm());
}
}
}

View File

@@ -0,0 +1,8 @@
{
"LastUsedPort": null,
"ScreenType": null,
"Line1Selection": "Cpu: CPU Total (Load)",
"Line1CustomText": "",
"Line2Selection": "Memory: Memory (Load)",
"Line2CustomText": "rfrfrf"
}