Skip to content

Commit d46b78c

Browse files
authored
Merge pull request #31 from USACE-RMC/bug-fixes-and-enhancements
Optimize time-series validation and prepare v1.0.2 release
2 parents 14c7db9 + 0e94409 commit d46b78c

20 files changed

Lines changed: 388 additions & 79 deletions

‎CITATION.cff‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cff-version: 1.2.0
22
message: "If you use this software, please cite it as below."
33
type: software
44
title: "WPF Framework"
5-
version: "1.0.1"
5+
version: "1.0.2"
66
date-released: "2026-07-10"
77
license: 0BSD
88
repository-code: "https://github.com/USACE-RMC/WPF-Framework"

‎Directory.Build.props‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
<PackageProjectUrl>https://github.com/USACE-RMC/WPF-Framework</PackageProjectUrl>
1515
<RepositoryUrl>https://github.com/USACE-RMC/WPF-Framework</RepositoryUrl>
1616
<RepositoryType>git</RepositoryType>
17-
<Version>1.0.1</Version>
18-
<AssemblyVersion>1.0.1.0</AssemblyVersion>
19-
<FileVersion>1.0.1.0</FileVersion>
17+
<Version>1.0.2</Version>
18+
<AssemblyVersion>1.0.2.0</AssemblyVersion>
19+
<FileVersion>1.0.2.0</FileVersion>
2020

2121
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
2222
<IsPackable>false</IsPackable>

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ dotnet test WPF-Framework.sln
5151
### Build Packages
5252

5353
```bash
54-
.\scripts\pack-wpf-framework.ps1 -Configuration Release -Version 1.0.1
54+
.\scripts\pack-wpf-framework.ps1 -Configuration Release -Version 1.0.2
5555
```
5656

5757
This creates and validates the following NuGet packages in `artifacts/packages/`:

‎codemeta.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"@type": "SoftwareSourceCode",
44
"name": "WPF Framework",
55
"description": "A free and open-source .NET 10 application framework for building Windows desktop project management applications. Provides a docking application shell with theming, project explorer, undo/redo, and specialized controls for charting, numeric input, databases, expression parsing, and directed acyclic graphs.",
6-
"version": "1.0.1",
6+
"version": "1.0.2",
77
"dateCreated": "2025-12-29",
88
"dateModified": "2026-07-10",
99
"license": "https://spdx.org/licenses/0BSD",

‎docs/getting-started.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ For NuGet consumption, reference the Controls bundle. It brings in Core, Models,
3030

3131
```xml
3232
<ItemGroup>
33-
<PackageReference Include="RMC.Wpf.Framework.Controls" Version="1.0.1" />
33+
<PackageReference Include="RMC.Wpf.Framework.Controls" Version="1.0.2" />
3434
</ItemGroup>
3535
```
3636

‎scripts/pack-wpf-framework.ps1‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ $expectedEntries = @{
7777
}
7878

7979
$expectedReleaseNotes = @{
80-
"RMC.Wpf.Framework.Core" = "Coordinated WPF Framework 1.0.1 release; no package-specific functional changes."
81-
"RMC.Wpf.Framework.Models" = "Coordinated WPF Framework 1.0.1 release; no package-specific functional changes."
82-
"RMC.Wpf.Framework.Support" = "Version 1.0.1 protects settings and runtime data during updates, supports transactional rollback, checksum enforcement, and safe replacement of the installed updater payload."
83-
"RMC.Wpf.Framework.Controls" = "Version 1.0.1 improves irregular time-series ordering validation and defaults new OxyPlot line annotations to editable text."
80+
"RMC.Wpf.Framework.Core" = "Coordinated WPF Framework 1.0.2 release; no package-specific functional changes."
81+
"RMC.Wpf.Framework.Models" = "Coordinated WPF Framework 1.0.2 release; no package-specific functional changes."
82+
"RMC.Wpf.Framework.Support" = "Version 1.0.2 carries forward protected, transactional self-updates and ships a version-aligned updater payload."
83+
"RMC.Wpf.Framework.Controls" = "Version 1.0.2 improves time-series table validation performance, preserves ordering checks after edits, and avoids repeated full-table scans while rebuilding large series."
8484
}
8585

8686
foreach ($packageId in $expectedEntries.Keys) {

‎src/GenericControls/DataGrid/ValidationDataGrid.cs‎

Lines changed: 108 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,39 @@ namespace GenericControls
2727
public sealed class ValidationDataGrid : CopyPasteDataGrid
2828
{
2929

30+
/// <summary>
31+
/// Restores validation when a suspension scope is disposed.
32+
/// </summary>
33+
private sealed class ValidationSuspension : IDisposable
34+
{
35+
private ValidationDataGrid _owner;
36+
private readonly bool _validateOnResume;
37+
38+
/// <summary>
39+
/// Initializes a new validation suspension scope.
40+
/// </summary>
41+
/// <param name="owner">The grid whose validation is suspended.</param>
42+
/// <param name="validateOnResume">Whether to request validation after the outermost scope is disposed.</param>
43+
public ValidationSuspension(ValidationDataGrid owner, bool validateOnResume)
44+
{
45+
_owner = owner;
46+
_validateOnResume = validateOnResume;
47+
}
48+
49+
/// <summary>
50+
/// Releases this suspension scope and optionally requests deferred validation.
51+
/// </summary>
52+
public void Dispose()
53+
{
54+
ValidationDataGrid owner = _owner;
55+
if (owner == null)
56+
return;
57+
58+
_owner = null;
59+
owner.ResumeValidation(_validateOnResume);
60+
}
61+
}
62+
3063
#region Construction
3164
/// <summary>
3265
/// Initializes a new instance of the <see cref="ValidationDataGrid"/> class.
@@ -68,6 +101,10 @@ public ValidationDataGrid()
68101

69102
private Dictionary<string, Type> _propertyTypes = new Dictionary<string, Type>();
70103

104+
private int _validationSuspensionCount;
105+
private bool _operationValidationSuppressed;
106+
private bool _validationRequestedOnResume;
107+
71108

72109
/// <summary>
73110
/// Identifies the <see cref="ErrorCellBorderBrush"/> dependency property.
@@ -113,7 +150,7 @@ public Brush ErrorCellBackgroundBrush
113150
/// <summary>
114151
/// Gets a value indicating whether validation should be suppressed.
115152
/// </summary>
116-
public bool SuppressValidation { get; private set; } = false;
153+
public bool SuppressValidation => _operationValidationSuppressed || _validationSuspensionCount > 0;
117154

118155

119156
/// <summary>
@@ -125,6 +162,51 @@ public Brush ErrorCellBackgroundBrush
125162

126163
#region Methods
127164

165+
/// <summary>
166+
/// Suspends row validation until the returned scope is disposed.
167+
/// </summary>
168+
/// <param name="validateOnResume">Whether to validate once after the outermost suspension scope is disposed.</param>
169+
/// <returns>An exception-safe scope that restores validation when disposed.</returns>
170+
/// <remarks>
171+
/// Scopes may be nested. Validation requested while suspended is deferred until both
172+
/// scoped and grid-operation suppression have ended.
173+
/// </remarks>
174+
public IDisposable SuspendValidation(bool validateOnResume = true)
175+
{
176+
_validationSuspensionCount++;
177+
return new ValidationSuspension(this, validateOnResume);
178+
}
179+
180+
/// <summary>
181+
/// Releases one validation suspension and runs any requested validation after the outermost scope.
182+
/// </summary>
183+
/// <param name="validateOnResume">Whether this scope requests validation on resume.</param>
184+
private void ResumeValidation(bool validateOnResume)
185+
{
186+
if (_validationSuspensionCount <= 0)
187+
return;
188+
189+
if (validateOnResume)
190+
{
191+
_validationRequestedOnResume = true;
192+
}
193+
194+
_validationSuspensionCount--;
195+
TryRunDeferredValidation();
196+
}
197+
198+
/// <summary>
199+
/// Runs a deferred validation request when no suppression remains active.
200+
/// </summary>
201+
private void TryRunDeferredValidation()
202+
{
203+
if (SuppressValidation || !_validationRequestedOnResume)
204+
return;
205+
206+
_validationRequestedOnResume = false;
207+
ValidateTable();
208+
}
209+
128210
/// <summary>
129211
/// Determines whether the BeginEdit command can execute.
130212
/// </summary>
@@ -450,24 +532,32 @@ private void Grid_RowsAdded(int startrow, int numrows)
450532
public void ValidateTable()
451533
{
452534
if (SuppressValidation == true)
535+
{
536+
_validationRequestedOnResume = true;
453537
return;
538+
}
454539
if (ItemsSource == null)
455540
return;
456541
IList<object> itemsList = (IList<object>)ItemsSource;
457542
if (itemsList.Count == 0)
458543
return;
459544
// Do bulk validation
460545
PerformingBulkValidation = true;
461-
DataGridRowItem rowitem;
462-
for (int i = 0, loopTo = itemsList.Count - 1; i <= loopTo; i++)
546+
try
463547
{
464-
if (!(itemsList[i] is DataGridRowItem))
465-
continue;
466-
rowitem = (DataGridRowItem)itemsList[i];
467-
rowitem.ForceValidation();
548+
DataGridRowItem rowitem;
549+
for (int i = 0, loopTo = itemsList.Count - 1; i <= loopTo; i++)
550+
{
551+
if (!(itemsList[i] is DataGridRowItem))
552+
continue;
553+
rowitem = (DataGridRowItem)itemsList[i];
554+
rowitem.ForceValidation();
555+
}
556+
}
557+
finally
558+
{
559+
PerformingBulkValidation = false;
468560
}
469-
PerformingBulkValidation = false;
470-
SuppressValidation = false;
471561
// Validate the first row.
472562
// This fires the unique rule if it is used.
473563
// Guard with the same is-check used in the loop: non-DataGridRowItem sources
@@ -486,16 +576,17 @@ public void ValidateTable()
486576
/// <param name="cancelPaste">Reference to a flag that can cancel the paste operation.</param>
487577
private void Grid_PreviewPasteData(string[][] clipboardData, ref bool cancelPaste)
488578
{
489-
SuppressValidation = true;
579+
_operationValidationSuppressed = true;
490580
}
491581

492582
/// <summary>
493583
/// Validates the table after pasting data.
494584
/// </summary>
495585
private void Grid_DataPasted()
496586
{
497-
SuppressValidation = false;
498-
ValidateTable();
587+
_operationValidationSuppressed = false;
588+
_validationRequestedOnResume = true;
589+
TryRunDeferredValidation();
499590
}
500591

501592
/// <summary>
@@ -505,7 +596,7 @@ private void Grid_DataPasted()
505596
/// <param name="cancel">Reference to a flag that can cancel the delete operation.</param>
506597
private void Grid_PreviewDeleteRows(List<int> rowindices, ref bool cancel)
507598
{
508-
SuppressValidation = true;
599+
_operationValidationSuppressed = true;
509600
}
510601

511602
/// <summary>
@@ -514,11 +605,12 @@ private void Grid_PreviewDeleteRows(List<int> rowindices, ref bool cancel)
514605
/// <param name="rowindices">The indices of the rows that were deleted.</param>
515606
private void Grid_RowsDeleted(List<int> rowindices)
516607
{
517-
SuppressValidation = false;
518-
ValidateTable();
608+
_operationValidationSuppressed = false;
609+
_validationRequestedOnResume = true;
610+
TryRunDeferredValidation();
519611
}
520612

521613
#endregion
522614

523615
}
524-
}
616+
}

‎src/NumericControls/Data/Time Series Editor/TimeSeriesRowItem.cs‎

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public TimeSeriesRowItem() : base(null) { }
3434
/// <param name="ordinate">The time series ordinate to be wrapped by this row item.</param>
3535
/// <param name="series">The time series collection that contains the ordinate, used for clone-and-replace on edits.</param>
3636
/// <param name="index">The positional index of this ordinate within the series, used for O(1) replacement.</param>
37-
public TimeSeriesRowItem(ObservableCollection<object> observableCollection, SeriesOrdinate<DateTime, double> ordinate, TimeSeries series, int index) : base(observableCollection)
37+
/// <param name="parentDataGrid">The parent validation grid used to honor bulk validation suppression.</param>
38+
public TimeSeriesRowItem(ObservableCollection<object> observableCollection, SeriesOrdinate<DateTime, double> ordinate, TimeSeries series, int index, ValidationDataGrid parentDataGrid = null) : base(observableCollection, parentDataGrid)
3839
{
3940
_ordinate = ordinate;
4041
_series = series;
@@ -136,6 +137,24 @@ private void ReplaceOrdinate(SeriesOrdinate<DateTime, double> newOrdinate)
136137
}
137138
}
138139

140+
/// <summary>
141+
/// Determines whether this ordinate violates strict ascending date-time order.
142+
/// </summary>
143+
/// <returns><see langword="true"/> when the current date-time is less than or equal to its predecessor; otherwise, <see langword="false"/>.</returns>
144+
/// <remarks>
145+
/// The stored positional index makes this check O(1). Searching the parent row collection
146+
/// for every row makes full-table validation O(n²) for large irregular series.
147+
/// </remarks>
148+
private bool IsDateTimeOutOfOrder()
149+
{
150+
if (_series == null || _series.TimeInterval != TimeInterval.Irregular)
151+
return false;
152+
if (_index <= 0 || _index >= _series.Count)
153+
return false;
154+
155+
return _ordinate.Index <= _series[_index - 1].Index;
156+
}
157+
139158
/// <summary>
140159
/// Adds validation rules for the time series row item properties.
141160
/// Validates that irregular date-time entries are in ascending data order
@@ -144,16 +163,9 @@ private void ReplaceOrdinate(SeriesOrdinate<DateTime, double> newOrdinate)
144163
public override void AddValidationRules()
145164
{
146165
AddRule(nameof(DateTime),
147-
() => _series != null
148-
&& _series.TimeInterval == TimeInterval.Irregular
149-
&& OrderRule<DateTime, TimeSeriesRowItem>(
150-
row => row.DateTime.Ticks,
151-
nameof(DateTime),
152-
ascending: true,
153-
canBeEqual: false),
154-
"Date/time values must be in ascending data order. Grid sorting does not reorder the time series used by the plot.",
155-
new[] { nameof(DateTime) });
156-
AddRule(nameof(Value), () => double.IsInfinity(Value), "The value must be a finite number.", new[] { nameof(Value) });
166+
IsDateTimeOutOfOrder,
167+
"Date/time values must be in ascending data order. Grid sorting does not reorder the time series used by the plot.");
168+
AddRule(nameof(Value), () => double.IsInfinity(Value), "The value must be a finite number.");
157169
}
158170

159171
/// <summary>

0 commit comments

Comments
 (0)