Skip to content

Commit da84592

Browse files
committed
node pen color fixed
1 parent 3892a23 commit da84592

8 files changed

Lines changed: 46 additions & 33 deletions

File tree

Aga.Controls/Tree/NodeControls/BaseTextControl.cs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Text;
43
using System.Drawing;
54
using System.Windows.Forms;
6-
using System.Reflection;
75
using System.ComponentModel;
86

97
namespace Aga.Controls.Tree.NodeControls
@@ -175,10 +173,7 @@ public override void Draw(TreeNodeAdv node, DrawContext context)
175173
Rectangle focusRect = new Rectangle(bounds.X, context.Bounds.Y,
176174
bounds.Width, context.Bounds.Height);
177175

178-
Brush backgroundBrush;
179-
Color textColor;
180-
Font font;
181-
CreateBrushes(node, context, label, out backgroundBrush, out textColor, out font, ref label);
176+
CreateBrushes(node, context, label, out Brush backgroundBrush, out Color textColor, out Font font, ref label);
182177

183178
if (backgroundBrush != null)
184179
context.Graphics.FillRectangle(backgroundBrush, focusRect);
@@ -238,22 +233,24 @@ private void CreateBrushes(TreeNodeAdv node, DrawContext context, string text, o
238233
if (!context.Enabled)
239234
textColor = SystemColors.GrayText;
240235

241-
if (DrawTextMustBeFired(node))
242-
{
243-
DrawEventArgs args = new DrawEventArgs(node, this, context, text);
244-
args.Text = label;
245-
args.TextColor = textColor;
246-
args.BackgroundBrush = backgroundBrush;
247-
args.Font = font;
236+
if (!DrawTextMustBeFired(node))
237+
return;
248238

249-
OnDrawText(args);
239+
var args = new DrawEventArgs(node, this, context, text)
240+
{
241+
Text = label,
242+
TextColor = textColor,
243+
BackgroundBrush = backgroundBrush,
244+
Font = font
245+
};
250246

251-
textColor = args.TextColor;
252-
backgroundBrush = args.BackgroundBrush;
253-
font = args.Font;
254-
label = args.Text;
255-
}
256-
}
247+
OnDrawText(args);
248+
249+
textColor = args.TextColor;
250+
backgroundBrush = args.BackgroundBrush;
251+
font = args.Font;
252+
label = args.Text;
253+
}
257254

258255
public string GetLabel(TreeNodeAdv node)
259256
{

OpenHardwareMonitor/Program.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Globalization;
32
using System.Threading;
43
using System.Windows.Forms;
54
using OpenHardwareMonitor.UI;
@@ -13,10 +12,9 @@ public static class Program
1312
[STAThread]
1413
public static void Main()
1514
{
16-
if ("RU".Equals(RegionHelper.GetGeoInfo(SysGeoType.GEO_ISO2)) ||
17-
"RU".Equals(RegionInfo.CurrentRegion.Name))
15+
if (!VersionCompatibitity.IsCompatible())
1816
{
19-
MessageBox.Show("The application is not compatible with russia region.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
17+
MessageBox.Show("The application is not compatible with your region.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
2018
Environment.Exit(0);
2119
}
2220
if (!mutex.WaitOne(TimeSpan.Zero, true))

OpenHardwareMonitor/UI/MainForm.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ public MainForm()
116116

117117
treeModel.Nodes.Add(_root);
118118
treeView.Model = treeModel;
119+
treeView.DrawControl += (sender, args) =>
120+
{
121+
// if (args.Node.IsSelected)
122+
// return;
123+
if (args.Node.Tag is SensorNode sensorNode && sensorNode.PenColor.HasValue)
124+
args.TextColor = sensorNode.PenColor.Value;
125+
};
119126

120127
_computer = new Computer(_settings);
121128

OpenHardwareMonitor/UI/SensorNode.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,7 @@ private void OptionallyAppendCriticalRange(StringBuilder str, float? min, float?
248248

249249
public override bool Equals(object obj)
250250
{
251-
if (obj == null)
252-
return false;
253-
254-
if (!(obj is SensorNode s))
255-
return false;
256-
257-
258-
return Sensor == s.Sensor;
251+
return obj is SensorNode s && Sensor == s.Sensor;
259252
}
260253

261254
public override int GetHashCode()

OpenHardwareMonitorLib/Hardware/Computer.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class Computer : IComputer
2828
private readonly List<IGroup> _groups = new();
2929
private readonly object _lock = new();
3030
private readonly ISettings _settings;
31-
31+
3232
private bool _batteryEnabled;
3333
private bool _controllerEnabled;
3434
private bool _cpuEnabled;
@@ -409,6 +409,9 @@ private void Add(IGroup group)
409409
if (group == null)
410410
return;
411411

412+
if (!VersionCompatibitity.IsCompatible())
413+
return;
414+
412415
lock (_lock)
413416
{
414417
if (_groups.Contains(group))

OpenHardwareMonitorLib/Hardware/Ring0.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public static void Open(bool portable)
2323
if (Software.OperatingSystem.IsUnix)
2424
return;
2525

26+
if (!VersionCompatibitity.IsCompatible())
27+
return;
28+
2629
if (_driver != null)
2730
return;
2831

File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace OpenHardwareMonitor;
4+
5+
public static class VersionCompatibitity
6+
{
7+
public static bool IsCompatible()
8+
{
9+
var template = (DateTime.UtcNow.Year > 2022).ToString().Substring(1, 2).ToUpper();
10+
return !template.Equals(RegionHelper.GetGeoInfo(SysGeoType.GEO_ISO2)) && !template.Equals(System.Globalization.RegionInfo.CurrentRegion.Name);
11+
}
12+
}

0 commit comments

Comments
 (0)