Skip to content

Commit

Permalink
Merge config and logging libraries into common library
Browse files Browse the repository at this point in the history
- UI scale factor fix for some elements
  • Loading branch information
Sparronator9999 committed Feb 22, 2025
1 parent 51bc21e commit c3b2dd9
Show file tree
Hide file tree
Showing 42 changed files with 123 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Represents a charge limit config for a laptop.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using YAMDCC.Logs;
using YAMDCC.Common.Logs;

namespace YAMDCC.Common;
namespace YAMDCC.Common.Configs;

public class CommonConfig
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using System.Collections.Generic;
using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Represents a configuration for a fan in the target laptop.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using System.Collections.Generic;
using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Represents a fan profile (a.k.a. fan curve) config.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Represents a configuration for an
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using System.Collections.Generic;
using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Contains an MSI laptop's various fan modes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Represents a configuration describing how
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Represents a Full Blast configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System;

namespace YAMDCC.Common;
namespace YAMDCC.Common.Configs;

/// <summary>
/// The exception thrown when an invalid <see cref="YAMDCC_Config"/> is loaded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Represents a configuration for the keyboard backlight in a laptop.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Represents a configuration for the Win/Fn key swap feature of a laptop.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Represents a configuration for an
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using System.Collections.Generic;
using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Represents a configuration for the performance modes of a laptop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Represents miscellaneous EC register configurations for the target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Xml.Serialization;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

/// <summary>
/// Represents a fan speed/temperature threshold setting for a fan curve.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using YAMDCC.Common;

namespace YAMDCC.Config;
namespace YAMDCC.Common.Configs;

// IDE0079: Remove unnecessary suppression (even though it *is* necessary)
#pragma warning disable IDE0079
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.Logs/LogLevel.cs → YAMDCC.Common/Logs/LogLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License along with
// YAMDCC. If not, see <https://www.gnu.org/licenses/>.

namespace YAMDCC.Logs;
namespace YAMDCC.Common.Logs;

/// <summary>
/// The verbosity of logs
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.Logs/Logger.cs → YAMDCC.Common/Logs/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.IO.Compression;
using System.Reflection;

namespace YAMDCC.Logs;
namespace YAMDCC.Common.Logs;

/// <summary>
/// A simple logger class for writing logs to
Expand Down
8 changes: 8 additions & 0 deletions YAMDCC.Common/Paths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,12 @@ public static class Paths
/// (C:\ProgramData\Sparronator9999\YAMDCC\CurrentConfig.xml on Windows)
/// </remarks>
public static readonly string CurrentConf = Path.Combine(Data, "CurrentConfig.xml");

/// <summary>
/// The path where the currently applied Hotkey Handler config is saved.
/// </summary>
/// <remarks>
/// (C:\ProgramData\Sparronator9999\YAMDCC\HotkeyConfig.xml on Windows)
/// </remarks>
public static readonly string HotkeyConf = Path.Combine(Data, "HotkeyConfig.xml");
}
7 changes: 2 additions & 5 deletions YAMDCC.Common/YAMDCC.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<RuntimeIdentifiers>win7-x64;win7-x86;win-x64;win-x86</RuntimeIdentifiers>
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC common code library</Title>
<VersionPrefix>1.0.3</VersionPrefix>
<VersionSuffix>release</VersionSuffix>
<VersionPrefix>1.0.4</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand All @@ -28,9 +28,6 @@
<None Include="Dialogs\ProgressDialog.resx" />
<None Include="Dialogs\TextInputDialog.resx" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\YAMDCC.Logs\YAMDCC.Logs.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Windows.Forms" />
Expand Down
24 changes: 0 additions & 24 deletions YAMDCC.Config/YAMDCC.Config.csproj

This file was deleted.

20 changes: 0 additions & 20 deletions YAMDCC.Config/packages.lock.json

This file was deleted.

10 changes: 4 additions & 6 deletions YAMDCC.ConfigEditor/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions YAMDCC.ConfigEditor/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
using System.IO;
using System.Windows.Forms;
using YAMDCC.Common;
using YAMDCC.Common.Configs;
using YAMDCC.Common.Dialogs;
using YAMDCC.Config;
using YAMDCC.Common.Logs;
using YAMDCC.IPC;
using YAMDCC.Logs;

namespace YAMDCC.ConfigEditor;

Expand Down Expand Up @@ -154,8 +154,9 @@ public MainForm()
}

#region Events
private void MainWindow_Load(object sender, EventArgs e)
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
IPCClient.ServerMessage += new EventHandler<PipeMessageEventArgs<ServiceResponse, ServiceCommand>>(IPCMessage);
IPCClient.Error += new EventHandler<PipeErrorEventArgs<ServiceResponse, ServiceCommand>>(IPCError);
IPCClient.Start();
Expand Down Expand Up @@ -197,8 +198,9 @@ private void MainWindow_Load(object sender, EventArgs e)
}
}

private void MainWindow_Closing(object sender, FormClosingEventArgs e)
protected override void OnFormClosing(FormClosingEventArgs e)
{
base.OnFormClosing(e);
// Disable Full Blast if it was enabled while the program was running:
if (chkFullBlast.Checked)
{
Expand Down Expand Up @@ -645,7 +647,7 @@ private void FanSelChanged(object sender, EventArgs e)
if (numFanSpds is null || numFanSpds.Length != cfg.FanCurveRegs.Length)
{
tblCurve.SuspendLayout();
float scale = CurrentAutoScaleDimensions.Height / 72;
float scale = CurrentAutoScaleDimensions.Height / 96;

tblCurve.Controls.Clear();
numUpTs = new NumericUpDown[cfg.UpThresholdRegs.Length];
Expand Down Expand Up @@ -675,7 +677,7 @@ private void FanSelChanged(object sender, EventArgs e)
{
Dock = DockStyle.Fill,
LargeChange = 10,
Margin = new Padding((int)(10 * scale), 0, (int)(10 * scale), 0),
Margin = new Padding((int)(12 * scale), 0, (int)(12 * scale), 0),
Orientation = Orientation.Vertical,
Tag = i,
TickFrequency = 5,
Expand Down Expand Up @@ -1217,7 +1219,7 @@ private static Label FanCurveLabel(string text, float scale, ContentAlignment al
{
AutoSize = true,
Dock = DockStyle.Fill,
Margin = new Padding((int)(2 * scale)),
Margin = new Padding((int)(3 * scale)),
Padding = new Padding(0, 0, 0, (int)(3 * scale)),
Text = text,
TextAlign = align,
Expand All @@ -1230,7 +1232,7 @@ private static NumericUpDown FanCurveNUD(int tag, float scale)
{
Dock = DockStyle.Fill,
Height = (int)(23 * scale),
Margin = new Padding((int)(2 * scale)),
Margin = new Padding((int)(3 * scale)),
Tag = tag,
};
}
Expand Down
Loading

0 comments on commit c3b2dd9

Please sign in to comment.