diff --git a/External/Aga.Controls.dll b/External/Aga.Controls.dll
index 82de1bb..404d3bb 100644
Binary files a/External/Aga.Controls.dll and b/External/Aga.Controls.dll differ
diff --git a/External/Aga.Controls/Aga.Controls.csproj b/External/Aga.Controls/Aga.Controls.csproj
index d0752da..e4bd3f4 100644
--- a/External/Aga.Controls/Aga.Controls.csproj
+++ b/External/Aga.Controls/Aga.Controls.csproj
@@ -91,6 +91,7 @@
+
diff --git a/External/Aga.Controls/Tree/MemberAdapter.cs b/External/Aga.Controls/Tree/MemberAdapter.cs
new file mode 100644
index 0000000..fb7a849
--- /dev/null
+++ b/External/Aga.Controls/Tree/MemberAdapter.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text;
+
+namespace Aga.Controls.Tree {
+ internal struct MemberAdapter
+ {
+ private object _obj;
+ private PropertyInfo _pi;
+ private FieldInfo _fi;
+
+ public static readonly MemberAdapter Empty = new MemberAdapter();
+
+ public Type MemberType
+ {
+ get
+ {
+ if (_pi != null)
+ return _pi.PropertyType;
+ else if (_fi != null)
+ return _fi.FieldType;
+ else
+ return null;
+ }
+ }
+
+ public object Value
+ {
+ get
+ {
+ if (_pi != null && _pi.CanRead)
+ return _pi.GetValue(_obj, null);
+ else if (_fi != null)
+ return _fi.GetValue(_obj);
+ else
+ return null;
+ }
+ set
+ {
+ if (_pi != null && _pi.CanWrite)
+ _pi.SetValue(_obj, value, null);
+ else if (_fi != null)
+ _fi.SetValue(_obj, value);
+ }
+ }
+
+ public MemberAdapter(object obj, PropertyInfo pi)
+ {
+ _obj = obj;
+ _pi = pi;
+ _fi = null;
+ }
+
+ public MemberAdapter(object obj, FieldInfo fi)
+ {
+ _obj = obj;
+ _fi = fi;
+ _pi = null;
+ }
+ }
+}
diff --git a/External/Aga.Controls/Tree/NodeControls/BindableControl.cs b/External/Aga.Controls/Tree/NodeControls/BindableControl.cs
index 5ce2c1e..6041e73 100644
--- a/External/Aga.Controls/Tree/NodeControls/BindableControl.cs
+++ b/External/Aga.Controls/Tree/NodeControls/BindableControl.cs
@@ -6,64 +6,10 @@ using System.ComponentModel;
namespace Aga.Controls.Tree.NodeControls
{
+
public abstract class BindableControl : NodeControl
{
- private struct MemberAdapter
- {
- private object _obj;
- private PropertyInfo _pi;
- private FieldInfo _fi;
-
- public static readonly MemberAdapter Empty = new MemberAdapter();
-
- public Type MemberType
- {
- get
- {
- if (_pi != null)
- return _pi.PropertyType;
- else if (_fi != null)
- return _fi.FieldType;
- else
- return null;
- }
- }
-
- public object Value
- {
- get
- {
- if (_pi != null && _pi.CanRead)
- return _pi.GetValue(_obj, null);
- else if (_fi != null)
- return _fi.GetValue(_obj);
- else
- return null;
- }
- set
- {
- if (_pi != null && _pi.CanWrite)
- _pi.SetValue(_obj, value, null);
- else if (_fi != null)
- _fi.SetValue(_obj, value);
- }
- }
-
- public MemberAdapter(object obj, PropertyInfo pi)
- {
- _obj = obj;
- _pi = pi;
- _fi = null;
- }
-
- public MemberAdapter(object obj, FieldInfo fi)
- {
- _obj = obj;
- _fi = fi;
- _pi = null;
- }
- }
-
+
#region Properties
private bool _virtualMode = false;
diff --git a/External/Aga.Controls/Tree/TreeNodeAdv.cs b/External/Aga.Controls/Tree/TreeNodeAdv.cs
index b9dea86..b11fb28 100644
--- a/External/Aga.Controls/Tree/TreeNodeAdv.cs
+++ b/External/Aga.Controls/Tree/TreeNodeAdv.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Reflection;
using System.Runtime.Serialization;
using System.Security.Permissions;
@@ -205,7 +206,12 @@ namespace Aga.Controls.Tree
internal void AssignIsExpanded(bool value)
{
- _isExpanded = value;
+ if (_isExpanded != value)
+ {
+ _isExpanded = value;
+ var ma = GetMemberAdapter("IsExpanded");
+ ma.Value = value;
+ }
}
private TreeNodeAdv _parent;
@@ -336,7 +342,7 @@ namespace Aga.Controls.Tree
set { _isExpandingNow = value; }
}
- private bool _autoExpandOnStructureChanged = true;
+ private bool _autoExpandOnStructureChanged = false;
public bool AutoExpandOnStructureChanged
{
get { return _autoExpandOnStructureChanged; }
@@ -357,6 +363,12 @@ namespace Aga.Controls.Tree
_nodes = new NodeCollection(this);
_children = new ReadOnlyCollection(_nodes);
_tag = tag;
+
+ var value = GetMemberAdapter("IsExpanded").Value;
+ if (value != null && value is bool)
+ {
+ _isExpanded = (bool)value;
+ }
}
public override string ToString()
@@ -402,11 +414,29 @@ namespace Aga.Controls.Tree
private void SetIsExpanded(bool value, bool ignoreChildren)
{
if (Tree == null)
- _isExpanded = value;
+ AssignIsExpanded(value);
else
Tree.SetIsExpanded(this, value, ignoreChildren);
}
+ private MemberAdapter GetMemberAdapter(string propertyName)
+ {
+ if (this.Tag != null && !string.IsNullOrEmpty(propertyName))
+ {
+ Type type = this.Tag.GetType();
+ PropertyInfo pi = type.GetProperty(propertyName);
+ if (pi != null)
+ return new MemberAdapter(this.Tag, pi);
+ else
+ {
+ FieldInfo fi = type.GetField(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ if (fi != null)
+ return new MemberAdapter(this.Tag, fi);
+ }
+ }
+ return MemberAdapter.Empty;
+ }
+
#region ISerializable Members
private TreeNodeAdv(SerializationInfo info, StreamingContext context)
diff --git a/GUI/HardwareNode.cs b/GUI/HardwareNode.cs
index a68289e..f81211a 100644
--- a/GUI/HardwareNode.cs
+++ b/GUI/HardwareNode.cs
@@ -4,21 +4,21 @@
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
- Copyright (C) 2009-2012 Michael Möller
+ Copyright (C) 2009-2020 Michael Möller
*/
using System;
using System.Collections.Generic;
-using System.Drawing;
using OpenHardwareMonitor.Hardware;
namespace OpenHardwareMonitor.GUI {
public class HardwareNode : Node {
- private PersistentSettings settings;
- private UnitManager unitManager;
- private IHardware hardware;
+ private readonly PersistentSettings settings;
+ private readonly UnitManager unitManager;
+ private readonly IHardware hardware;
+ private readonly Identifier expandedIdentifier;
private List typeNodes = new List();
@@ -31,13 +31,17 @@ namespace OpenHardwareMonitor.GUI {
this.Image = HardwareTypeImage.Instance.GetImage(hardware.HardwareType);
foreach (SensorType sensorType in Enum.GetValues(typeof(SensorType)))
- typeNodes.Add(new TypeNode(sensorType));
+ typeNodes.Add(new TypeNode(sensorType, hardware, settings));
foreach (ISensor sensor in hardware.Sensors)
SensorAdded(sensor);
hardware.SensorAdded +=new SensorEventHandler(SensorAdded);
hardware.SensorRemoved += new SensorEventHandler(SensorRemoved);
+
+ this.expandedIdentifier = new Identifier(hardware.Identifier, "expanded");
+ base.IsExpanded =
+ settings.GetValue(expandedIdentifier.ToString(), base.IsExpanded);
}
public override string Text {
@@ -49,6 +53,18 @@ namespace OpenHardwareMonitor.GUI {
get { return hardware; }
}
+ public override bool IsExpanded {
+ get {
+ return base.IsExpanded;
+ }
+ set {
+ if (base.IsExpanded != value) {
+ base.IsExpanded = value;
+ settings.SetValue(expandedIdentifier.ToString(), value);
+ }
+ }
+ }
+
private void UpdateNode(TypeNode node) {
if (node.Nodes.Count > 0) {
if (!Nodes.Contains(node)) {
diff --git a/GUI/Node.cs b/GUI/Node.cs
index 02750c6..4c23fe8 100644
--- a/GUI/Node.cs
+++ b/GUI/Node.cs
@@ -4,7 +4,7 @@
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
- Copyright (C) 2009-2010 Michael Möller
+ Copyright (C) 2009-2020 Michael Möller
*/
@@ -25,6 +25,7 @@ namespace OpenHardwareMonitor.GUI {
private string text;
private Image image;
private bool visible;
+ private bool expanded;
private TreeModel RootTreeModel() {
Node node = this;
@@ -42,6 +43,7 @@ namespace OpenHardwareMonitor.GUI {
this.text = text;
this.nodes = new NodeCollection(this);
this.visible = true;
+ this.expanded = true;
}
public TreeModel Model {
@@ -83,6 +85,17 @@ namespace OpenHardwareMonitor.GUI {
}
}
+ public virtual bool IsExpanded {
+ get {
+ return expanded;
+ }
+ set {
+ if (value != expanded) {
+ expanded = value;
+ }
+ }
+ }
+
public virtual bool IsVisible {
get { return visible; }
set {
diff --git a/GUI/TypeNode.cs b/GUI/TypeNode.cs
index 420c750..b95e95f 100644
--- a/GUI/TypeNode.cs
+++ b/GUI/TypeNode.cs
@@ -4,21 +4,26 @@
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
- Copyright (C) 2009-2012 Michael Möller
+ Copyright (C) 2009-2020 Michael Möller
*/
-using System;
-using System.Collections.Generic;
using OpenHardwareMonitor.Hardware;
namespace OpenHardwareMonitor.GUI {
public class TypeNode : Node {
- private SensorType sensorType;
+ private readonly PersistentSettings settings;
+ private readonly SensorType sensorType;
+ private readonly IHardware hardware;
+ private readonly Identifier expandedIdentifier;
- public TypeNode(SensorType sensorType) : base() {
+ public TypeNode(SensorType sensorType, IHardware hardware,
+ PersistentSettings settings) : base()
+ {
+ this.settings = settings;
this.sensorType = sensorType;
+ this.hardware = hardware;
switch (sensorType) {
case SensorType.Voltage:
@@ -77,6 +82,11 @@ namespace OpenHardwareMonitor.GUI {
NodeAdded += new NodeEventHandler(TypeNode_NodeAdded);
NodeRemoved += new NodeEventHandler(TypeNode_NodeRemoved);
+
+ this.expandedIdentifier = new Identifier(new Identifier(hardware.Identifier,
+ sensorType.ToString().ToLowerInvariant()), "expanded");
+ base.IsExpanded =
+ settings.GetValue(expandedIdentifier.ToString(), base.IsExpanded);
}
private void TypeNode_NodeRemoved(Node node) {
@@ -101,5 +111,17 @@ namespace OpenHardwareMonitor.GUI {
public SensorType SensorType {
get { return sensorType; }
}
+
+ public override bool IsExpanded {
+ get {
+ return base.IsExpanded;
+ }
+ set {
+ if (base.IsExpanded != value) {
+ base.IsExpanded = value;
+ settings.SetValue(expandedIdentifier.ToString(), value);
+ }
+ }
+ }
}
}