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,187 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user