diff --git a/CITATION.cff b/CITATION.cff index 388eadd3..4d7622f5 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -4,7 +4,7 @@ type: software title: "WPF Framework" version: "1.0.0" date-released: "2026-04-29" -license: BSD-3-Clause +license: 0BSD repository-code: "https://github.com/USACE-RMC/WPF-Framework" url: "https://github.com/USACE-RMC/WPF-Framework" abstract: >- diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b8f02eec..6d0dc746 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,4 +57,4 @@ If you discover a security vulnerability, please do **not** open a public issue. ## License -See [LICENSE](LICENSE) for details. This software is provided by USACE-RMC under a BSD-style license with a no-endorsement clause. +See [LICENSE](LICENSE) for details. This software is provided under the Zero-Clause BSD (0BSD) license. diff --git a/Directory.Build.props b/Directory.Build.props index 06da98c8..d3b6ee2f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,6 @@ C. Haden Smith, Woodrow L. Fields, Julian Gonzalez USACE-RMC WPF Framework - Copyright (c) 2026 U.S. Army Corps of Engineers, Risk Management Center https://github.com/USACE-RMC/WPF-Framework https://github.com/USACE-RMC/WPF-Framework git @@ -23,9 +22,8 @@ true embedded - LICENSE + 0BSD README.md - true diff --git a/LICENSE b/LICENSE index 73a797ee..d61efa4a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,12 +1,10 @@ -NOTICE: -The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about the results, or appropriateness of outputs, obtained from WPF Framework. - -LIST OF CONDITIONS: -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -* Redistributions of source code must retain the above notice, this list of conditions, and the following disclaimer. -* Redistributions in binary form must reproduce the above notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution. -* The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water Resources, or the Risk Management Center may not be used to endorse or promote products derived from this software without specific prior written permission. Nor may the names of its contributors be used to endorse or promote products derived from this software without specific prior written permission. - -DISCLAIMER: -THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted. +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE +FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY +DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN +AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md index 28a3d303..7efa0249 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # WPF Framework [![CI](https://github.com/USACE-RMC/WPF-Framework/actions/workflows/Integration.yml/badge.svg)](https://github.com/USACE-RMC/WPF-Framework/actions/workflows/Integration.yml) -[![License: BSD-3-Clause](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](LICENSE) +[![License: 0BSD](https://img.shields.io/badge/License-0BSD-blue.svg)](LICENSE) WPF Framework is a free and open-source .NET 10.0 application framework for building desktop project management applications, developed by the U.S. Army Corps of Engineers Risk Management Center ([USACE-RMC](https://www.rmc.usace.army.mil/)). It provides a complete application shell with docking layout, project explorer, theme switching, undo/redo, and specialized controls for charting, databases, expression parsing, and directed acyclic graphs. @@ -150,7 +150,7 @@ Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines ## License -This project is licensed under a BSD-3-Clause license. See [LICENSE](LICENSE) for details. +This project is licensed under the Zero-Clause BSD (0BSD) license — a permissive license with no attribution or notice requirements. See [LICENSE](LICENSE) for details. ## Authors diff --git a/codemeta.json b/codemeta.json index cb765f5f..339811b7 100644 --- a/codemeta.json +++ b/codemeta.json @@ -6,7 +6,7 @@ "version": "1.0.0", "dateCreated": "2025-12-29", "dateModified": "2026-04-29", - "license": "https://spdx.org/licenses/BSD-3-Clause", + "license": "https://spdx.org/licenses/0BSD", "codeRepository": "https://github.com/USACE-RMC/WPF-Framework", "issueTracker": "https://github.com/USACE-RMC/WPF-Framework/issues", "applicationCategory": "Desktop application framework", diff --git a/docs/oxyplot-controls.md b/docs/oxyplot-controls.md index b98099a3..8400b339 100644 --- a/docs/oxyplot-controls.md +++ b/docs/oxyplot-controls.md @@ -19,7 +19,7 @@ The OxyPlotControls library provides WPF controls for configuring and interactin ## OxyPlotToolbar -`OxyPlotToolbar` is a `UserControl` (implementing `IDisposable`) that attaches to an `OxyPlot.Wpf.Plot` and provides interactive charting tools. +`OxyPlotToolbar` is a `UserControl` that attaches to an `OxyPlot.Wpf.Plot` and provides interactive charting tools. Custom cursors are held in a process-wide static cache, so each toolbar instance is cheap and no explicit disposal is required. ### Dependency Properties @@ -244,7 +244,7 @@ The `OxyPlotControls.Demo` project demonstrates the toolbar, property editors, a ## Best Practices -- **Dispose the toolbar** -- `OxyPlotToolbar` implements `IDisposable` for cursor cleanup. The `Unloaded` event handles this automatically, but explicit disposal is recommended when programmatically removing toolbars. +- **No toolbar disposal required** -- `OxyPlotToolbar` keeps its custom cursors in a static `CursorCache`, so individual toolbar instances do not own disposable resources. Theme-event subscriptions are released by the `Unloaded` handler, and Plot-side event subscriptions are released when the `Plot` dependency property is cleared or replaced. - **Refresh bindings after deserialization** -- call `OxyPlotPropertiesControl.RefreshPlotBindings()` after `OxyPlotSettingsSerializer.FromXelement()` to ensure all property editors reflect the restored values. - **Use `WithThemedModel` for export** -- when exporting to images or PDF, use `OxyPlotThemeManager.WithThemedModel` to temporarily apply the report theme without permanently modifying the plot. - **Suppress property changes during theme application** -- set `Plot.SuppressPropertyChanged = true` before calling `ApplyTheme` to prevent undo/redo recording of theme changes. The toolbar handles this automatically. diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock.Themes.VS2013/BlueBrushs.xaml b/src/AvalonDock/Xceed.Wpf.AvalonDock.Themes.VS2013/BlueBrushs.xaml index e90ae7fb..f2c2745e 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock.Themes.VS2013/BlueBrushs.xaml +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock.Themes.VS2013/BlueBrushs.xaml @@ -8,7 +8,7 @@ #1ba1e2 + Color="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentColorKey}}" /> @@ -150,7 +150,7 @@ + Color="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentColorKey}}" /> @@ -162,7 +162,7 @@ + Color="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentColorKey}}" /> #1ba1e2 + Color="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentColorKey}}" /> @@ -31,7 +31,7 @@ + Color="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentColorKey}}" /> @@ -155,7 +155,7 @@ + Color="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentColorKey}}" /> @@ -167,7 +167,7 @@ + Color="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentColorKey}}" /> + Color="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentColorKey}}" /> @@ -156,7 +156,7 @@ + Color="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentColorKey}}" /> @@ -168,7 +168,7 @@ + Color="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentColorKey}}" /> - - + + + - - - - - - - - - - - - - + + @@ -80,26 +72,15 @@ HorizontalAlignment="Stretch" VerticalAlignment="Top" /> - - + + - - - - - - - - - - - - - + + @@ -126,23 +107,11 @@ HorizontalAlignment="Stretch" VerticalAlignment="Top" /> - - - - - - - - - - - - - + @@ -169,26 +138,15 @@ HorizontalAlignment="Stretch" VerticalAlignment="Top" /> - - + + - - - - - - - - - - - - - + + @@ -331,23 +289,11 @@ HorizontalAlignment="Stretch" VerticalAlignment="Top" /> - - - - - - - - - - - - - + @@ -373,26 +319,15 @@ HorizontalAlignment="Stretch" VerticalAlignment="Top" /> - - + + - - - - - - - - - - - - - + + @@ -419,26 +354,15 @@ HorizontalAlignment="Stretch" VerticalAlignment="Top" /> - - + + - - - - - - - - - - - - - + + @@ -464,26 +388,15 @@ HorizontalAlignment="Stretch" VerticalAlignment="Top" /> - - + + - - - - - - - - - - - - - + + diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneTitle.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneTitle.cs index f01f3a0a..911a1b69 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneTitle.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/AnchorablePaneTitle.cs @@ -170,9 +170,11 @@ protected override void OnMouseLeftButtonDown( System.Windows.Input.MouseButtonE if( attachFloatingWindow ) { - //the pane is hosted inside a floating window that contains only an anchorable pane so drag the floating window itself - var floatingWndControl = Model.Root.Manager.FloatingWindows.Single( fwc => fwc.Model == parentFloatingWindow ); - floatingWndControl.AttachDrag( false ); + //the pane is hosted inside a floating window that contains only an anchorable pane so drag the floating window itself. + // FirstOrDefault rather than Single — if the FW was just removed (race during + // tear-down) Single throws InvalidOperationException; silently no-op instead. + var floatingWndControl = Model.Root.Manager.FloatingWindows.FirstOrDefault( fwc => fwc.Model == parentFloatingWindow ); + floatingWndControl?.AttachDrag( false ); } else _isMouseDown = true;//normal drag diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/AutoHideWindowManager.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/AutoHideWindowManager.cs index 53134276..6f2aaac5 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/AutoHideWindowManager.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/AutoHideWindowManager.cs @@ -80,8 +80,12 @@ private void SetupClosingTimer() _closingTimer.Interval = TimeSpan.FromMilliseconds( 50 ); _closingTimer.Tick += ( s, e ) => { + // _manager.AutoHideWindow.Model is set to null after Hide() runs (see + // LayoutAutoHideWindowControl.HideInternal). A late-arriving timer tick that fires after + // Hide can otherwise NRE on the cast deref. + var model = _manager.AutoHideWindow.Model as LayoutAnchorable; if( _manager.AutoHideWindow.IsWin32MouseOver - || ( ( LayoutAnchorable )_manager.AutoHideWindow.Model ).IsActive + || ( model != null && model.IsActive ) || _manager.AutoHideWindow.IsResizing ) return; @@ -106,8 +110,10 @@ private void SetupCloseTimer() _closeTimer.Interval = TimeSpan.FromMilliseconds( _manager.AutoHideWindowClosingTimer ); _closeTimer.Tick += ( s, e ) => { + // Same null-Model guard as SetupClosingTimer above. + var model = _manager.AutoHideWindow.Model as LayoutAnchorable; if( _manager.AutoHideWindow.IsWin32MouseOver - || ( ( LayoutAnchorable )_manager.AutoHideWindow.Model ).IsActive + || ( model != null && model.IsActive ) || _manager.AutoHideWindow.IsResizing ) { _closeTimer.Stop(); diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/ContextMenuEx.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/ContextMenuEx.cs index 66e479a5..98d2daa3 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/ContextMenuEx.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/ContextMenuEx.cs @@ -43,7 +43,10 @@ protected override System.Windows.DependencyObject GetContainerForItemOverride() protected override void OnOpened( System.Windows.RoutedEventArgs e ) { - BindingOperations.GetBindingExpression( this, ItemsSourceProperty ).UpdateTarget(); + // GetBindingExpression returns null when ItemsSource has no binding (set + // via direct assignment of an enumerable rather than via {Binding}). The + // unguarded .UpdateTarget would NRE on context-menu open in that case. + BindingOperations.GetBindingExpression( this, ItemsSourceProperty )?.UpdateTarget(); base.OnOpened( e ); } diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/Extentions.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/Extentions.cs index 8acd5b49..f07c8e0a 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/Extentions.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/Extentions.cs @@ -90,6 +90,11 @@ public static DependencyObject FindVisualTreeRoot( this DependencyObject initial public static T FindVisualAncestor( this DependencyObject dependencyObject ) where T : class { + // Defensive null-check: callers occasionally pass an originalSource whose visual + // tree was already torn down. VisualTreeHelper.GetParent(null) throws ArgumentNullException. + if( dependencyObject == null ) + return null; + DependencyObject target = dependencyObject; do { @@ -101,6 +106,10 @@ public static T FindVisualAncestor( this DependencyObject dependencyObject ) public static T FindLogicalAncestor( this DependencyObject dependencyObject ) where T : class { + // Same null-guard rationale as FindVisualAncestor. + if( dependencyObject == null ) + return null; + DependencyObject target = dependencyObject; do { diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs index 8d32d49b..27c9deb4 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs @@ -145,7 +145,17 @@ protected override IntPtr FilterMessage( IntPtr hwnd, int msg, IntPtr wParam, In case Win32Helper.WM_NCLBUTTONDOWN: //Left button down on title -> start dragging over docking manager if( wParam.ToInt32() == Win32Helper.HT_CAPTION ) { - _model.Descendents().OfType().First( p => p.ChildrenCount > 0 && p.SelectedContent != null ).SelectedContent.IsActive = true; + // FirstOrDefault rather than First — when no LayoutAnchorablePane has children + // with non-null SelectedContent (transient state during selection change, or + // all panes just emptied), First throws InvalidOperationException and brings + // down the dispatcher. Title-bar click is a UX nicety; silently no-op when + // there's no candidate. + var pane = _model.Descendents().OfType() + .FirstOrDefault( p => p.ChildrenCount > 0 && p.SelectedContent != null ); + if( pane != null ) + { + pane.SelectedContent.IsActive = true; + } handled = true; } break; diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorablePaneControl.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorablePaneControl.cs index 438efd0a..011bca7a 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorablePaneControl.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorablePaneControl.cs @@ -122,7 +122,13 @@ protected override void OnMouseRightButtonDown( System.Windows.Input.MouseButton private void OnLayoutUpdated( object sender, EventArgs e ) { + // _model is typed as LayoutAnchorablePane (which implements + // ILayoutPositionableElementWithActualSize), but defensively guard the cast: if the model + // is detached (e.g. during shutdown or layout reload) the cast can return null and this + // path would NRE on the property setter. var modelWithAtcualSize = _model as ILayoutPositionableElementWithActualSize; + if( modelWithAtcualSize == null ) + return; modelWithAtcualSize.ActualWidth = ActualWidth; modelWithAtcualSize.ActualHeight = ActualHeight; } diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentControl.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentControl.cs index d5d5baa9..4e6ff540 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentControl.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutDocumentControl.cs @@ -190,7 +190,20 @@ internal void SetResourcesFromObject( FrameworkElement current ) this.Resources.Add( x.Key, x.Value ); } } - catch( Exception ) { } + // Narrow from catch-all so genuine bugs (OOM, ThreadAbort, NullReference) + // are no longer silently swallowed. The expected faults during resource + // copy are duplicate-key adds (ArgumentException) and concurrent + // dictionary mutation (InvalidOperationException). + catch( ArgumentException ex ) + { + System.Diagnostics.Trace.WriteLine( + $"[LayoutDocumentControl] Skipping duplicate resource key '{x.Key}': {ex.Message}" ); + } + catch( InvalidOperationException ex ) + { + System.Diagnostics.Trace.WriteLine( + $"[LayoutDocumentControl] Resource dictionary changed during copy of key '{x.Key}': {ex.Message}" ); + } } ); } current = current.Parent as FrameworkElement; diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs index 45ca7644..89741c8c 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs @@ -272,14 +272,15 @@ protected override void OnClosed( EventArgs e ) root.CollectGarbage(); } - if( this.Content != null ) + // The HwndSource hook is installed in OnLoaded regardless of Content state, + // so cleanup must happen unconditionally — gating on Content!=null leaked + // the native hook (and the managed callback closure that pins this) when + // Content was cleared before close. + if( _hwndSrc != null ) { - if( _hwndSrc != null ) - { - _hwndSrc.RemoveHook( _hwndSrcHook ); - _hwndSrc.Dispose(); - _hwndSrc = null; - } + _hwndSrc.RemoveHook( _hwndSrcHook ); + _hwndSrc.Dispose(); + _hwndSrc = null; } base.OnClosed( e ); @@ -385,7 +386,10 @@ internal virtual void UpdateThemeResources( Theme oldTheme = null ) } } - var manager = _model.Root.Manager; + // _model can be null and its Root/Manager can be null during shutdown + // races. Walk defensively, mirroring OnKeyDown / OnPreviewKeyDown / BringFocusOnDockingManager. + var manager = _model?.Root?.Manager; + if( manager == null ) return; if( manager.Theme != null ) { if( manager.Theme is DictionaryTheme ) @@ -632,7 +636,13 @@ private void OnLoaded( object sender, RoutedEventArgs e ) { this.Loaded -= new RoutedEventHandler( OnLoaded ); - this.SetParentToMainWindowOf( Model.Root.Manager ); + // Defensive walk — Model/Root/Manager can be null during a shutdown race + // where the manager unloaded between window creation and OnLoaded. + var manager = Model?.Root?.Manager; + if( manager != null ) + { + this.SetParentToMainWindowOf( manager ); + } _hwndSrc = HwndSource.FromDependencyObject( this ) as HwndSource; _hwndSrcHook = new HwndSourceHook( FilterMessage ); diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs index 01f13df9..532bc521 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs @@ -94,22 +94,42 @@ protected override void OnInitialized( EventArgs e ) { base.OnInitialized( e ); - _model.ChildrenTreeChanged += ( s, args ) => - { - if( args.Change != ChildrenTreeChange.DirectChildrenChanged ) - return; - if( _asyncRefreshCalled.HasValue && - _asyncRefreshCalled.Value == args.Change ) - return; - _asyncRefreshCalled = args.Change; - Dispatcher.BeginInvoke( new Action( () => - { - _asyncRefreshCalled = null; - UpdateChildren(); - } ), DispatcherPriority.Normal, null ); - }; + // Use a named handler (not an anonymous lambda) so we can detach it on Unload. An anonymous + // lambda would keep _model -> this rooted indefinitely, leaking the LayoutGridControl after + // the visual tree is replaced (e.g. layout reload, theme switch). + _model.ChildrenTreeChanged += OnModelChildrenTreeChanged; this.LayoutUpdated += new EventHandler( OnLayoutUpdated ); + this.Unloaded += OnLayoutGridControlUnloaded; + } + + #endregion + + #region Lifecycle + + private void OnModelChildrenTreeChanged( object s, ChildrenTreeChangedEventArgs args ) + { + if( args.Change != ChildrenTreeChange.DirectChildrenChanged ) + return; + if( _asyncRefreshCalled.HasValue && + _asyncRefreshCalled.Value == args.Change ) + return; + _asyncRefreshCalled = args.Change; + Dispatcher.BeginInvoke( new Action( () => + { + _asyncRefreshCalled = null; + UpdateChildren(); + } ), DispatcherPriority.Normal, null ); + } + + private void OnLayoutGridControlUnloaded( object sender, RoutedEventArgs e ) + { + // Detach to break the model -> control reference so GC can reclaim the control. + if( _model != null ) + { + _model.ChildrenTreeChanged -= OnModelChildrenTreeChanged; + } + this.Unloaded -= OnLayoutGridControlUnloaded; } #endregion @@ -130,7 +150,14 @@ protected void FixChildrenDockLengths() private void OnLayoutUpdated( object sender, EventArgs e ) { + // Defensive null-guard on the cast: _model is typed as LayoutPositionableGroup which + // implements ILayoutPositionableElementWithActualSize, but during teardown the cast can + // return null and the size assignments below would NRE. var modelWithAtcualSize = _model as ILayoutPositionableElementWithActualSize; + if( modelWithAtcualSize == null ) + { + return; + } modelWithAtcualSize.ActualWidth = ActualWidth; modelWithAtcualSize.ActualHeight = ActualHeight; diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/NavigatorWindow.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/NavigatorWindow.cs index a9eb8663..8cbb8c2b 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/NavigatorWindow.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/NavigatorWindow.cs @@ -484,6 +484,29 @@ internal void UpdateThemeResources( Theme oldTheme = null ) this.Resources.MergedDictionaries.Add( new ResourceDictionary() { Source = _manager.Theme.GetResourceUri() } ); } } + else + { + // When Theme property is not set, propagate theme dictionaries from the + // DockingManager or its parent Window. FrameworkUI adds VS2013 theme + // dictionaries to MainWindow.Resources, not to the DockingManager. Since + // NavigatorWindow is a separate Win32 window that does not inherit from + // the main window's visual tree, without this fallback it falls back to + // base generic.xaml (system grey). Mirrors LayoutFloatingWindowControl.UpdateThemeResources. + var sourceDict = _manager.Resources.MergedDictionaries.Count > 0 + ? _manager.Resources.MergedDictionaries + : Window.GetWindow( _manager )?.Resources.MergedDictionaries; + + if( sourceDict != null ) + { + foreach( var rd in sourceDict ) + { + if( !this.Resources.MergedDictionaries.Contains( rd ) ) + { + this.Resources.MergedDictionaries.Add( rd ); + } + } + } + } } internal void SelectNextDocument() diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/OverlayWindow.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/OverlayWindow.cs index 197a181f..2d3fb8ee 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/OverlayWindow.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Controls/OverlayWindow.cs @@ -104,9 +104,17 @@ public override void OnApplyTemplate() _gridDocumentPaneDropTargets = GetTemplateChild( "PART_DocumentPaneDropTargets" ) as Grid; _gridDocumentPaneFullDropTargets = GetTemplateChild( "PART_DocumentPaneFullDropTargets" ) as Grid; - _gridDockingManagerDropTargets.Visibility = System.Windows.Visibility.Hidden; - _gridAnchorablePaneDropTargets.Visibility = System.Windows.Visibility.Hidden; - _gridDocumentPaneDropTargets.Visibility = System.Windows.Visibility.Hidden; + // Each PART_* GetTemplateChild returns null if the control's template doesn't + // include that named element (e.g. a custom non-VS2013 theme). Guard each + // mirror the existing _gridDocumentPaneFullDropTargets pattern below — without + // this, a custom theme that omits any of these PARTs causes an NRE on first + // template apply. + if( _gridDockingManagerDropTargets != null ) + _gridDockingManagerDropTargets.Visibility = System.Windows.Visibility.Hidden; + if( _gridAnchorablePaneDropTargets != null ) + _gridAnchorablePaneDropTargets.Visibility = System.Windows.Visibility.Hidden; + if( _gridDocumentPaneDropTargets != null ) + _gridDocumentPaneDropTargets.Visibility = System.Windows.Visibility.Hidden; if( _gridDocumentPaneFullDropTargets != null ) _gridDocumentPaneFullDropTargets.Visibility = System.Windows.Visibility.Hidden; @@ -184,6 +192,34 @@ internal void UpdateThemeResources( Theme oldTheme = null ) Resources.MergedDictionaries.Add( new ResourceDictionary() { Source = _host.Manager.Theme.GetResourceUri() } ); } } + else + { + // When Theme property is not set, propagate theme dictionaries from the + // DockingManager or its parent Window. FrameworkUI adds VS2013 theme + // dictionaries to MainWindow.Resources, not to the DockingManager. The + // OverlayWindow is a separate Win32 window that does not inherit from + // the main window's visual tree, so without this fallback the dock-drop + // overlay renders system-grey instead of themed. Mirrors + // LayoutFloatingWindowControl.UpdateThemeResources. + var manager = _host?.Manager; + if( manager != null ) + { + var sourceDict = manager.Resources.MergedDictionaries.Count > 0 + ? manager.Resources.MergedDictionaries + : Window.GetWindow( manager )?.Resources.MergedDictionaries; + + if( sourceDict != null ) + { + foreach( var rd in sourceDict ) + { + if( !Resources.MergedDictionaries.Contains( rd ) ) + { + Resources.MergedDictionaries.Add( rd ); + } + } + } + } + } } internal void EnableDropTargets() @@ -722,7 +758,7 @@ void IOverlayWindow.DragLeave( IDropArea area ) void IOverlayWindow.DragEnter( IDropTarget target ) { var previewBoxPath = target.GetPreviewPath( this, _floatingWindow.Model as LayoutFloatingWindow ); - if( previewBoxPath != null ) + if( previewBoxPath != null && _previewBox != null ) { _previewBox.Data = previewBoxPath; _previewBox.Visibility = System.Windows.Visibility.Visible; @@ -731,7 +767,10 @@ void IOverlayWindow.DragEnter( IDropTarget target ) void IOverlayWindow.DragLeave( IDropTarget target ) { - _previewBox.Visibility = System.Windows.Visibility.Hidden; + // _previewBox can be null if the control template doesn't include + // PART_PreviewBox (custom non-VS2013 theme). + if( _previewBox != null ) + _previewBox.Visibility = System.Windows.Visibility.Hidden; } void IOverlayWindow.DragDrop( IDropTarget target ) diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/DockingManager.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/DockingManager.cs index a96ff744..1bea999d 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/DockingManager.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/DockingManager.cs @@ -3226,7 +3226,11 @@ IOverlayWindow IOverlayWindowHost.ShowOverlayWindow( LayoutFloatingWindowControl void IOverlayWindowHost.HideOverlayWindow() { + // _overlayWindow can be null if Unloaded fired and DestroyOverlayWindow + // ran while a drag was still in progress. Guard so the hide path is a + // no-op rather than NRE'ing on the dispatcher. _areas = null; + if( _overlayWindow == null ) return; _overlayWindow.Owner = null; _overlayWindow.HideDropTargets(); } diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Layout/LayoutAnchorableFloatingWindow.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Layout/LayoutAnchorableFloatingWindow.cs index f94e0a76..d68c2475 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Layout/LayoutAnchorableFloatingWindow.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Layout/LayoutAnchorableFloatingWindow.cs @@ -128,8 +128,12 @@ public ILayoutAnchorablePane SinglePane if( !IsSinglePane ) return null; - var singlePane = RootPanel.Descendents().OfType().Single( p => p.IsVisible ); - singlePane.UpdateIsDirectlyHostedInFloatingWindow(); + // SingleOrDefault rather than Single — IsSinglePane uses OfType + // (interface) for its predicate, but this lookup uses OfType + // (concrete). If a third-party adds an ILayoutAnchorablePane that isn't a + // LayoutAnchorablePane, the guard returns true while Single throws. + var singlePane = RootPanel.Descendents().OfType().SingleOrDefault( p => p.IsVisible ); + singlePane?.UpdateIsDirectlyHostedInFloatingWindow(); return singlePane; } } diff --git a/src/AvalonDock/Xceed.Wpf.AvalonDock/Layout/LayoutContent.cs b/src/AvalonDock/Xceed.Wpf.AvalonDock/Layout/LayoutContent.cs index 7aabeaa0..20f4647a 100644 --- a/src/AvalonDock/Xceed.Wpf.AvalonDock/Layout/LayoutContent.cs +++ b/src/AvalonDock/Xceed.Wpf.AvalonDock/Layout/LayoutContent.cs @@ -742,11 +742,11 @@ public virtual void ReadXml( System.Xml.XmlReader reader ) if( reader.MoveToAttribute( "PreviousContainerId" ) ) PreviousContainerId = reader.Value; if( reader.MoveToAttribute( "PreviousContainerIndex" ) ) - PreviousContainerIndex = int.Parse( reader.Value ); + PreviousContainerIndex = int.Parse( reader.Value, CultureInfo.InvariantCulture ); if( reader.MoveToAttribute( "InitialContainerId" ) ) InitialContainerId = reader.Value; if( reader.MoveToAttribute( "InitialContainerIndex" ) ) - InitialContainerIndex = int.Parse( reader.Value ); + InitialContainerIndex = int.Parse( reader.Value, CultureInfo.InvariantCulture ); if( reader.MoveToAttribute( "FloatingLeft" ) ) FloatingLeft = double.Parse( reader.Value, CultureInfo.InvariantCulture ); @@ -819,7 +819,7 @@ public virtual void WriteXml( System.Xml.XmlWriter writer ) if( paneSerializable != null ) { writer.WriteAttributeString( "PreviousContainerId", paneSerializable.Id ); - writer.WriteAttributeString( "PreviousContainerIndex", _previousContainerIndex.ToString() ); + writer.WriteAttributeString( "PreviousContainerIndex", _previousContainerIndex.ToString( CultureInfo.InvariantCulture ) ); } } if( _initialContainer != null ) @@ -828,7 +828,7 @@ public virtual void WriteXml( System.Xml.XmlWriter writer ) if( paneSerializable != null ) { writer.WriteAttributeString( "InitialContainerId", paneSerializable.Id ); - writer.WriteAttributeString( "InitialContainerIndex", _initialContainerIndex.ToString() ); + writer.WriteAttributeString( "InitialContainerIndex", _initialContainerIndex.ToString( CultureInfo.InvariantCulture ) ); } } diff --git a/src/DAG.Demo/App.xaml.cs b/src/DAG.Demo/App.xaml.cs index 73d593aa..44d990c6 100644 --- a/src/DAG.Demo/App.xaml.cs +++ b/src/DAG.Demo/App.xaml.cs @@ -1,35 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; -using System.Configuration; using System.Windows; namespace DAG.Demo @@ -39,5 +7,15 @@ namespace DAG.Demo /// public partial class App : Application { + public App() + { + // Set WPF to use the current culture for all bindings (international number support) + // This ensures StringFormat in XAML bindings uses the user's locale settings + FrameworkElement.LanguageProperty.OverrideMetadata( + typeof(FrameworkElement), + new FrameworkPropertyMetadata( + System.Windows.Markup.XmlLanguage.GetLanguage( + System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag))); + } } } diff --git a/src/DAG.Demo/MainWindow.xaml.cs b/src/DAG.Demo/MainWindow.xaml.cs index aafa9a1d..6af552a9 100644 --- a/src/DAG.Demo/MainWindow.xaml.cs +++ b/src/DAG.Demo/MainWindow.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using DAG; using System; using System.Collections.Generic; @@ -67,7 +37,7 @@ private void AddNodeButton_Click(object sender, RoutedEventArgs e) private void GraphCanvas_PreviewCanvasContextMenu(ContextMenu cm, Point canvasPosition) { - Image addIcon = new Image() { Source = new BitmapImage(new Uri("pack://application:,,/DAG.Demo;component/Resources/Add.png")) }; + Image addIcon = new Image() { Source = new BitmapImage(new Uri("pack://application:,,,/DAG.Demo;component/Resources/Add.png")) }; var cmi = new MenuItem() { Header = "Add Node", Tag = canvasPosition, Icon = addIcon }; cmi.Click += Cmi_Click; cm.Items.Add(cmi); @@ -115,7 +85,7 @@ private void AddNode(Point p) private void GraphCanvas_PreviewNodeContextMenu(ContextMenu cm, DAG.NodeBase node) { - Image editIcon = new Image() { Source = new BitmapImage(new Uri("pack://application:,,/DAG.Demo;component/Resources/EditWindow.png")) }; + Image editIcon = new Image() { Source = new BitmapImage(new Uri("pack://application:,,,/DAG.Demo;component/Resources/EditWindow.png")) }; var cmi = new MenuItem() { Header = "Edit", Tag = node, Icon = editIcon }; cmi.Click += (s, e) => { MessageBox.Show("Nothing here"); }; cm.Items.Add(cmi); diff --git a/src/DAG.Demo/Properties/AssemblyInfo.cs b/src/DAG.Demo/Properties/AssemblyInfo.cs index 742a9f37..804aed10 100644 --- a/src/DAG.Demo/Properties/AssemblyInfo.cs +++ b/src/DAG.Demo/Properties/AssemblyInfo.cs @@ -12,7 +12,6 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DAG.Demo")] -[assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/src/DAG.Demo/TestGraph.cs b/src/DAG.Demo/TestGraph.cs index f43c4bf3..4b330d90 100644 --- a/src/DAG.Demo/TestGraph.cs +++ b/src/DAG.Demo/TestGraph.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using DAG; using System.Xml.Linq; diff --git a/src/DAG.Demo/TestNode.cs b/src/DAG.Demo/TestNode.cs index 49b4ef16..28505b63 100644 --- a/src/DAG.Demo/TestNode.cs +++ b/src/DAG.Demo/TestNode.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using DAG; using System; using System.Globalization; diff --git a/src/DAG/Graph.cs b/src/DAG/Graph.cs index 02565fc9..94d885e1 100644 --- a/src/DAG/Graph.cs +++ b/src/DAG/Graph.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -187,11 +157,10 @@ public Graph(XElement el) Connections = new ReadOnlyCollection>(_connections); if (el == null || el.Name != this.GetType().Name) { return; } - // Clear the existing nodes. + // Clear the existing nodes. _connections was just initialized empty above, + // so there is nothing to capture or clear here — the prior ConnectionsRemoved + // invocation always fired with an empty array and was a no-op. Nodes.Clear(); - var connectionList = _connections.ToArray(); - _connections.Clear(); - ConnectionsRemoved?.Invoke(connectionList); // Set the scale if (el.Attribute(nameof(Scale)) != null) diff --git a/src/DAG/InConnector.cs b/src/DAG/InConnector.cs index 391d707e..ab7fafde 100644 --- a/src/DAG/InConnector.cs +++ b/src/DAG/InConnector.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; namespace DAG diff --git a/src/DAG/NodeBase.cs b/src/DAG/NodeBase.cs index f46cd9c1..295bda52 100644 --- a/src/DAG/NodeBase.cs +++ b/src/DAG/NodeBase.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.ObjectModel; using System.ComponentModel; diff --git a/src/DAG/OutConnector.cs b/src/DAG/OutConnector.cs index f1019a0b..ecfeb638 100644 --- a/src/DAG/OutConnector.cs +++ b/src/DAG/OutConnector.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; namespace DAG diff --git a/src/DAG/Utilities.cs b/src/DAG/Utilities.cs index 76786dd0..c053dc0f 100644 --- a/src/DAG/Utilities.cs +++ b/src/DAG/Utilities.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.ComponentModel; using System.Runtime.CompilerServices; diff --git a/src/DAGControls/FlowGraphCanvas.xaml.cs b/src/DAGControls/FlowGraphCanvas.xaml.cs index 0a5602ee..18bb39c4 100644 --- a/src/DAGControls/FlowGraphCanvas.xaml.cs +++ b/src/DAGControls/FlowGraphCanvas.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Threading; @@ -545,7 +515,7 @@ private void GraphCanvas_MouseDown(object sender, MouseButtonEventArgs e) { _targetNode = node.Key; ContextMenu cm = new ContextMenu(); - BitmapImage bmp = new BitmapImage(new Uri("pack://application:,,/DAGControls;component/Resources/Delete.png")); + BitmapImage bmp = new BitmapImage(new Uri("pack://application:,,,/DAGControls;component/Resources/Delete.png")); Image deleteIcon = new Image() { Source = bmp }; MenuItem cmi = new MenuItem() { Header = "Delete", Icon = deleteIcon }; cmi.Click += Cmi_Click; diff --git a/src/DAGControls/NodeControl.xaml.cs b/src/DAGControls/NodeControl.xaml.cs index 25a806d9..8fa0e48b 100644 --- a/src/DAGControls/NodeControl.xaml.cs +++ b/src/DAGControls/NodeControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using DAG; using System.Collections.Generic; using System.Linq; @@ -96,11 +66,13 @@ public partial class NodeControl : UserControl /// /// Identifies the dependency property. /// + // Default null — reference-type DP defaults are shared across all instances. + // Per-instance default initialized in the constructor. public static readonly DependencyProperty HeaderColorProperty = DependencyProperty.Register( nameof(HeaderColor), typeof(SolidColorBrush), typeof(NodeControl), - new FrameworkPropertyMetadata(new SolidColorBrush(Colors.Red))); + new FrameworkPropertyMetadata((SolidColorBrush)null)); /// /// Identifies the dependency property. @@ -206,6 +178,11 @@ public ImageSource NodeIcon public NodeControl(NodeBase node) { InitializeComponent(); + // Per-instance default (DP default is null — see DP registration). + if (HeaderColor == null) + { + HeaderColor = new SolidColorBrush(Colors.Red); + } Node = node; RefreshInConnectors(); diff --git a/src/DAGControls/Properties/AssemblyInfo.cs b/src/DAGControls/Properties/AssemblyInfo.cs index 8aa08501..6561bfcd 100644 --- a/src/DAGControls/Properties/AssemblyInfo.cs +++ b/src/DAGControls/Properties/AssemblyInfo.cs @@ -12,7 +12,6 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DAGControls")] -[assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/src/DatabaseControls.Demo/App.xaml b/src/DatabaseControls.Demo/App.xaml index 4a301370..a413ab3c 100644 --- a/src/DatabaseControls.Demo/App.xaml +++ b/src/DatabaseControls.Demo/App.xaml @@ -1,33 +1,3 @@ - - - - ..\..\..\numerics\Numerics\bin\$(Configuration)\net10.0\Numerics.dll - + diff --git a/src/DatabaseControls.Demo/MainWindow.xaml b/src/DatabaseControls.Demo/MainWindow.xaml index 515b663d..4f247305 100644 --- a/src/DatabaseControls.Demo/MainWindow.xaml +++ b/src/DatabaseControls.Demo/MainWindow.xaml @@ -1,33 +1,3 @@ - - (object)b.ToString("F15")).ToArray(); + object[] formattedBreaks = breaks.Select(b => (object)b.ToString("F15", CultureInfo.InvariantCulture)).ToArray(); BreaksTable.DataView.EditColumn(0, formattedBreaks); } @@ -602,9 +573,9 @@ private void UpdateDataView() }; // Format Count (index 0) as integer, all others as F15 - columnStrings[0] = ((int)columnData[0]).ToString(); + columnStrings[0] = ((int)columnData[0]).ToString(CultureInfo.InvariantCulture); for (int i = 1; i < columnData.Length; i++) - columnStrings[i] = double.IsNaN(columnData[i]) ? "" : columnData[i].ToString("F15"); + columnStrings[i] = double.IsNaN(columnData[i]) ? "" : columnData[i].ToString("F15", CultureInfo.InvariantCulture); if (_sortedData.Length != Data.Length) { @@ -797,7 +768,7 @@ private void Plot() for (int i = 0; i < ranges.Count; i++) { // Set breaks table - breaksDataTable.Rows.Add(ranges[i].Item2.ToString("F15"), rangeCounts[i]); + breaksDataTable.Rows.Add(ranges[i].Item2.ToString("F15", CultureInfo.InvariantCulture), rangeCounts[i]); if (ranges[i].Item2 == ranges[i].Item1) { diff --git a/src/DatabaseControls/ColumnStatsWindow.xaml.cs b/src/DatabaseControls/ColumnStatsWindow.xaml.cs index 1182c697..0815f780 100644 --- a/src/DatabaseControls/ColumnStatsWindow.xaml.cs +++ b/src/DatabaseControls/ColumnStatsWindow.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.ComponentModel; diff --git a/src/DatabaseControls/DatabaseControls.csproj b/src/DatabaseControls/DatabaseControls.csproj index df52d25d..465b2c4e 100644 --- a/src/DatabaseControls/DatabaseControls.csproj +++ b/src/DatabaseControls/DatabaseControls.csproj @@ -56,9 +56,7 @@ - - ..\..\..\numerics\Numerics\bin\Debug\net10.0\Numerics.dll - + diff --git a/src/DatabaseControls/FieldCalculator/CalculatorHelpWindow.xaml.cs b/src/DatabaseControls/FieldCalculator/CalculatorHelpWindow.xaml.cs index 573635cc..b312de5e 100644 --- a/src/DatabaseControls/FieldCalculator/CalculatorHelpWindow.xaml.cs +++ b/src/DatabaseControls/FieldCalculator/CalculatorHelpWindow.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.IO; using System.Reflection; diff --git a/src/DatabaseControls/FieldCalculator/ErrorItem.cs b/src/DatabaseControls/FieldCalculator/ErrorItem.cs index b59e97f8..42db97f8 100644 --- a/src/DatabaseControls/FieldCalculator/ErrorItem.cs +++ b/src/DatabaseControls/FieldCalculator/ErrorItem.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; namespace DatabaseControls diff --git a/src/DatabaseControls/FieldCalculator/ErrorWindow.xaml.cs b/src/DatabaseControls/FieldCalculator/ErrorWindow.xaml.cs index 370c4333..3c3968d1 100644 --- a/src/DatabaseControls/FieldCalculator/ErrorWindow.xaml.cs +++ b/src/DatabaseControls/FieldCalculator/ErrorWindow.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; diff --git a/src/DatabaseControls/FieldCalculator/ExpressionTextBox.cs b/src/DatabaseControls/FieldCalculator/ExpressionTextBox.cs index a217d1c1..7f4c8895 100644 --- a/src/DatabaseControls/FieldCalculator/ExpressionTextBox.cs +++ b/src/DatabaseControls/FieldCalculator/ExpressionTextBox.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.ComponentModel; diff --git a/src/DatabaseControls/FieldCalculator/FieldCalculator.xaml.cs b/src/DatabaseControls/FieldCalculator/FieldCalculator.xaml.cs index de665bcd..f848f6c5 100644 --- a/src/DatabaseControls/FieldCalculator/FieldCalculator.xaml.cs +++ b/src/DatabaseControls/FieldCalculator/FieldCalculator.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Windows; diff --git a/src/DatabaseControls/FieldCalculator/SelectByAttribute.xaml.cs b/src/DatabaseControls/FieldCalculator/SelectByAttribute.xaml.cs index d6b6c469..a704c22a 100644 --- a/src/DatabaseControls/FieldCalculator/SelectByAttribute.xaml.cs +++ b/src/DatabaseControls/FieldCalculator/SelectByAttribute.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Windows; diff --git a/src/DatabaseControls/FindAndReplace.xaml.cs b/src/DatabaseControls/FindAndReplace.xaml.cs index ff17673f..9a0499e5 100644 --- a/src/DatabaseControls/FindAndReplace.xaml.cs +++ b/src/DatabaseControls/FindAndReplace.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Windows; using System.Windows.Controls; diff --git a/src/DatabaseControls/TableViewer.xaml.cs b/src/DatabaseControls/TableViewer.xaml.cs index c13c9fa6..2924244d 100644 --- a/src/DatabaseControls/TableViewer.xaml.cs +++ b/src/DatabaseControls/TableViewer.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Data; diff --git a/src/DatabaseManager.Tests/AuditRegressionTests.cs b/src/DatabaseManager.Tests/AuditRegressionTests.cs new file mode 100644 index 00000000..d1b3f885 --- /dev/null +++ b/src/DatabaseManager.Tests/AuditRegressionTests.cs @@ -0,0 +1,128 @@ +using System; +using System.IO; +using System.Text; +using Xunit; + +namespace DatabaseManager.Tests +{ + /// + /// Regression tests pinning forensic-audit Phase 1 / 2 fixes. + /// Each test name references the audit finding ID it covers. + /// + public class AuditRegressionTests : IDisposable + { + private readonly string _testDir; + + public AuditRegressionTests() + { + _testDir = Path.Combine(Path.GetTempPath(), + "DatabaseManager.AuditRegression_" + Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(_testDir); + } + + public void Dispose() + { + try + { + if (Directory.Exists(_testDir)) + { + Directory.Delete(_testDir, recursive: true); + } + } + catch + { + // Best-effort cleanup; nothing actionable on failure here. + } + } + + /// + /// C-012: used to build SQL by + /// concatenating the column header into "[" + name + "]" with no validation. + /// A header containing a closing bracket — e.g. "col]; DROP TABLE x; --" — + /// would break out of the bracket-quoted identifier and inject SQL. The fix routes + /// every identifier through ValidateIdentifier, which throws + /// for names containing ] or null bytes. + /// + [Fact] + public void C012_ConvertCsvToSqLite_RejectsIdentifiersWithBrackets() + { + // Arrange — CSV with a header that, before the fix, would be injected verbatim + // into the CREATE TABLE statement. + var csvPath = Path.Combine(_testDir, "input.csv"); + var dbPath = Path.Combine(_testDir, "out.sqlite"); + File.WriteAllText( + csvPath, + "col]; DROP TABLE x; --,col2\nv1,v2\n", + Encoding.UTF8); + + // Act + Assert — must throw because the column header fails ValidateIdentifier. + var ex = Assert.ThrowsAny(() => + DatabaseManager.ConvertCsvToSqLite( + csvPath, + dbPath, + outputtableName: "AnyTable", + hasHeaders: true, + dataLineStartIndex: 0, + fieldsEnclosedInQuotes: false)); + + // Inner exception must be ArgumentException — the public method wraps caught + // failures in a generic Exception, so we check the inner cause. + var argEx = ex as ArgumentException ?? ex.InnerException as ArgumentException; + Assert.NotNull(argEx); + + // Defensive: make sure no SQLite file was produced — the rejection happens + // before any DDL executes so the database file should not contain the table. + // (The SQLiteManager opens/creates the file even on failure; we don't assert + // its absence, only that no rogue table was created.) + } + + /// + /// C-012: directly rejects bracket-bearing + /// table or column names without going through the CSV path. + /// + [Fact] + public void C012_SQLiteManager_CreateTable_RejectsBracketInTableName() + { + var dbPath = Path.Combine(_testDir, "ddl.sqlite"); + using var sqlite = new SQLiteManager(dbPath); + sqlite.Open(); + + try + { + Assert.Throws(() => + sqlite.CreateTable( + "evil]; DROP TABLE foo; --", + new[] { "Col1" }, + new[] { typeof(string) })); + } + finally + { + sqlite.Close(); + } + } + + /// + /// C-012: column names with brackets are rejected. + /// + [Fact] + public void C012_SQLiteManager_CreateTable_RejectsBracketInColumnName() + { + var dbPath = Path.Combine(_testDir, "ddl2.sqlite"); + using var sqlite = new SQLiteManager(dbPath); + sqlite.Open(); + + try + { + Assert.Throws(() => + sqlite.CreateTable( + "Good", + new[] { "good", "evil]; DROP TABLE x; --" }, + new[] { typeof(string), typeof(string) })); + } + finally + { + sqlite.Close(); + } + } + } +} diff --git a/src/DatabaseManager.Tests/DBFCultureRoundTripTests.cs b/src/DatabaseManager.Tests/DBFCultureRoundTripTests.cs new file mode 100644 index 00000000..05360e06 --- /dev/null +++ b/src/DatabaseManager.Tests/DBFCultureRoundTripTests.cs @@ -0,0 +1,191 @@ +using System; +using System.Data; +using System.Globalization; +using System.IO; +using System.Text; +using System.Threading; +using DatabaseManager; +using Xunit; + +namespace DatabaseManager.Tests +{ + /// + /// Tests in this collection mutate ; xunit must + /// not run them in parallel with anything else in the same assembly that reads culture. + /// + [CollectionDefinition("CultureSensitive", DisableParallelization = true)] + public class CultureSensitiveCollection { } + + /// + /// Verifies DBF file output uses culture-invariant numeric formatting. + /// + /// + /// DBF is a portable binary format. Floating-point values are written as ASCII text + /// inside the file (e.g. "1.23456789012e+003"). On a German machine without invariant + /// formatting, this becomes "1,23456789012e+003" — unreadable by Excel, ArcGIS, or any + /// other DBF consumer. + /// + [Collection("CultureSensitive")] + public class DBFCultureRoundTripTests : IDisposable + { + private readonly string _testDbfPath; + + public DBFCultureRoundTripTests() + { + _testDbfPath = Path.Combine(Path.GetTempPath(), $"culture_test_{Guid.NewGuid():N}.dbf"); + } + + public void Dispose() + { + if (File.Exists(_testDbfPath)) + { + try { File.Delete(_testDbfPath); } + catch { /* ignore cleanup errors */ } + } + } + + [Theory] + [InlineData("de-DE")] + [InlineData("fr-FR")] + [InlineData("en-US")] + public void CreateDbf_NumericColumn_FileUsesPeriodAsDecimalSeparator(string cultureName) + { + RunUnderCulture(cultureName, () => + { + var dt = new DataTable("Test"); + dt.Columns.Add("Value", typeof(double)); + dt.Rows.Add(1.5); + dt.Rows.Add(1234.5678); + dt.Rows.Add(-987.654321); + + DbfReader.CreateDbf(_testDbfPath, dt); + + Assert.True(File.Exists(_testDbfPath)); + byte[] bytes = File.ReadAllBytes(_testDbfPath); + string asAscii = Encoding.ASCII.GetString(bytes); + + // The numeric column data is encoded as ASCII text inside the DBF. + // Under any culture, it must use '.' (period) — never ',' for decimal sep. + // We don't search for the literal "1.5" string because DBF zero-pads numbers + // to fixed width; instead verify no German-style comma decimals leak through. + // Look for "0.0" or similar patterns; ensure no "0,0" floating-point patterns. + Assert.DoesNotContain("0,0000", asAscii); + Assert.DoesNotContain("1,500000", asAscii); + Assert.DoesNotContain("1,234567", asAscii); + }); + } + + [Theory] + [InlineData("de-DE")] + [InlineData("en-US")] + public void CreateDbf_RoundTrip_PreservesDoubleValues(string cultureName) + { + double[] expected = { 1.5, 1234.5678, -987.654321, 0.000001, 1.23456789e10 }; + + RunUnderCulture(cultureName, () => + { + var dt = new DataTable("Test"); + dt.Columns.Add("Value", typeof(double)); + foreach (double v in expected) + { + dt.Rows.Add(v); + } + + DbfReader.CreateDbf(_testDbfPath, dt); + + var reader = new DbfReader(_testDbfPath); + try + { + reader.Open(); + var view = reader.GetTableManager(Path.GetFileNameWithoutExtension(_testDbfPath)); + + // DBF's "0.00000000000e+000" format only retains 11 digits of mantissa precision, + // so use approximate equality rather than bit-exact. + Assert.Equal(expected.Length, view.NumberOfRows); + for (int i = 0; i < expected.Length; i++) + { + double actual = Convert.ToDouble(view.GetCell(0, i), CultureInfo.InvariantCulture); + Assert.Equal(expected[i], actual, precision: 8); + } + } + finally + { + reader.Close(); + } + }); + } + + [Fact] + public void CreateDbf_FileWrittenInGerman_ReadableInUS() + { + double[] expected = { 1234.5678, -42.0, 0.001 }; + + // Write under de-DE + RunUnderCulture("de-DE", () => + { + var dt = new DataTable("Test"); + dt.Columns.Add("Value", typeof(double)); + foreach (double v in expected) dt.Rows.Add(v); + DbfReader.CreateDbf(_testDbfPath, dt); + }); + + // Read under en-US — must succeed + RunUnderCulture("en-US", () => + { + var reader = new DbfReader(_testDbfPath); + try + { + reader.Open(); + var view = reader.GetTableManager(Path.GetFileNameWithoutExtension(_testDbfPath)); + for (int i = 0; i < expected.Length; i++) + { + double actual = Convert.ToDouble(view.GetCell(0, i), CultureInfo.InvariantCulture); + Assert.Equal(expected[i], actual, precision: 8); + } + } + finally + { + reader.Close(); + } + }); + } + + [Fact] + public void CreateDbf_FloatColumn_FileUsesInvariantFormat_UnderGermanCulture() + { + RunUnderCulture("de-DE", () => + { + var dt = new DataTable("Test"); + dt.Columns.Add("F", typeof(float)); + dt.Rows.Add(1.5f); + dt.Rows.Add(2.5f); + + DbfReader.CreateDbf(_testDbfPath, dt); + + byte[] bytes = File.ReadAllBytes(_testDbfPath); + string asAscii = Encoding.ASCII.GetString(bytes); + + // No comma-decimal floating-point patterns + Assert.DoesNotContain("1,500", asAscii); + Assert.DoesNotContain("2,500", asAscii); + }); + } + + private static void RunUnderCulture(string cultureName, Action body) + { + var prevCulture = Thread.CurrentThread.CurrentCulture; + try + { + var culture = new CultureInfo(cultureName); + Thread.CurrentThread.CurrentCulture = culture; + CultureInfo.CurrentCulture = culture; + body(); + } + finally + { + Thread.CurrentThread.CurrentCulture = prevCulture; + CultureInfo.CurrentCulture = prevCulture; + } + } + } +} diff --git a/src/DatabaseManager.Tests/DataTableViewCultureTests.cs b/src/DatabaseManager.Tests/DataTableViewCultureTests.cs new file mode 100644 index 00000000..a334919f --- /dev/null +++ b/src/DatabaseManager.Tests/DataTableViewCultureTests.cs @@ -0,0 +1,154 @@ +using System; +using System.Globalization; +using System.Threading; +using DatabaseManager; +using Xunit; + +namespace DatabaseManager.Tests +{ + /// + /// Verifies the dual-culture fallback in . + /// + /// + /// The fallback tries first (matching how the + /// user typed/pasted data in their own locale), then falls back to + /// for cross-machine data. The fallback only + /// fires for strings the CurrentCulture parser REJECTS — strings that succeed-but-misparse + /// under CurrentCulture (e.g., "1.5" on de-DE, where "." is thousands separator) are NOT + /// recovered. This is a documented limitation of the dual-culture pattern. + /// + [Collection("CultureSensitive")] + public class DataTableViewCultureTests + { + [Fact] + public void ConvertToColumnType_Double_InvariantInfinity_FallsThroughToInvariantUnderGermanCulture() + { + // "Infinity" is rejected by de-DE parser (de-DE uses "∞") but accepted by Invariant. + // Without the dual-culture fallback, ConvertToColumnType would return false here. + RunUnderCulture("de-DE", () => + { + object value = "Infinity"; + Assert.True(DataTableView.ConvertToColumnType(typeof(double), ref value)); + Assert.True(double.IsPositiveInfinity((double)value)); + }); + } + + [Fact] + public void ConvertToColumnType_Double_NegativeInvariantInfinity_FallsThroughToInvariantUnderGermanCulture() + { + RunUnderCulture("de-DE", () => + { + object value = "-Infinity"; + Assert.True(DataTableView.ConvertToColumnType(typeof(double), ref value)); + Assert.True(double.IsNegativeInfinity((double)value)); + }); + } + + [Fact] + public void ConvertToColumnType_Double_USFormatWithThousandsSeparator_FallsThroughToInvariantUnderGermanCulture() + { + // "1,234.56" is rejected by de-DE (comma=decimal, can't have a period after) but + // accepted by Invariant (comma=thousands, period=decimal). + RunUnderCulture("de-DE", () => + { + object value = "1,234.56"; + Assert.True(DataTableView.ConvertToColumnType(typeof(double), ref value)); + Assert.Equal(1234.56, (double)value); + }); + } + + [Fact] + public void ConvertToColumnType_Double_GermanFormat_ParsedViaCurrentCultureUnderGermanCulture() + { + // "1,5" parses as 1.5 under de-DE (comma=decimal). This validates the + // CurrentCulture leg of the fallback (no fall-through needed). + RunUnderCulture("de-DE", () => + { + object value = "1,5"; + Assert.True(DataTableView.ConvertToColumnType(typeof(double), ref value)); + Assert.Equal(1.5, (double)value); + }); + } + + [Fact] + public void ConvertToColumnType_Int_USFormatWithMultipleThousands_FallsThroughToInvariantUnderGermanCulture() + { + // Non-double numeric path: "1,234,567" is rejected by de-DE (commas as decimal + // can only appear once), accepted by Invariant (commas as thousands separator). + // Single-comma cases like "1,234" succeed under both cultures with DIFFERENT + // values (1.234 vs 1234) — using multi-comma forces the fall-through path. + RunUnderCulture("de-DE", () => + { + object value = "1,234,567"; + Assert.True(DataTableView.ConvertToColumnType(typeof(int), ref value)); + Assert.Equal(1234567, (int)value); + }); + } + + [Fact] + public void ConvertToColumnType_Long_InvariantInfinity_RejectedDueToOverflowConversion() + { + // Even though "Infinity" parses via Invariant fallback, Convert.ToInt64 of + // double.PositiveInfinity throws OverflowException → ConvertToColumnType catches + // and returns false. Documents the chain's behavior. + RunUnderCulture("de-DE", () => + { + object value = "Infinity"; + Assert.False(DataTableView.ConvertToColumnType(typeof(long), ref value)); + }); + } + + [Fact] + public void ConvertToColumnType_Float_USFormatWithThousandsAndDecimal_FallsThroughToInvariantUnderGermanCulture() + { + // "1,234.56" rejected by de-DE (period is thousands; comma already used as decimal) + // → falls through to Invariant which parses correctly as 1234.56. + RunUnderCulture("de-DE", () => + { + object value = "1,234.56"; + Assert.True(DataTableView.ConvertToColumnType(typeof(float), ref value)); + Assert.Equal(1234.56f, (float)value); + }); + } + + [Fact] + public void ConvertToColumnType_Double_Garbage_ReturnsFalseUnderAllCultures() + { + foreach (string culture in new[] { "en-US", "de-DE", "fr-FR" }) + { + RunUnderCulture(culture, () => + { + object value = "not a number"; + Assert.False(DataTableView.ConvertToColumnType(typeof(double), ref value), + $"Garbage string should not parse under {culture}"); + }); + } + } + + [Fact] + public void ConvertToColumnType_Double_NullValue_ReturnsTrueAsDBNull() + { + // Sanity check: pre-existing null-handling not regressed by helper introduction. + object? value = null; + Assert.True(DataTableView.ConvertToColumnType(typeof(double), ref value!)); + Assert.Equal(DBNull.Value, value); + } + + private static void RunUnderCulture(string cultureName, Action body) + { + var prevCulture = Thread.CurrentThread.CurrentCulture; + try + { + var culture = new CultureInfo(cultureName); + Thread.CurrentThread.CurrentCulture = culture; + CultureInfo.CurrentCulture = culture; + body(); + } + finally + { + Thread.CurrentThread.CurrentCulture = prevCulture; + CultureInfo.CurrentCulture = prevCulture; + } + } + } +} diff --git a/src/DatabaseManager.Tests/DataTableViewTests.cs b/src/DatabaseManager.Tests/DataTableViewTests.cs index 17870727..1af4e93f 100644 --- a/src/DatabaseManager.Tests/DataTableViewTests.cs +++ b/src/DatabaseManager.Tests/DataTableViewTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Data; using Xunit; diff --git a/src/DatabaseManager.Tests/DatabaseManagerTests.cs b/src/DatabaseManager.Tests/DatabaseManagerTests.cs index d9467f40..0b627491 100644 --- a/src/DatabaseManager.Tests/DatabaseManagerTests.cs +++ b/src/DatabaseManager.Tests/DatabaseManagerTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using Xunit; using DatabaseManager; diff --git a/src/DatabaseManager.Tests/EdgeCaseTests.cs b/src/DatabaseManager.Tests/EdgeCaseTests.cs index ea0a67e5..b5cee034 100644 --- a/src/DatabaseManager.Tests/EdgeCaseTests.cs +++ b/src/DatabaseManager.Tests/EdgeCaseTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Data; using Xunit; diff --git a/src/DatabaseManager.Tests/InMemoryReaderTests.cs b/src/DatabaseManager.Tests/InMemoryReaderTests.cs index 1b1e6412..41980411 100644 --- a/src/DatabaseManager.Tests/InMemoryReaderTests.cs +++ b/src/DatabaseManager.Tests/InMemoryReaderTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Data; using Xunit; diff --git a/src/DatabaseManager.Tests/IntegrationTests.cs b/src/DatabaseManager.Tests/IntegrationTests.cs index 3e075c98..7a2a1f4a 100644 --- a/src/DatabaseManager.Tests/IntegrationTests.cs +++ b/src/DatabaseManager.Tests/IntegrationTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Data; using System.IO; diff --git a/src/DatabaseManager.Tests/RegressionTests.cs b/src/DatabaseManager.Tests/RegressionTests.cs index 78209af5..dc26e886 100644 --- a/src/DatabaseManager.Tests/RegressionTests.cs +++ b/src/DatabaseManager.Tests/RegressionTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Data; diff --git a/src/DatabaseManager.Tests/SQLiteManagerTests.cs b/src/DatabaseManager.Tests/SQLiteManagerTests.cs index 7e16bc2d..fe5d605a 100644 --- a/src/DatabaseManager.Tests/SQLiteManagerTests.cs +++ b/src/DatabaseManager.Tests/SQLiteManagerTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Data; using System.Data.SQLite; diff --git a/src/DatabaseManager.Tests/TableEditTests.cs b/src/DatabaseManager.Tests/TableEditTests.cs index a0ded0b2..224bbc2b 100644 --- a/src/DatabaseManager.Tests/TableEditTests.cs +++ b/src/DatabaseManager.Tests/TableEditTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Linq; diff --git a/src/DatabaseManager/CSVReader.cs b/src/DatabaseManager/CSVReader.cs index 82f6e6ae..9836ed53 100644 --- a/src/DatabaseManager/CSVReader.cs +++ b/src/DatabaseManager/CSVReader.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Data; using System.IO; diff --git a/src/DatabaseManager/DBFReader.cs b/src/DatabaseManager/DBFReader.cs index d876aaf2..d0175687 100644 --- a/src/DatabaseManager/DBFReader.cs +++ b/src/DatabaseManager/DBFReader.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Data; using System.Globalization; @@ -1808,7 +1778,7 @@ protected override void AddColumnToDatabase(string columnName, double[] columnDa for (int i = 0; i < nRecords; i++) { recordBytes = _parentDbfReader.DbReader.ReadBytes(recordLen); - asciiBytes = System.Text.Encoding.ASCII.GetBytes(columnData[i].ToString("0.00000000000e+000").PadRight(fieldLength, ' ')); + asciiBytes = System.Text.Encoding.ASCII.GetBytes(columnData[i].ToString("0.00000000000e+000", CultureInfo.InvariantCulture).PadRight(fieldLength, ' ')); writeBwDbf.Write(recordBytes); writeBwDbf.Write(asciiBytes); } @@ -1918,7 +1888,7 @@ protected override void AddColumnToDatabase(string columnName, float[] columnDat for (int i = 0; i < nRecords; i++) { recordBytes = _parentDbfReader.DbReader.ReadBytes(recordLen); - asciiBytes = System.Text.Encoding.ASCII.GetBytes(columnData[i].ToString("0.00000000000e+000").PadRight(fieldLength, ' ')); + asciiBytes = System.Text.Encoding.ASCII.GetBytes(columnData[i].ToString("0.00000000000e+000", CultureInfo.InvariantCulture).PadRight(fieldLength, ' ')); writeBwDbf.Write(recordBytes); writeBwDbf.Write(asciiBytes); } @@ -3742,12 +3712,12 @@ public static void CreateDbf(string outputPath, List columnHeaders, List } case var case14 when case14 == typeof(float[]): { - cellText = ((float[])recordData[column])[i].ToString("0.00000000000e+000"); + cellText = ((float[])recordData[column])[i].ToString("0.00000000000e+000", CultureInfo.InvariantCulture); break; } case var case15 when case15 == typeof(double[]): { - cellText = ((double[])recordData[column])[i].ToString("0.00000000000e+000"); + cellText = ((double[])recordData[column])[i].ToString("0.00000000000e+000", CultureInfo.InvariantCulture); break; } case var case16 when case16 == typeof(bool[]): @@ -3963,7 +3933,7 @@ public static void CreateDbf(string outputPath, DataTable dt, bool overwrite = t else if (row[c] is double || row[c] is float) { // col is floating point (single or double) - cellText = Convert.ToDouble(row[c]).ToString("0.00000000000e+000"); + cellText = Convert.ToDouble(row[c]).ToString("0.00000000000e+000", CultureInfo.InvariantCulture); } else if (row[c] is int) { diff --git a/src/DatabaseManager/DataTableView.cs b/src/DatabaseManager/DataTableView.cs index c0412068..e06081fd 100644 --- a/src/DatabaseManager/DataTableView.cs +++ b/src/DatabaseManager/DataTableView.cs @@ -1,36 +1,7 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Data; +using System.Globalization; using System.IO; using System.Linq; #if NET9_0_OR_GREATER @@ -495,6 +466,19 @@ public void ApplyEdits() /// The cell edit object containing row, column, and value. private void ApplyCellEdit(CellEdit cellToEdit) { + // Guard against null/DBNull cell values — cellToEdit.Value.GetType() + // would NRE. ConvertToColumnType normally maps null to DBNull before + // the edit reaches this stack, so a null here is unexpected; emit a + // diagnostic and skip the apply rather than crashing the dispatcher. + // The cell retains its prior stored value; a cleared cell should be + // routed through ConvertToColumnType (which produces a typed default). + if (cellToEdit.Value is null || cellToEdit.Value is DBNull) + { + System.Diagnostics.Debug.WriteLine( + $"[DataTableView] Skipping null/DBNull cell edit at column {cellToEdit.ColumnIndex}, row {cellToEdit.RowIndex}."); + return; + } + switch (cellToEdit.Value.GetType()) { case var @case when @case == typeof(double): @@ -2392,41 +2376,36 @@ protected void AddRowsToDatabase(DataTable newRowData) public int SearchColumn(int startIndex, int endIndex, string columnName, string searchValue, bool matchCase, bool wholeWord) { if (_columnNames.Contains(columnName) == false) - { - return -1; + { + return -1; } int loopStep = 1; string cellValue; - if (matchCase == false) - { - searchValue = searchValue.ToLower(); - } + // Avoid ToLower() — culture-dependent and allocates per-call. Use StringComparison + // overloads of Contains/Equals so we never copy the string just to compare it. + var comparison = matchCase ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; if (startIndex > endIndex) { - loopStep = -1; + loopStep = -1; } object[] columnArray = GetColumn(columnName); if (columnArray.Length == 0) - { - return -1; + { + return -1; } for (int i = startIndex; loopStep >= 0 ? i <= endIndex : i >= endIndex; i += loopStep) { cellValue = columnArray[i].ToString(); - if (matchCase == false) - { - cellValue = cellValue.ToLower(); - } if (wholeWord == false) { - if (cellValue.Contains(searchValue)) + if (cellValue != null && searchValue != null && cellValue.Contains(searchValue, comparison)) { return i; } } - else if ((searchValue ?? "") == (cellValue ?? "")) - { - return i; + else if (string.Equals(searchValue ?? "", cellValue ?? "", comparison)) + { + return i; } } return -1; @@ -2773,6 +2752,21 @@ public void ExportToDbf(string filePath, int[] rowIndicesToExport = null, int[] } } + // Try CurrentCulture first (matches how the user typed/pasted), fall back to + // InvariantCulture so cross-machine data (e.g., a US-format CSV pasted on a German + // machine) is still readable. + private static bool TryParseDoubleDualCulture(string text, out double result) + { + return double.TryParse(text, NumberStyles.Any, CultureInfo.CurrentCulture, out result) + || double.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out result); + } + + private static bool TryParseSingleDualCulture(string text, out float result) + { + return float.TryParse(text, NumberStyles.Any, CultureInfo.CurrentCulture, out result) + || float.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out result); + } + /// /// Converts the input value to the specified type. /// @@ -2797,7 +2791,7 @@ public static bool ConvertToColumnType(Type columnType, ref object value) if (value.GetType() != typeof(double)) { double test; - if (double.TryParse(value.ToString(), out test) == false) + if (TryParseDoubleDualCulture(value.ToString(), out test) == false) { return false; } @@ -2811,7 +2805,7 @@ public static bool ConvertToColumnType(Type columnType, ref object value) if (value.GetType() != typeof(float)) { float test; - if (float.TryParse(value.ToString(), out test) == false) + if (TryParseSingleDualCulture(value.ToString(), out test) == false) { return false; } @@ -2824,7 +2818,7 @@ public static bool ConvertToColumnType(Type columnType, ref object value) { double test; long test2; - if (double.TryParse(value.ToString(), out test) == false) + if (TryParseDoubleDualCulture(value.ToString(), out test) == false) { return false; } @@ -2843,7 +2837,7 @@ public static bool ConvertToColumnType(Type columnType, ref object value) { double test; ulong test2; - if (double.TryParse(value.ToString(), out test) == false) + if (TryParseDoubleDualCulture(value.ToString(), out test) == false) { return false; } @@ -2862,7 +2856,7 @@ public static bool ConvertToColumnType(Type columnType, ref object value) { double test; int test2; - if (double.TryParse(value.ToString(), out test) == false) + if (TryParseDoubleDualCulture(value.ToString(), out test) == false) { return false; } @@ -2881,7 +2875,7 @@ public static bool ConvertToColumnType(Type columnType, ref object value) { double test; uint test2; - if (double.TryParse(value.ToString(), out test) == false) + if (TryParseDoubleDualCulture(value.ToString(), out test) == false) { return false; } @@ -2900,7 +2894,7 @@ public static bool ConvertToColumnType(Type columnType, ref object value) { double test; short test2; - if (double.TryParse(value.ToString(), out test) == false) + if (TryParseDoubleDualCulture(value.ToString(), out test) == false) { return false; } @@ -2919,7 +2913,7 @@ public static bool ConvertToColumnType(Type columnType, ref object value) { double test; ushort test2; - if (double.TryParse(value.ToString(), out test) == false) + if (TryParseDoubleDualCulture(value.ToString(), out test) == false) { return false; } @@ -2938,7 +2932,7 @@ public static bool ConvertToColumnType(Type columnType, ref object value) { double test; byte test2; - if (double.TryParse(value.ToString(), out test) == false) + if (TryParseDoubleDualCulture(value.ToString(), out test) == false) { return false; } @@ -3045,7 +3039,11 @@ public static object GetDefaultFromType(Type columnType) default: { - return new NotImplementedException(); + // Throw rather than RETURN an exception object — previously the + // exception was used as a cell value, which crashed downstream + // type-validation with a stack trace far from the root cause. + throw new NotImplementedException( + $"GetDefaultFromType: no default value defined for column type '{columnType}'."); } } } diff --git a/src/DatabaseManager/DatabaseManager.cs b/src/DatabaseManager/DatabaseManager.cs index 2a3de776..f4cde168 100644 --- a/src/DatabaseManager/DatabaseManager.cs +++ b/src/DatabaseManager/DatabaseManager.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Data; using System.IO; diff --git a/src/DatabaseManager/InMemoryReader.cs b/src/DatabaseManager/InMemoryReader.cs index fe744c76..2bd1abbc 100644 --- a/src/DatabaseManager/InMemoryReader.cs +++ b/src/DatabaseManager/InMemoryReader.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Data; using System.Linq; diff --git a/src/DatabaseManager/SQLiteManager.cs b/src/DatabaseManager/SQLiteManager.cs index c174ad5f..a58bc6de 100644 --- a/src/DatabaseManager/SQLiteManager.cs +++ b/src/DatabaseManager/SQLiteManager.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Data; using System.Data.SQLite; @@ -314,6 +284,30 @@ public void Optimize() #region Database Table Management + /// + /// Validates a table or column identifier for safe inclusion in SQL via + /// [bracket] quoting. Rejects names that contain a closing bracket + /// (which would break the quote) or null bytes. Public entry points that + /// build SQL from caller-supplied identifiers should call this once at the + /// boundary so internal SQL construction can trust the input. + /// + /// The identifier to validate. + /// Name of the parameter being validated, for the exception message. + /// The identifier is null, empty, or contains ] or a null byte. + private static void ValidateIdentifier(string name, string paramName) + { + if (string.IsNullOrEmpty(name)) + { + throw new ArgumentException("Identifier must not be null or empty.", paramName); + } + if (name.IndexOf(']') >= 0 || name.IndexOf('\0') >= 0) + { + throw new ArgumentException( + $"Identifier '{name}' contains characters that are not safe for SQL bracket-quoting (']' or null byte).", + paramName); + } + } + /// /// Copy table. /// @@ -321,9 +315,12 @@ public void Optimize() /// The name of the new table. public void CopyTable(string existingTableName, string newTableName) { + ValidateIdentifier(existingTableName, nameof(existingTableName)); + ValidateIdentifier(newTableName, nameof(newTableName)); + bool wasOpen = _dataBaseOpen; if (_dataBaseOpen == false) - { + { Open(); } if (_tableNames.Contains(existingTableName) == false) @@ -374,10 +371,13 @@ public void CopyTable(string existingTableName, string newTableName) /// The new name of the table. public void RenameTable(string oldTableName, string newTableName) { + ValidateIdentifier(oldTableName, nameof(oldTableName)); + ValidateIdentifier(newTableName, nameof(newTableName)); + bool wasOpen = _dataBaseOpen; if (_dataBaseOpen == false) - { - Open(); + { + Open(); } if (_tableNames.Contains(oldTableName) == false) { @@ -597,10 +597,20 @@ public void SaveDataTable(DataTable dt) /// Array of table column types. public void CreateTable(string newTableName, string[] tableColumnNames, Type[] newColumnTypes) { + ValidateIdentifier(newTableName, nameof(newTableName)); + if (tableColumnNames == null) + { + throw new ArgumentNullException(nameof(tableColumnNames)); + } + for (int i = 0; i < tableColumnNames.Length; i++) + { + ValidateIdentifier(tableColumnNames[i], $"{nameof(tableColumnNames)}[{i}]"); + } + bool wasOpen = _dataBaseOpen; if (_dataBaseOpen == false) - { - Open(); + { + Open(); } var sb = new System.Text.StringBuilder(500); sb.Append("Create Table [").Append(newTableName).Append("] ("); @@ -709,6 +719,7 @@ public void CreateTable(string newTableName, string[] tableColumnNames, Type[] n /// Optional. Maximum number of attempts to write to table from parallel loops. Default = 8. public void AppendRows(string tableName, DataTable newRowData, int maxAttempts = 8) { + ValidateIdentifier(tableName, nameof(tableName)); for (int ma = maxAttempts; ma >= 0; ma -= 1) { @@ -865,6 +876,7 @@ public void AppendRows(string tableName, DataTable newRowData, int maxAttempts = /// Table name. public void DeleteTable(string tableName) { + ValidateIdentifier(tableName, nameof(tableName)); if (_tableNames.Contains(tableName) == false) { return; } bool wasOpen = _dataBaseOpen; if (_dataBaseOpen == false) @@ -889,6 +901,7 @@ public void DeleteTable(string tableName) /// Table name. public void DeleteTableData(string tableName) { + ValidateIdentifier(tableName, nameof(tableName)); if (_tableNames.Contains(tableName) == false) { return; } bool wasOpen = _dataBaseOpen; if (_dataBaseOpen == false) @@ -918,6 +931,7 @@ public void DeleteTableData(string tableName) /// A instance for managing the specified table. public override DataTableView GetTableManager(string tableName) { + ValidateIdentifier(tableName, nameof(tableName)); return new SqLiteTableManager(this, tableName, _dbConnection); } @@ -928,6 +942,7 @@ public override DataTableView GetTableManager(string tableName) /// The number of rows in the table. public override long GetStoredNumberOfRows(string tableName) { + ValidateIdentifier(tableName, nameof(tableName)); bool wasOpen = _dataBaseOpen; if (_dataBaseOpen == false) { @@ -948,12 +963,13 @@ public override long GetStoredNumberOfRows(string tableName) /// public override int GetStoredNumberOfColumns(string tableName) { + ValidateIdentifier(tableName, nameof(tableName)); bool wasOpen = _dataBaseOpen; if (_dataBaseOpen == false) - { + { Open(); } - // + // int columnCount; using (var command = new SQLiteCommand("PRAGMA table_info([" + tableName + "])", _dbConnection)) { @@ -1414,6 +1430,7 @@ protected override void DeleteRowsFromDatabase(int[] rowIndices) /// protected override void AddColumnToDatabase(string columnName, byte[][] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -1450,6 +1467,7 @@ protected override void AddColumnToDatabase(string columnName, byte[][] columnDa /// protected override void AddColumnToDatabase(string columnName, byte[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -1486,6 +1504,7 @@ protected override void AddColumnToDatabase(string columnName, byte[] columnData /// protected override void AddColumnToDatabase(string columnName, double[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -1522,6 +1541,7 @@ protected override void AddColumnToDatabase(string columnName, double[] columnDa /// protected override void AddColumnToDatabase(string columnName, int[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -1559,6 +1579,7 @@ protected override void AddColumnToDatabase(string columnName, int[] columnData) /// protected override void AddColumnToDatabase(string columnName, long[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -1595,6 +1616,7 @@ protected override void AddColumnToDatabase(string columnName, long[] columnData /// protected override void AddColumnToDatabase(string columnName, short[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -1631,6 +1653,7 @@ protected override void AddColumnToDatabase(string columnName, short[] columnDat /// protected override void AddColumnToDatabase(string columnName, float[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -1667,6 +1690,7 @@ protected override void AddColumnToDatabase(string columnName, float[] columnDat /// protected override void AddColumnToDatabase(string columnName, bool[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -1703,6 +1727,7 @@ protected override void AddColumnToDatabase(string columnName, bool[] columnData /// protected override void AddColumnToDatabase(string columnName, string[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -2071,6 +2096,7 @@ protected override void EditDatabaseCell(int columnIndex, int rowIndex, DateTime /// protected override void EditDatabaseColumn(string columnName, bool[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -2123,6 +2149,7 @@ protected override void EditDatabaseColumn(string columnName, bool[] columnData) /// protected override void EditDatabaseColumn(string columnName, byte[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -2176,6 +2203,7 @@ protected override void EditDatabaseColumn(string columnName, byte[] columnData) /// protected override void EditDatabaseColumn(string columnName, byte[][] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -2225,6 +2253,7 @@ protected override void EditDatabaseColumn(string columnName, byte[][] columnDat /// protected override void EditDatabaseColumn(string columnName, double[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -2277,6 +2306,7 @@ protected override void EditDatabaseColumn(string columnName, double[] columnDat /// protected override void EditDatabaseColumn(string columnName, int[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -2329,6 +2359,7 @@ protected override void EditDatabaseColumn(string columnName, int[] columnData) /// protected override void EditDatabaseColumn(string columnName, short[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -2381,6 +2412,7 @@ protected override void EditDatabaseColumn(string columnName, short[] columnData /// protected override void EditDatabaseColumn(string columnName, long[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -2433,6 +2465,7 @@ protected override void EditDatabaseColumn(string columnName, long[] columnData) /// protected override void EditDatabaseColumn(string columnName, float[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { @@ -2485,6 +2518,7 @@ protected override void EditDatabaseColumn(string columnName, float[] columnData /// protected override void EditDatabaseColumn(string columnName, string[] columnData) { + ValidateIdentifier(columnName, nameof(columnName)); bool wasOpen = _parentDatabase.DataBaseOpen; if (_parentDatabase.DataBaseOpen == false) { diff --git a/src/DatabaseManager/Table Edits/AddColumnEdit.cs b/src/DatabaseManager/Table Edits/AddColumnEdit.cs index 15f3d389..3feb7648 100644 --- a/src/DatabaseManager/Table Edits/AddColumnEdit.cs +++ b/src/DatabaseManager/Table Edits/AddColumnEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Linq; diff --git a/src/DatabaseManager/Table Edits/AddColumnsEdit.cs b/src/DatabaseManager/Table Edits/AddColumnsEdit.cs index 75442396..8e4cae83 100644 --- a/src/DatabaseManager/Table Edits/AddColumnsEdit.cs +++ b/src/DatabaseManager/Table Edits/AddColumnsEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace DatabaseManager { diff --git a/src/DatabaseManager/Table Edits/AddRowEdit.cs b/src/DatabaseManager/Table Edits/AddRowEdit.cs index 72cc993b..da1566f9 100644 --- a/src/DatabaseManager/Table Edits/AddRowEdit.cs +++ b/src/DatabaseManager/Table Edits/AddRowEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; namespace DatabaseManager diff --git a/src/DatabaseManager/Table Edits/AddRowsEdit.cs b/src/DatabaseManager/Table Edits/AddRowsEdit.cs index 538b56f1..868b6078 100644 --- a/src/DatabaseManager/Table Edits/AddRowsEdit.cs +++ b/src/DatabaseManager/Table Edits/AddRowsEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; namespace DatabaseManager diff --git a/src/DatabaseManager/Table Edits/CellEdit.cs b/src/DatabaseManager/Table Edits/CellEdit.cs index 0fc0cba4..9970f30b 100644 --- a/src/DatabaseManager/Table Edits/CellEdit.cs +++ b/src/DatabaseManager/Table Edits/CellEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace DatabaseManager { diff --git a/src/DatabaseManager/Table Edits/ColumnEdit.cs b/src/DatabaseManager/Table Edits/ColumnEdit.cs index fe899408..6db975c6 100644 --- a/src/DatabaseManager/Table Edits/ColumnEdit.cs +++ b/src/DatabaseManager/Table Edits/ColumnEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Linq; diff --git a/src/DatabaseManager/Table Edits/DeleteColumnEdit.cs b/src/DatabaseManager/Table Edits/DeleteColumnEdit.cs index 3eaa5382..eb2b552d 100644 --- a/src/DatabaseManager/Table Edits/DeleteColumnEdit.cs +++ b/src/DatabaseManager/Table Edits/DeleteColumnEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace DatabaseManager { diff --git a/src/DatabaseManager/Table Edits/DeleteColumnsEdit.cs b/src/DatabaseManager/Table Edits/DeleteColumnsEdit.cs index eb29b09b..34993d90 100644 --- a/src/DatabaseManager/Table Edits/DeleteColumnsEdit.cs +++ b/src/DatabaseManager/Table Edits/DeleteColumnsEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace DatabaseManager { diff --git a/src/DatabaseManager/Table Edits/DeleteRowEdit.cs b/src/DatabaseManager/Table Edits/DeleteRowEdit.cs index e10800c0..b9cfc9d2 100644 --- a/src/DatabaseManager/Table Edits/DeleteRowEdit.cs +++ b/src/DatabaseManager/Table Edits/DeleteRowEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace DatabaseManager { diff --git a/src/DatabaseManager/Table Edits/DeleteRowsEdit.cs b/src/DatabaseManager/Table Edits/DeleteRowsEdit.cs index 44838dcf..1c5d30be 100644 --- a/src/DatabaseManager/Table Edits/DeleteRowsEdit.cs +++ b/src/DatabaseManager/Table Edits/DeleteRowsEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; namespace DatabaseManager diff --git a/src/DatabaseManager/Table Edits/IColumnEdit.cs b/src/DatabaseManager/Table Edits/IColumnEdit.cs index d08bc547..48869c61 100644 --- a/src/DatabaseManager/Table Edits/IColumnEdit.cs +++ b/src/DatabaseManager/Table Edits/IColumnEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; namespace DatabaseManager { diff --git a/src/DatabaseManager/Table Edits/MultiCellEdit.cs b/src/DatabaseManager/Table Edits/MultiCellEdit.cs index eaf653dc..38d56df6 100644 --- a/src/DatabaseManager/Table Edits/MultiCellEdit.cs +++ b/src/DatabaseManager/Table Edits/MultiCellEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace DatabaseManager diff --git a/src/DatabaseManager/Table Edits/RowEdit.cs b/src/DatabaseManager/Table Edits/RowEdit.cs index a0ca0095..eb626b0e 100644 --- a/src/DatabaseManager/Table Edits/RowEdit.cs +++ b/src/DatabaseManager/Table Edits/RowEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Linq; diff --git a/src/DatabaseManager/Table Edits/TableEdit.cs b/src/DatabaseManager/Table Edits/TableEdit.cs index d01c42c0..7403fa9d 100644 --- a/src/DatabaseManager/Table Edits/TableEdit.cs +++ b/src/DatabaseManager/Table Edits/TableEdit.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace DatabaseManager { diff --git a/src/ExpressionParser.Tests/ArithmeticTests.cs b/src/ExpressionParser.Tests/ArithmeticTests.cs index 32fd249b..b2ae9cc1 100644 --- a/src/ExpressionParser.Tests/ArithmeticTests.cs +++ b/src/ExpressionParser.Tests/ArithmeticTests.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/ExpressionParser.Tests/AuditRegressionTests.cs b/src/ExpressionParser.Tests/AuditRegressionTests.cs new file mode 100644 index 00000000..4c85d34e --- /dev/null +++ b/src/ExpressionParser.Tests/AuditRegressionTests.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using ExpressionParser; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace ExpressionParser.Tests +{ + /// + /// Regression tests pinning forensic-audit Phase 2e Models corrections. + /// Each test name references the audit finding ID it covers. + /// + [TestClass] + public class AuditRegressionTests + { + /// + /// C-001 — Numeric binary nodes / IF nodes used to widen a Single-typed branch + /// only when its OutputType was exactly ResultType.Double. A declared + /// Single variable (or any non-Double float) would fall through the float check + /// and cause integer-arithmetic truncation. The fix tests against the + /// FloatingPoint flag (Double | Single) so float operands stay floating. + /// This test pins the resulting precision: 1.5 must remain 1.5, not become 1. + /// + [TestMethod] + public void C001_IfNode_PreservesFloatPrecisionWhenAllOperandsAreSingle() + { + var availableVariables = new Dictionary + { + ["a"] = ResultType.Single, + ["b"] = ResultType.Single, + }; + var node = ExpressionParser.Parser.Parser.Parse("IF(true, [a], [b])", false, availableVariables); + + // Set variable values. + var variables = node.GetVariableNodes(); + foreach (var v in variables) + { + if (v.VariableName == "a") v.SetValue(1.5); + else if (v.VariableName == "b") v.SetValue(2.5); + } + + // Act + var result = node.Evaluate(); + + // Assert — the IF picks the true branch (1.5) and float precision is preserved. + Assert.AreEqual(1.5, System.Convert.ToDouble(result.Result), 0.0001, + "Float operands in IF must preserve their fractional value (C-001)."); + } + + /// + /// C-001 — companion test: numeric binary operations on float operands must also + /// widen via the FloatingPoint flag rather than the inverted-type-equality check. + /// + [TestMethod] + public void C001_NumericBinary_FloatOperandsPreservePrecision() + { + var availableVariables = new Dictionary + { + ["a"] = ResultType.Single, + ["b"] = ResultType.Single, + }; + var node = ExpressionParser.Parser.Parser.Parse("[a] + [b]", false, availableVariables); + + var variables = node.GetVariableNodes(); + foreach (var v in variables) + { + if (v.VariableName == "a") v.SetValue(1.25); + else if (v.VariableName == "b") v.SetValue(2.5); + } + + var result = node.Evaluate(); + + // Pre-fix this would fall through to Integer arithmetic and produce 3 (rounded). + Assert.AreEqual(3.75, System.Convert.ToDouble(result.Result), 0.0001, + "Single + Single must remain a floating-point sum (C-001)."); + } + } +} diff --git a/src/ExpressionParser.Tests/ComparisonAndLogicalTests.cs b/src/ExpressionParser.Tests/ComparisonAndLogicalTests.cs index 7a9c3c8b..1517b89a 100644 --- a/src/ExpressionParser.Tests/ComparisonAndLogicalTests.cs +++ b/src/ExpressionParser.Tests/ComparisonAndLogicalTests.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/ExpressionParser.Tests/ErrorHandlingTests.cs b/src/ExpressionParser.Tests/ErrorHandlingTests.cs index 9b1bed9e..b3396049 100644 --- a/src/ExpressionParser.Tests/ErrorHandlingTests.cs +++ b/src/ExpressionParser.Tests/ErrorHandlingTests.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using ExpressionParser; diff --git a/src/ExpressionParser.Tests/LexerTests.cs b/src/ExpressionParser.Tests/LexerTests.cs index f6a89c82..c5d8df63 100644 --- a/src/ExpressionParser.Tests/LexerTests.cs +++ b/src/ExpressionParser.Tests/LexerTests.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Collections.Generic; using System.Linq; diff --git a/src/ExpressionParser.Tests/ParserTests.cs b/src/ExpressionParser.Tests/ParserTests.cs index a0ebcbdb..b74bf3ef 100644 --- a/src/ExpressionParser.Tests/ParserTests.cs +++ b/src/ExpressionParser.Tests/ParserTests.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/ExpressionParser.Tests/RegressionTests.cs b/src/ExpressionParser.Tests/RegressionTests.cs index 011d09b1..2e46a137 100644 --- a/src/ExpressionParser.Tests/RegressionTests.cs +++ b/src/ExpressionParser.Tests/RegressionTests.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System.Collections.Generic; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/ExpressionParser.Tests/Resources.Designer.cs b/src/ExpressionParser.Tests/Resources.Designer.cs index d2fc8f7a..e184d07b 100644 --- a/src/ExpressionParser.Tests/Resources.Designer.cs +++ b/src/ExpressionParser.Tests/Resources.Designer.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -// ------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 diff --git a/src/ExpressionParser.Tests/SimplifyAndVariableTests.cs b/src/ExpressionParser.Tests/SimplifyAndVariableTests.cs index e8ab7e18..11b5dde2 100644 --- a/src/ExpressionParser.Tests/SimplifyAndVariableTests.cs +++ b/src/ExpressionParser.Tests/SimplifyAndVariableTests.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Collections.Generic; using ExpressionParser; diff --git a/src/ExpressionParser.Tests/StringFunctionTests.cs b/src/ExpressionParser.Tests/StringFunctionTests.cs index 57b3beec..b9a9726b 100644 --- a/src/ExpressionParser.Tests/StringFunctionTests.cs +++ b/src/ExpressionParser.Tests/StringFunctionTests.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using Microsoft.VisualStudio.TestTools.UnitTesting; namespace ExpressionParser.Tests diff --git a/src/ExpressionParser.Tests/TypeConverterTests.cs b/src/ExpressionParser.Tests/TypeConverterTests.cs index 1abd7110..1969e963 100644 --- a/src/ExpressionParser.Tests/TypeConverterTests.cs +++ b/src/ExpressionParser.Tests/TypeConverterTests.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using Microsoft.VisualStudio.TestTools.UnitTesting; namespace ExpressionParser.Tests diff --git a/src/ExpressionParser/Lexer/Lexer.cs b/src/ExpressionParser/Lexer/Lexer.cs index 31ade761..187d27d6 100644 --- a/src/ExpressionParser/Lexer/Lexer.cs +++ b/src/ExpressionParser/Lexer/Lexer.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Text; @@ -182,11 +152,36 @@ private static string BuildNumber(string s, ref int currentPosition, ref bool ha { var result = new StringBuilder(); hasDecimal = false; + bool hasExponent = false; for (; currentPosition < s.Length; currentPosition++) { - if (char.IsDigit(s[currentPosition]) == false) + char c = s[currentPosition]; + + // Scientific notation: consume an `e`/`E` followed by optional sign and digits. + // Without this, `1.5e10` lexed as `1.5` then identifier `e10`, producing the + // confusing parser error "Cannot have two values next to each other without + // an operator". A double with `e` is also implicitly a floating-point literal. + if ((c == 'e' || c == 'E') && !hasExponent && result.Length > 0) { - if (s[currentPosition] != '.') + int peek = currentPosition + 1; + if (peek < s.Length && (s[peek] == '+' || s[peek] == '-')) peek++; + if (peek < s.Length && char.IsDigit(s[peek])) + { + hasExponent = true; + hasDecimal = true; // promote to DecimalNumber + result.Append(c); + if (s[currentPosition + 1] == '+' || s[currentPosition + 1] == '-') + { + currentPosition++; + result.Append(s[currentPosition]); + } + continue; + } + } + + if (char.IsDigit(c) == false) + { + if (c != '.') { currentPosition -= 1; break; @@ -198,9 +193,9 @@ private static string BuildNumber(string s, ref int currentPosition, ref bool ha } hasDecimal = true; } - result.Append(s[currentPosition]); + result.Append(c); } - // + // return result.ToString(); } diff --git a/src/ExpressionParser/Lexer/Token.cs b/src/ExpressionParser/Lexer/Token.cs index d3fc6624..b631a431 100644 --- a/src/ExpressionParser/Lexer/Token.cs +++ b/src/ExpressionParser/Lexer/Token.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -namespace ExpressionParser +namespace ExpressionParser { // Order of operations uses the following precedence levels: // 1 | ()   []   ->   .   :: | Function call, scope, array/member access diff --git a/src/ExpressionParser/Lexer/TokenType.cs b/src/ExpressionParser/Lexer/TokenType.cs index 70a813aa..38dc8788 100644 --- a/src/ExpressionParser/Lexer/TokenType.cs +++ b/src/ExpressionParser/Lexer/TokenType.cs @@ -1,33 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -namespace ExpressionParser +namespace ExpressionParser { /// /// Specifies the specific type of a token parsed from an expression string. diff --git a/src/ExpressionParser/Parser/Nodes/Comparisons/AndOrNode.cs b/src/ExpressionParser/Parser/Nodes/Comparisons/AndOrNode.cs index 34ed3ddc..d7992796 100644 --- a/src/ExpressionParser/Parser/Nodes/Comparisons/AndOrNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Comparisons/AndOrNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Data; using System.Linq; diff --git a/src/ExpressionParser/Parser/Nodes/Comparisons/BooleanBinaryNode.cs b/src/ExpressionParser/Parser/Nodes/Comparisons/BooleanBinaryNode.cs index 515f6f6e..166cd5f0 100644 --- a/src/ExpressionParser/Parser/Nodes/Comparisons/BooleanBinaryNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Comparisons/BooleanBinaryNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser @@ -181,7 +151,7 @@ public List GetVariableNodes() if (ContainsVariable()) { if (!(_leftNode == null)) - result?.AddRange(_leftNode.GetVariableNodes()); + result.AddRange(_leftNode.GetVariableNodes()); if (!(_rightNode == null)) result.AddRange(_rightNode.GetVariableNodes()); } diff --git a/src/ExpressionParser/Parser/Nodes/Comparisons/BooleanNode.cs b/src/ExpressionParser/Parser/Nodes/Comparisons/BooleanNode.cs index 85f56efd..828d96df 100644 --- a/src/ExpressionParser/Parser/Nodes/Comparisons/BooleanNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Comparisons/BooleanNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace ExpressionParser { diff --git a/src/ExpressionParser/Parser/Nodes/Comparisons/ContainsNode.cs b/src/ExpressionParser/Parser/Nodes/Comparisons/ContainsNode.cs index ce8765b4..3b3668be 100644 --- a/src/ExpressionParser/Parser/Nodes/Comparisons/ContainsNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Comparisons/ContainsNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser diff --git a/src/ExpressionParser/Parser/Nodes/Comparisons/IfNode.cs b/src/ExpressionParser/Parser/Nodes/Comparisons/IfNode.cs index 3199af4e..f36937b3 100644 --- a/src/ExpressionParser/Parser/Nodes/Comparisons/IfNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Comparisons/IfNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser @@ -142,7 +112,12 @@ public IfNode(List parameters, List parameterErrors, Token { if (Parser.Parser.IsNumericType(_ifTrue) && Parser.Parser.IsNumericType(_ifFalse)) { - OutputType = _ifTrue.OutputType == ResultType.Double || _ifFalse.OutputType == ResultType.Double ? ResultType.Double : ResultType.Integer; + // ResultType is a flags enum — check FloatingPoint (Double | Single) + // so Single-typed branches widen to Double instead of falling through + // to Integer arithmetic and silently rounding. + bool trueIsFloat = (_ifTrue.OutputType & ResultType.FloatingPoint) > 0; + bool falseIsFloat = (_ifFalse.OutputType & ResultType.FloatingPoint) > 0; + OutputType = (trueIsFloat || falseIsFloat) ? ResultType.Double : ResultType.Integer; } else { @@ -180,16 +155,25 @@ public IParserNode Simplify() } // var result = Evaluate().Result; + + // Numeric output types are flags. Test by group rather than equality so + // Single/Short/Byte are routed correctly: floating-point widens to + // DecimalNode; integer types collapse to IntegerNode. + if ((OutputType & ResultType.FloatingPoint) > 0) + return new DecimalNode(Convert.ToDouble(result)); + if ((OutputType & ResultType.IntegerValue) > 0) + return new IntegerNode(Convert.ToInt32(result)); + switch (OutputType) { - case ResultType.Integer: - return new IntegerNode(Convert.ToInt32(result)); - case ResultType.Double: - return new DecimalNode(Convert.ToDouble(result)); case ResultType.Boolean: return new BooleanNode(Convert.ToBoolean(result)); case ResultType.String: return new StringNode(Convert.ToString(result)); + case ResultType.Error: + // Re-evaluation in caller will surface the error path; preserve + // the existing default-numeric fallback for compatibility. + return new DecimalNode(Convert.ToDouble(result)); default: return new DecimalNode(Convert.ToDouble(result)); } diff --git a/src/ExpressionParser/Parser/Nodes/Converters/ConverterNode.cs b/src/ExpressionParser/Parser/Nodes/Converters/ConverterNode.cs index 63c2c5e1..e4d11b25 100644 --- a/src/ExpressionParser/Parser/Nodes/Converters/ConverterNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Converters/ConverterNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Globalization; diff --git a/src/ExpressionParser/Parser/Nodes/IParserNode.cs b/src/ExpressionParser/Parser/Nodes/IParserNode.cs index 0754b0cc..29a17f69 100644 --- a/src/ExpressionParser/Parser/Nodes/IParserNode.cs +++ b/src/ExpressionParser/Parser/Nodes/IParserNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace ExpressionParser { diff --git a/src/ExpressionParser/Parser/Nodes/Numerics/DecimalNode.cs b/src/ExpressionParser/Parser/Nodes/Numerics/DecimalNode.cs index a9c0c130..e9399657 100644 --- a/src/ExpressionParser/Parser/Nodes/Numerics/DecimalNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Numerics/DecimalNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace ExpressionParser { diff --git a/src/ExpressionParser/Parser/Nodes/Numerics/IncrementNode.cs b/src/ExpressionParser/Parser/Nodes/Numerics/IncrementNode.cs index 1d28a789..7bc01462 100644 --- a/src/ExpressionParser/Parser/Nodes/Numerics/IncrementNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Numerics/IncrementNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser @@ -130,7 +100,14 @@ public IncrementNode(List parameters, List parameterErrors, _errorMessages.Add(new ParseError(token, errorString + " for the increment function")); // if (!(_initialNumber == null)) - OutputType = _initialNumber.OutputType == ResultType.Double || _step.OutputType == ResultType.Double ? ResultType.Double : ResultType.Integer; + { + // ResultType is a flags enum — check FloatingPoint (Double | Single) + // so float-typed start/step values widen to Double instead of falling + // through to Integer arithmetic and silently rounding. + bool initialIsFloat = (_initialNumber.OutputType & ResultType.FloatingPoint) > 0; + bool stepIsFloat = (_step.OutputType & ResultType.FloatingPoint) > 0; + OutputType = (initialIsFloat || stepIsFloat) ? ResultType.Double : ResultType.Integer; + } // if (_errorMessages.Count > 0) OutputType = ResultType.Error; diff --git a/src/ExpressionParser/Parser/Nodes/Numerics/IntegerNode.cs b/src/ExpressionParser/Parser/Nodes/Numerics/IntegerNode.cs index 7efea9d1..54ecb6d2 100644 --- a/src/ExpressionParser/Parser/Nodes/Numerics/IntegerNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Numerics/IntegerNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace ExpressionParser { diff --git a/src/ExpressionParser/Parser/Nodes/Numerics/NumericBinaryNode.cs b/src/ExpressionParser/Parser/Nodes/Numerics/NumericBinaryNode.cs index ceb5e2bd..6eecef8f 100644 --- a/src/ExpressionParser/Parser/Nodes/Numerics/NumericBinaryNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Numerics/NumericBinaryNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser @@ -108,7 +78,13 @@ public NumericBinaryNode(IParserNode leftNode, IParserNode rightNode, Func 0; + bool rightIsFloat = (_rightNode.OutputType & ResultType.FloatingPoint) > 0; + OutputType = (leftIsFloat || rightIsFloat) ? ResultType.Double : ResultType.Integer; } if (token.Type == TokenType.Division || token.Type == TokenType.Exponent) OutputType = ResultType.Double; diff --git a/src/ExpressionParser/Parser/Nodes/Numerics/RandomBetweenNode.cs b/src/ExpressionParser/Parser/Nodes/Numerics/RandomBetweenNode.cs index 0a7c905f..4948ec5d 100644 --- a/src/ExpressionParser/Parser/Nodes/Numerics/RandomBetweenNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Numerics/RandomBetweenNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser @@ -198,15 +168,13 @@ public ParseNodeResult Evaluate() if (ContainsErrors) return new ParseNodeResult(null, ResultType.Error); // - Random randy; - if (_seed == null) - { - randy = new Random(); - } - else - { - randy = new Random(Convert.ToInt32(_seed.Evaluate().Result)); - } + // When no seed is supplied, use Random.Shared (a thread-safe, lock-free instance + // introduced in .NET 6). It is preferable to `new Random()` because consecutive + // `new Random()` calls in tight loops can produce identical seeds (clock granularity) + // and the resulting sequence is non-thread-safe. + Random randy = _seed == null + ? Random.Shared + : new Random(Convert.ToInt32(_seed.Evaluate().Result)); // if (OutputType == ResultType.Double) { @@ -230,7 +198,12 @@ public ParseNodeResult Evaluate() min = max; max = temp; } - return new ParseNodeResult(randy.Next(min, max), OutputType); + // Excel's RANDBETWEEN(min, max) is inclusive on both ends; .NET's + // Random.Next(min, max) is exclusive on max. Bump by 1 so the + // upper bound can occur — required for Excel-formula compatibility. + // Guard against int.MaxValue overflow. + int upperExclusive = (max == int.MaxValue) ? int.MaxValue : max + 1; + return new ParseNodeResult(randy.Next(min, upperExclusive), OutputType); } } diff --git a/src/ExpressionParser/Parser/Nodes/Numerics/RandomGeneratorNode.cs b/src/ExpressionParser/Parser/Nodes/Numerics/RandomGeneratorNode.cs index a6ceef4e..555692bb 100644 --- a/src/ExpressionParser/Parser/Nodes/Numerics/RandomGeneratorNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Numerics/RandomGeneratorNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser @@ -153,15 +123,13 @@ public ParseNodeResult Evaluate() if (ContainsErrors) return new ParseNodeResult(null, ResultType.Error); // - Random randy; - if (_seed == null) - { - randy = new Random(); - } - else - { - randy = new Random(Convert.ToInt32(_seed.Evaluate().Result)); - } + // When no seed is supplied, use Random.Shared (a thread-safe, lock-free instance + // introduced in .NET 6). It is preferable to `new Random()` because consecutive + // `new Random()` calls in tight loops can produce identical seeds (clock granularity) + // and the resulting sequence is non-thread-safe. + Random randy = _seed == null + ? Random.Shared + : new Random(Convert.ToInt32(_seed.Evaluate().Result)); // if (OutputType == ResultType.Double) { diff --git a/src/ExpressionParser/Parser/Nodes/Numerics/RoundNode.cs b/src/ExpressionParser/Parser/Nodes/Numerics/RoundNode.cs index 1365128e..72bef816 100644 --- a/src/ExpressionParser/Parser/Nodes/Numerics/RoundNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Numerics/RoundNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser @@ -207,7 +177,21 @@ public ParseNodeResult Evaluate() double result = _operation(Convert.ToDouble(_number.Evaluate().Result), digit); if (digit <= 0d) { - return new ParseNodeResult((int)Math.Round(result), ResultType.Integer); + double rounded = Math.Round(result); + // ROUND/ROUNDUP/ROUNDDOWN with non-positive digits historically produced an + // ResultType.Integer (32-bit int). When the rounded value falls outside Int32 + // range, an int cast silently overflows to garbage (e.g. 3,000,000,000 → -1,294,967,296). + // Promote to long when it fits, otherwise return the unboxed double so callers can + // still handle the magnitude without data loss. + if (rounded >= int.MinValue && rounded <= int.MaxValue) + { + return new ParseNodeResult((int)rounded, ResultType.Integer); + } + if (rounded >= long.MinValue && rounded <= long.MaxValue) + { + return new ParseNodeResult((long)rounded, ResultType.Integer); + } + return new ParseNodeResult(rounded, ResultType.Double); } else { diff --git a/src/ExpressionParser/Parser/Nodes/ParseError.cs b/src/ExpressionParser/Parser/Nodes/ParseError.cs index fe1dd007..d08ba846 100644 --- a/src/ExpressionParser/Parser/Nodes/ParseError.cs +++ b/src/ExpressionParser/Parser/Nodes/ParseError.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -namespace ExpressionParser +namespace ExpressionParser { /// /// Represents an error encountered during parsing or evaluation of an expression. diff --git a/src/ExpressionParser/Parser/Nodes/ParseNodeResult.cs b/src/ExpressionParser/Parser/Nodes/ParseNodeResult.cs index d75ba20a..17eb0c61 100644 --- a/src/ExpressionParser/Parser/Nodes/ParseNodeResult.cs +++ b/src/ExpressionParser/Parser/Nodes/ParseNodeResult.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; namespace ExpressionParser { diff --git a/src/ExpressionParser/Parser/Nodes/ResultType.cs b/src/ExpressionParser/Parser/Nodes/ResultType.cs index 31712401..1db9eebe 100644 --- a/src/ExpressionParser/Parser/Nodes/ResultType.cs +++ b/src/ExpressionParser/Parser/Nodes/ResultType.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -namespace ExpressionParser +namespace ExpressionParser { /// /// Represents the possible result types of a parse node evaluation. diff --git a/src/ExpressionParser/Parser/Nodes/Strings/AmpersandNode.cs b/src/ExpressionParser/Parser/Nodes/Strings/AmpersandNode.cs index 42896044..b560526a 100644 --- a/src/ExpressionParser/Parser/Nodes/Strings/AmpersandNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Strings/AmpersandNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser diff --git a/src/ExpressionParser/Parser/Nodes/Strings/ConcatenateNode.cs b/src/ExpressionParser/Parser/Nodes/Strings/ConcatenateNode.cs index 3a9d05af..a32145b1 100644 --- a/src/ExpressionParser/Parser/Nodes/Strings/ConcatenateNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Strings/ConcatenateNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; diff --git a/src/ExpressionParser/Parser/Nodes/Strings/InStringNode.cs b/src/ExpressionParser/Parser/Nodes/Strings/InStringNode.cs index 5149d3f0..4e1619aa 100644 --- a/src/ExpressionParser/Parser/Nodes/Strings/InStringNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Strings/InStringNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser diff --git a/src/ExpressionParser/Parser/Nodes/Strings/LeftStringNode.cs b/src/ExpressionParser/Parser/Nodes/Strings/LeftStringNode.cs index 1fd490f3..71b411b7 100644 --- a/src/ExpressionParser/Parser/Nodes/Strings/LeftStringNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Strings/LeftStringNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser diff --git a/src/ExpressionParser/Parser/Nodes/Strings/RightStringNode.cs b/src/ExpressionParser/Parser/Nodes/Strings/RightStringNode.cs index bf1f5645..ee2f6427 100644 --- a/src/ExpressionParser/Parser/Nodes/Strings/RightStringNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Strings/RightStringNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser diff --git a/src/ExpressionParser/Parser/Nodes/Strings/StringLengthNode.cs b/src/ExpressionParser/Parser/Nodes/Strings/StringLengthNode.cs index a42cc96d..ea8524ec 100644 --- a/src/ExpressionParser/Parser/Nodes/Strings/StringLengthNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Strings/StringLengthNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser diff --git a/src/ExpressionParser/Parser/Nodes/Strings/StringNode.cs b/src/ExpressionParser/Parser/Nodes/Strings/StringNode.cs index 4f3ecb01..b3943fc6 100644 --- a/src/ExpressionParser/Parser/Nodes/Strings/StringNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Strings/StringNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace ExpressionParser { diff --git a/src/ExpressionParser/Parser/Nodes/Strings/SubStringNode.cs b/src/ExpressionParser/Parser/Nodes/Strings/SubStringNode.cs index 71a7dada..bf2af14e 100644 --- a/src/ExpressionParser/Parser/Nodes/Strings/SubStringNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Strings/SubStringNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; namespace ExpressionParser diff --git a/src/ExpressionParser/Parser/Nodes/Variable/VariableNode.cs b/src/ExpressionParser/Parser/Nodes/Variable/VariableNode.cs index 91fbe1fc..01cf2b80 100644 --- a/src/ExpressionParser/Parser/Nodes/Variable/VariableNode.cs +++ b/src/ExpressionParser/Parser/Nodes/Variable/VariableNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace ExpressionParser { diff --git a/src/ExpressionParser/Parser/Parser.cs b/src/ExpressionParser/Parser/Parser.cs index 27c02cd0..748f5790 100644 --- a/src/ExpressionParser/Parser/Parser.cs +++ b/src/ExpressionParser/Parser/Parser.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Globalization; @@ -49,6 +19,16 @@ public static class Parser /// Specifies whether string comparisons should be case-insensitive. /// Optional dictionary mapping variable names to their expected types. Variables not in this dictionary will be marked as undeclared. /// A parse tree root node that can be evaluated; returns null if the token list is null. + /// + /// + /// Threading contract: the static method is safe to invoke + /// from multiple threads concurrently because each invocation builds an independent AST. However the + /// returned tree is not thread-safe per AST instance — some nodes (notably + /// ) carry mutable evaluation state. Once an AST is produced, treat it + /// as a single-threaded resource: confine all Evaluate()/Simplify() calls and variable-value + /// updates on its s to one thread, or wrap access in your own synchronization. + /// + /// public static IParserNode Parse(List tokens, bool ignoreCase = false, Dictionary availableVariables = null) { if (tokens == null) @@ -71,6 +51,16 @@ public static IParserNode Parse(List tokens, bool ignoreCase = false, Dic /// Specifies whether string comparisons should be case-insensitive. /// Optional dictionary mapping variable names to their expected types. Variables not in this dictionary will be marked as undeclared. /// A parse tree root node that can be evaluated; returns null if the input string is null. + /// + /// + /// Threading contract: the static method is safe to invoke + /// from multiple threads concurrently because each invocation builds an independent AST. However the + /// returned tree is not thread-safe per AST instance — some nodes (notably + /// ) carry mutable evaluation state. Once an AST is produced, treat it + /// as a single-threaded resource: confine all Evaluate()/Simplify() calls and variable-value + /// updates on its s to one thread, or wrap access in your own synchronization. + /// + /// public static IParserNode Parse(string stringToParse, bool ignoreCase = false, Dictionary availableVariables = null) { if (stringToParse == null) @@ -119,8 +109,20 @@ private static IParserNode Parse(Stack tokenStack, IParserNode leftNode, { if (int.TryParse(token.TokenString, NumberStyles.Integer, CultureInfo.InvariantCulture, out int intValue)) newNode = new IntegerNode(intValue); + else if (long.TryParse(token.TokenString, NumberStyles.Integer, CultureInfo.InvariantCulture, out long longValue)) + // Out of int range but representable as long — promote to a + // double-backed DecimalNode rather than silently producing + // IntegerNode(0), which previously caused 9999999999 * 2 to + // evaluate to 0. + newNode = new DecimalNode((double)longValue); + else if (double.TryParse(token.TokenString, NumberStyles.Integer, CultureInfo.InvariantCulture, out double dblValue)) + newNode = new DecimalNode(dblValue); else - newNode = new IntegerNode(0); + { + var fallback = new IntegerNode(0); + fallback.GetErrors.Add(new ParseError(token, "integer literal '" + token.TokenString + "' is not parseable; using 0 as a placeholder.")); + newNode = fallback; + } break; } case TokenType.DecimalNumber: diff --git a/src/ExpressionParserControls.Demo/App.xaml.cs b/src/ExpressionParserControls.Demo/App.xaml.cs index 34291a2a..b9a5bea6 100644 --- a/src/ExpressionParserControls.Demo/App.xaml.cs +++ b/src/ExpressionParserControls.Demo/App.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using Themes; @@ -38,6 +8,17 @@ namespace ExpressionParserControls.Demo /// public partial class App : Application { + public App() + { + // Set WPF to use the current culture for all bindings (international number support) + // This ensures StringFormat in XAML bindings uses the user's locale settings + FrameworkElement.LanguageProperty.OverrideMetadata( + typeof(FrameworkElement), + new FrameworkPropertyMetadata( + System.Windows.Markup.XmlLanguage.GetLanguage( + System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag))); + } + private void Application_Startup(object sender, StartupEventArgs e) { ThemeService.Instance.Initialize(Theme.Light); diff --git a/src/ExpressionParserControls.Demo/MainWindow.xaml.cs b/src/ExpressionParserControls.Demo/MainWindow.xaml.cs index 166a4afe..422f72e3 100644 --- a/src/ExpressionParserControls.Demo/MainWindow.xaml.cs +++ b/src/ExpressionParserControls.Demo/MainWindow.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Windows; using ExpressionParser; diff --git a/src/ExpressionParserControls/AvailableFunctions.xaml.cs b/src/ExpressionParserControls/AvailableFunctions.xaml.cs index 2de91310..eb047ae7 100644 --- a/src/ExpressionParserControls/AvailableFunctions.xaml.cs +++ b/src/ExpressionParserControls/AvailableFunctions.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Windows; diff --git a/src/ExpressionParserControls/CalculatorControl.xaml.cs b/src/ExpressionParserControls/CalculatorControl.xaml.cs index d882ec7f..bc676bb2 100644 --- a/src/ExpressionParserControls/CalculatorControl.xaml.cs +++ b/src/ExpressionParserControls/CalculatorControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Windows; diff --git a/src/ExpressionParserControls/ExpressionControl.xaml.cs b/src/ExpressionParserControls/ExpressionControl.xaml.cs index 75c5b3b9..5b6f5dac 100644 --- a/src/ExpressionParserControls/ExpressionControl.xaml.cs +++ b/src/ExpressionParserControls/ExpressionControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/src/ExpressionParserControls/ExpressionParserControls.csproj b/src/ExpressionParserControls/ExpressionParserControls.csproj index ef5c0e63..ff195b66 100644 --- a/src/ExpressionParserControls/ExpressionParserControls.csproj +++ b/src/ExpressionParserControls/ExpressionParserControls.csproj @@ -17,7 +17,6 @@ - diff --git a/src/ExpressionParserControls/FunctionInfo.cs b/src/ExpressionParserControls/FunctionInfo.cs index 53c6c441..80a0732c 100644 --- a/src/ExpressionParserControls/FunctionInfo.cs +++ b/src/ExpressionParserControls/FunctionInfo.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.Generic; namespace ExpressionParserControls diff --git a/src/FrameworkInterfaces/Messaging/BasicMessageItem.cs b/src/FrameworkInterfaces/Messaging/BasicMessageItem.cs index 91c37211..9c9918fa 100644 --- a/src/FrameworkInterfaces/Messaging/BasicMessageItem.cs +++ b/src/FrameworkInterfaces/Messaging/BasicMessageItem.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; namespace FrameworkInterfaces @@ -43,6 +13,26 @@ namespace FrameworkInterfaces /// source when the message is clicked. /// /// + /// Identity is captured at construction time when the full constructor is used. + /// and hash by private + /// snapshots of the , element/collection name + /// (for sources), or project name (for + /// sources) — the values present at the moment the message was constructed. + /// As a consequence, mutating Source.Name, Source.ParentCollection.Name, + /// or after the message has been added to a + /// HashSet<BasicMessageItem> or Dictionary does not change + /// its hash bucket — Contains/Remove continue to work. This is also what makes the + /// auto-increment of event-type Code values + /// safe. + /// + /// + /// Parameterless ctor + property-init pattern: when the parameterless + /// constructor is used and properties are set afterward, the snapshot fields remain + /// null and equality/hash fall back to current state. The fall-back path preserves + /// historical semantics but does not protect against post-add mutations. + /// For hash-stable usage in collections, prefer the full constructor. + /// + /// /// Authors: /// /// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil @@ -123,8 +113,32 @@ public BasicMessageItem( ParameterName = parameterName; Code = code; TimeStamp = DateTime.Now.ToString("HH:mm:ss"); + + // Snapshot the identity-relevant state at construction for use in + // GetHashCode / Equals so the hash never changes after the message is + // added to a HashSet/Dictionary. Without this, mutations to Code + // (Messenger.AddItemInternal does this for Event-type messages), + // Source.Name, or ParentCollection.Name change the hash bucket and + // break Contains/Remove on the message after it was inserted. + _identityCode = code; + if (source is IElement element) + { + _identityElementName = element.Name; + _identityParentCollectionName = element.ParentCollection?.Name; + } + else if (source is IProject project) + { + _identityProjectName = project.Name; + } } + // Identity snapshot fields — set once in the constructor and never changed. + // See ctor remarks for rationale. + private readonly string _identityCode; + private readonly string? _identityElementName; + private readonly string? _identityParentCollectionName; + private readonly string? _identityProjectName; + #endregion #region Events @@ -361,8 +375,17 @@ public bool Equals(IMessageItem? other) { if (other == null) return false; - // Compare codes first (null-safe) - if (!string.Equals(Code, other.Code, StringComparison.Ordinal)) + // Use the identity snapshots taken at construction time when available + // so two messages remain equal/unequal across mutations to Code or + // Source.Name. When the parameterless ctor was used (snapshot fields are + // null), fall back to the current property values — preserves existing + // semantics for that init pattern at the cost of not protecting against + // post-add mutations on that path. + var otherBasic = other as BasicMessageItem; + + string? thisCode = _identityCode ?? Code; + string? otherCode = otherBasic != null ? (otherBasic._identityCode ?? otherBasic.Code) : other.Code; + if (!string.Equals(thisCode, otherCode, StringComparison.Ordinal)) { return false; } @@ -373,21 +396,24 @@ public bool Equals(IMessageItem? other) return false; } - // Compare IElement sources + // Compare IElement sources via name snapshots (with fallback) if (Source is IElement element && other.Source is IElement otherElement) { - // Null-safe comparison of parent collection names - string? elementCollectionName = element.ParentCollection?.Name; - string? otherElementCollectionName = otherElement.ParentCollection?.Name; + string? thisElementName = _identityElementName ?? element.Name; + string? thisCollectionName = _identityParentCollectionName ?? element.ParentCollection?.Name; + string? otherElementName = otherBasic != null ? (otherBasic._identityElementName ?? otherElement.Name) : otherElement.Name; + string? otherCollectionName = otherBasic != null ? (otherBasic._identityParentCollectionName ?? otherElement.ParentCollection?.Name) : otherElement.ParentCollection?.Name; - return string.Equals(elementCollectionName, otherElementCollectionName, StringComparison.Ordinal) && - string.Equals(element.Name, otherElement.Name, StringComparison.Ordinal); + return string.Equals(thisCollectionName, otherCollectionName, StringComparison.Ordinal) && + string.Equals(thisElementName, otherElementName, StringComparison.Ordinal); } - // Compare IProject sources + // Compare IProject sources via name snapshot (with fallback) if (Source is IProject project && other.Source is IProject otherProject) { - return string.Equals(project.Name, otherProject.Name, StringComparison.Ordinal); + string? thisProjectName = _identityProjectName ?? project.Name; + string? otherProjectName = otherBasic != null ? (otherBasic._identityProjectName ?? otherProject.Name) : otherProject.Name; + return string.Equals(thisProjectName, otherProjectName, StringComparison.Ordinal); } // Source types don't match @@ -409,22 +435,28 @@ public override int GetHashCode() { int hash = 17; - // Include code in hash - hash = hash * 31 + (Code?.GetHashCode() ?? 0); + // Hash from identity snapshots taken at construction time so the + // returned value is stable across the lifetime of this message — + // mutations to Code (Messenger.AddItemInternal) or Source.Name do + // not change the bucket once the message has been added to a + // HashSet/Dictionary. When the parameterless ctor was used, the + // snapshot fields are null and we fall back to current state. + hash = hash * 31 + ((_identityCode ?? Code)?.GetHashCode() ?? 0); - // Include source-specific information if (Source is IElement element) { - hash = hash * 31 + (element.ParentCollection?.Name?.GetHashCode() ?? 0); - hash = hash * 31 + (element.Name?.GetHashCode() ?? 0); + hash = hash * 31 + ((_identityParentCollectionName ?? element.ParentCollection?.Name)?.GetHashCode() ?? 0); + hash = hash * 31 + ((_identityElementName ?? element.Name)?.GetHashCode() ?? 0); } else if (Source is IProject project) { - hash = hash * 31 + (project.Name?.GetHashCode() ?? 0); + hash = hash * 31 + ((_identityProjectName ?? project.Name)?.GetHashCode() ?? 0); } else if (Source != null) { - hash = hash * 31 + Source.GetHashCode(); + // For non-IElement/IProject sources, fall back to reference + // identity (immutable for the object's lifetime). + hash = hash * 31 + System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(Source); } return hash; diff --git a/src/FrameworkInterfaces/Messaging/Extensions.cs b/src/FrameworkInterfaces/Messaging/Extensions.cs index 4c9bdc6b..4fc6b1d8 100644 --- a/src/FrameworkInterfaces/Messaging/Extensions.cs +++ b/src/FrameworkInterfaces/Messaging/Extensions.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -namespace FrameworkInterfaces.Messaging +namespace FrameworkInterfaces.Messaging { /// /// Provides extension methods for messaging-related types. diff --git a/src/FrameworkInterfaces/Messaging/IMessageItem.cs b/src/FrameworkInterfaces/Messaging/IMessageItem.cs index b41d6d0b..c2552edc 100644 --- a/src/FrameworkInterfaces/Messaging/IMessageItem.cs +++ b/src/FrameworkInterfaces/Messaging/IMessageItem.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; namespace FrameworkInterfaces diff --git a/src/FrameworkInterfaces/Messaging/MessageType.cs b/src/FrameworkInterfaces/Messaging/MessageType.cs index 53a53006..05409253 100644 --- a/src/FrameworkInterfaces/Messaging/MessageType.cs +++ b/src/FrameworkInterfaces/Messaging/MessageType.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -namespace FrameworkInterfaces +namespace FrameworkInterfaces { /// /// Defines the types of messages that can be displayed in the messaging system. diff --git a/src/FrameworkInterfaces/Messaging/Messenger.cs b/src/FrameworkInterfaces/Messaging/Messenger.cs index c8a76ddf..2327a259 100644 --- a/src/FrameworkInterfaces/Messaging/Messenger.cs +++ b/src/FrameworkInterfaces/Messaging/Messenger.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.IO; using System.Windows.Media; @@ -427,15 +397,24 @@ public void Add(IMessageItem item) if (item == null) throw new ArgumentNullException(nameof(item)); IMessageItem[]? toNotify = null; + string? deferredCode = null; lock (_lockObject) { - if (AddItemInternal(item)) + if (AddItemInternal(item, out deferredCode)) { toNotify = new IMessageItem[] { item }; } } + // Mutate item.Code outside the lock — the property setter raises PropertyChanged + // synchronously, which can re-enter the Messenger from a UI-thread subscriber. + // Holding _lockObject during that re-entry would deadlock. + if (deferredCode != null) + { + item.Code = deferredCode; + } + // Raise event outside the lock to prevent deadlock from re-entrant subscribers if (toNotify != null) { @@ -458,6 +437,8 @@ public void Add(IEnumerable items) if (items == null) throw new ArgumentNullException(nameof(items)); IMessageItem[]? toNotify = null; + // Deferred Code mutations to be applied OUTSIDE the lock; see comment in Add(IMessageItem). + List<(IMessageItem item, string newCode)>? deferredCodeMutations = null; lock (_lockObject) { @@ -465,9 +446,14 @@ public void Add(IEnumerable items) foreach (IMessageItem item in items) { if (item == null) continue; - if (AddItemInternal(item)) + if (AddItemInternal(item, out var newCode)) { newMessages.Add(item); + if (newCode != null) + { + deferredCodeMutations ??= new List<(IMessageItem, string)>(); + deferredCodeMutations.Add((item, newCode)); + } } } @@ -477,6 +463,15 @@ public void Add(IEnumerable items) } } + // Apply deferred Code mutations outside the lock (avoid re-entrant deadlock). + if (deferredCodeMutations != null) + { + foreach (var (item, newCode) in deferredCodeMutations) + { + item.Code = newCode; + } + } + // Raise event outside the lock to prevent deadlock from re-entrant subscribers if (toNotify != null) { @@ -577,9 +572,15 @@ public void Clear(object source) /// Handles event code uniquification for items. /// /// The message item to add. + /// When the item is an whose code had to be + /// changed for uniqueness, this receives the new value to be assigned to item.Code AFTER the + /// caller releases _lockObject. The Code setter raises PropertyChanged synchronously, which + /// can re-enter Messenger from a UI subscriber — that re-entry must not happen while the lock is held. + /// Receives null when no Code change is needed. /// true if the item was added; false if it was a duplicate or had no source. - private bool AddItemInternal(IMessageItem item) + private bool AddItemInternal(IMessageItem item, out string? deferredCode) { + deferredCode = null; if (item.Source == null) return false; if (item.Type == MessageType.Event) @@ -589,7 +590,7 @@ private bool AddItemInternal(IMessageItem item) _messagesBySource.Add(item.Source, new Dictionary()); } - // Ensure that the event code is unique by appending counter if needed + // Ensure that the event code is unique by appending counter if needed. var srcMsgs = _messagesBySource[item.Source]; string originalCode = item.Code; string code = originalCode; @@ -600,9 +601,15 @@ private bool AddItemInternal(IMessageItem item) code = $"{originalCode}{counter}"; counter++; } - item.Code = code; - srcMsgs.Add(item.Code, item); + // Store under the unique code without mutating item.Code (the setter would synchronously + // fire PropertyChanged → potentially re-enter Messenger via a UI subscriber while we still + // hold _lockObject). The mutation is deferred to the caller post-lock release. + srcMsgs.Add(code, item); + if (!ReferenceEquals(code, originalCode) && code != originalCode) + { + deferredCode = code; + } return true; } else diff --git a/src/FrameworkInterfaces/Project/ElementBase.cs b/src/FrameworkInterfaces/Project/ElementBase.cs index 208bba83..9eb17767 100644 --- a/src/FrameworkInterfaces/Project/ElementBase.cs +++ b/src/FrameworkInterfaces/Project/ElementBase.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Threading; using System.Windows.Media; diff --git a/src/FrameworkInterfaces/Project/ElementBaseBuff.cs b/src/FrameworkInterfaces/Project/ElementBaseBuff.cs index a125da65..01c0e3b6 100644 --- a/src/FrameworkInterfaces/Project/ElementBaseBuff.cs +++ b/src/FrameworkInterfaces/Project/ElementBaseBuff.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Windows.Media; @@ -240,11 +210,22 @@ private void SetDisplayNameDirty(string prop) /// Raise property changed event. /// /// Name of property that changed. - /// True to mark element as dirty. + /// + /// When true, marks the element as dirty (the typical case). When + /// false, leaves the existing dirty state untouched ("notify-only"). + /// This matches + /// promote-only semantics — previously the assignment was unconditional, so + /// passing false silently CLEARED the dirty flag, dropping unsaved-change + /// indicators when a subclass merely wanted to notify of a derived/computed + /// property change. + /// protected void RaisePropertyChange(string propertyName, bool isDirty = true) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - IsDirty = isDirty; + if (isDirty) + { + IsDirty = true; + } } /// diff --git a/src/FrameworkInterfaces/Project/ElementCollectionBase.cs b/src/FrameworkInterfaces/Project/ElementCollectionBase.cs index f5bfe3c1..1fa3c635 100644 --- a/src/FrameworkInterfaces/Project/ElementCollectionBase.cs +++ b/src/FrameworkInterfaces/Project/ElementCollectionBase.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections; +using System.Collections; using System.Collections.ObjectModel; using System.ComponentModel; using System.Threading; @@ -340,6 +310,10 @@ public virtual void MoveElement(IElement element, int startIndex, int endIndex) ElementList.RemoveAt(startIndex); ElementList.Insert(endIndex, element); + // Record the move so it participates in undo/redo. Without this call, + // any reorder (drag-drop in TreeView, programmatic) was non-undoable + // — Ctrl+Z after a drag-reorder did nothing. + RecordMoveElement(element, startIndex, endIndex); SetIsDirty(true); } diff --git a/src/FrameworkInterfaces/Project/IElement.cs b/src/FrameworkInterfaces/Project/IElement.cs index 643b14c3..9c7bc3c4 100644 --- a/src/FrameworkInterfaces/Project/IElement.cs +++ b/src/FrameworkInterfaces/Project/IElement.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows.Media; +using System.Windows.Media; namespace FrameworkInterfaces { diff --git a/src/FrameworkInterfaces/Project/IElementCollection.cs b/src/FrameworkInterfaces/Project/IElementCollection.cs index 2b551aef..045a9c41 100644 --- a/src/FrameworkInterfaces/Project/IElementCollection.cs +++ b/src/FrameworkInterfaces/Project/IElementCollection.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; namespace FrameworkInterfaces { diff --git a/src/FrameworkInterfaces/Project/IMetaData.cs b/src/FrameworkInterfaces/Project/IMetaData.cs index 99e53256..50c3c8d0 100644 --- a/src/FrameworkInterfaces/Project/IMetaData.cs +++ b/src/FrameworkInterfaces/Project/IMetaData.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -namespace FrameworkInterfaces +namespace FrameworkInterfaces { /// /// This is an interface for meta data. diff --git a/src/FrameworkInterfaces/Project/IProject.cs b/src/FrameworkInterfaces/Project/IProject.cs index 150ad8fc..d185b8da 100644 --- a/src/FrameworkInterfaces/Project/IProject.cs +++ b/src/FrameworkInterfaces/Project/IProject.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.Windows.Media; namespace FrameworkInterfaces diff --git a/src/FrameworkInterfaces/Project/ISave.cs b/src/FrameworkInterfaces/Project/ISave.cs index ac1e8d23..a2ca0bea 100644 --- a/src/FrameworkInterfaces/Project/ISave.cs +++ b/src/FrameworkInterfaces/Project/ISave.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; namespace FrameworkInterfaces { diff --git a/src/FrameworkInterfaces/Project/ProjectBase.cs b/src/FrameworkInterfaces/Project/ProjectBase.cs index e7f946ea..9d813f31 100644 --- a/src/FrameworkInterfaces/Project/ProjectBase.cs +++ b/src/FrameworkInterfaces/Project/ProjectBase.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using FrameworkInterfaces.Undo; +using FrameworkInterfaces.Undo; using FrameworkInterfaces.Undo.Actions; using System.Collections.ObjectModel; using System.ComponentModel; @@ -556,21 +526,42 @@ protected void ElementCollection_Saved(ISave sender) /// public void SaveAs(string newFullFileName) { - // Create a copy of the current project and rename it - File.Copy(FullFileName, newFullFileName, true); + // Wrap in try/catch so transient I/O errors (disk full, network drive, AV-locked file, + // permission denied) surface with informative context instead of an opaque + // "The process cannot access the file" propagating up from File.Copy. + try + { + // Create a copy of the current project and rename it + File.Copy(FullFileName, newFullFileName, true); + } + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) + { + throw new IOException( + $"Failed to save project as '{newFullFileName}'. Source: '{FullFileName}'. {ex.Message}", + ex); + } } /// public void ZipProject(string zipFileName) { - if (File.Exists(zipFileName)) + try { - File.Delete(zipFileName); - } + if (File.Exists(zipFileName)) + { + File.Delete(zipFileName); + } - using (var archive = ZipFile.Open(zipFileName, ZipArchiveMode.Create)) + using (var archive = ZipFile.Open(zipFileName, ZipArchiveMode.Create)) + { + archive.CreateEntryFromFile(FullFileName, Path.GetFileName(FullFileName)); + } + } + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { - archive.CreateEntryFromFile(FullFileName, Path.GetFileName(FullFileName)); + throw new IOException( + $"Failed to zip project to '{zipFileName}'. Source: '{FullFileName}'. {ex.Message}", + ex); } } diff --git a/src/FrameworkInterfaces/Undo/Actions/AddElementAction.cs b/src/FrameworkInterfaces/Undo/Actions/AddElementAction.cs index 6abb6f6e..141c88f5 100644 --- a/src/FrameworkInterfaces/Undo/Actions/AddElementAction.cs +++ b/src/FrameworkInterfaces/Undo/Actions/AddElementAction.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; namespace FrameworkInterfaces.Undo.Actions diff --git a/src/FrameworkInterfaces/Undo/Actions/CompositeAction.cs b/src/FrameworkInterfaces/Undo/Actions/CompositeAction.cs index 16f5938b..94f5ca69 100644 --- a/src/FrameworkInterfaces/Undo/Actions/CompositeAction.cs +++ b/src/FrameworkInterfaces/Undo/Actions/CompositeAction.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Linq; diff --git a/src/FrameworkInterfaces/Undo/Actions/DelegateAction.cs b/src/FrameworkInterfaces/Undo/Actions/DelegateAction.cs index ca9a99b4..d11dad87 100644 --- a/src/FrameworkInterfaces/Undo/Actions/DelegateAction.cs +++ b/src/FrameworkInterfaces/Undo/Actions/DelegateAction.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; namespace FrameworkInterfaces.Undo.Actions diff --git a/src/FrameworkInterfaces/Undo/Actions/MoveElementAction.cs b/src/FrameworkInterfaces/Undo/Actions/MoveElementAction.cs index 7354b817..16c6e8d3 100644 --- a/src/FrameworkInterfaces/Undo/Actions/MoveElementAction.cs +++ b/src/FrameworkInterfaces/Undo/Actions/MoveElementAction.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; namespace FrameworkInterfaces.Undo.Actions diff --git a/src/FrameworkInterfaces/Undo/Actions/PropertyChangeAction.cs b/src/FrameworkInterfaces/Undo/Actions/PropertyChangeAction.cs index 4b0aa1a3..62ce98cc 100644 --- a/src/FrameworkInterfaces/Undo/Actions/PropertyChangeAction.cs +++ b/src/FrameworkInterfaces/Undo/Actions/PropertyChangeAction.cs @@ -1,34 +1,5 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; +using System.Diagnostics; using System.Reflection; namespace FrameworkInterfaces.Undo.Actions @@ -63,12 +34,33 @@ public class PropertyChangeAction : IUndoableAction private readonly PropertyInfo _propertyInfo; private readonly object _syncLock = new object(); + // Monotonic timestamp for the merge-window check. Captured separately from + // the public DateTime Timestamp so the merge logic is immune to system clock + // adjustments (NTP corrections, DST transitions). Stopwatch.GetTimestamp() is + // a high-resolution monotonic counter that never moves backward. + private readonly long _monotonicTicks; + private static int _mergeWindowMilliseconds = 500; /// /// Gets or sets the time window in milliseconds for merging rapid changes to the same property. /// Must be greater than or equal to zero. Default is 500 ms. /// + /// + /// + /// The merge-window comparison in is + /// computed against , a + /// high-resolution monotonic counter — not against + /// . This makes the merge logic immune to system + /// clock adjustments (NTP corrections, manual time changes, DST transitions). A + /// wall-clock jump can never disable a legitimate merge or, worse, accept a stale + /// merge whose true elapsed time exceeds this window. + /// + /// + /// The public property remains a + /// for display purposes; only the merge-window calculation uses the monotonic ticks. + /// + /// public static int MergeWindowMilliseconds { get => _mergeWindowMilliseconds; @@ -106,6 +98,7 @@ public PropertyChangeAction(object target, string propertyName, object? oldValue } _propertyInfo = propertyInfo; + _monotonicTicks = Stopwatch.GetTimestamp(); Timestamp = DateTime.Now; } @@ -191,9 +184,13 @@ public bool CanMergeWith(IUndoableAction other) if (!ReferenceEquals(pca._target, _target)) return false; if (pca._propertyName != _propertyName) return false; - // Must be within the merge window - var timeDiff = (pca.Timestamp - Timestamp).TotalMilliseconds; - if (timeDiff < 0 || timeDiff > MergeWindowMilliseconds) return false; + // Must be within the merge window. Use the monotonic counter rather than + // wall-clock DateTime so NTP corrections / DST transitions don't disable + // legitimate merges (or, worse, accept stale ones if the clock jumps). + var deltaTicks = pca._monotonicTicks - _monotonicTicks; + if (deltaTicks < 0) return false; + var deltaMs = (deltaTicks * 1000.0) / Stopwatch.Frequency; + if (deltaMs > MergeWindowMilliseconds) return false; return true; } @@ -203,7 +200,10 @@ public IUndoableAction MergeWith(IUndoableAction other) { if (!(other is PropertyChangeAction pca)) return this; - // Keep old value from this action, new value from other action + // Keep old value from this action, new value from other action. + // The new instance's monotonic timestamp captures "now" in its ctor, but + // we override Timestamp (DateTime) to match the other action so the + // user-visible timestamp shows the latest sub-edit. return new PropertyChangeAction(_target, _propertyName, _oldValue, pca._newValue) { Timestamp = pca.Timestamp // Use the later timestamp diff --git a/src/FrameworkInterfaces/Undo/Actions/RemoveElementAction.cs b/src/FrameworkInterfaces/Undo/Actions/RemoveElementAction.cs index 39df5ffa..eb32a986 100644 --- a/src/FrameworkInterfaces/Undo/Actions/RemoveElementAction.cs +++ b/src/FrameworkInterfaces/Undo/Actions/RemoveElementAction.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; namespace FrameworkInterfaces.Undo.Actions diff --git a/src/FrameworkInterfaces/Undo/IUndoManager.cs b/src/FrameworkInterfaces/Undo/IUndoManager.cs index 75f84037..664ce891 100644 --- a/src/FrameworkInterfaces/Undo/IUndoManager.cs +++ b/src/FrameworkInterfaces/Undo/IUndoManager.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.ComponentModel; @@ -118,8 +88,17 @@ public interface IUndoManager : INotifyPropertyChanged /// /// The action to execute. /// + /// /// Use this when you want the undo manager to execute the action. /// The action's Execute() method will be called. + /// + /// + /// Re-entrancy: Calling ExecuteAction from inside another action's + /// Execute() (or from a property-change event raised by that Execute) is a + /// no-op — the nested call is silently dropped to prevent recursive recording. + /// Callers that need to chain multiple actions should use + /// rather than calling ExecuteAction recursively. + /// /// void ExecuteAction(IUndoableAction action); diff --git a/src/FrameworkInterfaces/Undo/IUndoableAction.cs b/src/FrameworkInterfaces/Undo/IUndoableAction.cs index f0de8f85..d73493d8 100644 --- a/src/FrameworkInterfaces/Undo/IUndoableAction.cs +++ b/src/FrameworkInterfaces/Undo/IUndoableAction.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; namespace FrameworkInterfaces.Undo diff --git a/src/FrameworkInterfaces/Undo/IUndoableElement.cs b/src/FrameworkInterfaces/Undo/IUndoableElement.cs index 97252050..ee195150 100644 --- a/src/FrameworkInterfaces/Undo/IUndoableElement.cs +++ b/src/FrameworkInterfaces/Undo/IUndoableElement.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - namespace FrameworkInterfaces.Undo { /// diff --git a/src/FrameworkInterfaces/Undo/UndoManager.cs b/src/FrameworkInterfaces/Undo/UndoManager.cs index 985151c2..37199052 100644 --- a/src/FrameworkInterfaces/Undo/UndoManager.cs +++ b/src/FrameworkInterfaces/Undo/UndoManager.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.ComponentModel; @@ -190,19 +160,36 @@ public void Undo() Interlocked.Exchange(ref _isExecutingAction, 1); try { - action.Undo(); + try + { + action.Undo(); + } + catch + { + // Restore the action to the undo stack so it isn't lost from + // both stacks. Without this, an exception in action.Undo + // (e.g. a property setter validation throw, a dynamic-dispatch + // RuntimeBinderException, an IndexOutOfRangeException after + // the collection shrunk) would silently drop the action — + // the user could no longer undo or redo to that point. + lock (_lockObject) + { + _undoStack.Push(action); + } + throw; + } + + lock (_lockObject) + { + _redoStack.Push(action); + _currentIndex--; + } } finally { Interlocked.Exchange(ref _isExecutingAction, 0); } - lock (_lockObject) - { - _redoStack.Push(action); - _currentIndex--; - } - OnStateChanged(); } @@ -239,19 +226,32 @@ public void Redo() Interlocked.Exchange(ref _isExecutingAction, 1); try { - action.Execute(); + try + { + action.Execute(); + } + catch + { + // Restore the action to the redo stack so it isn't lost from + // both stacks. Mirrors Undo's restoration logic — see comment there. + lock (_lockObject) + { + _redoStack.Push(action); + } + throw; + } + + lock (_lockObject) + { + _undoStack.Push(action); + _currentIndex++; + } } finally { Interlocked.Exchange(ref _isExecutingAction, 0); } - lock (_lockObject) - { - _undoStack.Push(action); - _currentIndex++; - } - OnStateChanged(); } @@ -416,6 +416,12 @@ public void RollbackTransaction() { Interlocked.Exchange(ref _isExecutingAction, 0); } + + // Notify subscribers that undo/redo state changed. Without this, UI + // elements bound to CanUndo/CanRedo / Description stay stale and the + // user sees the rolled-back action description on the Undo button as + // though it were still pending. + OnStateChanged(); } #endregion diff --git a/src/FrameworkInterfaces/Undo/UndoableCollectionBridge.cs b/src/FrameworkInterfaces/Undo/UndoableCollectionBridge.cs index 0172c762..dc869063 100644 --- a/src/FrameworkInterfaces/Undo/UndoableCollectionBridge.cs +++ b/src/FrameworkInterfaces/Undo/UndoableCollectionBridge.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/src/FrameworkInterfaces/Undo/UndoableStateBridge.cs b/src/FrameworkInterfaces/Undo/UndoableStateBridge.cs index a8b9cbb2..52bdac85 100644 --- a/src/FrameworkInterfaces/Undo/UndoableStateBridge.cs +++ b/src/FrameworkInterfaces/Undo/UndoableStateBridge.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Reflection; using FrameworkInterfaces.Undo.Actions; @@ -165,6 +135,17 @@ public class UndoableStateBridge : IDisposable /// private readonly Action? _onActionRecorded; + /// + /// Number of currently active scopes. Used to + /// support nested SuspendRecording calls correctly: only the outermost + /// transition (0→1) actually unsubscribes from PropertyChanged, and only the + /// outermost dispose (1→0) re-subscribes. Without this, two nested suspensions + /// would unsubscribe once but re-subscribe twice on dispose, leaving the + /// handler subscribed twice and recording every property change as TWO + /// undo actions. + /// + private int _suspendCount; + #endregion #region Constructor @@ -598,8 +579,13 @@ private class RecordingSuspension : IDisposable public RecordingSuspension(UndoableStateBridge bridge) { _bridge = bridge; - // Unsubscribe from events during suspension - _bridge._source.PropertyChanged -= _bridge.OnPropertyChanged; + // Reference-counted: only the outermost suspension actually unsubscribes. + // Inner SuspendRecording calls just bump the counter so a Dispose pair + // does not double-subscribe on exit. + if (System.Threading.Interlocked.Increment(ref _bridge._suspendCount) == 1) + { + _bridge._source.PropertyChanged -= _bridge.OnPropertyChanged; + } } /// @@ -617,13 +603,25 @@ public void Dispose() _disposed = true; GC.SuppressFinalize(this); - if (_bridge.IsDisposed) return; + if (_bridge.IsDisposed) + { + // Bridge is gone — decrement the counter for accounting but + // skip the shadow-value refresh and re-subscription (would + // resurrect a handler on a disposed bridge). + System.Threading.Interlocked.Decrement(ref _bridge._suspendCount); + return; + } - // Update shadow values to current state - _bridge.UpdateShadowValues(); + // Reference-counted: only the outermost dispose (1→0) actually + // re-subscribes. Inner disposes just decrement the counter. + if (System.Threading.Interlocked.Decrement(ref _bridge._suspendCount) == 0) + { + // Update shadow values to current state + _bridge.UpdateShadowValues(); - // Re-subscribe to events - _bridge._source.PropertyChanged += _bridge.OnPropertyChanged; + // Re-subscribe to events + _bridge._source.PropertyChanged += _bridge.OnPropertyChanged; + } } } } diff --git a/src/FrameworkInterfaces/Utilities/ExtensionMethods.cs b/src/FrameworkInterfaces/Utilities/ExtensionMethods.cs index 573d87ff..a35ef31e 100644 --- a/src/FrameworkInterfaces/Utilities/ExtensionMethods.cs +++ b/src/FrameworkInterfaces/Utilities/ExtensionMethods.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.Generic; +using System.Collections.Generic; namespace FrameworkInterfaces { diff --git a/src/FrameworkInterfaces/Utilities/Methods.cs b/src/FrameworkInterfaces/Utilities/Methods.cs index 0c7ef9b4..3b337bfc 100644 --- a/src/FrameworkInterfaces/Utilities/Methods.cs +++ b/src/FrameworkInterfaces/Utilities/Methods.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.ComponentModel; namespace FrameworkInterfaces diff --git a/src/FrameworkInterfaces/Utilities/Tools.cs b/src/FrameworkInterfaces/Utilities/Tools.cs index 95afe6ec..f5c3f562 100644 --- a/src/FrameworkInterfaces/Utilities/Tools.cs +++ b/src/FrameworkInterfaces/Utilities/Tools.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; namespace FrameworkInterfaces.Utilities { diff --git a/src/FrameworkUI.Demo/App.xaml.cs b/src/FrameworkUI.Demo/App.xaml.cs index 7335bbec..7a8e37b4 100644 --- a/src/FrameworkUI.Demo/App.xaml.cs +++ b/src/FrameworkUI.Demo/App.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ? Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ? Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ? The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using GenericControls; using SoftwareUpdate; using SoftwareUpdate.GitHub; diff --git a/src/FrameworkUI.Demo/AssemblyResolver.cs b/src/FrameworkUI.Demo/AssemblyResolver.cs index 7e0ec021..9dad9e18 100644 --- a/src/FrameworkUI.Demo/AssemblyResolver.cs +++ b/src/FrameworkUI.Demo/AssemblyResolver.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - #nullable enable using System.IO; using System.Reflection; diff --git a/src/FrameworkUI.Demo/FrameworkUI.Demo.csproj b/src/FrameworkUI.Demo/FrameworkUI.Demo.csproj index 726d5bc4..46c3ccef 100644 --- a/src/FrameworkUI.Demo/FrameworkUI.Demo.csproj +++ b/src/FrameworkUI.Demo/FrameworkUI.Demo.csproj @@ -7,7 +7,6 @@ FrameworkUI.Demo FrameworkUI.Demo A demonstration application for the FrameworkUI WPF framework, showcasing project management, AvalonDock layout, theming, and standard controls. - Copyright © 2026 U.S. Army Corps of Engineers U.S. Army Corps of Engineers disable true @@ -51,9 +50,7 @@ - - ..\..\..\numerics\Numerics\bin\$(Configuration)\net10.0\Numerics.dll - + diff --git a/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElement.cs b/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElement.cs index 51b4352b..93d77c52 100644 --- a/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElement.cs +++ b/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElement.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Windows.Media; using System.Windows.Media.Imaging; using FrameworkInterfaces; diff --git a/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElementCollection.cs b/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElementCollection.cs index 1b83e5d9..86d65e88 100644 --- a/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElementCollection.cs +++ b/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElementCollection.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/src/FrameworkUI.Demo/Model/DemoProject.cs b/src/FrameworkUI.Demo/Model/DemoProject.cs index 3feaf6c9..452c61c2 100644 --- a/src/FrameworkUI.Demo/Model/DemoProject.cs +++ b/src/FrameworkUI.Demo/Model/DemoProject.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using DatabaseManager; +using DatabaseManager; using FrameworkInterfaces; using FrameworkInterfaces.Messaging; using System; diff --git a/src/FrameworkUI.Demo/Model/Hazard Elements/HazardElement.cs b/src/FrameworkUI.Demo/Model/Hazard Elements/HazardElement.cs index de375060..c22a93e6 100644 --- a/src/FrameworkUI.Demo/Model/Hazard Elements/HazardElement.cs +++ b/src/FrameworkUI.Demo/Model/Hazard Elements/HazardElement.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using FrameworkInterfaces; +using FrameworkInterfaces; using FrameworkInterfaces.Messaging; using FrameworkInterfaces.Undo; using Numerics.Distributions; diff --git a/src/FrameworkUI.Demo/Model/Hazard Elements/HazardElementCollection.cs b/src/FrameworkUI.Demo/Model/Hazard Elements/HazardElementCollection.cs index 4ce54211..e62ccac0 100644 --- a/src/FrameworkUI.Demo/Model/Hazard Elements/HazardElementCollection.cs +++ b/src/FrameworkUI.Demo/Model/Hazard Elements/HazardElementCollection.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using FrameworkInterfaces; +using FrameworkInterfaces; namespace FrameworkUI.Demo { diff --git a/src/FrameworkUI.Demo/Model/Response Elements/ResponseElement.cs b/src/FrameworkUI.Demo/Model/Response Elements/ResponseElement.cs index 49428c43..7f8f0b17 100644 --- a/src/FrameworkUI.Demo/Model/Response Elements/ResponseElement.cs +++ b/src/FrameworkUI.Demo/Model/Response Elements/ResponseElement.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Windows.Media; using System.Windows.Media.Imaging; using FrameworkInterfaces; diff --git a/src/FrameworkUI.Demo/Model/Response Elements/ResponseElementCollection.cs b/src/FrameworkUI.Demo/Model/Response Elements/ResponseElementCollection.cs index 272f5012..6863aaf7 100644 --- a/src/FrameworkUI.Demo/Model/Response Elements/ResponseElementCollection.cs +++ b/src/FrameworkUI.Demo/Model/Response Elements/ResponseElementCollection.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElement.cs b/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElement.cs index 968a6d5c..a511d5ee 100644 --- a/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElement.cs +++ b/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElement.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using FrameworkInterfaces; using FrameworkInterfaces.Undo; using System; diff --git a/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElementCollection.cs b/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElementCollection.cs index da331978..74b46537 100644 --- a/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElementCollection.cs +++ b/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElementCollection.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using FrameworkInterfaces; namespace FrameworkUI.Demo diff --git a/src/FrameworkUI.Demo/Properties/Resources.Designer.cs b/src/FrameworkUI.Demo/Properties/Resources.Designer.cs index 7b43e20d..04789de0 100644 --- a/src/FrameworkUI.Demo/Properties/Resources.Designer.cs +++ b/src/FrameworkUI.Demo/Properties/Resources.Designer.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 diff --git a/src/FrameworkUI.Demo/UI/DemoProjectNode.cs b/src/FrameworkUI.Demo/UI/DemoProjectNode.cs index fa69820e..c33d4c73 100644 --- a/src/FrameworkUI.Demo/UI/DemoProjectNode.cs +++ b/src/FrameworkUI.Demo/UI/DemoProjectNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using FrameworkInterfaces; +using FrameworkInterfaces; using FrameworkUI; using FrameworkUI.ProjectExplorer; using GenericControls; diff --git a/src/FrameworkUI.Demo/UI/ElementDocumentControl.xaml.cs b/src/FrameworkUI.Demo/UI/ElementDocumentControl.xaml.cs index 5ca0b610..a575de5c 100644 --- a/src/FrameworkUI.Demo/UI/ElementDocumentControl.xaml.cs +++ b/src/FrameworkUI.Demo/UI/ElementDocumentControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/src/FrameworkUI.Demo/UI/ElementPropertiesControl.xaml.cs b/src/FrameworkUI.Demo/UI/ElementPropertiesControl.xaml.cs index 59ee7924..d332dec3 100644 --- a/src/FrameworkUI.Demo/UI/ElementPropertiesControl.xaml.cs +++ b/src/FrameworkUI.Demo/UI/ElementPropertiesControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/src/FrameworkUI.Demo/UI/Hazard Controls/HazardControl.xaml b/src/FrameworkUI.Demo/UI/Hazard Controls/HazardControl.xaml index 9faac072..6fb884e1 100644 --- a/src/FrameworkUI.Demo/UI/Hazard Controls/HazardControl.xaml +++ b/src/FrameworkUI.Demo/UI/Hazard Controls/HazardControl.xaml @@ -1,14 +1,15 @@  diff --git a/src/FrameworkUI.Demo/UI/Hazard Controls/HazardControl.xaml.cs b/src/FrameworkUI.Demo/UI/Hazard Controls/HazardControl.xaml.cs index 06c9f136..dec62785 100644 --- a/src/FrameworkUI.Demo/UI/Hazard Controls/HazardControl.xaml.cs +++ b/src/FrameworkUI.Demo/UI/Hazard Controls/HazardControl.xaml.cs @@ -8,6 +8,7 @@ using System.ComponentModel; using System.Data; using System.Diagnostics; +using System.Globalization; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -390,7 +391,7 @@ public void UpdatePlot() if (Element.IsUncertain) { - ConfidenceInterval.Title = (Element.ConfidenceIntervalWidth * 100).ToString("F0") + "% Confidence Interval"; + ConfidenceInterval.Title = (Element.ConfidenceIntervalWidth * 100).ToString("F0", CultureInfo.CurrentCulture) + "% Confidence Interval"; Plot.Series.Add(ConfidenceInterval); Plot.Series.Add(MeanLine); } @@ -438,8 +439,8 @@ private void HazardFunctionControl_LostFocus(object sender, RoutedEventArgs e) private void SetFrequencyCurveTableColumnHeaders() { double alpha = (1 - Element.ConfidenceIntervalWidth) / 2; - UpperColumn.Header = ((1 - alpha) * 100).ToString("F1") + "%-ile"; - LowerColumn.Header = (alpha * 100).ToString("F1") + "%-ile"; + UpperColumn.Header = ((1 - alpha) * 100).ToString("F1", CultureInfo.CurrentCulture) + "%-ile"; + LowerColumn.Header = (alpha * 100).ToString("F1", CultureInfo.CurrentCulture) + "%-ile"; } /// diff --git a/src/FrameworkUI.Demo/UI/ThemeDemoControl.xaml.cs b/src/FrameworkUI.Demo/UI/ThemeDemoControl.xaml.cs index e30820c6..b4caa84f 100644 --- a/src/FrameworkUI.Demo/UI/ThemeDemoControl.xaml.cs +++ b/src/FrameworkUI.Demo/UI/ThemeDemoControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.Generic; using System.Windows; using System.Windows.Controls; diff --git a/src/FrameworkUI.Demo/UI/UndoDemoControl.xaml.cs b/src/FrameworkUI.Demo/UI/UndoDemoControl.xaml.cs index 3a73d2fb..f8a9a4fd 100644 --- a/src/FrameworkUI.Demo/UI/UndoDemoControl.xaml.cs +++ b/src/FrameworkUI.Demo/UI/UndoDemoControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Windows; using System.Windows.Controls; diff --git a/src/FrameworkUI/Help Menu/AboutWindow.xaml.cs b/src/FrameworkUI/Help Menu/AboutWindow.xaml.cs index 40e4876c..c69f7cce 100644 --- a/src/FrameworkUI/Help Menu/AboutWindow.xaml.cs +++ b/src/FrameworkUI/Help Menu/AboutWindow.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using GenericControls; using System.Globalization; using System.Windows; diff --git a/src/FrameworkUI/Help Menu/TermsAndConditionsWindow.xaml.cs b/src/FrameworkUI/Help Menu/TermsAndConditionsWindow.xaml.cs index cc91ff0c..3f45455f 100644 --- a/src/FrameworkUI/Help Menu/TermsAndConditionsWindow.xaml.cs +++ b/src/FrameworkUI/Help Menu/TermsAndConditionsWindow.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using GenericControls; using System.Windows; using System.Windows.Controls; diff --git a/src/FrameworkUI/Main Window/FrameworkUIController.cs b/src/FrameworkUI/Main Window/FrameworkUIController.cs index 9239f1e1..059d4f56 100644 --- a/src/FrameworkUI/Main Window/FrameworkUIController.cs +++ b/src/FrameworkUI/Main Window/FrameworkUIController.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using FrameworkUI.ProjectExplorer; +using FrameworkUI.ProjectExplorer; using FrameworkInterfaces; using System.Collections.ObjectModel; using System.Windows; diff --git a/src/FrameworkUI/Main Window/MainWindow.xaml.cs b/src/FrameworkUI/Main Window/MainWindow.xaml.cs index 2cda45fe..66e4afef 100644 --- a/src/FrameworkUI/Main Window/MainWindow.xaml.cs +++ b/src/FrameworkUI/Main Window/MainWindow.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ? Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ? Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ? The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; @@ -137,6 +107,12 @@ public MainWindow() { ThemeManager.SetTheme(ThemeColor.Light); } + else + { + // Unknown / unrecognized theme value (corrupt setting, future theme name, etc.) — fall back to Light + // so that ThemeManager always loads a valid theme dictionary before any UI renders. + ThemeManager.SetTheme(ThemeColor.Light); + } // Dummy call using Avalon Themes method so that the dlls will be copied with the ProjectUI control. var avalonDummy = new Xceed.Wpf.AvalonDock.Themes.Vs2013BlueTheme(); } @@ -878,7 +854,7 @@ private void SaveLayout() FrameworkInterfaces.Messaging.Messenger.GetInstance().Add( new BasicMessageItem(MessageType.Warning, $"Failed to save dock layout: {ex.Message}", - null, "MainWindow", string.Empty, "SaveLayout")); + this, "MainWindow", string.Empty, "SaveLayout")); } } @@ -1807,7 +1783,63 @@ private void MainWindow_Closing(object sender, CancelEventArgs e) return; } - bool userSavedBeforeClosing = false; + if (!TryPromptToSaveDirtyState(out bool userSavedBeforeClosing)) + { + e.Cancel = true; + return; + } + + + + // Compact on close + if (UserSettings.CompressProjectFileOnClose == true && ProjectNode?.Project is not null) + { + // Compact and Optimize + FileSizeManager.CompactAndOptimizeFile(ProjectNode.Project); + } + + // Close the current project + CloseProject(); + + // Delete backup file + if (UserSettings.KeepLastBackupVersion == true && userSavedBeforeClosing == true) + { + // Delete backup file + AutoBackup.DeleteBackupProjectFile(); + } + else + { + // Delete backup file + AutoBackup.DeleteBackupProjectFile(); + } + + // Save user settings — guard against disk-full / permission / locked-file errors at shutdown + // so a transient failure here doesn't crash the close (loses unsaved Recent Files updates, + // but the project itself was already saved above). + try { UserSettings.Save(ShellPublicVariables.UserSettingsFilePath); } + catch (Exception ex) { Debug.WriteLine($"[Closing] UserSettings.Save failed: {ex.Message}"); } + + // Save Recent Files — same shutdown-resilience rationale. + try { RecentFiles.SaveToXML(); } + catch (Exception ex) { Debug.WriteLine($"[Closing] RecentFiles.SaveToXML failed: {ex.Message}"); } + } + + /// + /// Prompts the user to save unsaved project state (elements and/or project file). + /// Used by both the application-close flow and the auto-update install flow so + /// dirty work is never silently lost when the process exits. + /// + /// + /// Set to true if the user chose Save (project was saved), false if + /// they chose Don't Save or no save was needed. + /// + /// + /// true if the caller should proceed (user saved or chose not to save, or + /// nothing was dirty); false if the user cancelled. + /// + private bool TryPromptToSaveDirtyState(out bool userSaved) + { + userSaved = false; // See if there are any unsaved elements. Ask if they want to save. var unSavedElementItems = new ObservableCollection(); @@ -1829,23 +1861,18 @@ private void MainWindow_Closing(object sender, CancelEventArgs e) { var saveElementsDialog = new SaveElementsDialog() { ElementItems = unSavedElementItems }; saveElementsDialog.ShowDialog(); - // if (saveElementsDialog.Result == SaveElementsDialog.DialogResultType.YesSave) { - // If the user clicks "Save", then proceed with closing application - userSavedBeforeClosing = true; + userSaved = true; SaveProject(); } else if (saveElementsDialog.Result == SaveElementsDialog.DialogResultType.NoSave) { - // If the user clicks "Don't Save", then proceed with closing application - userSavedBeforeClosing = false; + userSaved = false; } else if (saveElementsDialog.Result == SaveElementsDialog.DialogResultType.Cancel) { - // If the user clicks Cancel or closes the dialog, then cancel closing - e.Cancel = true; - return; + return false; } } else @@ -1874,51 +1901,21 @@ private void MainWindow_Closing(object sender, CancelEventArgs e) MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { - userSavedBeforeClosing = true; + userSaved = true; SaveProject(); } if (result == MessageBoxResult.No) { - userSavedBeforeClosing = false; + userSaved = false; } if (result == MessageBoxResult.Cancel) { - e.Cancel = true; - return; + return false; } } - - } - - - - // Compact on close - if (UserSettings.CompressProjectFileOnClose == true && ProjectNode?.Project is not null) - { - // Compact and Optimize - FileSizeManager.CompactAndOptimizeFile(ProjectNode.Project); - } - - // Close the current project - CloseProject(); - - // Delete backup file - if (UserSettings.KeepLastBackupVersion == true && userSavedBeforeClosing == true) - { - // Delete backup file - AutoBackup.DeleteBackupProjectFile(); - } - else - { - // Delete backup file - AutoBackup.DeleteBackupProjectFile(); } - // Save user settings - UserSettings.Save(ShellPublicVariables.UserSettingsFilePath); - - // Save Recent Files - RecentFiles.SaveToXML(); + return true; } /// @@ -2501,12 +2498,54 @@ private void RestoreFromBackup_Click(object sender, RoutedEventArgs e) GenericControls.MessageBox.Show("The file name is too long. Please shorten the name to have less than 250 characters before trying to restore.", "File name error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } - // Rename the backup file - File.Move(fullFileName, newFileName); - // Open project - OpenProject(newFileName); - // Log Event - FrameworkInterfaces.Messaging.Messenger.GetInstance().Add(new BasicMessageItem(MessageType.Event, $"The backup project file '{fullFileName}{ShellPublicVariables.BackupExtension}' was restored.", ProjectNode.Project, "Project", ProjectNode.Project.Name, "RestoreFromBackup")); + // Copy (don't move) the backup so a failed open leaves the original + // .bak intact and the user can try a different recovery path. Move- + // then-open consumed the backup name before knowing the open succeeded; + // any open failure (corrupt file, version mismatch, missing dependencies) + // left the user with no .bak to retry. + try + { + File.Copy(fullFileName, newFileName, overwrite: false); + } + catch (Exception copyEx) + { + GenericControls.MessageBox.Show( + $"Failed to copy the backup file:\n\n{copyEx.Message}", + "Restore Failed", + MessageBoxButton.OK, + MessageBoxImage.Error); + return; + } + + // Open project. If this throws or otherwise fails, leave the original + // backup file in place so the user can attempt restore again. + bool openSucceeded = false; + try + { + OpenProject(newFileName); + openSucceeded = ProjectNode?.Project != null; + } + catch (Exception openEx) + { + GenericControls.MessageBox.Show( + $"Failed to open the restored project. The original backup file has been preserved at:\n{fullFileName}\n\n{openEx.Message}", + "Restore Failed", + MessageBoxButton.OK, + MessageBoxImage.Error); + // Clean up the half-restored copy so it doesn't masquerade as a usable project. + try { File.Delete(newFileName); } catch (Exception deleteEx) { Debug.WriteLine(deleteEx.Message); } + return; + } + + if (openSucceeded && ProjectNode?.Project is not null) + { + // Only delete the original backup once the restored project is known good. + try { File.Delete(fullFileName); } catch (Exception deleteEx) { Debug.WriteLine(deleteEx.Message); } + + // Log Event + var restoredProject = ProjectNode.Project; + FrameworkInterfaces.Messaging.Messenger.GetInstance().Add(new BasicMessageItem(MessageType.Event, $"The backup project file '{fullFileName}{ShellPublicVariables.BackupExtension}' was restored.", restoredProject, "Project", restoredProject.Name, "RestoreFromBackup")); + } } } @@ -2639,6 +2678,16 @@ private async System.Threading.Tasks.Task DownloadAndInstallUpdateAsync(UpdateIn if (downloadResult.Success) { + if (ShellPublicVariables.SimulationInProgress == true) + { + GenericControls.MessageBox.Show( + "A simulation is currently running. Please wait for it to finish before installing the update.", + "Cannot Install Update", + MessageBoxButton.OK, + MessageBoxImage.Information); + return; + } + var confirmResult = GenericControls.MessageBox.Show( "Update downloaded successfully.\n\n" + "The application will now close to install the update and restart automatically.\n\n" + @@ -2649,6 +2698,21 @@ private async System.Threading.Tasks.Task DownloadAndInstallUpdateAsync(UpdateIn if (confirmResult == MessageBoxResult.Yes && downloadResult.FilePath != null) { + // Prompt to save any unsaved project / element state. The updater + // calls Environment.Exit(0) so any dirty state not flushed here is lost. + if (!TryPromptToSaveDirtyState(out _)) + { + return; + } + + // Persist user settings + recent files before the updater terminates + // the process. Wrapped defensively so a settings I/O error doesn't + // block the install. + try { UserSettings.Save(ShellPublicVariables.UserSettingsFilePath); } + catch (Exception saveEx) { Debug.WriteLine($"[Update] UserSettings.Save failed: {saveEx.Message}"); } + try { RecentFiles.SaveToXML(); } + catch (Exception saveEx) { Debug.WriteLine($"[Update] RecentFiles.SaveToXML failed: {saveEx.Message}"); } + UpdateService.InstallUpdateAndRestart(downloadResult.FilePath); } } diff --git a/src/FrameworkUI/Message Window/Converters/MessageTypeToImageConverter.cs b/src/FrameworkUI/Message Window/Converters/MessageTypeToImageConverter.cs index ce9c9468..c53dfa47 100644 --- a/src/FrameworkUI/Message Window/Converters/MessageTypeToImageConverter.cs +++ b/src/FrameworkUI/Message Window/Converters/MessageTypeToImageConverter.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Globalization; +using System.Globalization; using System.Windows.Data; using System.Windows.Media; using FrameworkInterfaces; diff --git a/src/FrameworkUI/Message Window/View Models/MessageItem.cs b/src/FrameworkUI/Message Window/View Models/MessageItem.cs index 0ea3a88d..2d1fc00b 100644 --- a/src/FrameworkUI/Message Window/View Models/MessageItem.cs +++ b/src/FrameworkUI/Message Window/View Models/MessageItem.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Data; using System.Windows.Media; using FrameworkInterfaces; diff --git a/src/FrameworkUI/Message Window/Views/MessageWindowControl.xaml.cs b/src/FrameworkUI/Message Window/Views/MessageWindowControl.xaml.cs index f41d447f..dbb63d3e 100644 --- a/src/FrameworkUI/Message Window/Views/MessageWindowControl.xaml.cs +++ b/src/FrameworkUI/Message Window/Views/MessageWindowControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; using System.Windows.Input; diff --git a/src/FrameworkUI/Project Explorer/View Models/ElementNode.cs b/src/FrameworkUI/Project Explorer/View Models/ElementNode.cs index 76a2e76d..b60ccac5 100644 --- a/src/FrameworkUI/Project Explorer/View Models/ElementNode.cs +++ b/src/FrameworkUI/Project Explorer/View Models/ElementNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Input; diff --git a/src/FrameworkUI/Project Explorer/View Models/ElementNodeCollection.cs b/src/FrameworkUI/Project Explorer/View Models/ElementNodeCollection.cs index 2373ab26..354552d5 100644 --- a/src/FrameworkUI/Project Explorer/View Models/ElementNodeCollection.cs +++ b/src/FrameworkUI/Project Explorer/View Models/ElementNodeCollection.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using FrameworkInterfaces; +using FrameworkInterfaces; using System.Windows; using System.Windows.Data; diff --git a/src/FrameworkUI/Project Explorer/View Models/ElementNodeGroup.cs b/src/FrameworkUI/Project Explorer/View Models/ElementNodeGroup.cs index c51d556c..3644324c 100644 --- a/src/FrameworkUI/Project Explorer/View Models/ElementNodeGroup.cs +++ b/src/FrameworkUI/Project Explorer/View Models/ElementNodeGroup.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -namespace FrameworkUI.ProjectExplorer +namespace FrameworkUI.ProjectExplorer { /// diff --git a/src/FrameworkUI/Project Explorer/View Models/ExplorerTreeView.cs b/src/FrameworkUI/Project Explorer/View Models/ExplorerTreeView.cs index 7a664ded..54c3db64 100644 --- a/src/FrameworkUI/Project Explorer/View Models/ExplorerTreeView.cs +++ b/src/FrameworkUI/Project Explorer/View Models/ExplorerTreeView.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using GenericControls; +using GenericControls; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; diff --git a/src/FrameworkUI/Project Explorer/View Models/Node.cs b/src/FrameworkUI/Project Explorer/View Models/Node.cs index bb33fd07..34751e8e 100644 --- a/src/FrameworkUI/Project Explorer/View Models/Node.cs +++ b/src/FrameworkUI/Project Explorer/View Models/Node.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using GenericControls; +using GenericControls; using System.Collections; using System.Collections.ObjectModel; using System.ComponentModel; @@ -893,7 +863,7 @@ protected virtual void UpdateRenameTextBox() /// /// When header loses focus, update rename text box. - /// protected virtual void HeaderRenameTextbox_LostFocus(object sender, RoutedEventArgs e) { if (_hitTestResult == null || !(_hitTestResult.VisualHit is TextBox)) diff --git a/src/FrameworkUI/Project Explorer/View Models/NodeCollection.cs b/src/FrameworkUI/Project Explorer/View Models/NodeCollection.cs index d96316c7..679b7e77 100644 --- a/src/FrameworkUI/Project Explorer/View Models/NodeCollection.cs +++ b/src/FrameworkUI/Project Explorer/View Models/NodeCollection.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using GenericControls; +using GenericControls; using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/FrameworkUI/Project Explorer/View Models/NodeGroup.cs b/src/FrameworkUI/Project Explorer/View Models/NodeGroup.cs index 20bd0d48..d6a83230 100644 --- a/src/FrameworkUI/Project Explorer/View Models/NodeGroup.cs +++ b/src/FrameworkUI/Project Explorer/View Models/NodeGroup.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using GenericControls; +using GenericControls; using System.ComponentModel; using System.Windows.Input; using System.Windows; diff --git a/src/FrameworkUI/Project Explorer/View Models/ProjectExplorerTreeView.cs b/src/FrameworkUI/Project Explorer/View Models/ProjectExplorerTreeView.cs index a2cac53d..b9d654cc 100644 --- a/src/FrameworkUI/Project Explorer/View Models/ProjectExplorerTreeView.cs +++ b/src/FrameworkUI/Project Explorer/View Models/ProjectExplorerTreeView.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; namespace FrameworkUI.ProjectExplorer { diff --git a/src/FrameworkUI/Project Explorer/View Models/ProjectNode.cs b/src/FrameworkUI/Project Explorer/View Models/ProjectNode.cs index 692f7262..4f290172 100644 --- a/src/FrameworkUI/Project Explorer/View Models/ProjectNode.cs +++ b/src/FrameworkUI/Project Explorer/View Models/ProjectNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using GenericControls; +using GenericControls; using FrameworkInterfaces; using System; using System.Windows; @@ -532,24 +502,6 @@ private void NodeHeader_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) e.Handled = true; } - /// - /// Raises the set properties control event. - /// - /// The property control to set. - //protected void RaiseSetPropertiesControl(Control propertyControl) - //{ - // SetPropertiesControl?.Invoke(propertyControl); - //} - - /// - /// Raises the close property control event. - /// - /// The property control to close. - //protected void RaiseClosePropertiesControl(Control propertyControl) - //{ - // ClosePropertiesControl?.Invoke(propertyControl); - //} - #endregion } diff --git a/src/FrameworkUI/Project Explorer/View Models/SimpleNode.cs b/src/FrameworkUI/Project Explorer/View Models/SimpleNode.cs index df469af1..7671b0c0 100644 --- a/src/FrameworkUI/Project Explorer/View Models/SimpleNode.cs +++ b/src/FrameworkUI/Project Explorer/View Models/SimpleNode.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using GenericControls; +using GenericControls; using System.Windows; using System.Windows.Data; using System.Windows.Media; diff --git a/src/FrameworkUI/Project Explorer/Views/NodeHeader.xaml.cs b/src/FrameworkUI/Project Explorer/Views/NodeHeader.xaml.cs index b434c84a..45e70a5f 100644 --- a/src/FrameworkUI/Project Explorer/Views/NodeHeader.xaml.cs +++ b/src/FrameworkUI/Project Explorer/Views/NodeHeader.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Globalization; +using System.Globalization; using System.Windows; using System.Windows.Controls; using System.Windows.Media; @@ -40,11 +10,12 @@ namespace FrameworkUI.ProjectExplorer /// /// /// - /// Authors: - /// Woody Fields - /// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil - /// + /// Authors: /// + /// + /// Woody Fields + /// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil + /// /// public partial class NodeHeader : UserControl { diff --git a/src/FrameworkUI/Project Properties/ProjectPropertiesControl.xaml.cs b/src/FrameworkUI/Project Properties/ProjectPropertiesControl.xaml.cs index 8a5e9748..be425545 100644 --- a/src/FrameworkUI/Project Properties/ProjectPropertiesControl.xaml.cs +++ b/src/FrameworkUI/Project Properties/ProjectPropertiesControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.IO; +using System.IO; using System.Windows; using System.Windows.Controls; using System.Windows.Input; diff --git a/src/FrameworkUI/Properties/Resources.Designer.cs b/src/FrameworkUI/Properties/Resources.Designer.cs index ecd28574..ba100965 100644 --- a/src/FrameworkUI/Properties/Resources.Designer.cs +++ b/src/FrameworkUI/Properties/Resources.Designer.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - //------------------------------------------------------------------------------ // // This code was generated by a tool. diff --git a/src/FrameworkUI/Properties/Settings.Designer.cs b/src/FrameworkUI/Properties/Settings.Designer.cs index b9d60a4e..caea2a1a 100644 --- a/src/FrameworkUI/Properties/Settings.Designer.cs +++ b/src/FrameworkUI/Properties/Settings.Designer.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 diff --git a/src/FrameworkUI/Recent Files/RecentFileItem.cs b/src/FrameworkUI/Recent Files/RecentFileItem.cs index f3e62a12..1876aac9 100644 --- a/src/FrameworkUI/Recent Files/RecentFileItem.cs +++ b/src/FrameworkUI/Recent Files/RecentFileItem.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows.Controls; +using System.Windows.Controls; namespace FrameworkUI { diff --git a/src/FrameworkUI/Recent Files/RecentFiles.cs b/src/FrameworkUI/Recent Files/RecentFiles.cs index 0c9dbfb2..a8c64a81 100644 --- a/src/FrameworkUI/Recent Files/RecentFiles.cs +++ b/src/FrameworkUI/Recent Files/RecentFiles.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.IO; using System.Runtime.InteropServices; using System.Reflection; @@ -155,6 +125,15 @@ public void AddItem(string filePath) if (index >= 0) RemoveItem(index); var item = new RecentFileItem(filePath); Collection.Insert(0, item); + // Trim the collection to NumberOfFilesToDisplay so it doesn't grow unbounded. + // Only trim when a positive cap is configured (NumberOfFilesToDisplay defaults to 0). + if (NumberOfFilesToDisplay > 0) + { + while (Collection.Count > NumberOfFilesToDisplay) + { + RemoveItem(Collection.Count - 1); + } + } AddToJumpList(filePath); SaveToXML(); } @@ -202,6 +181,20 @@ public void AddToJumpList(string filePath) var jumpList = JumpList.GetJumpList(Application.Current); if (jumpList == null) return; + + // De-duplicate: remove any existing JumpItem matching this file path before inserting. + // Without this, opening the same file repeatedly accumulates duplicate entries in the + // Windows JumpList, and the trim below only removes the oldest — leaving stale dupes + // visible in the taskbar's Recent Files category. + for (int i = jumpList.JumpItems.Count - 1; i >= 0; i--) + { + if (jumpList.JumpItems[i] is JumpTask existing && + string.Equals(existing.Arguments, filePath, StringComparison.OrdinalIgnoreCase)) + { + jumpList.JumpItems.RemoveAt(i); + } + } + jumpList.JumpItems.Insert(0, task); if (jumpList.JumpItems.Count > NumberOfFilesToDisplay) { @@ -262,31 +255,39 @@ public void LoadJumpList() /// public void LoadFromXML() { - // Check if the recent file list exists. - if (File.Exists(FilePath) == true) + try { - // Clear collection - ClearAll(); - // Load recent files from disk - var xml = new XmlDocument(); - xml.Load(FilePath); - var recentFilesNode = xml.GetElementsByTagName("RecentFiles").Item(0); - if (recentFilesNode == null) return; - - foreach (XmlNode node in recentFilesNode.ChildNodes) + // Check if the recent file list exists. + if (File.Exists(FilePath) == true) { - // Check to see if the file still exists - var pathAttribute = node.Attributes?["Path"]; - if (pathAttribute == null) continue; - - string filePath = pathAttribute.Value; - if (File.Exists(filePath)) + // Clear collection + ClearAll(); + // Load recent files from disk + var xml = new XmlDocument(); + xml.Load(FilePath); + var recentFilesNode = xml.GetElementsByTagName("RecentFiles").Item(0); + if (recentFilesNode == null) return; + + foreach (XmlNode node in recentFilesNode.ChildNodes) { - var item = new RecentFileItem(filePath); - Collection.Add(item); + // Check to see if the file still exists + var pathAttribute = node.Attributes?["Path"]; + if (pathAttribute == null) continue; + + string filePath = pathAttribute.Value; + if (File.Exists(filePath)) + { + var item = new RecentFileItem(filePath); + Collection.Add(item); + } } } } + catch (Exception ex) when (ex is XmlException || ex is IOException || ex is UnauthorizedAccessException) + { + // If the XML file is corrupted or inaccessible, drop the list and fall through to LoadJumpList. + ClearAll(); + } LoadJumpList(); } @@ -327,9 +328,32 @@ public void SaveToXML() /// /// The source of the event. /// The event arguments. + /// + /// + /// Parent contract: derives from + /// and is intended to live + /// inside a (typically the + /// File menu). This handler runs on the Loaded event and walks the + /// logical parent: if Parent is not a MenuItem, the wiring is + /// silently skipped (a Debug.WriteLine is emitted) so a misconfigured XAML + /// host cannot crash application startup. Hosts that need to embed + /// RecentFiles elsewhere (toolbar, ribbon, custom shell) must subclass + /// it and override the menu wiring. + /// + /// private void ConnectToMenu(object sender, RoutedEventArgs e) { - if (Parent is not MenuItem parentItem) throw new ApplicationException("Parent must be a MenuItem"); + // The parent must be a MenuItem for SubmenuOpened wiring below to make sense, but a + // misconfigured XAML host (e.g. RecentFiles dropped into a ContextMenu, ToolBar, or + // any non-MenuItem container) is a developer error — not a reason to crash the app + // at startup. Log and skip; the recent-files feature simply won't activate there. + if (Parent is not MenuItem parentItem) + { + System.Diagnostics.Debug.WriteLine( + $"RecentFiles.ConnectToMenu: Parent must be a MenuItem but is '{Parent?.GetType().FullName ?? "null"}'. " + + "Recent files menu wiring skipped."); + return; + } if (FileMenu != null && FileMenu.Equals(parentItem)) return; if (FileMenu != null) FileMenu.SubmenuOpened -= FileMenu_SubMenuOpened; FileMenu = parentItem; diff --git a/src/FrameworkUI/Recent Files/RecentFilesDialog.xaml.cs b/src/FrameworkUI/Recent Files/RecentFilesDialog.xaml.cs index 923770c6..619cc887 100644 --- a/src/FrameworkUI/Recent Files/RecentFilesDialog.xaml.cs +++ b/src/FrameworkUI/Recent Files/RecentFilesDialog.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ? Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ? Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ? The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; using System.Windows.Media; diff --git a/src/FrameworkUI/Themes/ThemeColor.cs b/src/FrameworkUI/Themes/ThemeColor.cs index a79d264c..596f5119 100644 --- a/src/FrameworkUI/Themes/ThemeColor.cs +++ b/src/FrameworkUI/Themes/ThemeColor.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - // Copyright (c) USACE. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. diff --git a/src/FrameworkUI/Themes/ThemeManager.cs b/src/FrameworkUI/Themes/ThemeManager.cs index 1a9ba860..58979f2d 100644 --- a/src/FrameworkUI/Themes/ThemeManager.cs +++ b/src/FrameworkUI/Themes/ThemeManager.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - // Copyright (c) USACE. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. @@ -127,6 +97,16 @@ public class ThemeManager /// public static void SetTheme(ThemeColor theme) { + // Marshal to UI thread when called from a worker. Mirrors the pattern in + // Themes.ThemeService.SetTheme — ResourceDictionary mutation and the + // raised ThemeChanged event must occur on the dispatcher thread. + var app = Application.Current; + if (app != null && !app.Dispatcher.CheckAccess()) + { + app.Dispatcher.Invoke(() => SetTheme(theme)); + return; + } + // Convert to Themes.Theme enum and update ThemeService var themesTheme = ConvertToThemesTheme(theme); @@ -224,12 +204,21 @@ public static ThemeColor ConvertFromThemesTheme(Themes.Theme theme) /// The light theme URI string. private static void RemoveProjectUIThemeDictionaries(string blueString, string darkString, string lightString) { + // Only consider dictionaries whose Source explicitly references FrameworkUI's pack URI segment. + // Without the assembly-segment guard, EndsWith could match dictionaries with the same relative + // suffix from a different assembly (e.g. RmcCore;component/Themes/VS2013/BlueTheme.xaml). + const string assemblySegment = "/FrameworkUI;component/"; for (int i = Application.Current.Resources.MergedDictionaries.Count - 1; i >= 0; i -= 1) { var source = Application.Current.Resources.MergedDictionaries[i].Source; if (source != null) { var originalString = source.OriginalString; + if (!originalString.Contains(assemblySegment, StringComparison.OrdinalIgnoreCase)) + { + continue; + } + if (originalString.EndsWith(blueString, StringComparison.OrdinalIgnoreCase) || originalString.EndsWith(darkString, StringComparison.OrdinalIgnoreCase) || originalString.EndsWith(lightString, StringComparison.OrdinalIgnoreCase)) diff --git a/src/FrameworkUI/Tools Menu/AutoBackup/AutoBackup.cs b/src/FrameworkUI/Tools Menu/AutoBackup/AutoBackup.cs index ab8b6c10..d78bd2e1 100644 --- a/src/FrameworkUI/Tools Menu/AutoBackup/AutoBackup.cs +++ b/src/FrameworkUI/Tools Menu/AutoBackup/AutoBackup.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Diagnostics; using System.IO; @@ -194,30 +164,39 @@ public static void Cancel() /// Any existing backup file will be deleted before the new backup is created. /// /// - public static void CreateBackupProjectFile() + /// true if a backup was successfully created; false if the project was missing, + /// the source file did not exist, or an I/O / permission error prevented the copy. + public static bool CreateBackupProjectFile() { - if (Project == null) return; - if (string.IsNullOrEmpty(Project.FullFileName)) return; - if (!File.Exists(Project.FullFileName)) return; + // Snapshot Project / FullFileName once. The static Project property can change between + // calls (e.g. user opens a different project mid-backup), so we want a stable view. + var project = Project; + if (project == null) return false; + var sourcePath = project.FullFileName; + if (string.IsNullOrEmpty(sourcePath)) return false; + if (!File.Exists(sourcePath)) return false; try { - // Delete existing backup first - DeleteBackupProjectFile(); + // Delete existing backup first (uses the same snapshot) + DeleteBackupProjectFile(sourcePath); // Create backup copy - string backupPath = Project.FullFileName + ShellPublicVariables.BackupExtension; - File.Copy(Project.FullFileName, backupPath, overwrite: true); + string backupPath = sourcePath + ShellPublicVariables.BackupExtension; + File.Copy(sourcePath, backupPath, overwrite: true); + return true; } catch (IOException ex) { // File may be in use - log but don't interrupt user workflow Debug.WriteLine($"AutoBackup.CreateBackupProjectFile: IOException - {ex.Message}"); + return false; } catch (UnauthorizedAccessException ex) { // No permission - log but don't interrupt user workflow Debug.WriteLine($"AutoBackup.CreateBackupProjectFile: UnauthorizedAccessException - {ex.Message}"); + return false; } } @@ -230,12 +209,23 @@ public static void CreateBackupProjectFile() /// public static void DeleteBackupProjectFile() { - if (Project == null) return; - if (string.IsNullOrEmpty(Project.FullFileName)) return; + var project = Project; + if (project == null) return; + DeleteBackupProjectFile(project.FullFileName); + } + + /// + /// Deletes the backup file associated with a specific source project path. + /// + /// The current project's full file path. The backup path is derived by + /// appending . + private static void DeleteBackupProjectFile(string? sourceProjectPath) + { + if (string.IsNullOrEmpty(sourceProjectPath)) return; try { - string backupPath = Project.FullFileName + ShellPublicVariables.BackupExtension; + string backupPath = sourceProjectPath + ShellPublicVariables.BackupExtension; if (File.Exists(backupPath)) { File.Delete(backupPath); @@ -294,7 +284,18 @@ private static void Timer_Tick(object? sender, EventArgs e) /// private static void BackgroundWorker_DoWork(object? sender, DoWorkEventArgs e) { - CreateBackupProjectFile(); + // Honor a cancellation request that arrived between RunWorkerAsync and DoWork. + var worker = sender as BackgroundWorker; + if (worker?.CancellationPending == true) + { + e.Cancel = true; + e.Result = false; + return; + } + + // Surface success/failure on the completed args so WorkerComplete only reports + // "saved" when a backup actually happened. + e.Result = CreateBackupProjectFile(); } /// @@ -303,6 +304,10 @@ private static void BackgroundWorker_DoWork(object? sender, DoWorkEventArgs e) private static void BackgroundWorker_WorkerComplete(object? sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled) return; + // Don't claim a backup happened if DoWork bailed out (no project, file missing, + // I/O exception, permission denied). Errors were already logged via Debug.WriteLine. + if (e.Error != null) return; + if (e.Result is bool success && !success) return; string projectName = Project?.Name ?? "Unknown"; ReportProgress?.Invoke($"A backup file for the project '{projectName}' was saved."); diff --git a/src/FrameworkUI/Tools Menu/File Size Management/CompactProgressControl.xaml.cs b/src/FrameworkUI/Tools Menu/File Size Management/CompactProgressControl.xaml.cs index 7ed5783e..32bec4ae 100644 --- a/src/FrameworkUI/Tools Menu/File Size Management/CompactProgressControl.xaml.cs +++ b/src/FrameworkUI/Tools Menu/File Size Management/CompactProgressControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using GenericControls; +using GenericControls; namespace FrameworkUI { diff --git a/src/FrameworkUI/Tools Menu/File Size Management/FileSizeManager.cs b/src/FrameworkUI/Tools Menu/File Size Management/FileSizeManager.cs index 6ca0da9c..bab0c1b3 100644 --- a/src/FrameworkUI/Tools Menu/File Size Management/FileSizeManager.cs +++ b/src/FrameworkUI/Tools Menu/File Size Management/FileSizeManager.cs @@ -1,35 +1,6 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Windows.Threading; using FrameworkInterfaces; @@ -374,7 +345,7 @@ public static string FormatBytes(ulong bytes) unit = "bytes"; } - return value.ToString("N2") + " " + unit; + return value.ToString("N2", CultureInfo.CurrentCulture) + " " + unit; } catch (Exception ex) { diff --git a/src/FrameworkUI/Tools Menu/Options/DefaultsOptions.xaml.cs b/src/FrameworkUI/Tools Menu/Options/DefaultsOptions.xaml.cs index bc07f9a1..4c17da4a 100644 --- a/src/FrameworkUI/Tools Menu/Options/DefaultsOptions.xaml.cs +++ b/src/FrameworkUI/Tools Menu/Options/DefaultsOptions.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using GenericControls; +using GenericControls; using System.IO; using System.Windows; using System.Windows.Controls; diff --git a/src/FrameworkUI/Tools Menu/Options/FileManagementOptions.xaml.cs b/src/FrameworkUI/Tools Menu/Options/FileManagementOptions.xaml.cs index 8359a922..d1735ae8 100644 --- a/src/FrameworkUI/Tools Menu/Options/FileManagementOptions.xaml.cs +++ b/src/FrameworkUI/Tools Menu/Options/FileManagementOptions.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Controls; namespace FrameworkUI diff --git a/src/FrameworkUI/Tools Menu/Options/GeneralOptions.xaml.cs b/src/FrameworkUI/Tools Menu/Options/GeneralOptions.xaml.cs index 8ac2c868..eaa1bf94 100644 --- a/src/FrameworkUI/Tools Menu/Options/GeneralOptions.xaml.cs +++ b/src/FrameworkUI/Tools Menu/Options/GeneralOptions.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Controls; namespace FrameworkUI diff --git a/src/FrameworkUI/Tools Menu/Options/MessageWindowOptions.xaml.cs b/src/FrameworkUI/Tools Menu/Options/MessageWindowOptions.xaml.cs index bf5a7ca6..76f6c46c 100644 --- a/src/FrameworkUI/Tools Menu/Options/MessageWindowOptions.xaml.cs +++ b/src/FrameworkUI/Tools Menu/Options/MessageWindowOptions.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Controls; using System.Windows.Media; diff --git a/src/FrameworkUI/Tools Menu/Options/OptionsDialog.xaml.cs b/src/FrameworkUI/Tools Menu/Options/OptionsDialog.xaml.cs index 3bca97f6..6fddfbae 100644 --- a/src/FrameworkUI/Tools Menu/Options/OptionsDialog.xaml.cs +++ b/src/FrameworkUI/Tools Menu/Options/OptionsDialog.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Windows; using System.Windows.Media; using GenericControls; diff --git a/src/FrameworkUI/Unsaved Elements/SaveElementsDialog.xaml.cs b/src/FrameworkUI/Unsaved Elements/SaveElementsDialog.xaml.cs index ba4d76c5..49a70245 100644 --- a/src/FrameworkUI/Unsaved Elements/SaveElementsDialog.xaml.cs +++ b/src/FrameworkUI/Unsaved Elements/SaveElementsDialog.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ? Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ? Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ? The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.ObjectModel; using System.Windows; using GenericControls; diff --git a/src/FrameworkUI/Unsaved Elements/UnsavedElement.cs b/src/FrameworkUI/Unsaved Elements/UnsavedElement.cs index c308578d..fc03267f 100644 --- a/src/FrameworkUI/Unsaved Elements/UnsavedElement.cs +++ b/src/FrameworkUI/Unsaved Elements/UnsavedElement.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Media; using GenericControls; using FrameworkInterfaces; diff --git a/src/FrameworkUI/User Settings/UserSettings.cs b/src/FrameworkUI/User Settings/UserSettings.cs index 217ac915..8550029f 100644 --- a/src/FrameworkUI/User Settings/UserSettings.cs +++ b/src/FrameworkUI/User Settings/UserSettings.cs @@ -1,34 +1,5 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; +using System.Globalization; using System.IO; using System.Xml; @@ -297,13 +268,13 @@ public static void Load(string xmlFilePath) else if (elementName == nameof(MaxWindowMenuItems)) { innerXml = xmlReader.ReadInnerXml(); - if (int.TryParse(innerXml, out int maxItems)) + if (int.TryParse(innerXml, NumberStyles.Integer, CultureInfo.InvariantCulture, out int maxItems)) MaxWindowMenuItems = maxItems; } else if (elementName == nameof(MaxRecentFileItems)) { innerXml = xmlReader.ReadInnerXml(); - if (int.TryParse(innerXml, out int maxRecent)) + if (int.TryParse(innerXml, NumberStyles.Integer, CultureInfo.InvariantCulture, out int maxRecent)) MaxRecentFileItems = maxRecent; } else if (elementName == nameof(ShowUndoRedoButtons)) @@ -328,7 +299,7 @@ public static void Load(string xmlFilePath) else if (elementName == nameof(AutoRecoverInterval)) { innerXml = xmlReader.ReadInnerXml(); - if (int.TryParse(innerXml, out int interval)) + if (int.TryParse(innerXml, NumberStyles.Integer, CultureInfo.InvariantCulture, out int interval)) AutoRecoverInterval = Math.Max(1, interval); } else if (elementName == nameof(KeepLastBackupVersion)) @@ -371,25 +342,25 @@ public static void Load(string xmlFilePath) else if (elementName == nameof(ErrorColor)) { innerXml = xmlReader.ReadInnerXml(); - if (int.TryParse(innerXml, out int argb)) + if (int.TryParse(innerXml, NumberStyles.Integer, CultureInfo.InvariantCulture, out int argb)) ErrorColor = UtilityFunctions.IntegerToColor(ref argb); } else if (elementName == nameof(WarningColor)) { innerXml = xmlReader.ReadInnerXml(); - if (int.TryParse(innerXml, out int argb)) + if (int.TryParse(innerXml, NumberStyles.Integer, CultureInfo.InvariantCulture, out int argb)) WarningColor = UtilityFunctions.IntegerToColor(ref argb); } else if (elementName == nameof(MessageColor)) { innerXml = xmlReader.ReadInnerXml(); - if (int.TryParse(innerXml, out int argb)) + if (int.TryParse(innerXml, NumberStyles.Integer, CultureInfo.InvariantCulture, out int argb)) MessageColor = UtilityFunctions.IntegerToColor(ref argb); } else if (elementName == nameof(EventColor)) { innerXml = xmlReader.ReadInnerXml(); - if (int.TryParse(innerXml, out int argb)) + if (int.TryParse(innerXml, NumberStyles.Integer, CultureInfo.InvariantCulture, out int argb)) EventColor = UtilityFunctions.IntegerToColor(ref argb); } // Defaults @@ -400,7 +371,7 @@ public static void Load(string xmlFilePath) else if (elementName == nameof(DefaultValueDigits)) { innerXml = xmlReader.ReadInnerXml(); - if (int.TryParse(innerXml, out int digits)) + if (int.TryParse(innerXml, NumberStyles.Integer, CultureInfo.InvariantCulture, out int digits)) DefaultValueDigits = digits; } } @@ -457,11 +428,11 @@ public static void Save(string xmlFilePath) xmlWriter.WriteEndElement(); // xmlWriter.WriteStartElement(nameof(MaxWindowMenuItems)); - xmlWriter.WriteString(MaxWindowMenuItems.ToString()); + xmlWriter.WriteString(MaxWindowMenuItems.ToString(CultureInfo.InvariantCulture)); xmlWriter.WriteEndElement(); - // + // xmlWriter.WriteStartElement(nameof(MaxRecentFileItems)); - xmlWriter.WriteString(MaxRecentFileItems.ToString()); + xmlWriter.WriteString(MaxRecentFileItems.ToString(CultureInfo.InvariantCulture)); xmlWriter.WriteEndElement(); // xmlWriter.WriteStartElement(nameof(ShowUndoRedoButtons)); @@ -479,7 +450,7 @@ public static void Save(string xmlFilePath) xmlWriter.WriteEndElement(); // xmlWriter.WriteStartElement(nameof(AutoRecoverInterval)); - xmlWriter.WriteString(AutoRecoverInterval.ToString()); + xmlWriter.WriteString(AutoRecoverInterval.ToString(CultureInfo.InvariantCulture)); xmlWriter.WriteEndElement(); // xmlWriter.WriteStartElement(nameof(KeepLastBackupVersion)); @@ -509,19 +480,19 @@ public static void Save(string xmlFilePath) xmlWriter.WriteEndElement(); // xmlWriter.WriteStartElement(nameof(ErrorColor)); - xmlWriter.WriteString(UtilityFunctions.ColorToInteger(ErrorColor).ToString()); + xmlWriter.WriteString(UtilityFunctions.ColorToInteger(ErrorColor).ToString(CultureInfo.InvariantCulture)); xmlWriter.WriteEndElement(); // xmlWriter.WriteStartElement(nameof(WarningColor)); - xmlWriter.WriteString(UtilityFunctions.ColorToInteger(WarningColor).ToString()); + xmlWriter.WriteString(UtilityFunctions.ColorToInteger(WarningColor).ToString(CultureInfo.InvariantCulture)); xmlWriter.WriteEndElement(); // xmlWriter.WriteStartElement(nameof(MessageColor)); - xmlWriter.WriteString(UtilityFunctions.ColorToInteger(MessageColor).ToString()); + xmlWriter.WriteString(UtilityFunctions.ColorToInteger(MessageColor).ToString(CultureInfo.InvariantCulture)); xmlWriter.WriteEndElement(); // xmlWriter.WriteStartElement(nameof(EventColor)); - xmlWriter.WriteString(UtilityFunctions.ColorToInteger(EventColor).ToString()); + xmlWriter.WriteString(UtilityFunctions.ColorToInteger(EventColor).ToString(CultureInfo.InvariantCulture)); xmlWriter.WriteEndElement(); // // Defaults @@ -531,7 +502,7 @@ public static void Save(string xmlFilePath) xmlWriter.WriteEndElement(); // xmlWriter.WriteStartElement(nameof(DefaultValueDigits)); - xmlWriter.WriteString(DefaultValueDigits.ToString()); + xmlWriter.WriteString(DefaultValueDigits.ToString(CultureInfo.InvariantCulture)); xmlWriter.WriteEndElement(); // // The end of settings. diff --git a/src/FrameworkUI/Utilities/ApplicationAttributes.cs b/src/FrameworkUI/Utilities/ApplicationAttributes.cs index 364d26d2..78bf2f21 100644 --- a/src/FrameworkUI/Utilities/ApplicationAttributes.cs +++ b/src/FrameworkUI/Utilities/ApplicationAttributes.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Reflection; +using System.Reflection; namespace FrameworkUI { diff --git a/src/FrameworkUI/Utilities/ShellPublicVariables.cs b/src/FrameworkUI/Utilities/ShellPublicVariables.cs index 42f40955..9c6d1ce4 100644 --- a/src/FrameworkUI/Utilities/ShellPublicVariables.cs +++ b/src/FrameworkUI/Utilities/ShellPublicVariables.cs @@ -1,47 +1,15 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -namespace FrameworkUI +namespace FrameworkUI { /// /// A static class for public shared shell variables. /// /// /// - /// Authors: -/// -/// Authors: -/// -/// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil -/// -/// + /// Authors: + /// + /// + /// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil + /// /// public static class ShellPublicVariables { diff --git a/src/FrameworkUI/Utilities/UtilityFunctions.cs b/src/FrameworkUI/Utilities/UtilityFunctions.cs index 987fb539..ca6f1b78 100644 --- a/src/FrameworkUI/Utilities/UtilityFunctions.cs +++ b/src/FrameworkUI/Utilities/UtilityFunctions.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.IO; using System.Reflection; using System.Text; @@ -317,7 +287,6 @@ orderby p.Name /// /// Adds the handlers from the source component to the destination component /// - /// An IComponent type /// The destination component. /// The source component. public static void CopyClick(this MenuItem destinationComponent, MenuItem sourceComponent) diff --git a/src/FrameworkUI/Windows Menu/OpenWindowItem.cs b/src/FrameworkUI/Windows Menu/OpenWindowItem.cs index 37d6f815..5d43c728 100644 --- a/src/FrameworkUI/Windows Menu/OpenWindowItem.cs +++ b/src/FrameworkUI/Windows Menu/OpenWindowItem.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Controls; using System.Windows.Media; using FrameworkInterfaces; diff --git a/src/FrameworkUI/Windows Menu/OpenWindows.cs b/src/FrameworkUI/Windows Menu/OpenWindows.cs index 9cea4d5d..d2d03730 100644 --- a/src/FrameworkUI/Windows Menu/OpenWindows.cs +++ b/src/FrameworkUI/Windows Menu/OpenWindows.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/FrameworkUI/Windows Menu/OpenWindowsDialog.xaml.cs b/src/FrameworkUI/Windows Menu/OpenWindowsDialog.xaml.cs index 3af58bae..cab4d940 100644 --- a/src/FrameworkUI/Windows Menu/OpenWindowsDialog.xaml.cs +++ b/src/FrameworkUI/Windows Menu/OpenWindowsDialog.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Controls; using GenericControls; diff --git a/src/GenericControls.Demo/App.xaml.cs b/src/GenericControls.Demo/App.xaml.cs index 64040da5..bc464fc1 100644 --- a/src/GenericControls.Demo/App.xaml.cs +++ b/src/GenericControls.Demo/App.xaml.cs @@ -1,33 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -using System.Windows; +using System.Windows; using Themes; namespace GenericControls.Demo diff --git a/src/GenericControls.Demo/ColorItem.cs b/src/GenericControls.Demo/ColorItem.cs index ad3ed86f..d438dd4c 100644 --- a/src/GenericControls.Demo/ColorItem.cs +++ b/src/GenericControls.Demo/ColorItem.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - #nullable enable using System.ComponentModel; diff --git a/src/GenericControls.Demo/MainWindow.xaml b/src/GenericControls.Demo/MainWindow.xaml index 03dba42c..82d9b671 100644 --- a/src/GenericControls.Demo/MainWindow.xaml +++ b/src/GenericControls.Demo/MainWindow.xaml @@ -4,6 +4,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:glob="clr-namespace:System.Globalization;assembly=mscorlib" xmlns:local="clr-namespace:GenericControls.Demo" xmlns:cntrls="clr-namespace:GenericControls;assembly=GenericControls" mc:Ignorable="d" @@ -478,7 +479,7 @@ - diff --git a/src/GenericControls.Demo/MainWindow.xaml.cs b/src/GenericControls.Demo/MainWindow.xaml.cs index 23a148e7..8adb8524 100644 --- a/src/GenericControls.Demo/MainWindow.xaml.cs +++ b/src/GenericControls.Demo/MainWindow.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; diff --git a/src/GenericControls/Adorners/DragAdorner.cs b/src/GenericControls/Adorners/DragAdorner.cs index 5bed8f69..bd689e9d 100644 --- a/src/GenericControls/Adorners/DragAdorner.cs +++ b/src/GenericControls/Adorners/DragAdorner.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Documents; using System.Windows.Media; diff --git a/src/GenericControls/Adorners/InsertionAdorner.cs b/src/GenericControls/Adorners/InsertionAdorner.cs index 0814f52a..aae17a98 100644 --- a/src/GenericControls/Adorners/InsertionAdorner.cs +++ b/src/GenericControls/Adorners/InsertionAdorner.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Documents; using System.Windows.Media; diff --git a/src/GenericControls/DataGrid/CopyPasteDataGrid.cs b/src/GenericControls/DataGrid/CopyPasteDataGrid.cs index efa7360e..84272713 100644 --- a/src/GenericControls/DataGrid/CopyPasteDataGrid.cs +++ b/src/GenericControls/DataGrid/CopyPasteDataGrid.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections; +using System.Collections; using System.Collections.ObjectModel; using System.ComponentModel; using System.Data; @@ -877,6 +847,18 @@ public void PasteClipboard() y.SetValue(Items[rowIndex + i], double.NaN, null); } } + else if (IsNumericType(y.PropertyType)) + { + // Non-double numeric (int/long/decimal/etc): parse as double with + // dual-culture fallback first, then convert to the target type. + // Convert.ChangeType alone uses Thread.CurrentCulture and silently + // misparses cross-culture clipboard data ("1,234" US vs DE). + if (double.TryParse(clipboardData[i][j], NumberStyles.Any, CultureInfo.CurrentCulture, out double parsed) || + double.TryParse(clipboardData[i][j], NumberStyles.Any, CultureInfo.InvariantCulture, out parsed)) + { + y.SetValue(Items[rowIndex + i], Convert.ChangeType(parsed, y.PropertyType, CultureInfo.InvariantCulture), null); + } + } else { y.SetValue(Items[rowIndex + i], Convert.ChangeType(clipboardData[i][j], y.PropertyType), null); @@ -984,6 +966,16 @@ public void PasteClipboard() y.SetValue(Items[rowIndex + i], double.NaN, null); } } + else if (IsNumericType(y.PropertyType)) + { + // Non-double numeric (int/long/decimal/etc): parse as double with + // dual-culture fallback first, then convert to the target type. + if (double.TryParse(clipboardData[i][j], NumberStyles.Any, CultureInfo.CurrentCulture, out double parsed) || + double.TryParse(clipboardData[i][j], NumberStyles.Any, CultureInfo.InvariantCulture, out parsed)) + { + y.SetValue(Items[rowIndex + i], Convert.ChangeType(parsed, y.PropertyType, CultureInfo.InvariantCulture), null); + } + } else { y.SetValue(Items[rowIndex + i], Convert.ChangeType(clipboardData[i][j], y.PropertyType), null); diff --git a/src/GenericControls/DataGrid/DataGridToolbar.xaml.cs b/src/GenericControls/DataGrid/DataGridToolbar.xaml.cs index 4f42b6f3..8687448f 100644 --- a/src/GenericControls/DataGrid/DataGridToolbar.xaml.cs +++ b/src/GenericControls/DataGrid/DataGridToolbar.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Windows; diff --git a/src/GenericControls/DataGrid/ValidationDataGrid.cs b/src/GenericControls/DataGrid/ValidationDataGrid.cs index d3b33a70..4a91f944 100644 --- a/src/GenericControls/DataGrid/ValidationDataGrid.cs +++ b/src/GenericControls/DataGrid/ValidationDataGrid.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Diagnostics; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/DataGrid/ValidationDataGridObjects/DataGridRowItem.cs b/src/GenericControls/DataGrid/ValidationDataGridObjects/DataGridRowItem.cs index f787ab51..4cc4e018 100644 --- a/src/GenericControls/DataGrid/ValidationDataGridObjects/DataGridRowItem.cs +++ b/src/GenericControls/DataGrid/ValidationDataGridObjects/DataGridRowItem.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Runtime.CompilerServices; namespace GenericControls diff --git a/src/GenericControls/DataGrid/ValidationDataGridObjects/PropertyRule.cs b/src/GenericControls/DataGrid/ValidationDataGridObjects/PropertyRule.cs index 02831a6c..1865f3b9 100644 --- a/src/GenericControls/DataGrid/ValidationDataGridObjects/PropertyRule.cs +++ b/src/GenericControls/DataGrid/ValidationDataGridObjects/PropertyRule.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; namespace GenericControls { diff --git a/src/GenericControls/Date and Time Controls/ClockControl.xaml.cs b/src/GenericControls/Date and Time Controls/ClockControl.xaml.cs index 52a0f1f1..1b855559 100644 --- a/src/GenericControls/Date and Time Controls/ClockControl.xaml.cs +++ b/src/GenericControls/Date and Time Controls/ClockControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Input; @@ -301,7 +271,8 @@ public double TimeFontSize /// /// Identifies the dependency property. /// - public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register(nameof(SelectedColor), typeof(SolidColorBrush), typeof(ClockControl), new UIPropertyMetadata(new SolidColorBrush(Color.FromArgb(255, 24, 24, 25)))); + // Default null — reference-type DP defaults are shared across all instances. + public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register(nameof(SelectedColor), typeof(SolidColorBrush), typeof(ClockControl), new UIPropertyMetadata(null)); /// /// Gets or sets the brush used to render selected tick marks. /// @@ -339,7 +310,8 @@ public SolidColorBrush HighlightColor /// /// Identifies the dependency property. /// - public static readonly DependencyProperty FaceColorProperty = DependencyProperty.Register(nameof(FaceColor), typeof(SolidColorBrush), typeof(ClockControl), new UIPropertyMetadata(new SolidColorBrush(Color.FromArgb(255, 240, 240, 245)))); + // Default null — reference-type DP defaults are shared across all instances. + public static readonly DependencyProperty FaceColorProperty = DependencyProperty.Register(nameof(FaceColor), typeof(SolidColorBrush), typeof(ClockControl), new UIPropertyMetadata(null)); /// /// Gets or sets the brush used for coloring the face of the clock. /// @@ -446,6 +418,18 @@ public ClockControl() // This call is required by the designer. this.InitializeComponent(); + // Per-instance defaults for the SelectedColor and FaceColor DPs. The DP + // defaults are null because a shared SolidColorBrush across every + // ClockControl instance would let one instance's color change leak + // visually to others. + if (SelectedColor == null) + { + SelectedColor = new SolidColorBrush(Color.FromArgb(255, 24, 24, 25)); + } + if (FaceColor == null) + { + FaceColor = new SolidColorBrush(Color.FromArgb(255, 240, 240, 245)); + } // // Add any initialization after the InitializeComponent() call. _clockMajorNumberStyle = (Style)this.FindResource("ClockMajorValueStyle"); diff --git a/src/GenericControls/Date and Time Controls/DateAndTimePickerControl.xaml.cs b/src/GenericControls/Date and Time Controls/DateAndTimePickerControl.xaml.cs index cbe37a79..927a9c85 100644 --- a/src/GenericControls/Date and Time Controls/DateAndTimePickerControl.xaml.cs +++ b/src/GenericControls/Date and Time Controls/DateAndTimePickerControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Controls; using System.Windows.Input; diff --git a/src/GenericControls/Date and Time Controls/DateAndTimeTextBoxControl.xaml.cs b/src/GenericControls/Date and Time Controls/DateAndTimeTextBoxControl.xaml.cs index f4cc42e0..29fabd8a 100644 --- a/src/GenericControls/Date and Time Controls/DateAndTimeTextBoxControl.xaml.cs +++ b/src/GenericControls/Date and Time Controls/DateAndTimeTextBoxControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Data; diff --git a/src/GenericControls/File Management/FolderBrowser.cs b/src/GenericControls/File Management/FolderBrowser.cs index 710d408c..7d95ff56 100644 --- a/src/GenericControls/File Management/FolderBrowser.cs +++ b/src/GenericControls/File Management/FolderBrowser.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Interop; diff --git a/src/GenericControls/File Management/RecentFileList.cs b/src/GenericControls/File Management/RecentFileList.cs index 806d8c60..ad344e4a 100644 --- a/src/GenericControls/File Management/RecentFileList.cs +++ b/src/GenericControls/File Management/RecentFileList.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Reflection; +using System.Reflection; using System.Windows; using System.Windows.Controls; using Microsoft.Win32; diff --git a/src/GenericControls/General Controls/BooleanToVisibilityConverter.cs b/src/GenericControls/General Controls/BooleanToVisibilityConverter.cs index a37e7a1c..bf4441ed 100644 --- a/src/GenericControls/General Controls/BooleanToVisibilityConverter.cs +++ b/src/GenericControls/General Controls/BooleanToVisibilityConverter.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Globalization; +using System.Globalization; using System.Windows.Data; using System.Windows; diff --git a/src/GenericControls/General Controls/ColorPicker.xaml.cs b/src/GenericControls/General Controls/ColorPicker.xaml.cs index 1e6a4092..95e9c306 100644 --- a/src/GenericControls/General Controls/ColorPicker.xaml.cs +++ b/src/GenericControls/General Controls/ColorPicker.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; @@ -62,8 +32,26 @@ public partial class ColorPicker:UserControl private bool _isLoaded = false; /// - /// Dependency property for the selected color. + /// Dependency property for the selected color. /// + /// + /// + /// Property type is , not + /// . Bindings and code-behind must + /// supply (and read back) a SolidColorBrush; assigning a raw + /// Color will not type-check at the DP level. Callers that hold a + /// Color should wrap it: new SolidColorBrush(myColor). + /// + /// + /// Grayscale-hue retention: when a grayscale color (saturation ≈ 0) + /// is assigned, the slider's hue position is intentionally preserved from + /// the prior selection rather than snapping back to red (hue = 0). This + /// keeps the slider stable while the user moves the marker through the + /// neutral column of the color preview, so subsequent saturation/value + /// changes do not jump the chosen hue. For the assignment path, see + /// UpdateSliderPosition. + /// + /// public static readonly DependencyProperty ColorProperty = DependencyProperty.Register(nameof(Color), typeof(SolidColorBrush), typeof(ColorPicker), new UIPropertyMetadata(Brushes.Black, ColorCallback)); /// diff --git a/src/GenericControls/General Controls/ColorPickerPopup.xaml.cs b/src/GenericControls/General Controls/ColorPickerPopup.xaml.cs index 71a91ca9..2c626c5f 100644 --- a/src/GenericControls/General Controls/ColorPickerPopup.xaml.cs +++ b/src/GenericControls/General Controls/ColorPickerPopup.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; using System.Windows.Media; diff --git a/src/GenericControls/General Controls/ColorToByteConverter.cs b/src/GenericControls/General Controls/ColorToByteConverter.cs index def929ab..6339cbe1 100644 --- a/src/GenericControls/General Controls/ColorToByteConverter.cs +++ b/src/GenericControls/General Controls/ColorToByteConverter.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Data; using System.Windows.Media; diff --git a/src/GenericControls/General Controls/GridLengthControl.xaml.cs b/src/GenericControls/General Controls/GridLengthControl.xaml.cs index 4348f3ee..3cf4f810 100644 --- a/src/GenericControls/General Controls/GridLengthControl.xaml.cs +++ b/src/GenericControls/General Controls/GridLengthControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/General Controls/NameTextBox.xaml.cs b/src/GenericControls/General Controls/NameTextBox.xaml.cs index 4bc3c726..335e1ba5 100644 --- a/src/GenericControls/General Controls/NameTextBox.xaml.cs +++ b/src/GenericControls/General Controls/NameTextBox.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; using System.Windows.Data; diff --git a/src/GenericControls/General Controls/NumericSlider.xaml.cs b/src/GenericControls/General Controls/NumericSlider.xaml.cs index e2d86102..4e23f7cb 100644 --- a/src/GenericControls/General Controls/NumericSlider.xaml.cs +++ b/src/GenericControls/General Controls/NumericSlider.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using System.Windows.Controls; namespace GenericControls diff --git a/src/GenericControls/General Controls/NumericTextBox.xaml.cs b/src/GenericControls/General Controls/NumericTextBox.xaml.cs index 805f9f75..6bee074f 100644 --- a/src/GenericControls/General Controls/NumericTextBox.xaml.cs +++ b/src/GenericControls/General Controls/NumericTextBox.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; using System.Windows.Data; diff --git a/src/GenericControls/General Controls/NumericTextBox2.xaml b/src/GenericControls/General Controls/NumericTextBox2.xaml index 411ccd1a..84023816 100644 --- a/src/GenericControls/General Controls/NumericTextBox2.xaml +++ b/src/GenericControls/General Controls/NumericTextBox2.xaml @@ -1,22 +1,23 @@  + Text="{Binding Value, ElementName=NumericText, UpdateSourceTrigger=LostFocus, Mode=TwoWay, StringFormat='G', ConverterCulture={x:Static glob:CultureInfo.CurrentCulture}}"> diff --git a/src/GenericControls/General Controls/NumericTextBox2.xaml.cs b/src/GenericControls/General Controls/NumericTextBox2.xaml.cs index 5ea812e8..e009ba66 100644 --- a/src/GenericControls/General Controls/NumericTextBox2.xaml.cs +++ b/src/GenericControls/General Controls/NumericTextBox2.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/General Controls/NumericUpDown.xaml.cs b/src/GenericControls/General Controls/NumericUpDown.xaml.cs index 7668e20f..72965c84 100644 --- a/src/GenericControls/General Controls/NumericUpDown.xaml.cs +++ b/src/GenericControls/General Controls/NumericUpDown.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; namespace GenericControls { diff --git a/src/GenericControls/General Controls/ResizableTextBoxControl.xaml.cs b/src/GenericControls/General Controls/ResizableTextBoxControl.xaml.cs index 4971dc68..c67a64ce 100644 --- a/src/GenericControls/General Controls/ResizableTextBoxControl.xaml.cs +++ b/src/GenericControls/General Controls/ResizableTextBoxControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; using System.Windows.Data; diff --git a/src/GenericControls/General Controls/SeparatorWithHeader.xaml.cs b/src/GenericControls/General Controls/SeparatorWithHeader.xaml.cs index 3be9825f..ed0a297b 100644 --- a/src/GenericControls/General Controls/SeparatorWithHeader.xaml.cs +++ b/src/GenericControls/General Controls/SeparatorWithHeader.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/General Controls/ThicknessControl.xaml.cs b/src/GenericControls/General Controls/ThicknessControl.xaml.cs index 0d673791..1f980ed0 100644 --- a/src/GenericControls/General Controls/ThicknessControl.xaml.cs +++ b/src/GenericControls/General Controls/ThicknessControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; using System.Windows.Input; diff --git a/src/GenericControls/Properties Controls/BooleanPropertyControl.xaml.cs b/src/GenericControls/Properties Controls/BooleanPropertyControl.xaml.cs index 2e7f30c8..6d6a4548 100644 --- a/src/GenericControls/Properties Controls/BooleanPropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/BooleanPropertyControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Properties Controls/CalendarWeekRulePropertyControl.xaml.cs b/src/GenericControls/Properties Controls/CalendarWeekRulePropertyControl.xaml.cs index fdd36f8f..7543a2f9 100644 --- a/src/GenericControls/Properties Controls/CalendarWeekRulePropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/CalendarWeekRulePropertyControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Globalization; using System.Windows; diff --git a/src/GenericControls/Properties Controls/ColorPropertyControl.xaml.cs b/src/GenericControls/Properties Controls/ColorPropertyControl.xaml.cs index 95ff3e56..51fae0da 100644 --- a/src/GenericControls/Properties Controls/ColorPropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/ColorPropertyControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; using System.Windows.Media; @@ -58,12 +28,19 @@ public partial class ColorPropertyControl:UserControl public ColorPropertyControl() { InitializeComponent(); + // Per-instance default (DP default is null — see DP registration). + if (SelectedColor == null) + { + SelectedColor = new SolidColorBrush(Colors.Black); + } } /// /// Dependency property for the property. /// - public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register(nameof(SelectedColor), typeof(SolidColorBrush), typeof(ColorPropertyControl), new UIPropertyMetadata(new SolidColorBrush(Colors.Black))); + // Default null — reference-type DP defaults are shared across all instances. + // Per-instance default initialized in the constructor. + public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register(nameof(SelectedColor), typeof(SolidColorBrush), typeof(ColorPropertyControl), new UIPropertyMetadata(null)); /// /// Gets or sets the selected color represented as a . /// diff --git a/src/GenericControls/Properties Controls/ContentPropertyControl.xaml.cs b/src/GenericControls/Properties Controls/ContentPropertyControl.xaml.cs index 116ef8e1..49a2d3ec 100644 --- a/src/GenericControls/Properties Controls/ContentPropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/ContentPropertyControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Properties Controls/DateTimePropertyControl.xaml.cs b/src/GenericControls/Properties Controls/DateTimePropertyControl.xaml.cs index 5201acd3..55397f8d 100644 --- a/src/GenericControls/Properties Controls/DateTimePropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/DateTimePropertyControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Properties Controls/DirectorySelectorControl.xaml.cs b/src/GenericControls/Properties Controls/DirectorySelectorControl.xaml.cs index 567c82fa..6ac49ebb 100644 --- a/src/GenericControls/Properties Controls/DirectorySelectorControl.xaml.cs +++ b/src/GenericControls/Properties Controls/DirectorySelectorControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Properties Controls/FileSelectorControl.xaml.cs b/src/GenericControls/Properties Controls/FileSelectorControl.xaml.cs index dd17ccc9..fe0e4b20 100644 --- a/src/GenericControls/Properties Controls/FileSelectorControl.xaml.cs +++ b/src/GenericControls/Properties Controls/FileSelectorControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Properties Controls/FolderSelectorControl.xaml.cs b/src/GenericControls/Properties Controls/FolderSelectorControl.xaml.cs index c5d328c7..610b719e 100644 --- a/src/GenericControls/Properties Controls/FolderSelectorControl.xaml.cs +++ b/src/GenericControls/Properties Controls/FolderSelectorControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Properties Controls/FontSelectorControl.xaml.cs b/src/GenericControls/Properties Controls/FontSelectorControl.xaml.cs index 6125ece4..bade5c39 100644 --- a/src/GenericControls/Properties Controls/FontSelectorControl.xaml.cs +++ b/src/GenericControls/Properties Controls/FontSelectorControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Properties Controls/FontWeightSelectorControl.xaml.cs b/src/GenericControls/Properties Controls/FontWeightSelectorControl.xaml.cs index 8cdec027..bd417d75 100644 --- a/src/GenericControls/Properties Controls/FontWeightSelectorControl.xaml.cs +++ b/src/GenericControls/Properties Controls/FontWeightSelectorControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Properties Controls/HorizontalAlignmentControl.xaml.cs b/src/GenericControls/Properties Controls/HorizontalAlignmentControl.xaml.cs index 2190d271..5650e968 100644 --- a/src/GenericControls/Properties Controls/HorizontalAlignmentControl.xaml.cs +++ b/src/GenericControls/Properties Controls/HorizontalAlignmentControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Linq; using System.Windows; diff --git a/src/GenericControls/Properties Controls/LineStyleSelectorControl.xaml.cs b/src/GenericControls/Properties Controls/LineStyleSelectorControl.xaml.cs index c602a651..b64146b7 100644 --- a/src/GenericControls/Properties Controls/LineStyleSelectorControl.xaml.cs +++ b/src/GenericControls/Properties Controls/LineStyleSelectorControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using System.Windows.Controls; @@ -60,6 +30,10 @@ public partial class LineStyleSelectorControl:UserControl public LineStyleSelectorControl() { InitializeComponent(); + if (SelectedDashArray == null) + { + SelectedDashArray = new DoubleCollection(); + } } /// @@ -70,7 +44,8 @@ public LineStyleSelectorControl() /// /// Identifies the dependency property. /// - public static readonly DependencyProperty SelectedDashArrayProperty = DependencyProperty.Register(nameof(SelectedDashArray), typeof(DoubleCollection), typeof(LineStyleSelectorControl), new UIPropertyMetadata(new DoubleCollection())); + // Default null — reference-type DP defaults are shared across all instances. + public static readonly DependencyProperty SelectedDashArrayProperty = DependencyProperty.Register(nameof(SelectedDashArray), typeof(DoubleCollection), typeof(LineStyleSelectorControl), new UIPropertyMetadata(null)); /// /// Gets or sets the currently selected dash array pattern. /// diff --git a/src/GenericControls/Properties Controls/LineWidthSelectorControl.xaml.cs b/src/GenericControls/Properties Controls/LineWidthSelectorControl.xaml.cs index b226e26f..062cad5d 100644 --- a/src/GenericControls/Properties Controls/LineWidthSelectorControl.xaml.cs +++ b/src/GenericControls/Properties Controls/LineWidthSelectorControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Windows; using System.Windows.Controls; @@ -59,6 +29,10 @@ public partial class LineWidthSelectorControl :UserControl, INotifyPropertyChang public LineWidthSelectorControl() { InitializeComponent(); + if (WidthOptions == null) + { + WidthOptions = new List { 0d, 1d, 2d, 3d, 4d, 5d }; + } } /// @@ -83,7 +57,9 @@ public double SelectedWidth /// /// Identifies the dependency property. /// - public static readonly DependencyProperty WidthOptionsProperty = DependencyProperty.Register(nameof(WidthOptions), typeof(IList), typeof(LineWidthSelectorControl), new PropertyMetadata(new List(new[] { 0d, 1d, 2d, 3d, 4d, 5d }))); + // Default null — reference-type DP defaults are shared across all instances. + // Per-instance default initialized in the constructor. + public static readonly DependencyProperty WidthOptionsProperty = DependencyProperty.Register(nameof(WidthOptions), typeof(IList), typeof(LineWidthSelectorControl), new PropertyMetadata(null)); /// /// Gets or sets the list of selectable line width options. /// diff --git a/src/GenericControls/Properties Controls/NameTextPropertyControl.xaml.cs b/src/GenericControls/Properties Controls/NameTextPropertyControl.xaml.cs index b1e129aa..846c69ee 100644 --- a/src/GenericControls/Properties Controls/NameTextPropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/NameTextPropertyControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Input; diff --git a/src/GenericControls/Properties Controls/NumericAutoPropertyControl.xaml b/src/GenericControls/Properties Controls/NumericAutoPropertyControl.xaml index c29f1a7f..18df9257 100644 --- a/src/GenericControls/Properties Controls/NumericAutoPropertyControl.xaml +++ b/src/GenericControls/Properties Controls/NumericAutoPropertyControl.xaml @@ -1,10 +1,11 @@  @@ -43,7 +44,7 @@ @@ -36,7 +37,7 @@ x:Name="NumericTBox" Height="22" IsEnabled="{Binding IsTextBoxEnabled, ElementName=NumericProperty, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" - Text="{Binding Number, ElementName=NumericProperty, UpdateSourceTrigger=LostFocus, Mode=TwoWay, StringFormat='G'}" + Text="{Binding Number, ElementName=NumericProperty, UpdateSourceTrigger=LostFocus, Mode=TwoWay, StringFormat='G', ConverterCulture={x:Static glob:CultureInfo.CurrentCulture}}" SizeChanged="ControlSizeChanged" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" diff --git a/src/GenericControls/Properties Controls/NumericPropertyControl.xaml.cs b/src/GenericControls/Properties Controls/NumericPropertyControl.xaml.cs index 0446fd60..5735b125 100644 --- a/src/GenericControls/Properties Controls/NumericPropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/NumericPropertyControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Data; diff --git a/src/GenericControls/Properties Controls/NumericPropertySelectorControl.xaml b/src/GenericControls/Properties Controls/NumericPropertySelectorControl.xaml index 7987d8ee..f2618b46 100644 --- a/src/GenericControls/Properties Controls/NumericPropertySelectorControl.xaml +++ b/src/GenericControls/Properties Controls/NumericPropertySelectorControl.xaml @@ -1,10 +1,11 @@  @@ -38,7 +39,7 @@ diff --git a/src/GenericControls/Properties Controls/NumericPropertySelectorControl.xaml.cs b/src/GenericControls/Properties Controls/NumericPropertySelectorControl.xaml.cs index 8a746230..cdbe1e90 100644 --- a/src/GenericControls/Properties Controls/NumericPropertySelectorControl.xaml.cs +++ b/src/GenericControls/Properties Controls/NumericPropertySelectorControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Globalization; using System.Windows; @@ -62,6 +32,10 @@ public partial class NumericPropertySelectorControl : UserControl, INotifyProper public NumericPropertySelectorControl() { InitializeComponent(); + if (NumericOptions == null) + { + NumericOptions = new List { 0d, 1d, 2d, 3d, 4d, 5d }; + } } /// @@ -86,7 +60,8 @@ public double SelectedNumber /// /// Identifies the dependency property. /// - public static readonly DependencyProperty NumericOptionsProperty = DependencyProperty.Register(nameof(NumericOptions), typeof(IList), typeof(NumericPropertySelectorControl), new PropertyMetadata(new List(new[] { 0d, 1d, 2d, 3d, 4d, 5d }))); + // Default null — reference-type DP defaults are shared across all instances. + public static readonly DependencyProperty NumericOptionsProperty = DependencyProperty.Register(nameof(NumericOptions), typeof(IList), typeof(NumericPropertySelectorControl), new PropertyMetadata(null)); /// /// gets/sets the list of numeric options available for selection. /// diff --git a/src/GenericControls/Properties Controls/NumericSliderPropertyControl.xaml b/src/GenericControls/Properties Controls/NumericSliderPropertyControl.xaml index 5a7809eb..914dec72 100644 --- a/src/GenericControls/Properties Controls/NumericSliderPropertyControl.xaml +++ b/src/GenericControls/Properties Controls/NumericSliderPropertyControl.xaml @@ -1,10 +1,11 @@  @@ -90,7 +91,7 @@ x:Name="NumericTBox" Height="22" IsEnabled="{Binding IsTextBoxEnabled, ElementName=NumericWithSlider, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" - Text="{Binding Number, ElementName=NumericWithSlider, UpdateSourceTrigger=LostFocus, Mode=TwoWay, StringFormat='G'}" + Text="{Binding Number, ElementName=NumericWithSlider, UpdateSourceTrigger=LostFocus, Mode=TwoWay, StringFormat='G', ConverterCulture={x:Static glob:CultureInfo.CurrentCulture}}" SizeChanged="ControlSizeChanged" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" diff --git a/src/GenericControls/Properties Controls/NumericSliderPropertyControl.xaml.cs b/src/GenericControls/Properties Controls/NumericSliderPropertyControl.xaml.cs index f1814a58..e49e78e0 100644 --- a/src/GenericControls/Properties Controls/NumericSliderPropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/NumericSliderPropertyControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Data; diff --git a/src/GenericControls/Properties Controls/Point3DPropertyControl.xaml.cs b/src/GenericControls/Properties Controls/Point3DPropertyControl.xaml.cs index 21f6e78b..563b61ec 100644 --- a/src/GenericControls/Properties Controls/Point3DPropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/Point3DPropertyControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Properties Controls/PointPropertyControl.xaml.cs b/src/GenericControls/Properties Controls/PointPropertyControl.xaml.cs index b6d6fb12..a7e3c915 100644 --- a/src/GenericControls/Properties Controls/PointPropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/PointPropertyControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Properties Controls/PropertyDefaults.cs b/src/GenericControls/Properties Controls/PropertyDefaults.cs index a509f2a8..42d306d8 100644 --- a/src/GenericControls/Properties Controls/PropertyDefaults.cs +++ b/src/GenericControls/Properties Controls/PropertyDefaults.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; namespace GenericControls { diff --git a/src/GenericControls/Properties Controls/ResizeableTextPropertyControl.xaml.cs b/src/GenericControls/Properties Controls/ResizeableTextPropertyControl.xaml.cs index d4446dd8..01c2ce88 100644 --- a/src/GenericControls/Properties Controls/ResizeableTextPropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/ResizeableTextPropertyControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Properties Controls/StringListPropertyControl.xaml.cs b/src/GenericControls/Properties Controls/StringListPropertyControl.xaml.cs index b8187e29..9f3d4ae8 100644 --- a/src/GenericControls/Properties Controls/StringListPropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/StringListPropertyControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections; using System.Windows; using System.Windows.Controls; @@ -59,12 +29,17 @@ public partial class StringListPropertyControl:UserControl public StringListPropertyControl() { InitializeComponent(); + if (StringList == null) + { + StringList = new List(); + } } /// /// Backing dependency property for . /// - public static readonly DependencyProperty StringListProperty = DependencyProperty.Register(nameof(StringList), typeof(IList), typeof(StringListPropertyControl), new PropertyMetadata(new List(), StringListPropertyChanged_Callback)); + // Default null — reference-type DP defaults are shared across all instances. + public static readonly DependencyProperty StringListProperty = DependencyProperty.Register(nameof(StringList), typeof(IList), typeof(StringListPropertyControl), new PropertyMetadata(null, StringListPropertyChanged_Callback)); /// /// Gets/sets the list of strings displayed in the control. /// diff --git a/src/GenericControls/Properties Controls/TextPropertyControl.xaml.cs b/src/GenericControls/Properties Controls/TextPropertyControl.xaml.cs index 3766ae03..e1af65b3 100644 --- a/src/GenericControls/Properties Controls/TextPropertyControl.xaml.cs +++ b/src/GenericControls/Properties Controls/TextPropertyControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Properties Controls/VerticalAlignmentControl.xaml.cs b/src/GenericControls/Properties Controls/VerticalAlignmentControl.xaml.cs index c4222924..5e91a995 100644 --- a/src/GenericControls/Properties Controls/VerticalAlignmentControl.xaml.cs +++ b/src/GenericControls/Properties Controls/VerticalAlignmentControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using System.Linq; using System.Windows; diff --git a/src/GenericControls/Property Attributes/PropertyAttributes.xaml.cs b/src/GenericControls/Property Attributes/PropertyAttributes.xaml.cs index 29b8a599..d99df859 100644 --- a/src/GenericControls/Property Attributes/PropertyAttributes.xaml.cs +++ b/src/GenericControls/Property Attributes/PropertyAttributes.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Windows.Controls; namespace GenericControls diff --git a/src/GenericControls/Utilities/ComboBoxItemTemplateSelector.cs b/src/GenericControls/Utilities/ComboBoxItemTemplateSelector.cs index 5ef03d70..e63b66b0 100644 --- a/src/GenericControls/Utilities/ComboBoxItemTemplateSelector.cs +++ b/src/GenericControls/Utilities/ComboBoxItemTemplateSelector.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; using System.Windows.Media; diff --git a/src/GenericControls/Utilities/Converters.cs b/src/GenericControls/Utilities/Converters.cs index 9df8b152..b844b38f 100644 --- a/src/GenericControls/Utilities/Converters.cs +++ b/src/GenericControls/Utilities/Converters.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using System.Windows.Controls; @@ -1183,7 +1153,10 @@ public object Convert(object value, Type targetType, object parameter, CultureIn if (value == null) return null; double stringDouble; - double.TryParse(value.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out stringDouble); + // Honor the supplied IValueConverter culture (defaults to the binding's CurrentCulture) + // so that "1,5" parses correctly under de-DE while "1.5" still works under en-US, instead + // of locking to InvariantCulture which silently breaks comma-decimal locales. + double.TryParse(value.ToString(), NumberStyles.Any, culture ?? CultureInfo.InvariantCulture, out stringDouble); return stringDouble; } @@ -1249,7 +1222,10 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu if (value == null) return null; double stringDouble; - double.TryParse(value.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out stringDouble); + // Honor the supplied IValueConverter culture (defaults to the binding's CurrentCulture) + // so that "1,5" parses correctly under de-DE while "1.5" still works under en-US, instead + // of locking to InvariantCulture which silently breaks comma-decimal locales. + double.TryParse(value.ToString(), NumberStyles.Any, culture ?? CultureInfo.InvariantCulture, out stringDouble); return stringDouble; } } @@ -1661,15 +1637,15 @@ public object Convert(object value, Type targetType, object parameter, CultureIn if (value.GetType() != typeof(string)) return "N/A"; string val = (string)value; - // + // double doubleVal; - if (!double.TryParse(val, out doubleVal)) + if (!double.TryParse(val, NumberStyles.Any, culture, out doubleVal)) return "N/A"; if (double.IsNaN(doubleVal)) return "N/A"; if (double.IsInfinity(doubleVal)) return "N/A"; - // + // return val; } diff --git a/src/GenericControls/Utilities/GeneralMethods.cs b/src/GenericControls/Utilities/GeneralMethods.cs index 4c1de803..5dd212e3 100644 --- a/src/GenericControls/Utilities/GeneralMethods.cs +++ b/src/GenericControls/Utilities/GeneralMethods.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Diagnostics; +using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Windows; diff --git a/src/GenericControls/Utilities/NumberFormatHelper.cs b/src/GenericControls/Utilities/NumberFormatHelper.cs index bf0745e3..9a4f8178 100644 --- a/src/GenericControls/Utilities/NumberFormatHelper.cs +++ b/src/GenericControls/Utilities/NumberFormatHelper.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; diff --git a/src/GenericControls/Utilities/ValidationRules.cs b/src/GenericControls/Utilities/ValidationRules.cs index ad2a90e1..ea092f0a 100644 --- a/src/GenericControls/Utilities/ValidationRules.cs +++ b/src/GenericControls/Utilities/ValidationRules.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using System.Windows.Controls; diff --git a/src/GenericControls/Windows/MessageBox.cs b/src/GenericControls/Windows/MessageBox.cs index bb22a532..82c69a87 100644 --- a/src/GenericControls/Windows/MessageBox.cs +++ b/src/GenericControls/Windows/MessageBox.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; diff --git a/src/GenericControls/Windows/MessageBoxWindow.xaml.cs b/src/GenericControls/Windows/MessageBoxWindow.xaml.cs index 016fa99e..4da4acaf 100644 --- a/src/GenericControls/Windows/MessageBoxWindow.xaml.cs +++ b/src/GenericControls/Windows/MessageBoxWindow.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; using System.Windows.Input; diff --git a/src/GenericControls/Windows/MetroDialogWindow.cs b/src/GenericControls/Windows/MetroDialogWindow.cs index b9d6c81b..cb0ecd12 100644 --- a/src/GenericControls/Windows/MetroDialogWindow.cs +++ b/src/GenericControls/Windows/MetroDialogWindow.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Input; diff --git a/src/GenericControls/Windows/MetroWindow.cs b/src/GenericControls/Windows/MetroWindow.cs index eb236373..5dde67a4 100644 --- a/src/GenericControls/Windows/MetroWindow.cs +++ b/src/GenericControls/Windows/MetroWindow.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Input; diff --git a/src/GenericControls/Windows/NameDialog.xaml.cs b/src/GenericControls/Windows/NameDialog.xaml.cs index f1ad88c1..9e6fbb1e 100644 --- a/src/GenericControls/Windows/NameDialog.xaml.cs +++ b/src/GenericControls/Windows/NameDialog.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; namespace GenericControls diff --git a/src/NumericControls.Demo/App.xaml.cs b/src/NumericControls.Demo/App.xaml.cs index 33e2ab67..c932b5a4 100644 --- a/src/NumericControls.Demo/App.xaml.cs +++ b/src/NumericControls.Demo/App.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using Themes; namespace NumericControls.Demo diff --git a/src/NumericControls.Demo/MainWindow.xaml.cs b/src/NumericControls.Demo/MainWindow.xaml.cs index d3d68602..9181e47b 100644 --- a/src/NumericControls.Demo/MainWindow.xaml.cs +++ b/src/NumericControls.Demo/MainWindow.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.ComponentModel; +using System.ComponentModel; using System.Windows; using System.Windows.Controls; using GenericControls; diff --git a/src/NumericControls.Demo/NumericControls.Demo.csproj b/src/NumericControls.Demo/NumericControls.Demo.csproj index 54a50018..f623b5f5 100644 --- a/src/NumericControls.Demo/NumericControls.Demo.csproj +++ b/src/NumericControls.Demo/NumericControls.Demo.csproj @@ -19,9 +19,7 @@ - - ..\..\..\numerics\Numerics\bin\$(Configuration)\net10.0\Numerics.dll - + diff --git a/src/NumericControls.Demo/Properties/Resources.Designer.cs b/src/NumericControls.Demo/Properties/Resources.Designer.cs index 311d01ce..485de181 100644 --- a/src/NumericControls.Demo/Properties/Resources.Designer.cs +++ b/src/NumericControls.Demo/Properties/Resources.Designer.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 diff --git a/src/NumericControls.Demo/Properties/Settings.Designer.cs b/src/NumericControls.Demo/Properties/Settings.Designer.cs index 30add42b..32793674 100644 --- a/src/NumericControls.Demo/Properties/Settings.Designer.cs +++ b/src/NumericControls.Demo/Properties/Settings.Designer.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 diff --git a/src/NumericControls/Data/Ordered Curve Editor/OrderedDataSelectorControl.xaml.cs b/src/NumericControls/Data/Ordered Curve Editor/OrderedDataSelectorControl.xaml.cs index 93f4f309..23fafe29 100644 --- a/src/NumericControls/Data/Ordered Curve Editor/OrderedDataSelectorControl.xaml.cs +++ b/src/NumericControls/Data/Ordered Curve Editor/OrderedDataSelectorControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.ObjectModel; using System.ComponentModel; using System.Windows; diff --git a/src/NumericControls/Data/Ordered Curve Editor/OrderedDataTableEditor.xaml.cs b/src/NumericControls/Data/Ordered Curve Editor/OrderedDataTableEditor.xaml.cs index b1ee25a3..b3f6e66d 100644 --- a/src/NumericControls/Data/Ordered Curve Editor/OrderedDataTableEditor.xaml.cs +++ b/src/NumericControls/Data/Ordered Curve Editor/OrderedDataTableEditor.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.ObjectModel; using System.ComponentModel; using System.Windows; @@ -60,12 +30,20 @@ public partial class OrderedDataTableEditor : UserControl public OrderedDataTableEditor() { InitializeComponent(); + // Per-instance OrderedData (DP default is null — see DP registration). + if (OrderedData == null) + { + OrderedData = new OrderedPairedData(false, SortOrder.Ascending, false, SortOrder.Ascending); + } } /// /// Dependency property for the OrderedData property. /// - public static readonly DependencyProperty OrderedDataProperty = DependencyProperty.Register(nameof(OrderedData), typeof(OrderedPairedData), typeof(OrderedDataTableEditor), new PropertyMetadata(new OrderedPairedData(false, SortOrder.Ascending, false, SortOrder.Ascending), SetData)); + // Default null — every reference-type DP default is a SHARED instance across + // all OrderedDataTableEditor instances; two unbound editors would mutate one + // another's data. Per-instance initialization in the constructor. + public static readonly DependencyProperty OrderedDataProperty = DependencyProperty.Register(nameof(OrderedData), typeof(OrderedPairedData), typeof(OrderedDataTableEditor), new PropertyMetadata(null, SetData)); /// /// Handles changes to the OrderedData property and updates the data grid. @@ -90,9 +68,13 @@ private static void SetData(DependencyObject d, DependencyPropertyChangedEventAr } thisControl.CurveRows.Clear(); OrdinateRowItem rowItem; + int index = 0; foreach (Ordinate o in newCurve) { - rowItem = new OrdinateRowItem(o.X, o.Y, thisControl.XColumnHeader, thisControl.YColumnHeader, thisControl.CurveRows, thisControl.MinimumX, thisControl.MaximumX, thisControl.MinimumY, thisControl.MaximumY, newCurve.StrictX, newCurve.StrictY, newCurve.OrderX, newCurve.OrderY); + rowItem = new OrdinateRowItem(o.X, o.Y, thisControl.XColumnHeader, thisControl.YColumnHeader, thisControl.CurveRows, thisControl.MinimumX, thisControl.MaximumX, thisControl.MinimumY, thisControl.MaximumY, newCurve.StrictX, newCurve.StrictY, newCurve.OrderX, newCurve.OrderY) + { + Index = index++ + }; rowItem.PropertyChanged += thisControl.RowItemPropertyChanged; thisControl.CurveRows.Add(rowItem); } @@ -106,7 +88,10 @@ private static void SetData(DependencyObject d, DependencyPropertyChangedEventAr private void RowItemPropertyChanged(object sender, PropertyChangedEventArgs e) { OrdinateRowItem rItem = (OrdinateRowItem)sender; - int dataIndex = CurveRows.IndexOf(rItem); + // Use the cached positional index instead of CurveRows.IndexOf which is O(n) and + // value-equality based. With duplicate (X, Y) pairs IndexOf would target the wrong row. + int dataIndex = rItem.Index; + if (dataIndex < 0 || dataIndex >= OrderedData.Count) return; OrderedData[dataIndex] = rItem.GetOrdinate(); } diff --git a/src/NumericControls/Data/Ordered Curve Editor/OrdinateRowItem.cs b/src/NumericControls/Data/Ordered Curve Editor/OrdinateRowItem.cs index f48befaa..24ca92ea 100644 --- a/src/NumericControls/Data/Ordered Curve Editor/OrdinateRowItem.cs +++ b/src/NumericControls/Data/Ordered Curve Editor/OrdinateRowItem.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.ObjectModel; using GenericControls; using Numerics.Data; @@ -63,6 +33,16 @@ public class OrdinateRowItem : DataGridRowItem private double _x; private double _y; + /// + /// The positional index of this ordinate within the parent CurveRows collection. + /// Cached for O(1) lookup in RowItemPropertyChanged instead of an + /// ObservableCollection.IndexOf call (which is O(n) and uses value equality — + /// duplicate (X, Y) pairs would resolve to the wrong row). Mirrors the same pattern + /// in . Updated by OrderedDataTableEditor after + /// each rebuild of the row collection. + /// + public int Index { get; set; } = -1; + /// /// Gets or sets the maximum allowed X value. /// diff --git a/src/NumericControls/Data/Probability Ordinates/ProbabilityOrdinateRowItem.cs b/src/NumericControls/Data/Probability Ordinates/ProbabilityOrdinateRowItem.cs index 7f9e7e41..a051c918 100644 --- a/src/NumericControls/Data/Probability Ordinates/ProbabilityOrdinateRowItem.cs +++ b/src/NumericControls/Data/Probability Ordinates/ProbabilityOrdinateRowItem.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using GenericControls; +using GenericControls; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/src/NumericControls/Data/Probability Ordinates/ProbabilityOrdinatesControl.xaml.cs b/src/NumericControls/Data/Probability Ordinates/ProbabilityOrdinatesControl.xaml.cs index 27dbf872..d7c24561 100644 --- a/src/NumericControls/Data/Probability Ordinates/ProbabilityOrdinatesControl.xaml.cs +++ b/src/NumericControls/Data/Probability Ordinates/ProbabilityOrdinatesControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using Numerics.Data; +using Numerics.Data; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/src/NumericControls/Data/Time Series Editor/MathEditorControl.xaml.cs b/src/NumericControls/Data/Time Series Editor/MathEditorControl.xaml.cs index 21b40b61..6bac781b 100644 --- a/src/NumericControls/Data/Time Series Editor/MathEditorControl.xaml.cs +++ b/src/NumericControls/Data/Time Series Editor/MathEditorControl.xaml.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ? Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ? Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ? The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using GenericControls; using Numerics.Data; using System.Globalization; diff --git a/src/NumericControls/Data/Time Series Editor/NumericEntryDialog.xaml.cs b/src/NumericControls/Data/Time Series Editor/NumericEntryDialog.xaml.cs index c4f97c04..c43e48c5 100644 --- a/src/NumericControls/Data/Time Series Editor/NumericEntryDialog.xaml.cs +++ b/src/NumericControls/Data/Time Series Editor/NumericEntryDialog.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows; +using System.Windows; using GenericControls; namespace NumericControls diff --git a/src/NumericControls/Data/Time Series Editor/TimeSeriesRowItem.cs b/src/NumericControls/Data/Time Series Editor/TimeSeriesRowItem.cs index 1d0ae7e4..b29e051f 100644 --- a/src/NumericControls/Data/Time Series Editor/TimeSeriesRowItem.cs +++ b/src/NumericControls/Data/Time Series Editor/TimeSeriesRowItem.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using GenericControls; +using GenericControls; using Numerics.Data; using System.Collections.ObjectModel; diff --git a/src/NumericControls/Data/Time Series Editor/TimeSeriesTable.xaml.cs b/src/NumericControls/Data/Time Series Editor/TimeSeriesTable.xaml.cs index 6cb2946a..41ab8734 100644 --- a/src/NumericControls/Data/Time Series Editor/TimeSeriesTable.xaml.cs +++ b/src/NumericControls/Data/Time Series Editor/TimeSeriesTable.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using GenericControls; +using GenericControls; using Numerics.Data; using System.Collections.ObjectModel; using System.Collections.Specialized; @@ -156,7 +126,11 @@ private void Series_CollectionChanged(object sender, NotifyCollectionChangedEven /// /// Identifies the dependency property. /// - public static readonly DependencyProperty SeriesProperty = DependencyProperty.Register(nameof(Series), typeof(TimeSeries), typeof(TimeSeriesTable), new PropertyMetadata(new TimeSeries(), SetData)); + // Default is null (not `new TimeSeries()`) — every reference-type DP default is + // a SHARED instance across all TimeSeriesTable instances; two unbound editors + // would mutate one another's data. Per-instance initialization happens in the + // constructor. + public static readonly DependencyProperty SeriesProperty = DependencyProperty.Register(nameof(Series), typeof(TimeSeries), typeof(TimeSeriesTable), new PropertyMetadata(null, SetData)); /// /// Handles changes to the Series property and configures the grid for the time interval type. @@ -321,6 +295,23 @@ public string YColumnHeader public TimeSeriesTable() { InitializeComponent(); + // Per-instance initialization (the SeriesProperty default is now null to + // avoid sharing one TimeSeries instance across every unbound editor). + if (Series == null) + { + Series = new TimeSeries(); + } + // When the control is unloaded (e.g. window closing or tab removed), unsubscribe from + // the live TimeSeries so a long-lived data model does not pin this control in memory. + // SeriesProperty resubscribes its CollectionChanged handler whenever Series changes. + Unloaded += (s, e) => + { + if (_previousSeries != null) + { + _previousSeries.CollectionChanged -= Series_CollectionChanged; + _previousSeries = null; + } + }; TimeSeriesDataGrid.RowType = typeof(SeriesOrdinate); TimeSeriesDataGrid.PasteAddsRows = true; TimeSeriesDataGrid.ItemsSource = _rowItems; diff --git a/src/NumericControls/Data/Uncertain Curve Editor/DistributionDataItem.cs b/src/NumericControls/Data/Uncertain Curve Editor/DistributionDataItem.cs index a0aaf910..fad0edf2 100644 --- a/src/NumericControls/Data/Uncertain Curve Editor/DistributionDataItem.cs +++ b/src/NumericControls/Data/Uncertain Curve Editor/DistributionDataItem.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using Numerics.Data; diff --git a/src/NumericControls/Data/Uncertain Curve Editor/DistributionRowItem.cs b/src/NumericControls/Data/Uncertain Curve Editor/DistributionRowItem.cs index f9d38162..0340adc6 100644 --- a/src/NumericControls/Data/Uncertain Curve Editor/DistributionRowItem.cs +++ b/src/NumericControls/Data/Uncertain Curve Editor/DistributionRowItem.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using GenericControls; using Numerics; using Numerics.Data; diff --git a/src/NumericControls/Data/Uncertain Curve Editor/UncertainOrderedDataSelectorControl.xaml.cs b/src/NumericControls/Data/Uncertain Curve Editor/UncertainOrderedDataSelectorControl.xaml.cs index 706937aa..8aa6053e 100644 --- a/src/NumericControls/Data/Uncertain Curve Editor/UncertainOrderedDataSelectorControl.xaml.cs +++ b/src/NumericControls/Data/Uncertain Curve Editor/UncertainOrderedDataSelectorControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using Numerics.Data; +using Numerics.Data; using Numerics.Distributions; using OxyPlot; using OxyPlot.Legends; diff --git a/src/NumericControls/Data/Uncertain Curve Editor/UncertainOrderedDataTableEditor.xaml.cs b/src/NumericControls/Data/Uncertain Curve Editor/UncertainOrderedDataTableEditor.xaml.cs index b818666c..935ffede 100644 --- a/src/NumericControls/Data/Uncertain Curve Editor/UncertainOrderedDataTableEditor.xaml.cs +++ b/src/NumericControls/Data/Uncertain Curve Editor/UncertainOrderedDataTableEditor.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using Numerics.Data; +using Numerics.Data; using Numerics.Distributions; using System.Collections.ObjectModel; using System.Globalization; diff --git a/src/NumericControls/Data/Uncertain Curve Editor/UncertainOrderedTableEditor.xaml.cs b/src/NumericControls/Data/Uncertain Curve Editor/UncertainOrderedTableEditor.xaml.cs index a68eaf00..127f6329 100644 --- a/src/NumericControls/Data/Uncertain Curve Editor/UncertainOrderedTableEditor.xaml.cs +++ b/src/NumericControls/Data/Uncertain Curve Editor/UncertainOrderedTableEditor.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using Numerics.Data; +using Numerics.Data; using Numerics.Distributions; using System.Collections.ObjectModel; using System.Collections.Specialized; diff --git a/src/NumericControls/Data/Uncertain Curve Editor/UncertainTableEditor.xaml.cs b/src/NumericControls/Data/Uncertain Curve Editor/UncertainTableEditor.xaml.cs index b5490599..e65ad174 100644 --- a/src/NumericControls/Data/Uncertain Curve Editor/UncertainTableEditor.xaml.cs +++ b/src/NumericControls/Data/Uncertain Curve Editor/UncertainTableEditor.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using Numerics.Data; +using Numerics.Data; using System.Collections.ObjectModel; using System.Windows; using System.Windows.Controls; diff --git a/src/NumericControls/Distributions/Multivariate/BivariateEmpirical.cs b/src/NumericControls/Distributions/Multivariate/BivariateEmpirical.cs index ee1da30e..17c77431 100644 --- a/src/NumericControls/Distributions/Multivariate/BivariateEmpirical.cs +++ b/src/NumericControls/Distributions/Multivariate/BivariateEmpirical.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.ComponentModel; namespace NumericControls.Distributions.Multivariate diff --git a/src/NumericControls/Distributions/Multivariate/BivariateEmpiricalControl.xaml.cs b/src/NumericControls/Distributions/Multivariate/BivariateEmpiricalControl.xaml.cs index 7745c8f5..30fe473c 100644 --- a/src/NumericControls/Distributions/Multivariate/BivariateEmpiricalControl.xaml.cs +++ b/src/NumericControls/Distributions/Multivariate/BivariateEmpiricalControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Data; +using System.Data; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; diff --git a/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/UnivariateDistributionValidatingRow.cs b/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/UnivariateDistributionValidatingRow.cs index 584c2dd0..d24d1825 100644 --- a/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/UnivariateDistributionValidatingRow.cs +++ b/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/UnivariateDistributionValidatingRow.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using GenericControls; namespace NumericControls diff --git a/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/UnivariateXPControl.xaml.cs b/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/UnivariateXPControl.xaml.cs index 37e1c72e..4b7d382e 100644 --- a/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/UnivariateXPControl.xaml.cs +++ b/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/UnivariateXPControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using Numerics.Distributions; +using Numerics.Distributions; using System.Collections.ObjectModel; using System.Windows; using System.Windows.Controls; diff --git a/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/XYDataGridControl.xaml.cs b/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/XYDataGridControl.xaml.cs index 7d9b3872..f2e5088e 100644 --- a/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/XYDataGridControl.xaml.cs +++ b/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/XYDataGridControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Windows.Controls; diff --git a/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/XYZDataGridControl.xaml.cs b/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/XYZDataGridControl.xaml.cs index 4d56061e..3f5c8464 100644 --- a/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/XYZDataGridControl.xaml.cs +++ b/src/NumericControls/Distributions/Univariate/Distribution Selector/Data Grid Popups/XYZDataGridControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System.Windows.Controls; +using System.Windows.Controls; namespace NumericControls { diff --git a/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorControl.xaml b/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorControl.xaml index a6e1e5d0..a471e601 100644 --- a/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorControl.xaml +++ b/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorControl.xaml @@ -7,7 +7,8 @@ xmlns:cntrls="clr-namespace:GenericControls;assembly=GenericControls" xmlns:oxy="http://oxyplot.org/wpf" xmlns:sys="clr-namespace:System;assembly=mscorlib" - mc:Ignorable="d" + xmlns:glob="clr-namespace:System.Globalization;assembly=mscorlib" + mc:Ignorable="d" d:DesignHeight="382" d:DesignWidth="300" MinWidth="200"> @@ -162,7 +163,7 @@ - diff --git a/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorControl.xaml.cs b/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorControl.xaml.cs index 63208244..e05f13c0 100644 --- a/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorControl.xaml.cs +++ b/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#nullable enable +#nullable enable using GenericControls; using Numerics.Data.Statistics; using Numerics.Distributions; diff --git a/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorPopup.xaml.cs b/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorPopup.xaml.cs index 51004884..ce95c855 100644 --- a/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorPopup.xaml.cs +++ b/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorPopup.xaml.cs @@ -1,34 +1,5 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using Numerics.Distributions; +using Numerics.Distributions; +using System.Globalization; using System.Text; using System.Windows; using System.Windows.Controls; @@ -61,11 +32,18 @@ public partial class DistributionSelectorPopup : UserControl public DistributionSelectorPopup() { InitializeComponent(); + // Per-instance default (DP default is null — see DP registration). + if (SelectedDistribution == null) + { + SelectedDistribution = new Normal(); + } } /// /// Dependency property for the selected distribution. /// - public static readonly DependencyProperty SelectedDistributionProperty = DependencyProperty.Register(nameof(SelectedDistribution), typeof(UnivariateDistributionBase), typeof(DistributionSelectorPopup), new PropertyMetadata(new Normal(), SetDistribution)); + // Default null — reference-type DP defaults are shared across all instances. + // Per-instance initialization in the constructor. + public static readonly DependencyProperty SelectedDistributionProperty = DependencyProperty.Register(nameof(SelectedDistribution), typeof(UnivariateDistributionBase), typeof(DistributionSelectorPopup), new PropertyMetadata(null, SetDistribution)); /// /// Get and set the selected probability distribution. /// @@ -168,7 +146,7 @@ private static void SetDistribution(DependencyObject d, DependencyPropertyChange { sb.Append(shortNames[i]); sb.Append("="); - sb.Append(string.Format("{0:0.#####}", paramVals[i])); + sb.Append(string.Format(CultureInfo.CurrentCulture, "{0:0.#####}", paramVals[i])); if (i != shortNames.Count() - 1) sb.Append(", "); } diff --git a/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionWithSelectorControl.xaml.cs b/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionWithSelectorControl.xaml.cs index 5187ebdc..0dab4420 100644 --- a/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionWithSelectorControl.xaml.cs +++ b/src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionWithSelectorControl.xaml.cs @@ -1,34 +1,5 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using Numerics.Distributions; +using Numerics.Distributions; +using System.Globalization; using System.Text; using System.Windows; using System.Windows.Controls; @@ -153,7 +124,7 @@ private static void SetDistribution(DependencyObject d, DependencyPropertyChange { sb.Append(shortNames[i]); sb.Append("="); - sb.Append(string.Format("{0:0.#####}", paramVals[i])); + sb.Append(string.Format(CultureInfo.CurrentCulture, "{0:0.#####}", paramVals[i])); if (i != shortNames.Count() - 1) sb.Append(", "); } diff --git a/src/NumericControls/Distributions/Univariate/Distribution Selector/Parameter.cs b/src/NumericControls/Distributions/Univariate/Distribution Selector/Parameter.cs index 7471db12..80a2fcfa 100644 --- a/src/NumericControls/Distributions/Univariate/Distribution Selector/Parameter.cs +++ b/src/NumericControls/Distributions/Univariate/Distribution Selector/Parameter.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; diff --git a/src/NumericControls/Distributions/Univariate/Distribution Selector/Selector.xaml b/src/NumericControls/Distributions/Univariate/Distribution Selector/Selector.xaml index aceb8fd9..27263b1d 100644 --- a/src/NumericControls/Distributions/Univariate/Distribution Selector/Selector.xaml +++ b/src/NumericControls/Distributions/Univariate/Distribution Selector/Selector.xaml @@ -7,7 +7,8 @@ xmlns:cntrls="clr-namespace:GenericControls;assembly=GenericControls" xmlns:oxy="http://oxyplot.org/wpf" xmlns:sys="clr-namespace:System;assembly=mscorlib" - mc:Ignorable="d" + xmlns:glob="clr-namespace:System.Globalization;assembly=mscorlib" + mc:Ignorable="d" d:DesignHeight="382" d:DesignWidth="300" MinWidth="200"> @@ -419,7 +420,7 @@ - diff --git a/src/NumericControls/Distributions/Univariate/Distribution Selector/Selector.xaml.cs b/src/NumericControls/Distributions/Univariate/Distribution Selector/Selector.xaml.cs index 52d52f16..02d4b604 100644 --- a/src/NumericControls/Distributions/Univariate/Distribution Selector/Selector.xaml.cs +++ b/src/NumericControls/Distributions/Univariate/Distribution Selector/Selector.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#nullable enable +#nullable enable using GenericControls; using Numerics.Data.Statistics; using Numerics.Distributions; @@ -465,18 +435,18 @@ private void UpdateHistogram() var stats = Numerics.Data.Statistics.Statistics.ProductMoments(SampleData); var mode = histogram.Mode; - SummaryStatisticsList[0].DataStat = summaryPercentiles[0].ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[1].DataStat = summaryPercentiles[6].ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[2].DataStat = stats[0].ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[3].DataStat = mode.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[4].DataStat = stats[1].ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[5].DataStat = stats[2].ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[6].DataStat = stats[3].ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[7].DataStat = summaryPercentiles[1].ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[8].DataStat = summaryPercentiles[2].ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[9].DataStat = summaryPercentiles[3].ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[10].DataStat = summaryPercentiles[4].ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[11].DataStat = summaryPercentiles[5].ToString("N4", CultureInfo.InvariantCulture); + SummaryStatisticsList[0].DataStat = summaryPercentiles[0].ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[1].DataStat = summaryPercentiles[6].ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[2].DataStat = stats[0].ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[3].DataStat = mode.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[4].DataStat = stats[1].ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[5].DataStat = stats[2].ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[6].DataStat = stats[3].ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[7].DataStat = summaryPercentiles[1].ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[8].DataStat = summaryPercentiles[2].ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[9].DataStat = summaryPercentiles[3].ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[10].DataStat = summaryPercentiles[4].ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[11].DataStat = summaryPercentiles[5].ToString("N4", CultureInfo.CurrentCulture); SummaryTable.Items.Refresh(); @@ -745,34 +715,34 @@ private void UpdateDistributionStats() // Distribution if ((SelectedDistribution is null) || (SelectedDistribution.ParametersValid == false)) { - SummaryStatisticsList[0].DistStat = double.NaN.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[1].DistStat = double.NaN.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[2].DistStat = double.NaN.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[3].DistStat = double.NaN.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[4].DistStat = double.NaN.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[5].DistStat = double.NaN.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[6].DistStat = double.NaN.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[7].DistStat = double.NaN.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[8].DistStat = double.NaN.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[9].DistStat = double.NaN.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[10].DistStat = double.NaN.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[11].DistStat = double.NaN.ToString("N4", CultureInfo.InvariantCulture); + SummaryStatisticsList[0].DistStat = double.NaN.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[1].DistStat = double.NaN.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[2].DistStat = double.NaN.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[3].DistStat = double.NaN.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[4].DistStat = double.NaN.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[5].DistStat = double.NaN.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[6].DistStat = double.NaN.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[7].DistStat = double.NaN.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[8].DistStat = double.NaN.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[9].DistStat = double.NaN.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[10].DistStat = double.NaN.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[11].DistStat = double.NaN.ToString("N4", CultureInfo.CurrentCulture); SummaryTable.Items.Refresh(); } else { - SummaryStatisticsList[0].DistStat = SelectedDistribution.Minimum.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[1].DistStat = SelectedDistribution.Maximum.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[2].DistStat = SelectedDistribution.Mean.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[3].DistStat = SelectedDistribution.Mode.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[4].DistStat = SelectedDistribution.StandardDeviation.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[5].DistStat = SelectedDistribution.Skewness.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[6].DistStat = SelectedDistribution.Kurtosis.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[7].DistStat = SelectedDistribution.InverseCDF(0.05d).ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[8].DistStat = SelectedDistribution.InverseCDF(0.25d).ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[9].DistStat = SelectedDistribution.InverseCDF(0.5d).ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[10].DistStat = SelectedDistribution.InverseCDF(0.75d).ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[11].DistStat = SelectedDistribution.InverseCDF(0.95d).ToString("N4", CultureInfo.InvariantCulture); + SummaryStatisticsList[0].DistStat = SelectedDistribution.Minimum.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[1].DistStat = SelectedDistribution.Maximum.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[2].DistStat = SelectedDistribution.Mean.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[3].DistStat = SelectedDistribution.Mode.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[4].DistStat = SelectedDistribution.StandardDeviation.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[5].DistStat = SelectedDistribution.Skewness.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[6].DistStat = SelectedDistribution.Kurtosis.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[7].DistStat = SelectedDistribution.InverseCDF(0.05d).ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[8].DistStat = SelectedDistribution.InverseCDF(0.25d).ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[9].DistStat = SelectedDistribution.InverseCDF(0.5d).ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[10].DistStat = SelectedDistribution.InverseCDF(0.75d).ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[11].DistStat = SelectedDistribution.InverseCDF(0.95d).ToString("N4", CultureInfo.CurrentCulture); // Add Goodness of fit stats. Only populate indices 12-14 when the list was // built with all 15 rows. Selector initializes 12 rows; the three GoF rows @@ -788,9 +758,9 @@ private void UpdateDistributionStats() var chi = GoodnessOfFit.ChiSquared(data, SelectedDistribution); var ks = GoodnessOfFit.KolmogorovSmirnov(data, SelectedDistribution); - SummaryStatisticsList[12].DistStat = rmse.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[13].DistStat = chi.ToString("N4", CultureInfo.InvariantCulture); - SummaryStatisticsList[14].DistStat = ks.ToString("N4", CultureInfo.InvariantCulture); + SummaryStatisticsList[12].DistStat = rmse.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[13].DistStat = chi.ToString("N4", CultureInfo.CurrentCulture); + SummaryStatisticsList[14].DistStat = ks.ToString("N4", CultureInfo.CurrentCulture); } diff --git a/src/NumericControls/Distributions/Univariate/Distribution Selector/SummaryStatistic.cs b/src/NumericControls/Distributions/Univariate/Distribution Selector/SummaryStatistic.cs index 540274ac..7cd63cb7 100644 --- a/src/NumericControls/Distributions/Univariate/Distribution Selector/SummaryStatistic.cs +++ b/src/NumericControls/Distributions/Univariate/Distribution Selector/SummaryStatistic.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - namespace NumericControls.Distributions.Univariate { /// diff --git a/src/NumericControls/NumericControls.csproj b/src/NumericControls/NumericControls.csproj index 38076758..26fc82f4 100644 --- a/src/NumericControls/NumericControls.csproj +++ b/src/NumericControls/NumericControls.csproj @@ -24,9 +24,7 @@ - - ..\..\..\numerics\Numerics\bin\Debug\net10.0\Numerics.dll - + diff --git a/src/NumericControls/Sampling/Stratification Binning/BinDefinitionControl.xaml.cs b/src/NumericControls/Sampling/Stratification Binning/BinDefinitionControl.xaml.cs index 2896aeb1..e74997ac 100644 --- a/src/NumericControls/Sampling/Stratification Binning/BinDefinitionControl.xaml.cs +++ b/src/NumericControls/Sampling/Stratification Binning/BinDefinitionControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using Numerics.Sampling; +using Numerics.Sampling; using System.Collections.ObjectModel; using System.ComponentModel; using System.Windows; diff --git a/src/NumericControls/Sampling/Stratification Binning/StratificationOptionsRowItem.cs b/src/NumericControls/Sampling/Stratification Binning/StratificationOptionsRowItem.cs index 6a74dac0..1fb12b46 100644 --- a/src/NumericControls/Sampling/Stratification Binning/StratificationOptionsRowItem.cs +++ b/src/NumericControls/Sampling/Stratification Binning/StratificationOptionsRowItem.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.ObjectModel; using GenericControls; using Numerics.Sampling; diff --git a/src/OxyPlot/OxyPlot.Wpf.Shared/OxyPlot.Wpf.Shared.csproj b/src/OxyPlot/OxyPlot.Wpf.Shared/OxyPlot.Wpf.Shared.csproj index e5a6cf44..c69f276c 100644 --- a/src/OxyPlot/OxyPlot.Wpf.Shared/OxyPlot.Wpf.Shared.csproj +++ b/src/OxyPlot/OxyPlot.Wpf.Shared/OxyPlot.Wpf.Shared.csproj @@ -8,6 +8,7 @@ true true OxyPlot.Wpf.Shared.snk + $(NoWarn);CS0618 diff --git a/src/OxyPlot/OxyPlot.Wpf.Shared/PlotViewBase.Events.cs b/src/OxyPlot/OxyPlot.Wpf.Shared/PlotViewBase.Events.cs index a752a279..2593953d 100644 --- a/src/OxyPlot/OxyPlot.Wpf.Shared/PlotViewBase.Events.cs +++ b/src/OxyPlot/OxyPlot.Wpf.Shared/PlotViewBase.Events.cs @@ -8,6 +8,7 @@ namespace OxyPlot.Wpf { using System; using System.Windows.Input; + using System.Windows.Threading; /// /// Base class for WPF PlotView implementations. @@ -75,19 +76,113 @@ protected override void OnManipulationCompleted(ManipulationCompletedEventArgs e e.Handled = this.ActualController.HandleTouchCompleted(this, e.ToTouchEventArgs(this)); } + /// + /// Pending wheel delta accumulated since the last coalesced flush. See + /// . + /// + private int pendingWheelDelta; + + /// + /// Cached position + modifier-keys snapshot from the most recent wheel event in the + /// accumulation window. Used as the position for the synthesised coalesced wheel + /// event — taking the latest position keeps zoom-at-cursor accurate. + /// + private OxyMouseWheelEventArgs latestWheelArgs; + + /// + /// True when a coalesced-wheel flush is pending in the dispatcher queue. Subsequent + /// wheel events accumulate into instead of dispatching + /// their own work. + /// + private bool wheelFlushScheduled; + /// /// Called before the event occurs to provide handling for the event in a derived class without attaching a delegate. /// /// A that contains the event data. + /// + /// Wheel events are coalesced via : rapid wheel + /// scrolls (high-Hz mice, trackpad inertia) produce N independent events, each of which + /// would otherwise trigger a synchronous Model.Update + render-queue dispatch. + /// On a multi-LineSeries large-data plot these stack up to multi-frame latency before + /// the first paint catches up. The coalescer accumulates deltas and dispatches one + /// combined wheel event per dispatcher tick, summed at the latest pointer position. + /// protected override void OnMouseWheel(MouseWheelEventArgs e) { - base.OnMouseWheel(e); - if (e.Handled || !this.IsMouseWheelEnabled) +#if DEBUG + // Open a new wheel-event scope at the very top of the WPF event handler. Every traced + // method below this point logs against this wheel sequence number and timestamp, + // producing a single coherent block per wheel tick. + OxyPlot.PlotDiagnostics.BeginWheel(); + try + { + using (OxyPlot.PlotDiagnostics.Trace("PlotViewBase.OnMouseWheel", + $"delta={e.Delta}")) + { +#endif + base.OnMouseWheel(e); + if (e.Handled || !this.IsMouseWheelEnabled) + { + return; + } + + // Mark handled now to prevent the ScrollViewer (or any ancestor) from + // also processing this event. The actual zoom dispatch is deferred to + // the coalesced flush below. + e.Handled = true; + + // Accumulate delta and capture the latest pointer position + modifiers. + // OxyMouseWheelEventArgs is small and intentionally allocated each event + // so the snapshot reflects the wheel-tick state exactly. + this.pendingWheelDelta += e.Delta; + this.latestWheelArgs = e.ToMouseWheelEventArgs(this); + + if (!this.wheelFlushScheduled) + { + this.wheelFlushScheduled = true; + // Render priority matches the deferred-render dispatcher and lands + // before the next composition tick — so the user sees the combined + // zoom on the very next frame. + this.Dispatcher.BeginInvoke( + DispatcherPriority.Render, + new Action(this.FlushAccumulatedWheel)); + } +#if DEBUG + } + } + finally + { + // Close the wheel scope so subsequent unrelated invalidations (mouse-move, pan, + // render) don't emit trace lines attributed to this wheel sequence number. + OxyPlot.PlotDiagnostics.EndWheel(); + } +#endif + } + + /// + /// Dispatches the accumulated wheel delta as a single + /// through the controller. Resets the pending + /// state so the next wheel event starts a fresh accumulation window. + /// + private void FlushAccumulatedWheel() + { + int delta = this.pendingWheelDelta; + var args = this.latestWheelArgs; + this.pendingWheelDelta = 0; + this.latestWheelArgs = null; + this.wheelFlushScheduled = false; + + if (delta == 0 || args == null) { return; } - e.Handled = this.ActualController.HandleMouseWheel(this, e.ToMouseWheelEventArgs(this)); + // Synthesise a combined wheel event at the latest pointer position. Position + + // ModifierKeys are taken from the most recent event; Delta is the sum across + // the window so cumulative zoom matches what the user saw. + args.Delta = delta; + this.ActualController.HandleMouseWheel(this, args); } /// diff --git a/src/OxyPlot/OxyPlot.Wpf.Shared/PlotViewBase.cs b/src/OxyPlot/OxyPlot.Wpf.Shared/PlotViewBase.cs index dd5fd0e3..c85c5430 100644 --- a/src/OxyPlot/OxyPlot.Wpf.Shared/PlotViewBase.cs +++ b/src/OxyPlot/OxyPlot.Wpf.Shared/PlotViewBase.cs @@ -81,9 +81,16 @@ public abstract partial class PlotViewBase : Control, IPlotView private Canvas overlays; /// - /// The zoom control. + /// The zoom-rectangle drag overlay. Renders the zoom-rectangle affordance via a single + /// per mouse-move with no layout-pass overhead. /// - private ContentControl zoomControl; + /// + /// Replaces the historical + + /// approach (see for rationale). Sized once to the + /// full plot area and positioned at (0, 0); only its internal rectangle bounds + /// change during a drag. + /// + private ZoomRectangleAdorner zoomAdorner; /// /// True when a render has been scheduled via Dispatcher.BeginInvoke but has not yet executed. @@ -91,6 +98,152 @@ public abstract partial class PlotViewBase : Control, IPlotView /// private bool renderPending; + /// + /// Cached DPI scale. Filled lazily on first call and invalidated + /// in + . Avoids the + /// COM-boundary walk on every render — + /// which fires once per pan/zoom step at 60Hz. + /// + private double? cachedDpiScale; + + /// + /// Backing field for . + /// + private bool disableShapeAntiAliasing; + + /// + /// Gets or sets a value indicating whether shape anti-aliasing is disabled inside the + /// hosted plot presenter. Default is false (anti-aliasing on). + /// + /// + /// + /// When set to true, applies to the presenter via + /// RenderOptions.SetEdgeMode. WPF's stroke-tessellation pass for anti-aliased + /// lines is the dominant per-series cost on dense multi-series plots (e.g. 20-chain + /// MCMC traces); disabling it produces a multi-x speedup for line rendering. Markers, + /// fills, and text are unaffected. + /// + /// + /// Recommended for trace, density, and scientific plots where many line series are + /// rendered together and pixel-exact line edges are not visually critical. Leave + /// false for plots that rely on anti-aliased thick strokes or curved geometry + /// where the visual quality difference is noticeable. + /// + /// + /// Recommended pairings with : + /// + /// + /// Static plot (report view, finished chart): set both + /// =true and =true. + /// Aliasing is invisible at typical thin strokes and the bitmap cache eliminates + /// re-rasterization on overlay drags / dock splits. + /// Real-time / streaming plot (oscilloscope, live data): leave both + /// at the default false. Every frame regenerates the geometry, so neither lever + /// helps and =true would add bitmap-encode overhead. + /// Interactive zoom/pan plot on large static data (multi-LineSeries + /// trace plot): set =true and + /// =false. Aliasing accelerates the per-zoom render; + /// the bitmap cache is invalidated on every zoom/pan and offers no benefit. + /// + /// + public bool DisableShapeAntiAliasing + { + get => this.disableShapeAntiAliasing; + set + { + if (this.disableShapeAntiAliasing == value) return; + this.disableShapeAntiAliasing = value; + this.ApplyAntiAliasingPreference(); + } + } + + /// + /// Pushes the current setting onto the hosted + /// plot presenter via RenderOptions.SetEdgeMode. Called from the property setter + /// and from . Walks the presenter's Visual property + /// (if any) to also apply the mode to the underlying , + /// without requiring a type reference to the OxyPlot.Wpf-specific DrawingVisualHost + /// from this Shared assembly. + /// + private void ApplyAntiAliasingPreference() + { + if (this.plotPresenter == null) return; + var mode = this.disableShapeAntiAliasing ? EdgeMode.Aliased : EdgeMode.Unspecified; + RenderOptions.SetEdgeMode(this.plotPresenter, mode); + + // DrawingVisualHost exposes its inner DrawingVisual via a public Visual property. + // Reflect to avoid a circular reference back to OxyPlot.Wpf. + var visualProp = this.plotPresenter.GetType().GetProperty("Visual", + System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); + if (visualProp?.GetValue(this.plotPresenter) is System.Windows.Media.Visual innerVisual) + { + RenderOptions.SetEdgeMode(innerVisual, mode); + } + } + + /// + /// Backing field for . + /// + private bool useBitmapCache; + + /// + /// Gets or sets a value indicating whether the rasterized output of the plot's hosted + /// presenter is cached as a bitmap in video memory via WPF's + /// mechanism. Default false. + /// + /// + /// + /// When true, the underlying DrawingVisualHost.UseBitmapCache property is + /// enabled, which assigns a to . + /// WPF rasterizes the plot's visual subtree once into a GPU bitmap and reuses the bitmap + /// on subsequent compositor frames; the cache regenerates only when the subtree's + /// content actually changes (i.e., on each Plot.InvalidatePlot). Markers, fills, + /// and other plot elements are unaffected. + /// + /// + /// When this helps. Scenarios where the plot is static but the surface is + /// repeatedly composited — dragging a transient overlay (e.g., the magnifier-glass zoom + /// rectangle) over the plot, parent panel resize animations, dock-splitter drags, plot + /// scrolling into and out of viewport. Without the cache, WPF re-rasterizes the plot's + /// vector geometry under the dirty region on every compositor frame. + /// + /// + /// When this doesn't help. Real-time streaming plots that re-render every frame + /// see no benefit and pay a small per-render overhead. Default is off; opt in per plot. + /// + /// + /// See for the three-scenario pairing table + /// (static / real-time / interactive) that pairs both flags for best results. + /// + /// + public bool UseBitmapCache + { + get => this.useBitmapCache; + set + { + if (this.useBitmapCache == value) return; + this.useBitmapCache = value; + this.ApplyBitmapCachePreference(); + } + } + + /// + /// Pushes the current setting onto the hosted plot + /// presenter. Called from the property setter and from . + /// Reflects on a public UseBitmapCache property exposed by the presenter (the + /// OxyPlot.Wpf DrawingVisualHost) without requiring a circular reference. + /// + private void ApplyBitmapCachePreference() + { + if (this.plotPresenter == null) return; + var prop = this.plotPresenter.GetType().GetProperty("UseBitmapCache", + System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); + if (prop != null && prop.CanWrite) + { + prop.SetValue(this.plotPresenter, this.useBitmapCache); + } + } + /// /// Initializes static members of the class. /// @@ -118,6 +271,13 @@ protected PlotViewBase() private void OnPlotViewLoaded(object sender, RoutedEventArgs e) { this.LayoutUpdated += this.OnLayoutUpdated; + // Once Loaded fires we know we're in a tree (Window, Popup, ElementHost, etc.). + // OnLayoutUpdated still walks the tree for the rare popup-hosting edge case where + // Loaded can fire before the popup is fully composed. + this.isInVisualTree = true; + // DPI may have changed since the last Loaded (cross-monitor / theme reload); + // force re-fetch on next render. + this.cachedDpiScale = null; } /// @@ -126,6 +286,7 @@ private void OnPlotViewLoaded(object sender, RoutedEventArgs e) private void OnPlotViewUnloaded(object sender, RoutedEventArgs e) { this.LayoutUpdated -= this.OnLayoutUpdated; + this.isInVisualTree = false; } /// @@ -175,10 +336,7 @@ public void HideTracker() /// public void HideZoomRectangle() { - if (this.zoomControl != null) - { - this.zoomControl.Visibility = Visibility.Collapsed; - } + this.zoomAdorner?.ClearBounds(); } /// @@ -192,26 +350,135 @@ public virtual void InvalidatePlot(bool updateData = true) return; } - lock (this.ActualModel.SyncRoot) +#if DEBUG + DiagnoseInvalidatePlotCall(updateData); + using (OxyPlot.PlotDiagnostics.Trace("PlotViewBase.InvalidatePlot", $"updateData={updateData} renderPending={this.renderPending}")) { - ((IPlotModel)this.ActualModel).Update(updateData); +#endif + + lock (this.ActualModel.SyncRoot) + { + ((IPlotModel)this.ActualModel).Update(updateData); + } + + if (!this.renderPending) + { + this.renderPending = true; +#if DEBUG + int wheelSeqAtDispatch = OxyPlot.PlotDiagnostics.CurrentWheelSeq; + long dispatchTicks = System.Diagnostics.Stopwatch.GetTimestamp(); +#endif + // DispatcherPriority.Render runs at the same priority as WPF's internal + // composition tick — the deferred render therefore executes at the start + // of the next frame budget rather than after pending Layout/DataBind + // work drains (which is what DispatcherPriority.Loaded would do). Cuts + // ~one full dispatcher cycle (~16ms at 60Hz) of latency on rapid wheel + // zoom + pan. The renderPending flag still guards against double-queuing. + this.Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() => + { + this.renderPending = false; +#if DEBUG + if (OxyPlot.PlotDiagnostics.WheelTraceEnabled && wheelSeqAtDispatch != 0) + { + double queueMs = (System.Diagnostics.Stopwatch.GetTimestamp() - dispatchTicks) * 1000.0 + / System.Diagnostics.Stopwatch.Frequency; + System.Diagnostics.Debug.WriteLine( + $"[W#{wheelSeqAtDispatch,4}] PlotViewBase.Render DEQUEUED (Render) queueMs={queueMs,8:F2}"); + } + var renderSw = System.Diagnostics.Stopwatch.StartNew(); +#endif + this.Render(); +#if DEBUG + renderSw.Stop(); + if (OxyPlot.PlotDiagnostics.WheelTraceEnabled && wheelSeqAtDispatch != 0) + { + System.Diagnostics.Debug.WriteLine( + $"[W#{wheelSeqAtDispatch,4}] PlotViewBase.Render EXIT renderMs={renderSw.Elapsed.TotalMilliseconds,8:F2}"); + } +#endif + })); + } +#if DEBUG } +#endif + } + +#if DEBUG + /// + /// Set to true to enable per-call diagnostics + /// (caller chain + timing). Consumers flip this on just before reproducing a suspected + /// invalidation loop and off immediately after, to keep the log focused. + /// + /// + /// Debug-only. Has no effect in Release builds. + /// + public static bool InvalidatePlotDiagnosticsEnabled { get; set; } - if (!this.renderPending) + /// + /// Restrict diagnostics output to plots whose contains this + /// substring (case-insensitive). Null or empty = log all plots. Use this to silence + /// unrelated plots when reproducing a loop against a single plot. + /// + public static string InvalidatePlotDiagnosticsTitleFilter { get; set; } + + private static readonly System.Threading.ThreadLocal _lastInvalidateTicks = + new System.Threading.ThreadLocal(() => 0); + + private static long _invalidateCallCounter; + + private void DiagnoseInvalidatePlotCall(bool updateData) + { + if (!InvalidatePlotDiagnosticsEnabled) return; + + var model = this.ActualModel; + if (model == null) return; + + // Title filter so the log is focused on the plot under investigation. + var filter = InvalidatePlotDiagnosticsTitleFilter; + if (!string.IsNullOrEmpty(filter)) { - this.renderPending = true; - this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => - { - this.renderPending = false; - this.Render(); - })); + var title = model.Title ?? string.Empty; + if (title.IndexOf(filter, StringComparison.OrdinalIgnoreCase) < 0) return; } + + long callId = System.Threading.Interlocked.Increment(ref _invalidateCallCounter); + + // Per-thread inter-call timing. InvalidatePlot is UI-thread-only in practice, but we + // use ThreadLocal to be safe if any background-thread caller slips through. + long nowTicks = DateTime.UtcNow.Ticks; + long prevTicks = _lastInvalidateTicks.Value; + _lastInvalidateTicks.Value = nowTicks; + double dtMs = prevTicks == 0 ? -1 : (nowTicks - prevTicks) / 10_000.0; + + // Capture up to 8 frames of the call stack, skipping this method and InvalidatePlot. + var stackTrace = new System.Diagnostics.StackTrace(skipFrames: 2, fNeedFileInfo: false); + var sb = new System.Text.StringBuilder(256); + int frameCount = System.Math.Min(stackTrace.FrameCount, 8); + for (int i = 0; i < frameCount; i++) + { + var frame = stackTrace.GetFrame(i); + var method = frame?.GetMethod(); + if (method == null) continue; + var type = method.DeclaringType; + string typeName = type != null ? (type.Name ?? string.Empty) : "?"; + if (i > 0) sb.Append(" <- "); + sb.Append(typeName).Append('.').Append(method.Name); + } + + string titleForLog = model.Title ?? "(no title)"; + System.Diagnostics.Debug.WriteLine( + $"[InvalidatePlot #{callId,6} title=\"{titleForLog}\" updateData={(updateData ? "T" : "F"),-1} dt={dtMs,7:F2}ms] {sb}"); } +#endif /// public override void OnApplyTemplate() { base.OnApplyTemplate(); + // Force DPI re-fetch on next render — template re-application may move the + // visual to a different PresentationSource (AvalonDock detach to floating window + // on a different monitor, theme switch that re-templates, etc.). + this.cachedDpiScale = null; this.grid = this.GetTemplateChild(PartGrid) as Grid; if (this.grid == null) { @@ -223,12 +490,36 @@ public override void OnApplyTemplate() this.plotPresenter.UpdateLayout(); this.renderContext = this.CreateRenderContext(); + // Propagate any DisableShapeAntiAliasing / UseBitmapCache preference set before the + // template was applied (the presenter is created here for the first time). + this.ApplyAntiAliasingPreference(); + this.ApplyBitmapCachePreference(); + this.overlays = new Canvas(); this.grid.Children.Add(this.overlays); - this.zoomControl = new ContentControl(); - this.zoomControl.Focusable = false; - this.overlays.Children.Add(this.zoomControl); + // Clear bindings on the previous adorner instance (if any) before discarding the + // reference. Otherwise the WPF binding objects retain a Source reference back to + // the old overlay Canvas, keeping the prior visual subtree alive across + // re-template events (AvalonDock dock/undock, theme switches that re-template + // the control). + if (this.zoomAdorner != null) + { + System.Windows.Data.BindingOperations.ClearAllBindings(this.zoomAdorner); + } + + this.zoomAdorner = new ZoomRectangleAdorner(); + // The adorner renders the zoom-rectangle drag affordance with no layout-pass overhead + // per mouse-move (see ZoomRectangleAdorner remarks for the full rationale). It sits + // at (0, 0) of the overlay canvas; the rectangle to draw is set via SetBounds. + // Bind Width/Height so the adorner fills the overlay canvas (Canvas does not + // auto-size its children); without this its render area would be 0x0 and OnRender + // would draw nothing. + this.zoomAdorner.SetBinding(WidthProperty, + new System.Windows.Data.Binding(nameof(Canvas.ActualWidth)) { Source = this.overlays }); + this.zoomAdorner.SetBinding(HeightProperty, + new System.Windows.Data.Binding(nameof(Canvas.ActualHeight)) { Source = this.overlays }); + this.overlays.Children.Add(this.zoomAdorner); // add additional grid on top of everthing else to fix issue of mouse events getting lost // it must be added last so it covers all other controls @@ -339,19 +630,15 @@ public void ShowTracker(TrackerHitResult trackerHitResult) /// Shows the zoom rectangle. /// /// The rectangle. + /// + /// Called on every mouse-move during a magnifier-glass zoom-rectangle drag (60–125 Hz), + /// so the body must be cheap. Delegates to , + /// which only updates an internal field and calls + /// — no WPF layout pass per mouse-move. + /// public void ShowZoomRectangle(OxyRect r) { - if (this.zoomControl == null) - { - return; - } - - this.zoomControl.Width = r.Width; - this.zoomControl.Height = r.Height; - Canvas.SetLeft(this.zoomControl, r.Left); - Canvas.SetTop(this.zoomControl, r.Top); - this.zoomControl.Template = this.ZoomRectangleTemplate; - this.zoomControl.Visibility = Visibility.Visible; + this.zoomAdorner?.SetBounds(new Rect(r.Left, r.Top, r.Width, r.Height)); } /// @@ -417,7 +704,16 @@ protected void Render() { return; } - this.isInVisualTree = this.IsInVisualTree(); + + // Skip the full IsInVisualTree() tree walk on every render. The Loaded/Unloaded + // events maintain the cached value; OnLayoutUpdated handles edge cases (popup + // hosting, ElementHost) where Loaded doesn't reliably reflect tree connectivity. + // Only re-walk when the cached value says "not in tree" — to discover transitions + // we may have missed. + if (!this.isInVisualTree) + { + this.isInVisualTree = this.IsInVisualTree(); + } this.RenderOverride(); } @@ -427,18 +723,28 @@ protected void Render() /// protected virtual void RenderOverride() { - var dpiScale = this.UpdateDpi(); - this.ClearBackground(); - - if (this.ActualModel != null) +#if DEBUG + using (OxyPlot.PlotDiagnostics.Trace("PlotViewBase.RenderOverride")) +#endif { - // round width and height to full device pixels - var width = ((int)(this.plotPresenter.ActualWidth * dpiScale)) / dpiScale; - var height = ((int)(this.plotPresenter.ActualHeight * dpiScale)) / dpiScale; + var dpiScale = this.UpdateDpi(); + this.ClearBackground(); - lock (this.ActualModel.SyncRoot) + if (this.ActualModel != null) { - ((IPlotModel)this.ActualModel).Render(this.renderContext, new OxyRect(0, 0, width, height)); + // round width and height to full device pixels + var width = ((int)(this.plotPresenter.ActualWidth * dpiScale)) / dpiScale; + var height = ((int)(this.plotPresenter.ActualHeight * dpiScale)) / dpiScale; + + lock (this.ActualModel.SyncRoot) + { +#if DEBUG + using (OxyPlot.PlotDiagnostics.Trace("PlotModel.Render", $"size={width:F0}x{height:F0}")) +#endif + { + ((IPlotModel)this.ActualModel).Render(this.renderContext, new OxyRect(0, 0, width, height)); + } + } } } } @@ -447,13 +753,37 @@ protected virtual void RenderOverride() /// Updates the DPI scale of the render context. /// /// The DPI scale. + /// + /// Caches the DPI scale across renders. + /// is a non-trivial COM-boundary lookup; calling it on every render adds avoidable + /// overhead when the DPI changes only on monitor switch. The cache is invalidated in + /// (per-monitor DPI change) and reset in + /// (presenter recreation). + /// protected virtual double UpdateDpi() { + if (this.cachedDpiScale.HasValue) + { + return this.cachedDpiScale.Value; + } + var transformMatrix = PresentationSource.FromVisual(this)?.CompositionTarget?.TransformToDevice; var scale = transformMatrix == null ? 1 : (transformMatrix.Value.M11 + transformMatrix.Value.M22) / 2; + this.cachedDpiScale = scale; return scale; } + /// + /// Invalidates the cached DPI scale when the host moves between monitors with + /// different DPI. Forces the next to re-fetch from + /// . + /// + protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi) + { + base.OnDpiChanged(oldDpi, newDpi); + this.cachedDpiScale = null; + } + /// /// Called when the model is changed. /// @@ -472,7 +802,10 @@ private void BeginInvoke(Action action) { if (!this.Dispatcher.CheckAccess()) { - this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, action); + // Render priority matches the deferred-render dispatch in InvalidatePlot, + // so cross-thread invocations don't sit behind pending Layout/DataBind + // work in the dispatcher queue. + this.Dispatcher.BeginInvoke(DispatcherPriority.Render, action); } else { diff --git a/src/OxyPlot/OxyPlot.Wpf.Shared/ZoomRectangleAdorner.cs b/src/OxyPlot/OxyPlot.Wpf.Shared/ZoomRectangleAdorner.cs new file mode 100644 index 00000000..f82c0f67 --- /dev/null +++ b/src/OxyPlot/OxyPlot.Wpf.Shared/ZoomRectangleAdorner.cs @@ -0,0 +1,126 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2014 OxyPlot contributors +// +// +// Lightweight overlay element for rendering the zoom-rectangle drag affordance with minimal per-mouse-move cost. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OxyPlot.Wpf +{ + using System.Windows; + using System.Windows.Media; + + /// + /// Lightweight overlay used to render the zoom-rectangle affordance during a magnifier-glass + /// drag. Replaces the historical + + /// approach with a single + /// that draws via . + /// + /// + /// + /// Why this exists. The previous implementation used a templated + /// resized via / on + /// every mouse-move during a drag. WPF responded to those property changes by invalidating + /// measure on the control and arrange on its parent , + /// scheduling a layout pass at every mouse-move (60–125 Hz). Combined with the dashed-stroke + /// tessellation in the default template, that produced visible multi-second drag lag on dense + /// 20-series plots. + /// + /// + /// What this does instead. The adorner sits at (0, 0) of the overlay canvas + /// and is sized to the full plot area once, then never resized. Mouse-move updates only + /// mutate an internal field via and call + /// , which schedules a render-priority callback + /// without any layout pass. draws a single rectangle each frame using + /// frozen, cached and instances. + /// is applied to skip stroke-tessellation anti-aliasing. + /// + /// + /// The adorner is hit-test invisible so it never intercepts the drag's mouse events. + /// + /// + public sealed class ZoomRectangleAdorner : FrameworkElement + { + /// + /// Frozen, shared brush for the rectangle fill (semi-transparent yellow). Frozen brushes + /// can be reused freely across visuals without copy overhead. + /// + private static readonly Brush FillBrush; + + /// + /// Frozen, shared pen for the rectangle outline (1 px black, "3,1" dashed). + /// + private static readonly Pen StrokePen; + + /// + /// The current zoom-rectangle bounds in adorner-local coordinates. Updated by + /// . Drawn each frame by . + /// + private Rect bounds; + + /// + /// True when the adorner has any rectangle to draw. + /// + private bool hasBounds; + + static ZoomRectangleAdorner() + { + FillBrush = new SolidColorBrush(Color.FromArgb(0x40, 0xFF, 0xFF, 0x00)); + FillBrush.Freeze(); + + var dash = new DashStyle(new double[] { 3, 1 }, 0); + dash.Freeze(); + StrokePen = new Pen(Brushes.Black, 1) { DashStyle = dash, DashCap = PenLineCap.Flat }; + StrokePen.Freeze(); + } + + /// + /// Initializes a new instance of the class. + /// + public ZoomRectangleAdorner() + { + // Aliased edges skip WPF stroke-tessellation AA. The rectangle is a transient drag + // affordance — slight pixel jaggedness is acceptable and worth the major perf win. + RenderOptions.SetEdgeMode(this, EdgeMode.Aliased); + + // Drag affordance never intercepts pointer events. + this.IsHitTestVisible = false; + + // The adorner draws to its own coordinate space; no layout participation needed. + this.SnapsToDevicePixels = true; + } + + /// + /// Sets the rectangle to draw. Cheap; only invalidates the visual (no layout pass). + /// + /// The rectangle in adorner-local coordinates. + public void SetBounds(Rect r) + { + if (this.hasBounds && this.bounds == r) return; + this.bounds = r; + this.hasBounds = true; + this.InvalidateVisual(); + } + + /// + /// Clears the rectangle so the adorner draws nothing on the next render frame. + /// + public void ClearBounds() + { + if (!this.hasBounds) return; + this.hasBounds = false; + this.InvalidateVisual(); + } + + /// + protected override void OnRender(DrawingContext drawingContext) + { + base.OnRender(drawingContext); + if (!this.hasBounds) return; + if (this.bounds.Width <= 0 || this.bounds.Height <= 0) return; + drawingContext.DrawRectangle(FillBrush, StrokePen, this.bounds); + } + } +} diff --git a/src/OxyPlot/OxyPlot.Wpf/Axes/Axis.cs b/src/OxyPlot/OxyPlot.Wpf/Axes/Axis.cs index 783a04f3..906ba550 100644 --- a/src/OxyPlot/OxyPlot.Wpf/Axes/Axis.cs +++ b/src/OxyPlot/OxyPlot.Wpf/Axes/Axis.cs @@ -1021,8 +1021,17 @@ protected static void AppearanceChanged(DependencyObject d, DependencyPropertyCh /// /// Handles changes to the Minimum/Maximum properties. - /// Resets zoom state when user explicitly sets a value, then triggers a full data update. + /// Resets zoom state when user explicitly sets a value, then triggers a synchronized re-render. /// + /// + /// Min/Max is an axis-range change, not a data change. Previously this called + /// which routed through InvalidatePlot() (default + /// updateData=true) — that walked every visible series via + /// series.UpdateData() for what is purely a range adjustment. Routing through + /// instead sets _needsSynchronization = true (so + /// the next sync pushes the new Min/Max into the internal axis) and then issues + /// InvalidatePlot(false), skipping the per-series data walk. + /// private static void MinMaxChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var axis = (Axis)d; @@ -1035,7 +1044,7 @@ private static void MinMaxChanged(DependencyObject d, DependencyPropertyChangedE axis.InternalAxis.Reset(); } - axis.OnDataChanged(); + axis.OnVisualChanged(); } /// @@ -1062,7 +1071,11 @@ protected void OnDataChanged() /// protected void OnVisualChanged() { - // Set _needsSynchronization before InvalidatePlot so the sync is not skipped. + // Load-bearing ordering: _needsSynchronization MUST be set before InvalidatePlot. + // If suppression is active, Plot.InvalidatePlot short-circuits at the gate but the + // _needsSynchronization=true survives, so the next non-gated invalidation runs the + // sync that picks up this axis's WPF DP change. Reordering (or omitting) the flag + // would silently lose the visual update across a suppression window. // OnVisualChanged is only called from WPF DP change callbacks (not zoom/pan), // so this does not affect zoom/pan performance. if (this.Parent is Plot plot) diff --git a/src/OxyPlot/OxyPlot.Wpf/DrawingVisualHost.cs b/src/OxyPlot/OxyPlot.Wpf/DrawingVisualHost.cs index 3382a866..0fe1c351 100644 --- a/src/OxyPlot/OxyPlot.Wpf/DrawingVisualHost.cs +++ b/src/OxyPlot/OxyPlot.Wpf/DrawingVisualHost.cs @@ -54,6 +54,94 @@ public DrawingVisualHost() this.AddLogicalChild(this.visual); } + /// + /// Gets or sets a value indicating whether the rasterized output of this element is + /// cached as a bitmap in video memory via + + /// . Default false. + /// + /// + /// + /// When true, WPF renders this element's visual subtree once into a GPU bitmap + /// and reuses the bitmap on subsequent compositor frames. The cache regenerates only + /// when the structure of the subtree changes — which for a plot means whenever the + /// inner 's content is rewritten via + /// (i.e., on every Plot.InvalidatePlot). + /// + /// + /// When this helps. Scenarios where the plot is static but the surface is + /// repeatedly composited: dragging a transient overlay (e.g., the magnifier-glass zoom + /// rectangle) over the plot, parent panel resize animations, dock-splitter drags, or + /// the plot scrolling into and out of viewport. Without the cache, WPF re-rasterizes + /// the plot's geometry under the dirty region on every compositor frame. + /// + /// + /// When this doesn't help (and may slightly regress). Scenarios where every + /// frame re-renders the plot (e.g., real-time streaming data). The cache regenerates + /// each render, paying a small overhead with no reuse benefit. + /// + /// + /// is set to the current per-monitor DPI scale + /// to keep the cached bitmap sharp. is + /// enabled to align with the existing pixel-snapping configuration. + /// + /// + public bool UseBitmapCache + { + get => this.CacheMode is BitmapCache; + set + { + if (value) + { + var dpiInfo = VisualTreeHelper.GetDpi(this); + var scale = dpiInfo.PixelsPerDip > 0 ? dpiInfo.PixelsPerDip : 1.0; + this.CacheMode = new BitmapCache + { + RenderAtScale = scale, + SnapsToDevicePixels = true, + EnableClearType = false, + }; + } + else + { + this.CacheMode = null; + } + } + } + + /// + /// Gets or sets a value indicating whether anti-aliasing is disabled for shape rendering + /// inside the hosted . Default is false (anti-aliasing on). + /// + /// + /// + /// When set to true, applies to the visual via + /// RenderOptions.SetEdgeMode. This disables WPF's stroke-tessellation + /// anti-aliasing for the entire visual. + /// + /// + /// Why it matters for performance. WPF's stroked-geometry tessellation runs on the + /// render thread and is the dominant per-series cost for plots with many + /// instances (e.g. a 20-chain MCMC trace at 1751 points each). Disabling anti-aliasing + /// skips the tessellation entirely and yields a multi-x speedup for line rendering. + /// Markers, fills, and text are unaffected (text uses its own rendering path). For thin + /// strokes (≤2 px) the visual difference is barely perceptible; for trace/density plots + /// the perf gain is decisive. + /// + /// + /// Background: this is the same root cause flagged by OxyPlot upstream issue #1286 + /// ("LineSeries has bad performance with large amount of data due to aliased=false"). + /// + /// + public bool DisableShapeAntiAliasing + { + get => RenderOptions.GetEdgeMode(this.visual) == EdgeMode.Aliased; + set + { + RenderOptions.SetEdgeMode(this.visual, value ? EdgeMode.Aliased : EdgeMode.Unspecified); + RenderOptions.SetEdgeMode(this, value ? EdgeMode.Aliased : EdgeMode.Unspecified); + } + } + /// /// Gets the hosted . /// @@ -73,5 +161,23 @@ protected override Visual GetVisualChild(int index) { return this.visual; } + + /// + /// Re-applies when the host moves between + /// monitors with different DPI scales. Without this, an active + /// retains the original monitor's PixelsPerDip and renders blurry on the new + /// monitor (low-DPI cache scaled up) or unnecessarily oversharp (high-DPI cache scaled + /// down) until is toggled off and on. + /// + /// The DPI scale before the change. + /// The DPI scale after the change. + protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi) + { + base.OnDpiChanged(oldDpi, newDpi); + if (this.CacheMode is BitmapCache bc) + { + bc.RenderAtScale = newDpi.PixelsPerDip > 0 ? newDpi.PixelsPerDip : 1.0; + } + } } } diff --git a/src/OxyPlot/OxyPlot.Wpf/DrawingVisualRenderContext.cs b/src/OxyPlot/OxyPlot.Wpf/DrawingVisualRenderContext.cs index 295d77d5..dc798807 100644 --- a/src/OxyPlot/OxyPlot.Wpf/DrawingVisualRenderContext.cs +++ b/src/OxyPlot/OxyPlot.Wpf/DrawingVisualRenderContext.cs @@ -84,7 +84,39 @@ public class DrawingVisualRenderContext : ClippingRenderContext /// Avoids redundant FormattedText allocations during margin-adjustment iterations /// and across frames when axis tick labels haven't changed. /// - private readonly Dictionary<(string text, string fontFamily, double fontSize, bool isBold), OxySize> measureCache = new Dictionary<(string, string, double, bool), OxySize>(); + /// + /// Maximum number of entries retained in and + /// before LRU eviction removes the least-recently-used entry. + /// On a real-time / streaming plot the unique-label count grows monotonically with time + /// (each frame produces fresh numeric labels). An unbounded dictionary would leak — + /// 512 entries comfortably accommodates a frame's worth of axis ticks plus repeating + /// legend / annotation text, while capping retained objects + /// at a fixed memory ceiling. + /// + private const int TextCacheCapacity = 512; + + private readonly LruCache<(string text, string fontFamily, double fontSize, bool isBold, TextFormattingMode mode, string cultureName), OxySize> measureCache = + new LruCache<(string, string, double, bool, TextFormattingMode, string), OxySize>(TextCacheCapacity); + + /// + /// The DrawText FormattedText cache, keyed by (text, fontFamily, fontSize, isBold, color, mode, cultureName). + /// Axis tick labels, axis titles, and legend entries typically repeat across frames; + /// caching the eliminates ~100 allocations per render on + /// a typical plot and measurably reduces GC pressure on long-running dashboards. + /// + /// + /// IMPORTANT: Do NOT mutate cached instances after + /// construction (no SetForegroundBrush, SetFontWeight, TextDecorations, + /// SetMaxTextWidth, etc.). only reads Width/Height + /// and passes the instance to — safe reuse. + /// The key includes and the current UI culture name so + /// mode switches and culture changes (e.g. user toggling RTL locale) produce a fresh + /// instead of returning a stale layout. Cache is bounded to + /// entries via LRU eviction and cleared when + /// or changes. + /// + private readonly LruCache<(string text, string fontFamily, double fontSize, bool isBold, OxyColor color, TextFormattingMode mode, string cultureName), FormattedText> drawTextCache = + new LruCache<(string, string, double, bool, OxyColor, TextFormattingMode, string), FormattedText>(TextCacheCapacity); /// /// The active drawing context, or null if not currently rendering. @@ -96,6 +128,7 @@ public class DrawingVisualRenderContext : ClippingRenderContext /// private bool clipPushed; + /// /// Initializes a new instance of the class. /// @@ -122,15 +155,32 @@ public double DpiScale { this.dpiScale = value; this.measureCache.Clear(); + this.drawTextCache.Clear(); } } } + private TextFormattingMode textFormattingMode = TextFormattingMode.Display; + /// /// Gets or sets the text formatting mode. + /// Changing this value clears both text caches so cached + /// and measurement results that were built under the old mode aren't returned. /// /// The text formatting mode. The default value is . - public TextFormattingMode TextFormattingMode { get; set; } = TextFormattingMode.Display; + public TextFormattingMode TextFormattingMode + { + get => this.textFormattingMode; + set + { + if (this.textFormattingMode != value) + { + this.textFormattingMode = value; + this.measureCache.Clear(); + this.drawTextCache.Clear(); + } + } + } /// /// Gets or sets the visual offset for pixel snapping calculations. @@ -165,6 +215,20 @@ public void CloseDrawing() /// Sets the clipping area to the specified rectangle. /// Called by when the active clip region changes. /// + /// + /// Cached frozen reused across + /// calls. The plot-area clipping rect is the same value across most calls within a + /// render (each series clips to the same plot area) and the same across most renders + /// (only changes on resize). + /// + private RectangleGeometry cachedClipGeometry; + + /// + /// The reflected in . Compared on + /// each call to detect when the cache must rebuild. + /// + private OxyRect cachedClipRect; + /// The clipping rectangle. protected override void SetClip(OxyRect clippingRect) { @@ -173,7 +237,17 @@ protected override void SetClip(OxyRect clippingRect) return; } - this.dc.PushClip(new RectangleGeometry(ToRect(clippingRect))); + // Reuse the cached frozen geometry when the clip rect hasn't changed since the + // last call. On a 20-series plot, SetClip is called once per series with the same + // plot-area rect — without this, 20 RectangleGeometry allocations per render. + if (this.cachedClipGeometry == null || !this.cachedClipRect.Equals(clippingRect)) + { + this.cachedClipGeometry = new RectangleGeometry(ToRect(clippingRect)); + this.cachedClipGeometry.Freeze(); + this.cachedClipRect = clippingRect; + } + + this.dc.PushClip(this.cachedClipGeometry); this.clipPushed = true; } @@ -192,12 +266,45 @@ protected override void ResetClip() this.clipPushed = false; } - /// /// /// Maximum number of vertices per StreamGeometry tile. - /// Keeps WPF's stroke tessellation within L2 cache for better performance. /// - private const int StreamGeometryTileSize = 1024; + /// + /// Earlier versions split at 1024 to "keep stroke tessellation within L2 cache." In + /// practice, 20-LineSeries plots with a fused decimator output ~1000–4000 points each + /// and the per-tile StreamGeometry + DrawGeometry overhead was the dominant + /// per-series cost. With (bulk + /// native-side append) replacing the LineTo loop, large geometries are cheap and + /// further splitting hurts more than it helps. The tile size is now large enough that a + /// typical fused-decimated chain renders as a single geometry. Pathological inputs + /// (>16k screen-space points per series) still fall back to tiling for safety. + /// + private const int StreamGeometryTileSize = 16384; + + /// + /// Reusable buffer for calls. Avoids + /// allocating a fresh [] per series per render. Grown as needed and + /// reused across all DrawLine/DrawLineSegments calls within and across + /// frames. Per-render-context (one context per plot) so no concurrency concerns. + /// + private Point[] polyPointBuffer = new Point[2048]; + + /// + /// Ensures has at least slots. + /// + private void EnsurePolyBuffer(int capacity) + { + if (this.polyPointBuffer.Length < capacity) + { + int newSize = this.polyPointBuffer.Length; + while (newSize < capacity) + { + newSize *= 2; + } + + this.polyPointBuffer = new Point[newSize]; + } + } /// public override void DrawLine( @@ -225,7 +332,9 @@ public override void DrawLine( int n = points.Count; if (n > StreamGeometryTileSize) { - // Split into overlapping tiles for better WPF tessellation performance. + // Pathological case: extremely long polylines fall back to tiled rendering for + // safety. With StreamGeometryTileSize = 16384, only inputs above that size hit + // this path. Most fused-decimated series never do. int start = 0; while (start < n - 1) { @@ -243,16 +352,38 @@ public override void DrawLine( /// /// Draws a line segment range as a single StreamGeometry. /// + /// + /// Uses for the + /// bulk of the points instead of a per-point + /// loop. PolyLineTo hands the entire vertex array to the native MIL layer in one + /// call, eliminating the managed-call overhead that dominates for large polylines. + /// Reuses across calls to avoid per-render allocations. + /// private void DrawLineRange(IList points, int from, int to, Pen pen, double actualThickness, bool snap) { + int count = to - from; + if (count < 2) + { + return; + } + + this.EnsurePolyBuffer(count); + var buf = this.polyPointBuffer; + for (int i = 0; i < count; i++) + { + buf[i] = this.ToPoint(points[from + i], actualThickness, snap); + } + var sg = new StreamGeometry(); using (var sgc = sg.Open()) { - sgc.BeginFigure(this.ToPoint(points[from], actualThickness, snap), false, false); - for (int i = from + 1; i < to; i++) - { - sgc.LineTo(this.ToPoint(points[i], actualThickness, snap), true, false); - } + sgc.BeginFigure(buf[0], false, false); + + // PolyLineTo accepts an IList; pass an ArraySegment-equivalent via + // a slice-list wrapper to avoid allocating a trimmed array. Since WPF's + // implementation copies internally, slicing isn't required for correctness, + // but a wrapper keeps the call zero-alloc. + sgc.PolyLineTo(new ArraySegmentList(buf, 1, count - 1), true, false); } sg.Freeze(); @@ -282,6 +413,9 @@ public override void DrawLineSegments( var actualThickness = this.GetActualStrokeThickness(thickness, edgeRenderingMode); bool snap = this.ShouldSnapPoints(edgeRenderingMode, points); + // DrawLineSegments uses alternating stroked/unstroked figures (each segment is a + // separate move-line pair), so PolyLineTo can't batch the whole list. The LineTo + // loop here is unavoidable, but the geometry is still built in one StreamGeometry. var sg = new StreamGeometry(); using (var sgc = sg.Open()) { @@ -299,6 +433,158 @@ public override void DrawLineSegments( this.dc.DrawGeometry(null, pen, sg); } + /// + /// Lightweight zero-alloc view over an array slice. + /// Used to pass a sub-range of to + /// without + /// allocating a new array each call. + /// + /// + /// The indexer performs an unchecked offset+index access. The single caller + /// () early-exits when count < 2, so the segment + /// length passed here is always count - 1 >= 1 and the empty-slice path is + /// unreachable. If a future caller bypasses that guard and passes count == 0, + /// PolyLineTo will receive an empty IList<Point> — WPF's + /// implementation iterates via Count and the indexer, both of which are safe + /// here, but no figure will be drawn. + /// + private sealed class ArraySegmentList : IList + { + private readonly T[] array; + private readonly int offset; + private readonly int count; + + public ArraySegmentList(T[] array, int offset, int count) + { + this.array = array; + this.offset = offset; + this.count = count; + } + + public T this[int index] + { + get => this.array[this.offset + index]; + set => throw new NotSupportedException(); + } + + public int Count => this.count; + public bool IsReadOnly => true; + + public IEnumerator GetEnumerator() + { + for (int i = 0; i < this.count; i++) + { + yield return this.array[this.offset + i]; + } + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => this.GetEnumerator(); + + public bool Contains(T item) + { + int end = this.offset + this.count; + var cmp = EqualityComparer.Default; + for (int i = this.offset; i < end; i++) + { + if (cmp.Equals(this.array[i], item)) return true; + } + return false; + } + + public void CopyTo(T[] target, int targetIndex) => Array.Copy(this.array, this.offset, target, targetIndex, this.count); + + public int IndexOf(T item) + { + int end = this.offset + this.count; + var cmp = EqualityComparer.Default; + for (int i = this.offset; i < end; i++) + { + if (cmp.Equals(this.array[i], item)) return i - this.offset; + } + return -1; + } + + public void Add(T item) => throw new NotSupportedException(); + public void Clear() => throw new NotSupportedException(); + public void Insert(int index, T item) => throw new NotSupportedException(); + public bool Remove(T item) => throw new NotSupportedException(); + public void RemoveAt(int index) => throw new NotSupportedException(); + } + + /// + /// Bounded least-recently-used cache. Used by and + /// so live-data plots (real-time dashboards, oscilloscope + /// views) cannot accumulate a per-frame stream of distinct numeric labels indefinitely. + /// On lookup, hits are moved to the front of the recency list; on insert, the oldest + /// entry is evicted if the capacity is exceeded. + /// + /// + /// Single-threaded by design — all access is from the WPF render thread holding the + /// DrawingContext. No locking; introducing concurrency here would require external + /// synchronization at the call site. + /// + private sealed class LruCache + { + private readonly int capacity; + private readonly Dictionary>> map; + private readonly LinkedList> list = new LinkedList>(); + + public LruCache(int capacity) + { + if (capacity < 1) throw new ArgumentOutOfRangeException(nameof(capacity)); + this.capacity = capacity; + this.map = new Dictionary>>(capacity); + } + + public int Count => this.map.Count; + + public bool TryGetValue(TKey key, out TValue value) + { + if (this.map.TryGetValue(key, out var node)) + { + // Move-to-front: this entry is now the most recently used. + this.list.Remove(node); + this.list.AddFirst(node); + value = node.Value.Value; + return true; + } + value = default!; + return false; + } + + public TValue this[TKey key] + { + set + { + if (this.map.TryGetValue(key, out var existing)) + { + // Replace existing entry; move to front. + this.list.Remove(existing); + this.map.Remove(key); + } + + var newNode = new LinkedListNode>( + new KeyValuePair(key, value)); + this.list.AddFirst(newNode); + this.map[key] = newNode; + + // Evict oldest if over capacity. + if (this.map.Count > this.capacity) + { + var oldest = this.list.Last!; + this.list.RemoveLast(); + this.map.Remove(oldest.Value.Key); + } + } + } + + public void Clear() + { + this.map.Clear(); + this.list.Clear(); + } + } + /// public override void DrawPolygon( IList points, @@ -490,9 +776,13 @@ public override void DrawEllipses( return; } - // Each ellipse generates 3 path commands (BeginFigure + 2 ArcTo). - // Tile at ~500 ellipses (1500 path commands) for cache-efficient tessellation. - const int ellipseTileSize = 500; + // Each ellipse generates 3 path commands (BeginFigure + 2 ArcTo). Tile at 4096 + // ellipses (~12k path commands) per StreamGeometry — well below the line-tile + // ceiling of 16384 and large enough that high-density marker plots (5k+ markers + // across 20 series) emit a small number of frozen geometries instead of dozens. + // The previous 500-ellipse tile dated from the canvas-renderer era; the + // DrawingVisual path handles much larger geometry batches efficiently. + const int ellipseTileSize = 4096; int count = rectangles.Count; int start = 0; @@ -543,17 +833,28 @@ public override void DrawText( return; } - var typeface = this.CreateTypeface(fontFamily, fontWeight); - var ft = new FormattedText( - text, - CultureInfo.CurrentUICulture, - FlowDirection.LeftToRight, - typeface, - fontSize > 0 ? fontSize : 12, - brush, - null, - this.TextFormattingMode, - this.DpiScale); + // Cache lookup: same (text, font, size, weight, color, mode, culture) produces an + // identical FormattedText render. Axis tick labels and repeated legend text hit this + // path on every frame — caching saves ~100 allocations per render on a typical plot. + // NEVER mutate cached FormattedText instances (see drawTextCache docs). + var isBold = fontWeight > FontWeights.Normal; + var culture = CultureInfo.CurrentUICulture; + var drawKey = (text, fontFamily ?? "Segoe UI", fontSize > 0 ? fontSize : 12, isBold, fill, this.TextFormattingMode, culture.Name); + if (!this.drawTextCache.TryGetValue(drawKey, out var ft)) + { + var typeface = this.CreateTypeface(fontFamily, fontWeight); + ft = new FormattedText( + text, + culture, + FlowDirection.LeftToRight, + typeface, + fontSize > 0 ? fontSize : 12, + brush, + null, + this.TextFormattingMode, + this.DpiScale); + this.drawTextCache[drawKey] = ft; + } double textWidth = ft.Width; double textHeight = ft.Height; @@ -596,6 +897,15 @@ public override void DrawText( if (hasRotation) { + // IMPORTANT: do NOT reuse a cached Transform here. DrawingContext.PushTransform + // captures the Transform by reference; the DrawingVisual command stream + // re-evaluates the Transform's current matrix at composition time. Mutating a + // cached transform between draws causes every previously-recorded rotated text + // (axis titles, annotation labels) to render at the latest position+angle — + // visible as "Y-axis title appears at the polyline annotation" / "labels jump + // and overlap." Allocating fresh transforms per call is the correct behaviour; + // any caching would have to freeze immediately after construction (defeating + // the cache). this.dc.PushTransform(new TranslateTransform(p.X, p.Y)); this.dc.PushTransform(new RotateTransform(rotate)); this.dc.DrawText(ft, new Point(dx, dy)); @@ -621,7 +931,8 @@ public override OxySize MeasureText(string text, string fontFamily, double fontS } var isBold = fontWeight > FontWeights.Normal; - var cacheKey = (text, fontFamily ?? "Segoe UI", fontSize > 0 ? fontSize : 12, isBold); + var culture = CultureInfo.CurrentUICulture; + var cacheKey = (text, fontFamily ?? "Segoe UI", fontSize > 0 ? fontSize : 12, isBold, this.TextFormattingMode, culture.Name); if (this.measureCache.TryGetValue(cacheKey, out var cached)) { return cached; @@ -630,7 +941,7 @@ public override OxySize MeasureText(string text, string fontFamily, double fontS var typeface = this.CreateTypeface(fontFamily, fontWeight); var ft = new FormattedText( text, - CultureInfo.CurrentUICulture, + culture, FlowDirection.LeftToRight, typeface, fontSize > 0 ? fontSize : 12, @@ -698,16 +1009,57 @@ public override void SetToolTip(string text) // The tracker popup is rendered on the overlays Canvas, which is independent of this render context. } + /// + /// Reusable buffer for image-cache eviction in . Avoids the + /// per-render LINQ + List allocation that would otherwise fire on every render even + /// for plots that don't use images. + /// + private List imageEvictBuffer; + /// public override void CleanUp() { - // Remove unreferenced images from the cache. - var imagesToRelease = this.imageCache.Keys.Where(i => !this.imagesInUse.Contains(i)).ToList(); - foreach (var i in imagesToRelease) + // Fast path: no images cached, nothing to evict. + if (this.imageCache.Count == 0) + { + this.imagesInUse.Clear(); + return; + } + + // Fast path: every cached image was used this frame — clear the in-use set and + // exit without walking the cache. + if (this.imageCache.Count == this.imagesInUse.Count) + { + this.imagesInUse.Clear(); + return; + } + + // Slow path: at least one cached image was not used this frame. Reuse a private + // List buffer (Clear+Add) instead of the LINQ Where().ToList() that would allocate + // a fresh list on every render. + if (this.imageEvictBuffer == null) + { + this.imageEvictBuffer = new List(); + } + else + { + this.imageEvictBuffer.Clear(); + } + + foreach (var key in this.imageCache.Keys) + { + if (!this.imagesInUse.Contains(key)) + { + this.imageEvictBuffer.Add(key); + } + } + + for (int i = 0; i < this.imageEvictBuffer.Count; i++) { - this.imageCache.Remove(i); + this.imageCache.Remove(this.imageEvictBuffer[i]); } + this.imageEvictBuffer.Clear(); this.imagesInUse.Clear(); } diff --git a/src/OxyPlot/OxyPlot.Wpf/OxyPlot.Wpf.csproj b/src/OxyPlot/OxyPlot.Wpf/OxyPlot.Wpf.csproj index 5d0dc709..69aeb91b 100644 --- a/src/OxyPlot/OxyPlot.Wpf/OxyPlot.Wpf.csproj +++ b/src/OxyPlot/OxyPlot.Wpf/OxyPlot.Wpf.csproj @@ -9,6 +9,7 @@ 8 true OxyPlot is a plotting library for .NET. This package targets WPF applications. + $(NoWarn);CS0618 diff --git a/src/OxyPlot/OxyPlot.Wpf/Plot.cs b/src/OxyPlot/OxyPlot.Wpf/Plot.cs index bdc38d23..d4b0d456 100644 --- a/src/OxyPlot/OxyPlot.Wpf/Plot.cs +++ b/src/OxyPlot/OxyPlot.Wpf/Plot.cs @@ -51,6 +51,15 @@ public partial class Plot : PlotView, INotifyPropertyChanged /// public event PropertyChangedEventHandler? PropertyChanged; + /// + /// Backing field for . Marked volatile so + /// reads on the dispatcher thread reliably observe writes from any thread without a + /// memory barrier at the call site. The gate reads this + /// flag once per call, so a stale-read race could miss a suppressed bulk-update window + /// or render mid-suppression on consumers that prepare data on a worker thread. + /// + private volatile bool suppressPropertyChanged; + /// /// Gets or sets whether events are suppressed. /// When true, no PropertyChanged events fire from this Plot instance, @@ -59,9 +68,16 @@ public partial class Plot : PlotView, INotifyPropertyChanged /// /// Use this to suppress events during bulk operations such as deserialization, /// theme application, or programmatic series population where the undo system - /// should not record individual changes. + /// should not record individual changes. The backing field is volatile so + /// cross-thread writes are visible without explicit synchronization at the call site, + /// but the broader pipeline still expects dispatch-thread + /// access for visual-tree mutations. /// - public bool SuppressPropertyChanged { get; set; } + public bool SuppressPropertyChanged + { + get => this.suppressPropertyChanged; + set => this.suppressPropertyChanged = value; + } /// /// Occurs when an axis is replaced via , @@ -519,8 +535,63 @@ protected void OnPropertyChanged(string propertyName) /// This avoids expensive re-synchronization during zoom/pan, where only /// internal axis ranges change and the WPF wrappers are untouched. /// + /// + /// Semantics: this is the "force full sync" flag. Setting it to true guarantees + /// every Synchronize* method runs on the next non-gated . + /// Internal callers that know which collection changed should set the corresponding + /// per-collection dirty flag (, , + /// , ) instead — those + /// trigger only the sync work that actually applies. External callers that don't have + /// that granularity can keep setting _needsSynchronization = true; that path + /// is preserved as a conservative "sync everything" fallback for backward compatibility. + /// internal bool _needsSynchronization = true; + /// + /// Set to true when an item in changed (collection mutation + /// or item-level PropertyChanged). Triggers alone on + /// the next sync pass — avoids re-creating all axes and annotation models for an + /// unrelated series-only edit. + /// + private bool _seriesDirty; + + /// + /// Set to true when an item in changed. Triggers + /// alone on the next sync pass. + /// + private bool _axesDirty; + + /// + /// Set to true when an item in changed. Triggers + /// alone on the next sync pass. + /// + private bool _annotationsDirty; + + /// + /// Set to true when a Plot-level DP changed (background, title, legend + /// appearance, etc.). Triggers alone on the + /// next sync pass. + /// + private bool _propertiesDirty; + + /// + /// When true, the next non-gated call must run with + /// updateData=true regardless of the caller's argument, because at least one + /// suppressed call requested a data refresh. Set inside the suppression gate when + /// updateData=true is dropped; cleared as soon as it is consumed by a non-gated + /// call. This guarantees a data refresh is never silently lost across a suppression + /// window, even if the consumer's final flush call passes updateData=false. + /// + /// + /// Intentionally non-volatile: both the writer (suppression-gate branch in + /// ) and the consumer (just below the gate, same method) + /// run on the dispatcher thread. The cross-thread visibility we need is on + /// , not on this flag — once a gated write + /// observes SuppressPropertyChanged==true, the corresponding pending-flag + /// write is already on the dispatcher thread. + /// + private bool _pendingUpdateData; + /// /// Initializes static members of the class. /// @@ -731,6 +802,12 @@ public bool IsLegendVisible /// /// Gets or sets the default text color. /// + /// + /// This property round-trips through + /// OxyPlot.Wpf.Serialization.PlotSerializer.GeneralPropertiesToXElement + /// and is restored on load — saved plot configurations preserve the chosen + /// text color rather than reverting to the framework default. + /// public Color TextColor { get => (Color)this.GetValue(TextColorProperty); @@ -1080,20 +1157,226 @@ protected override System.Collections.IEnumerator LogicalChildren /// Invalidates the plot and updates the model. /// /// Whether to update data. + /// + /// + /// When is set on this plot, all invalidation + /// work is deferred. This gate catches not only the Plot's own direct InvalidatePlot calls + /// but also the cascading calls that flow back in from child Series. There are two common + /// cascades that previously bypassed suppression and produced the multi-second lag on + /// many-series plots (e.g. a 20-chain MCMC trace): + /// + /// + /// + /// + /// Logical-tree inherited-DP cascade: adding a Series wrapper to + /// causes WPF to re-evaluate every inherited DependencyProperty (Visibility, Background, + /// FontFamily, FontSize, FontWeight, Foreground). Each change fires AppearanceChanged + /// on the wrapper, which calls back into Plot.InvalidatePlot. For N series × 6 inherited + /// DPs = 6N synchronous Model.Update calls during bulk Series.Add. + /// + /// + /// + /// + /// ItemsSource-per-series cascade: assigning ItemsSource on each wrapper fires + /// OnItemsSourceChangedOnDataChanged → InvalidatePlot(true). For N series + /// assignments that's N full Model.Update(true) cycles. + /// + /// + /// + /// + /// The gate marks _needsSynchronization = true so the final explicit + /// InvalidatePlot(true) (issued after + /// is cleared) runs the full sync, but skips the ~120 redundant Update calls during the + /// bulk-update window. Consumers MUST pair SuppressPropertyChanged=true with an + /// explicit InvalidatePlot(...) after clearing — otherwise the plot state may be + /// inconsistent until the next user interaction. + /// + /// + /// The flag is preserved across the suppression window: + /// any suppressed call with updateData=true sets a private pending flag that + /// promotes the next non-gated call to updateData=true, even if the consumer's + /// final flush passes updateData=false. This guarantees a data refresh requested + /// during the suppression window is never silently dropped. + /// + /// public override void InvalidatePlot(bool updateData = true) { - if (this._needsSynchronization || updateData) + if (this.SuppressPropertyChanged) { - this.SynchronizeProperties(); - this.SynchronizeSeries(); - this.SynchronizeAxes(); - this.SynchronizeAnnotations(); + this._needsSynchronization = true; + // Preserve a deferred data-refresh request across the suppression window. + // Without this, a suppressed InvalidatePlot(true) would be silently lost + // when the consumer ends suppression with InvalidatePlot(false). + if (updateData) + { + this._pendingUpdateData = true; + } + return; + } + + // Consume any data-refresh request that was deferred during a suppression window. + // This must happen before the sync block so the consolidated updateData flag + // controls both Synchronize* and base.InvalidatePlot below. + if (this._pendingUpdateData) + { + updateData = true; + this._pendingUpdateData = false; + } + +#if DEBUG + // Per-phase timing to locate the real bottleneck when the aggregate InvalidatePlot + // is slower than expected. Gated on the same flag as the outer diagnostic. + bool diagnose = InvalidatePlotDiagnosticsEnabled && InvalidatePlotPhaseDiagnosticsEnabled + && this.ActualModel != null + && (string.IsNullOrEmpty(InvalidatePlotDiagnosticsTitleFilter) + || (this.ActualModel.Title ?? string.Empty).IndexOf( + InvalidatePlotDiagnosticsTitleFilter, + System.StringComparison.OrdinalIgnoreCase) >= 0); + long t0 = 0, tSync = 0, tBase = 0; + bool ranSync = false; + bool entryNeedsSync = this._needsSynchronization; + int gc0_0 = 0, gc1_0 = 0, gc2_0 = 0; + if (diagnose) + { + t0 = System.Diagnostics.Stopwatch.GetTimestamp(); + gc0_0 = System.GC.CollectionCount(0); + gc1_0 = System.GC.CollectionCount(1); + gc2_0 = System.GC.CollectionCount(2); + OxyPlot.PlotDiagnostics.Log("Plot.InvalidatePlot ENTER"); + } +#endif + + // Dispatch synchronization by per-collection dirty flags. _needsSynchronization + // (legacy "force full sync" flag) and updateData=true both promote to "sync + // everything" — preserves backward compatibility with external callers that set + // _needsSynchronization directly. Otherwise only the dirty collections re-sync, + // which on a 20-series plot means a single Series.Color change runs only + // SynchronizeSeries (~20 CreateModel calls) instead of all four sync methods + // (~22 CreateModel calls plus Plot-property and legend copy work). + bool forceAll = this._needsSynchronization || updateData; + bool needSyncProps = forceAll || this._propertiesDirty; + bool needSyncSeries = forceAll || this._seriesDirty; + bool needSyncAxes = forceAll || this._axesDirty; + bool needSyncAnnotations = forceAll || this._annotationsDirty; + + if (needSyncProps || needSyncSeries || needSyncAxes || needSyncAnnotations) + { + if (needSyncProps) this.SynchronizeProperties(); + if (needSyncSeries) this.SynchronizeSeries(); + if (needSyncAxes) this.SynchronizeAxes(); + if (needSyncAnnotations) this.SynchronizeAnnotations(); + this._needsSynchronization = false; + this._propertiesDirty = false; + this._seriesDirty = false; + this._axesDirty = false; + this._annotationsDirty = false; +#if DEBUG + ranSync = true; +#endif } +#if DEBUG + if (diagnose) tSync = System.Diagnostics.Stopwatch.GetTimestamp(); +#endif + base.InvalidatePlot(updateData); + +#if DEBUG + if (diagnose) + { + tBase = System.Diagnostics.Stopwatch.GetTimestamp(); + double ticksPerMs = System.Diagnostics.Stopwatch.Frequency / 1000.0; + double syncMs = (tSync - t0) / ticksPerMs; + double baseMs = (tBase - tSync) / ticksPerMs; + + // GC counter delta — catches a stop-the-world collection eating wall-clock time + // outside the InvalidatePlot pipeline. + int gc0_d = System.GC.CollectionCount(0) - gc0_0; + int gc1_d = System.GC.CollectionCount(1) - gc1_0; + int gc2_d = System.GC.CollectionCount(2) - gc2_0; + + // Render-complete measurement: ContextIdle fires after the dispatcher has drained + // the full render. Total includes the WPF composition cost. + var paintSw = System.Diagnostics.Stopwatch.StartNew(); + long callId = System.Threading.Interlocked.Increment(ref _invalidatePhaseCallCounter); + string phaseTag = $"sync={(ranSync ? "Y" : "N")} entryNeedsSync={(entryNeedsSync ? "Y" : "N")} updateData={(updateData ? "T" : "F")}"; + this.Dispatcher.BeginInvoke( + new System.Action(() => + { + paintSw.Stop(); + System.Diagnostics.Debug.WriteLine( + $"[InvalidatePhase #{callId,6}] {phaseTag} syncMs={syncMs,6:F2} baseMs={baseMs,6:F2} paintMs={paintSw.ElapsedMilliseconds,5} gc0={gc0_d} gc1={gc1_d} gc2={gc2_d}"); + }), + System.Windows.Threading.DispatcherPriority.ContextIdle); + + // First-frame measurement: hook CompositionTarget.Rendering exactly once. This fires + // on the next WPF render-tree commit, which is when the user actually sees pixels + // change. If this is large but paintMs is small, the slowness lives in the WPF + // visual tree commit / DWM compositor, not the OxyPlot pipeline. + // Coalesce: if a previous InvalidatePlot already subscribed a handler that hasn't + // fired yet (rapid 60Hz wheel zoom outpaces CompositionTarget.Rendering), skip + // re-subscribing. Otherwise N stale handlers accumulate and fire simultaneously + // on the next render tick, producing N redundant log lines and adding subscribe + // overhead per call. + if (!_firstFrameHandlerPending) + { + _firstFrameHandlerPending = true; + long invalidateEntryTicks = t0; + int captureCallId = (int)callId; + System.EventHandler firstFrameHandler = null; + firstFrameHandler = (s, ev) => + { + long now = System.Diagnostics.Stopwatch.GetTimestamp(); + double firstFrameMs = (now - invalidateEntryTicks) * 1000.0 / System.Diagnostics.Stopwatch.Frequency; + System.Diagnostics.Debug.WriteLine( + $"[FirstFrame #{captureCallId,6}] msFromInvalidate={firstFrameMs,7:F2}"); + System.Windows.Media.CompositionTarget.Rendering -= firstFrameHandler; + _firstFrameHandlerPending = false; + }; + System.Windows.Media.CompositionTarget.Rendering += firstFrameHandler; + } + + OxyPlot.PlotDiagnostics.Log($"Plot.InvalidatePlot EXIT (renderQueued, callId={callId})"); + } +#endif + } + +#if DEBUG + private static bool _invalidatePlotPhaseDiagnosticsEnabled; + + /// + /// When true and + /// is also true, logs per-phase timing for every call: + /// synchronization cost, Model.Update + render-queue cost, render-complete cost (via a + /// ContextIdle callback), first-frame cost (via CompositionTarget.Rendering), GC + /// counter delta, and a full wheel-zoom stack trace via . + /// + public static bool InvalidatePlotPhaseDiagnosticsEnabled + { + get => _invalidatePlotPhaseDiagnosticsEnabled; + set + { + _invalidatePlotPhaseDiagnosticsEnabled = value; + // Mirror to the core-side flag so the wheel-stack trace activates with the same toggle. + OxyPlot.PlotDiagnostics.WheelTraceEnabled = value; + } } + private static long _invalidatePhaseCallCounter; + + /// + /// True between subscribing a CompositionTarget.Rendering handler in InvalidatePlot's + /// debug diagnostics and that handler firing+unsubscribing. Coalesces rapid InvalidatePlot + /// calls (faster than 60Hz render tick) into a single subscribed handler so the log + /// shows one [FirstFrame] line per render, not N stale lines from N redundant handlers. + /// Per-instance so two Plot controls in the same process don't share state — otherwise + /// a Rendering tick fired for one plot would clear the other's pending flag and produce + /// misleading diagnostics. + /// + private bool _firstFrameHandlerPending; +#endif + /// /// Called when visual appearance changes. /// @@ -1103,7 +1386,11 @@ private static void AppearanceChanged(DependencyObject d, DependencyPropertyChan { var plot = (Plot)d; if (plot.SuppressPropertyChanged) return; - plot._needsSynchronization = true; + // A Plot-level DP changed (background, title, legend properties, etc.). + // Only Plot-level properties need re-syncing; series, axes, and annotations are + // unaffected. Setting only _propertiesDirty avoids re-creating their model + // wrappers on every appearance tweak. + plot._propertiesDirty = true; plot.InvalidatePlot(false); plot.OnPropertyChanged(e.Property.Name); } @@ -1116,7 +1403,7 @@ private void OnSeriesChanged(object sender, NotifyCollectionChangedEventArgs e) { this.UpdateItemSubscriptions(e, this.subscribedSeries); this.SyncLogicalTree(e); - this._needsSynchronization = true; + this._seriesDirty = true; if (this.SuppressPropertyChanged) return; this.InvalidatePlot(); this.OnPropertyChanged("Series"); @@ -1130,7 +1417,7 @@ private void OnAxesChanged(object sender, NotifyCollectionChangedEventArgs e) { this.UpdateItemSubscriptions(e, this.subscribedAxes); this.SyncLogicalTree(e); - this._needsSynchronization = true; + this._axesDirty = true; if (this.SuppressPropertyChanged) return; this.InvalidatePlot(); this.OnPropertyChanged("Axes"); @@ -1144,7 +1431,7 @@ private void OnAnnotationsChanged(object sender, NotifyCollectionChangedEventArg { this.UpdateItemSubscriptions(e, this.subscribedAnnotations); this.SyncLogicalTree(e); - this._needsSynchronization = true; + this._annotationsDirty = true; if (this.SuppressPropertyChanged) return; this.InvalidatePlot(); this.OnPropertyChanged("Annotations"); @@ -1229,23 +1516,28 @@ private void UpdateItemSubscriptions(NotifyCollectionChangedEventArgs e, List /// private void OnCollectionItemPropertyChanged(object sender, PropertyChangedEventArgs e) { - this._needsSynchronization = true; - + // Dispatch sync work to only the affected collection. A Series.Color edit, for + // example, no longer triggers SynchronizeAxes + SynchronizeAnnotations. string prefix; if (sender is Annotation) { + this._annotationsDirty = true; prefix = "Annotation"; } else if (sender is Series) { + this._seriesDirty = true; prefix = "Series"; } else if (sender is Axis) { + this._axesDirty = true; prefix = "Axis"; } else { + // Unknown sender — fall back to the conservative full-sync path. + this._needsSynchronization = true; prefix = "Item"; } diff --git a/src/OxyPlot/OxyPlot.Wpf/Serialization/AnnotationSerializer.cs b/src/OxyPlot/OxyPlot.Wpf/Serialization/AnnotationSerializer.cs index 2948a0cd..d751450a 100644 --- a/src/OxyPlot/OxyPlot.Wpf/Serialization/AnnotationSerializer.cs +++ b/src/OxyPlot/OxyPlot.Wpf/Serialization/AnnotationSerializer.cs @@ -68,13 +68,26 @@ public static class AnnotationSerializer /// /// The plot containing annotations to serialize. /// An containing all serialized annotations. + /// + /// Only -derived annotations are serialized. Non-textual + /// annotations such as ImageAnnotation are skipped with a diagnostic trace — + /// previously they were silently dropped on Save/Open. Full round-trip support for + /// ImageAnnotation requires base64-encoding the OxyImage blob and is + /// tracked as a follow-up; the diagnostic ensures the loss is no longer invisible. + /// public static XElement AnnotationsToXElement(Plot plot) { var annotationProperties = new XElement(AnnotationsPropertiesTag); foreach (var annotation in plot.Annotations) { var textualAnnotation = annotation as TextualAnnotation; - if (textualAnnotation == null) continue; + if (textualAnnotation == null) + { + System.Diagnostics.Debug.WriteLine( + $"[AnnotationSerializer] Annotation of type '{annotation?.GetType().FullName}' is not a TextualAnnotation and will not be persisted. " + + "Save/Open will lose this annotation. (Issue D-001 — full round-trip pending.)"); + continue; + } annotationProperties.Add(AnnotationToXElement(textualAnnotation)); } @@ -317,7 +330,15 @@ public static XElement AnnotationToXElement(TextualAnnotation annotation) else if (annotationTypeString == typeof(FunctionAnnotation).ToString()) annotation = new FunctionAnnotation(); else - annotation = new TextAnnotation(); + { + // Unknown annotation type. Previously fell through to `new TextAnnotation()`, + // which silently substituted a phantom empty text annotation in the user's + // plot. Return null instead — the caller (XElementToAnnotations) already + // skips null entries, matching the SeriesSerializer pattern. + System.Diagnostics.Debug.WriteLine( + $"[AnnotationSerializer] Unknown AnnotationType '{annotationTypeString}'; skipping."); + return null; + } // General Properties var generalElement = element.Element("General"); diff --git a/src/OxyPlot/OxyPlot.Wpf/Serialization/AxisSerializer.cs b/src/OxyPlot/OxyPlot.Wpf/Serialization/AxisSerializer.cs index 758d0a18..e0c4c3ea 100644 --- a/src/OxyPlot/OxyPlot.Wpf/Serialization/AxisSerializer.cs +++ b/src/OxyPlot/OxyPlot.Wpf/Serialization/AxisSerializer.cs @@ -128,6 +128,15 @@ public static XElement AxisToXElement(Axis axis) numericProperties.SetAttributeValue(nameof(axis.AbsoluteMinimum), axis.AbsoluteMinimum.ToString("G17", CultureInfo.InvariantCulture)); numericProperties.SetAttributeValue(nameof(axis.FilterMaxValue), axis.FilterMaxValue.ToString("G17", CultureInfo.InvariantCulture)); numericProperties.SetAttributeValue(nameof(axis.FilterMinValue), axis.FilterMinValue.ToString("G17", CultureInfo.InvariantCulture)); + // User-settable padding/range properties — previously not persisted. Only the + // properties exposed as DPs on the WPF Axis wrapper are serialized here: + // MaximumPadding, MinimumPadding, MaximumRange, MinimumRange. + // Margin and data-margin properties exist on the model but are not WPF DPs; + // adding them as wrapper DPs is tracked as a future enhancement. + numericProperties.SetAttributeValue(nameof(axis.MaximumPadding), axis.MaximumPadding.ToString("G17", CultureInfo.InvariantCulture)); + numericProperties.SetAttributeValue(nameof(axis.MinimumPadding), axis.MinimumPadding.ToString("G17", CultureInfo.InvariantCulture)); + numericProperties.SetAttributeValue(nameof(axis.MaximumRange), axis.MaximumRange.ToString("G17", CultureInfo.InvariantCulture)); + numericProperties.SetAttributeValue(nameof(axis.MinimumRange), axis.MinimumRange.ToString("G17", CultureInfo.InvariantCulture)); axisProperties.Add(numericProperties); // Style Properties @@ -155,6 +164,8 @@ public static XElement AxisToXElement(Axis axis) titleProperties.SetAttributeValue(nameof(axis.TitleFontWeight), FontWeightConverterInstance.ConvertToInvariantString(axis.TitleFontWeight)); titleProperties.SetAttributeValue(nameof(axis.AxisTitleDistance), axis.AxisTitleDistance.ToString("G17", CultureInfo.InvariantCulture)); titleProperties.SetAttributeValue(nameof(axis.Unit), axis.Unit); + titleProperties.SetAttributeValue(nameof(axis.ClipTitle), axis.ClipTitle.ToString()); + titleProperties.SetAttributeValue(nameof(axis.TitleClippingLength), axis.TitleClippingLength.ToString("G17", CultureInfo.InvariantCulture)); axisProperties.Add(titleProperties); // Label Properties @@ -167,6 +178,8 @@ public static XElement AxisToXElement(Axis axis) labelProperties.SetAttributeValue(nameof(axis.AxisTickToLabelDistance), axis.AxisTickToLabelDistance.ToString("G17", CultureInfo.InvariantCulture)); labelProperties.SetAttributeValue(nameof(axis.StringFormat), axis.StringFormat); labelProperties.SetAttributeValue(nameof(axis.UseSuperExponentialFormat), axis.UseSuperExponentialFormat.ToString()); + // IntervalLength controls label-density target — previously not persisted. + labelProperties.SetAttributeValue(nameof(axis.IntervalLength), axis.IntervalLength.ToString("G17", CultureInfo.InvariantCulture)); axisProperties.Add(labelProperties); // Major Gridline Properties @@ -176,6 +189,10 @@ public static XElement AxisToXElement(Axis axis) majorGridlineProperties.SetAttributeValue(nameof(axis.MajorGridlineThickness), axis.MajorGridlineThickness.ToString("G17", CultureInfo.InvariantCulture)); majorGridlineProperties.SetAttributeValue(nameof(axis.MajorStep), axis.MajorStep.ToString("G17", CultureInfo.InvariantCulture)); majorGridlineProperties.SetAttributeValue(nameof(axis.MajorTickSize), axis.MajorTickSize.ToString("G17", CultureInfo.InvariantCulture)); + // MinimumMajorStep, MaximumMajorIntervalCount, MinimumMajorIntervalCount, + // CropGridlines exist on the model but not as WPF Axis wrapper DPs; not + // serialized here. Add them as wrapper DPs (with Plot.SynchronizeProperties + // wiring) before persisting via this serializer. axisProperties.Add(majorGridlineProperties); // Minor Gridline Properties @@ -185,6 +202,8 @@ public static XElement AxisToXElement(Axis axis) minorGridlineProperties.SetAttributeValue(nameof(axis.MinorGridlineThickness), axis.MinorGridlineThickness.ToString("G17", CultureInfo.InvariantCulture)); minorGridlineProperties.SetAttributeValue(nameof(axis.MinorStep), axis.MinorStep.ToString("G17", CultureInfo.InvariantCulture)); minorGridlineProperties.SetAttributeValue(nameof(axis.MinorTickSize), axis.MinorTickSize.ToString("G17", CultureInfo.InvariantCulture)); + // MinimumMinorStep exists on the model but not as a WPF Axis wrapper DP; + // not serialized here. axisProperties.Add(minorGridlineProperties); // Extra Gridline Properties @@ -192,12 +211,16 @@ public static XElement AxisToXElement(Axis axis) extraGridlineProperties.SetAttributeValue(nameof(axis.ExtraGridlineColor), axis.ExtraGridlineColor.ToString()); extraGridlineProperties.SetAttributeValue(nameof(axis.ExtraGridlineStyle), axis.ExtraGridlineStyle.ToString()); extraGridlineProperties.SetAttributeValue(nameof(axis.ExtraGridlineThickness), axis.ExtraGridlineThickness.ToString("G17", CultureInfo.InvariantCulture)); + // Explicit gridline values (the axis.ExtraGridlines double[]) — previously not persisted. + extraGridlineProperties.Add(axis.ExtraGridlines.ToXElement(nameof(axis.ExtraGridlines))); axisProperties.Add(extraGridlineProperties); // Tick Style Properties var tickStyleProperties = new XElement("Tick"); tickStyleProperties.SetAttributeValue(nameof(axis.TickStyle), axis.TickStyle.ToString()); tickStyleProperties.SetAttributeValue(nameof(axis.TicklineColor), axis.TicklineColor.ToString()); + // MinorTicklineColor exists on the model but not as a WPF Axis wrapper DP; + // not serialized here. axisProperties.Add(tickStyleProperties); // Concrete axis implementation properties @@ -407,6 +430,10 @@ public static XElement AxisToXElement(Axis axis) if (GetDoubleAttribute(numbersElement, nameof(axis.AbsoluteMinimum), out var absoluteMinimum)) axis.AbsoluteMinimum = absoluteMinimum; if (GetDoubleAttribute(numbersElement, nameof(axis.FilterMaxValue), out var filterMaxValue)) axis.FilterMaxValue = filterMaxValue; if (GetDoubleAttribute(numbersElement, nameof(axis.FilterMinValue), out var filterMinValue)) axis.FilterMinValue = filterMinValue; + if (GetDoubleAttribute(numbersElement, nameof(axis.MaximumPadding), out var maximumPadding)) axis.MaximumPadding = maximumPadding; + if (GetDoubleAttribute(numbersElement, nameof(axis.MinimumPadding), out var minimumPadding)) axis.MinimumPadding = minimumPadding; + if (GetDoubleAttribute(numbersElement, nameof(axis.MaximumRange), out var maximumRange)) axis.MaximumRange = maximumRange; + if (GetDoubleAttribute(numbersElement, nameof(axis.MinimumRange), out var minimumRange)) axis.MinimumRange = minimumRange; } // Style Properties @@ -450,6 +477,8 @@ public static XElement AxisToXElement(Axis axis) if (GetFontWeightAttribute(titleElement, nameof(axis.TitleFontWeight), FontWeightConverterInstance, out var titleFontWeight)) axis.TitleFontWeight = titleFontWeight; if (GetDoubleAttribute(titleElement, nameof(axis.AxisTitleDistance), out var axisTitleDistance)) axis.AxisTitleDistance = axisTitleDistance; if (GetStringAttribute(titleElement, nameof(axis.Unit), out var unit)) axis.Unit = unit; + if (GetBooleanAttribute(titleElement, nameof(axis.ClipTitle), out var clipTitle)) axis.ClipTitle = clipTitle; + if (GetDoubleAttribute(titleElement, nameof(axis.TitleClippingLength), out var titleClippingLength)) axis.TitleClippingLength = titleClippingLength; // Backward compatibility if (GetColorAttribute(titleElement, "Color", out titleColor)) axis.TitleColor = titleColor; @@ -471,6 +500,7 @@ public static XElement AxisToXElement(Axis axis) if (GetDoubleAttribute(labelElement, nameof(axis.AxisTickToLabelDistance), out var axisTickToLabelDistance)) axis.AxisTickToLabelDistance = axisTickToLabelDistance; if (GetStringAttribute(labelElement, nameof(axis.StringFormat), out var stringFormat)) axis.StringFormat = stringFormat; if (GetBooleanAttribute(labelElement, nameof(axis.UseSuperExponentialFormat), out var useSuperExponentialFormat)) axis.UseSuperExponentialFormat = useSuperExponentialFormat; + if (GetDoubleAttribute(labelElement, nameof(axis.IntervalLength), out var intervalLength)) axis.IntervalLength = intervalLength; // Backward compatibility if (GetColorAttribute(labelElement, "Color", out textColor)) axis.TextColor = textColor; @@ -523,6 +553,12 @@ public static XElement AxisToXElement(Axis axis) if (GetColorAttribute(extraGridlineElement, nameof(axis.ExtraGridlineColor), out var extraGridlineColor)) axis.ExtraGridlineColor = extraGridlineColor; if (GetEnumAttribute(extraGridlineElement, nameof(axis.ExtraGridlineStyle), out OxyPlot.LineStyle extraGridlineStyle)) axis.ExtraGridlineStyle = extraGridlineStyle; if (GetDoubleAttribute(extraGridlineElement, nameof(axis.ExtraGridlineThickness), out var extraGridlineThickness)) axis.ExtraGridlineThickness = extraGridlineThickness; + // Read explicit gridline values (the double[] array). Empty array if absent. + var extraGridlinesValuesElement = extraGridlineElement.Element(nameof(axis.ExtraGridlines)); + if (extraGridlinesValuesElement != null) + { + axis.ExtraGridlines = extraGridlinesValuesElement.DoublesFromXElement(); + } } // Tick Style Properties diff --git a/src/OxyPlot/OxyPlot.Wpf/Serialization/PlotSerializer.cs b/src/OxyPlot/OxyPlot.Wpf/Serialization/PlotSerializer.cs index bcaa9fef..b210e827 100644 --- a/src/OxyPlot/OxyPlot.Wpf/Serialization/PlotSerializer.cs +++ b/src/OxyPlot/OxyPlot.Wpf/Serialization/PlotSerializer.cs @@ -16,6 +16,7 @@ namespace OxyPlot.Wpf.Serialization using System; using System.Collections.Generic; using System.Globalization; + using System.Linq; using System.Windows; using System.Windows.Media; using System.Xml.Linq; @@ -167,6 +168,9 @@ public static XElement GeneralPropertiesToXElement(Plot plot) { var generalProperties = new XElement(GeneralPropertiesTag); generalProperties.SetAttributeValue(nameof(plot.IsEnabled), plot.IsEnabled.ToString()); + // Global text color applies to every default-colored text element on the plot. + // Previously not persisted: round-trip silently reset TextColor to default. + generalProperties.SetAttributeValue(nameof(plot.TextColor), plot.TextColor.ToString()); var weightConverter = new FontWeightConverter(); @@ -229,6 +233,8 @@ public static void XElementToGeneralProperties(Plot plot, XElement element) // disabling loaded plots. if (GetBooleanAttribute(element, nameof(plot.IsEnabled), out bool isEnabled)) plot.IsEnabled = isEnabled; + if (GetColorAttribute(element, nameof(plot.TextColor), out Color textColor)) + plot.TextColor = textColor; // Set up converters var weightConverter = new FontWeightConverter(); @@ -312,10 +318,12 @@ public static void XElementToGeneralProperties(Plot plot, XElement element) var backgroundElement = chartElement.Element("BackgroundBrush"); if (backgroundElement != null) { - var firstElement = backgroundElement.Elements().GetEnumerator(); - if (firstElement.MoveNext()) + // FirstOrDefault avoids the manual GetEnumerator() pattern (which leaks the + // enumerator if not disposed) and reads cleanly. + var firstChild = backgroundElement.Elements().FirstOrDefault(); + if (firstChild != null) { - var bg = DeserializeFromXElement(firstElement.Current) as Brush; + var bg = DeserializeFromXElement(firstChild) as Brush; if (bg != null) plot.Background = bg; } } @@ -323,10 +331,10 @@ public static void XElementToGeneralProperties(Plot plot, XElement element) var borderElement = chartElement.Element("BorderBrush"); if (borderElement != null) { - var firstElement = borderElement.Elements().GetEnumerator(); - if (firstElement.MoveNext()) + var firstChild = borderElement.Elements().FirstOrDefault(); + if (firstChild != null) { - var bg = DeserializeFromXElement(firstElement.Current) as Brush; + var bg = DeserializeFromXElement(firstChild) as Brush; if (bg != null) plot.BorderBrush = bg; } } @@ -349,10 +357,10 @@ public static void XElementToGeneralProperties(Plot plot, XElement element) var backgroundElement = plotAreaElement.Element("BackgroundBrush"); if (backgroundElement != null) { - var firstElement = backgroundElement.Elements().GetEnumerator(); - if (firstElement.MoveNext()) + var firstChild = backgroundElement.Elements().FirstOrDefault(); + if (firstChild != null) { - var bg = DeserializeFromXElement(firstElement.Current) as Brush; + var bg = DeserializeFromXElement(firstChild) as Brush; if (bg != null) plot.PlotAreaBackground = bg; } } @@ -819,6 +827,10 @@ public static bool GetDataPointAttribute(XElement el, string attributeName, out /// The name of the attribute to read. /// When this method returns, contains the parsed ScreenVector if successful. /// true if the attribute exists and was successfully parsed; otherwise, false. + /// + /// Distinguishes a genuine (0,0) value from a malformed attribute: returns + /// true only when the attribute exists and parses to a valid pair of doubles. + /// public static bool GetScreenVectorAttribute(XElement el, string attributeName, out OxyPlot.ScreenVector vp) { vp = default(OxyPlot.ScreenVector); @@ -826,8 +838,7 @@ public static bool GetScreenVectorAttribute(XElement el, string attributeName, o string value = el.Attribute(attributeName)!.Value; if (string.IsNullOrEmpty(value)) return false; - vp = value.FromPrettyVectorText(); - return true; + return value.TryFromPrettyVectorText(out vp); } /// @@ -855,6 +866,10 @@ public static bool GetScreenPointAttribute(XElement el, string attributeName, ou /// The name of the attribute to read. /// When this method returns, contains the parsed Vector if successful. /// true if the attribute exists and was successfully parsed; otherwise, false. + /// + /// Distinguishes a genuine (0,0) value from a malformed attribute: returns + /// true only when the attribute exists and parses to a valid pair of doubles. + /// public static bool GetVectorAttribute(XElement el, string attributeName, out Vector v) { v = default(Vector); @@ -862,8 +877,7 @@ public static bool GetVectorAttribute(XElement el, string attributeName, out Vec string value = el.Attribute(attributeName)!.Value; if (string.IsNullOrEmpty(value)) return false; - v = value.FromPrettyVectorString(); - return true; + return value.TryFromPrettyVectorString(out v); } #endregion diff --git a/src/OxyPlot/OxyPlot.Wpf/Serialization/SerializerExtensions.cs b/src/OxyPlot/OxyPlot.Wpf/Serialization/SerializerExtensions.cs index ddcc579f..82cb9a0a 100644 --- a/src/OxyPlot/OxyPlot.Wpf/Serialization/SerializerExtensions.cs +++ b/src/OxyPlot/OxyPlot.Wpf/Serialization/SerializerExtensions.cs @@ -37,15 +37,36 @@ public static string ToPrettyText(this ScreenVector sv) /// /// The string in "X, Y" format. /// A parsed from the string, or default if parsing fails. + /// + /// Returns default(ScreenVector) (i.e., (0,0)) on parse failure. A genuine + /// (0,0) input is indistinguishable from a malformed input through this overload. + /// Use when callers need + /// to differentiate parse success from a zero vector. + /// public static ScreenVector FromPrettyVectorText(this string svString) { + return svString.TryFromPrettyVectorText(out var v) ? v : default(ScreenVector); + } + + /// + /// Attempts to parse a formatted "X, Y" string into a . + /// + /// The string in "X, Y" format. + /// When this method returns, the parsed + /// on success, or default(ScreenVector) on failure. + /// true if the string parsed successfully; otherwise false. + public static bool TryFromPrettyVectorText(this string svString, out ScreenVector value) + { + value = default(ScreenVector); + if (svString == null) return false; var svStringSplit = svString.Split(new[] { ", " }, StringSplitOptions.None); - if (svStringSplit.Length != 2) return default(ScreenVector); + if (svStringSplit.Length != 2) return false; double x, y; - if (double.TryParse(svStringSplit[0], NumberStyles.Any, CultureInfo.InvariantCulture, out x) == false) return default(ScreenVector); - if (double.TryParse(svStringSplit[1], NumberStyles.Any, CultureInfo.InvariantCulture, out y) == false) return default(ScreenVector); - return new ScreenVector(x, y); + if (!double.TryParse(svStringSplit[0], NumberStyles.Any, CultureInfo.InvariantCulture, out x)) return false; + if (!double.TryParse(svStringSplit[1], NumberStyles.Any, CultureInfo.InvariantCulture, out y)) return false; + value = new ScreenVector(x, y); + return true; } /// @@ -148,15 +169,36 @@ public static string ToPrettyText(this Vector v) /// /// The string in "X, Y" format. /// A parsed from the string, or default if parsing fails. + /// + /// Returns default(Vector) (i.e., (0,0)) on parse failure. A genuine + /// (0,0) input is indistinguishable from a malformed input through this overload. + /// Use when callers need to + /// differentiate parse success from a zero vector. + /// public static Vector FromPrettyVectorString(this string vString) { + return vString.TryFromPrettyVectorString(out var v) ? v : default(Vector); + } + + /// + /// Attempts to parse a formatted "X, Y" string into a . + /// + /// The string in "X, Y" format. + /// When this method returns, the parsed on + /// success, or default(Vector) on failure. + /// true if the string parsed successfully; otherwise false. + public static bool TryFromPrettyVectorString(this string vString, out Vector value) + { + value = default(Vector); + if (vString == null) return false; var vStringSplit = vString.Split(new[] { ", " }, StringSplitOptions.None); - if (vStringSplit.Length != 2) return default(Vector); + if (vStringSplit.Length != 2) return false; double x, y; - if (double.TryParse(vStringSplit[0], NumberStyles.Any, CultureInfo.InvariantCulture, out x) == false) return default(Vector); - if (double.TryParse(vStringSplit[1], NumberStyles.Any, CultureInfo.InvariantCulture, out y) == false) return default(Vector); - return new Vector(x, y); + if (!double.TryParse(vStringSplit[0], NumberStyles.Any, CultureInfo.InvariantCulture, out x)) return false; + if (!double.TryParse(vStringSplit[1], NumberStyles.Any, CultureInfo.InvariantCulture, out y)) return false; + value = new Vector(x, y); + return true; } /// @@ -198,5 +240,45 @@ public static IList PointsFromXElement(this XElement dpelements) return dpList; } + + /// + /// Converts an array of values to an XML element for serialization. + /// Each value becomes a <Value> child element using G17 invariant-culture + /// formatting so the array round-trips exactly across locales. + /// + /// The array of doubles to serialize. May be null. + /// The name for the parent XML element. + /// An containing all values as child elements (empty when is null). + public static XElement ToXElement(this double[] values, string name) + { + var el = new XElement(name); + if (values != null) + { + foreach (var v in values) + { + el.Add(new XElement("Value", v.ToString("G17", System.Globalization.CultureInfo.InvariantCulture))); + } + } + return el; + } + + /// + /// Parses an XML element produced by back into + /// a [] array. + /// + /// The XML element containing <Value> children. + /// The parsed array, or an empty array when the element has no parseable values. + public static double[] DoublesFromXElement(this XElement element) + { + var list = new List(); + foreach (var v in element.Elements("Value")) + { + if (double.TryParse(v.Value, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out var d)) + { + list.Add(d); + } + } + return list.ToArray(); + } } } diff --git a/src/OxyPlot/OxyPlot.Wpf/Serialization/SeriesSerializer.cs b/src/OxyPlot/OxyPlot.Wpf/Serialization/SeriesSerializer.cs index ce522f5f..53e3e8ce 100644 --- a/src/OxyPlot/OxyPlot.Wpf/Serialization/SeriesSerializer.cs +++ b/src/OxyPlot/OxyPlot.Wpf/Serialization/SeriesSerializer.cs @@ -174,6 +174,11 @@ public static XElement SeriesToXElement(Series series) generalProperties.SetAttributeValue(nameof(series.Padding), tc.ConvertToInvariantString(series.Padding)); generalProperties.SetAttributeValue(nameof(series.TrackerFormatString), series.TrackerFormatString); generalProperties.SetAttributeValue(nameof(series.TrackerKey), series.TrackerKey); + // User-settable perf opt-ins. Previously not persisted: every Save/Open + // would silently revert IsHitTestEnabled to true and EdgeRenderingMode to + // Automatic, undoing the framework's documented dense-trace perf lever. + generalProperties.SetAttributeValue(nameof(series.IsHitTestEnabled), series.IsHitTestEnabled.ToString()); + generalProperties.SetAttributeValue(nameof(series.EdgeRenderingMode), series.EdgeRenderingMode.ToString()); seriesElement.Add(generalProperties); @@ -638,6 +643,8 @@ public static XElement SeriesToXElement(Series series) if (GetThicknessAttribute(generalElement, nameof(series.Padding), thicknessConverter, out var padding)) series.Padding = padding; if (GetStringAttribute(generalElement, nameof(series.TrackerFormatString), out var trackerFormatString)) series.TrackerFormatString = trackerFormatString; if (GetStringAttribute(generalElement, nameof(series.TrackerKey), out var trackerKey)) series.TrackerKey = trackerKey; + if (GetBooleanAttribute(generalElement, nameof(series.IsHitTestEnabled), out var isHitTestEnabled)) series.IsHitTestEnabled = isHitTestEnabled; + if (GetEnumAttribute(generalElement, nameof(series.EdgeRenderingMode), out OxyPlot.EdgeRenderingMode edgeRenderingMode)) series.EdgeRenderingMode = edgeRenderingMode; } // Deserialize XY Axis Series Properties diff --git a/src/OxyPlot/OxyPlot.Wpf/Series/Series.cs b/src/OxyPlot/OxyPlot.Wpf/Series/Series.cs index a82e5312..52111a83 100644 --- a/src/OxyPlot/OxyPlot.Wpf/Series/Series.cs +++ b/src/OxyPlot/OxyPlot.Wpf/Series/Series.cs @@ -107,6 +107,22 @@ protected void OnPropertyChanged(string propertyName) typeof(Series), new PropertyMetadata(null, AppearanceChanged)); + /// + /// Identifies the dependency property. + /// + /// + /// Uses instead of + /// or . Toggling hit-test routing is neither a visual change + /// nor a data change, so it must not trigger InvalidatePlot or fire + /// PropertyChanged. Setting the DP directly updates the internal series so + /// the change is picked up on the next tracker event without forcing a render. + /// + public static readonly DependencyProperty IsHitTestEnabledProperty = DependencyProperty.Register( + nameof(IsHitTestEnabled), + typeof(bool), + typeof(Series), + new PropertyMetadata(true, HitTestRoutingChanged)); + /// /// Identifies the dependency property. /// @@ -212,10 +228,42 @@ public string TrackerKey set => this.SetValue(TrackerKeyProperty, value); } + /// + /// Gets or sets a value indicating whether this series participates in tracker hit-tests. + /// The default is true. + /// + /// + /// + /// Set to false for dense or decorative series (e.g. MCMC chain traces, overlay + /// reference lines) where per-point hit-testing provides no diagnostic value. When + /// disabled, the series is skipped by the tracker on every mouse move, avoiding the + /// O(n) nearest-point scan that would otherwise saturate the UI thread on large datasets. + /// This is a tracker-routing flag only: it does not affect rendering, does not trigger + /// InvalidatePlot, and does not fire . + /// + /// + /// This property round-trips through + /// OxyPlot.Wpf.Serialization.SeriesSerializer — saved plot configurations + /// preserve the hit-test flag so reopening a plot keeps tracker-routing exactly + /// as the user left it. + /// + /// + public bool IsHitTestEnabled + { + get => (bool)this.GetValue(IsHitTestEnabledProperty); + set => this.SetValue(IsHitTestEnabledProperty, value); + } + /// /// Gets or sets the edge rendering mode for the series. The default is . /// /// The edge rendering mode that controls anti-aliasing behavior. + /// + /// This property round-trips through + /// OxyPlot.Wpf.Serialization.SeriesSerializer — saved plot configurations + /// preserve the edge-rendering selection (e.g., Adaptive, PreferSpeed) + /// rather than reverting to on reload. + /// public EdgeRenderingMode EdgeRenderingMode { get => (EdgeRenderingMode)this.GetValue(EdgeRenderingModeProperty); @@ -263,6 +311,28 @@ protected static void DataChanged(DependencyObject d, DependencyPropertyChangedE series.OnDataChanged(); } + /// + /// Handles changes to the dependency property. + /// + /// The dependency object that changed. + /// The event arguments containing property change information. + /// + /// Hit-test routing is neither a visual nor a data change, so this callback must NOT + /// trigger InvalidatePlot or fire . Instead it + /// directly pushes the new value to so the tracker + /// (which reads from the internal model on every mouse move) picks up the change + /// without a render. The next call to will reassert + /// the same value via the normal pathway; there is no race. + /// + protected static void HitTestRoutingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var series = (Series)d; + if (series.InternalSeries != null) + { + series.InternalSeries.IsHitTestEnabled = (bool)e.NewValue; + } + } + /// /// Called when data has changed and a full update is required. /// @@ -324,6 +394,7 @@ protected virtual void SynchronizeProperties(OxyPlot.Series.Series s) s.TrackerFormatString = this.TrackerFormatString; s.TrackerKey = this.TrackerKey; s.IsVisible = this.Visibility == Visibility.Visible; + s.IsHitTestEnabled = this.IsHitTestEnabled; s.Font = this.FontFamily?.ToString(); s.FontSize = this.FontSize; s.FontWeight = this.FontWeight.ToOpenTypeWeight(); diff --git a/src/OxyPlot/OxyPlot/Axes/Axis.cs b/src/OxyPlot/OxyPlot/Axes/Axis.cs index e9305510..eecb066f 100644 --- a/src/OxyPlot/OxyPlot/Axes/Axis.cs +++ b/src/OxyPlot/OxyPlot/Axes/Axis.cs @@ -11,6 +11,7 @@ namespace OxyPlot.Axes { using System; using System.Collections.Generic; + using System.Globalization; using System.Linq; using OxyPlot.Series; using OxyPlot.Utilities; @@ -322,7 +323,22 @@ public string ActualTitle /// /// Gets or sets the filter function. The default value is null. /// - public Func FilterFunction { get; set; } + private Func filterFunction; + private bool hasFilterFunction; + + /// + /// Gets or sets the filter function. The default is null. + /// + /// The filter function. + public Func FilterFunction + { + get => this.filterFunction; + set + { + this.filterFunction = value; + this.hasFilterFunction = value != null; + } + } /// /// Gets or sets the maximum value that can be shown using this axis. Values greater or equal to this value will not be shown. The default value is double.MaxValue. @@ -854,12 +870,16 @@ public bool IsValidValue(double value) #pragma warning disable 1718 // ReSharper disable EqualExpressionComparison // ReSharper disable CompareOfFloatsByEqualityOperator + // hasFilterFunction is a cached bool flag mirrored from FilterFunction null-state; + // the JIT predicts this branch as always-false in the common case (no filter set) + // after a single observation, whereas the original null-check on the property + // could not be devirtualized. return value == value && value != 1.0 / 0.0 && value != -1.0 / 0.0 && value < this.FilterMaxValue && value > this.FilterMinValue && - (this.FilterFunction == null || this.FilterFunction(value)); + (!this.hasFilterFunction || this.filterFunction(value)); // ReSharper restore CompareOfFloatsByEqualityOperator // ReSharper restore EqualExpressionComparison #pragma warning restore 1718 @@ -889,6 +909,59 @@ public virtual bool IsLogarithmic() return false; } + /// + /// Cached at the time of the last call — + /// used by to skip redundant measurement passes during + /// the plot-margin stabilization loop. + /// + private double lastMeasuredScale = double.NaN; + + /// + /// Cached at the time of the last call. + /// + private double lastMeasuredOffset = double.NaN; + + /// + /// Cached at the time of the last call. + /// + private double lastMeasuredMin = double.NaN; + + /// + /// Cached at the time of the last call. + /// + private double lastMeasuredMax = double.NaN; + + /// + /// Returns true if any of the parameters that affect tick layout + /// (, , , + /// ) have changed since the last + /// call. Always returns true on the first call (NaN sentinels). Used by + /// the plot-margin stabilization loop to skip re-measuring axes that haven't moved. + /// + public bool NeedsMeasure() + { + // Use bit-equality to handle the NaN-sentinel "first call" case correctly: + // double.NaN != double.NaN, so the comparisons below always trigger a measure + // on the first call, and all four parameters become tracked thereafter. + return this.lastMeasuredScale != this.Scale + || this.lastMeasuredOffset != this.Offset + || this.lastMeasuredMin != this.ActualMinimum + || this.lastMeasuredMax != this.ActualMaximum; + } + + /// + /// Records the parameters that were in effect for the most recent + /// call. Subsequent checks compare against these values to + /// detect whether the axis has moved. + /// + public void MarkMeasured() + { + this.lastMeasuredScale = this.Scale; + this.lastMeasuredOffset = this.Offset; + this.lastMeasuredMin = this.ActualMinimum; + this.lastMeasuredMax = this.ActualMaximum; + } + /// /// Measures the size of the axis and updates accordingly. This takes into account the axis title as well as tick labels /// potentially exceeding the axis range. @@ -1282,46 +1355,61 @@ public virtual void Zoom(double x0, double x1) /// The coordinate to zoom at. public virtual void ZoomAt(double factor, double x) { - if (!this.IsZoomEnabled) +#if DEBUG + using (PlotDiagnostics.Trace("Axis.ZoomAt", $"axis={this.Position} key={this.Key ?? "(none)"} factor={factor:F4}")) +#endif { - return; - } + if (!this.IsZoomEnabled) + { + return; + } - var oldMinimum = this.ActualMinimum; - var oldMaximum = this.ActualMaximum; + var oldMinimum = this.ActualMinimum; + var oldMaximum = this.ActualMaximum; - double dx0 = (this.ActualMinimum - x) * this.scale; - double dx1 = (this.ActualMaximum - x) * this.scale; - this.scale *= factor; + double dx0 = (this.ActualMinimum - x) * this.scale; + double dx1 = (this.ActualMaximum - x) * this.scale; + this.scale *= factor; - double newMinimum = (dx0 / this.scale) + x; - double newMaximum = (dx1 / this.scale) + x; + double newMinimum = (dx0 / this.scale) + x; + double newMaximum = (dx1 / this.scale) + x; - if (newMaximum - newMinimum > this.MaximumRange) - { - var mid = (newMinimum + newMaximum) * 0.5; - newMaximum = mid + (this.MaximumRange * 0.5); - newMinimum = mid - (this.MaximumRange * 0.5); - } + if (newMaximum - newMinimum > this.MaximumRange) + { + var mid = (newMinimum + newMaximum) * 0.5; + newMaximum = mid + (this.MaximumRange * 0.5); + newMinimum = mid - (this.MaximumRange * 0.5); + } - if (newMaximum - newMinimum < this.MinimumRange) - { - var mid = (newMinimum + newMaximum) * 0.5; - newMaximum = mid + (this.MinimumRange * 0.5); - newMinimum = mid - (this.MinimumRange * 0.5); - } + if (newMaximum - newMinimum < this.MinimumRange) + { + var mid = (newMinimum + newMaximum) * 0.5; + newMaximum = mid + (this.MinimumRange * 0.5); + newMinimum = mid - (this.MinimumRange * 0.5); + } - newMinimum = Math.Max(newMinimum, this.AbsoluteMinimum); - newMaximum = Math.Min(newMaximum, this.AbsoluteMaximum); + newMinimum = Math.Max(newMinimum, this.AbsoluteMinimum); + newMaximum = Math.Min(newMaximum, this.AbsoluteMaximum); - this.ViewMinimum = newMinimum; - this.ViewMaximum = newMaximum; - this.UpdateActualMaxMin(); + this.ViewMinimum = newMinimum; + this.ViewMaximum = newMaximum; +#if DEBUG + using (PlotDiagnostics.Trace("Axis.ZoomAt.UpdateActualMaxMin")) +#endif + { + this.UpdateActualMaxMin(); + } - var deltaMinimum = this.ActualMinimum - oldMinimum; - var deltaMaximum = this.ActualMaximum - oldMaximum; + var deltaMinimum = this.ActualMinimum - oldMinimum; + var deltaMaximum = this.ActualMaximum - oldMaximum; - this.OnAxisChanged(new AxisChangedEventArgs(AxisChangeTypes.Zoom, deltaMinimum, deltaMaximum)); +#if DEBUG + using (PlotDiagnostics.Trace("Axis.ZoomAt.OnAxisChanged")) +#endif + { + this.OnAxisChanged(new AxisChangedEventArgs(AxisChangeTypes.Zoom, deltaMinimum, deltaMaximum)); + } + } } /// @@ -1885,7 +1973,7 @@ protected double CalculateActualInterval(double availableSize, double maxInterva // Function to remove 'double precision noise' // TODO: can this be improved - Func removeNoise = x => double.Parse(x.ToString("e14")); + Func removeNoise = x => double.Parse(x.ToString("e14", CultureInfo.InvariantCulture), CultureInfo.InvariantCulture); // decrease interval until interval count becomes less than maxIntervalCount while (true) @@ -1928,12 +2016,23 @@ protected double CalculateActualInterval(double availableSize, double maxInterva /// The instance containing the event data. protected virtual void OnAxisChanged(AxisChangedEventArgs args) { - this.UpdateActualMaxMin(); +#if DEBUG + using (PlotDiagnostics.Trace("Axis.OnAxisChanged.UpdateActualMaxMin")) +#endif + { + this.UpdateActualMaxMin(); + } var handler = this.AxisChanged; if (handler != null) { - handler(this, args); +#if DEBUG + int subscriberCount = handler.GetInvocationList().Length; + using (PlotDiagnostics.Trace("Axis.OnAxisChanged.HandlerInvoke", $"subs={subscriberCount}")) +#endif + { + handler(this, args); + } } } diff --git a/src/OxyPlot/OxyPlot/Axes/GumbelProbabilityAxis.cs b/src/OxyPlot/OxyPlot/Axes/GumbelProbabilityAxis.cs index 224549a8..fab9ef71 100644 --- a/src/OxyPlot/OxyPlot/Axes/GumbelProbabilityAxis.cs +++ b/src/OxyPlot/OxyPlot/Axes/GumbelProbabilityAxis.cs @@ -275,18 +275,21 @@ public override void ZoomAt(double factor, double x) /// internal override void UpdateActualMaxMin() { + // Let the base class resolve ActualMin/Max from ViewMaximum, Maximum, or + // CalculateActualMaximum() (and the same for Minimum). The base also runs + // CoerceActualMaxMin which can produce 0/100 sentinels for a still-NaN axis + // — values that are outside the probability domain (_epsilon, 0.999). + base.UpdateActualMaxMin(); - if (!double.IsNaN(this.ActualMinimum) || this.ActualMinimum <= _epsilon) + // Constrain to the valid probability range. The probability transform is + // undefined at 0 and 1; falling outside this range produces ±Infinity in + // PostInverseTransform and breaks rendering. + if (double.IsNaN(this.ActualMinimum) || this.ActualMinimum < _epsilon) { this.ActualMinimum = _epsilon; } - if (this.ActualMinimum < _epsilon) - { - this.ActualMinimum = _epsilon; - } - - if (!double.IsNaN(this.ActualMaximum) || this.ActualMaximum >= 0.999) + if (double.IsNaN(this.ActualMaximum) || this.ActualMaximum > 0.999) { this.ActualMaximum = 0.999; } @@ -296,9 +299,6 @@ internal override void UpdateActualMaxMin() this.ActualMinimum = _epsilon; this.ActualMaximum = 0.999; } - - base.UpdateActualMaxMin(); - } /// diff --git a/src/OxyPlot/OxyPlot/Axes/LogarithmicAxis.cs b/src/OxyPlot/OxyPlot/Axes/LogarithmicAxis.cs index 57ddf83b..747121bc 100644 --- a/src/OxyPlot/OxyPlot/Axes/LogarithmicAxis.cs +++ b/src/OxyPlot/OxyPlot/Axes/LogarithmicAxis.cs @@ -273,11 +273,22 @@ public override void ZoomAt(double factor, double x) /// A new IList containing the resulting values. internal IList PowList(IList logInput, bool clip = false) { - return - logInput.Where(item => !clip || !(item < this.LogClipMinimum)) - .TakeWhile(item => !clip || !(item > this.LogClipMaximum)) - .Select(item => Math.Pow(this.Base, item)) - .ToList(); + // Direct loop instead of Where().TakeWhile().Select().ToList() — the LINQ chain + // allocated three iterator state machines plus a List per call. Tick generation + // runs in every AdjustPlotMargins iteration, so this fires multiple times per + // render on log-axis plots. + var result = new List(logInput.Count); + for (int i = 0; i < logInput.Count; i++) + { + var item = logInput[i]; + if (clip) + { + if (item < this.LogClipMinimum) continue; + if (item > this.LogClipMaximum) break; // mirror TakeWhile semantics + } + result.Add(Math.Pow(this.Base, item)); + } + return result; } /// @@ -288,11 +299,18 @@ internal IList PowList(IList logInput, bool clip = false) /// A new IList containing the resulting values. internal IList LogList(IList input, bool clip = false) { - return - input.Where(item => !clip || !(item < this.ClipMinimum)) - .TakeWhile(item => !clip || !(item > this.ClipMaximum)) - .Select(item => Math.Log(item, this.Base)) - .ToList(); + var result = new List(input.Count); + for (int i = 0; i < input.Count; i++) + { + var item = input[i]; + if (clip) + { + if (item < this.ClipMinimum) continue; + if (item > this.ClipMaximum) break; + } + result.Add(Math.Log(item, this.Base)); + } + return result; } /// diff --git a/src/OxyPlot/OxyPlot/Axes/NormalProbabilityAxis.cs b/src/OxyPlot/OxyPlot/Axes/NormalProbabilityAxis.cs index 1596db2c..9410cda2 100644 --- a/src/OxyPlot/OxyPlot/Axes/NormalProbabilityAxis.cs +++ b/src/OxyPlot/OxyPlot/Axes/NormalProbabilityAxis.cs @@ -276,18 +276,21 @@ public override void ZoomAt(double factor, double x) /// internal override void UpdateActualMaxMin() { + // Let the base class resolve ActualMin/Max from ViewMaximum, Maximum, or + // CalculateActualMaximum() (and the same for Minimum). The base also runs + // CoerceActualMaxMin which can produce 0/100 sentinels for a still-NaN axis + // — values that are outside the probability domain (_epsilon, 0.999). + base.UpdateActualMaxMin(); - if (!double.IsNaN(this.ActualMinimum) || this.ActualMinimum <= _epsilon) + // Constrain to the valid probability range. The probability transform is + // undefined at 0 and 1; falling outside this range produces ±Infinity in + // PostInverseTransform and breaks rendering. + if (double.IsNaN(this.ActualMinimum) || this.ActualMinimum < _epsilon) { this.ActualMinimum = _epsilon; } - if (this.ActualMinimum < _epsilon) - { - this.ActualMinimum = _epsilon; - } - - if (!double.IsNaN(this.ActualMaximum) || this.ActualMaximum >= 0.999) + if (double.IsNaN(this.ActualMaximum) || this.ActualMaximum > 0.999) { this.ActualMaximum = 0.999; } @@ -297,9 +300,6 @@ internal override void UpdateActualMaxMin() this.ActualMinimum = _epsilon; this.ActualMaximum = 0.999; } - - base.UpdateActualMaxMin(); - } /// diff --git a/src/OxyPlot/OxyPlot/Graphics/ControllerBase.cs b/src/OxyPlot/OxyPlot/Graphics/ControllerBase.cs index e03d220d..8a8ab17f 100644 --- a/src/OxyPlot/OxyPlot/Graphics/ControllerBase.cs +++ b/src/OxyPlot/OxyPlot/Graphics/ControllerBase.cs @@ -54,6 +54,20 @@ protected ControllerBase() /// protected IList> TouchManipulators { get; private set; } + /// + /// Gets or sets a value indicating whether continue to run while + /// a mouse button is held (i.e., during pan / zoom-rectangle drag). The default is false. + /// + /// + /// When false (the default), hover manipulators — most importantly the tracker — are skipped + /// on every while any is active. + /// The tracker tooltip is not visible mid-drag anyway, and on large datasets its per-mouse-move + /// O(points) scan can saturate the UI thread and back up the pan/zoom render queue, producing + /// multi-second perceived lag. Suppressing hover during drag eliminates that cascade. + /// Set to true to restore the legacy behavior. + /// + public bool EnableHoverDuringDrag { get; set; } + /// /// Handles the specified gesture. /// @@ -168,9 +182,17 @@ public virtual bool HandleMouseMove(IView view, OxyMouseEventArgs args) m.Delta(args); } - foreach (var m in this.MouseHoverManipulators) + // Skip hover (tracker) manipulators while any mouse-down manipulator is active + // (i.e., pan or zoom-rectangle drag is in progress). The tracker tooltip is not + // visible mid-drag anyway, and on large datasets its per-mouse-move O(n) scan + // saturates the UI thread and backs up the pan/zoom render queue. Consumers that + // need the legacy always-on behavior can opt in via EnableHoverDuringDrag. + if (this.EnableHoverDuringDrag || this.MouseDownManipulators.Count == 0) { - m.Delta(args); + foreach (var m in this.MouseHoverManipulators) + { + m.Delta(args); + } } return args.Handled; @@ -202,6 +224,20 @@ public virtual bool HandleMouseUp(IView view, OxyMouseEventArgs args) this.MouseDownManipulators.Remove(m); } + // After the last drag manipulator finishes, fire one final hover delta so the + // tracker / crosshair / tooltip refreshes to the mouse-up position. Without this, + // the suppress-hover-during-drag optimization (HandleMouseMove above) leaves the + // tracker frozen at its pre-drag position until the user moves the mouse again. + // Skip when EnableHoverDuringDrag is set — that mode already delivered live + // updates throughout the drag, so a final tick would be redundant. + if (!this.EnableHoverDuringDrag && this.MouseDownManipulators.Count == 0) + { + foreach (var m in this.MouseHoverManipulators) + { + m.Delta(args); + } + } + return args.Handled; } } @@ -214,10 +250,32 @@ public virtual bool HandleMouseUp(IView view, OxyMouseEventArgs args) /// true if the event was handled. public virtual bool HandleMouseWheel(IView view, OxyMouseWheelEventArgs args) { - lock (this.GetSyncRoot(view)) +#if DEBUG + using (PlotDiagnostics.Trace("ControllerBase.HandleMouseWheel")) +#endif { - var command = this.GetCommand(new OxyMouseWheelGesture(args.ModifierKeys)); - return this.HandleCommand(command, view, args); +#if DEBUG + long lockT0 = PlotDiagnostics.IsActive ? System.Diagnostics.Stopwatch.GetTimestamp() : 0; +#endif + lock (this.GetSyncRoot(view)) + { +#if DEBUG + if (PlotDiagnostics.IsActive) + { + double lockMs = (System.Diagnostics.Stopwatch.GetTimestamp() - lockT0) * 1000.0 + / System.Diagnostics.Stopwatch.Frequency; + PlotDiagnostics.Log($"ControllerBase.HandleMouseWheel lockAcquired={lockMs:F2}ms"); + } +#endif + IViewCommand command; +#if DEBUG + using (PlotDiagnostics.Trace("ControllerBase.GetCommand(MouseWheelGesture)")) +#endif + { + command = this.GetCommand(new OxyMouseWheelGesture(args.ModifierKeys)); + } + return this.HandleCommand(command, view, args); + } } } @@ -507,7 +565,12 @@ protected virtual bool HandleCommand(IViewCommand command, IView view, OxyInputE return false; } - command.Execute(view, this, args); +#if DEBUG + using (PlotDiagnostics.Trace("ControllerBase.HandleCommand", command.GetType().Name)) +#endif + { + command.Execute(view, this, args); + } return args.Handled; } diff --git a/src/OxyPlot/OxyPlot/Graphics/PlotDiagnostics.cs b/src/OxyPlot/OxyPlot/Graphics/PlotDiagnostics.cs new file mode 100644 index 00000000..14577240 --- /dev/null +++ b/src/OxyPlot/OxyPlot/Graphics/PlotDiagnostics.cs @@ -0,0 +1,191 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2014 OxyPlot contributors +// +// +// Debug-only diagnostic helpers for tracing the full wheel-zoom stack. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OxyPlot +{ + /// + /// Debug-only diagnostic helpers for tracing the full wheel-zoom stack across the OxyPlot + /// core, the WPF view, the manipulator, the axes, the model update, and the per-series render. + /// + /// + /// + /// Mirrored from OxyPlot.Wpf.Plot.InvalidatePlotPhaseDiagnosticsEnabled. Consumers that + /// already toggle that flag automatically get the full stack trace. + /// + /// + /// All output is via and gated on + /// #if DEBUG; zero cost in Release builds. + /// + /// + /// Each wheel event opens a numbered scope (W#NNNN). Every traced method logs entry and exit + /// with elapsed-since-wheel-start time and method-local elapsed time, so one log can show: + /// + /// + /// The total wheel-event-to-pixels wall-clock time. + /// Where in the stack the time is consumed (manipulator vs. axis vs. model update vs. render). + /// Whether render-priority work runs before or after the next wheel event arrives. + /// + /// + public static class PlotDiagnostics + { +#if DEBUG + /// + /// Master toggle for the full wheel-zoom stack trace. When true, every traced method on + /// the wheel event path emits enter/exit lines to the debug console. + /// + /// + /// OxyPlot.Wpf.Plot.InvalidatePlotPhaseDiagnosticsEnabled mirrors to this flag; setting + /// it on the WPF side enables this on the core side too. + /// + public static volatile bool WheelTraceEnabled; + + private static long _globalWheelSeq; + + [System.ThreadStatic] + private static int _wheelSeq; + + [System.ThreadStatic] + private static long _wheelStartTicks; + + /// + /// Opens a new wheel-event scope: increments the global sequence number and resets the + /// per-event start clock. Call this exactly once at the WPF OnMouseWheel entry. + /// + /// The new wheel sequence number, or 0 if tracing is disabled. + public static int BeginWheel() + { + if (!WheelTraceEnabled) return 0; + _wheelSeq = (int)System.Threading.Interlocked.Increment(ref _globalWheelSeq); + _wheelStartTicks = System.Diagnostics.Stopwatch.GetTimestamp(); + return _wheelSeq; + } + + /// + /// Closes the current wheel-event scope on this thread: clears the per-thread sequence + /// number and start clock so subsequent unrelated calls (mouse-move, pan, render) don't + /// emit trace output attributed to the last wheel event. Call this exactly once at the + /// end of the WPF OnMouseWheel handler, paired with . + /// + public static void EndWheel() + { + _wheelSeq = 0; + _wheelStartTicks = 0; + } + + /// + /// Returns the current wheel sequence number for this thread, or 0 if no wheel scope is open. + /// + /// + /// Backed by a [ThreadStatic] field. Reads from any thread other than the one that + /// called (e.g. a background diagnostic logger or the WPF render + /// thread) always return 0. Intended for use only from the UI thread that processes the + /// wheel event. + /// + public static int CurrentWheelSeq => _wheelSeq; + + /// + /// Returns true if a wheel scope has been opened on the current thread and tracing is on. + /// Cheap; intended to gate the scope helpers below without the cost of building log strings. + /// + public static bool IsActive => WheelTraceEnabled && _wheelSeq != 0; + + /// + /// Milliseconds since was called on the current thread. Returns + /// -1 if no scope is open. + /// + public static double SinceWheelStartMs() + { + if (_wheelStartTicks == 0) return -1; + long delta = System.Diagnostics.Stopwatch.GetTimestamp() - _wheelStartTicks; + return delta * 1000.0 / System.Diagnostics.Stopwatch.Frequency; + } + + /// + /// Emits a single trace line in the form + /// [W#NNNN +TTTT.TTms] message. Cheap when is false. + /// + /// The message to emit. + public static void Log(string message) + { + if (!WheelTraceEnabled || _wheelSeq == 0) return; + System.Diagnostics.Debug.WriteLine( + $"[W#{_wheelSeq,4} +{SinceWheelStartMs(),8:F2}ms] {message}"); + } + + /// + /// Emits an "ENTER" trace line and returns a disposable that emits a matching + /// "EXIT methodLocalMs=X.XX" line on disposal. Use with using: + /// using (PlotDiagnostics.Trace("Foo.Method")) { ... } + /// + /// A short tag identifying the method, e.g. "Axis.ZoomAt". + /// Optional extra context appended to the ENTER line. + public static System.IDisposable Trace(string methodTag, string extra = null) + { + if (!WheelTraceEnabled || _wheelSeq == 0) return _noopScope; + return new TraceScope(methodTag, extra); + } + + private static readonly System.IDisposable _noopScope = new NoopScope(); + + private sealed class NoopScope : System.IDisposable + { + public void Dispose() { } + } + + private sealed class TraceScope : System.IDisposable + { + private readonly string _tag; + private readonly long _t0; + + public TraceScope(string tag, string extra) + { + _tag = tag; + _t0 = System.Diagnostics.Stopwatch.GetTimestamp(); + System.Diagnostics.Debug.WriteLine( + string.IsNullOrEmpty(extra) + ? $"[W#{_wheelSeq,4} +{SinceWheelStartMs(),8:F2}ms] {_tag} ENTER" + : $"[W#{_wheelSeq,4} +{SinceWheelStartMs(),8:F2}ms] {_tag} ENTER {extra}"); + } + + public void Dispose() + { + long ticks = System.Diagnostics.Stopwatch.GetTimestamp() - _t0; + double ms = ticks * 1000.0 / System.Diagnostics.Stopwatch.Frequency; + System.Diagnostics.Debug.WriteLine( + $"[W#{_wheelSeq,4} +{SinceWheelStartMs(),8:F2}ms] {_tag} EXIT {ms,8:F2}ms"); + } + } +#else + /// + /// No-op in Release builds. + /// + public static int BeginWheel() => 0; + + /// + /// No-op in Release builds. + /// + public static void EndWheel() { } + + /// + /// No-op in Release builds. + /// + public static bool IsActive => false; + + /// + /// No-op in Release builds. + /// + public static void Log(string message) { } + + /// + /// No-op in Release builds. + /// + public static System.IDisposable Trace(string methodTag, string extra = null) => null; +#endif + } +} diff --git a/src/OxyPlot/OxyPlot/PlotController/Manipulators/ZoomRectangleManipulator.cs b/src/OxyPlot/OxyPlot/PlotController/Manipulators/ZoomRectangleManipulator.cs index 7e056f7d..b6538aed 100644 --- a/src/OxyPlot/OxyPlot/PlotController/Manipulators/ZoomRectangleManipulator.cs +++ b/src/OxyPlot/OxyPlot/PlotController/Manipulators/ZoomRectangleManipulator.cs @@ -65,7 +65,9 @@ public override void Completed(OxyMouseEventArgs e) this.YAxis.Zoom(p0.Y, p1.Y); } - this.PlotView.InvalidatePlot(); + // Zoom only changes axis range, not series data, so updateData=false avoids + // a redundant per-series UpdateData walk on every zoom-rectangle release. + this.PlotView.InvalidatePlot(false); } e.Handled = true; diff --git a/src/OxyPlot/OxyPlot/PlotController/Manipulators/ZoomStepManipulator.cs b/src/OxyPlot/OxyPlot/PlotController/Manipulators/ZoomStepManipulator.cs index 42165d36..18e9057a 100644 --- a/src/OxyPlot/OxyPlot/PlotController/Manipulators/ZoomStepManipulator.cs +++ b/src/OxyPlot/OxyPlot/PlotController/Manipulators/ZoomStepManipulator.cs @@ -39,45 +39,65 @@ public ZoomStepManipulator(IPlotView plotView) /// The instance containing the event data. public override void Started(OxyMouseEventArgs e) { - base.Started(e); +#if DEBUG + using (PlotDiagnostics.Trace("ZoomStepManipulator.Started")) +#endif + { + base.Started(e); - var isZoomEnabled = (this.XAxis != null && this.XAxis.IsZoomEnabled) - || (this.YAxis != null && this.YAxis.IsZoomEnabled); + var isZoomEnabled = (this.XAxis != null && this.XAxis.IsZoomEnabled) + || (this.YAxis != null && this.YAxis.IsZoomEnabled); - if (!isZoomEnabled) - { - return; - } + if (!isZoomEnabled) + { + return; + } - var current = this.InverseTransform(e.Position.X, e.Position.Y); + var current = this.InverseTransform(e.Position.X, e.Position.Y); - var scale = this.Step; - if (this.FineControl) - { - scale *= 3; - } + var scale = this.Step; + if (this.FineControl) + { + scale *= 3; + } - if (scale > 0) - { - scale = 1 + scale; - } - else - { - scale = 1.0 / (1 - scale); - } + if (scale > 0) + { + scale = 1 + scale; + } + else + { + scale = 1.0 / (1 - scale); + } - if (this.XAxis != null) - { - this.XAxis.ZoomAt(scale, current.X); - } + if (this.XAxis != null) + { +#if DEBUG + using (PlotDiagnostics.Trace("ZoomStepManipulator.XAxis.ZoomAt", $"scale={scale:F4}")) +#endif + { + this.XAxis.ZoomAt(scale, current.X); + } + } - if (this.YAxis != null) - { - this.YAxis.ZoomAt(scale, current.Y); - } + if (this.YAxis != null) + { +#if DEBUG + using (PlotDiagnostics.Trace("ZoomStepManipulator.YAxis.ZoomAt", $"scale={scale:F4}")) +#endif + { + this.YAxis.ZoomAt(scale, current.Y); + } + } - this.PlotView.InvalidatePlot(false); - e.Handled = true; +#if DEBUG + using (PlotDiagnostics.Trace("ZoomStepManipulator.PlotView.InvalidatePlot")) +#endif + { + this.PlotView.InvalidatePlot(false); + } + e.Handled = true; + } } } } diff --git a/src/OxyPlot/OxyPlot/PlotController/PlotCommands.cs b/src/OxyPlot/OxyPlot/PlotController/PlotCommands.cs index f7244361..e968664c 100644 --- a/src/OxyPlot/OxyPlot/PlotController/PlotCommands.cs +++ b/src/OxyPlot/OxyPlot/PlotController/PlotCommands.cs @@ -255,8 +255,14 @@ private static void HandleZoomAt(IPlotView view, OxyMouseEventArgs args, double /// The zoom speed factor. Default value is 1. private static void HandleZoomByWheel(IPlotView view, OxyMouseWheelEventArgs args, double factor = 1) { - var m = new ZoomStepManipulator(view) { Step = args.Delta * 0.001 * factor, FineControl = args.IsControlDown }; - m.Started(args); +#if DEBUG + using (PlotDiagnostics.Trace("PlotCommands.HandleZoomByWheel", + $"step={args.Delta * 0.001 * factor:F4} fineCtl={args.IsControlDown}")) +#endif + { + var m = new ZoomStepManipulator(view) { Step = args.Delta * 0.001 * factor, FineControl = args.IsControlDown }; + m.Started(args); + } } /// diff --git a/src/OxyPlot/OxyPlot/PlotModel/PlotModel.Rendering.cs b/src/OxyPlot/OxyPlot/PlotModel/PlotModel.Rendering.cs index abb17337..7bcbf8b4 100644 --- a/src/OxyPlot/OxyPlot/PlotModel/PlotModel.Rendering.cs +++ b/src/OxyPlot/OxyPlot/PlotModel/PlotModel.Rendering.cs @@ -80,37 +80,87 @@ protected virtual void RenderOverride(IRenderContext rc, OxyRect rect) l.EnsureLegendProperties(); } - for (var i = 0; i < 10; i++) // make we sure we don't loop infinitely +#if DEBUG + int marginIters = 0; + using (PlotDiagnostics.Trace("PlotModel.Render.PlotAreaLayout")) +#endif { - this.UpdatePlotArea(rc); - this.UpdateAxisTransforms(); - this.UpdateIntervals(); - - if (!this.AdjustPlotMargins(rc)) + for (var i = 0; i < 10; i++) // make we sure we don't loop infinitely + { + this.UpdatePlotArea(rc); + this.UpdateAxisTransforms(); + this.UpdateIntervals(); + + if (!this.AdjustPlotMargins(rc)) + { + break; + } +#if DEBUG + marginIters++; +#endif + } +#if DEBUG + if (PlotDiagnostics.IsActive) { - break; + PlotDiagnostics.Log($"PlotModel.Render.PlotAreaLayout marginIters={marginIters + 1}"); } +#endif } if (this.PlotType == PlotType.Cartesian) { - this.EnforceCartesianTransforms(); - this.UpdateIntervals(); +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Render.EnforceCartesian")) +#endif + { + this.EnforceCartesianTransforms(); + this.UpdateIntervals(); + } } - this.RenderBackgrounds(rc); - this.RenderAnnotations(rc, AnnotationLayer.BelowAxes); - this.RenderAxes(rc, AxisLayer.BelowSeries); - this.RenderAnnotations(rc, AnnotationLayer.BelowSeries); - this.RenderSeries(rc); - this.RenderAnnotations(rc, AnnotationLayer.AboveSeries); - this.RenderTitle(rc); - this.RenderBox(rc); - this.RenderAxes(rc, AxisLayer.AboveSeries); +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Render.Backgrounds")) +#endif + { this.RenderBackgrounds(rc); } +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Render.Annotations(BelowAxes)")) +#endif + { this.RenderAnnotations(rc, AnnotationLayer.BelowAxes); } +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Render.Axes(BelowSeries)")) +#endif + { this.RenderAxes(rc, AxisLayer.BelowSeries); } +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Render.Annotations(BelowSeries)")) +#endif + { this.RenderAnnotations(rc, AnnotationLayer.BelowSeries); } +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Render.Series", $"count={this.Series.Count}")) +#endif + { this.RenderSeries(rc); } +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Render.Annotations(AboveSeries)")) +#endif + { this.RenderAnnotations(rc, AnnotationLayer.AboveSeries); } +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Render.Title")) +#endif + { this.RenderTitle(rc); } +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Render.Box")) +#endif + { this.RenderBox(rc); } +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Render.Axes(AboveSeries)")) +#endif + { this.RenderAxes(rc, AxisLayer.AboveSeries); } if (this.IsLegendVisible) { - this.RenderLegends(rc); +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Render.Legends")) +#endif + { this.RenderLegends(rc); } } if (rc.ClipCount != initialClipCount + 1) @@ -162,11 +212,18 @@ private void RenderErrorMessage(IRenderContext rc, string title, string errorMes /// true if the margins were adjusted. private bool AdjustPlotMargins(IRenderContext rc) { + // Only re-measure axes whose transform parameters have changed since the last + // pass. The stabilization loop in RenderOverride may call AdjustPlotMargins up + // to 10 times — without this guard, every call re-measures every visible axis, + // which iterates ticks, formats labels, and calls rc.MeasureText for each tick. + // Comparison-based dirty detection (vs. an explicit dirty flag) avoids the risk + // of missing a code path that mutates the axis. foreach (var axis in this.Axes) { - if (axis.IsAxisVisible) + if (axis.IsAxisVisible && axis.NeedsMeasure()) { axis.Measure(rc); + axis.MarkMeasured(); } } diff --git a/src/OxyPlot/OxyPlot/PlotModel/PlotModel.cs b/src/OxyPlot/OxyPlot/PlotModel/PlotModel.cs index fae13ce5..311d619d 100644 --- a/src/OxyPlot/OxyPlot/PlotModel/PlotModel.cs +++ b/src/OxyPlot/OxyPlot/PlotModel/PlotModel.cs @@ -714,8 +714,15 @@ public Series.Series GetSeriesFromPoint(ScreenPoint point, double limit = 100) { double mindist = double.MaxValue; Series.Series nearestSeries = null; - foreach (var series in this.Series.Reverse().Where(s => s.IsVisible)) + // Iterate in reverse via index instead of LINQ Reverse().Where(). Reverse() on a + // Collection allocates an iterator on every mouse-move (60Hz), creating + // continuous Gen0 GC pressure. The indexed loop is identical in semantics — visit + // the topmost (last-added) series first — and zero-allocation. + for (int i = this.Series.Count - 1; i >= 0; i--) { + var series = this.Series[i]; + if (!series.IsVisible || !series.IsHitTestEnabled) continue; + var thr = series.GetNearestPoint(point, true) ?? series.GetNearestPoint(point, false); if (thr == null) @@ -799,54 +806,95 @@ public Exception GetLastPlotException() /// if set to true , all data collections will be updated. void IPlotModel.Update(bool updateData) { - lock (this.SyncRoot) +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Update", $"updateData={updateData} series={this.Series.Count} axes={this.Axes.Count}")) +#endif { - try + lock (this.SyncRoot) { - this.lastPlotException = null; - this.OnUpdating(); + try + { + this.lastPlotException = null; + this.OnUpdating(); - // Updates the default axes - this.EnsureDefaultAxes(); + // Updates the default axes +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Update.EnsureDefaultAxes")) +#endif + { + this.EnsureDefaultAxes(); + } - // Update data of the series - if (updateData || !this.isDataUpdated) - { - foreach (var s in this.Series) + // Update data of the series + if (updateData || !this.isDataUpdated) { - if (s.IsVisible) +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Update.SeriesUpdateData")) +#endif { - s.UpdateData(); + foreach (var s in this.Series) + { + if (s.IsVisible) + { + s.UpdateData(); + } + } } + + this.isDataUpdated = true; } - this.isDataUpdated = true; - } + // Updates bar series managers and associated category axes +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Update.UpdateBarSeriesManagers")) +#endif + { + this.UpdateBarSeriesManagers(); + } - // Updates bar series managers and associated category axes - this.UpdateBarSeriesManagers(); + // Update the max and min of the axes +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Update.UpdateMaxMin")) +#endif + { + this.UpdateMaxMin(updateData); + } - // Update the max and min of the axes - this.UpdateMaxMin(updateData); + // Update category axes that are not managed by bar series managers +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Update.UpdateUnmanagedCategoryAxes")) +#endif + { + this.UpdateUnmanagedCategoryAxes(); + } - // Update category axes that are not managed by bar series managers - this.UpdateUnmanagedCategoryAxes(); + // Update undefined colors +#if DEBUG + using (PlotDiagnostics.Trace("PlotModel.Update.ResetDefaultColor+SetDefaultValues")) +#endif + { + this.ResetDefaultColor(); + foreach (var s in this.Series) + { + if (this.AssignColorsToInvisibleSeries || s.IsVisible) + { + s.SetDefaultValues(); + } + } + } - // Update undefined colors - this.ResetDefaultColor(); - foreach (var s in this.Series) - { - if (this.AssignColorsToInvisibleSeries || s.IsVisible) +#if DEBUG + int updatedSubs = this.Updated?.GetInvocationList().Length ?? 0; + using (PlotDiagnostics.Trace("PlotModel.Update.OnUpdated", $"subs={updatedSubs}")) +#endif { - s.SetDefaultValues(); + this.OnUpdated(); } } - - this.OnUpdated(); - } - catch (Exception e) - { - this.lastPlotException = e; + catch (Exception e) + { + this.lastPlotException = e; + } } } } diff --git a/src/OxyPlot/OxyPlot/Series/AreaSeries.cs b/src/OxyPlot/OxyPlot/Series/AreaSeries.cs index c6c05fad..c44d92dd 100644 --- a/src/OxyPlot/OxyPlot/Series/AreaSeries.cs +++ b/src/OxyPlot/OxyPlot/Series/AreaSeries.cs @@ -235,8 +235,9 @@ public override void Render(IRenderContext rc) // determine render range var xmin = this.XAxis.ClipMinimum; xmax = this.XAxis.ClipMaximum; - this.WindowStartIndex = this.UpdateWindowStartIndex(actualPoints, point => point.X, xmin, this.WindowStartIndex); - this.WindowStartIndex2 = this.UpdateWindowStartIndex(actualPoints2, point => point.X, xmin, this.WindowStartIndex2); + // Specialised IList overload — see XYAxisSeries.UpdateWindowStartIndex. + this.WindowStartIndex = this.UpdateWindowStartIndex(actualPoints, xmin, this.WindowStartIndex); + this.WindowStartIndex2 = this.UpdateWindowStartIndex(actualPoints2, xmin, this.WindowStartIndex2); startIdx = this.WindowStartIndex; startIdx2 = this.WindowStartIndex2; diff --git a/src/OxyPlot/OxyPlot/Series/LineSeries.cs b/src/OxyPlot/OxyPlot/Series/LineSeries.cs index 87810a45..3b81cdbd 100644 --- a/src/OxyPlot/OxyPlot/Series/LineSeries.cs +++ b/src/OxyPlot/OxyPlot/Series/LineSeries.cs @@ -45,6 +45,20 @@ public class LineSeries : DataPointSeries /// private bool decimationActive; + /// + /// Single-element marker-size array passed to IRenderContext.DrawMarkers. + /// Cached so we don't allocate a new double[] on every render call. Rebuilt + /// when changes. + /// + private double[] markerSizeArray; + + /// + /// The value reflected in . + /// Compared on each render to detect a marker-size change and rebuild the array. + /// NaN sentinel forces initialization on first use. + /// + private double markerSizeArrayValue = double.NaN; + /// /// The default color. /// @@ -215,6 +229,23 @@ public LineSeries() /// Type of interpolation algorithm. public IInterpolationAlgorithm InterpolationAlgorithm { get; set; } + /// + /// Gets or sets the maximum number of points per render segment for which spline + /// smoothing () is applied. When set to a positive + /// value, skips smoothing for segments larger than + /// this threshold and renders the raw decimated line directly. The default 0 + /// disables the threshold (smoothing always runs when an interpolation algorithm is + /// set). Recommended value for large-data plots: 1000. + /// + /// + /// Spline smoothing is O(N) on its input plus a fresh allocation of the smoothed + /// point list every render. On a 100k-point segment this is a noticeable per-frame + /// cost; on dense telemetry data it is rarely visible since the smoothing operates + /// on already-decimated screen points. Setting MaxSmoothingPoints = 1000 turns + /// off smoothing automatically once the visible point count crosses that threshold. + /// + public int MaxSmoothingPoints { get; set; } + /// /// Gets or sets the thickness of the curve. /// @@ -336,20 +367,26 @@ public override void Render(IRenderContext rc) return; } - this.VerifyAxes(); +#if DEBUG + using (PlotDiagnostics.Trace("LineSeries.Render", + $"title=\"{this.Title ?? "(no title)"}\" pts={actualPoints.Count}")) +#endif + { + this.VerifyAxes(); - this.RenderPoints(rc, actualPoints); + this.RenderPoints(rc, actualPoints); - if (this.LabelFormatString != null) - { - // render point labels (not optimized for performance) - this.RenderPointLabels(rc); - } + if (this.LabelFormatString != null) + { + // render point labels (not optimized for performance) + this.RenderPointLabels(rc); + } - if (this.LineLegendPosition != LineLegendPosition.None && !string.IsNullOrEmpty(this.Title)) - { - // renders a legend on the line - this.RenderLegendOnLine(rc); + if (this.LineLegendPosition != LineLegendPosition.None && !string.IsNullOrEmpty(this.Title)) + { + // renders a legend on the line + this.RenderLegendOnLine(rc); + } } } @@ -447,33 +484,61 @@ protected void RenderPoints(IRenderContext rc, IList points) var broken = areBrokenLinesRendered ? new List(2) : null; int startIdx = 0; + int endIdx = points.Count; double xmax = double.MaxValue; if (this.IsXMonotonic) { var xmin = this.XAxis.ClipMinimum; xmax = this.XAxis.ClipMaximum; - this.WindowStartIndex = this.UpdateWindowStartIndex(points, point => point.X, xmin, this.WindowStartIndex); + // Specialised IList overload — no Func delegate, the + // JIT inlines the .x field read on every binary-search step. + this.WindowStartIndex = this.UpdateWindowStartIndex(points, xmin, this.WindowStartIndex); startIdx = this.WindowStartIndex; + + // Symmetric upper bound: cap outer-loop iteration at the visible window edge + // for the slow fallback path (custom decimator, non-base-10 log axis, + // probability axes). The fused path already exits cleanly when X > xmax inside + // FusedExtractAndDecimate, so this bound only tightens the worst case for the + // fallback — and never affects correctness because ExtractNextContiguousLineSegment + // also returns false when X > xmax. + this.WindowEndIndex = this.UpdateWindowEndIndex(points, xmax, this.WindowEndIndex); + if (this.WindowEndIndex >= 0 && this.WindowEndIndex < points.Count) + { + // Add one for line-continuity past the right edge (matches how Window + // StartIndex steps back by one for left-edge continuity). + endIdx = Math.Min(points.Count, this.WindowEndIndex + 2); + } } // Determine if fused extract-decimate-transform is possible. - // Requires: rendering to screen, monotonic X, standard decimator, - // and both axes must use the base linear transform ((x - offset) * scale). - // Axes that override Transform (LogarithmicAxis, NormalProbabilityAxis, - // GumbelProbabilityAxis) fall back to the existing pipeline. + // Requires: rendering to screen, monotonic X, standard decimator. The fused path + // supports linear axes plus base-10 LogarithmicAxis (covers the overwhelming + // common case; LogarithmicAxis.Base defaults to 10). Non-base-10 log axes, + // GumbelProbabilityAxis, and NormalProbabilityAxis use transforms that cannot be + // cheaply inlined and fall back to the slow path. bool useFused = rc.RendersToScreen && this.IsXMonotonic && this.Decimator == OxyPlot.Decimator.Decimate - && !this.XAxis.IsLogarithmic() && !(this.XAxis is GumbelProbabilityAxis) && !(this.XAxis is NormalProbabilityAxis) - && !this.YAxis.IsLogarithmic() && !(this.YAxis is GumbelProbabilityAxis) - && !(this.YAxis is NormalProbabilityAxis); + && !(this.YAxis is NormalProbabilityAxis) + && !(this.XAxis is LogarithmicAxis xLogAxisCheck && xLogAxisCheck.Base != 10) + && !(this.YAxis is LogarithmicAxis yLogAxisCheck && yLogAxisCheck.Base != 10); this.decimationActive = useFused || this.Decimator != null; +#if DEBUG + if (PlotDiagnostics.IsActive) + { + PlotDiagnostics.Log( + $"LineSeries.RenderPoints title=\"{this.Title ?? "(no title)"}\" useFused={useFused} " + + $"isXMonotonic={this.IsXMonotonic} decimator={(this.Decimator == OxyPlot.Decimator.Decimate ? "std" : (this.Decimator == null ? "none" : "custom"))} " + + $"rendersToScreen={rc.RendersToScreen} startIdx={startIdx} pts={points.Count}"); + } +#endif + if (useFused) { // Fast path: single-pass fused extract + decimate + transform. @@ -516,7 +581,11 @@ protected void RenderPoints(IRenderContext rc, IList points) this.contiguousScreenPointsBuffer = new List(points.Count); } - for (int i = startIdx; i < points.Count; i++) + // Cap outer iteration at endIdx (== WindowEndIndex+2 for monotonic, points.Count + // otherwise). For non-monotonic data we still scan the full collection because + // X is unsorted and ExtractNextContiguousLineSegment's internal clipCount is + // the only safe terminator. + for (int i = startIdx; i < endIdx; i++) { if (!this.ExtractNextContiguousLineSegment(points, ref i, ref lastValidPoint, xmax, broken, this.contiguousScreenPointsBuffer)) { @@ -585,7 +654,19 @@ protected bool ExtractNextContiguousLineSegment( { DataPoint currentPoint = default(DataPoint); bool hasValidPoint = false; - + + // Detect the fast-path conditions once, outside the per-point loop. When both axes + // use default filters and no FilterFunction is set (the common case for telemetry + // data), validity reduces to a NaN/Infinity check that can be inlined as a struct + // comparison rather than a virtual IsValidPoint dispatch — multiplied by N points + // this is a measurable speedup for large datasets in the fallback path. + bool fastValidity = this.XAxis != null && this.YAxis != null + && this.XAxis.FilterFunction == null && this.YAxis.FilterFunction == null + && this.XAxis.FilterMinValue == double.MinValue + && this.XAxis.FilterMaxValue == double.MaxValue + && this.YAxis.FilterMinValue == double.MinValue + && this.YAxis.FilterMaxValue == double.MaxValue; + // Skip all undefined points for (; pointIdx < points.Count; pointIdx++) { @@ -594,9 +675,12 @@ protected bool ExtractNextContiguousLineSegment( { return false; } - + // ReSharper disable once AssignmentInConditionalExpression - if (hasValidPoint = this.IsValidPoint(currentPoint)) + bool isValid = fastValidity + ? IsFiniteFast(currentPoint.X) && IsFiniteFast(currentPoint.Y) + : this.IsValidPoint(currentPoint); + if (hasValidPoint = isValid) { break; } @@ -630,7 +714,10 @@ protected bool ExtractNextContiguousLineSegment( { break; } - if (!this.IsValidPoint(currentPoint)) + bool isValidLoop = fastValidity + ? IsFiniteFast(currentPoint.X) && IsFiniteFast(currentPoint.Y) + : this.IsValidPoint(currentPoint); + if (!isValidLoop) { break; } @@ -644,6 +731,25 @@ protected bool ExtractNextContiguousLineSegment( return true; } + /// + /// Inlinable finite-value check used by the validity-fast-path in + /// . Equivalent to + /// !double.IsNaN(value) && !double.IsInfinity(value) but written as a + /// pair of struct comparisons so the JIT can inline it inside hot loops. + /// + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + private static bool IsFiniteFast(double value) + { + // value == value rejects NaN; the bound check rejects ±Infinity. The constants are + // double.MaxValue / double.MinValue so finite values pass and infinities fail. + // CS1718 suppression: the self-comparison is intentional — that's the canonical + // NaN check; mirrors Axis.IsValidValue. +#pragma warning disable 1718 + // ReSharper disable once CompareOfFloatsByEqualityOperator + return value == value && value <= double.MaxValue && value >= double.MinValue; +#pragma warning restore 1718 + } + /// /// Single-pass fused extraction, decimation, and transformation. /// Computes pixel columns from data coordinates and only transforms the 1-4 surviving @@ -669,15 +775,28 @@ private bool FusedExtractAndDecimate( } if (!hasValidPoint) return false; - // Cache axis transform parameters for inline computation. - // Only called for linear axes (base Axis.Transform: (x - offset) * scale). + // Cache axis transform parameters for inline computation. Linear axes use the + // base Axis.Transform formula (v - offset) * scale; logarithmic axes use the + // same formula composed with Math.Log10. The xIsLog/yIsLog booleans are captured + // by the local functions below — the resulting per-point branch is far cheaper + // than the virtual Transform() call it replaces (~10ns → ~1ns per point). + // IsValidPoint already filters non-positive values when an axis is logarithmic, + // so Math.Log10 is never called on invalid inputs here. + // + // Implicit coupling with the useFused gate above: if xIsLog or yIsLog is true, + // the gate has already verified Base == 10 (LogarithmicAxis subclasses with a + // non-10 base fall through to the slow path). If a future axis subclass overrides + // IsLogarithmic() to return true without honoring the Base==10 contract, the + // gate must be updated alongside this inline. + bool xIsLog = this.XAxis.IsLogarithmic(); + bool yIsLog = this.YAxis.IsLogarithmic(); double xOffset = this.XAxis.Offset; double xScale = this.XAxis.Scale; double yOffset = this.YAxis.Offset; double yScale = this.YAxis.Scale; - double TransformX(double v) => (v - xOffset) * xScale; - double TransformY(double v) => (v - yOffset) * yScale; + double TransformX(double v) => xIsLog ? (System.Math.Log10(v) - xOffset) * xScale : (v - xOffset) * xScale; + double TransformY(double v) => yIsLog ? (System.Math.Log10(v) - yOffset) * yScale : (v - yOffset) * yScale; // First valid point double firstSX = TransformX(currentPoint.X); @@ -741,11 +860,25 @@ private bool FusedExtractAndDecimate( /// The render context. protected void RenderPointLabels(IRenderContext rc) { - int index = -1; - foreach (var point in this.ActualPoints) + // Restrict label rendering to the visible window for monotonic series. On a + // 100k-point dataset, labels for off-screen points were previously formatted + // and submitted to DrawText anyway — even though they would clip outside the + // plot area. The window indices were already computed by RenderPoints upstream. + var actualPoints = this.ActualPoints; + int startIdx = 0; + int endIdx = actualPoints.Count; + if (this.IsXMonotonic) { - index++; + startIdx = Math.Max(0, this.WindowStartIndex); + if (this.WindowEndIndex >= 0 && this.WindowEndIndex < actualPoints.Count) + { + endIdx = Math.Min(actualPoints.Count, this.WindowEndIndex + 2); + } + } + for (int index = startIdx; index < endIdx; index++) + { + var point = actualPoints[index]; if (!this.IsValidPoint(point)) { continue; @@ -846,9 +979,19 @@ protected virtual void RenderLineAndMarkers(IRenderContext rc, IList 0 && pointsToRender.Count > this.MaxSmoothingPoints) + { + // Smoothing skipped — the raw points are used as-is. + } + else + { + var resampledPoints = ScreenPointHelper.ResamplePoints(pointsToRender, this.MinimumSegmentLength); + screenPoints = this.InterpolationAlgorithm.CreateSpline(resampledPoints, false, 0.25); + } } // clip the line segments with the clipping rectangle @@ -861,16 +1004,25 @@ protected virtual void RenderLineAndMarkers(IRenderContext rc, IList 0 ? this.Transform(this.MinX, this.MinY) : default(ScreenPoint); + // Reuse the cached single-element size array across renders; only rebuild when + // MarkerSize actually changes. Eliminates a per-render-per-series double[] + // allocation that adds up across many-series plots. + if (this.markerSizeArray == null || this.markerSizeArrayValue != this.MarkerSize) + { + this.markerSizeArray = new[] { this.MarkerSize }; + this.markerSizeArrayValue = this.MarkerSize; + } + rc.DrawMarkers( - pointsToRender, - this.MarkerType, - this.MarkerOutline, - new[] { this.MarkerSize }, - this.ActualMarkerFill, - this.MarkerStroke, - this.MarkerStrokeThickness, + pointsToRender, + this.MarkerType, + this.MarkerOutline, + this.markerSizeArray, + this.ActualMarkerFill, + this.MarkerStroke, + this.MarkerStrokeThickness, this.EdgeRenderingMode, - this.MarkerResolution, + this.MarkerResolution, markerBinOffset); } } diff --git a/src/OxyPlot/OxyPlot/Series/Series.cs b/src/OxyPlot/OxyPlot/Series/Series.cs index 3286714c..ee64cf9e 100644 --- a/src/OxyPlot/OxyPlot/Series/Series.cs +++ b/src/OxyPlot/OxyPlot/Series/Series.cs @@ -23,6 +23,7 @@ public abstract class Series : PlotElement protected Series() { this.IsVisible = true; + this.IsHitTestEnabled = true; this.Background = OxyColors.Undefined; this.RenderInLegend = true; } @@ -38,6 +39,23 @@ protected Series() /// public bool IsVisible { get; set; } + /// + /// Gets or sets a value indicating whether this series participates in tracker hit-tests. The default is true. + /// + /// + /// Set to false for dense or decorative series where per-point hit-testing has no + /// diagnostic value (e.g. MCMC chain traces, overlay reference lines). When disabled, + /// returns null immediately and + /// skips the series, so the O(n) nearest-point + /// scan does not run on every mouse move for this series. This is a tracker-routing flag + /// only; it does not affect rendering and does not fire PropertyChanged. Consumers wiring + /// undo-redo through PropertyChanged on the WPF wrapper's DependencyProperty + /// (OxyPlot.Wpf.Series.IsHitTestEnabled) get correct undo behavior automatically; + /// consumers that mutate this flag on the core instance directly + /// must record state transitions externally — this property is intentionally silent. + /// + public bool IsHitTestEnabled { get; set; } + /// /// Gets or sets the title of the series. The default is null. /// @@ -153,6 +171,11 @@ public virtual TrackerHitResult GetNearestPoint(ScreenPoint point, bool interpol /// protected override HitTestResult HitTestOverride(HitTestArguments args) { + if (!this.IsHitTestEnabled) + { + return null; + } + var thr = this.GetNearestPoint(args.Point, true) ?? this.GetNearestPoint(args.Point, false); if (thr != null) diff --git a/src/OxyPlot/OxyPlot/Series/StairStepSeries.cs b/src/OxyPlot/OxyPlot/Series/StairStepSeries.cs index 189efce5..518a7db9 100644 --- a/src/OxyPlot/OxyPlot/Series/StairStepSeries.cs +++ b/src/OxyPlot/OxyPlot/Series/StairStepSeries.cs @@ -232,7 +232,8 @@ public override void Render(IRenderContext rc) double xClipMin = this.XAxis.ClipMinimum; xClipMax = this.XAxis.ClipMaximum; - this.WindowStartIndex = this.UpdateWindowStartIndex(points, point => point.X, xClipMin, this.WindowStartIndex); + // Specialised IList overload — see XYAxisSeries.UpdateWindowStartIndex. + this.WindowStartIndex = this.UpdateWindowStartIndex(points, xClipMin, this.WindowStartIndex); offset = this.WindowStartIndex; } diff --git a/src/OxyPlot/OxyPlot/Series/XYAxisSeries.cs b/src/OxyPlot/OxyPlot/Series/XYAxisSeries.cs index 4b661c7c..c83b4391 100644 --- a/src/OxyPlot/OxyPlot/Series/XYAxisSeries.cs +++ b/src/OxyPlot/OxyPlot/Series/XYAxisSeries.cs @@ -101,6 +101,17 @@ protected XYAxisSeries() /// protected int WindowStartIndex { get; set; } + /// + /// Gets or sets the last visible window end position in the data points collection + /// (inclusive). For series, this is computed alongside + /// by symmetric bisect on the data X axis. Series may + /// use it as an explicit upper bound on render-time iteration, eliminating O(N) + /// behaviour when only a small window is visible. Defaults to + /// (no upper bound) so series that don't compute it fall back to the existing + /// per-point clip-count termination. + /// + protected int WindowEndIndex { get; set; } = int.MaxValue; + /// public override OxyRect GetClippingRect() { @@ -273,7 +284,19 @@ protected TrackerHitResult GetNearestInterpolatedPointInternal(List p if (minimumDistance < double.MaxValue) { - var item = this.GetItem((int)Math.Round(index)); + // GetItem may dereference the underlying ItemsSource at the captured index; + // if the source mutated between scan and this lookup (concurrent producer), + // the index can be stale. Treat that as "no item" rather than propagating + // the exception out of the hit-test path. + object item; + try + { + item = this.GetItem((int)Math.Round(index)); + } + catch (System.ArgumentOutOfRangeException) + { + item = null; + } return new TrackerHitResult { Series = this, @@ -314,32 +337,283 @@ protected TrackerHitResult GetNearestPointInternal(IEnumerable points double index = -1; double minimumDistance = double.MaxValue; - int i = startIdx; - foreach (var p in points.Skip(startIdx)) + + // Fast path for IList (the common case: series points are stored in a List). + // Indexed access is both slightly faster than a LINQ iterator state machine and, more + // importantly, does not throw InvalidOperationException if the underlying collection + // is mutated on another thread during the scan. + // + // Concurrent mutation (still unsafe for List in general, but documented as a rare + // real-world scenario in OxyPlot upstream issue #1482) is handled with two layers of + // defense: (1) re-read list.Count on every iteration so a shrink terminates the loop + // cleanly, and (2) catch ArgumentOutOfRangeException from the indexer for the narrow + // window between the bounds check and the element access. Both combined let the hit- + // test survive a race without bubbling an exception up to the controller. + // + // Fallback for arbitrary IEnumerable: snapshot to an array once at entry. + // This avoids the thread-unsafe `foreach (var p in points.Skip(startIdx))` pattern that + // builds an enumerator over a potentially mutable source. + if (points is IList list) { - if (!this.IsValidPoint(p)) + // Fast path for IsXMonotonic series: bisect on data X to find a candidate + // index, then expand outward in both directions stopping when the screen-X + // distance to the cursor exceeds the running best total distance — no point + // further out can be closer in Euclidean distance. This converts the per-mouse- + // move cost from O(N) to O(log N + k), where k is the small set of points + // within the running best distance. The 16-element threshold avoids overhead + // for tiny series where the linear scan is already free. + int remaining = list.Count - startIdx; + if (this.IsXMonotonic && remaining >= 16) { - i++; - continue; + DataPoint queryDp; + bool inverseOk; + try + { + queryDp = this.InverseTransform(point); + inverseOk = true; + } + catch + { + // InverseTransform unavailable (e.g. axis not initialized); fall through + // to the linear scan below by leaving inverseOk=false. + queryDp = default; + inverseOk = false; + } + + if (inverseOk) + { + double targetX = queryDp.X; + + // Bisect: smallest index in [startIdx, list.Count-1] whose X >= targetX, + // or list.Count-1 if all X < targetX. Defensive against concurrent + // mutation: re-read list.Count each iteration (already implicit) and + // catch out-of-range from the indexer. + int lo = startIdx; + int hi = list.Count - 1; + bool bisectOk = true; + while (lo < hi) + { + int mid = lo + ((hi - lo) >> 1); + DataPoint mp; + try + { + mp = list[mid]; + } + catch (ArgumentOutOfRangeException) + { + bisectOk = false; + break; + } + if (mp.x < targetX) lo = mid + 1; + else hi = mid; + } + + if (bisectOk) + { + int center = lo < list.Count ? lo : list.Count - 1; + + // Expand outward; early-terminate each direction when screen-X + // distance squared exceeds the best total distance squared. + int li = center; + int ri = center + 1; + bool leftDone = li < startIdx; + bool rightDone = ri >= list.Count; + + while (!leftDone || !rightDone) + { + if (!leftDone) + { + DataPoint p; + try + { + p = list[li]; + } + catch (ArgumentOutOfRangeException) + { + leftDone = true; + p = default; + } + if (!leftDone && this.IsValidPoint(p)) + { + var sp = this.Transform(p.x, p.y); + double dxL = sp.X - point.X; + double dxLSq = dxL * dxL; + if (minimumDistance < double.MaxValue && dxLSq > minimumDistance) + { + leftDone = true; + } + else + { + double d2 = (sp - point).LengthSquared; + if (d2 < minimumDistance) + { + dpn = p; + spn = sp; + minimumDistance = d2; + index = li; + } + } + } + if (!leftDone) + { + li--; + if (li < startIdx) leftDone = true; + } + } + + if (!rightDone) + { + DataPoint p; + try + { + p = list[ri]; + } + catch (ArgumentOutOfRangeException) + { + rightDone = true; + p = default; + } + if (!rightDone && this.IsValidPoint(p)) + { + var sp = this.Transform(p.x, p.y); + double dxR = sp.X - point.X; + double dxRSq = dxR * dxR; + if (minimumDistance < double.MaxValue && dxRSq > minimumDistance) + { + rightDone = true; + } + else + { + double d2 = (sp - point).LengthSquared; + if (d2 < minimumDistance) + { + dpn = p; + spn = sp; + minimumDistance = d2; + index = ri; + } + } + } + if (!rightDone) + { + ri++; + if (ri >= list.Count) rightDone = true; + } + } + } + + goto AfterIListScan; + } + } } - var sp = this.Transform(p.x, p.y); - double d2 = (sp - point).LengthSquared; - - if (d2 < minimumDistance) + // Linear scan fallback (small series, non-monotonic, or fast path declined). + for (int i = startIdx; i < list.Count; i++) { - dpn = p; - spn = sp; - minimumDistance = d2; - index = i; + DataPoint p; + try + { + p = list[i]; + } + catch (ArgumentOutOfRangeException) + { + // Concurrent mutation shrank the list under us. Stop cleanly. + break; + } + + if (!this.IsValidPoint(p)) + { + continue; + } + + var sp = this.Transform(p.x, p.y); + double d2 = (sp - point).LengthSquared; + + if (d2 < minimumDistance) + { + dpn = p; + spn = sp; + minimumDistance = d2; + index = i; + } + } + AfterIListScan:; + } + else if (points is IReadOnlyList roList) + { + // IReadOnlyList fast path: the same indexed scan as IList, + // but covers consumers that supply read-only collections (immutable arrays, + // IReadOnlyList views, ImmutableList, etc.) without falling through to the + // allocating snapshot fallback below. Re-reads roList.Count each iteration so + // a shrink terminates the loop cleanly. + for (int i = startIdx; i < roList.Count; i++) + { + DataPoint p; + try + { + p = roList[i]; + } + catch (ArgumentOutOfRangeException) + { + break; + } + + if (!this.IsValidPoint(p)) + { + continue; + } + + var sp = this.Transform(p.x, p.y); + double d2 = (sp - point).LengthSquared; + + if (d2 < minimumDistance) + { + dpn = p; + spn = sp; + minimumDistance = d2; + index = i; + } + } + } + else + { + var snapshot = points.Skip(startIdx).ToArray(); + for (int k = 0; k < snapshot.Length; k++) + { + var p = snapshot[k]; + if (!this.IsValidPoint(p)) + { + continue; + } + + var sp = this.Transform(p.x, p.y); + double d2 = (sp - point).LengthSquared; + + if (d2 < minimumDistance) + { + dpn = p; + spn = sp; + minimumDistance = d2; + index = startIdx + k; + } } - - i++; } if (minimumDistance < double.MaxValue) { - var item = this.GetItem((int)Math.Round(index)); + // GetItem may dereference the underlying ItemsSource at the captured index; + // if the source mutated between scan and this lookup (concurrent producer), + // the index can be stale. Treat that as "no item" rather than propagating + // the exception out of the hit-test path. + object item; + try + { + item = this.GetItem((int)Math.Round(index)); + } + catch (System.ArgumentOutOfRangeException) + { + item = null; + } return new TrackerHitResult { Series = this, @@ -857,5 +1131,193 @@ double GetX(int index) return start; } + + /// + /// Specialised overload for + /// of . Avoids the + /// delegate dispatch on every binary-search step, + /// which on a 500k-point series is called dozens of times per render. + /// + /// Data points. + /// X coordinate of visible window start. + /// Last window index. + /// The new window start index. + protected int UpdateWindowStartIndex(IList items, double targetX, int lastIndex) + { + lastIndex = this.FindWindowStartIndex(items, targetX, lastIndex); + if (lastIndex > 0) + { + lastIndex--; + } + + return lastIndex; + } + + /// + /// Specialised overload for + /// of . Reads DataPoint.x + /// directly instead of going through a ; the JIT + /// can then inline the field access on every binary-search step. + /// + /// vector of data points + /// target x. + /// initial guess index. + /// + /// index of x with max(x) <= target x or 0 if cannot find + /// + public int FindWindowStartIndex(IList items, double targetX, int initialGuess) + { + int start = 0; + int nominalEnd = items.Count - 1; + while (nominalEnd > 0 && double.IsNaN(items[nominalEnd].x)) + nominalEnd -= 1; + int end = nominalEnd; + int curGuess = Math.Max(0, Math.Min(end, initialGuess)); + + double GetX(int index) + { + while (index <= nominalEnd) + { + double guessX = items[index].x; + if (double.IsNaN(guessX)) + index += 1; + else + return guessX; + } + return items[nominalEnd].x; + } + + while (start < end) + { + double guessX = GetX(curGuess); + if (guessX.Equals(targetX)) + { + start = curGuess; + break; + } + else if (guessX > targetX) + { + end = curGuess - 1; + } + else + { + start = curGuess; + } + + if (start >= end) + { + break; + } + + double endX = GetX(end); + double startX = GetX(start); + + if (endX == startX) + { + break; + } + + var m = (end - start + 1) / (endX - startX); + + curGuess = start + (int)((targetX - startX) * m); + curGuess = Math.Max(start + 1, Math.Min(curGuess, end)); + } + + // Post-search adjustment (mirrors the generic overload). + while (start > 0) + { + double val = items[start].x; + if (double.IsNaN(val) || val > targetX) + start -= 1; + else + break; + } + + for (int i = start + 1; i < items.Count; i++) + { + double val = items[i].x; + if (double.IsNaN(val)) + continue; + if (val <= targetX) + start = i; + else + break; + } + + return start; + } + + /// + /// Updates the visible window end index for an of + /// . Symmetric to + /// : returns the + /// largest index whose X is <= , plus one for line + /// continuity past the right edge. Returns if the search + /// can't bound the window (e.g. all values past the target are NaN). + /// + /// Data points (assumed monotonic in X). + /// X coordinate of visible window end. + /// Last computed window end index (used as initial guess). + /// The new window end index (inclusive). + protected int UpdateWindowEndIndex(IList items, double targetX, int lastIndex) + { + int idx = this.FindWindowEndIndex(items, targetX, lastIndex); + if (idx < items.Count - 1) + { + idx++; + } + return idx; + } + + /// + /// Finds the largest index in a monotonic-X data-point list whose X <= targetX. + /// Mirrors but + /// finds the right boundary of the visible window. Used to bound render-time + /// iteration so the slow fallback path doesn't scan past the visible edge. + /// + public int FindWindowEndIndex(IList items, double targetX, int initialGuess) + { + if (items.Count == 0) return -1; + + int last = items.Count - 1; + // Step back over trailing NaN. + while (last > 0 && double.IsNaN(items[last].x)) + last -= 1; + + // If even the last valid X is <= target, return last directly. + if (items[last].x <= targetX) return last; + + // Bisect: smallest index where X > targetX, then return idx-1. + int lo = 0, hi = last; + int initial = Math.Max(0, Math.Min(last, initialGuess)); + // Use the initial guess as a hint to skip ahead in the common case where + // the window has only shifted slightly between renders. + if (items[initial].x > targetX) + { + hi = initial; + } + else + { + lo = initial; + } + + while (lo < hi) + { + int mid = lo + ((hi - lo) >> 1); + double midX = items[mid].x; + if (double.IsNaN(midX)) + { + // Step over NaN by treating it as "<= targetX" so we keep moving right. + lo = mid + 1; + continue; + } + if (midX <= targetX) lo = mid + 1; + else hi = mid; + } + + // lo is the smallest index with X > targetX (or last if not found). Return lo-1 + // unless lo==0 (no points in window). + return lo > 0 ? lo - 1 : 0; + } } } diff --git a/src/OxyPlotControls.Demo/App.xaml.cs b/src/OxyPlotControls.Demo/App.xaml.cs index 6feed365..6df2ab3b 100644 --- a/src/OxyPlotControls.Demo/App.xaml.cs +++ b/src/OxyPlotControls.Demo/App.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System.Windows; using Themes; diff --git a/src/OxyPlotControls.Demo/MainWindow.xaml.cs b/src/OxyPlotControls.Demo/MainWindow.xaml.cs index cd72edb6..e4bf1c5c 100644 --- a/src/OxyPlotControls.Demo/MainWindow.xaml.cs +++ b/src/OxyPlotControls.Demo/MainWindow.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -60,7 +31,7 @@ public partial class MainWindow : MetroWindow /// Dependency property for the test axis name binding property. /// public static readonly DependencyProperty TestAxisNameBindingProperty = - DependencyProperty.Register(nameof(TestAxisNameBinding), typeof(string), typeof(MainWindow), new FrameworkPropertyMetadata("Test Y")); + DependencyProperty.Register(nameof(TestAxisNameBinding), typeof(string), typeof(MainWindow), new FrameworkPropertyMetadata("Y")); /// /// Gets or sets the test axis name binding value. @@ -144,14 +115,12 @@ private void MainWindow_Loaded(object sender, RoutedEventArgs e) // OxyPlot controls need explicit invalidation because they use a custom rendering pipeline ThemeService.Instance.ThemeChanged += OnThemeChanged; - // Unsubscribe when the window closes to prevent memory leaks, and dispose the - // OxyPlotToolbar so its custom-cursor resources are released. The toolbar - // implements IDisposable specifically for cursor cleanup; without Dispose the - // Cursor objects were kept alive until process GC. + // Unsubscribe when the window closes to prevent memory leaks. As of the + // OxyPlotToolbar refactor, cursor resources live in a process-wide static + // cache so the toolbar no longer implements IDisposable. Closing += (s, e) => { ThemeService.Instance.ThemeChanged -= OnThemeChanged; - OxyPlotToolBar?.Dispose(); }; } @@ -997,7 +966,7 @@ private void LineSeries_Create(bool boundBool) Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test Y", + Title = "Y", Key = "y" }; @@ -1008,7 +977,7 @@ private void LineSeries_Create(bool boundBool) TitleFontSize = 20, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test X", + Title = "X", Key = "x" }; @@ -1090,7 +1059,7 @@ private void ScatterSeries_Create(bool boundBool) Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test Y", + Title = "Y", Key = "y" }; @@ -1101,7 +1070,7 @@ private void ScatterSeries_Create(bool boundBool) TitleFontSize = 20, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test X", + Title = "X", Key = "x" }; @@ -1190,7 +1159,7 @@ private void ScatterErrorSeries_Create(bool boundBool) Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test Y", + Title = "Y", Key = "y" }; @@ -1201,7 +1170,7 @@ private void ScatterErrorSeries_Create(bool boundBool) TitleFontSize = 20, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test X", + Title = "X", Key = "x" }; @@ -1299,7 +1268,7 @@ private void HeatMapSeries_Create(bool boundBool) Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test Y", + Title = "Y", Key = "y" }; @@ -1310,7 +1279,7 @@ private void HeatMapSeries_Create(bool boundBool) TitleFontSize = 20, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test X", + Title = "X", Key = "x" }; @@ -1385,7 +1354,7 @@ private void HistogramSeries_Create(bool boundBool) Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test Y", + Title = "Y", Key = "y" }; @@ -1396,7 +1365,7 @@ private void HistogramSeries_Create(bool boundBool) TitleFontSize = 20, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test X", + Title = "X", Key = "x" }; @@ -1449,7 +1418,7 @@ private void BoxPlotSeries_Create(bool boundBool) Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test Y", + Title = "Y", Key = "y" }; @@ -1463,7 +1432,7 @@ private void BoxPlotSeries_Create(bool boundBool) TitleFontSize = 20, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test X", + Title = "X", Key = "x" }; @@ -1531,7 +1500,7 @@ private void ColumnSeries_Create(bool boundBool) Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test Y", + Title = "Y", Key = "y" }; @@ -1544,7 +1513,7 @@ private void ColumnSeries_Create(bool boundBool) TitleFontSize = 20, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test X", + Title = "X", Key = "x" }; @@ -1603,7 +1572,7 @@ private void BarSeries_Create(bool boundBool) Position = AxisPosition.Bottom, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test Y", + Title = "Y", Key = "y" }; @@ -1616,7 +1585,7 @@ private void BarSeries_Create(bool boundBool) TitleFontSize = 20, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test X", + Title = "X", Key = "x" }; @@ -1696,7 +1665,7 @@ private void AreaSeries_Create(bool boundBool) Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test Y", + Title = "Y", Key = "y" }; @@ -1707,7 +1676,7 @@ private void AreaSeries_Create(bool boundBool) TitleFontSize = 20, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test X", + Title = "X", Key = "x" }; @@ -1773,7 +1742,7 @@ private void DateTimeSeries_Create(bool boundBool) Position = AxisPosition.Left, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test Y", + Title = "Y", Key = "y" }; @@ -1784,7 +1753,7 @@ private void DateTimeSeries_Create(bool boundBool) TitleFontSize = 20, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash, - Title = "Test X", + Title = "X", Key = "x" }; diff --git a/src/OxyPlotControls.Demo/OxyPlotControls.Demo.csproj b/src/OxyPlotControls.Demo/OxyPlotControls.Demo.csproj index 727366d3..3a572a9e 100644 --- a/src/OxyPlotControls.Demo/OxyPlotControls.Demo.csproj +++ b/src/OxyPlotControls.Demo/OxyPlotControls.Demo.csproj @@ -26,9 +26,7 @@ - - ..\..\..\numerics\Numerics\bin\$(Configuration)\net10.0\Numerics.dll - + diff --git a/src/OxyPlotControls.Demo/Properties/AssemblyInfo.cs b/src/OxyPlotControls.Demo/Properties/AssemblyInfo.cs index 3d29d7be..5fdba40e 100644 --- a/src/OxyPlotControls.Demo/Properties/AssemblyInfo.cs +++ b/src/OxyPlotControls.Demo/Properties/AssemblyInfo.cs @@ -10,7 +10,6 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Demo_OxyPlotControls")] -[assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/src/OxyPlotControls/Annotations/AnnotationControl.xaml.cs b/src/OxyPlotControls/Annotations/AnnotationControl.xaml.cs index 010b3e49..52310b96 100644 --- a/src/OxyPlotControls/Annotations/AnnotationControl.xaml.cs +++ b/src/OxyPlotControls/Annotations/AnnotationControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Windows; diff --git a/src/OxyPlotControls/Annotations/AnnotationSelectorControl.xaml.cs b/src/OxyPlotControls/Annotations/AnnotationSelectorControl.xaml.cs index 3264cbc2..ae2f453b 100644 --- a/src/OxyPlotControls/Annotations/AnnotationSelectorControl.xaml.cs +++ b/src/OxyPlotControls/Annotations/AnnotationSelectorControl.xaml.cs @@ -1,34 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -using System; +using System; using System.Collections.Specialized; using System.Windows; using System.Windows.Controls; diff --git a/src/OxyPlotControls/Axes/AxesControl.xaml.cs b/src/OxyPlotControls/Axes/AxesControl.xaml.cs index 9b20b521..1c48d23b 100644 --- a/src/OxyPlotControls/Axes/AxesControl.xaml.cs +++ b/src/OxyPlotControls/Axes/AxesControl.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Collections.Specialized; using System.Windows; diff --git a/src/OxyPlotControls/Axes/AxisControl.xaml.cs b/src/OxyPlotControls/Axes/AxisControl.xaml.cs index dc6c7c5d..127d5f46 100644 --- a/src/OxyPlotControls/Axes/AxisControl.xaml.cs +++ b/src/OxyPlotControls/Axes/AxisControl.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Collections.Generic; using System.Globalization; @@ -581,12 +552,9 @@ private void AxisMinimum_PreviewNumberChanged(object oldValue, object newValue, { if (_ignoreMaxMinChange) return; - double newNumber; - if (!double.TryParse(newValue.ToString(), out newNumber)) - { - if (newValue.GetType() != typeof(double)) return; - newNumber = (double)newValue; - } + // newValue always comes in boxed as a double from NumericTextBox; the prior + // double.TryParse(newValue.ToString(), ...) round-trip was vestigial. + if (newValue is not double newNumber) return; if (newNumber >= AxisMaximum.Number) { @@ -609,12 +577,9 @@ private void AxisMaximum_PreviewNumberChanged(object oldValue, object newValue, { if (_ignoreMaxMinChange) return; - double newNumber; - if (!double.TryParse(newValue.ToString(), out newNumber)) - { - if (newValue.GetType() != typeof(double)) return; - newNumber = (double)newValue; - } + // newValue always comes in boxed as a double from NumericTextBox; the prior + // double.TryParse(newValue.ToString(), ...) round-trip was vestigial. + if (newValue is not double newNumber) return; if (newNumber <= AxisMinimum.Number) { @@ -678,10 +643,10 @@ private void DecimalPlaces_PropertyChanged(object sender, System.ComponentModel. if (_isSyncingFromStringFormat) return; if (e.PropertyName == nameof(GenericControls.NumericAutoPropertyControl.Number)) { - if (DecimalPlaces.Number.ToString() == "NaN") + if (double.IsNaN(DecimalPlaces.Number)) _stringFormatDecimals = ""; else - _stringFormatDecimals = DecimalPlaces.Number.ToString(); + _stringFormatDecimals = ((int)DecimalPlaces.Number).ToString(CultureInfo.InvariantCulture); Axis.StringFormat = _stringFormatCategory + _stringFormatDecimals; } @@ -696,12 +661,9 @@ private void DecimalPlaces_PropertyChanged(object sender, System.ComponentModel. /// Set to true to cancel the change. private void DecimalPlaces_PreviewNumberChanged(object oldValue, object newValue, ref bool cancel) { - double newNumber; - if (!double.TryParse(newValue.ToString(), out newNumber)) - { - if (newValue.GetType() != typeof(double)) return; - newNumber = (double)newValue; - } + // newValue always comes in boxed as a double from NumericTextBox; the prior + // double.TryParse(newValue.ToString(), ...) round-trip was vestigial. + if (newValue is not double newNumber) return; DecimalPlaces.Number = Math.Floor(newNumber); } @@ -777,7 +739,7 @@ private void SyncLabelTypeFromStringFormat() if (Axis.StringFormat != null && Axis.StringFormat.Length > 1) { stringFormatDecimal = Axis.StringFormat.Substring(1); - if (double.TryParse(stringFormatDecimal, out double decimals)) + if (double.TryParse(stringFormatDecimal, NumberStyles.Integer, CultureInfo.InvariantCulture, out double decimals)) { DecimalPlaces.Number = decimals; } @@ -806,10 +768,10 @@ public class ReverseAxisConverter : IMultiValueConverter /// public object Convert(object[] values, Type targetType, object? parameter, CultureInfo culture) { - double startPosition; - double.TryParse(values[0]?.ToString(), out startPosition); - double endPosition; - double.TryParse(values[1]?.ToString(), out endPosition); + // values[0] / values[1] are bound to Axis.StartPosition / Axis.EndPosition (double). + // The prior double.TryParse(values[i]?.ToString(), ...) round-trip was vestigial. + double startPosition = values[0] is double s ? s : 0d; + double endPosition = values[1] is double e ? e : 0d; if (values[2] == null) { diff --git a/src/OxyPlotControls/Extensions.cs b/src/OxyPlotControls/Extensions.cs index 34e7fa17..c880eb76 100644 --- a/src/OxyPlotControls/Extensions.cs +++ b/src/OxyPlotControls/Extensions.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.ComponentModel; using System.Globalization; diff --git a/src/OxyPlotControls/GeneralPlotControl.xaml.cs b/src/OxyPlotControls/GeneralPlotControl.xaml.cs index 309d0a2d..3a1732bd 100644 --- a/src/OxyPlotControls/GeneralPlotControl.xaml.cs +++ b/src/OxyPlotControls/GeneralPlotControl.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Globalization; using System.Windows; diff --git a/src/OxyPlotControls/LegendControl.xaml.cs b/src/OxyPlotControls/LegendControl.xaml.cs index 6a5c8a85..ffdcf3ca 100644 --- a/src/OxyPlotControls/LegendControl.xaml.cs +++ b/src/OxyPlotControls/LegendControl.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Collections.Generic; using System.Windows; @@ -147,11 +118,12 @@ private static void OnPlotPropertyChanged(DependencyObject d, DependencyProperty /// The event arguments. private void LegendPropertyComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { - // Invalidate the plot to refresh the legend display - // Use true to force a full update including layout recalculation + // Legend property changes (orientation, position, font, padding, etc.) are display-only; + // no series data changes, so updateData=false avoids walking every series via + // PlotModel.Update(true) for what is purely a layout/style refresh. if (Plot != null) { - Plot.InvalidatePlot(true); + Plot.InvalidatePlot(false); } UpdateOrientationEnabled(); diff --git a/src/OxyPlotControls/OxyPlotControls.csproj b/src/OxyPlotControls/OxyPlotControls.csproj index 4027be1b..e1a22af1 100644 --- a/src/OxyPlotControls/OxyPlotControls.csproj +++ b/src/OxyPlotControls/OxyPlotControls.csproj @@ -9,7 +9,7 @@ false OxyPlotControls OxyPlotControls - $(NoWarn);CA1416 + $(NoWarn);CA1416;CS0618 true RMC.OxyPlotControls diff --git a/src/OxyPlotControls/OxyPlotSettingsSerializer.cs b/src/OxyPlotControls/OxyPlotSettingsSerializer.cs index 8c0268f8..3434d340 100644 --- a/src/OxyPlotControls/OxyPlotSettingsSerializer.cs +++ b/src/OxyPlotControls/OxyPlotSettingsSerializer.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System.Xml.Linq; using OxyPlot.Wpf; using OxyPlot.Wpf.Serialization; diff --git a/src/OxyPlotControls/OxyPlotToolbar.xaml.cs b/src/OxyPlotControls/OxyPlotToolbar.xaml.cs index 89189e6a..3b020b3f 100644 --- a/src/OxyPlotControls/OxyPlotToolbar.xaml.cs +++ b/src/OxyPlotControls/OxyPlotToolbar.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Collections.Generic; using System.Collections.Specialized; @@ -51,15 +22,49 @@ namespace OxyPlotControls /// /// OxyPlot toolbar control providing pan, zoom, annotation, and export functionality. /// - public partial class OxyPlotToolbar : UserControl, IDisposable + /// + /// + /// Lifetime: the toolbar uses five custom + /// instances loaded from embedded resources (move-points, add-point, pan-hand, pan-hand-closed, + /// zoom). They are held in a private static cache (CursorCache) so they load exactly once + /// per process and are shared across every toolbar instance. Because cursors are immutable + /// process-lifetime resources, the toolbar deliberately does not implement + /// and consumers do not need to dispose it. Repeatedly creating and + /// tearing down the toolbar (e.g., per-document tabs) no longer leaks HCURSOR handles. + /// + /// + public partial class OxyPlotToolbar : UserControl { - private bool _disposed = false; /// /// Tracks which theme was last applied to the plot. Used to detect when the theme changed /// while the toolbar was unloaded (inactive tab) so it can be reapplied on next load. /// private Themes.Theme? _lastAppliedTheme; + /// + /// Static cache of toolbar cursors loaded once from embedded resources and shared across + /// all toolbar instances. Cursors are immutable, process-lifetime resources, so each + /// toolbar instance does not need to own or dispose them. This removes the + /// IDisposable contract previously imposed on consumers and prevents the cursor handle + /// leak that occurred when consumers forgot to call Dispose(). + /// + private static class CursorCache + { + internal static readonly Cursor MovePoints = LoadCursor(Properties.Resources.SelectPointCursor); + internal static readonly Cursor AddPoint = LoadCursor(Properties.Resources.AddPointCursor); + internal static readonly Cursor PanHand = LoadCursor(Properties.Resources.Pan_Hand); + internal static readonly Cursor PanHandClosed = LoadCursor(Properties.Resources.Pan_Hand_Closed); + internal static readonly Cursor Zoom = LoadCursor(Properties.Resources.ZoomIn); + + private static Cursor LoadCursor(byte[] cursorBytes) + { + using (var ms = new MemoryStream(cursorBytes)) + { + return new Cursor(ms); + } + } + } + #region Construction /// @@ -69,39 +74,7 @@ public OxyPlotToolbar() { InitializeComponent(); - // Set up custom cursors from embedded resources - try - { - using (var ms = new MemoryStream(Properties.Resources.SelectPointCursor)) - { - _movePointsCursor = new Cursor(ms); - } - using (var ms = new MemoryStream(Properties.Resources.AddPointCursor)) - { - _addPointCursor = new Cursor(ms); - } - using (var ms = new MemoryStream(Properties.Resources.Pan_Hand)) - { - _panHandCursor = new Cursor(ms); - } - using (var ms = new MemoryStream(Properties.Resources.Pan_Hand_Closed)) - { - _panHandClosedCursor = new Cursor(ms); - } - using (var ms = new MemoryStream(Properties.Resources.ZoomIn)) - { - _zoomCursor = new Cursor(ms); - } - } - catch - { - _movePointsCursor?.Dispose(); - _addPointCursor?.Dispose(); - _panHandCursor?.Dispose(); - _panHandClosedCursor?.Dispose(); - _zoomCursor?.Dispose(); - throw; - } + // Custom cursors are loaded once into CursorCache; no per-instance setup required. // Create leader line canvas and leader line _leaderLine.StrokeThickness = 2; @@ -130,15 +103,28 @@ private void OxyPlotToolbar_Loaded(object sender, RoutedEventArgs e) { _lastAppliedTheme = currentTheme; Plot.SuppressPropertyChanged = true; - var theme = OxyPlotThemeManager.GetThemeFor(currentTheme); - OxyPlotThemeManager.ApplyTheme(Plot, theme); - Plot.SuppressPropertyChanged = false; + try + { + var theme = OxyPlotThemeManager.GetThemeFor(currentTheme); + OxyPlotThemeManager.ApplyTheme(Plot, theme); + } + finally + { + Plot.SuppressPropertyChanged = false; + // ApplyTheme's internal InvalidatePlot was gated out by the Plot-level + // suppression flag above; flush now that the gate is closed so the theme + // takes effect immediately rather than at the next user interaction. + Plot.InvalidatePlot(false); + } } } /// /// Handles the Unloaded event. Unsubscribes from theme changes. - /// Does not call Dispose because the control may be re-loaded (e.g., tab switching). + /// Plot-side event subscriptions are managed by (the Plot + /// dependency-property changed callback), so they are detached automatically when the + /// Plot binding is cleared. Cursors live in and are not + /// per-instance, so there is nothing to dispose here. /// private void OxyPlotToolbar_Unloaded(object sender, RoutedEventArgs e) { @@ -158,9 +144,18 @@ private void OnAppThemeChanged(object? sender, ThemeChangedEventArgs e) _lastAppliedTheme = e.NewTheme; Plot.SuppressPropertyChanged = true; - var theme = OxyPlotThemeManager.GetThemeFor(e.NewTheme); - OxyPlotThemeManager.ApplyTheme(Plot, theme); - Plot.SuppressPropertyChanged = false; + try + { + var theme = OxyPlotThemeManager.GetThemeFor(e.NewTheme); + OxyPlotThemeManager.ApplyTheme(Plot, theme); + } + finally + { + Plot.SuppressPropertyChanged = false; + // ApplyTheme's internal InvalidatePlot was gated out by the Plot-level + // suppression flag above; flush now that the gate is closed. + Plot.InvalidatePlot(false); + } } #endregion @@ -224,13 +219,13 @@ private static void InitializePlot(DependencyObject d, DependencyPropertyChanged newPlot.ApplyTemplate(); // Needed to set the canvas - // Define the zooming cursor - newPlot.ZoomHorizontalCursor = oxyToolBar._zoomCursor; - newPlot.ZoomRectangleCursor = oxyToolBar._zoomCursor; - newPlot.ZoomVerticalCursor = oxyToolBar._zoomCursor; + // Define the zooming cursor (cached static cursors). + newPlot.ZoomHorizontalCursor = _zoomCursor; + newPlot.ZoomRectangleCursor = _zoomCursor; + newPlot.ZoomVerticalCursor = _zoomCursor; - // Define the pan cursor - newPlot.PanCursor = oxyToolBar._panHandCursor; + // Define the pan cursor. + newPlot.PanCursor = _panHandCursor; // Set up the mouse bindings if (oxyToolBar.PointerButton.IsChecked == true) oxyToolBar.PointerButton_Click(oxyToolBar, new RoutedEventArgs()); @@ -247,9 +242,18 @@ private static void InitializePlot(DependencyObject d, DependencyPropertyChanged if (oxyToolBar.IsLoaded) { newPlot.SuppressPropertyChanged = true; - var theme = OxyPlotThemeManager.GetThemeFor(ThemeService.Instance.CurrentTheme); - OxyPlotThemeManager.ApplyTheme(newPlot, theme); - newPlot.SuppressPropertyChanged = false; + try + { + var theme = OxyPlotThemeManager.GetThemeFor(ThemeService.Instance.CurrentTheme); + OxyPlotThemeManager.ApplyTheme(newPlot, theme); + } + finally + { + newPlot.SuppressPropertyChanged = false; + // ApplyTheme's internal InvalidatePlot was gated out by the Plot-level + // suppression flag above; flush now that the gate is closed. + newPlot.InvalidatePlot(false); + } } } } @@ -351,12 +355,13 @@ public enum AddToolMode AddHorizontalLineAnnotation } - // Custom Cursors - private Cursor _movePointsCursor; - private Cursor _addPointCursor; - private Cursor _panHandCursor; - private Cursor _panHandClosedCursor; - private Cursor _zoomCursor; + // Custom cursors live in the static CursorCache nested type above; access them + // through the helper properties below to keep call sites readable. + private static Cursor _movePointsCursor => CursorCache.MovePoints; + private static Cursor _addPointCursor => CursorCache.AddPoint; + private static Cursor _panHandCursor => CursorCache.PanHand; + private static Cursor _panHandClosedCursor => CursorCache.PanHandClosed; + private static Cursor _zoomCursor => CursorCache.Zoom; /// /// The distance in screen pixels used for annotation hit-testing, edge detection, and point proximity checks. @@ -477,8 +482,9 @@ private void ZoomAllButton_Click(object sender, RoutedEventArgs e) { if (Plot == null) return; + // ResetAllAxes already calls InvalidatePlot(false). A second InvalidatePlot + // here was running PlotModel.Update twice for every Zoom-To-Extents click. Plot.ResetAllAxes(); - Plot.InvalidatePlot(false); Plot.Focus(); } @@ -696,11 +702,21 @@ private void StopAddAnnotation() // Unsuppress PropertyChanged and notify the plot so undo bridges // can rebuild their shadow state to match the final property values. + // try/finally guarantees suppression is cleared even if NotifyAnnotationsModified + // or InvalidatePlot throws — otherwise the annotation would remain permanently + // silenced and break undo/redo for that annotation. if (_targetAddAnnotation != null) { - _targetAddAnnotation.SuppressPropertyChanged = false; - Plot.NotifyAnnotationsModified(); - Plot.InvalidatePlot(false); + try + { + _targetAddAnnotation.SuppressPropertyChanged = false; + Plot.NotifyAnnotationsModified(); + Plot.InvalidatePlot(false); + } + finally + { + _targetAddAnnotation.SuppressPropertyChanged = false; + } } if (_addAnnotationToolMode == AddToolMode.AddPolygonAnnotation || _addAnnotationToolMode == AddToolMode.AddPolylineAnnotation) @@ -738,11 +754,26 @@ private void CancelAddAnnotation() { if (_addAnnotationToolMode == AddToolMode.None) return; - // Remove the in-progress annotation from the plot before stopping - if (_targetAddAnnotation != null && Plot.Annotations.Contains(_targetAddAnnotation)) + // Remove the in-progress annotation from the plot before stopping. + // Always clear suppression on the tracked annotation — even if it never made it + // into Plot.Annotations (e.g. an exception fired between SuppressPropertyChanged=true + // and the Plot.Annotations.Add call). Otherwise the orphaned annotation would + // remain permanently silenced and a future reuse via the same reference would + // suppress all change notifications. + if (_targetAddAnnotation != null) { - _targetAddAnnotation.SuppressPropertyChanged = false; - Plot.Annotations.Remove(_targetAddAnnotation); + try + { + _targetAddAnnotation.SuppressPropertyChanged = false; + if (Plot.Annotations.Contains(_targetAddAnnotation)) + { + Plot.Annotations.Remove(_targetAddAnnotation); + } + } + finally + { + _targetAddAnnotation.SuppressPropertyChanged = false; + } } // For polygon/polyline that may not be added yet, just clear the leader line @@ -844,8 +875,16 @@ private void PlotModelAnnotationCollectionChanged(object? sender, NotifyCollecti newArrow.InternalAnnotation.MouseUp += (s, ae) => { if (!newArrow.IsEnabled) return; - newArrow.Color = _originalColor; - newArrow.SuppressPropertyChanged = false; + try + { + newArrow.Color = _originalColor; + } + finally + { + // Guarantee suppression is cleared even if the Color setter throws, + // so PropertyChanged (and undo bridge) are not silenced indefinitely. + newArrow.SuppressPropertyChanged = false; + } newArrow.RaisePropertyChanged(nameof(newArrow.StartPoint), nameof(newArrow.EndPoint), nameof(newArrow.Color)); }; } @@ -891,8 +930,14 @@ private void PlotModelAnnotationCollectionChanged(object? sender, NotifyCollecti newText.InternalAnnotation.MouseUp += (s, ae) => { if (!newText.IsEnabled) return; - newText.Background = _originalColor; - newText.SuppressPropertyChanged = false; + try + { + newText.Background = _originalColor; + } + finally + { + newText.SuppressPropertyChanged = false; + } newText.RaisePropertyChanged(nameof(newText.TextPosition), nameof(newText.Background)); }; } @@ -966,8 +1011,14 @@ private void PlotModelAnnotationCollectionChanged(object? sender, NotifyCollecti newRect.InternalAnnotation.MouseUp += (s, ae) => { if (!newRect.IsEnabled) return; - newRect.Fill = _originalColor; - newRect.SuppressPropertyChanged = false; + try + { + newRect.Fill = _originalColor; + } + finally + { + newRect.SuppressPropertyChanged = false; + } newRect.RaisePropertyChanged(nameof(newRect.MinimumX), nameof(newRect.MaximumX), nameof(newRect.MinimumY), nameof(newRect.MaximumY), nameof(newRect.Fill)); }; } @@ -1041,8 +1092,14 @@ private void PlotModelAnnotationCollectionChanged(object? sender, NotifyCollecti newEllipse.InternalAnnotation.MouseUp += (s, ae) => { if (!newEllipse.IsEnabled) return; - newEllipse.Fill = _originalColor; - newEllipse.SuppressPropertyChanged = false; + try + { + newEllipse.Fill = _originalColor; + } + finally + { + newEllipse.SuppressPropertyChanged = false; + } newEllipse.RaisePropertyChanged(nameof(newEllipse.X), nameof(newEllipse.Y), nameof(newEllipse.Width), nameof(newEllipse.Height), nameof(newEllipse.Fill)); }; } @@ -1092,8 +1149,14 @@ private void PlotModelAnnotationCollectionChanged(object? sender, NotifyCollecti newPoint.InternalAnnotation.MouseUp += (s, ae) => { if (!newPoint.IsEnabled) return; - newPoint.Fill = _originalColor; - newPoint.SuppressPropertyChanged = false; + try + { + newPoint.Fill = _originalColor; + } + finally + { + newPoint.SuppressPropertyChanged = false; + } newPoint.RaisePropertyChanged(nameof(newPoint.X), nameof(newPoint.Y), nameof(newPoint.Fill)); }; } @@ -1197,8 +1260,14 @@ private void PlotModelAnnotationCollectionChanged(object? sender, NotifyCollecti newPolygon.InternalAnnotation.MouseUp += (s, ae) => { if (!newPolygon.IsEnabled) return; - newPolygon.Fill = _originalColor; - newPolygon.SuppressPropertyChanged = false; + try + { + newPolygon.Fill = _originalColor; + } + finally + { + newPolygon.SuppressPropertyChanged = false; + } newPolygon.RaisePropertyChanged(nameof(newPolygon.Points), nameof(newPolygon.Fill)); }; } @@ -1288,8 +1357,14 @@ private void PlotModelAnnotationCollectionChanged(object? sender, NotifyCollecti newPolyline.InternalAnnotation.MouseUp += (s, ae) => { if (!newPolyline.IsEnabled) return; - newPolyline.Color = _originalColor; - newPolyline.SuppressPropertyChanged = false; + try + { + newPolyline.Color = _originalColor; + } + finally + { + newPolyline.SuppressPropertyChanged = false; + } newPolyline.RaisePropertyChanged(nameof(newPolyline.Points), nameof(newPolyline.Color)); }; } @@ -1359,8 +1434,14 @@ private void PlotModelAnnotationCollectionChanged(object? sender, NotifyCollecti newLine.InternalAnnotation.MouseUp += (s, ae) => { if (!newLine.IsEnabled) return; - newLine.Color = _originalColor; - newLine.SuppressPropertyChanged = false; + try + { + newLine.Color = _originalColor; + } + finally + { + newLine.SuppressPropertyChanged = false; + } newLine.RaisePropertyChanged(nameof(newLine.X), nameof(newLine.Y), nameof(newLine.Intercept), nameof(newLine.Color)); CloseLineAnnotationTooltip(newLine); }; @@ -1651,12 +1732,20 @@ private void PlotModelMouseDown(object? sender, OxyMouseDownEventArgs e) case AddToolMode.AddPolygonAnnotation: if (_targetAddAnnotation == null) { + // Defend against plots without default axes (e.g. category-only or + // not-yet-laid-out plots). Without this, an Undefined point would be + // added to the polygon and render as garbage / NaN. + var dataPointClicked = ConvertScreenPointToDataPoint(e.Position); + if (!dataPointClicked.IsDefined()) + { + break; + } + var newPolygon = new Wpf.PolygonAnnotation(); newPolygon.SuppressPropertyChanged = true; newPolygon.Text = "Polygon Annotation"; newPolygon.Points = new System.Collections.Generic.List(); - var dataPointClicked = ConvertScreenPointToDataPoint(e.Position); newPolygon.Points.Add(dataPointClicked); _leaderLine.Points.Add(new Point(e.Position.X, e.Position.Y)); _leaderLine.Points.Add(new Point(e.Position.X, e.Position.Y)); @@ -1673,8 +1762,12 @@ private void PlotModelMouseDown(object? sender, OxyMouseDownEventArgs e) } if (e.ClickCount < 2) { - _leaderLine.Points.Add(new Point(e.Position.X, e.Position.Y)); - polyAnnotation.Points.Add(ConvertScreenPointToDataPoint(e.Position)); + var nextDataPoint = ConvertScreenPointToDataPoint(e.Position); + if (nextDataPoint.IsDefined()) + { + _leaderLine.Points.Add(new Point(e.Position.X, e.Position.Y)); + polyAnnotation.Points.Add(nextDataPoint); + } } } break; @@ -1682,6 +1775,13 @@ private void PlotModelMouseDown(object? sender, OxyMouseDownEventArgs e) case AddToolMode.AddPolylineAnnotation: if (_targetAddAnnotation == null) { + // Defend against plots without default axes — see polygon comment above. + var dataPointClicked = ConvertScreenPointToDataPoint(e.Position); + if (!dataPointClicked.IsDefined()) + { + break; + } + var newPolyline = new Wpf.PolylineAnnotation(); newPolyline.SuppressPropertyChanged = true; newPolyline.Text = "Polyline Annotation"; @@ -1689,7 +1789,6 @@ private void PlotModelMouseDown(object? sender, OxyMouseDownEventArgs e) newPolyline.Points = new System.Collections.Generic.List(); Plot.Annotations.Add(newPolyline); PropertiesCalled?.Invoke(Plot, true, OxyPlotPropertiesControl.PropertyEXP.Annotations_Text, newPolyline); - var dataPointClicked = ConvertScreenPointToDataPoint(e.Position); newPolyline.Points.Add(dataPointClicked); _leaderLine.Points.Add(new Point(e.Position.X, e.Position.Y)); _leaderLine.Points.Add(new Point(e.Position.X, e.Position.Y)); @@ -1700,7 +1799,15 @@ private void PlotModelMouseDown(object? sender, OxyMouseDownEventArgs e) _doubleClicked = e.ClickCount > 1; if (e.ClickCount < 2) { - ((Wpf.PolylineAnnotation)_targetAddAnnotation).Points.Add(_targetAddAnnotation.InternalAnnotation.InverseTransform(e.Position)); + // Mirror the polygon path's IsDefined guard: if axes are not yet + // laid out (AvalonDock dock/undock window) ConvertScreenPointToDataPoint + // returns DataPoint.Undefined; skip rather than appending NaN to the + // polyline points. + var nextDataPoint = ConvertScreenPointToDataPoint(e.Position); + if (nextDataPoint.IsDefined()) + { + ((Wpf.PolylineAnnotation)_targetAddAnnotation).Points.Add(nextDataPoint); + } } } break; @@ -1734,6 +1841,20 @@ private void PlotModelMouseDown(object? sender, OxyMouseDownEventArgs e) /// private void PlotModelMouseMove(object? sender, OxyMouseEventArgs e) { + // Fast-path: while any mouse button is held (zoom-rect drag, pan, annotation drag, + // etc.) skip the annotation-hit-test + cursor-update logic below. That logic exists + // for hover-discovery of annotation handles; during an active drag the user is + // committed to a manipulator and the per-mouse-move work is wasted (and on plots + // with many annotations or shapes, expensive). The annotation-add early-out below + // still runs for the in-progress add-annotation tools. + if (_addAnnotationToolMode == AddToolMode.None + && (Mouse.LeftButton == MouseButtonState.Pressed + || Mouse.MiddleButton == MouseButtonState.Pressed + || Mouse.RightButton == MouseButtonState.Pressed)) + { + return; + } + // For adding annotations if (_addAnnotationToolMode != AddToolMode.None && _targetAddAnnotation != null) { @@ -1786,7 +1907,10 @@ private void PlotModelMouseMove(object? sender, OxyMouseEventArgs e) case AddToolMode.AddPolygonAnnotation: _leaderLine.Points[_leaderLine.Points.Count - 1] = new Point(e.Position.X, e.Position.Y); - Plot.InvalidatePlot(true); + // Mouse-move during polygon drag updates the leader-line preview only; + // no series data changes, so updateData=false avoids a per-mousemove walk + // of all series. Matches the AddPolylineAnnotation case below. + Plot.InvalidatePlot(false); break; case AddToolMode.AddPolylineAnnotation: @@ -4317,55 +4441,5 @@ private void SwapScatterErrorPoints(OxyPlot.Series.ScatterErrorSeries dps) } #endregion - - #region IDisposable - - /// - /// Releases the unmanaged resources used by the and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - protected virtual void Dispose(bool disposing) - { - if (!_disposed) - { - if (disposing) - { - // Unsubscribe from events to prevent memory leaks - ThemeService.Instance.ThemeChanged -= OnAppThemeChanged; - if (Plot != null) - { - Plot.Annotations.CollectionChanged -= PlotModelAnnotationCollectionChanged; - Plot.LayoutUpdated -= ToolBarLayoutUpdated; - - // Unsubscribe from PlotModel mouse events - if (Plot.ActualModel != null) - { - Plot.ActualModel.MouseDown -= PlotModelMouseDown; - Plot.ActualModel.MouseMove -= PlotModelMouseMove; - Plot.ActualModel.MouseUp -= PlotModelMouseUp; - } - } - - // Dispose managed resources (cursors) - _movePointsCursor?.Dispose(); - _addPointCursor?.Dispose(); - _panHandCursor?.Dispose(); - _panHandClosedCursor?.Dispose(); - _zoomCursor?.Dispose(); - } - _disposed = true; - } - } - - /// - /// Releases all resources used by the . - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - #endregion } } diff --git a/src/OxyPlotControls/OxyplotPropertiesControl.xaml.cs b/src/OxyPlotControls/OxyplotPropertiesControl.xaml.cs index a9b2ac2b..58484d69 100644 --- a/src/OxyPlotControls/OxyplotPropertiesControl.xaml.cs +++ b/src/OxyPlotControls/OxyplotPropertiesControl.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Windows; using System.Windows.Controls; diff --git a/src/OxyPlotControls/Properties/AssemblyInfo.cs b/src/OxyPlotControls/Properties/AssemblyInfo.cs index e143b7f3..61d2814c 100644 --- a/src/OxyPlotControls/Properties/AssemblyInfo.cs +++ b/src/OxyPlotControls/Properties/AssemblyInfo.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System.Reflection; using System.Runtime.InteropServices; using System.Windows; @@ -39,7 +10,6 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("USACE-RMC")] [assembly: AssemblyProduct("OxyPlotControls")] -[assembly: AssemblyCopyright("Copyright © USACE-RMC")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/src/OxyPlotControls/SavePlotImageDialog.xaml.cs b/src/OxyPlotControls/SavePlotImageDialog.xaml.cs index 2a6b9642..7432df1d 100644 --- a/src/OxyPlotControls/SavePlotImageDialog.xaml.cs +++ b/src/OxyPlotControls/SavePlotImageDialog.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.ComponentModel; using System.IO; diff --git a/src/OxyPlotControls/Series/BarSeriesControl.xaml.cs b/src/OxyPlotControls/Series/BarSeriesControl.xaml.cs index 2029d71a..51468f91 100644 --- a/src/OxyPlotControls/Series/BarSeriesControl.xaml.cs +++ b/src/OxyPlotControls/Series/BarSeriesControl.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Globalization; using System.Windows; diff --git a/src/OxyPlotControls/Series/BoxPlotSeriesControl.xaml.cs b/src/OxyPlotControls/Series/BoxPlotSeriesControl.xaml.cs index 0b375af1..e1802e33 100644 --- a/src/OxyPlotControls/Series/BoxPlotSeriesControl.xaml.cs +++ b/src/OxyPlotControls/Series/BoxPlotSeriesControl.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Collections.Generic; using System.Globalization; diff --git a/src/OxyPlotControls/Series/GenericSeriesControl.xaml.cs b/src/OxyPlotControls/Series/GenericSeriesControl.xaml.cs index 06d5c908..dffffaa4 100644 --- a/src/OxyPlotControls/Series/GenericSeriesControl.xaml.cs +++ b/src/OxyPlotControls/Series/GenericSeriesControl.xaml.cs @@ -1,33 +1,4 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Windows; diff --git a/src/OxyPlotControls/Series/LineSeriesControl.xaml.cs b/src/OxyPlotControls/Series/LineSeriesControl.xaml.cs index 25b3a16d..37480213 100644 --- a/src/OxyPlotControls/Series/LineSeriesControl.xaml.cs +++ b/src/OxyPlotControls/Series/LineSeriesControl.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Collections.Generic; using System.Globalization; diff --git a/src/OxyPlotControls/Series/ScatterSeriesControl.xaml.cs b/src/OxyPlotControls/Series/ScatterSeriesControl.xaml.cs index e2cd0c97..9f574bad 100644 --- a/src/OxyPlotControls/Series/ScatterSeriesControl.xaml.cs +++ b/src/OxyPlotControls/Series/ScatterSeriesControl.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Collections.Generic; using System.Globalization; diff --git a/src/OxyPlotControls/Series/SeriesControl.xaml.cs b/src/OxyPlotControls/Series/SeriesControl.xaml.cs index 1f5ece7b..5d636e9d 100644 --- a/src/OxyPlotControls/Series/SeriesControl.xaml.cs +++ b/src/OxyPlotControls/Series/SeriesControl.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Windows; using System.Windows.Controls; diff --git a/src/OxyPlotControls/Series/SeriesSelectorControl.xaml.cs b/src/OxyPlotControls/Series/SeriesSelectorControl.xaml.cs index e1526a15..4ceec407 100644 --- a/src/OxyPlotControls/Series/SeriesSelectorControl.xaml.cs +++ b/src/OxyPlotControls/Series/SeriesSelectorControl.xaml.cs @@ -1,32 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ using System; using System.Collections.Specialized; using System.Windows; @@ -249,7 +220,9 @@ private void MoveSeriesUpButton_Click(object sender, RoutedEventArgs e) } SeriesPropertyControlComboBox.SelectedIndex = index - 1; - Plot.InvalidatePlot(true); + // Reordering series Z-order is structural, not data — same series objects in a + // different sequence. updateData=false skips the per-series UpdateData walk. + Plot.InvalidatePlot(false); } /// @@ -279,7 +252,9 @@ private void MoveSeriesDownButton_Click(object sender, RoutedEventArgs e) } SeriesPropertyControlComboBox.SelectedIndex = index + 1; - Plot.InvalidatePlot(true); + // Reordering series Z-order is structural, not data — same series objects in a + // different sequence. updateData=false skips the per-series UpdateData walk. + Plot.InvalidatePlot(false); } /// diff --git a/src/OxyPlotControls/Theming/OxyPlotTheme.cs b/src/OxyPlotControls/Theming/OxyPlotTheme.cs index 48d1fe1d..720e85af 100644 --- a/src/OxyPlotControls/Theming/OxyPlotTheme.cs +++ b/src/OxyPlotControls/Theming/OxyPlotTheme.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using OxyPlot; namespace OxyPlotControls diff --git a/src/OxyPlotControls/Theming/OxyPlotThemeManager.cs b/src/OxyPlotControls/Theming/OxyPlotThemeManager.cs index 76fec6ed..a972b8d0 100644 --- a/src/OxyPlotControls/Theming/OxyPlotThemeManager.cs +++ b/src/OxyPlotControls/Theming/OxyPlotThemeManager.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.Generic; using System.Windows; using System.Windows.Media; diff --git a/src/SoftwareUpdate.Updater/InstallationManager.cs b/src/SoftwareUpdate.Updater/InstallationManager.cs index a768a0c9..4e9c4f9b 100644 --- a/src/SoftwareUpdate.Updater/InstallationManager.cs +++ b/src/SoftwareUpdate.Updater/InstallationManager.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Diagnostics; using System.IO; @@ -360,6 +330,29 @@ private void CleanUp(string? backupDir, bool success) File.Delete(_args.ZipPath); _log("Deleted update package."); } + + // Best-effort: also delete the parent directory if it is the per-download + // staging folder created by GitHubUpdateService at "%TEMP%/SoftwareUpdate/{guid}". + // Restrict the cleanup to that exact pattern so we never recursively delete + // a user-supplied path or anything outside %TEMP%. + var zipDir = Path.GetDirectoryName(_args.ZipPath); + if (!string.IsNullOrEmpty(zipDir) && Directory.Exists(zipDir)) + { + var tempRoot = Path.GetFullPath(Path.Combine(Path.GetTempPath(), "SoftwareUpdate")); + var fullZipDir = Path.GetFullPath(zipDir); + var parent = Path.GetDirectoryName(fullZipDir); + var isInTempStagingArea = + parent != null && + string.Equals(Path.GetFullPath(parent), tempRoot, StringComparison.OrdinalIgnoreCase) && + // The leaf must be a GUID-shaped name (32 hex chars, no dashes — Guid("N")). + Guid.TryParseExact(Path.GetFileName(fullZipDir), "N", out _); + + if (isInTempStagingArea && Directory.GetFileSystemEntries(fullZipDir).Length == 0) + { + Directory.Delete(fullZipDir); + _log("Deleted empty staging directory."); + } + } } catch (Exception ex) { @@ -418,10 +411,26 @@ private void RestartApplication() }; // Process.Start can return null when UseShellExecute redirects to an already-running - // instance. Guard the null before calling Dispose through the using. - var started = Process.Start(startInfo); - started?.Dispose(); - _log("Application restarted."); + // instance, and can throw on AV-blocked or otherwise-unstartable executables. Log + // either outcome so the post-install state is auditable instead of silently treated + // as success — the user may otherwise see no app come back and have no idea why. + try + { + var started = Process.Start(startInfo); + if (started == null) + { + _log($"Warning: Process.Start returned null for {exePath}. Update applied, but the application " + + "could not be restarted automatically. Please launch it manually."); + return; + } + started.Dispose(); + _log("Application restarted."); + } + catch (Exception ex) + { + _log($"Error: Failed to restart application at {exePath}: {ex.GetType().Name}: {ex.Message}. " + + "Update applied successfully but please launch the application manually."); + } } /// diff --git a/src/SoftwareUpdate.Updater/Program.cs b/src/SoftwareUpdate.Updater/Program.cs index f4203e80..03314c5f 100644 --- a/src/SoftwareUpdate.Updater/Program.cs +++ b/src/SoftwareUpdate.Updater/Program.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.IO; using System.Threading; @@ -56,6 +26,15 @@ internal class Program /// private const int AutoCloseTimeoutMs = 3000; + /// + /// Timeout for the failure-path "press any key to exit" prompt. Longer than the + /// success-path timeout so users with an attached console have time to read the + /// error message. The same guarded WaitForKeyWithTimeout helper handles the + /// no-console case (when launched with CreateNoWindow=true) by returning + /// immediately rather than throwing InvalidOperationException. + /// + private const int FailureCloseTimeoutMs = 15000; + /// /// Polling interval in milliseconds when checking for user key input. /// A small value provides responsive key detection without excessive CPU usage. @@ -134,8 +113,16 @@ static int Main(string[] args) Console.WriteLine("The application may need to be reinstalled manually."); Console.WriteLine("Check the log file for details."); Console.WriteLine(); - Console.WriteLine("Press any key to exit..."); - Console.ReadKey(true); + Console.WriteLine($"Press any key to exit (auto-closing in {FailureCloseTimeoutMs / 1000} seconds)..."); + // Use the same guarded wait as the success path. With CreateNoWindow=true the + // console is not attached and Console.ReadKey throws InvalidOperationException; + // the helper catches that case and returns immediately rather than crashing + // the updater mid-failure (which previously left the install in a corrupt state + // with no UI feedback). Longer timeout gives users with consoles time to read. + if (!WaitForKeyWithTimeout(FailureCloseTimeoutMs)) + { + Console.WriteLine("Auto-closing..."); + } return 1; } diff --git a/src/SoftwareUpdate.Updater/UpdaterArguments.cs b/src/SoftwareUpdate.Updater/UpdaterArguments.cs index 17206b99..e3a7e9cc 100644 --- a/src/SoftwareUpdate.Updater/UpdaterArguments.cs +++ b/src/SoftwareUpdate.Updater/UpdaterArguments.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; @@ -140,9 +110,25 @@ public void Validate() errors.Add("--pid is required and must be a valid process ID"); if (string.IsNullOrEmpty(ZipPath)) + { errors.Add("--zip is required"); + } else if (!System.IO.File.Exists(ZipPath)) - errors.Add($"Zip file not found: {ZipPath}"); + { + // The updater waits up to 60 seconds for the parent process to exit before it + // does anything. During that window the zip can disappear: AV scanners, Windows + // %TEMP% cleanup, OneDrive sync, or even the user manually deleting it can wipe + // the file before we ever get to extraction. Surface a clearer message so support + // logs (and the user) understand what happened instead of seeing only the bare + // path. The fix is informational; the underlying race is unchanged here. The + // larger-touch remediation is to copy the zip into the install dir before the + // parent exits — see GitHubUpdateService.InstallUpdateAndRestart for the staging + // approach. + errors.Add( + $"Zip file not found at the expected path: {ZipPath}. " + + "It may have been removed by anti-virus, %TEMP% cleanup, or another process " + + "between download and the parent application's exit. Try the update again."); + } if (string.IsNullOrEmpty(TargetDirectory)) errors.Add("--target is required"); diff --git a/src/SoftwareUpdate/Core/IUpdateService.cs b/src/SoftwareUpdate/Core/IUpdateService.cs index 6f344c8e..b96df08b 100644 --- a/src/SoftwareUpdate/Core/IUpdateService.cs +++ b/src/SoftwareUpdate/Core/IUpdateService.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Threading; using System.Threading.Tasks; @@ -116,6 +86,28 @@ Task DownloadUpdateAsync( /// Restart the application /// /// + /// + /// Lifecycle contract — this method does not return. The reference + /// implementation GitHubUpdateService.InstallUpdateAndRestart calls + /// after spawning the updater, so + /// no code in the calling application runs after this method returns: + /// finally blocks, Application.Exit handlers, OnClosing + /// overrides, and IDisposable.Dispose calls are all skipped. + /// + /// + /// Callers MUST flush user-visible state before invoking — including but + /// not limited to: + /// + /// Persisting UserSettings / RecentFiles via their Save methods + /// Prompting to save dirty projects (the framework's normal close-flow handler is a good model) + /// Closing open file/database handles, stopping background workers, and flushing logs + /// + /// + /// + /// See the FrameworkUI shell's MainWindow.DownloadAndInstallUpdateAsync + /// for an example consumer that runs the dirty-project save flow before + /// invoking this method. + /// /// void InstallUpdateAndRestart(string downloadedFilePath); @@ -140,11 +132,35 @@ Task DownloadUpdateAsync( /// /// Occurs when an update check completes. /// + /// + /// + /// Threading: handlers may be invoked on a thread-pool thread, not on + /// the UI thread. This event is raised from + /// after the asynchronous network I/O completes, so the continuation can run + /// on any . + /// WPF consumers that touch UI elements from the handler MUST marshal back to + /// the UI thread via Application.Current.Dispatcher.Invoke (or + /// BeginInvoke) — accessing dependency properties off the dispatcher + /// thread will throw . + /// + /// event EventHandler? UpdateCheckCompleted; /// /// Occurs when an error occurs during update operations. /// + /// + /// + /// Threading: handlers may be invoked on a thread-pool thread, not on + /// the UI thread. This event is raised from any of the asynchronous update + /// methods (, ) + /// when an unrecoverable error occurs, so the continuation can run on any + /// . + /// WPF consumers that touch UI elements (e.g., showing a MessageBox) MUST + /// marshal back to the UI thread via Application.Current.Dispatcher.Invoke + /// or BeginInvoke. + /// + /// event EventHandler? UpdateError; } } diff --git a/src/SoftwareUpdate/Core/UpdateCheckResult.cs b/src/SoftwareUpdate/Core/UpdateCheckResult.cs index 204469a6..062e7536 100644 --- a/src/SoftwareUpdate/Core/UpdateCheckResult.cs +++ b/src/SoftwareUpdate/Core/UpdateCheckResult.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; namespace SoftwareUpdate diff --git a/src/SoftwareUpdate/Core/UpdateDownloadProgress.cs b/src/SoftwareUpdate/Core/UpdateDownloadProgress.cs index bac55077..ed053bbb 100644 --- a/src/SoftwareUpdate/Core/UpdateDownloadProgress.cs +++ b/src/SoftwareUpdate/Core/UpdateDownloadProgress.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - namespace SoftwareUpdate { /// diff --git a/src/SoftwareUpdate/Core/UpdateDownloadResult.cs b/src/SoftwareUpdate/Core/UpdateDownloadResult.cs index 1878cf75..5f1be0ed 100644 --- a/src/SoftwareUpdate/Core/UpdateDownloadResult.cs +++ b/src/SoftwareUpdate/Core/UpdateDownloadResult.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; namespace SoftwareUpdate diff --git a/src/SoftwareUpdate/Core/UpdateInfo.cs b/src/SoftwareUpdate/Core/UpdateInfo.cs index 3cf96849..46b15232 100644 --- a/src/SoftwareUpdate/Core/UpdateInfo.cs +++ b/src/SoftwareUpdate/Core/UpdateInfo.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; namespace SoftwareUpdate diff --git a/src/SoftwareUpdate/Core/UpdateOptions.cs b/src/SoftwareUpdate/Core/UpdateOptions.cs index da2620df..60023ce3 100644 --- a/src/SoftwareUpdate/Core/UpdateOptions.cs +++ b/src/SoftwareUpdate/Core/UpdateOptions.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.IO; using System.Reflection; diff --git a/src/SoftwareUpdate/Core/UpdateState.cs b/src/SoftwareUpdate/Core/UpdateState.cs index 200e251a..2d6994d0 100644 --- a/src/SoftwareUpdate/Core/UpdateState.cs +++ b/src/SoftwareUpdate/Core/UpdateState.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - namespace SoftwareUpdate { /// diff --git a/src/SoftwareUpdate/GitHub/GitHubRelease.cs b/src/SoftwareUpdate/GitHub/GitHubRelease.cs index 759a5c61..5d67611e 100644 --- a/src/SoftwareUpdate/GitHub/GitHubRelease.cs +++ b/src/SoftwareUpdate/GitHub/GitHubRelease.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Globalization; diff --git a/src/SoftwareUpdate/GitHub/GitHubReleaseAsset.cs b/src/SoftwareUpdate/GitHub/GitHubReleaseAsset.cs index e64515d4..07d0310f 100644 --- a/src/SoftwareUpdate/GitHub/GitHubReleaseAsset.cs +++ b/src/SoftwareUpdate/GitHub/GitHubReleaseAsset.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Text.Json.Serialization; namespace SoftwareUpdate.GitHub diff --git a/src/SoftwareUpdate/GitHub/GitHubUpdateService.cs b/src/SoftwareUpdate/GitHub/GitHubUpdateService.cs index 848c60c7..2d1dc271 100644 --- a/src/SoftwareUpdate/GitHub/GitHubUpdateService.cs +++ b/src/SoftwareUpdate/GitHub/GitHubUpdateService.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Diagnostics; @@ -127,9 +97,43 @@ public UpdateInfo? AvailableUpdate /// public event EventHandler? UpdateError; + /// + /// Throws if the current is + /// not in . Public methods call this at entry to enforce the + /// state machine: rejects re-entry while a previous + /// install is in flight; requires an UpdateAvailable + /// outcome from a prior check; requires a + /// completed download (ReadyToInstall). + /// + /// The calling method's name (used in the exception message). + /// The set of states that permit the call to proceed. + /// Thrown when is not allowed. + private void EnsureState(string caller, params UpdateState[] allowed) + { + UpdateState current; + lock (_lock) { current = _state; } + if (Array.IndexOf(allowed, current) < 0) + { + throw new InvalidOperationException( + $"{caller} cannot run while the update service is in the {current} state. " + + $"Expected one of: {string.Join(", ", allowed)}."); + } + } + /// public async Task CheckForUpdateAsync(CancellationToken cancellationToken = default) { + // A check may run from any state EXCEPT Installing (the updater process is mid-handoff + // and the in-process service should not race it). + EnsureState(nameof(CheckForUpdateAsync), + UpdateState.Idle, + UpdateState.Checking, + UpdateState.UpdateAvailable, + UpdateState.UpToDate, + UpdateState.Downloading, + UpdateState.ReadyToInstall, + UpdateState.Error); + State = UpdateState.Checking; try @@ -213,7 +217,8 @@ public async Task CheckForUpdateAsync(CancellationToken cance ReleaseNotes = release.Body, PublishedAt = release.GetPublishedDateTime(), IsPreRelease = release.PreRelease, - ReleasePageUrl = release.HtmlUrl + ReleasePageUrl = release.HtmlUrl, + Sha256Checksum = ExtractSha256Checksum(release.Body) }; // Atomically update AvailableUpdate, IsSkipped, and State in a single lock @@ -223,7 +228,9 @@ public async Task CheckForUpdateAsync(CancellationToken cance lock (_lock) { _availableUpdate = updateInfo; - isSkipped = _skippedVersions.Contains(releaseVersion.ToString()); + // Use the metadata-stripped key so two builds of "1.2.3" with different + // build metadata still match the same skip entry. + isSkipped = _skippedVersions.Contains(GetSkipKey(releaseVersion)); _state = UpdateState.UpdateAvailable; } @@ -276,8 +283,12 @@ public async Task DownloadUpdateAsync( IProgress? progress = null, CancellationToken cancellationToken = default) { + // Argument validation runs before the state check so that misuse (a null update) + // surfaces as an ArgumentNullException regardless of state — callers shouldn't have + // to drive the state machine just to get the right exception type for a bad arg. if (update == null) throw new ArgumentNullException(nameof(update)); + EnsureState(nameof(DownloadUpdateAsync), UpdateState.UpdateAvailable); State = UpdateState.Downloading; @@ -336,16 +347,18 @@ public async Task DownloadUpdateAsync( while ((bytesRead = await contentStream.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) > 0) { - await fileStream.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false); - totalRead += bytesRead; - - // Security: Enforce maximum download size to prevent DoS - if (totalRead > MaxDownloadSizeBytes) + // Security: Enforce maximum download size BEFORE writing the chunk to disk. + // Checking after WriteAsync meant the over-limit chunk was already on disk + // before the throw, partially defeating the DoS guard. + if (totalRead + bytesRead > MaxDownloadSizeBytes) { throw new InvalidOperationException( $"Download exceeded maximum allowed size of {MaxDownloadSizeBytes / 1024 / 1024} MB."); } + await fileStream.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false); + totalRead += bytesRead; + // Report progress if (progress != null) { @@ -433,6 +446,8 @@ public void InstallUpdateAndRestart(string downloadedFilePath) if (!File.Exists(downloadedFilePath)) throw new FileNotFoundException("Downloaded update file not found.", downloadedFilePath); + EnsureState(nameof(InstallUpdateAndRestart), UpdateState.ReadyToInstall); + State = UpdateState.Installing; var updaterPath = Options.ResolvedUpdaterPath; @@ -459,6 +474,30 @@ public void InstallUpdateAndRestart(string downloadedFilePath) var targetDir = Options.ResolvedInstallDirectory; var mainExe = Options.ResolvedMainExecutableName; + // Stage the zip into the install directory under a stable name BEFORE we exit. If + // the download landed in %TEMP% (typical), AV scanners and Windows temp-cleanup can + // delete it during the 60-second window between parent exit and updater extraction, + // leaving the updater unable to find its payload. Copying into the install dir + // (which is generally not subject to %TEMP% sweeps) closes that window. We use a + // GUID-suffixed name so concurrent or repeated update attempts don't collide. + var stagedZipPath = downloadedFilePath; + try + { + var stagedDir = Path.Combine(targetDir, "updates_pending"); + Directory.CreateDirectory(stagedDir); + var stagedName = $"update_{Guid.NewGuid():N}{Path.GetExtension(downloadedFilePath)}"; + stagedZipPath = Path.Combine(stagedDir, stagedName); + File.Copy(downloadedFilePath, stagedZipPath, overwrite: true); + } + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException) + { + // If staging fails (read-only install dir, permission issue), fall back to the + // original temp path. The softer Validate failure in UpdaterArguments will then + // surface a clearer message if the zip is later swept up. + Debug.WriteLine($"[Update] Failed to stage zip into install dir, falling back to temp path: {ex.Message}"); + stagedZipPath = downloadedFilePath; + } + // Use ArgumentList for safe argument passing (no manual quoting/escaping) var startInfo = new ProcessStartInfo { @@ -469,7 +508,7 @@ public void InstallUpdateAndRestart(string downloadedFilePath) startInfo.ArgumentList.Add("--pid"); startInfo.ArgumentList.Add(currentPid.ToString()); startInfo.ArgumentList.Add("--zip"); - startInfo.ArgumentList.Add(downloadedFilePath); + startInfo.ArgumentList.Add(stagedZipPath); startInfo.ArgumentList.Add("--target"); startInfo.ArgumentList.Add(targetDir); startInfo.ArgumentList.Add("--exe"); @@ -495,7 +534,7 @@ public void SkipVersion(SemanticVersion? version) lock (_lock) { - _skippedVersions.Add(version.ToString()); + _skippedVersions.Add(GetSkipKey(version)); } SaveSkippedVersions(); } @@ -507,10 +546,31 @@ public bool IsVersionSkipped(SemanticVersion? version) lock (_lock) { - return _skippedVersions.Contains(version.ToString()); + return _skippedVersions.Contains(GetSkipKey(version)); } } + /// + /// Builds the persisted "skip" key for a . + /// + /// + /// SemVer 2.0 §10 declares that build metadata MUST be ignored when determining version + /// precedence — two versions that differ only in +build metadata represent the + /// same release. includes that metadata, so using + /// it directly would let "1.2.3+build.42" be marked skipped while "1.2.3+build.43" is + /// still surfaced. This helper returns MAJOR.MINOR.PATCH[-PRERELEASE] so a single + /// skip entry covers every metadata variant of the same release. + /// + /// The version whose skip key should be computed. + /// The metadata-stripped persistence key. + private static string GetSkipKey(SemanticVersion version) + { + var key = $"{version.Major}.{version.Minor}.{version.Patch}"; + if (version.IsPreRelease) + key += "-" + version.PreRelease; + return key; + } + /// public void ClearSkippedVersions() { @@ -572,9 +632,38 @@ private static string ComputeSha256Checksum(string filePath) } } + // Pre-compiled regex for SHA256 checksum extraction. Matches "SHA256:" (case-insensitive) + // followed by optional whitespace and exactly 64 hex characters. The release-notes convention + // documented for this framework is `SHA256: ` somewhere in the body of the GitHub release. + private static readonly Regex Sha256ChecksumPattern = new Regex( + @"SHA256\s*[:=]\s*([0-9a-fA-F]{64})", + RegexOptions.IgnoreCase | RegexOptions.Compiled); + + /// + /// Extracts a SHA256 checksum from GitHub release notes when present. + /// + /// The body of the GitHub release (markdown). + /// + /// The lowercase 64-character hex checksum if a SHA256: <hex> token is present + /// in the release notes; otherwise null. Absence is treated as silent-skip per the + /// documented contract on . + /// + private static string? ExtractSha256Checksum(string? releaseBody) + { + if (string.IsNullOrEmpty(releaseBody)) return null; + var match = Sha256ChecksumPattern.Match(releaseBody); + return match.Success ? match.Groups[1].Value.ToLowerInvariant() : null; + } + /// /// Loads skipped versions from disk. /// + /// + /// Migration: prior to F-005 the file persisted full + /// output, which embedded any build metadata (+build.42). Each line is now reduced + /// to a metadata-stripped key (MAJOR.MINOR.PATCH[-PRERELEASE]) so old entries from + /// previous versions still match against skip checks computed by GetSkipKey. + /// private void LoadSkippedVersions() { _skippedVersions = new HashSet(StringComparer.OrdinalIgnoreCase); @@ -587,8 +676,19 @@ private void LoadSkippedVersions() var lines = File.ReadAllLines(filePath); foreach (var line in lines) { - if (!string.IsNullOrWhiteSpace(line)) - _skippedVersions.Add(line.Trim()); + if (string.IsNullOrWhiteSpace(line)) continue; + var trimmed = line.Trim(); + + // Migrate legacy "1.2.3+build.42" entries to "1.2.3" so the in-memory set + // always uses the same key shape that SkipVersion / IsVersionSkipped emit. + if (SemanticVersion.TryParse(trimmed, out var parsed) && parsed != null) + { + _skippedVersions.Add(GetSkipKey(parsed)); + } + else + { + _skippedVersions.Add(trimmed); + } } } } @@ -624,8 +724,11 @@ private void SaveSkippedVersions() } // Write to a temp file then atomically rename to prevent a partial write - // from corrupting the persisted file. - var tempPath = filePath + ".tmp"; + // from corrupting the persisted file. Use a per-call unique temp suffix so two + // concurrent saves never collide on the same on-disk path: a fixed ".tmp" suffix + // would let a second writer truncate or rename a temp file the first writer is + // still using, producing zero-byte or corrupt output. + var tempPath = filePath + "." + Guid.NewGuid().ToString("N") + ".tmp"; File.WriteAllLines(tempPath, versionsCopy); File.Move(tempPath, filePath, overwrite: true); } @@ -656,6 +759,13 @@ protected virtual void Dispose(bool disposing) if (disposing) { _httpClient?.Dispose(); + + // Drop subscriber references so the service does not pin handlers (and any + // captured target objects) past disposal. Without this, a subscriber's + // closure can keep a reference to the service alive — and vice versa — for + // the lifetime of the host process. + UpdateCheckCompleted = null; + UpdateError = null; } _disposed = true; } diff --git a/src/SoftwareUpdate/Utilities/SemanticVersion.cs b/src/SoftwareUpdate/Utilities/SemanticVersion.cs index 395f36d1..92e937ee 100644 --- a/src/SoftwareUpdate/Utilities/SemanticVersion.cs +++ b/src/SoftwareUpdate/Utilities/SemanticVersion.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Text.RegularExpressions; @@ -54,9 +24,15 @@ namespace SoftwareUpdate /// public class SemanticVersion : IComparable, IEquatable { - // Regex pattern for semantic version parsing + // Regex pattern for semantic version parsing. + // Pre-release identifiers (per SemVer 2.0 §9) are dot-separated tokens; numeric tokens + // MUST NOT include leading zeros (so "1.0.0-alpha.01" is invalid). Build metadata + // (§10) keeps the broader [0-9A-Za-z-] alphabet — leading zeros are allowed there. + // Each pre-release identifier must be either a non-zero numeric ("0", or [1-9][0-9]*) + // or contain at least one non-digit character. + private const string PreReleaseIdentifier = @"(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)"; private static readonly Regex VersionPattern = new Regex( - @"^v?(?\d+)\.(?\d+)(?:\.(?\d+))?(?:-(?[0-9A-Za-z\-\.]+))?(?:\+(?[0-9A-Za-z\-\.]+))?$", + @"^v?(?\d+)\.(?\d+)(?:\.(?\d+))?(?:-(?" + PreReleaseIdentifier + @"(?:\." + PreReleaseIdentifier + @")*))?(?:\+(?[0-9A-Za-z\-]+(?:\.[0-9A-Za-z\-]+)*))?$", RegexOptions.Compiled | RegexOptions.IgnoreCase); /// @@ -159,6 +135,26 @@ public static bool TryParse(string versionString, out SemanticVersion? version) var preRelease = match.Groups["prerelease"].Success ? match.Groups["prerelease"].Value : null; var build = match.Groups["build"].Success ? match.Groups["build"].Value : null; + // SemVer 2.0 §9: numeric identifiers in the pre-release portion MUST NOT include + // leading zeros. The base regex accepts the broader `[0-9A-Za-z-.]+` character + // class, so re-validate any all-digit dot-separated sub-identifiers here. (We do + // not enforce this for build metadata per §10, which permits leading zeros.) + if (preRelease != null) + { + foreach (var part in preRelease.Split('.')) + { + // Empty segments (e.g. "alpha..1") are invalid per §9. + if (part.Length == 0) return false; + // Numeric-only segment longer than 1 character starting with '0' is invalid. + bool isAllDigits = true; + for (int i = 0; i < part.Length; i++) + { + if (!char.IsDigit(part[i])) { isAllDigits = false; break; } + } + if (isAllDigits && part.Length > 1 && part[0] == '0') return false; + } + } + version = new SemanticVersion(major, minor, patch, preRelease, build); return true; } diff --git a/src/SoftwareUpdate/Utilities/UpdaterBootstrapper.cs b/src/SoftwareUpdate/Utilities/UpdaterBootstrapper.cs index 97fdd0bd..2dd5fab4 100644 --- a/src/SoftwareUpdate/Utilities/UpdaterBootstrapper.cs +++ b/src/SoftwareUpdate/Utilities/UpdaterBootstrapper.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Diagnostics; using System.IO; diff --git a/src/Themes/Core/ColorKeys.cs b/src/Themes/Core/ColorKeys.cs index dc9fa8b3..e71ef752 100644 --- a/src/Themes/Core/ColorKeys.cs +++ b/src/Themes/Core/ColorKeys.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - namespace Themes { /// diff --git a/src/Themes/Core/IThemeService.cs b/src/Themes/Core/IThemeService.cs index 8e6bf83d..b797eebc 100644 --- a/src/Themes/Core/IThemeService.cs +++ b/src/Themes/Core/IThemeService.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; namespace Themes diff --git a/src/Themes/Core/Theme.cs b/src/Themes/Core/Theme.cs index ce663ebb..baacf253 100644 --- a/src/Themes/Core/Theme.cs +++ b/src/Themes/Core/Theme.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - namespace Themes { /// diff --git a/src/Themes/Core/ThemeChangedEventArgs.cs b/src/Themes/Core/ThemeChangedEventArgs.cs index 80e800ff..39374aa9 100644 --- a/src/Themes/Core/ThemeChangedEventArgs.cs +++ b/src/Themes/Core/ThemeChangedEventArgs.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Windows; diff --git a/src/Themes/Core/ThemeResourceHelper.cs b/src/Themes/Core/ThemeResourceHelper.cs index 08cfc8b6..166b2157 100644 --- a/src/Themes/Core/ThemeResourceHelper.cs +++ b/src/Themes/Core/ThemeResourceHelper.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; @@ -199,7 +169,17 @@ public static bool TryParseTheme(string themeName, out Theme theme) return false; } - return Enum.TryParse(themeName, ignoreCase: true, out theme); + // Enum.TryParse will succeed for any integer string (including values outside the enum + // range), so we additionally check that the parsed value is a defined enum member. + if (!Enum.TryParse(themeName, ignoreCase: true, out Theme parsed) || + !Enum.IsDefined(typeof(Theme), parsed)) + { + theme = Theme.Light; + return false; + } + + theme = parsed; + return true; } #endregion diff --git a/src/Themes/Core/ThemeService.cs b/src/Themes/Core/ThemeService.cs index 88ab9c79..7a9a5eeb 100644 --- a/src/Themes/Core/ThemeService.cs +++ b/src/Themes/Core/ThemeService.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Threading; using System.Windows; @@ -240,13 +210,30 @@ public void SetTheme(Theme theme) if (!app.Dispatcher.CheckAccess()) { - app.Dispatcher.BeginInvoke(() => SetTheme(theme)); + // Use Invoke (synchronous) so any exception thrown on the UI thread surfaces + // back to the original caller. BeginInvoke would fire-and-forget, swallowing + // failures and making caller-side error handling impossible. + app.Dispatcher.Invoke(() => SetTheme(theme)); return; } + // Build the new dictionary outside the lock. Loading XAML via pack URI can be + // slow and can recursively touch other resource dictionaries; doing it under + // the lock would extend the critical section unnecessarily. + var newColorDictionary = new ResourceDictionary + { + Source = new Uri(ThemeResourceHelper.GetColorDictionaryUri(theme), UriKind.Absolute) + }; + + // Capture state under the lock, but DO NOT touch MergedDictionaries here. + // WPF resource invalidation can synchronously fire callbacks into subscribers + // that re-enter the CurrentTheme getter (which acquires _lock). Holding _lock + // during MergedDictionaries.Remove/Add would risk a deadlock; mutate after the + // lock is released. The whole method is already serialized on the UI thread + // via the BeginInvoke marshal above, so MergedDictionaries access is single- + // threaded even after lock release. Theme oldTheme; - ResourceDictionary newColorDictionary; - + ResourceDictionary? oldColorDictionary; lock (_lock) { if (!_isInitialized) @@ -261,24 +248,21 @@ public void SetTheme(Theme theme) } oldTheme = _currentTheme; - _currentTheme = theme; - - // Remove old color dictionary - if (_currentColorDictionary != null) - { - app.Resources.MergedDictionaries.Remove(_currentColorDictionary); - } + oldColorDictionary = _currentColorDictionary; - // Create and add new color dictionary - newColorDictionary = new ResourceDictionary - { - Source = new Uri(ThemeResourceHelper.GetColorDictionaryUri(theme), UriKind.Absolute) - }; - app.Resources.MergedDictionaries.Add(newColorDictionary); + _currentTheme = theme; _currentColorDictionary = newColorDictionary; } - // Raise event outside the lock to prevent deadlocks + // Mutate MergedDictionaries and raise the event outside the lock so that + // subscribers (and synchronous WPF resource-invalidation callbacks) can + // safely call back into the service. + if (oldColorDictionary != null) + { + app.Resources.MergedDictionaries.Remove(oldColorDictionary); + } + app.Resources.MergedDictionaries.Add(newColorDictionary); + OnThemeChanged(new ThemeChangedEventArgs(oldTheme, theme, newColorDictionary)); } diff --git a/src/Themes/Resources/Controls/Converters/CutoffConverter.cs b/src/Themes/Resources/Controls/Converters/CutoffConverter.cs index 1d74b7b9..3d2b0892 100644 --- a/src/Themes/Resources/Controls/Converters/CutoffConverter.cs +++ b/src/Themes/Resources/Controls/Converters/CutoffConverter.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Globalization; using System.Windows; diff --git a/src/Themes/Resources/Controls/Converters/TabSizeConverter.cs b/src/Themes/Resources/Controls/Converters/TabSizeConverter.cs index 38f6f1bd..d0acd4ee 100644 --- a/src/Themes/Resources/Controls/Converters/TabSizeConverter.cs +++ b/src/Themes/Resources/Controls/Converters/TabSizeConverter.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Globalization; using System.Windows.Controls; diff --git a/src/Themes/Resources/Controls/Converters/TreeViewIndentConverter.cs b/src/Themes/Resources/Controls/Converters/TreeViewIndentConverter.cs index 332b6807..68dfc562 100644 --- a/src/Themes/Resources/Controls/Converters/TreeViewIndentConverter.cs +++ b/src/Themes/Resources/Controls/Converters/TreeViewIndentConverter.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Globalization; using System.Windows; diff --git a/tests/CULTURE_SMOKE_TESTS.md b/tests/CULTURE_SMOKE_TESTS.md new file mode 100644 index 00000000..0c76d8fb --- /dev/null +++ b/tests/CULTURE_SMOKE_TESTS.md @@ -0,0 +1,114 @@ +# Culture Smoke Tests — Manual Verification + +This file documents the manual smoke tests for international number/date formatting that cannot be automated easily. Most culture handling is covered by unit tests (see `tests/*/CultureRoundTripTests.cs`, `DBFCultureRoundTripTests.cs`, `NumberFormatHelperCultureTests.cs`, etc.). These tests cover what unit tests cannot: + +- AvalonDock layout serialization (no test project exists for AvalonDock) +- End-to-end WPF binding behavior with the user's actual Windows region setting +- Visual confirmation that displays render correctly across cultures + +## Setup — switch Windows to German region + +1. **Settings → Time & language → Language & region → Regional format** +2. Choose **German (Germany)** and click **Apply** +3. **Sign out and back in** (some apps cache the locale at startup) +4. Verify: open Calculator, type a decimal value — should show comma as decimal separator + +## Test 1 — AvalonDock layout round-trip (HIGHEST PRIORITY) + +**Why this is manual**: AvalonDock has no test project in the solution. The fix at `LayoutContent.cs:745, 749` (PreviousContainerIndex / InitialContainerIndex `int.Parse` with InvariantCulture) only manifests when reloading a layout file written under one culture on a machine running another. Since these are integers without decimal separators in the default .NET formatting, this is largely defensive — but worth verifying. + +**Steps:** +1. Run **FrameworkUI.Demo** (or any host that uses AvalonDock for docking) +2. Drag a panel out to undock it (creates a floating window) — note its position +3. Save layout via **File → Save** (or whatever the host's save action is) +4. Close the application +5. Restart the application +6. Open the saved layout file +7. **Verify**: the previously-floating panel returns to the same position with the same size + +**Expected file content sanity check** (open the saved layout `.xml` in a text editor): +- All numeric attributes should use `.` as decimal separator (e.g., `FloatingLeft="123.45"`) +- No `,` decimal separators in any numeric attribute regardless of Windows region + +## Test 2 — OxyPlot settings round-trip + +**Steps:** +1. Run **OxyPlotControls.Demo** +2. Configure a plot with non-integer axis ranges (e.g., Minimum=0.1, Maximum=99.9, MajorStep=0.5) +3. Save plot settings via the demo's save UI +4. Close, restart +5. Load the saved plot file +6. **Verify**: axis ranges restored exactly, plot looks identical + +**Expected file content** (open the saved settings `.xml`): +- All `Minimum`, `Maximum`, `MajorStep` etc. attributes use `.` decimal separator +- File loads identically on a colleague's en-US machine + +## Test 3 — DAG graph save/load (covered by automated tests, also worth manual) + +**Steps:** +1. Run **DAG.Demo** +2. Create a graph with several nodes at non-integer positions (drag to fractional coordinates) +3. Save the graph +4. Close, restart, reload +5. **Verify**: nodes appear in the same positions + +## Test 4 — DBF export + +**Steps:** +1. Run **DatabaseControls.Demo** +2. Open or create a table with a numeric column containing values like `1234.5678`, `-987.654321`, `1e-10` +3. Export the table as DBF +4. Open the exported `.dbf` file in **Microsoft Excel** (or ArcGIS, QGIS — any DBF reader) +5. **Verify**: values appear correctly in Excel (American format with `.` decimals); not parsed as text + +**Hex check** (optional — use a hex editor like HxD): +- Numeric column data should contain ASCII strings like `1.23456789012e+003` (period decimal) +- **Should NOT** contain `1,23456789012e+003` (comma decimal) regardless of Windows region + +## Test 5 — User input (NumericTextBox / property controls) + +**Steps:** +1. Run any demo with `NumericTextBox`, `NumericUpDown`, or property-grid controls (e.g., **GenericControls.Demo**) +2. Click a numeric field and type **1,5** (German format) +3. Tab away to commit +4. **Verify**: the underlying value is `1.5`, the field redisplays as `1,5` +5. Type **1.234,56** (German with thousands separator) +6. **Verify**: parses as `1234.56`, redisplays as `1.234,56` + +## Test 6 — DataGrid copy-paste cross-culture + +**Steps:** +1. Run **GenericControls.Demo** with a `CopyPasteDataGrid` showing numeric data +2. Copy a row containing `1.5` (Note: copy text from another app or have a colleague send a US-formatted CSV row) +3. Paste into the grid +4. **Verify**: parses correctly via the dual-culture fallback in `CopyPasteDataGrid` and `DataTableView.ConvertToColumnType` +5. Type `1,5` directly into a cell +6. **Verify**: also parses correctly (CurrentCulture leg) + +## Test 7 — Distribution Selector statistics display + +**Steps:** +1. Run **NumericControls.Demo** → Distribution Selector +2. Choose any distribution and load sample data +3. **Verify**: the summary statistics table displays values with German decimal separator (e.g., `1,2345`) + +## Reverting + +After testing, switch Windows back to your normal region: +- **Settings → Time & language → Language & region → Regional format → English (United States)** +- Sign out / back in + +## Reporting issues + +If any of the above fails under German region, file an issue with: +- Test number and step +- Expected vs actual behavior +- Screenshot of the failure +- Contents of the saved file (if applicable) + +Other relevant cultures to test if you have the time: +- **fr-FR** (French) — comma decimal, narrow no-break space thousands +- **tr-TR** (Turkish) — has unusual `i`/`İ` casing rules that historically caused .NET regressions +- **fa-IR** (Persian) — uses non-Western digits `۰-۹` +- **ar-SA** (Arabic) — RTL layout, may need separate visual testing diff --git a/tests/DAG.Tests/CultureRoundTripTests.cs b/tests/DAG.Tests/CultureRoundTripTests.cs new file mode 100644 index 00000000..5a159b36 --- /dev/null +++ b/tests/DAG.Tests/CultureRoundTripTests.cs @@ -0,0 +1,214 @@ +using System.Globalization; +using System.Threading; +using System.Xml.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace DAG.Tests +{ + /// + /// Verifies that graph serialization survives a round-trip under non-US cultures. + /// + /// + /// On a German machine (decimal comma), naive ToString/Parse without InvariantCulture + /// would write "1,5" instead of "1.5", breaking interchange across machines. + /// + [TestClass] + public class CultureRoundTripTests + { + // Each value listed here has a decimal point in its G17 mantissa, so under bare + // (non-Invariant) ToString on de-DE it would serialize with a comma separator and + // fail to parse on read. -0.0 is included for sign preservation and is documented + // as a serialization-completeness case (the "-0" string is culture-independent). + private static readonly double[] TrickyValues = + { + 1234.5678, + -987.654321, + 1.23456789e-10, + 1.23456789e+15, + 0.1, + -0.0, + double.Epsilon, + double.MaxValue, + double.MinValue, + 1e-300, + -1e+250, + }; + + [TestMethod] + public void Graph_RoundTrip_PreservesNodePositionsBitExact_UnderGermanCulture() + { + RunUnderCulture("de-DE", () => + { + var graph = new SimpleTestGraph { Scale = 1.234567890123456 }; + for (int i = 0; i < TrickyValues.Length; i++) + { + var node = new SimpleTestNode($"Node{i}") + { + LeftPosition = TrickyValues[i], + TopPosition = TrickyValues[(i + 1) % TrickyValues.Length], + }; + node.AddInput("In"); + node.AddOutput("Out"); + graph.Nodes.Add(node); + } + + XElement serialized = graph.ToXElement(); + var loaded = new SimpleTestGraph(serialized); + + AssertBitExact(graph.Scale, loaded.Scale, "Scale"); + Assert.AreEqual(graph.Nodes.Count, loaded.Nodes.Count); + for (int i = 0; i < graph.Nodes.Count; i++) + { + AssertBitExact(graph.Nodes[i].LeftPosition, loaded.Nodes[i].LeftPosition, $"Node{i}.LeftPosition"); + AssertBitExact(graph.Nodes[i].TopPosition, loaded.Nodes[i].TopPosition, $"Node{i}.TopPosition"); + } + }); + } + + [TestMethod] + public void Graph_SerializedXml_UsesPeriodAsDecimalSeparator_UnderGermanCulture() + { + RunUnderCulture("de-DE", () => + { + var graph = new SimpleTestGraph { Scale = 1.5 }; + var node = new SimpleTestNode("N") { LeftPosition = 2.5, TopPosition = 3.75 }; + node.AddInput("In"); + node.AddOutput("Out"); + graph.Nodes.Add(node); + + XElement serialized = graph.ToXElement(); + string xml = serialized.ToString(); + + // The serialized XML must use '.' (Invariant), not ',' (German), for decimals. + Assert.IsTrue(xml.Contains("1.5"), $"Scale '1.5' missing from XML:\n{xml}"); + Assert.IsTrue(xml.Contains("2.5"), $"LeftPosition '2.5' missing from XML:\n{xml}"); + Assert.IsTrue(xml.Contains("3.75"), $"TopPosition '3.75' missing from XML:\n{xml}"); + }); + } + + /// + /// Verifies that the sign bit of negative zero survives round-trip. + /// + /// + /// NOT a culture regression test — "-0" is culture-independent in G17 form. This + /// is a serialization-completeness test that documents sign preservation. + /// + [TestMethod] + public void Graph_RoundTrip_PreservesNegativeZeroSign() + { + RunUnderCulture("en-US", () => + { + var graph = new SimpleTestGraph(); + var node = new SimpleTestNode("N") { LeftPosition = -0.0, TopPosition = 0.0 }; + node.AddInput("In"); + node.AddOutput("Out"); + graph.Nodes.Add(node); + + XElement serialized = graph.ToXElement(); + var loaded = new SimpleTestGraph(serialized); + + long expectedNegZeroBits = System.BitConverter.DoubleToInt64Bits(-0.0); + long expectedPosZeroBits = System.BitConverter.DoubleToInt64Bits(0.0); + long loadedLeftBits = System.BitConverter.DoubleToInt64Bits(loaded.Nodes[0].LeftPosition); + long loadedTopBits = System.BitConverter.DoubleToInt64Bits(loaded.Nodes[0].TopPosition); + + Assert.AreEqual(expectedNegZeroBits, loadedLeftBits, + $"-0.0 sign bit lost: expected bits {expectedNegZeroBits}, got {loadedLeftBits}"); + Assert.AreEqual(expectedPosZeroBits, loadedTopBits, + $"+0.0 changed: expected bits {expectedPosZeroBits}, got {loadedTopBits}"); + Assert.AreNotEqual(loadedLeftBits, loadedTopBits, + "Negative zero and positive zero collapsed to the same bit pattern"); + }); + } + + /// + /// Verifies that NaN, +Infinity, and -Infinity survive round-trip. + /// + /// + /// NaN portion is serialization-completeness (the "NaN" string is culture-independent). + /// Infinity portion IS a genuine culture regression test: G17 + InvariantCulture + /// produces "Infinity"; under bare ToString on de-DE, it produces "∞", which the + /// Invariant reader rejects. Reverting the fix would break this test. + /// + [TestMethod] + public void Graph_RoundTrip_PreservesNaNAndInfinity_UnderGermanCulture() + { + RunUnderCulture("de-DE", () => + { + var graph = new SimpleTestGraph(); + var nanNode = new SimpleTestNode("NaN") { LeftPosition = double.NaN, TopPosition = double.NaN }; + nanNode.AddInput("In"); nanNode.AddOutput("Out"); + graph.Nodes.Add(nanNode); + + var posInfNode = new SimpleTestNode("PosInf") { LeftPosition = double.PositiveInfinity, TopPosition = double.PositiveInfinity }; + posInfNode.AddInput("In"); posInfNode.AddOutput("Out"); + graph.Nodes.Add(posInfNode); + + var negInfNode = new SimpleTestNode("NegInf") { LeftPosition = double.NegativeInfinity, TopPosition = double.NegativeInfinity }; + negInfNode.AddInput("In"); negInfNode.AddOutput("Out"); + graph.Nodes.Add(negInfNode); + + XElement serialized = graph.ToXElement(); + var loaded = new SimpleTestGraph(serialized); + + Assert.IsTrue(double.IsNaN(loaded.Nodes[0].LeftPosition), "NaN.LeftPosition lost"); + Assert.IsTrue(double.IsNaN(loaded.Nodes[0].TopPosition), "NaN.TopPosition lost"); + Assert.IsTrue(double.IsPositiveInfinity(loaded.Nodes[1].LeftPosition), "+Inf.LeftPosition lost"); + Assert.IsTrue(double.IsPositiveInfinity(loaded.Nodes[1].TopPosition), "+Inf.TopPosition lost"); + Assert.IsTrue(double.IsNegativeInfinity(loaded.Nodes[2].LeftPosition), "-Inf.LeftPosition lost"); + Assert.IsTrue(double.IsNegativeInfinity(loaded.Nodes[2].TopPosition), "-Inf.TopPosition lost"); + }); + } + + [TestMethod] + public void Graph_RoundTrip_LoadsUsCultureFileUnderGermanCulture() + { + // Build under en-US, serialize, then deserialize under de-DE — the file format + // must be culture-neutral or non-US users would fail to load files from US users. + XElement serialized = null; + var sourceGraph = new SimpleTestGraph(); + RunUnderCulture("en-US", () => + { + sourceGraph.Scale = 12345.6789; + var node = new SimpleTestNode("N") { LeftPosition = 100.5, TopPosition = -200.25 }; + node.AddInput("In"); + node.AddOutput("Out"); + sourceGraph.Nodes.Add(node); + serialized = sourceGraph.ToXElement(); + }); + + RunUnderCulture("de-DE", () => + { + var loaded = new SimpleTestGraph(serialized); + AssertBitExact(sourceGraph.Scale, loaded.Scale, "Scale"); + AssertBitExact(sourceGraph.Nodes[0].LeftPosition, loaded.Nodes[0].LeftPosition, "LeftPosition"); + AssertBitExact(sourceGraph.Nodes[0].TopPosition, loaded.Nodes[0].TopPosition, "TopPosition"); + }); + } + + private static void RunUnderCulture(string cultureName, System.Action body) + { + var prevCulture = Thread.CurrentThread.CurrentCulture; + try + { + var culture = new CultureInfo(cultureName); + Thread.CurrentThread.CurrentCulture = culture; + CultureInfo.CurrentCulture = culture; + body(); + } + finally + { + Thread.CurrentThread.CurrentCulture = prevCulture; + CultureInfo.CurrentCulture = prevCulture; + } + } + + private static void AssertBitExact(double expected, double actual, string label) + { + long expectedBits = System.BitConverter.DoubleToInt64Bits(expected); + long actualBits = System.BitConverter.DoubleToInt64Bits(actual); + Assert.AreEqual(expectedBits, actualBits, + $"{label}: expected {expected:R} (bits {expectedBits}), got {actual:R} (bits {actualBits})"); + } + } +} diff --git a/tests/DAG.Tests/GraphTests.cs b/tests/DAG.Tests/GraphTests.cs index 7f0793dc..d3d012da 100644 --- a/tests/DAG.Tests/GraphTests.cs +++ b/tests/DAG.Tests/GraphTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Collections.Generic; using System.Linq; diff --git a/tests/DAG.Tests/SimpleTestGraph.cs b/tests/DAG.Tests/SimpleTestGraph.cs index b5b8fd70..a0702694 100644 --- a/tests/DAG.Tests/SimpleTestGraph.cs +++ b/tests/DAG.Tests/SimpleTestGraph.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Xml.Linq; using DAG; diff --git a/tests/DAG.Tests/SimpleTestNode.cs b/tests/DAG.Tests/SimpleTestNode.cs index d40cc432..4f0e4d82 100644 --- a/tests/DAG.Tests/SimpleTestNode.cs +++ b/tests/DAG.Tests/SimpleTestNode.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* ● Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* ● Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* ● The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Xml.Linq; using DAG; diff --git a/tests/FrameworkInterfaces.Tests/AuditRegressionTests.cs b/tests/FrameworkInterfaces.Tests/AuditRegressionTests.cs new file mode 100644 index 00000000..ef024af6 --- /dev/null +++ b/tests/FrameworkInterfaces.Tests/AuditRegressionTests.cs @@ -0,0 +1,180 @@ +using System.Collections.ObjectModel; +using System.Reflection; +using System.Windows.Media; +using FrameworkInterfaces; +using FrameworkInterfaces.Tests.Undo.Actions; +using FrameworkInterfaces.Undo; +using Xunit; + +namespace FrameworkInterfaces.Tests +{ + /// + /// Regression tests pinning behavior fixed in the forensic-audit Phase 1/2 work. + /// Each test name references the audit finding ID it covers. + /// + public class AuditRegressionTests + { + #region A-001 — ElementBaseBuff.RaisePropertyChange dirty semantics + + /// + /// Concrete subclass of exposing the protected + /// RaisePropertyChange for testing. + /// + private sealed class FakeElement : ElementBaseBuff + { + public FakeElement(IElementCollection parent) : base("fake", parent) { } + + public override ImageSource ElementImage => null!; + public override bool CanCopyFromExternal => false; + public override IElement Copy(string? newName = null) => new FakeElement(ParentCollection); + public override IElement CopyFromExternal(string itemName, string fullFileName) => + new FakeElement(ParentCollection); + public override void Open() { } + public override void Save() { } + public override void Delete() { } + + public void SetIsDirty(bool value) => IsDirty = value; + + public void TriggerRaise(string propertyName, bool isDirty) => + RaisePropertyChange(propertyName, isDirty); + } + + [Fact] + public void A001_ElementBaseBuff_RaisePropertyChange_PreservesIsDirty_OnFalse() + { + // Arrange — element starts dirty; the fix's contract is that + // RaisePropertyChange("Foo", false) is "notify-only" and must NOT clear dirty. + var collection = new MockElementCollection(); + var element = new FakeElement(collection); + element.SetIsDirty(true); + Assert.True(element.IsDirty); + + // Act + element.TriggerRaise("Foo", false); + + // Assert — IsDirty must still be true (promote-only semantics). + Assert.True(element.IsDirty); + } + + [Fact] + public void A001_ElementBaseBuff_RaisePropertyChange_PromotesIsDirty_OnTrue() + { + // Arrange — clean element; the default isDirty=true overload should promote. + var collection = new MockElementCollection(); + var element = new FakeElement(collection); + Assert.False(element.IsDirty); + + // Act + element.TriggerRaise("Foo", true); + + // Assert + Assert.True(element.IsDirty); + } + + [Fact] + public void A001_ElementBaseBuff_RaisePropertyChange_RaisesPropertyChangedEvent() + { + // Arrange + var collection = new MockElementCollection(); + var element = new FakeElement(collection); + string? observed = null; + element.PropertyChanged += (_, e) => observed = e.PropertyName; + + // Act + element.TriggerRaise("Foo", false); + + // Assert — notify-only mode must still raise PropertyChanged. + Assert.Equal("Foo", observed); + } + + #endregion + + #region A-007 — ElementCollectionBase.MoveElement is undoable + + /// + /// Minimal concrete for exercising MoveElement + /// against the real undo plumbing (RecordMoveElement / UndoManager). + /// + private sealed class FakeCollection : ElementCollectionBase + { + public FakeCollection() : base(null!) { } + + public override string Name => "FakeCollection"; + + public override void Add(IElement item) + { + ElementList.Add(item); + } + + public override void Insert(int index, IElement item) + { + ElementList.Insert(index, item); + } + + public override void InsertFromExternalProject(int index, string elementName, string elementType, string fullFileName) + { + throw new NotImplementedException(); + } + + public override void Open() { } + + public override void Delete() { } + } + + [Fact] + public void A007_ElementCollectionBase_MoveElement_IsUndoable() + { + // Arrange — three elements in stable order: a, b, c. + var collection = new FakeCollection(); + var a = new MockElement { Name = "a" }; + var b = new MockElement { Name = "b" }; + var c = new MockElement { Name = "c" }; + collection.Add(a); + collection.Add(b); + collection.Add(c); + + // Force lazy creation of the UndoManager; verify clean baseline. + Assert.False(collection.UndoManager.CanUndo); + + // Act — move 'a' from position 0 to 2 → expected order [b, c, a]. + collection.MoveElement(a, 0, 2); + Assert.Same(b, collection[0]); + Assert.Same(c, collection[1]); + Assert.Same(a, collection[2]); + + // Without the fix, no MoveElementAction would have been recorded so CanUndo is false. + Assert.True(collection.UndoManager.CanUndo); + + // Act — undo the move. + collection.UndoManager.Undo(); + + // Assert — collection is restored to [a, b, c]. + Assert.Same(a, collection[0]); + Assert.Same(b, collection[1]); + Assert.Same(c, collection[2]); + } + + [Fact] + public void A007_ElementCollectionBase_MoveElement_RedoRestoresMovedOrder() + { + // Arrange + var collection = new FakeCollection(); + var a = new MockElement { Name = "a" }; + var b = new MockElement { Name = "b" }; + var c = new MockElement { Name = "c" }; + collection.Add(a); collection.Add(b); collection.Add(c); + + // Act + collection.MoveElement(a, 0, 2); + collection.UndoManager.Undo(); + collection.UndoManager.Redo(); + + // Assert — after redo, moved order is back. + Assert.Same(b, collection[0]); + Assert.Same(c, collection[1]); + Assert.Same(a, collection[2]); + } + + #endregion + } +} diff --git a/tests/FrameworkInterfaces.Tests/Messaging/BasicMessageItemTests.cs b/tests/FrameworkInterfaces.Tests/Messaging/BasicMessageItemTests.cs index 375d3577..c8da6025 100644 --- a/tests/FrameworkInterfaces.Tests/Messaging/BasicMessageItemTests.cs +++ b/tests/FrameworkInterfaces.Tests/Messaging/BasicMessageItemTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using FrameworkInterfaces; using FrameworkInterfaces.Messaging; diff --git a/tests/FrameworkInterfaces.Tests/Messaging/MessengerTests.cs b/tests/FrameworkInterfaces.Tests/Messaging/MessengerTests.cs index 55efbd6c..cd22c072 100644 --- a/tests/FrameworkInterfaces.Tests/Messaging/MessengerTests.cs +++ b/tests/FrameworkInterfaces.Tests/Messaging/MessengerTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using FrameworkInterfaces; using FrameworkInterfaces.Messaging; diff --git a/tests/FrameworkInterfaces.Tests/Undo/Actions/AddElementActionTests.cs b/tests/FrameworkInterfaces.Tests/Undo/Actions/AddElementActionTests.cs index 632213d0..5d3e98c8 100644 --- a/tests/FrameworkInterfaces.Tests/Undo/Actions/AddElementActionTests.cs +++ b/tests/FrameworkInterfaces.Tests/Undo/Actions/AddElementActionTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using FrameworkInterfaces; using FrameworkInterfaces.Undo.Actions; diff --git a/tests/FrameworkInterfaces.Tests/Undo/Actions/ElementActionTestHelpers.cs b/tests/FrameworkInterfaces.Tests/Undo/Actions/ElementActionTestHelpers.cs index 8618eaab..9e7dfa1d 100644 --- a/tests/FrameworkInterfaces.Tests/Undo/Actions/ElementActionTestHelpers.cs +++ b/tests/FrameworkInterfaces.Tests/Undo/Actions/ElementActionTestHelpers.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using FrameworkInterfaces; using System.Collections; using System.Collections.ObjectModel; @@ -230,6 +200,7 @@ internal class MockElementCollection : IElementCollection /// public event ElementRemovedEventHandler? ElementRemoved; +#pragma warning disable CS0067 // Events are never used (mock implementation satisfies interface) /// /// Occurs when a child element transitions from clean to dirty. /// @@ -238,7 +209,6 @@ internal class MockElementCollection : IElementCollection /// /// Occurs before the collection is saved. /// -#pragma warning disable CS0067 // Event is never used (mock implementation satisfies interface) public event PreviewObjectSavedEventHandler? PreviewObjectSaved; /// diff --git a/tests/FrameworkInterfaces.Tests/Undo/Actions/MoveElementActionTests.cs b/tests/FrameworkInterfaces.Tests/Undo/Actions/MoveElementActionTests.cs index b657e5d3..6b995684 100644 --- a/tests/FrameworkInterfaces.Tests/Undo/Actions/MoveElementActionTests.cs +++ b/tests/FrameworkInterfaces.Tests/Undo/Actions/MoveElementActionTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using FrameworkInterfaces; using FrameworkInterfaces.Undo.Actions; diff --git a/tests/FrameworkInterfaces.Tests/Undo/Actions/RemoveElementActionTests.cs b/tests/FrameworkInterfaces.Tests/Undo/Actions/RemoveElementActionTests.cs index 3d954c25..454c46d8 100644 --- a/tests/FrameworkInterfaces.Tests/Undo/Actions/RemoveElementActionTests.cs +++ b/tests/FrameworkInterfaces.Tests/Undo/Actions/RemoveElementActionTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using FrameworkInterfaces; using FrameworkInterfaces.Undo.Actions; diff --git a/tests/FrameworkInterfaces.Tests/Undo/CompositeActionTests.cs b/tests/FrameworkInterfaces.Tests/Undo/CompositeActionTests.cs index 08b4a261..d22347db 100644 --- a/tests/FrameworkInterfaces.Tests/Undo/CompositeActionTests.cs +++ b/tests/FrameworkInterfaces.Tests/Undo/CompositeActionTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using FrameworkInterfaces.Undo.Actions; diff --git a/tests/FrameworkInterfaces.Tests/Undo/DelegateActionTests.cs b/tests/FrameworkInterfaces.Tests/Undo/DelegateActionTests.cs index 1ea2454f..5e78c1cd 100644 --- a/tests/FrameworkInterfaces.Tests/Undo/DelegateActionTests.cs +++ b/tests/FrameworkInterfaces.Tests/Undo/DelegateActionTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using FrameworkInterfaces.Undo.Actions; diff --git a/tests/FrameworkInterfaces.Tests/Undo/PropertyChangeActionTests.cs b/tests/FrameworkInterfaces.Tests/Undo/PropertyChangeActionTests.cs index 7969d201..7b12452d 100644 --- a/tests/FrameworkInterfaces.Tests/Undo/PropertyChangeActionTests.cs +++ b/tests/FrameworkInterfaces.Tests/Undo/PropertyChangeActionTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using FrameworkInterfaces.Undo.Actions; using System.ComponentModel; diff --git a/tests/FrameworkInterfaces.Tests/Undo/UndoManagerTests.cs b/tests/FrameworkInterfaces.Tests/Undo/UndoManagerTests.cs index ca5b159d..29335e50 100644 --- a/tests/FrameworkInterfaces.Tests/Undo/UndoManagerTests.cs +++ b/tests/FrameworkInterfaces.Tests/Undo/UndoManagerTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using FrameworkInterfaces.Undo; using FrameworkInterfaces.Undo.Actions; diff --git a/tests/FrameworkInterfaces.Tests/Undo/UndoableStateBridgeTests.cs b/tests/FrameworkInterfaces.Tests/Undo/UndoableStateBridgeTests.cs index 01125ea9..329b30e3 100644 --- a/tests/FrameworkInterfaces.Tests/Undo/UndoableStateBridgeTests.cs +++ b/tests/FrameworkInterfaces.Tests/Undo/UndoableStateBridgeTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using FrameworkInterfaces.Undo; using System.ComponentModel; diff --git a/tests/GenericControls.Tests/Controls/CopyPasteDataGridTests.cs b/tests/GenericControls.Tests/Controls/CopyPasteDataGridTests.cs index b0ad166c..a6f45f57 100644 --- a/tests/GenericControls.Tests/Controls/CopyPasteDataGridTests.cs +++ b/tests/GenericControls.Tests/Controls/CopyPasteDataGridTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; namespace GenericControls.Tests.Controls; diff --git a/tests/GenericControls.Tests/Controls/HsvColorTests.cs b/tests/GenericControls.Tests/Controls/HsvColorTests.cs index 7a7cbd8b..b7f22ff8 100644 --- a/tests/GenericControls.Tests/Controls/HsvColorTests.cs +++ b/tests/GenericControls.Tests/Controls/HsvColorTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows.Media; using Xunit; diff --git a/tests/GenericControls.Tests/Controls/MessageBoxTests.cs b/tests/GenericControls.Tests/Controls/MessageBoxTests.cs index 74f35ac8..43ea80b8 100644 --- a/tests/GenericControls.Tests/Controls/MessageBoxTests.cs +++ b/tests/GenericControls.Tests/Controls/MessageBoxTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Controls; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/AlwaysVisibleConverterTests.cs b/tests/GenericControls.Tests/Converters/AlwaysVisibleConverterTests.cs index 82d6a85e..ce141536 100644 --- a/tests/GenericControls.Tests/Converters/AlwaysVisibleConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/AlwaysVisibleConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/ConverterTests.cs b/tests/GenericControls.Tests/Converters/ConverterTests.cs index 517dc210..e0336724 100644 --- a/tests/GenericControls.Tests/Converters/ConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/ConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using System.Windows.Media; diff --git a/tests/GenericControls.Tests/Converters/DataGridWidthConverterTests.cs b/tests/GenericControls.Tests/Converters/DataGridWidthConverterTests.cs index af3f955b..0434ae7d 100644 --- a/tests/GenericControls.Tests/Converters/DataGridWidthConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/DataGridWidthConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/DoubleToCornerRadiusConverterTests.cs b/tests/GenericControls.Tests/Converters/DoubleToCornerRadiusConverterTests.cs index da3fcd70..953490f3 100644 --- a/tests/GenericControls.Tests/Converters/DoubleToCornerRadiusConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/DoubleToCornerRadiusConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/DoubleToDataGridLengthConverterTests.cs b/tests/GenericControls.Tests/Converters/DoubleToDataGridLengthConverterTests.cs index 3db7c4e8..9631dcae 100644 --- a/tests/GenericControls.Tests/Converters/DoubleToDataGridLengthConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/DoubleToDataGridLengthConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Controls; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/DoubleToGridLengthConverterTests.cs b/tests/GenericControls.Tests/Converters/DoubleToGridLengthConverterTests.cs index 98d68d64..2f28591a 100644 --- a/tests/GenericControls.Tests/Converters/DoubleToGridLengthConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/DoubleToGridLengthConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/DoubleToNAConverterTests.cs b/tests/GenericControls.Tests/Converters/DoubleToNAConverterTests.cs index d537bca9..baa750bc 100644 --- a/tests/GenericControls.Tests/Converters/DoubleToNAConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/DoubleToNAConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/DoubleToThicknessConverterTests.cs b/tests/GenericControls.Tests/Converters/DoubleToThicknessConverterTests.cs index 7823760a..0f87fd3e 100644 --- a/tests/GenericControls.Tests/Converters/DoubleToThicknessConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/DoubleToThicknessConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/HorizontalAlignmentToTextAlignmentConverterTests.cs b/tests/GenericControls.Tests/Converters/HorizontalAlignmentToTextAlignmentConverterTests.cs index 2bac0a5f..c52191dd 100644 --- a/tests/GenericControls.Tests/Converters/HorizontalAlignmentToTextAlignmentConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/HorizontalAlignmentToTextAlignmentConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/InRangeConverterTests.cs b/tests/GenericControls.Tests/Converters/InRangeConverterTests.cs index d1f8cf6d..22d541b0 100644 --- a/tests/GenericControls.Tests/Converters/InRangeConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/InRangeConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/StringToDoubleConverterTests.cs b/tests/GenericControls.Tests/Converters/StringToDoubleConverterTests.cs index c0ca2916..c965c94c 100644 --- a/tests/GenericControls.Tests/Converters/StringToDoubleConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/StringToDoubleConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/StringToNAConverterTests.cs b/tests/GenericControls.Tests/Converters/StringToNAConverterTests.cs index cdfa64c3..688e9405 100644 --- a/tests/GenericControls.Tests/Converters/StringToNAConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/StringToNAConverterTests.cs @@ -1,34 +1,5 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; +using System.Threading; using Xunit; namespace GenericControls.Tests.Converters; @@ -36,6 +7,7 @@ namespace GenericControls.Tests.Converters; /// /// Unit tests for StringToNAConverter. /// +[Collection("CultureSensitive")] public class StringToNAConverterTests { /// @@ -152,4 +124,71 @@ public void ConvertBack_ThrowsNotImplementedException() Assert.Throws(() => _converter.ConvertBack("123", typeof(string), null, CultureInfo.InvariantCulture)); } + + /// + /// Verifies the converter respects the culture parameter passed by WPF rather than + /// using . Uses the string "1.5e308" because: + /// - de-DE parses it as (period interpreted as thousands separator → "15e308" overflows) + /// - Invariant parses it as the finite 1.5e308 + /// The converter returns "N/A" for infinite values and the original string for finite. + /// Setting thread to en-US and passing culture=de-DE forces the converter to honor the + /// parameter (and produce "N/A"), distinguishing it from the thread-culture path that + /// would produce "1.5e308". + /// + [Fact] + public void Convert_FiniteUnderInvariantInfiniteUnderGerman_HonorsCultureParameter() + { + RunUnderCulture("en-US", () => + { + // With param=de-DE: parses "1.5e308" as ∞ → IsInfinity → "N/A" + var result = _converter.Convert("1.5e308", typeof(string), null, new CultureInfo("de-DE")); + Assert.Equal("N/A", result); + }); + } + + /// + /// Mirror test: thread is de-DE, parameter is Invariant. With the fix, the converter + /// uses Invariant which gives finite 1.5e308 → returns the original string. Without + /// the fix, thread culture (de-DE) gives ∞ → "N/A". + /// + [Fact] + public void Convert_FiniteUnderInvariantInfiniteUnderGerman_ReturnsFiniteUnderInvariantParameter() + { + RunUnderCulture("de-DE", () => + { + var result = _converter.Convert("1.5e308", typeof(string), null, CultureInfo.InvariantCulture); + Assert.Equal("1.5e308", result); + }); + } + + /// + /// US-formatted "1.5" parses successfully under Invariant. Confirms the symmetric + /// case: providing Invariant explicitly works regardless of thread culture. + /// + [Fact] + public void Convert_USFormat_ParsesUsingInvariantCulture_RegardlessOfThreadCulture() + { + RunUnderCulture("de-DE", () => + { + var result = _converter.Convert("1.5", typeof(string), null, CultureInfo.InvariantCulture); + Assert.Equal("1.5", result); + }); + } + + private static void RunUnderCulture(string cultureName, System.Action body) + { + var prevCulture = Thread.CurrentThread.CurrentCulture; + try + { + var culture = new CultureInfo(cultureName); + Thread.CurrentThread.CurrentCulture = culture; + CultureInfo.CurrentCulture = culture; + body(); + } + finally + { + Thread.CurrentThread.CurrentCulture = prevCulture; + CultureInfo.CurrentCulture = prevCulture; + } + } } diff --git a/tests/GenericControls.Tests/Converters/TabSizeConverterTests.cs b/tests/GenericControls.Tests/Converters/TabSizeConverterTests.cs index 0ede7146..2891aa58 100644 --- a/tests/GenericControls.Tests/Converters/TabSizeConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/TabSizeConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/ThicknessToDoubleConverterTests.cs b/tests/GenericControls.Tests/Converters/ThicknessToDoubleConverterTests.cs index 236af24d..624ade4e 100644 --- a/tests/GenericControls.Tests/Converters/ThicknessToDoubleConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/ThicknessToDoubleConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/TimeTextConverterTests.cs b/tests/GenericControls.Tests/Converters/TimeTextConverterTests.cs index c15d4671..bd09d1e9 100644 --- a/tests/GenericControls.Tests/Converters/TimeTextConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/TimeTextConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using Xunit; diff --git a/tests/GenericControls.Tests/Converters/VectorToPointConverterTests.cs b/tests/GenericControls.Tests/Converters/VectorToPointConverterTests.cs index bb09f8a0..2c60d4fe 100644 --- a/tests/GenericControls.Tests/Converters/VectorToPointConverterTests.cs +++ b/tests/GenericControls.Tests/Converters/VectorToPointConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Xunit; diff --git a/tests/GenericControls.Tests/NumberFormatHelperCultureTests.cs b/tests/GenericControls.Tests/NumberFormatHelperCultureTests.cs new file mode 100644 index 00000000..4083f785 --- /dev/null +++ b/tests/GenericControls.Tests/NumberFormatHelperCultureTests.cs @@ -0,0 +1,171 @@ +using System.Globalization; +using System.Threading; +using GenericControls; +using Xunit; + +namespace GenericControls.Tests; + +/// +/// Tests in this collection mutate ; xunit must +/// not run them in parallel with anything else in the same assembly that reads culture. +/// +[CollectionDefinition("CultureSensitive", DisableParallelization = true)] +public class CultureSensitiveCollection { } + +/// +/// Verifies respects the current culture for parsing +/// and formatting across decimal-comma cultures (de-DE, fr-FR), RTL cultures (ar-SA), +/// and non-Western digit cultures (fa-IR Persian). +/// +[Collection("CultureSensitive")] +public class NumberFormatHelperCultureTests +{ + [Theory] + [InlineData("de-DE", "1,5", 1.5)] + [InlineData("de-DE", "1.234,56", 1234.56)] + [InlineData("fr-FR", "1,5", 1.5)] + [InlineData("en-US", "1.5", 1.5)] + [InlineData("en-US", "1,234.56", 1234.56)] + public void TryParseDouble_RespectsCurrentCulture(string cultureName, string input, double expected) + { + RunUnderCulture(cultureName, () => + { + Assert.True(NumberFormatHelper.TryParseDouble(input, out double parsed), + $"TryParseDouble failed for '{input}' under {cultureName}"); + Assert.Equal(expected, parsed); + }); + } + + [Theory] + [InlineData("de-DE", 1.5, ',')] + [InlineData("fr-FR", 1.5, ',')] + [InlineData("en-US", 1.5, '.')] + public void FormatDouble_UsesCultureDecimalSeparator(string cultureName, double value, char expectedSep) + { + RunUnderCulture(cultureName, () => + { + string formatted = NumberFormatHelper.FormatDouble(value); + Assert.Contains(expectedSep.ToString(), formatted); + }); + } + + [Theory] + [InlineData("de-DE", ",")] + [InlineData("fr-FR", ",")] + [InlineData("en-US", ".")] + public void DecimalSeparator_MatchesCulture(string cultureName, string expected) + { + RunUnderCulture(cultureName, () => + { + Assert.Equal(expected, NumberFormatHelper.DecimalSeparator); + }); + } + + [Fact] + public void IsRightToLeft_TrueForArabicCulture() + { + RunUnderCulture("ar-SA", () => + { + Assert.True(NumberFormatHelper.IsRightToLeft); + }); + } + + [Fact] + public void IsRightToLeft_FalseForEnglishCulture() + { + RunUnderCulture("en-US", () => + { + Assert.False(NumberFormatHelper.IsRightToLeft); + }); + } + + [Theory] + [InlineData("١٢٣", "123")] // Eastern Arabic-Indic digits + [InlineData("۱۲۳", "123")] // Extended Arabic-Indic digits (Persian) + [InlineData("123", "123")] // Western Arabic — no change + public void NormalizeDigits_ConvertsAllNumeralSystems(string input, string expected) + { + Assert.Equal(expected, NumberFormatHelper.NormalizeDigits(input)); + } + + [Theory] + [InlineData("de-DE")] + [InlineData("fr-FR")] + [InlineData("en-US")] + [InlineData("tr-TR")] + public void RoundTrip_HelperFormatThenHelperParse_PreservesValueBitExact(string cultureName) + { + RunUnderCulture(cultureName, () => + { + // Use NumberFormatHelper on BOTH legs so we test the helper's round-trip, + // not the BCL's. NumberFormatHelper.FormatDouble uses ToString(CurrentCulture) + // which produces the most-precise representation by default for double. + double[] values = { 1234.5678, 0.1, -0.0, 1e-10, 12345.6789012345, -987.654321 }; + foreach (double v in values) + { + string formatted = NumberFormatHelper.FormatDouble(v); + Assert.True(NumberFormatHelper.TryParseDouble(formatted, out double parsed), + $"Failed to parse '{formatted}' under {cultureName}"); + Assert.Equal(System.BitConverter.DoubleToInt64Bits(v), + System.BitConverter.DoubleToInt64Bits(parsed)); + } + }); + } + + [Theory] + [InlineData("fa-IR", "۱۲۳", 123.0)] // Persian Eastern Arabic-Indic digits + [InlineData("ar-SA", "١٢٣", 123.0)] // Arabic Eastern Arabic-Indic digits + public void NormalizeDigitsThenTryParseDouble_HandlesNonWesternDigits(string cultureName, string input, double expected) + { + RunUnderCulture(cultureName, () => + { + // Workflow: user types non-Western digits → NormalizeDigits → TryParseDouble. + // This is the documented use case for NormalizeDigits; verify it composes correctly. + string normalized = NumberFormatHelper.NormalizeDigits(input); + Assert.True(NumberFormatHelper.TryParseDouble(normalized, out double result), + $"Failed to parse normalized '{normalized}' (from '{input}') under {cultureName}"); + Assert.Equal(expected, result); + }); + } + + [Theory] + [InlineData("de-DE", "abc")] + [InlineData("de-DE", "1,2,3")] // ambiguous — parser may accept as group separator; just verify no throw + public void TryParseDouble_InvalidInput_ReturnsFalseWithoutThrowing(string cultureName, string input) + { + RunUnderCulture(cultureName, () => + { + // The contract is: must NOT throw. Result of parse may be true or false depending on input. + var ex = Record.Exception(() => NumberFormatHelper.TryParseDouble(input, out _)); + Assert.Null(ex); + }); + } + + [Fact] + public void IsValidPartialNumber_HandlesGermanPartials() + { + RunUnderCulture("de-DE", () => + { + Assert.True(NumberFormatHelper.IsValidPartialNumber(",")); // German decimal partial + Assert.True(NumberFormatHelper.IsValidPartialNumber("-,")); + Assert.True(NumberFormatHelper.IsValidPartialNumber("1e")); + }); + } + + private static void RunUnderCulture(string cultureName, System.Action body) + { + var prevCulture = Thread.CurrentThread.CurrentCulture; + try + { + var culture = new CultureInfo(cultureName); + Thread.CurrentThread.CurrentCulture = culture; + CultureInfo.CurrentCulture = culture; + body(); + } + finally + { + Thread.CurrentThread.CurrentCulture = prevCulture; + CultureInfo.CurrentCulture = prevCulture; + } + } +} diff --git a/tests/GenericControls.Tests/Utilities/GeneralMethodsTests.cs b/tests/GenericControls.Tests/Utilities/GeneralMethodsTests.cs index 2859f21d..be37aa13 100644 --- a/tests/GenericControls.Tests/Utilities/GeneralMethodsTests.cs +++ b/tests/GenericControls.Tests/Utilities/GeneralMethodsTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; namespace GenericControls.Tests.Utilities; diff --git a/tests/GenericControls.Tests/Utilities/NumberFormatHelperTests.cs b/tests/GenericControls.Tests/Utilities/NumberFormatHelperTests.cs index 8705bedb..d48eceeb 100644 --- a/tests/GenericControls.Tests/Utilities/NumberFormatHelperTests.cs +++ b/tests/GenericControls.Tests/Utilities/NumberFormatHelperTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using Xunit; diff --git a/tests/GenericControls.Tests/Validation/PropertyRuleTests.cs b/tests/GenericControls.Tests/Validation/PropertyRuleTests.cs index 03001442..b02f5016 100644 --- a/tests/GenericControls.Tests/Validation/PropertyRuleTests.cs +++ b/tests/GenericControls.Tests/Validation/PropertyRuleTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.ComponentModel; using Xunit; diff --git a/tests/GenericControls.Tests/Validation/RangeValidationRuleTests.cs b/tests/GenericControls.Tests/Validation/RangeValidationRuleTests.cs index 1f55c383..4065a583 100644 --- a/tests/GenericControls.Tests/Validation/RangeValidationRuleTests.cs +++ b/tests/GenericControls.Tests/Validation/RangeValidationRuleTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Controls; using Xunit; diff --git a/tests/GenericControls.Tests/XamlBindingCultureTests.cs b/tests/GenericControls.Tests/XamlBindingCultureTests.cs new file mode 100644 index 00000000..c6fc3ae4 --- /dev/null +++ b/tests/GenericControls.Tests/XamlBindingCultureTests.cs @@ -0,0 +1,88 @@ +using System.IO; +using Xunit; + +namespace GenericControls.Tests; + +/// +/// Structural regression guard for the XAML ConverterCulture binding pattern. +/// +/// +/// Phase 3 added xmlns:glob="clr-namespace:System.Globalization;assembly=mscorlib" +/// and ConverterCulture={x:Static glob:CultureInfo.CurrentCulture} to numeric +/// bindings in shared framework controls so they parse user input under the user's +/// locale even in host apps that don't call FrameworkElement.LanguageProperty.OverrideMetadata. +/// +/// These tests scan the XAML files at test time and verify the patterns are present. +/// They catch accidental removal during XAML refactors / merges. They run by reading +/// files from the source tree (not from the compiled BAML), so the source is what's +/// guarded. +/// +/// A runtime test of binding behavior would be more thorough but is omitted intentionally: +/// once any test in the assembly triggers FrameworkElement.LanguageProperty.OverrideMetadata, +/// the override cannot be cleanly reset, leading to false-pass results that hide regressions. +/// +public class XamlBindingCultureTests +{ + private const string GlobNamespace = "xmlns:glob=\"clr-namespace:System.Globalization;assembly=mscorlib\""; + private const string ConverterCulturePattern = "ConverterCulture={x:Static glob:CultureInfo.CurrentCulture}"; + + public static TheoryData XamlFilesWithCultureBinding => new() + { + "src/GenericControls/General Controls/NumericTextBox2.xaml", + "src/GenericControls/Properties Controls/NumericPropertyControl.xaml", + "src/GenericControls/Properties Controls/NumericAutoPropertyControl.xaml", + "src/GenericControls/Properties Controls/NumericSliderPropertyControl.xaml", + "src/GenericControls/Properties Controls/NumericPropertySelectorControl.xaml", + "src/FrameworkUI.Demo/UI/Hazard Controls/HazardControl.xaml", + "src/GenericControls.Demo/MainWindow.xaml", + "src/NumericControls/Distributions/Univariate/Distribution Selector/Selector.xaml", + "src/NumericControls/Distributions/Univariate/Distribution Selector/DistributionSelectorControl.xaml", + }; + + [Theory] + [MemberData(nameof(XamlFilesWithCultureBinding))] + public void XamlFile_DeclaresGlobalizationNamespace(string repoRelativePath) + { + string fullPath = ResolveRepoPath(repoRelativePath); + Assert.True(File.Exists(fullPath), $"XAML file not found at {fullPath}"); + + string content = File.ReadAllText(fullPath); + Assert.Contains(GlobNamespace, content); + } + + [Theory] + [MemberData(nameof(XamlFilesWithCultureBinding))] + public void XamlFile_HasConverterCultureBindingPattern(string repoRelativePath) + { + string fullPath = ResolveRepoPath(repoRelativePath); + Assert.True(File.Exists(fullPath), $"XAML file not found at {fullPath}"); + + string content = File.ReadAllText(fullPath); + Assert.Contains(ConverterCulturePattern, content); + } + + /// + /// Walks up from the test assembly's bin directory to find the repository root + /// (identified by the presence of WPF-Framework.sln), then resolves the + /// repo-relative path. This works regardless of build configuration depth. + /// + private static string ResolveRepoPath(string repoRelativePath) + { + string current = AppContext.BaseDirectory; + while (!string.IsNullOrEmpty(current)) + { + if (File.Exists(Path.Combine(current, "WPF-Framework.sln"))) + { + return Path.Combine(current, repoRelativePath.Replace('/', Path.DirectorySeparatorChar)); + } + string? parent = Path.GetDirectoryName(current); + if (parent == current) + { + break; + } + current = parent!; + } + throw new InvalidOperationException( + $"Could not locate repository root (looking for WPF-Framework.sln) starting from {AppContext.BaseDirectory}"); + } +} diff --git a/tests/NumericControls.Tests/Converters/DateToStringConverterTests.cs b/tests/NumericControls.Tests/Converters/DateToStringConverterTests.cs index 75ad1218..937266e2 100644 --- a/tests/NumericControls.Tests/Converters/DateToStringConverterTests.cs +++ b/tests/NumericControls.Tests/Converters/DateToStringConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Numerics.Data; diff --git a/tests/NumericControls.Tests/Converters/DoubleToFontFamilyConverterTests.cs b/tests/NumericControls.Tests/Converters/DoubleToFontFamilyConverterTests.cs index 2eb13d80..ffcc9b34 100644 --- a/tests/NumericControls.Tests/Converters/DoubleToFontFamilyConverterTests.cs +++ b/tests/NumericControls.Tests/Converters/DoubleToFontFamilyConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Numerics.Data; diff --git a/tests/NumericControls.Tests/Converters/MathFunctionTypeToIconConverterTests.cs b/tests/NumericControls.Tests/Converters/MathFunctionTypeToIconConverterTests.cs index b93c5903..ba8d05c9 100644 --- a/tests/NumericControls.Tests/Converters/MathFunctionTypeToIconConverterTests.cs +++ b/tests/NumericControls.Tests/Converters/MathFunctionTypeToIconConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Numerics.Data; diff --git a/tests/NumericControls.Tests/Converters/MathFunctionTypeToNameConverterTests.cs b/tests/NumericControls.Tests/Converters/MathFunctionTypeToNameConverterTests.cs index 8dd23c11..5d5c9c15 100644 --- a/tests/NumericControls.Tests/Converters/MathFunctionTypeToNameConverterTests.cs +++ b/tests/NumericControls.Tests/Converters/MathFunctionTypeToNameConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Numerics.Data; diff --git a/tests/NumericControls.Tests/Converters/MathFunctionTypeToTooltipConverterTests.cs b/tests/NumericControls.Tests/Converters/MathFunctionTypeToTooltipConverterTests.cs index f1b607a2..c21f8bf2 100644 --- a/tests/NumericControls.Tests/Converters/MathFunctionTypeToTooltipConverterTests.cs +++ b/tests/NumericControls.Tests/Converters/MathFunctionTypeToTooltipConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Numerics.Data; diff --git a/tests/NumericControls.Tests/Distributions/SelectorDisplayCultureTests.cs b/tests/NumericControls.Tests/Distributions/SelectorDisplayCultureTests.cs new file mode 100644 index 00000000..79d066fa --- /dev/null +++ b/tests/NumericControls.Tests/Distributions/SelectorDisplayCultureTests.cs @@ -0,0 +1,97 @@ +using System.Globalization; +using System.Threading; +using Xunit; + +namespace NumericControls.Tests.Distributions; + +/// +/// Tests in this collection mutate ; xunit must +/// not run them in parallel with anything else in the same assembly that reads culture. +/// +[CollectionDefinition("CultureSensitive", DisableParallelization = true)] +public class CultureSensitiveCollection { } + +/// +/// Guard tests for the Distribution Selector statistics display format. +/// +/// +/// The Selector previously formatted DataStat/DistStat with +/// ToString("N4", CultureInfo.InvariantCulture), which always rendered +/// "1,234.5678" regardless of locale. The fix flips InvariantCulture to +/// CurrentCulture so a German user sees "1.234,5678". +/// +/// These tests don't instantiate the WPF Selector control (that needs an STA +/// host); instead they verify the underlying format pattern produces the +/// expected culture-specific output, guarding against a future regression +/// that flips back to Invariant. +/// +[Collection("CultureSensitive")] +public class SelectorDisplayCultureTests +{ + [Theory] + [InlineData("de-DE", 1234.5678, ',')] + [InlineData("fr-FR", 1234.5678, ',')] + [InlineData("en-US", 1234.5678, '.')] + public void StatN4Format_UsesCurrentCultureDecimalSeparator(string cultureName, double value, char expectedSep) + { + RunUnderCulture(cultureName, () => + { + string formatted = value.ToString("N4", CultureInfo.CurrentCulture); + Assert.Contains(expectedSep.ToString(), formatted); + }); + } + + [Fact] + public void StatN4Format_GermanLocale_ProducesGermanThousandsAndDecimal() + { + RunUnderCulture("de-DE", () => + { + string formatted = 1234.5678.ToString("N4", CultureInfo.CurrentCulture); + // German format: '.' for thousands, ',' for decimal → "1.234,5678" + Assert.Equal("1.234,5678", formatted); + }); + } + + [Fact] + public void StatN4Format_UsLocale_ProducesUsThousandsAndDecimal() + { + RunUnderCulture("en-US", () => + { + string formatted = 1234.5678.ToString("N4", CultureInfo.CurrentCulture); + // US format: ',' for thousands, '.' for decimal → "1,234.5678" + Assert.Equal("1,234.5678", formatted); + }); + } + + [Fact] + public void StatN4Format_NaN_RendersAsLocaleNaN() + { + // double.NaN is rendered as the locale's NaN symbol; just verify no throw + // and a non-empty result under each culture + foreach (string culture in new[] { "de-DE", "en-US", "fr-FR" }) + { + RunUnderCulture(culture, () => + { + string formatted = double.NaN.ToString("N4", CultureInfo.CurrentCulture); + Assert.False(string.IsNullOrEmpty(formatted)); + }); + } + } + + private static void RunUnderCulture(string cultureName, System.Action body) + { + var prevCulture = Thread.CurrentThread.CurrentCulture; + try + { + var culture = new CultureInfo(cultureName); + Thread.CurrentThread.CurrentCulture = culture; + CultureInfo.CurrentCulture = culture; + body(); + } + finally + { + Thread.CurrentThread.CurrentCulture = prevCulture; + CultureInfo.CurrentCulture = prevCulture; + } + } +} diff --git a/tests/NumericControls.Tests/MathEditor/MathEditorFunctionTests.cs b/tests/NumericControls.Tests/MathEditor/MathEditorFunctionTests.cs index d1555072..83766fd9 100644 --- a/tests/NumericControls.Tests/MathEditor/MathEditorFunctionTests.cs +++ b/tests/NumericControls.Tests/MathEditor/MathEditorFunctionTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Numerics.Data; using NumericControls; using Xunit; diff --git a/tests/NumericControls.Tests/Models/ParameterTests.cs b/tests/NumericControls.Tests/Models/ParameterTests.cs index 1001a2a3..7ba8c92c 100644 --- a/tests/NumericControls.Tests/Models/ParameterTests.cs +++ b/tests/NumericControls.Tests/Models/ParameterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using NumericControls; using Xunit; diff --git a/tests/NumericControls.Tests/Models/SummaryStatisticTests.cs b/tests/NumericControls.Tests/Models/SummaryStatisticTests.cs index effd7c86..41b471b1 100644 --- a/tests/NumericControls.Tests/Models/SummaryStatisticTests.cs +++ b/tests/NumericControls.Tests/Models/SummaryStatisticTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using NumericControls.Distributions.Univariate; using Xunit; diff --git a/tests/NumericControls.Tests/NumericControls.Tests.csproj b/tests/NumericControls.Tests/NumericControls.Tests.csproj index 11ee8625..52948f23 100644 --- a/tests/NumericControls.Tests/NumericControls.Tests.csproj +++ b/tests/NumericControls.Tests/NumericControls.Tests.csproj @@ -29,9 +29,7 @@ - - ..\..\..\numerics\Numerics\bin\$(Configuration)\net10.0\Numerics.dll - + diff --git a/tests/NumericControls.Tests/RowItems/DistributionRowItemTests.cs b/tests/NumericControls.Tests/RowItems/DistributionRowItemTests.cs index 6dc109b1..36cf75ec 100644 --- a/tests/NumericControls.Tests/RowItems/DistributionRowItemTests.cs +++ b/tests/NumericControls.Tests/RowItems/DistributionRowItemTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.ObjectModel; using Numerics.Data; using Numerics.Distributions; diff --git a/tests/NumericControls.Tests/RowItems/OrdinateRowItemTests.cs b/tests/NumericControls.Tests/RowItems/OrdinateRowItemTests.cs index b3a39b20..53e2e8d0 100644 --- a/tests/NumericControls.Tests/RowItems/OrdinateRowItemTests.cs +++ b/tests/NumericControls.Tests/RowItems/OrdinateRowItemTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.ObjectModel; using Numerics.Data; using NumericControls; diff --git a/tests/NumericControls.Tests/RowItems/ProbabilityOrdinateRowItemTests.cs b/tests/NumericControls.Tests/RowItems/ProbabilityOrdinateRowItemTests.cs index 5affd9b6..6717c777 100644 --- a/tests/NumericControls.Tests/RowItems/ProbabilityOrdinateRowItemTests.cs +++ b/tests/NumericControls.Tests/RowItems/ProbabilityOrdinateRowItemTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Collections.ObjectModel; using NumericControls; using Xunit; diff --git a/tests/OxyPlot.ExampleLibrary/OxyPlot.ExampleLibrary.csproj b/tests/OxyPlot.ExampleLibrary/OxyPlot.ExampleLibrary.csproj index 7e69fa26..5cfb00ff 100644 --- a/tests/OxyPlot.ExampleLibrary/OxyPlot.ExampleLibrary.csproj +++ b/tests/OxyPlot.ExampleLibrary/OxyPlot.ExampleLibrary.csproj @@ -6,6 +6,7 @@ Example models for OxyPlot. false 11 + $(NoWarn);CS0618 diff --git a/tests/OxyPlot.Tests/Axes/AxisCultureTests.cs b/tests/OxyPlot.Tests/Axes/AxisCultureTests.cs new file mode 100644 index 00000000..e522948e --- /dev/null +++ b/tests/OxyPlot.Tests/Axes/AxisCultureTests.cs @@ -0,0 +1,159 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2014 OxyPlot contributors +// +// +// Verifies that axis interval calculation works under non-US cultures. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OxyPlot.Tests +{ + using System; + using System.Globalization; + using System.Threading; + + using NUnit.Framework; + + using OxyPlot.Axes; + + /// + /// The Axis.cs:CalculateActualInterval helper uses a `removeNoise` lambda that round-trips + /// doubles through `ToString("e14")` + `double.Parse`. Without explicit InvariantCulture + /// the round-trip is culture-sensitive — same culture both legs avoids exceptions but + /// drifts ActualMajorStep across machines if one ever computes the interval and another + /// reads/uses the formatted value. + /// + [TestFixture] + public class AxisCultureTests + { + /// + /// A plot rendered under de-DE must produce the same `ActualMajorStep` as under en-US. + /// This is the strongest assertion that the `removeNoise` lambda is culture-invariant. + /// + [Test] + public void Axis_ActualMajorStep_MatchesEnUs_UnderGermanCulture() + { + double enUsMajorStep = ComputeMajorStepUnderCulture("en-US", 0.1, 9.9); + double deDeMajorStep = ComputeMajorStepUnderCulture("de-DE", 0.1, 9.9); + AssertBitExact(enUsMajorStep, deDeMajorStep, "ActualMajorStep"); + } + + [Test] + public void Axis_ActualMajorStep_MatchesEnUs_UnderFrenchCulture() + { + double enUsMajorStep = ComputeMajorStepUnderCulture("en-US", 1234.5678, 5678.1234); + double frFrMajorStep = ComputeMajorStepUnderCulture("fr-FR", 1234.5678, 5678.1234); + AssertBitExact(enUsMajorStep, frFrMajorStep, "ActualMajorStep"); + } + + /// + /// Turkish has unusual casing rules ("i"/"İ"); historically caused regressions in + /// code that uppercases format strings. Verify axis math is unaffected. + /// + [Test] + public void Axis_ActualMajorStep_MatchesEnUs_UnderTurkishCulture() + { + double enUsMajorStep = ComputeMajorStepUnderCulture("en-US", -3.14159, 3.14159); + double trTrMajorStep = ComputeMajorStepUnderCulture("tr-TR", -3.14159, 3.14159); + AssertBitExact(enUsMajorStep, trTrMajorStep, "ActualMajorStep"); + } + + [Test] + public void Axis_RenderToSvg_DoesNotThrow_UnderGermanCulture() + { + RunUnderCulture("de-DE", () => + { + var plot = new PlotModel { Title = "Culture Test" }; + plot.Axes.Add(new LinearAxis + { + Position = AxisPosition.Bottom, + Minimum = 0.1, + Maximum = 9.9, + }); + plot.Axes.Add(new LinearAxis + { + Position = AxisPosition.Left, + Minimum = 1234.5678, + Maximum = 5678.1234, + }); + + Assert.DoesNotThrow(() => + { + string svg = SvgExporter.ExportToString(plot, 800, 500, true); + Assert.That(svg, Is.Not.Null.And.Not.Empty); + }); + }); + } + + [Test] + public void Axis_UpdateThenFormatValue_DoesNotThrow_UnderGermanCulture() + { + RunUnderCulture("de-DE", () => + { + var model = new PlotModel(); + var axis = new LinearAxis + { + Position = AxisPosition.Bottom, + Minimum = 0.1, + Maximum = 1000.5, + }; + model.Axes.Add(axis); + + Assert.DoesNotThrow(() => + { + ((IPlotModel)model).Update(true); + // FormatValue exercises ActualCulture path (uses CurrentCulture by default) + string label = axis.FormatValue(123.456); + Assert.That(label, Is.Not.Null.And.Not.Empty); + }); + }); + } + + /// + /// Builds a single-axis plot under the given culture, renders to SVG (which forces + /// `UpdateIntervals → CalculateActualInterval → removeNoise`), and returns the + /// resulting `ActualMajorStep`. + /// + private static double ComputeMajorStepUnderCulture(string cultureName, double min, double max) + { + double majorStep = 0; + RunUnderCulture(cultureName, () => + { + var plot = new PlotModel(); + var axis = new LinearAxis { Position = AxisPosition.Bottom, Minimum = min, Maximum = max }; + plot.Axes.Add(axis); + plot.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = min, Maximum = max }); + // Rendering forces full interval computation (rendering loops through UpdateIntervals). + _ = SvgExporter.ExportToString(plot, 800, 500, false); + majorStep = axis.ActualMajorStep; + }); + return majorStep; + } + + private static void AssertBitExact(double expected, double actual, string label) + { + long expectedBits = BitConverter.DoubleToInt64Bits(expected); + long actualBits = BitConverter.DoubleToInt64Bits(actual); + Assert.That(actualBits, Is.EqualTo(expectedBits), + $"{label}: expected {expected:R} (bits {expectedBits}), got {actual:R} (bits {actualBits})"); + } + + private static void RunUnderCulture(string cultureName, Action body) + { + var prevCulture = Thread.CurrentThread.CurrentCulture; + try + { + var culture = new CultureInfo(cultureName); + Thread.CurrentThread.CurrentCulture = culture; + CultureInfo.CurrentCulture = culture; + body(); + } + finally + { + Thread.CurrentThread.CurrentCulture = prevCulture; + CultureInfo.CurrentCulture = prevCulture; + } + } + } +} diff --git a/tests/OxyPlot.Tests/Axes/ProbabilityAxisTests.cs b/tests/OxyPlot.Tests/Axes/ProbabilityAxisTests.cs new file mode 100644 index 00000000..1028ae52 --- /dev/null +++ b/tests/OxyPlot.Tests/Axes/ProbabilityAxisTests.cs @@ -0,0 +1,99 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2014 OxyPlot contributors +// +// +// Regression tests for D-003 — probability axes incorrectly clobbered user-set Maximum/Minimum. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OxyPlot.Tests +{ + using System.Reflection; + + using NUnit.Framework; + + using OxyPlot.Axes; + + /// + /// Regression tests for D-003: and + /// contained an inverted condition in + /// UpdateActualMaxMin that overwrote any user-set Min/Max with the + /// hard-coded _epsilon / 0.999 bounds. The fix replaces + /// !IsNaN || ActualMin <= _epsilon with IsNaN || ActualMin < _epsilon + /// so user values inside the valid probability domain are preserved. + /// + [TestFixture] + public class ProbabilityAxisTests + { + /// + /// Calls the internal override UpdateActualMaxMin() via reflection so the + /// test can exercise the constraint logic without spinning up a full PlotModel. + /// + private static void InvokeUpdateActualMaxMin(Axis axis) + { + var method = typeof(Axis).GetMethod( + "UpdateActualMaxMin", + BindingFlags.Instance | BindingFlags.NonPublic); + Assert.IsNotNull(method); + method!.Invoke(axis, null); + } + + [Test] + public void NormalProbabilityAxis_RespectsUserSetMinimum() + { + var axis = new NormalProbabilityAxis { Minimum = 0.05, Maximum = 0.95 }; + + InvokeUpdateActualMaxMin(axis); + + Assert.AreEqual(0.05, axis.ActualMinimum, 1e-12); + } + + [Test] + public void NormalProbabilityAxis_RespectsUserSetMaximum() + { + var axis = new NormalProbabilityAxis { Minimum = 0.05, Maximum = 0.95 }; + + InvokeUpdateActualMaxMin(axis); + + Assert.AreEqual(0.95, axis.ActualMaximum, 1e-12); + } + + [Test] + public void NormalProbabilityAxis_ClampsBelowEpsilonToEpsilon() + { + // Negative or zero Minimum is outside the valid probability domain — the + // setter coerces it to the configured epsilon so the actualMinimum is the + // expected non-zero clamp. + var axis = new NormalProbabilityAxis(); + // Force ActualMinimum to 0 to simulate a CalculateActualMaximum result that + // came back outside the valid range. + typeof(Axis).GetProperty(nameof(Axis.ActualMinimum))! + .SetValue(axis, 0.0); + + InvokeUpdateActualMaxMin(axis); + + Assert.That(axis.ActualMinimum, Is.GreaterThan(0.0)); + } + + [Test] + public void GumbelProbabilityAxis_RespectsUserSetMinimum() + { + var axis = new GumbelProbabilityAxis { Minimum = 0.05, Maximum = 0.95 }; + + InvokeUpdateActualMaxMin(axis); + + Assert.AreEqual(0.05, axis.ActualMinimum, 1e-12); + } + + [Test] + public void GumbelProbabilityAxis_RespectsUserSetMaximum() + { + var axis = new GumbelProbabilityAxis { Minimum = 0.05, Maximum = 0.95 }; + + InvokeUpdateActualMaxMin(axis); + + Assert.AreEqual(0.95, axis.ActualMaximum, 1e-12); + } + } +} diff --git a/tests/OxyPlot.Tests/OxyPlot.Tests.csproj b/tests/OxyPlot.Tests/OxyPlot.Tests.csproj index 7276a54c..26ec73cd 100644 --- a/tests/OxyPlot.Tests/OxyPlot.Tests.csproj +++ b/tests/OxyPlot.Tests/OxyPlot.Tests.csproj @@ -49,5 +49,8 @@ PreserveNewest + + PreserveNewest + diff --git a/tests/OxyPlot.Tests/baseline/A00.svg b/tests/OxyPlot.Tests/baseline/A00.svg new file mode 100644 index 00000000..5f93bb56 --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/A00.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + 20 + 30 + 40 + 50 + 60 + 70 + 80 + + + + + + + + + 10 + 20 + 30 + 40 + 50 + 60 + + + + + + + + + + + + + + + + + + + + + + Simple plot without axes defined + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/A01.svg b/tests/OxyPlot.Tests/baseline/A01.svg new file mode 100644 index 00000000..be111a4c --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/A01.svg @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + 20 + 30 + 40 + 50 + 60 + 70 + 80 + + + + + + + + + X-axis + 10 + 20 + 30 + 40 + 50 + 60 + + + + + + + Y-axis + + + + + + + + + + + + + + + + Simple plot + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/A02.svg b/tests/OxyPlot.Tests/baseline/A02.svg new file mode 100644 index 00000000..4dfd1e35 --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/A02.svg @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 10 + 20 + 30 + 40 + 50 + 60 + 70 + 80 + + + + + + + + + + X-axis + 10 + 20 + 30 + 40 + 50 + 60 + + + + + + + Y-axis + + + + + + + + + + + + + + + + Reversed axes + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/A11.svg b/tests/OxyPlot.Tests/baseline/A11.svg new file mode 100644 index 00000000..626f1076 --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/A11.svg @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1e-40 + 1.1e-40 + 1.2e-40 + 1.3e-40 + 1.4e-40 + 1.5e-40 + 1.6e-40 + + + + + + + + X-axis + 1e-38 + 1.5e-38 + 2e-38 + 2.5e-38 + 3e-38 + + + + + + Y-axis + + + + + + + + + + + + + + + + Small range axis + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/A12.svg b/tests/OxyPlot.Tests/baseline/A12.svg new file mode 100644 index 00000000..175c6865 --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/A12.svg @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1e+40 + 1.1e+40 + 1.2e+40 + 1.3e+40 + 1.4e+40 + 1.5e+40 + 1.6e+40 + + + + + + + + X-axis + 1e+38 + 1.5e+38 + 2e+38 + 2.5e+38 + 3e+38 + + + + + + Y-axis + + + + + + + + + + + + + + + + Large range axis + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/A13.svg b/tests/OxyPlot.Tests/baseline/A13.svg new file mode 100644 index 00000000..0cfab73c --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/A13.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.2 + 1.2 + 1.2 + 1.2 + 1.2 + 1.2 + 1.2 + + + + + + + + X-axis + 2.4e+09 + 2.4e+09 + 2.4e+09 + 2.4e+09 + 2.4e+09 + + + + + + Y-axis + + + + + + + + + + + + + + + + Bad conditioned axis + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/A13B.svg b/tests/OxyPlot.Tests/baseline/A13B.svg new file mode 100644 index 00000000..e883301e --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/A13B.svg @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.1995 + 1.1996 + 1.1997 + 1.1998 + 1.1999 + 1.2 + 1.2001 + 1.2002 + 1.2003 + 1.2004 + 1.2005 + + + + + + + + + + + + X-axis + 2.36E09 + 2.38E09 + 2.40E09 + 2.42E09 + 2.44E09 + + + + + + Y-axis + + + + + + + + + + + + + + + + Bad conditioned axis with MinimumRange + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/A14.svg b/tests/OxyPlot.Tests/baseline/A14.svg new file mode 100644 index 00000000..9a90bc97 --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/A14.svg @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 1.5 + 2 + 2.5 + 3 + 3.5 + 4 + + + + + + + + X-axis + 1.5 + 2 + 2.5 + 3 + 3.5 + + + + + + Y-axis + + + + + + + + + + + + + + + + Constant value + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/A15.svg b/tests/OxyPlot.Tests/baseline/A15.svg new file mode 100644 index 00000000..9752e5ad --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/A15.svg @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.5 + 0.6 + 0.7 + 0.8 + 0.9 + 1 + 1.1 + 1.2 + 1.3 + 1.4 + 1.5 + + + + + + + + + + + + X-axis + 1.5 + 2 + 2.5 + 3 + 3.5 + + + + + + Y-axis + + + + + + + + + + + + + + + + Single point + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/A16.svg b/tests/OxyPlot.Tests/baseline/A16.svg new file mode 100644 index 00000000..8ef5b4be --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/A16.svg @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.9995 + 0.9996 + 0.9997 + 0.9998 + 0.9999 + 1 + 1.0001 + 1.0002 + 1.0003 + 1.0004 + 1.0005 + + + + + + + + + + + + X-axis + 1.5 + 2 + 2.5 + 3 + 3.5 + + + + + + Y-axis + + + + + + + + + + + + + + + + Two close points + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/B01.svg b/tests/OxyPlot.Tests/baseline/B01.svg new file mode 100644 index 00000000..c089ef44 --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/B01.svg @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 10 + 100 + 1000 + 10000 + + + + + + X-axis + 1 + 10 + 100 + 1000 + + + + + Y-axis + + + + + + + + + + + + + + + + Logarithmic axis + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/B02.svg b/tests/OxyPlot.Tests/baseline/B02.svg new file mode 100644 index 00000000..13b83b6a --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/B02.svg @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 10 + 100 + + + + X-axis + 10 + 100 + + + Y-axis + + + + + + + + + + + + + + + + Logarithmic axis + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/B03.svg b/tests/OxyPlot.Tests/baseline/B03.svg new file mode 100644 index 00000000..7494896f --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/B03.svg @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1e+09 + 1e+13 + 1e+17 + 1e+21 + 1e+25 + 1e+29 + 1e+33 + 1e+37 + 1e+41 + + + + + + + + + + X-axis + 1e+17 + 1e+21 + 1e+25 + 1e+29 + 1e+33 + 1e+37 + + + + + + + Y-axis + + + + + + + + + + + + + + + + Logarithmic axis + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/B04.svg b/tests/OxyPlot.Tests/baseline/B04.svg new file mode 100644 index 00000000..eec28523 --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/B04.svg @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 10 + 100 + + + + X-axis + 10 + 100 + + + Y-axis + + + + + + + + + + + + + + + + Logarithmic axis with padding + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/B05.svg b/tests/OxyPlot.Tests/baseline/B05.svg new file mode 100644 index 00000000..cf14bebc --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/B05.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + 3 + 10 + 4 + 10 + 5 + + + + X-axis + 10 + 18 + 10 + 22 + 10 + 26 + 10 + 30 + 10 + 34 + 10 + 38 + + + + + + + Y-axis + Logarithmic axis with SuperExponentialFormat + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/C01.svg b/tests/OxyPlot.Tests/baseline/C01.svg new file mode 100644 index 00000000..91de7261 --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/C01.svg @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1/1/2011 + 1/2/2011 + 1/3/2011 + 1/4/2011 + 1/5/2011 + 1/6/2011 + 1/7/2011 + 1/8/2011 + 1/9/2011 + 1/10/2011 + 1/11/2011 + 1/12/2011 + 1/13/2011 + 1/14/2011 + 1/15/2011 + 1/16/2011 + 1/17/2011 + 1/18/2011 + 1/19/2011 + + + + + + + + + + + + + + + + + + + + DateTime X + 3/1/2011 + 3/2/2011 + 3/3/2011 + 3/4/2011 + 3/5/2011 + 3/6/2011 + 3/7/2011 + 3/8/2011 + 3/9/2011 + 3/10/2011 + 3/11/2011 + 3/12/2011 + 3/13/2011 + 3/14/2011 + + + + + + + + + + + + + + + DateTime Y + + + + + + + + + + + + + + + + DateTime axis + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/C02.svg b/tests/OxyPlot.Tests/baseline/C02.svg new file mode 100644 index 00000000..6ab6feea --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/C02.svg @@ -0,0 +1,221 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1/1/2011 + 1/2/2011 + 1/3/2011 + 1/4/2011 + 1/5/2011 + 1/6/2011 + 1/7/2011 + 1/8/2011 + 1/9/2011 + 1/10/2011 + 1/11/2011 + 1/12/2011 + 1/13/2011 + 1/14/2011 + 1/15/2011 + 1/16/2011 + 1/17/2011 + 1/18/2011 + 1/19/2011 + + + + + + + + + + + + + + + + + + + + DateTime X + 3/1/2011 + 3/2/2011 + 3/3/2011 + 3/4/2011 + 3/5/2011 + 3/6/2011 + 3/7/2011 + 3/8/2011 + 3/9/2011 + 3/10/2011 + 3/11/2011 + 3/12/2011 + 3/13/2011 + 3/14/2011 + + + + + + + + + + + + + + + DateTime Y + + + + + + + + + + + + + + + + + + DateTime axis + + + \ No newline at end of file diff --git a/tests/OxyPlot.Tests/baseline/C03.svg b/tests/OxyPlot.Tests/baseline/C03.svg new file mode 100644 index 00000000..4464262f --- /dev/null +++ b/tests/OxyPlot.Tests/baseline/C03.svg @@ -0,0 +1,1231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 12/30/1899 + 12/31/1899 + 1/1/1900 + 1/2/1900 + 1/3/1900 + 1/4/1900 + 1/5/1900 + 1/6/1900 + 1/7/1900 + 1/8/1900 + 1/9/1900 + 1/10/1900 + 1/11/1900 + 1/12/1900 + 1/13/1900 + 1/14/1900 + 1/15/1900 + 1/16/1900 + 1/17/1900 + 1/18/1900 + 1/19/1900 + 1/20/1900 + 1/21/1900 + 1/22/1900 + 1/23/1900 + 1/24/1900 + 1/25/1900 + 1/26/1900 + 1/27/1900 + 1/28/1900 + 1/29/1900 + 1/30/1900 + 1/31/1900 + 2/1/1900 + 2/2/1900 + 2/3/1900 + 2/4/1900 + 2/5/1900 + 2/6/1900 + 2/7/1900 + 2/8/1900 + 2/9/1900 + 2/10/1900 + 2/11/1900 + 2/12/1900 + 2/13/1900 + 2/14/1900 + 2/15/1900 + 2/16/1900 + 2/17/1900 + 2/18/1900 + 2/19/1900 + 2/20/1900 + 2/21/1900 + 2/22/1900 + 2/23/1900 + 2/24/1900 + 2/25/1900 + 2/26/1900 + 2/27/1900 + 2/28/1900 + 3/1/1900 + 3/2/1900 + 3/3/1900 + 3/4/1900 + 3/5/1900 + 3/6/1900 + 3/7/1900 + 3/8/1900 + 3/9/1900 + 3/10/1900 + 3/11/1900 + 3/12/1900 + 3/13/1900 + 3/14/1900 + 3/15/1900 + 3/16/1900 + 3/17/1900 + 3/18/1900 + 3/19/1900 + 3/20/1900 + 3/21/1900 + 3/22/1900 + 3/23/1900 + 3/24/1900 + 3/25/1900 + 3/26/1900 + 3/27/1900 + 3/28/1900 + 3/29/1900 + 3/30/1900 + 3/31/1900 + 4/1/1900 + 4/2/1900 + 4/3/1900 + 4/4/1900 + 4/5/1900 + 4/6/1900 + 4/7/1900 + 4/8/1900 + 4/9/1900 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DateTime X + 12/30/1899 + 12/31/1899 + 1/1/1900 + 1/2/1900 + 1/3/1900 + 1/4/1900 + 1/5/1900 + 1/6/1900 + 1/7/1900 + 1/8/1900 + 1/9/1900 + 1/10/1900 + 1/11/1900 + 1/12/1900 + 1/13/1900 + 1/14/1900 + 1/15/1900 + 1/16/1900 + 1/17/1900 + 1/18/1900 + 1/19/1900 + 1/20/1900 + 1/21/1900 + 1/22/1900 + 1/23/1900 + 1/24/1900 + 1/25/1900 + 1/26/1900 + 1/27/1900 + 1/28/1900 + 1/29/1900 + 1/30/1900 + 1/31/1900 + 2/1/1900 + 2/2/1900 + 2/3/1900 + 2/4/1900 + 2/5/1900 + 2/6/1900 + 2/7/1900 + 2/8/1900 + 2/9/1900 + 2/10/1900 + 2/11/1900 + 2/12/1900 + 2/13/1900 + 2/14/1900 + 2/15/1900 + 2/16/1900 + 2/17/1900 + 2/18/1900 + 2/19/1900 + 2/20/1900 + 2/21/1900 + 2/22/1900 + 2/23/1900 + 2/24/1900 + 2/25/1900 + 2/26/1900 + 2/27/1900 + 2/28/1900 + 3/1/1900 + 3/2/1900 + 3/3/1900 + 3/4/1900 + 3/5/1900 + 3/6/1900 + 3/7/1900 + 3/8/1900 + 3/9/1900 + 3/10/1900 + 3/11/1900 + 3/12/1900 + 3/13/1900 + 3/14/1900 + 3/15/1900 + 3/16/1900 + 3/17/1900 + 3/18/1900 + 3/19/1900 + 3/20/1900 + 3/21/1900 + 3/22/1900 + 3/23/1900 + 3/24/1900 + 3/25/1900 + 3/26/1900 + 3/27/1900 + 3/28/1900 + 3/29/1900 + 3/30/1900 + 3/31/1900 + 4/1/1900 + 4/2/1900 + 4/3/1900 + 4/4/1900 + 4/5/1900 + 4/6/1900 + 4/7/1900 + 4/8/1900 + 4/9/1900 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DateTime Y + + + + + + + + + + + + + + DateTime axis + + + \ No newline at end of file diff --git a/tests/OxyPlot.Wpf.Tests/AuditRegressionTests.cs b/tests/OxyPlot.Wpf.Tests/AuditRegressionTests.cs new file mode 100644 index 00000000..2d739f05 --- /dev/null +++ b/tests/OxyPlot.Wpf.Tests/AuditRegressionTests.cs @@ -0,0 +1,182 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2014 OxyPlot contributors +// +// +// Regression tests pinning serialization fixes from the forensic audit (D-001, D-002). +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OxyPlot.Wpf.Tests +{ + using System.Diagnostics; + using System.Linq; + using System.Threading; + using System.Xml.Linq; + + using NUnit.Framework; + + using OxyPlot.Wpf; + using OxyPlot.Wpf.Serialization; + + /// + /// Regression tests pinning forensic-audit Phase 1/2 serialization fixes. + /// Each test name references the audit finding ID it covers. + /// + [TestFixture] + public class AuditRegressionTests + { + #region D-001 — non-textual annotations are skipped with a diagnostic, not silently dropped + + /// + /// D-001: Adding an ImageAnnotation (non-textual) to a plot must + /// produce zero AnnotationProperties children. Previously it would silently + /// fall through and the annotation was dropped without any indication. + /// The fix logs a Debug.WriteLine diagnostic so the loss is visible. + /// + [Test] + [Apartment(ApartmentState.STA)] + public void D001_AnnotationsToXElement_SkipsImageAnnotationWithoutThrowing() + { + // Arrange — plot containing only a non-textual annotation. + var plot = new Plot(); + plot.Annotations.Add(new OxyPlot.Wpf.ImageAnnotation()); + plot.InvalidatePlot(true); + + // Act + XElement element = null!; + Assert.DoesNotThrow(() => element = AnnotationSerializer.AnnotationsToXElement(plot)); + + // Assert — no AnnotationProperties children. + Assert.That(element, Is.Not.Null); + var children = element.Elements().ToList(); + Assert.AreEqual(0, children.Count, + "ImageAnnotation must be skipped (D-001 contract)."); + } + + /// + /// D-001: A diagnostic message must be emitted via Debug.WriteLine when an + /// ImageAnnotation is encountered, naming the dropped type. + /// + [Test] + [Apartment(ApartmentState.STA)] + public void D001_AnnotationsToXElement_EmitsDiagnosticForImageAnnotation() + { + // Arrange + var plot = new Plot(); + plot.Annotations.Add(new OxyPlot.Wpf.ImageAnnotation()); + plot.InvalidatePlot(true); + + var listener = new CapturingTraceListener(); + Trace.Listeners.Add(listener); + try + { + // Act + AnnotationSerializer.AnnotationsToXElement(plot); + listener.Flush(); + } + finally + { + Trace.Listeners.Remove(listener); + } + + // Assert — at least one diagnostic mentions "ImageAnnotation". + Assert.That( + listener.Captured.Exists(m => m.Contains("ImageAnnotation")), + "Expected a Debug.WriteLine diagnostic naming ImageAnnotation (D-001)."); + } + + /// + /// Trace listener that captures Debug.WriteLine output for assertion. + /// + private sealed class CapturingTraceListener : TraceListener + { + public System.Collections.Generic.List Captured { get; } = new(); + public override void Write(string message) { if (message != null) Captured.Add(message); } + public override void WriteLine(string message) { if (message != null) Captured.Add(message); } + } + + #endregion + + #region D-002 — Series.IsHitTestEnabled and EdgeRenderingMode round-trip + + [Test] + [Apartment(ApartmentState.STA)] + public void D002_LineSeries_IsHitTestEnabled_RoundTripsFalse() + { + // Arrange + var plot = new Plot(); + var s = new LineSeries + { + Title = "RT", + IsHitTestEnabled = false + }; + plot.Series.Add(s); + plot.InvalidatePlot(true); + + // Act + var element = PlotSerializer.ToXElement(plot); + var plot2 = new Plot(); + PlotSerializer.FromXElement(plot2, element); + + // Assert + Assert.AreEqual(1, plot2.Series.Count); + Assert.IsFalse(plot2.Series[0].IsHitTestEnabled, + "IsHitTestEnabled=false must survive a round-trip (D-002)."); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void D002_LineSeries_EdgeRenderingMode_RoundTripsPreferSpeed() + { + // Arrange + var plot = new Plot(); + var s = new LineSeries + { + Title = "RT", + EdgeRenderingMode = EdgeRenderingMode.PreferSpeed + }; + plot.Series.Add(s); + plot.InvalidatePlot(true); + + // Act + var element = PlotSerializer.ToXElement(plot); + var plot2 = new Plot(); + PlotSerializer.FromXElement(plot2, element); + + // Assert + Assert.AreEqual(1, plot2.Series.Count); + Assert.AreEqual(EdgeRenderingMode.PreferSpeed, plot2.Series[0].EdgeRenderingMode, + "EdgeRenderingMode must survive a round-trip (D-002)."); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void D002_LineSeries_DefaultIsHitTestEnabledTrueAlsoRoundTrips() + { + // Arrange — explicitly default values; the original audit symptom was that the + // attribute was missing entirely, so unchanged values would still come back as + // defaults — but explicitly setting and round-tripping verifies the writer fired. + var plot = new Plot(); + var s = new LineSeries + { + Title = "RT", + IsHitTestEnabled = true, + EdgeRenderingMode = EdgeRenderingMode.Adaptive + }; + plot.Series.Add(s); + plot.InvalidatePlot(true); + + // Act + var element = PlotSerializer.ToXElement(plot); + var plot2 = new Plot(); + PlotSerializer.FromXElement(plot2, element); + + // Assert + Assert.IsTrue(plot2.Series[0].IsHitTestEnabled); + Assert.AreEqual(EdgeRenderingMode.Adaptive, plot2.Series[0].EdgeRenderingMode); + } + + #endregion + } +} diff --git a/tests/OxyPlot.Wpf.Tests/CultureRoundTripTests.cs b/tests/OxyPlot.Wpf.Tests/CultureRoundTripTests.cs new file mode 100644 index 00000000..1a47d9cf --- /dev/null +++ b/tests/OxyPlot.Wpf.Tests/CultureRoundTripTests.cs @@ -0,0 +1,177 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2014 OxyPlot contributors +// +// +// Verifies plot serialization survives a round-trip under non-US cultures. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OxyPlot.Wpf.Tests +{ + using System; + using System.Globalization; + using System.Threading; + using System.Xml.Linq; + + using NUnit.Framework; + + using OxyPlot.Wpf; + using OxyPlot.Wpf.Serialization; + + /// + /// On a German machine (decimal comma), naive ToString/Parse without InvariantCulture + /// would write "1,5" instead of "1.5", breaking interchange across machines. + /// + [TestFixture] + public class CultureRoundTripTests + { + // Each value has a decimal point in its G17 mantissa, so under bare (non-Invariant) + // ToString on de-DE it would serialize with a comma separator, then fail or drift on + // Invariant parse. MaxValue/MinValue specifically catch a 1-ULP precision drift that + // occurs when bare TryParse on de-DE reads an Invariant-formatted string. + private static readonly double[] TrickyValues = + { + 1234.5678, + -987.654321, + 1.23456789e-10, + 1.23456789e+15, + 0.1, + double.MaxValue, + double.MinValue, + 1e-300, + -1e+250, + }; + + [Test] + [Apartment(ApartmentState.STA)] + public void PlotSerializer_RoundTrip_PreservesAxisBoundsBitExact_UnderGermanCulture() + { + RunUnderCulture("de-DE", () => + { + var plot = BuildPlot(min: 1234.5678, max: 9876.54321, majorStep: 0.1); + plot.InvalidatePlot(true); + + XElement element = PlotSerializer.ToXElement(plot); + + var plot2 = new Plot(); + PlotSerializer.FromXElement(plot2, element); + + Assert.That(plot2.Axes.Count, Is.EqualTo(plot.Axes.Count)); + AssertBitExact(plot.Axes[0].Minimum, plot2.Axes[0].Minimum, "Axes[0].Minimum"); + AssertBitExact(plot.Axes[0].Maximum, plot2.Axes[0].Maximum, "Axes[0].Maximum"); + AssertBitExact(plot.Axes[0].MajorStep, plot2.Axes[0].MajorStep, "Axes[0].MajorStep"); + }); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void PlotSerializer_SerializedXml_UsesPeriodAsDecimalSeparator_UnderGermanCulture() + { + RunUnderCulture("de-DE", () => + { + var plot = BuildPlot(min: 1.5, max: 2.5, majorStep: 0.25); + plot.InvalidatePlot(true); + + XElement element = PlotSerializer.ToXElement(plot); + string xml = element.ToString(); + + Assert.That(xml, Does.Contain("1.5"), $"Min '1.5' missing:\n{xml}"); + Assert.That(xml, Does.Contain("2.5"), $"Max '2.5' missing"); + Assert.That(xml, Does.Contain("0.25"), $"MajorStep '0.25' missing"); + StringAssert.DoesNotContain("1,5", xml, "German-formatted decimal leaked into serialized XML"); + StringAssert.DoesNotContain("0,25", xml, "German-formatted decimal leaked into serialized XML"); + }); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void PlotSerializer_LoadsUsCultureFileUnderGermanCulture() + { + // A user in Germany must be able to load a settings file produced in the US. + XElement element = null; + Plot sourcePlot = null; + RunUnderCulture("en-US", () => + { + sourcePlot = BuildPlot(min: 100.5, max: 999.999, majorStep: 0.1); + sourcePlot.InvalidatePlot(true); + element = PlotSerializer.ToXElement(sourcePlot); + }); + + RunUnderCulture("de-DE", () => + { + var plot2 = new Plot(); + PlotSerializer.FromXElement(plot2, element); + AssertBitExact(sourcePlot.Axes[0].Minimum, plot2.Axes[0].Minimum, "Min"); + AssertBitExact(sourcePlot.Axes[0].Maximum, plot2.Axes[0].Maximum, "Max"); + AssertBitExact(sourcePlot.Axes[0].MajorStep, plot2.Axes[0].MajorStep, "MajorStep"); + }); + } + + [Test] + [Apartment(ApartmentState.STA)] + public void PlotSerializer_RoundTrip_PreservesTrickyDoubleValues_UnderGermanCulture() + { + RunUnderCulture("de-DE", () => + { + foreach (double v in TrickyValues) + { + var plot = BuildPlot(min: v, max: v + 1.0, majorStep: 0.1); + plot.InvalidatePlot(true); + + XElement element = PlotSerializer.ToXElement(plot); + var plot2 = new Plot(); + PlotSerializer.FromXElement(plot2, element); + + AssertBitExact(plot.Axes[0].Minimum, plot2.Axes[0].Minimum, $"Min for {v:R}"); + } + }); + } + + private static Plot BuildPlot(double min, double max, double majorStep) + { + var plot = new Plot(); + var xAxis = new LinearAxis + { + Position = OxyPlot.Axes.AxisPosition.Bottom, + Minimum = min, + Maximum = max, + MajorStep = majorStep, + }; + plot.Axes.Add(xAxis); + var yAxis = new LinearAxis + { + Position = OxyPlot.Axes.AxisPosition.Left, + Minimum = min, + Maximum = max, + }; + plot.Axes.Add(yAxis); + return plot; + } + + private static void RunUnderCulture(string cultureName, Action body) + { + var prevCulture = Thread.CurrentThread.CurrentCulture; + try + { + var culture = new CultureInfo(cultureName); + Thread.CurrentThread.CurrentCulture = culture; + CultureInfo.CurrentCulture = culture; + body(); + } + finally + { + Thread.CurrentThread.CurrentCulture = prevCulture; + CultureInfo.CurrentCulture = prevCulture; + } + } + + private static void AssertBitExact(double expected, double actual, string label) + { + long expectedBits = BitConverter.DoubleToInt64Bits(expected); + long actualBits = BitConverter.DoubleToInt64Bits(actual); + Assert.That(actualBits, Is.EqualTo(expectedBits), + $"{label}: expected {expected:R} (bits {expectedBits}), got {actual:R} (bits {actualBits})"); + } + } +} diff --git a/tests/OxyPlotControls.Tests/AuditRegressionTests.cs b/tests/OxyPlotControls.Tests/AuditRegressionTests.cs new file mode 100644 index 00000000..bf2e59b5 --- /dev/null +++ b/tests/OxyPlotControls.Tests/AuditRegressionTests.cs @@ -0,0 +1,78 @@ +using System.Linq; +using System.Reflection; +using OxyPlotControls; +using Xunit; + +namespace OxyPlotControls.Tests; + +/// +/// Regression tests pinning forensic-audit Phase 3 OxyPlotToolbar refactor. +/// +public class AuditRegressionTests +{ + /// + /// E-001: cursors used to be per-instance and the toolbar implemented IDisposable so + /// consumers had to remember to call Dispose() — they typically didn't, leaking + /// HCURSOR handles. The Phase-3 refactor moved the five custom cursors into a + /// private static CursorCache and removed the IDisposable contract entirely. + /// + [StaFact] + public void E001_OxyPlotToolbar_DoesNotImplementIDisposable() + { + // Arrange + Assert — type contract. + var iface = typeof(OxyPlotToolbar) + .GetInterfaces() + .FirstOrDefault(i => i == typeof(System.IDisposable)); + Assert.Null(iface); + } + + /// + /// E-001: confirms the static CursorCache exists and is populated. Reflection is used + /// because the cache is private. The cache being process-lifetime guarantees that + /// cursor handles are not leaked per toolbar instance. + /// + [StaFact] + public void E001_OxyPlotToolbar_HasStaticCursorCache() + { + // Arrange — locate the private nested CursorCache class. + var cacheType = typeof(OxyPlotToolbar) + .GetNestedType("CursorCache", BindingFlags.NonPublic); + Assert.NotNull(cacheType); + Assert.True(cacheType!.IsAbstract && cacheType.IsSealed, + "CursorCache must be a static class."); + + // Act — every cursor field should be a non-null Cursor. + var fields = cacheType.GetFields(BindingFlags.Static | BindingFlags.NonPublic); + Assert.True(fields.Length >= 5, + $"Expected at least 5 cached cursors; found {fields.Length}."); + + foreach (var field in fields) + { + var value = field.GetValue(null); + Assert.NotNull(value); + Assert.IsAssignableFrom(value); + } + } + + /// + /// E-001: cursors are shared as singletons across toolbar instances. We compare the + /// reference identity of every CursorCache field across two reads — they must be + /// the same instance. + /// + [StaFact] + public void E001_OxyPlotToolbar_CursorsAreShared() + { + var cacheType = typeof(OxyPlotToolbar) + .GetNestedType("CursorCache", BindingFlags.NonPublic); + Assert.NotNull(cacheType); + + var fields = cacheType!.GetFields(BindingFlags.Static | BindingFlags.NonPublic); + foreach (var field in fields) + { + var first = field.GetValue(null); + var second = field.GetValue(null); + // Reference equality: static readonly cached cursor is the same instance. + Assert.Same(first, second); + } + } +} diff --git a/tests/OxyPlotControls.Tests/Axes/AxisTypeConversionTests.cs b/tests/OxyPlotControls.Tests/Axes/AxisTypeConversionTests.cs index 720750e9..11ddd650 100644 --- a/tests/OxyPlotControls.Tests/Axes/AxisTypeConversionTests.cs +++ b/tests/OxyPlotControls.Tests/Axes/AxisTypeConversionTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Media; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Controller/SuppressHoverDuringDragTests.cs b/tests/OxyPlotControls.Tests/Controller/SuppressHoverDuringDragTests.cs new file mode 100644 index 00000000..157fb014 --- /dev/null +++ b/tests/OxyPlotControls.Tests/Controller/SuppressHoverDuringDragTests.cs @@ -0,0 +1,128 @@ +using System.Collections.Generic; +using OxyPlot; +using Xunit; + +namespace OxyPlotControls.Tests.Controller; + +/// +/// Tests for the Phase 1 behavior where skips +/// MouseHoverManipulators (most importantly the tracker) while any MouseDownManipulator is +/// active. This eliminates the per-mouse-move tracker scan that would otherwise saturate +/// the UI thread during pan / zoom-rectangle drag on large-data plots. +/// +public class SuppressHoverDuringDragTests +{ + /// + /// Hover manipulators must fire on MouseMove when NO mouse-down manipulator is active + /// (the normal hover-to-track case). Default EnableHoverDuringDrag=false does + /// not affect the normal hover path. + /// + [Fact] + public void HoverManipulator_Fires_WhenNoDragActive() + { + var ctrl = new TestableController(); + var view = new StubView { ActualController = ctrl }; + + var hover = new CountingMouseManipulator(view); + ctrl.MouseHoverManipulatorsAccessor.Add(hover); + + ctrl.HandleMouseMove(view, NewMouseArgs(10, 10)); + ctrl.HandleMouseMove(view, NewMouseArgs(11, 10)); + + Assert.Equal(2, hover.DeltaCount); + } + + /// + /// When a MouseDownManipulator is active (pan or zoom-rectangle drag in progress), the + /// hover manipulator's Delta must NOT be invoked on subsequent MouseMove events. + /// This is the behavior change of item 1.5 — tracker work is eliminated mid-drag. + /// + [Fact] + public void HoverManipulator_DoesNotFire_WhileDragIsActive() + { + var ctrl = new TestableController(); + var view = new StubView { ActualController = ctrl }; + + var hover = new CountingMouseManipulator(view); + var drag = new CountingMouseManipulator(view); + ctrl.MouseHoverManipulatorsAccessor.Add(hover); + ctrl.MouseDownManipulatorsAccessor.Add(drag); // simulates active pan + + ctrl.HandleMouseMove(view, NewMouseArgs(10, 10)); + ctrl.HandleMouseMove(view, NewMouseArgs(11, 10)); + + Assert.Equal(2, drag.DeltaCount); // drag manipulator keeps firing + Assert.Equal(0, hover.DeltaCount); // hover is suppressed + } + + /// + /// Setting EnableHoverDuringDrag=true restores the legacy behavior where hover + /// manipulators keep firing even while a MouseDownManipulator is active. This is the + /// opt-in escape valve for consumers who rely on mid-drag hover. + /// + [Fact] + public void HoverManipulator_StillFires_WhenEnableHoverDuringDragIsTrue() + { + var ctrl = new TestableController { EnableHoverDuringDrag = true }; + var view = new StubView { ActualController = ctrl }; + + var hover = new CountingMouseManipulator(view); + var drag = new CountingMouseManipulator(view); + ctrl.MouseHoverManipulatorsAccessor.Add(hover); + ctrl.MouseDownManipulatorsAccessor.Add(drag); + + ctrl.HandleMouseMove(view, NewMouseArgs(10, 10)); + + Assert.Equal(1, drag.DeltaCount); + Assert.Equal(1, hover.DeltaCount); + } + + /// + /// Builds a fresh at the given screen point. + /// + private static OxyMouseEventArgs NewMouseArgs(double x, double y) => + new OxyMouseEventArgs { Position = new ScreenPoint(x, y) }; + + /// + /// Test-only that counts Delta invocations. + /// + private sealed class CountingMouseManipulator : ManipulatorBase + { + public CountingMouseManipulator(IView view) : base(view) { } + + public int DeltaCount { get; private set; } + + public override void Delta(OxyMouseEventArgs e) + { + this.DeltaCount++; + base.Delta(e); + } + } + + /// + /// Subclass of that exposes the protected manipulator lists + /// so tests can inject the test-only manipulators directly (bypassing the binding system). + /// + private sealed class TestableController : ControllerBase + { + public IList> MouseDownManipulatorsAccessor => this.MouseDownManipulators; + + public IList> MouseHoverManipulatorsAccessor => this.MouseHoverManipulators; + } + + /// + /// Minimal stub for ControllerBase.HandleMouseMove to run against. + /// + private sealed class StubView : IView + { + public IController? ActualController { get; set; } + public Model? ActualModel => null; + public OxyRect ClientArea => new OxyRect(0, 0, 100, 100); + public void HideTracker() { } + public void HideZoomRectangle() { } + public void SetClipboardText(string text) { } + public void SetCursorType(CursorType cursorType) { } + public void ShowTracker(TrackerHitResult trackerHitResult) { } + public void ShowZoomRectangle(OxyRect rectangle) { } + } +} diff --git a/tests/OxyPlotControls.Tests/Converters/AreaSeriesColor2ConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/AreaSeriesColor2ConverterTests.cs index bb5f0de6..785e6b75 100644 --- a/tests/OxyPlotControls.Tests/Converters/AreaSeriesColor2ConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/AreaSeriesColor2ConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Converters/AreaSeriesFillConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/AreaSeriesFillConverterTests.cs index 75e16937..a79c5d15 100644 --- a/tests/OxyPlotControls.Tests/Converters/AreaSeriesFillConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/AreaSeriesFillConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Converters/BarSeriesFillConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/BarSeriesFillConverterTests.cs index fd4c9857..104d382f 100644 --- a/tests/OxyPlotControls.Tests/Converters/BarSeriesFillConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/BarSeriesFillConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Converters/BoxPlotSeriesFillConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/BoxPlotSeriesFillConverterTests.cs index 84bdfa0a..b967e442 100644 --- a/tests/OxyPlotControls.Tests/Converters/BoxPlotSeriesFillConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/BoxPlotSeriesFillConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Converters/ColorConverterCommonBehaviorTests.cs b/tests/OxyPlotControls.Tests/Converters/ColorConverterCommonBehaviorTests.cs index 8126582b..b51afa01 100644 --- a/tests/OxyPlotControls.Tests/Converters/ColorConverterCommonBehaviorTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/ColorConverterCommonBehaviorTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Converters/DataPointToPointConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/DataPointToPointConverterTests.cs index 25440444..f64f0967 100644 --- a/tests/OxyPlotControls.Tests/Converters/DataPointToPointConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/DataPointToPointConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using OxyPlot; using Xunit; diff --git a/tests/OxyPlotControls.Tests/Converters/DateToNumberConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/DateToNumberConverterTests.cs index 89a9d187..45a98d80 100644 --- a/tests/OxyPlotControls.Tests/Converters/DateToNumberConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/DateToNumberConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System; using System.Globalization; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Converters/EmptyStringToNullConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/EmptyStringToNullConverterTests.cs index bc4338b1..82396a96 100644 --- a/tests/OxyPlotControls.Tests/Converters/EmptyStringToNullConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/EmptyStringToNullConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using Xunit; diff --git a/tests/OxyPlotControls.Tests/Converters/LineSeriesColorConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/LineSeriesColorConverterTests.cs index 319ba28b..66854724 100644 --- a/tests/OxyPlotControls.Tests/Converters/LineSeriesColorConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/LineSeriesColorConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Converters/LineSeriesMarkerFillConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/LineSeriesMarkerFillConverterTests.cs index eddeea7e..336d7821 100644 --- a/tests/OxyPlotControls.Tests/Converters/LineSeriesMarkerFillConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/LineSeriesMarkerFillConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Converters/LineSeriesMarkerStrokeConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/LineSeriesMarkerStrokeConverterTests.cs index 38fdbb9c..e32b9322 100644 --- a/tests/OxyPlotControls.Tests/Converters/LineSeriesMarkerStrokeConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/LineSeriesMarkerStrokeConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Converters/OxyAutomaticColorConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/OxyAutomaticColorConverterTests.cs index 436591b2..9c91f492 100644 --- a/tests/OxyPlotControls.Tests/Converters/OxyAutomaticColorConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/OxyAutomaticColorConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using Xunit; diff --git a/tests/OxyPlotControls.Tests/Converters/OxyDefaultFontSizeConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/OxyDefaultFontSizeConverterTests.cs index b4ec4f28..837486df 100644 --- a/tests/OxyPlotControls.Tests/Converters/OxyDefaultFontSizeConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/OxyDefaultFontSizeConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using Xunit; diff --git a/tests/OxyPlotControls.Tests/Converters/OxyHorizontalAlignmentConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/OxyHorizontalAlignmentConverterTests.cs index 21dd1c8a..e58dec55 100644 --- a/tests/OxyPlotControls.Tests/Converters/OxyHorizontalAlignmentConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/OxyHorizontalAlignmentConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Xunit; diff --git a/tests/OxyPlotControls.Tests/Converters/OxyLineStyleToDashArrayConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/OxyLineStyleToDashArrayConverterTests.cs index 844423e4..64f71bcb 100644 --- a/tests/OxyPlotControls.Tests/Converters/OxyLineStyleToDashArrayConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/OxyLineStyleToDashArrayConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Converters/OxyVerticalAlignmentConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/OxyVerticalAlignmentConverterTests.cs index 9605ca93..ebd1ef2d 100644 --- a/tests/OxyPlotControls.Tests/Converters/OxyVerticalAlignmentConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/OxyVerticalAlignmentConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using Xunit; diff --git a/tests/OxyPlotControls.Tests/Converters/ReverseAxisConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/ReverseAxisConverterTests.cs index bb41afbd..0d47b332 100644 --- a/tests/OxyPlotControls.Tests/Converters/ReverseAxisConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/ReverseAxisConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using Xunit; diff --git a/tests/OxyPlotControls.Tests/Converters/ScatterSeriesMarkerFillConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/ScatterSeriesMarkerFillConverterTests.cs index abd293f7..4dd40c57 100644 --- a/tests/OxyPlotControls.Tests/Converters/ScatterSeriesMarkerFillConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/ScatterSeriesMarkerFillConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Converters/ScatterSeriesMarkerStrokeConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/ScatterSeriesMarkerStrokeConverterTests.cs index 21bc482d..d9b3ed76 100644 --- a/tests/OxyPlotControls.Tests/Converters/ScatterSeriesMarkerStrokeConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/ScatterSeriesMarkerStrokeConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using OxyPlot; diff --git a/tests/OxyPlotControls.Tests/Converters/ScreenVectorToPointConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/ScreenVectorToPointConverterTests.cs index 34485e6c..86b3463d 100644 --- a/tests/OxyPlotControls.Tests/Converters/ScreenVectorToPointConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/ScreenVectorToPointConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using OxyPlot; using Xunit; diff --git a/tests/OxyPlotControls.Tests/Converters/SolidColorBrushConverterTests.cs b/tests/OxyPlotControls.Tests/Converters/SolidColorBrushConverterTests.cs index 766b6e30..f1820dc7 100644 --- a/tests/OxyPlotControls.Tests/Converters/SolidColorBrushConverterTests.cs +++ b/tests/OxyPlotControls.Tests/Converters/SolidColorBrushConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows.Media; using Xunit; diff --git a/tests/OxyPlotControls.Tests/Extensions/DataPointExtensionsTests.cs b/tests/OxyPlotControls.Tests/Extensions/DataPointExtensionsTests.cs index 1a8d5bcb..b0af5c15 100644 --- a/tests/OxyPlotControls.Tests/Extensions/DataPointExtensionsTests.cs +++ b/tests/OxyPlotControls.Tests/Extensions/DataPointExtensionsTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Xml.Linq; using OxyPlot; using OxyPlot.Wpf.Serialization; diff --git a/tests/OxyPlotControls.Tests/Extensions/GetFirstAbstractBaseTypeTests.cs b/tests/OxyPlotControls.Tests/Extensions/GetFirstAbstractBaseTypeTests.cs index 3567c80f..81c01715 100644 --- a/tests/OxyPlotControls.Tests/Extensions/GetFirstAbstractBaseTypeTests.cs +++ b/tests/OxyPlotControls.Tests/Extensions/GetFirstAbstractBaseTypeTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; namespace OxyPlotControls.Tests.Extensions; diff --git a/tests/OxyPlotControls.Tests/Extensions/ScreenPointExtensionsTests.cs b/tests/OxyPlotControls.Tests/Extensions/ScreenPointExtensionsTests.cs index b23d7421..6030fdf4 100644 --- a/tests/OxyPlotControls.Tests/Extensions/ScreenPointExtensionsTests.cs +++ b/tests/OxyPlotControls.Tests/Extensions/ScreenPointExtensionsTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using OxyPlot; using OxyPlot.Wpf.Serialization; using Xunit; diff --git a/tests/OxyPlotControls.Tests/Extensions/ScreenVectorExtensionsTests.cs b/tests/OxyPlotControls.Tests/Extensions/ScreenVectorExtensionsTests.cs index 54c3e0f9..f1b2c370 100644 --- a/tests/OxyPlotControls.Tests/Extensions/ScreenVectorExtensionsTests.cs +++ b/tests/OxyPlotControls.Tests/Extensions/ScreenVectorExtensionsTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using OxyPlot; using OxyPlot.Wpf.Serialization; using Xunit; diff --git a/tests/OxyPlotControls.Tests/Extensions/VectorExtensionsTests.cs b/tests/OxyPlotControls.Tests/Extensions/VectorExtensionsTests.cs index 9457c778..a6d8ef04 100644 --- a/tests/OxyPlotControls.Tests/Extensions/VectorExtensionsTests.cs +++ b/tests/OxyPlotControls.Tests/Extensions/VectorExtensionsTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using OxyPlot.Wpf.Serialization; using Xunit; diff --git a/tests/OxyPlotControls.Tests/Rendering/DrawTextCacheTests.cs b/tests/OxyPlotControls.Tests/Rendering/DrawTextCacheTests.cs new file mode 100644 index 00000000..e8dfa115 --- /dev/null +++ b/tests/OxyPlotControls.Tests/Rendering/DrawTextCacheTests.cs @@ -0,0 +1,145 @@ +using System.Reflection; +using System.Windows.Media; +using OxyPlot; +using OxyPlot.Wpf; +using Xunit; + +namespace OxyPlotControls.Tests.Rendering; + +/// +/// Tests for the Phase 1 Item 1.7 cache in +/// . +/// +/// +/// The cache mirrors the existing MeasureText cache. Axis tick labels, axis titles, and +/// legend entries typically repeat across frames; caching the FormattedText eliminates +/// ~100 allocations per render on a typical plot. These tests verify: +/// 1. Identical inputs produce a cache hit (same reference returned). +/// 2. Varying any cache-key component (text / family / size / weight / color) produces a miss. +/// 3. Changing DpiScale clears the cache (dimensions would be wrong). +/// +public class DrawTextCacheTests +{ + /// + /// Returns the entry count of the private drawTextCache field so tests can inspect + /// cache state without exposing implementation details on the public API. The cache was + /// migrated from to a + /// bounded LRU (private nested type), so we read the public Count property + /// reflectively instead of casting to . + /// + private static int GetDrawTextCacheCount(DrawingVisualRenderContext rc) + { + var field = typeof(DrawingVisualRenderContext).GetField( + "drawTextCache", + BindingFlags.Instance | BindingFlags.NonPublic)!; + var cache = field.GetValue(rc)!; + var countProp = cache.GetType().GetProperty("Count", BindingFlags.Instance | BindingFlags.Public)!; + return (int)countProp.GetValue(cache)!; + } + + /// + /// Two DrawText calls with identical inputs should result in a single cache entry + /// reused across both calls — the second call must NOT allocate a new FormattedText. + /// + [Fact] + public void DrawText_IdenticalInputs_ReusesCachedFormattedText() + { + var rc = new DrawingVisualRenderContext(); + var visual = new DrawingVisual(); + rc.OpenDrawing(visual); + + rc.DrawText( + new ScreenPoint(0, 0), + "Hello", + OxyColors.Black, + "Segoe UI", + 12, + 400, + 0, + HorizontalAlignment.Left, + VerticalAlignment.Top, + null); + + rc.DrawText( + new ScreenPoint(10, 10), + "Hello", + OxyColors.Black, + "Segoe UI", + 12, + 400, + 0, + HorizontalAlignment.Left, + VerticalAlignment.Top, + null); + + rc.CloseDrawing(); + + Assert.Equal(1, GetDrawTextCacheCount(rc)); + } + + /// + /// Varying any component of the cache key (here: fontSize) should produce a second + /// cache entry — the cache must not accidentally collapse distinct renders. + /// + [Fact] + public void DrawText_DifferentFontSize_AllocatesSeparateCacheEntry() + { + var rc = new DrawingVisualRenderContext(); + var visual = new DrawingVisual(); + rc.OpenDrawing(visual); + + rc.DrawText(new ScreenPoint(0, 0), "Label", OxyColors.Black, "Segoe UI", 12, 400, 0, + HorizontalAlignment.Left, VerticalAlignment.Top, null); + rc.DrawText(new ScreenPoint(0, 0), "Label", OxyColors.Black, "Segoe UI", 14, 400, 0, + HorizontalAlignment.Left, VerticalAlignment.Top, null); + + rc.CloseDrawing(); + + Assert.Equal(2, GetDrawTextCacheCount(rc)); + } + + /// + /// Different colors must NOT share a FormattedText because its foreground brush is + /// embedded in the object. + /// + [Fact] + public void DrawText_DifferentColor_AllocatesSeparateCacheEntry() + { + var rc = new DrawingVisualRenderContext(); + var visual = new DrawingVisual(); + rc.OpenDrawing(visual); + + rc.DrawText(new ScreenPoint(0, 0), "Same", OxyColors.Red, "Segoe UI", 12, 400, 0, + HorizontalAlignment.Left, VerticalAlignment.Top, null); + rc.DrawText(new ScreenPoint(0, 0), "Same", OxyColors.Blue, "Segoe UI", 12, 400, 0, + HorizontalAlignment.Left, VerticalAlignment.Top, null); + + rc.CloseDrawing(); + + Assert.Equal(2, GetDrawTextCacheCount(rc)); + } + + /// + /// Setting to a new value must clear + /// the FormattedText cache; cached dimensions are DPI-dependent and reusing them at + /// a different DPI would produce incorrect layout. + /// + [Fact] + public void DpiScaleChange_ClearsDrawTextCache() + { + var rc = new DrawingVisualRenderContext(); + var visual = new DrawingVisual(); + rc.OpenDrawing(visual); + + rc.DrawText(new ScreenPoint(0, 0), "Text", OxyColors.Black, "Segoe UI", 12, 400, 0, + HorizontalAlignment.Left, VerticalAlignment.Top, null); + + rc.CloseDrawing(); + + Assert.Equal(1, GetDrawTextCacheCount(rc)); + + rc.DpiScale = 1.5; + + Assert.Equal(0, GetDrawTextCacheCount(rc)); + } +} diff --git a/tests/OxyPlotControls.Tests/SavePlotImageDialog/SavePlotImageDialogTests.cs b/tests/OxyPlotControls.Tests/SavePlotImageDialog/SavePlotImageDialogTests.cs index 8fbc4bbd..99643f02 100644 --- a/tests/OxyPlotControls.Tests/SavePlotImageDialog/SavePlotImageDialogTests.cs +++ b/tests/OxyPlotControls.Tests/SavePlotImageDialog/SavePlotImageDialogTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.IO; using System.Windows; using OxyPlot; @@ -89,7 +59,11 @@ public void Constructor_WithValidPlot_TitleIsSetCorrectly() } /// - /// Verifies that the dialog has the correct initial size computed from the default preset (600x480). + /// Verifies that the dialog initial size is computed from the default preset (600x480) and + /// falls within the expected bounds. The exact dialog size depends on + /// , which varies by display/DPI and + /// between interactive and headless (CI) environments, so the assertion uses tolerant ranges + /// rather than exact pixel values. /// [StaFact] public void Constructor_WithValidPlot_HasCorrectInitialSize() @@ -101,9 +75,12 @@ public void Constructor_WithValidPlot_HasCorrectInitialSize() var dialog = new OxyPlotControls.SavePlotImageDialog(plot); // Assert — initial size computed from default 600x480 preset: - // width = 600 + 36 (padding) = 636, height = 480 + 190 (controls) + 50 (chrome) = 720 - Assert.Equal(636, dialog.Width); - Assert.Equal(720, dialog.Height); + // width = 600 + 36 (padding) ≈ 636 on a typical display + // height = 480 + 190 (controls) + 50 (chrome) ≈ 720 on a typical display + // Both are clamped to at least MinWidth/MinHeight and at most WorkArea * ScreenUsageFraction, + // so CI's smaller WorkArea can produce slightly smaller values. + Assert.InRange(dialog.Width, dialog.MinWidth, 800); + Assert.InRange(dialog.Height, dialog.MinHeight, 900); } /// diff --git a/tests/OxyPlotControls.Tests/Serialization/AxisSerializationTests.cs b/tests/OxyPlotControls.Tests/Serialization/AxisSerializationTests.cs index fbd45c58..c97c4769 100644 --- a/tests/OxyPlotControls.Tests/Serialization/AxisSerializationTests.cs +++ b/tests/OxyPlotControls.Tests/Serialization/AxisSerializationTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using System.Windows.Media; diff --git a/tests/OxyPlotControls.Tests/Serialization/GeneralPropertiesSerializationTests.cs b/tests/OxyPlotControls.Tests/Serialization/GeneralPropertiesSerializationTests.cs index fbcaea26..efd7cd6e 100644 --- a/tests/OxyPlotControls.Tests/Serialization/GeneralPropertiesSerializationTests.cs +++ b/tests/OxyPlotControls.Tests/Serialization/GeneralPropertiesSerializationTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Media; using System.Xml.Linq; diff --git a/tests/OxyPlotControls.Tests/Serialization/LegendSerializationTests.cs b/tests/OxyPlotControls.Tests/Serialization/LegendSerializationTests.cs index 2451841c..975dbdf8 100644 --- a/tests/OxyPlotControls.Tests/Serialization/LegendSerializationTests.cs +++ b/tests/OxyPlotControls.Tests/Serialization/LegendSerializationTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Windows; using System.Windows.Media; using System.Xml.Linq; diff --git a/tests/OxyPlotControls.Tests/Serialization/OxyPlotSettingsSerializerTests.cs b/tests/OxyPlotControls.Tests/Serialization/OxyPlotSettingsSerializerTests.cs index 34de40ec..5c140a05 100644 --- a/tests/OxyPlotControls.Tests/Serialization/OxyPlotSettingsSerializerTests.cs +++ b/tests/OxyPlotControls.Tests/Serialization/OxyPlotSettingsSerializerTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using System.Globalization; using System.Windows; using System.Windows.Media; diff --git a/tests/OxyPlotControls.Tests/Series/GetNearestPointThreadSafetyTests.cs b/tests/OxyPlotControls.Tests/Series/GetNearestPointThreadSafetyTests.cs new file mode 100644 index 00000000..ed7ece9c --- /dev/null +++ b/tests/OxyPlotControls.Tests/Series/GetNearestPointThreadSafetyTests.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using OxyPlot; +using OxyPlot.Axes; +using OxyPlot.Series; +using Xunit; + +namespace OxyPlotControls.Tests.Series; + +/// +/// Thread-safety tests for the Phase 1 Item 1.6 refactor of +/// . +/// +/// +/// The original implementation used foreach (var p in points.Skip(startIdx)) over the +/// backing , which constructs a state-machine enumerator. +/// If the underlying list is mutated by another thread mid-scan, that enumerator throws +/// InvalidOperationException: Collection was modified. After 1.6 the method uses +/// an indexed for loop over , which does not observe +/// the enumerator version flag and so is safe against concurrent mutation (reads are still +/// torn, but no exception). +/// +public class GetNearestPointThreadSafetyTests +{ + /// + /// Drives in a tight loop on the UI thread while + /// a worker thread mutates the series' Points list. The legacy implementation + /// threw InvalidOperationException within a few iterations; the 1.6 indexed scan + /// completes without throwing. + /// + [Fact] + public async Task GetNearestPoint_DoesNotThrow_UnderConcurrentPointsMutation() + { + var series = new LineSeries(); + for (int i = 0; i < 1000; i++) + { + series.Points.Add(new DataPoint(i, i)); + } + + // Attach axes so Transform does not throw. + var model = new PlotModel(); + model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = 0, Maximum = 1000 }); + model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 0, Maximum = 1000 }); + model.Series.Add(series); + ((IPlotModel)model).Update(updateData: true); + + using var cts = new CancellationTokenSource(); + var mutator = Task.Run(() => + { + var rng = new Random(12345); + try + { + while (!cts.Token.IsCancellationRequested) + { + // Rapid add/remove on the list to maximize chances of catching a + // version-sensitive enumerator mid-iteration. + if (series.Points.Count > 500 && rng.Next(2) == 0) + { + series.Points.RemoveAt(series.Points.Count - 1); + } + else + { + int n = series.Points.Count; + series.Points.Add(new DataPoint(n, n)); + } + } + } + catch + { + // Mutation races on List itself may produce internal exceptions; + // they are not the subject of this test and must not fail the assertion. + } + }); + + try + { + for (int iter = 0; iter < 2000; iter++) + { + // Any screen point — the scan is what we care about, not the returned hit. + _ = series.GetNearestPoint(new ScreenPoint(500, 500), interpolate: false); + } + } + finally + { + cts.Cancel(); + await mutator.WaitAsync(TimeSpan.FromSeconds(5)); + } + + // Reaching this assertion means no InvalidOperationException bubbled out of + // GetNearestPointInternal while the mutator thread was churning Points. + Assert.True(true); + } +} diff --git a/tests/OxyPlotControls.Tests/Series/SeriesIsHitTestEnabledTests.cs b/tests/OxyPlotControls.Tests/Series/SeriesIsHitTestEnabledTests.cs new file mode 100644 index 00000000..fc3099f7 --- /dev/null +++ b/tests/OxyPlotControls.Tests/Series/SeriesIsHitTestEnabledTests.cs @@ -0,0 +1,94 @@ +using OxyPlot; +using OxyPlot.Axes; +using OxyPlot.Series; +using Xunit; + +namespace OxyPlotControls.Tests.Series; + +/// +/// Tests for the property added in the +/// Phase 1 OxyPlot performance overhaul. Verifies per-series opt-out from the tracker +/// hit-test path. +/// +public class SeriesIsHitTestEnabledTests +{ + /// + /// A fresh must default + /// to true so Phase 1 is purely additive — existing consumers unaware of the flag + /// get identical tracker behavior to before. + /// + [Fact] + public void IsHitTestEnabled_DefaultsToTrue_OnFreshLineSeries() + { + var series = new LineSeries(); + Assert.True(series.IsHitTestEnabled); + } + + /// + /// When IsHitTestEnabled=false, must skip + /// the series in its filter. The filter runs BEFORE any hit-test work, so + /// must not be invoked on a disabled series. + /// + [Fact] + public void GetSeriesFromPoint_DoesNotCallGetNearestPoint_WhenHitTestDisabled() + { + var model = new PlotModel(); + model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = 0, Maximum = 10 }); + model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 0, Maximum = 10 }); + + var series = new CountingLineSeries { IsHitTestEnabled = false }; + series.Points.Add(new DataPoint(0, 0)); + series.Points.Add(new DataPoint(10, 10)); + model.Series.Add(series); + + // Must update the model so visible series list is populated correctly. + ((IPlotModel)model).Update(updateData: true); + + // Arbitrary screen point — the filter short-circuits before coordinates matter. + _ = model.GetSeriesFromPoint(new ScreenPoint(50, 50), limit: 1000); + + Assert.Equal(0, series.GetNearestPointCallCount); + } + + /// + /// When IsHitTestEnabled=true (the default), + /// must still invoke on the series — + /// the flag is the ONLY gate added by 1.1. + /// + [Fact] + public void GetSeriesFromPoint_CallsGetNearestPoint_WhenHitTestEnabled() + { + var model = new PlotModel(); + model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = 0, Maximum = 10 }); + model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 0, Maximum = 10 }); + + var series = new CountingLineSeries(); // IsHitTestEnabled defaults to true + series.Points.Add(new DataPoint(0, 0)); + series.Points.Add(new DataPoint(10, 10)); + model.Series.Add(series); + + ((IPlotModel)model).Update(updateData: true); + + _ = model.GetSeriesFromPoint(new ScreenPoint(50, 50), limit: 1000); + + Assert.True(series.GetNearestPointCallCount > 0, + "IsHitTestEnabled=true should route through GetNearestPoint at least once."); + } + + /// + /// Test-only subclass that records the number of times + /// is invoked. + /// + private sealed class CountingLineSeries : LineSeries + { + /// Gets the number of invocations since construction. + public int GetNearestPointCallCount { get; private set; } + + /// + public override TrackerHitResult GetNearestPoint(ScreenPoint point, bool interpolate) + { + this.GetNearestPointCallCount++; + return base.GetNearestPoint(point, interpolate); + } + } +} diff --git a/tests/SoftwareUpdate.Tests/Core/UpdateCheckResultTests.cs b/tests/SoftwareUpdate.Tests/Core/UpdateCheckResultTests.cs index a7f1db99..696ca899 100644 --- a/tests/SoftwareUpdate.Tests/Core/UpdateCheckResultTests.cs +++ b/tests/SoftwareUpdate.Tests/Core/UpdateCheckResultTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using SoftwareUpdate; diff --git a/tests/SoftwareUpdate.Tests/Core/UpdateDownloadProgressTests.cs b/tests/SoftwareUpdate.Tests/Core/UpdateDownloadProgressTests.cs index 3c0ce236..dc670416 100644 --- a/tests/SoftwareUpdate.Tests/Core/UpdateDownloadProgressTests.cs +++ b/tests/SoftwareUpdate.Tests/Core/UpdateDownloadProgressTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using SoftwareUpdate; diff --git a/tests/SoftwareUpdate.Tests/Core/UpdateDownloadResultTests.cs b/tests/SoftwareUpdate.Tests/Core/UpdateDownloadResultTests.cs index 5322e390..f86e3700 100644 --- a/tests/SoftwareUpdate.Tests/Core/UpdateDownloadResultTests.cs +++ b/tests/SoftwareUpdate.Tests/Core/UpdateDownloadResultTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using SoftwareUpdate; diff --git a/tests/SoftwareUpdate.Tests/Core/UpdateInfoTests.cs b/tests/SoftwareUpdate.Tests/Core/UpdateInfoTests.cs index 1dd866ad..e7c25c75 100644 --- a/tests/SoftwareUpdate.Tests/Core/UpdateInfoTests.cs +++ b/tests/SoftwareUpdate.Tests/Core/UpdateInfoTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using SoftwareUpdate; diff --git a/tests/SoftwareUpdate.Tests/Core/UpdateOptionsTests.cs b/tests/SoftwareUpdate.Tests/Core/UpdateOptionsTests.cs index 2aa8714a..874aa739 100644 --- a/tests/SoftwareUpdate.Tests/Core/UpdateOptionsTests.cs +++ b/tests/SoftwareUpdate.Tests/Core/UpdateOptionsTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using SoftwareUpdate; diff --git a/tests/SoftwareUpdate.Tests/GitHub/GitHubUpdateServiceTests.cs b/tests/SoftwareUpdate.Tests/GitHub/GitHubUpdateServiceTests.cs index 48180a2b..2d7dfc39 100644 --- a/tests/SoftwareUpdate.Tests/GitHub/GitHubUpdateServiceTests.cs +++ b/tests/SoftwareUpdate.Tests/GitHub/GitHubUpdateServiceTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using SoftwareUpdate; using SoftwareUpdate.GitHub; @@ -383,10 +353,16 @@ await Assert.ThrowsAsync(() => } /// - /// Verifies that DownloadUpdateAsync returns a failed result when the download URL is missing. + /// Verifies that DownloadUpdateAsync rejects calls made from the Idle state with an + /// . Per the F-006 state-machine contract, callers + /// must run a successful first so + /// the service is in the state before download. + /// Previously this test asserted that a malformed UpdateInfo (null DownloadUrl) returned + /// a failed result; that path is now unreachable because the state guard fires first, + /// regardless of the supplied UpdateInfo's contents. /// [Fact] - public async Task DownloadUpdateAsync_MissingDownloadUrl_ReturnsFailedResult() + public async Task DownloadUpdateAsync_FromIdleState_ThrowsInvalidOperationException() { var options = CreateValidOptions(); _service = new GitHubUpdateService(options); @@ -394,13 +370,11 @@ public async Task DownloadUpdateAsync_MissingDownloadUrl_ReturnsFailedResult() var update = new UpdateInfo { AssetName = "valid.zip", - DownloadUrl = null // Missing URL + DownloadUrl = "https://example.com/valid.zip" }; - // This should fail gracefully with a result, not throw - var result = await _service.DownloadUpdateAsync(update); - - Assert.False(result.Success); + await Assert.ThrowsAsync(() => + _service.DownloadUpdateAsync(update)); } #endregion diff --git a/tests/SoftwareUpdate.Tests/GitHub/Sha256ExtractionTests.cs b/tests/SoftwareUpdate.Tests/GitHub/Sha256ExtractionTests.cs new file mode 100644 index 00000000..3d78f5e8 --- /dev/null +++ b/tests/SoftwareUpdate.Tests/GitHub/Sha256ExtractionTests.cs @@ -0,0 +1,86 @@ +using System.Reflection; +using SoftwareUpdate.GitHub; +using Xunit; + +namespace SoftwareUpdate.Tests.GitHub +{ + /// + /// Regression tests pinning the SHA256 release-notes extraction (F-002). + /// + /// The audit flagged that UpdateInfo.Sha256Checksum was always null because + /// no parsing path existed in . The fix added a + /// private static ExtractSha256Checksum helper that scans the release body + /// for the documented SHA256: <hex> token. These tests exercise that + /// helper via reflection so accidental removal or regex regression is caught. + /// + public class Sha256ExtractionTests + { + /// + /// Invokes the private ExtractSha256Checksum(string?) helper via reflection. + /// + private static string? Invoke(string? releaseBody) + { + var method = typeof(GitHubUpdateService).GetMethod( + "ExtractSha256Checksum", + BindingFlags.Static | BindingFlags.NonPublic); + Assert.NotNull(method); + return (string?)method!.Invoke(null, new object?[] { releaseBody }); + } + + [Fact] + public void Sha256ChecksumIsExtractedFromReleaseNotes() + { + // Arrange — typical release body containing the documented SHA256 token. + var hex = new string('a', 64); + var body = "Release v1.2.3\n\nSHA256: " + hex + "\n"; + + // Act + var result = Invoke(body); + + // Assert + Assert.Equal(hex, result); + } + + [Fact] + public void Sha256IsExtractedWhenSurroundedByOtherText() + { + var hex = "0123456789abcdefABCDEF" + new string('1', 42); // 64 chars + var body = "## Changes\n\n- Improved foo\n- Fixed bar\n\nSHA256: " + hex + "\n\nThanks!"; + + var result = Invoke(body); + + Assert.Equal(hex.ToLowerInvariant(), result); + } + + [Fact] + public void Sha256ExtractionReturnsNullForEmptyBody() + { + Assert.Null(Invoke(null)); + Assert.Null(Invoke(string.Empty)); + } + + [Fact] + public void Sha256ExtractionReturnsNullWhenTokenMissing() + { + var body = "Release notes that do not contain a checksum line."; + Assert.Null(Invoke(body)); + } + + [Fact] + public void Sha256ExtractionRejectsShortHex() + { + // 32 hex chars instead of 64 — must not match. + var body = "SHA256: " + new string('a', 32); + Assert.Null(Invoke(body)); + } + + [Fact] + public void Sha256ExtractionResultIsLowercase() + { + var hex = new string('A', 64); + var body = "SHA256: " + hex; + var result = Invoke(body); + Assert.Equal(new string('a', 64), result); + } + } +} diff --git a/tests/SoftwareUpdate.Tests/Utilities/SemanticVersionTests.cs b/tests/SoftwareUpdate.Tests/Utilities/SemanticVersionTests.cs index e13e06f0..0c30df33 100644 --- a/tests/SoftwareUpdate.Tests/Utilities/SemanticVersionTests.cs +++ b/tests/SoftwareUpdate.Tests/Utilities/SemanticVersionTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using SoftwareUpdate; diff --git a/tests/SoftwareUpdate.Updater.Tests/InstallationManagerTests.cs b/tests/SoftwareUpdate.Updater.Tests/InstallationManagerTests.cs index c9426b46..4e35bd5f 100644 --- a/tests/SoftwareUpdate.Updater.Tests/InstallationManagerTests.cs +++ b/tests/SoftwareUpdate.Updater.Tests/InstallationManagerTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using SoftwareUpdate.Updater; using System.IO.Compression; diff --git a/tests/SoftwareUpdate.Updater.Tests/UpdaterArgumentsTests.cs b/tests/SoftwareUpdate.Updater.Tests/UpdaterArgumentsTests.cs index 59ce9882..33b00a62 100644 --- a/tests/SoftwareUpdate.Updater.Tests/UpdaterArgumentsTests.cs +++ b/tests/SoftwareUpdate.Updater.Tests/UpdaterArgumentsTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using SoftwareUpdate.Updater; diff --git a/tests/SoftwareUpdate.Updater.Tests/WaitForKeyTimeoutTests.cs b/tests/SoftwareUpdate.Updater.Tests/WaitForKeyTimeoutTests.cs new file mode 100644 index 00000000..d25e7961 --- /dev/null +++ b/tests/SoftwareUpdate.Updater.Tests/WaitForKeyTimeoutTests.cs @@ -0,0 +1,81 @@ +using System.Diagnostics; +using System.IO; +using Xunit; + +namespace SoftwareUpdate.Updater.Tests +{ + /// + /// Regression tests for F-003: the failure-path key-wait used to throw + /// when the updater was launched + /// with no console attached (e.g. CreateNoWindow=true). The fix wraps + /// Console.ReadKey inside the existing WaitForKeyWithTimeout guard + /// so the failure path exits cleanly instead of crashing. + /// + public class WaitForKeyTimeoutTests + { + /// + /// Locates the built SoftwareUpdate.Updater.exe alongside the test assembly. + /// + private static string LocateUpdaterExe() + { + var dir = Path.GetDirectoryName(typeof(WaitForKeyTimeoutTests).Assembly.Location)!; + var path = Path.Combine(dir, "SoftwareUpdate.Updater.exe"); + if (!File.Exists(path)) + { + throw new FileNotFoundException( + $"SoftwareUpdate.Updater.exe was expected next to the test assembly at '{path}'. " + + "The test depends on the updater build copying its output beside the test runner."); + } + return path; + } + + /// + /// F-003: With no attached console, the failure-path Console.ReadKey would throw + /// InvalidOperationException; the fix swallows it through WaitForKeyWithTimeout. + /// We invoke the updater with deliberately invalid args so it takes the failure + /// path, redirect stderr, and confirm no InvalidOperationException is reported. + /// + [Fact] + public void WaitForKeyWithTimeout_DoesNotThrowWithoutConsole() + { + var exe = LocateUpdaterExe(); + + var psi = new ProcessStartInfo + { + FileName = exe, + Arguments = "--unknown-arg something", + UseShellExecute = false, + CreateNoWindow = true, + RedirectStandardInput = true, + RedirectStandardOutput = true, + RedirectStandardError = true, + }; + + using var proc = Process.Start(psi); + Assert.NotNull(proc); + + // Force stdin closed so the failure-path key wait cannot read anything. + proc!.StandardInput.Close(); + + // The failure-path keeps the console open up to FailureCloseTimeoutMs (15s). + // Give it 30s to finish to be safe. + var exited = proc.WaitForExit(30_000); + if (!exited) + { + try { proc.Kill(true); } catch { /* ignore */ } + Assert.Fail("Updater did not exit within 30 seconds; failure-path likely blocked on Console.ReadKey."); + } + + var stderr = proc.StandardError.ReadToEnd(); + var stdout = proc.StandardOutput.ReadToEnd(); + + // Must have exited with a non-zero code (it failed to parse args). + Assert.NotEqual(0, proc.ExitCode); + + // Crucially: must NOT have crashed via InvalidOperationException — the F-003 fix + // wraps Console.ReadKey to handle the no-console case. + var combined = stderr + stdout; + Assert.DoesNotContain("InvalidOperationException", combined); + } + } +} diff --git a/tests/Themes.Tests/Converters/CutoffConverterTests.cs b/tests/Themes.Tests/Converters/CutoffConverterTests.cs index 1da72e2a..bc600204 100644 --- a/tests/Themes.Tests/Converters/CutoffConverterTests.cs +++ b/tests/Themes.Tests/Converters/CutoffConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using Themes; using System.Windows; diff --git a/tests/Themes.Tests/Converters/TabSizeConverterTests.cs b/tests/Themes.Tests/Converters/TabSizeConverterTests.cs index 564802ae..e2980f19 100644 --- a/tests/Themes.Tests/Converters/TabSizeConverterTests.cs +++ b/tests/Themes.Tests/Converters/TabSizeConverterTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using Themes; using System.Globalization; diff --git a/tests/Themes.Tests/Core/ThemeChangedEventArgsTests.cs b/tests/Themes.Tests/Core/ThemeChangedEventArgsTests.cs index 7b92f512..26a81aa7 100644 --- a/tests/Themes.Tests/Core/ThemeChangedEventArgsTests.cs +++ b/tests/Themes.Tests/Core/ThemeChangedEventArgsTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using Themes; using System.Windows; diff --git a/tests/Themes.Tests/Core/ThemeResourceHelperTests.cs b/tests/Themes.Tests/Core/ThemeResourceHelperTests.cs index bc107685..2593c353 100644 --- a/tests/Themes.Tests/Core/ThemeResourceHelperTests.cs +++ b/tests/Themes.Tests/Core/ThemeResourceHelperTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using Themes; diff --git a/tests/Themes.Tests/Core/ThemeServiceConcurrencyTests.cs b/tests/Themes.Tests/Core/ThemeServiceConcurrencyTests.cs new file mode 100644 index 00000000..1fb6a885 --- /dev/null +++ b/tests/Themes.Tests/Core/ThemeServiceConcurrencyTests.cs @@ -0,0 +1,185 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Threading; +using Themes; +using Xunit; + +namespace Themes.Tests.Core +{ + /// + /// Regression tests for forensic-audit findings A-006 and A-014. + /// + /// + /// + /// A-006 — must not deadlock when a + /// subscriber re-enters the singleton from inside the ThemeChanged handler. + /// The fix mutates MergedDictionaries and raises the event outside the + /// internal _lock. + /// + /// + /// A-014 — must marshal background-thread + /// calls to the WPF UI thread instead of throwing. + /// + /// + /// Both tests run on a single dedicated STA thread that owns + /// and runs a real loop, + /// shared via . Without that, each StaFact thread + /// would create a fresh Application with its dispatcher bound to the calling thread — + /// but Application.Current is process-wide, so the second test sees a Dispatcher + /// belonging to the first test's thread, which has no message pump and deadlocks. + /// + /// + public class ThemeServiceConcurrencyTests + { + [Fact] + public void A006_ThemeService_SwitchesThemeUnderConcurrentAccess_DoesNotDeadlock() + { + DispatcherTestHost.Run(() => + { + Theme observed = Theme.Light; + EventHandler handler = (_, _) => + { + // Synchronously re-enter the service from inside the handler. + // Pre-fix this hung because SetTheme still held _lock; post-fix the + // mutation/event are outside the lock so this re-entry returns. + observed = ThemeService.Instance.CurrentTheme; + }; + ThemeService.Instance.ThemeChanged += handler; + + try + { + ThemeService.Instance.SetTheme(Theme.Dark); + + Assert.Equal(Theme.Dark, observed); + Assert.Equal(Theme.Dark, ThemeService.Instance.CurrentTheme); + } + finally + { + ThemeService.Instance.ThemeChanged -= handler; + if (ThemeService.Instance.CurrentTheme != Theme.Light) + { + ThemeService.Instance.SetTheme(Theme.Light); + } + } + }); + } + + [Fact] + public void A014_ThemeService_BackgroundThreadSetTheme_MarshalsToUI() + { + DispatcherTestHost.Run(() => + { + // Submit SetTheme from a non-dispatcher thread. The fix marshals to the + // UI thread via Dispatcher.Invoke. The DispatcherTestHost is running a + // real Dispatcher.Run() loop on a dedicated STA thread, and its dispatcher + // is the one bound to Application.Current — so the marshalled call + // actually reaches a thread that pumps it. + var task = Task.Run(() => ThemeService.Instance.SetTheme(Theme.Dark)); + + // Block the dispatcher thread momentarily while the worker runs. We + // cannot Dispatcher.PushFrame here because we are already inside the + // dispatcher; instead we yield via DispatcherFrame which runs queued + // operations and exits when the worker completes. + var frame = new DispatcherFrame(); + var watchdog = Task.Run(async () => + { + var deadline = DateTime.UtcNow.AddSeconds(5); + while (!task.IsCompleted && DateTime.UtcNow < deadline) + { + await Task.Delay(20).ConfigureAwait(false); + } + frame.Continue = false; + }); + Dispatcher.PushFrame(frame); + watchdog.Wait(TimeSpan.FromSeconds(1)); + + try + { + Assert.True(task.IsCompleted, + "Background-thread SetTheme did not complete within 5s (A-014)."); + if (task.Exception != null) + { + Assert.Fail("Background-thread SetTheme threw: " + task.Exception); + } + Assert.Equal(Theme.Dark, ThemeService.Instance.CurrentTheme); + } + finally + { + if (ThemeService.Instance.CurrentTheme != Theme.Light) + { + ThemeService.Instance.SetTheme(Theme.Light); + } + } + }); + } + } + + /// + /// Hosts a single dedicated STA thread that owns + /// and runs a real loop. Tests submit work via + /// which executes synchronously on that thread. Sharing one + /// dispatcher across tests prevents the cross-test Application.Current/Dispatcher + /// thread mismatch that caused intermittent deadlocks under StaFact. + /// + internal static class DispatcherTestHost + { + private static readonly object _gate = new(); + private static Dispatcher? _dispatcher; + private static Thread? _thread; + + private static Dispatcher EnsureRunning() + { + lock (_gate) + { + if (_dispatcher != null) + { + return _dispatcher; + } + + using var ready = new ManualResetEventSlim(false); + Dispatcher? captured = null; + + _thread = new Thread(() => + { + // Application.Current is process-wide and binds to the thread that + // creates it, so we must do this on the dispatcher thread to ensure + // SetTheme's auto-marshal reaches a pumped dispatcher. + if (Application.Current == null) + { + _ = new Application(); + } + + if (!ThemeService.Instance.IsInitialized) + { + ThemeService.Instance.Initialize(Theme.Light); + } + else if (ThemeService.Instance.CurrentTheme != Theme.Light) + { + ThemeService.Instance.SetTheme(Theme.Light); + } + + captured = Dispatcher.CurrentDispatcher; + ready.Set(); + Dispatcher.Run(); + }) + { + IsBackground = true, + Name = "ThemeServiceTestsDispatcher", + }; + _thread.SetApartmentState(ApartmentState.STA); + _thread.Start(); + ready.Wait(); + _dispatcher = captured!; + return _dispatcher; + } + } + + public static void Run(Action body) + { + var d = EnsureRunning(); + d.Invoke(body); + } + } +} diff --git a/tests/Themes.Tests/Core/ThemeTests.cs b/tests/Themes.Tests/Core/ThemeTests.cs index e7b64b8c..4fbc8f6e 100644 --- a/tests/Themes.Tests/Core/ThemeTests.cs +++ b/tests/Themes.Tests/Core/ThemeTests.cs @@ -1,33 +1,3 @@ -/* -* NOTICE: -* The U.S. Army Corps of Engineers, Risk Management Center (USACE-RMC) makes no guarantees about -* the results, or appropriateness of outputs, obtained from this software. -* -* LIST OF CONDITIONS: -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* - Redistributions of source code must retain the above notice, this list of conditions, and the -* following disclaimer. -* - Redistributions in binary form must reproduce the above notice, this list of conditions, and -* the following disclaimer in the documentation and/or other materials provided with the distribution. -* - The names of the U.S. Government, the U.S. Army Corps of Engineers, the Institute for Water -* Resources, or the Risk Management Center may not be used to endorse or promote products derived -* from this software without specific prior written permission. Nor may the names of its contributors -* be used to endorse or promote products derived from this software without specific prior -* written permission. -* -* DISCLAIMER: -* THIS SOFTWARE IS PROVIDED BY THE U.S. ARMY CORPS OF ENGINEERS RISK MANAGEMENT CENTER -* (USACE-RMC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL USACE-RMC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - using Xunit; using Themes; diff --git a/tests/Themes.Tests/Themes.Tests.csproj b/tests/Themes.Tests/Themes.Tests.csproj index c89d17b2..6ecfce84 100644 --- a/tests/Themes.Tests/Themes.Tests.csproj +++ b/tests/Themes.Tests/Themes.Tests.csproj @@ -26,4 +26,10 @@ + + + PreserveNewest + + + diff --git a/tests/Themes.Tests/xunit.runner.json b/tests/Themes.Tests/xunit.runner.json new file mode 100644 index 00000000..dd80f43a --- /dev/null +++ b/tests/Themes.Tests/xunit.runner.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", + "parallelizeAssembly": false, + "parallelizeTestCollections": false +}