Skip to content

Commit 50b00a7

Browse files
committed
user common repository
1 parent a662ea1 commit 50b00a7

49 files changed

Lines changed: 234 additions & 1777 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
using System.Reflection;
1+
global using sergiye.Common;
2+
using System.Reflection;
23

34
[assembly: AssemblyTitle("Open Hardware Monitor")]
45
[assembly: AssemblyDescription("")]
56
[assembly: AssemblyConfiguration("")]
6-
[assembly: AssemblyCompany("sergiye")]
7-
[assembly: AssemblyProduct("Open Hardware Monitor")]
7+
[assembly: AssemblyCompany("SergiyE")]
8+
[assembly: AssemblyProduct("OpenHardwareMonitor")]
89
[assembly: AssemblyCopyright("Copyright © 2022 Sergiy Egoshyn")]
910
[assembly: AssemblyVersion("2025.1.*")]

OpenHardwareMonitor/OpenHardwareMonitor.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@
8181
</ItemGroup>
8282
<ItemGroup>
8383
<EmbeddedResource Include="Resources\**" />
84+
<Compile Include="..\..\common\sergiye.Common\SerializerHelper.cs" Link="common\SerializerHelper.cs" />
85+
<Compile Include="..\..\common\sergiye.Common\Updater.cs" Link="common\Updater.cs" />
86+
<Compile Include="..\..\common\sergiye.Common\Crasher.cs" Link="common\Crasher.cs" />
87+
<Compile Include="..\..\common\sergiye.Common.UI\PersistentSettings.cs" Link="common\PersistentSettings.cs" />
88+
<Compile Include="..\..\common\sergiye.Common.UI\Themes\CustomTheme.cs" Link="common\Themes\CustomTheme.cs" />
89+
<Compile Include="..\..\common\sergiye.Common.UI\Themes\DarkTheme.cs" Link="common\Themes\DarkTheme.cs" />
90+
<Compile Include="..\..\common\sergiye.Common.UI\Themes\LightTheme.cs" Link="common\Themes\LightTheme.cs" />
91+
<Compile Include="..\..\common\sergiye.Common.UI\Themes\Theme.cs" Link="common\Themes\Theme.cs" />
92+
<Compile Include="..\..\common\sergiye.Common.UI\Themes\ThemedHScrollIndicator.cs" Link="common\Themes\ThemedHScrollIndicator.cs" />
93+
<Compile Include="..\..\common\sergiye.Common.UI\Themes\ThemedToolStripRenderer.cs" Link="common\Themes\ThemedToolStripRenderer.cs" />
94+
<Compile Include="..\..\common\sergiye.Common.UI\Themes\ThemedVScrollIndicator.cs" Link="common\Themes\ThemedVScrollIndicator.cs" />
95+
<Compile Include="..\..\common\sergiye.Common.UI\ToolStripRadioButtonMenuItem.cs" Link="common\ToolStripRadioButtonMenuItem.cs" />
8496
<None Include="Resources\app.manifest" />
8597
<None Include="Resources\icon.ico" />
8698
</ItemGroup>

OpenHardwareMonitor/Program.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Threading;
55
using System.Windows.Forms;
66
using OpenHardwareMonitor.UI;
7-
using sergiye.Common;
87

98
namespace OpenHardwareMonitor;
109

@@ -15,11 +14,22 @@ public static class Program
1514
[STAThread]
1615
public static void Main()
1716
{
18-
if (!VersionCompatibility.IsCompatible())
17+
if (!OperatingSystemHelper.IsCompatible(false, out var errorMessage, out var fixAction))
1918
{
20-
MessageBox.Show("The application is not compatible with your region.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
19+
if (fixAction != null)
20+
{
21+
if (MessageBox.Show(errorMessage, Updater.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
22+
{
23+
fixAction?.Invoke();
24+
}
25+
}
26+
else
27+
{
28+
MessageBox.Show(errorMessage, Updater.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
29+
}
2130
Environment.Exit(0);
2231
}
32+
2333
if (!mutex.WaitOne(TimeSpan.Zero, true))
2434
{
2535
var process = Process.GetProcessesByName(Updater.ApplicationName).FirstOrDefault();

OpenHardwareMonitor/Resources/themes/Black.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

OpenHardwareMonitor/Resources/themes/white.json renamed to OpenHardwareMonitor/Resources/themes/gray.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"DisplayName": "White",
2+
"DisplayName": "Gray",
33
"DarkMode": false,
44
"BackgroundColor": "#F7F5F2",
55
"ForegroundColor": "#161616",

OpenHardwareMonitor/UI/AboutBox.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Drawing;
44
using System.Windows.Forms;
55
using OpenHardwareMonitor.Utilities;
6-
using sergiye.Common;
76

87
namespace OpenHardwareMonitor.UI;
98

OpenHardwareMonitor/UI/AuthForm.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Windows.Forms;
3-
using sergiye.Common;
43

54
namespace OpenHardwareMonitor.UI;
65

OpenHardwareMonitor/UI/InterfacePortForm.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Net;
44
using System.Net.Sockets;
55
using System.Diagnostics;
6-
using sergiye.Common;
76

87
namespace OpenHardwareMonitor.UI;
98

OpenHardwareMonitor/UI/MainForm.Designer.cs

Lines changed: 34 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OpenHardwareMonitor/UI/MainForm.cs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
using Aga.Controls.Tree.NodeControls;
1111
using OpenHardwareMonitor.Hardware;
1212
using OpenHardwareMonitor.Hardware.Storage;
13-
using OpenHardwareMonitor.UI.Themes;
1413
using OpenHardwareMonitor.Utilities;
1514
using OpenHardwareMonitor.WMI;
16-
using sergiye.Common;
1715

1816
namespace OpenHardwareMonitor.UI;
1917

@@ -123,7 +121,7 @@ public MainForm()
123121
_systemTray.HideShowCommand += HideShowClick;
124122
_systemTray.ExitCommand += ExitClick;
125123

126-
if (Software.OperatingSystem.IsUnix)
124+
if (OperatingSystemHelper.IsUnix)
127125
{
128126
// Unix
129127
treeView.RowHeight = Math.Max(treeView.RowHeight, 18);
@@ -543,6 +541,7 @@ private void InitializeTheme()
543541
treeContextMenu.Renderer = new ThemedToolStripRenderer();
544542
ThemedVScrollIndicator.AddToControl(treeView);
545543
ThemedHScrollIndicator.AddToControl(treeView);
544+
TreeViewAdvThemeExtender.SubscribeToThemes();
546545

547546
if (Theme.SupportsAutoThemeSwitching())
548547
{
@@ -556,16 +555,13 @@ private void InitializeTheme()
556555
themeMenuItem.DropDownItems.Add(_autoThemeMenuItem);
557556
}
558557

559-
Theme setTheme = Theme.All.FirstOrDefault(theme => _settings.GetValue("theme", "auto") == theme.Id);
558+
var allThemes = CustomTheme.GetAllThemes("themes", "OpenHardwareMonitor.Resources.themes").OrderBy(x => x.DisplayName).ToList();
559+
Theme setTheme = allThemes.FirstOrDefault(theme => _settings.GetValue("theme", "auto") == theme.Id);
560560
if (setTheme != null)
561561
{
562562
Theme.Current = setTheme;
563563
Theme.Current.Apply(this);
564564
}
565-
else
566-
{
567-
themeMenuItem.DropDownItems[0].PerformClick();
568-
}
569565

570566
void AddThemeMenuItems(IEnumerable<Theme> themes)
571567
{
@@ -583,9 +579,14 @@ void AddThemeMenuItems(IEnumerable<Theme> themes)
583579
}
584580
}
585581

586-
AddThemeMenuItems(Theme.All.Where(t => t is not CustomTheme));
582+
AddThemeMenuItems(allThemes.Where(t => t is not CustomTheme));
587583
themeMenuItem.DropDownItems.Add("-"); //separator
588-
AddThemeMenuItems(Theme.All.Where(t => t is CustomTheme));
584+
AddThemeMenuItems(allThemes.Where(t => t is CustomTheme));
585+
586+
if (setTheme == null && themeMenuItem.DropDownItems.Count > 0)
587+
{
588+
themeMenuItem.DropDownItems[0].PerformClick();
589+
}
589590
}
590591

591592
private void OnThemeMenuItemClick(object sender, EventArgs e)
@@ -714,12 +715,22 @@ private void MainForm_Load(object sender, EventArgs e)
714715
RestoreCollapsedNodeState(treeView);
715716
treeView.Width += 1; //just to apply column auto-resize
716717

718+
Updater.Subscribe(
719+
(message, isError) => {
720+
MessageBox.Show(message, Updater.ApplicationName, MessageBoxButtons.OK, isError ? MessageBoxIcon.Warning : MessageBoxIcon.Information);
721+
},
722+
(message) => {
723+
return MessageBox.Show(message, Updater.ApplicationName, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK;
724+
},
725+
Application.Exit
726+
);
727+
717728
//will display prompt only if update available & when main form displayed
718729
var timer = new Timer();
719730
timer.Interval = 3000;
720731
timer.Tick += async (_, _) => {
721732
timer.Enabled = false;
722-
timer.Enabled = ! await Updater.CheckForUpdatesAsync(true).ConfigureAwait(false);
733+
timer.Enabled = ! await Updater.CheckForUpdatesAsync(true);
723734
};
724735
timer.Enabled = true;
725736

0 commit comments

Comments
 (0)