chore: organize solution into module folders (Core/Server/Drivers/Client/Tooling)
Group all 69 projects into category subfolders under src/ and tests/ so the Rider Solution Explorer mirrors the module structure. Folders: Core, Server, Drivers (with a nested Driver CLIs subfolder), Client, Tooling. - Move every project folder on disk with git mv (history preserved as renames). - Recompute relative paths in 57 .csproj files: cross-category ProjectReferences, the lib/ HintPath+None refs in Driver.Historian.Wonderware, and the external mxaccessgw refs in Driver.Galaxy and its test project. - Rebuild ZB.MOM.WW.OtOpcUa.slnx with nested solution folders. - Re-prefix project paths in functional scripts (e2e, compliance, smoke SQL, integration, install). Build green (0 errors); unit tests pass. Docs left for a separate pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using ZB.MOM.WW.OtOpcUa.Client.Shared;
|
||||
using ZB.MOM.WW.OtOpcUa.Client.UI.Services;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Client.UI.ViewModels;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a single node in the OPC UA browse tree with lazy-load support.
|
||||
/// </summary>
|
||||
public partial class TreeNodeViewModel : ObservableObject
|
||||
{
|
||||
private static readonly TreeNodeViewModel PlaceholderSentinel = new();
|
||||
private readonly IUiDispatcher? _dispatcher;
|
||||
|
||||
private readonly IOpcUaClientService? _service;
|
||||
private bool _hasLoadedChildren;
|
||||
|
||||
[ObservableProperty] private bool _isExpanded;
|
||||
|
||||
[ObservableProperty] private bool _isLoading;
|
||||
|
||||
/// <summary>
|
||||
/// Private constructor for the placeholder sentinel only.
|
||||
/// </summary>
|
||||
private TreeNodeViewModel()
|
||||
{
|
||||
NodeId = string.Empty;
|
||||
DisplayName = "Loading...";
|
||||
NodeClass = string.Empty;
|
||||
HasChildren = false;
|
||||
}
|
||||
|
||||
public TreeNodeViewModel(
|
||||
string nodeId,
|
||||
string displayName,
|
||||
string nodeClass,
|
||||
bool hasChildren,
|
||||
IOpcUaClientService service,
|
||||
IUiDispatcher dispatcher)
|
||||
{
|
||||
NodeId = nodeId;
|
||||
DisplayName = displayName;
|
||||
NodeClass = nodeClass;
|
||||
HasChildren = hasChildren;
|
||||
_service = service;
|
||||
_dispatcher = dispatcher;
|
||||
|
||||
if (hasChildren) Children.Add(PlaceholderSentinel);
|
||||
}
|
||||
|
||||
/// <summary>The string NodeId of this node.</summary>
|
||||
public string NodeId { get; }
|
||||
|
||||
/// <summary>The display name shown in the tree.</summary>
|
||||
public string DisplayName { get; }
|
||||
|
||||
/// <summary>The OPC UA node class (Object, Variable, etc.).</summary>
|
||||
public string NodeClass { get; }
|
||||
|
||||
/// <summary>Whether this node has child references.</summary>
|
||||
public bool HasChildren { get; }
|
||||
|
||||
/// <summary>Child nodes (may contain a placeholder sentinel before first expand).</summary>
|
||||
public ObservableCollection<TreeNodeViewModel> Children { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether this node instance is the placeholder sentinel.
|
||||
/// </summary>
|
||||
internal bool IsPlaceholder => ReferenceEquals(this, PlaceholderSentinel);
|
||||
|
||||
partial void OnIsExpandedChanged(bool value)
|
||||
{
|
||||
if (value && !_hasLoadedChildren && HasChildren) _ = LoadChildrenAsync();
|
||||
}
|
||||
|
||||
private async Task LoadChildrenAsync()
|
||||
{
|
||||
if (_service == null || _dispatcher == null) return;
|
||||
|
||||
_hasLoadedChildren = true;
|
||||
IsLoading = true;
|
||||
|
||||
try
|
||||
{
|
||||
var nodeId = Opc.Ua.NodeId.Parse(NodeId);
|
||||
var results = await _service.BrowseAsync(nodeId);
|
||||
|
||||
_dispatcher.Post(() =>
|
||||
{
|
||||
Children.Clear();
|
||||
foreach (var result in results)
|
||||
Children.Add(new TreeNodeViewModel(
|
||||
result.NodeId,
|
||||
result.DisplayName,
|
||||
result.NodeClass,
|
||||
result.HasChildren,
|
||||
_service,
|
||||
_dispatcher));
|
||||
});
|
||||
}
|
||||
catch
|
||||
{
|
||||
_dispatcher.Post(() => Children.Clear());
|
||||
}
|
||||
finally
|
||||
{
|
||||
_dispatcher.Post(() => IsLoading = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user