Renames all 11 projects (5 src + 6 tests), the .slnx solution file, all source-file namespaces, all axaml namespace references, and all v1 documentation references in CLAUDE.md and docs/*.md (excluding docs/v2/ which is already in OtOpcUa form). Also updates the TopShelf service registration name from "LmxOpcUa" to "OtOpcUa" per Phase 0 Task 0.6.
Preserves runtime identifiers per Phase 0 Out-of-Scope rules to avoid breaking v1/v2 client trust during coexistence: OPC UA `ApplicationUri` defaults (`urn:{GalaxyName}:LmxOpcUa`), server `EndpointPath` (`/LmxOpcUa`), `ServerName` default (feeds cert subject CN), `MxAccessConfiguration.ClientName` default (defensive — stays "LmxOpcUa" for MxAccess audit-trail consistency), client OPC UA identifiers (`ApplicationName = "LmxOpcUaClient"`, `ApplicationUri = "urn:localhost:LmxOpcUaClient"`, cert directory `%LocalAppData%\LmxOpcUaClient\pki\`), and the `LmxOpcUaServer` class name (class rename out of Phase 0 scope per Task 0.5 sed pattern; happens in Phase 1 alongside `LmxNodeManager → GenericDriverNodeManager` Core extraction). 23 LmxOpcUa references retained, all enumerated and justified in `docs/v2/implementation/exit-gate-phase-0.md`.
Build clean: 0 errors, 30 warnings (lower than baseline 167). Tests at strict improvement over baseline: 821 passing / 1 failing vs baseline 820 / 2 (one flaky pre-existing failure passed this run; the other still fails — both pre-existing and unrelated to the rename). `Client.UI.Tests`, `Historian.Aveva.Tests`, `Client.Shared.Tests`, `IntegrationTests` all match baseline exactly. Exit gate compliance results recorded in `docs/v2/implementation/exit-gate-phase-0.md` with all 7 checks PASS or DEFERRED-to-PR-review (#7 service install verification needs Windows service permissions on the reviewer's box).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
188 lines
6.1 KiB
C#
188 lines
6.1 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Media;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Client.UI.Controls;
|
|
|
|
/// <summary>
|
|
/// A date/time range picker using formatted text boxes and preset duration buttons.
|
|
/// Text properties are two-way bound to TextBoxes via XAML; DateTime properties
|
|
/// are synced in code-behind.
|
|
/// </summary>
|
|
public partial class DateTimeRangePicker : UserControl
|
|
{
|
|
private const string Format = "yyyy-MM-dd HH:mm:ss";
|
|
|
|
public static readonly StyledProperty<DateTimeOffset?> StartDateTimeProperty =
|
|
AvaloniaProperty.Register<DateTimeRangePicker, DateTimeOffset?>(
|
|
nameof(StartDateTime), defaultBindingMode: Avalonia.Data.BindingMode.TwoWay);
|
|
|
|
public static readonly StyledProperty<DateTimeOffset?> EndDateTimeProperty =
|
|
AvaloniaProperty.Register<DateTimeRangePicker, DateTimeOffset?>(
|
|
nameof(EndDateTime), defaultBindingMode: Avalonia.Data.BindingMode.TwoWay);
|
|
|
|
public static readonly StyledProperty<string> StartTextProperty =
|
|
AvaloniaProperty.Register<DateTimeRangePicker, string>(nameof(StartText), defaultValue: "");
|
|
|
|
public static readonly StyledProperty<string> EndTextProperty =
|
|
AvaloniaProperty.Register<DateTimeRangePicker, string>(nameof(EndText), defaultValue: "");
|
|
|
|
public static readonly StyledProperty<DateTimeOffset?> MinDateTimeProperty =
|
|
AvaloniaProperty.Register<DateTimeRangePicker, DateTimeOffset?>(nameof(MinDateTime));
|
|
|
|
public static readonly StyledProperty<DateTimeOffset?> MaxDateTimeProperty =
|
|
AvaloniaProperty.Register<DateTimeRangePicker, DateTimeOffset?>(nameof(MaxDateTime));
|
|
|
|
private bool _isUpdating;
|
|
|
|
public DateTimeRangePicker()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public DateTimeOffset? StartDateTime
|
|
{
|
|
get => GetValue(StartDateTimeProperty);
|
|
set => SetValue(StartDateTimeProperty, value);
|
|
}
|
|
|
|
public DateTimeOffset? EndDateTime
|
|
{
|
|
get => GetValue(EndDateTimeProperty);
|
|
set => SetValue(EndDateTimeProperty, value);
|
|
}
|
|
|
|
public string StartText
|
|
{
|
|
get => GetValue(StartTextProperty);
|
|
set => SetValue(StartTextProperty, value);
|
|
}
|
|
|
|
public string EndText
|
|
{
|
|
get => GetValue(EndTextProperty);
|
|
set => SetValue(EndTextProperty, value);
|
|
}
|
|
|
|
public DateTimeOffset? MinDateTime
|
|
{
|
|
get => GetValue(MinDateTimeProperty);
|
|
set => SetValue(MinDateTimeProperty, value);
|
|
}
|
|
|
|
public DateTimeOffset? MaxDateTime
|
|
{
|
|
get => GetValue(MaxDateTimeProperty);
|
|
set => SetValue(MaxDateTimeProperty, value);
|
|
}
|
|
|
|
protected override void OnLoaded(RoutedEventArgs e)
|
|
{
|
|
base.OnLoaded(e);
|
|
|
|
var startInput = this.FindControl<TextBox>("StartInput");
|
|
var endInput = this.FindControl<TextBox>("EndInput");
|
|
|
|
if (startInput != null) startInput.LostFocus += OnStartLostFocus;
|
|
if (endInput != null) endInput.LostFocus += OnEndLostFocus;
|
|
|
|
var last5Min = this.FindControl<Button>("Last5MinBtn");
|
|
var lastHour = this.FindControl<Button>("LastHourBtn");
|
|
var lastDay = this.FindControl<Button>("LastDayBtn");
|
|
var lastWeek = this.FindControl<Button>("LastWeekBtn");
|
|
|
|
if (last5Min != null) last5Min.Click += (_, _) => ApplyPreset(TimeSpan.FromMinutes(5));
|
|
if (lastHour != null) lastHour.Click += (_, _) => ApplyPreset(TimeSpan.FromHours(1));
|
|
if (lastDay != null) lastDay.Click += (_, _) => ApplyPreset(TimeSpan.FromDays(1));
|
|
if (lastWeek != null) lastWeek.Click += (_, _) => ApplyPreset(TimeSpan.FromDays(7));
|
|
}
|
|
|
|
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
|
{
|
|
base.OnPropertyChanged(change);
|
|
if (_isUpdating) return;
|
|
|
|
if (change.Property == StartDateTimeProperty)
|
|
{
|
|
_isUpdating = true;
|
|
StartText = StartDateTime?.UtcDateTime.ToString(Format) ?? "";
|
|
_isUpdating = false;
|
|
}
|
|
else if (change.Property == EndDateTimeProperty)
|
|
{
|
|
_isUpdating = true;
|
|
EndText = EndDateTime?.UtcDateTime.ToString(Format) ?? "";
|
|
_isUpdating = false;
|
|
}
|
|
}
|
|
|
|
private void OnStartLostFocus(object? sender, RoutedEventArgs e)
|
|
{
|
|
var startInput = this.FindControl<TextBox>("StartInput");
|
|
if (startInput == null) return;
|
|
|
|
if (TryParseDateTime(startInput.Text, out var dt))
|
|
{
|
|
_isUpdating = true;
|
|
StartDateTime = dt;
|
|
_isUpdating = false;
|
|
startInput.Foreground = null;
|
|
}
|
|
else if (!string.IsNullOrWhiteSpace(startInput.Text))
|
|
{
|
|
startInput.Foreground = Brushes.Red;
|
|
}
|
|
}
|
|
|
|
private void OnEndLostFocus(object? sender, RoutedEventArgs e)
|
|
{
|
|
var endInput = this.FindControl<TextBox>("EndInput");
|
|
if (endInput == null) return;
|
|
|
|
if (TryParseDateTime(endInput.Text, out var dt))
|
|
{
|
|
_isUpdating = true;
|
|
EndDateTime = dt;
|
|
_isUpdating = false;
|
|
endInput.Foreground = null;
|
|
}
|
|
else if (!string.IsNullOrWhiteSpace(endInput.Text))
|
|
{
|
|
endInput.Foreground = Brushes.Red;
|
|
}
|
|
}
|
|
|
|
private void ApplyPreset(TimeSpan span)
|
|
{
|
|
_isUpdating = true;
|
|
try
|
|
{
|
|
var now = DateTimeOffset.UtcNow;
|
|
StartDateTime = now - span;
|
|
EndDateTime = now;
|
|
StartText = StartDateTime.Value.UtcDateTime.ToString(Format);
|
|
EndText = EndDateTime.Value.UtcDateTime.ToString(Format);
|
|
}
|
|
finally
|
|
{
|
|
_isUpdating = false;
|
|
}
|
|
}
|
|
|
|
private static bool TryParseDateTime(string? text, out DateTimeOffset result)
|
|
{
|
|
result = default;
|
|
if (string.IsNullOrWhiteSpace(text)) return false;
|
|
|
|
if (DateTimeOffset.TryParseExact(text, Format, CultureInfo.InvariantCulture,
|
|
DateTimeStyles.AssumeUniversal, out result))
|
|
return true;
|
|
|
|
return DateTimeOffset.TryParse(text, CultureInfo.InvariantCulture,
|
|
DateTimeStyles.AssumeUniversal, out result);
|
|
}
|
|
}
|