From c9696eaa9aed89b9be0a63413ab0762dd5fb482a Mon Sep 17 00:00:00 2001 From: Haden Smith <123974306+HadenSmith@users.noreply.github.com> Date: Sun, 19 Jul 2026 17:00:25 +0000 Subject: [PATCH 01/13] Trim FrameworkUI.Demo to the hazard function example Remove the stubbed response and consequence function elements, the orphaned undo and theme demo controls, and the unused generic element document/properties controls. The demo now focuses on a single fully implemented hazard function element. --- .../ConsequenceElement.cs | 129 -------- .../ConsequenceElementCollection.cs | 113 ------- src/FrameworkUI.Demo/Model/DemoProject.cs | 24 +- .../Response Elements/ResponseElement.cs | 129 -------- .../ResponseElementCollection.cs | 113 ------- .../Model/Undo Demo/UndoDemoElement.cs | 276 ------------------ .../Undo Demo/UndoDemoElementCollection.cs | 187 ------------ .../UI/ElementDocumentControl.xaml | 12 - .../UI/ElementDocumentControl.xaml.cs | 44 --- .../UI/ElementPropertiesControl.xaml | 15 - .../UI/ElementPropertiesControl.xaml.cs | 44 --- src/FrameworkUI.Demo/UI/ThemeDemoControl.xaml | 267 ----------------- .../UI/ThemeDemoControl.xaml.cs | 200 ------------- src/FrameworkUI.Demo/UI/UndoDemoControl.xaml | 78 ----- .../UI/UndoDemoControl.xaml.cs | 259 ---------------- 15 files changed, 7 insertions(+), 1883 deletions(-) delete mode 100644 src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElement.cs delete mode 100644 src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElementCollection.cs delete mode 100644 src/FrameworkUI.Demo/Model/Response Elements/ResponseElement.cs delete mode 100644 src/FrameworkUI.Demo/Model/Response Elements/ResponseElementCollection.cs delete mode 100644 src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElement.cs delete mode 100644 src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElementCollection.cs delete mode 100644 src/FrameworkUI.Demo/UI/ElementDocumentControl.xaml delete mode 100644 src/FrameworkUI.Demo/UI/ElementDocumentControl.xaml.cs delete mode 100644 src/FrameworkUI.Demo/UI/ElementPropertiesControl.xaml delete mode 100644 src/FrameworkUI.Demo/UI/ElementPropertiesControl.xaml.cs delete mode 100644 src/FrameworkUI.Demo/UI/ThemeDemoControl.xaml delete mode 100644 src/FrameworkUI.Demo/UI/ThemeDemoControl.xaml.cs delete mode 100644 src/FrameworkUI.Demo/UI/UndoDemoControl.xaml delete mode 100644 src/FrameworkUI.Demo/UI/UndoDemoControl.xaml.cs diff --git a/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElement.cs b/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElement.cs deleted file mode 100644 index 93d77c52..00000000 --- a/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElement.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using FrameworkInterfaces; - -namespace FrameworkUI.Demo -{ - /// - /// Represents a consequence element in the demo project. - /// - /// - /// - /// Authors: - /// - /// - /// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil - /// - /// - /// Woodrow Fields, USACE Risk Management Center, woodrow.l.fields@usace.army.mil - /// - /// - /// - /// - internal class ConsequenceElement : ElementBase - { - /// - /// Initializes a new instance of the class. - /// - /// The name of the consequence element. - /// The parent collection that contains this element. - public ConsequenceElement(string name, IElementCollection parentCollection) : base(name, parentCollection) - { - Name = name; - _description = "Consequence Element"; - _creationDate = DateTime.Now; - _lastModified = _creationDate; - SetIsDirty(false); - } - - /// - /// Gets or sets the name of the consequence element. - /// - public override string Name { get; set; } - - /// - /// Gets or sets the description of the consequence element. - /// - public override string Description { get => _description; set => _description = value; } - - /// - /// Gets the creation date of the consequence element. - /// - public override DateTime CreationDate => _creationDate; - - /// - /// Gets the last modified date of the consequence element. - /// - public override DateTime LastModified => _lastModified; - - /// - /// Gets the name used when saving the element to disk. - /// - public override string NameOnDisk => "Consequence Element"; - - /// - /// Gets the image icon representing the element. - /// - private static readonly Lazy s_icon = new(() => { var img = new BitmapImage(new Uri("pack://application:,,,/FrameworkUI.Demo;component/Resources/Hazard_Icon.png")); img.Freeze(); return img; }); - public override ImageSource ElementImage => s_icon.Value; - - /// - /// Gets a value indicating whether this element can be copied from an external project. - /// - public override bool CanCopyFromExternal => true; - - /// - /// Gets a value indicating whether the element is valid. - /// - public override bool IsValid { get => true; } - - /// - /// Creates a copy of the consequence element. - /// - /// The name for the copied element. If null, a default name will be used. - /// A copy of the element, or null if copying is not implemented. - public override IElement Copy(string newName = null) - { - //throw new NotImplementedException(); - return null; - } - - /// - /// Copies an element from an external project file. - /// - /// The name of the item to copy. - /// The full path to the external file. - /// A copy of the external element, or null if not implemented. - public override IElement CopyFromExternal(string itemName, string fullFileName) - { - //throw new NotImplementedException(); - return null; - } - - /// - /// Deletes the consequence element. - /// - public override void Delete() - { - //throw new NotImplementedException(); - } - - - /// - /// Opens the consequence element for editing. - /// - public override void Open() - { - //throw new NotImplementedException(); - } - - /// - /// Saves the consequence element to disk. - /// - public override void Save() - { - //throw new NotImplementedException(); - } - } -} diff --git a/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElementCollection.cs b/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElementCollection.cs deleted file mode 100644 index 86d65e88..00000000 --- a/src/FrameworkUI.Demo/Model/Consequence Elements/ConsequenceElementCollection.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using FrameworkInterfaces; - -namespace FrameworkUI.Demo -{ - /// - /// Collection of consequence function elements for the demo project. - /// - /// - /// - /// Authors: - /// - /// - /// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil - /// - /// - /// Woodrow Fields, USACE Risk Management Center, woodrow.l.fields@usace.army.mil - /// - /// - /// - /// - internal class ConsequenceElementCollection : ElementCollectionBase - { - - /// - /// Initializes a new instance of the class. - /// - /// The parent project that contains this collection. - public ConsequenceElementCollection(IProject parentProject) : base(parentProject) - { - } - - /// - /// Gets the name of the collection. - /// - public override string Name - { - get - { - return "Consequence Functions"; - } - } - - /// - /// Opens the collection and loads elements from disk. - /// - public override void Open() - { - _opening = true; - // read from disk - _opening = false; - } - - /// - /// Adds a consequence element to the collection. - /// - /// The element to add to the collection. - public override void Add(IElement item) - { - item.Deleted += ElementDeleted; - //item.AddMessage += RaiseAddMessage; - //item.RemoveMessage += RaiseRemoveMessage; - ElementList.Add((ConsequenceElement)item); - // Save to disk - if (_opening == false) - { - //item.IsValid(); - SetIsDirty(true); - } - RaiseElementAddedEvent(item); - } - - /// - /// Inserts a consequence element at the specified index in the collection. - /// - /// The zero-based index at which the element should be inserted. - /// The element to insert. - public override void Insert(int index, IElement item) - { - item.Deleted += ElementDeleted; - //item.AddMessage += RaiseAddMessage; - //item.RemoveMessage += RaiseRemoveMessage; - ElementList.Insert(index, (ConsequenceElement)item); - // save to disk - SetIsDirty(true); - RaiseElementAddedEvent(item); - } - - /// - /// Deletes the collection from disk. - /// - public override void Delete() - { - // Delete from disk - } - - /// - /// Inserts an element from an external project at the specified index. - /// - /// The zero-based index at which the element should be inserted. - /// The name of the element to insert. - /// The type of the element. - /// The full path to the external project file. - public override void InsertFromExternalProject(int index, string elementName, string elementType, string fullFileName) - { - throw new System.NotImplementedException(); - } - } -} diff --git a/src/FrameworkUI.Demo/Model/DemoProject.cs b/src/FrameworkUI.Demo/Model/DemoProject.cs index cfb002fd..227a48d2 100644 --- a/src/FrameworkUI.Demo/Model/DemoProject.cs +++ b/src/FrameworkUI.Demo/Model/DemoProject.cs @@ -32,7 +32,7 @@ namespace FrameworkUI.Demo /// [Category("Project")] [DisplayName("Demo Project")] - [Description("The Demo project includes hazard, response, and consequence input functions.")] + [Description("The Demo project showcases a fully implemented hazard function element.")] [Browsable(true)] public class DemoProject : ProjectBase { @@ -51,15 +51,11 @@ private DemoProject() InitializeMessages(); _hazardFunctions = new HazardElementCollection(this); - _responseFunctions = new ResponseElementCollection(this); - _consequenceFunctions = new ConsequenceElementCollection(this); _hazardFunctions.ObjectSaved += ElementCollection_Saved; - _responseFunctions.ObjectSaved += ElementCollection_Saved; - _consequenceFunctions.ObjectSaved += ElementCollection_Saved; - _readOnlyElementCollections = new ReadOnlyCollection(new IElementCollection[] - { _hazardFunctions, _responseFunctions, _consequenceFunctions}); + _readOnlyElementCollections = new ReadOnlyCollection(new IElementCollection[] + { _hazardFunctions }); } /// @@ -101,8 +97,6 @@ private void InitializeMessages() private static readonly char[] _InvalidNameCharacters = new List(Path.GetInvalidFileNameChars()) { '\'', '[', ']' }.ToArray(); private HazardElementCollection _hazardFunctions; - private ResponseElementCollection _responseFunctions; - private ConsequenceElementCollection _consequenceFunctions; private bool _nameValid = false; private List _messages = new List(); private Messenger _messenger = Messenger.GetInstance(); @@ -233,7 +227,7 @@ public override void CreateNew(string fullFileName) // Load element collections. _readOnlyElementCollections = new ReadOnlyCollection(new IElementCollection[] - { _hazardFunctions, _responseFunctions, _consequenceFunctions}); + { _hazardFunctions }); Save(); } @@ -252,7 +246,7 @@ public void CreateNewDummyProject() // Load element collections. _readOnlyElementCollections = new ReadOnlyCollection(new IElementCollection[] - { _hazardFunctions, _responseFunctions, _consequenceFunctions}); + { _hazardFunctions }); Save(); } @@ -270,12 +264,10 @@ public override void Open() // Open element collections. _hazardFunctions.Open(); - _responseFunctions.Open(); - _consequenceFunctions.Open(); // Load element collections. _readOnlyElementCollections = new ReadOnlyCollection(new IElementCollection[] - { _hazardFunctions, _responseFunctions, _consequenceFunctions}); + { _hazardFunctions }); NameOnDisk = Name; IsUndoEnabled = true; @@ -289,10 +281,8 @@ public override void Close() { _messenger.Clear(this); - // Close all project element collections.. + // Close all project element collections. _hazardFunctions.Clear(); - _responseFunctions.Clear(); - _consequenceFunctions.Clear(); } /// diff --git a/src/FrameworkUI.Demo/Model/Response Elements/ResponseElement.cs b/src/FrameworkUI.Demo/Model/Response Elements/ResponseElement.cs deleted file mode 100644 index 7f8f0b17..00000000 --- a/src/FrameworkUI.Demo/Model/Response Elements/ResponseElement.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using FrameworkInterfaces; - -namespace FrameworkUI.Demo -{ - /// - /// Represents a response element in the demo project. - /// - /// - /// - /// Authors: - /// - /// - /// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil - /// - /// - /// Woodrow Fields, USACE Risk Management Center, woodrow.l.fields@usace.army.mil - /// - /// - /// - /// - internal class ResponseElement : ElementBase - { - /// - /// Initializes a new instance of the class. - /// - /// The name of the response element. - /// The parent collection that contains this element. - public ResponseElement(string name, IElementCollection parentCollection) : base(name, parentCollection) - { - Name = name; - _description = "Response Element"; - _creationDate = DateTime.Now; - _lastModified = _creationDate; - SetIsDirty(false); - } - - /// - /// Gets or sets the name of the response element. - /// - public override string Name { get; set; } - - /// - /// Gets or sets the description of the response element. - /// - public override string Description { get => _description; set => _description = value; } - - /// - /// Gets the creation date of the response element. - /// - public override DateTime CreationDate => _creationDate; - - /// - /// Gets the last modified date of the response element. - /// - public override DateTime LastModified => _lastModified; - - /// - /// Gets the name used when saving the element to disk. - /// - public override string NameOnDisk => "Response Element"; - - /// - /// Gets the image icon representing the element. - /// - private static readonly Lazy s_icon = new(() => { var img = new BitmapImage(new Uri("pack://application:,,,/FrameworkUI.Demo;component/Resources/Hazard_Icon.png")); img.Freeze(); return img; }); - public override ImageSource ElementImage => s_icon.Value; - - /// - /// Gets a value indicating whether this element can be copied from an external project. - /// - public override bool CanCopyFromExternal => true; - - /// - /// Gets a value indicating whether the element is valid. - /// - public override bool IsValid { get => true; } - - /// - /// Creates a copy of the response element. - /// - /// The name for the copied element. If null, a default name will be used. - /// A copy of the element, or null if copying is not implemented. - public override IElement Copy(string newName = null) - { - //throw new NotImplementedException(); - return null; - } - - /// - /// Copies an element from an external project file. - /// - /// The name of the item to copy. - /// The full path to the external file. - /// A copy of the external element, or null if not implemented. - public override IElement CopyFromExternal(string itemName, string fullFileName) - { - //throw new NotImplementedException(); - return null; - } - - /// - /// Deletes the response element. - /// - public override void Delete() - { - //throw new NotImplementedException(); - } - - - /// - /// Opens the response element for editing. - /// - public override void Open() - { - //throw new NotImplementedException(); - } - - /// - /// Saves the response element to disk. - /// - public override void Save() - { - //throw new NotImplementedException(); - } - } -} diff --git a/src/FrameworkUI.Demo/Model/Response Elements/ResponseElementCollection.cs b/src/FrameworkUI.Demo/Model/Response Elements/ResponseElementCollection.cs deleted file mode 100644 index 6863aaf7..00000000 --- a/src/FrameworkUI.Demo/Model/Response Elements/ResponseElementCollection.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using FrameworkInterfaces; - -namespace FrameworkUI.Demo -{ - /// - /// Collection of response function elements for the demo project. - /// - /// - /// - /// Authors: - /// - /// - /// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil - /// - /// - /// Woodrow Fields, USACE Risk Management Center, woodrow.l.fields@usace.army.mil - /// - /// - /// - /// - internal class ResponseElementCollection : ElementCollectionBase - { - - /// - /// Initializes a new instance of the class. - /// - /// The parent project that contains this collection. - public ResponseElementCollection(IProject parentProject) : base(parentProject) - { - } - - /// - /// Gets the name of the collection. - /// - public override string Name - { - get - { - return "Response Functions"; - } - } - - /// - /// Opens the collection and loads elements from disk. - /// - public override void Open() - { - _opening = true; - // read from disk - _opening = false; - } - - /// - /// Adds a response element to the collection. - /// - /// The element to add to the collection. - public override void Add(IElement item) - { - item.Deleted += ElementDeleted; - //item.AddMessage += RaiseAddMessage; - //item.RemoveMessage += RaiseRemoveMessage; - ElementList.Add((ResponseElement)item); - // Save to disk - if (_opening == false) - { - //item.IsValid(); - SetIsDirty(true); - } - RaiseElementAddedEvent(item); - } - - /// - /// Inserts a response element at the specified index in the collection. - /// - /// The zero-based index at which the element should be inserted. - /// The element to insert. - public override void Insert(int index, IElement item) - { - item.Deleted += ElementDeleted; - //item.AddMessage += RaiseAddMessage; - //item.RemoveMessage += RaiseRemoveMessage; - ElementList.Insert(index, (ResponseElement)item); - // save to disk - SetIsDirty(true); - RaiseElementAddedEvent(item); - } - - /// - /// Deletes the collection from disk. - /// - public override void Delete() - { - // Delete from disk - } - - /// - /// Inserts an element from an external project at the specified index. - /// - /// The zero-based index at which the element should be inserted. - /// The name of the element to insert. - /// The type of the element. - /// The full path to the external project file. - public override void InsertFromExternalProject(int index, string elementName, string elementType, string fullFileName) - { - throw new System.NotImplementedException(); - } - } -} diff --git a/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElement.cs b/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElement.cs deleted file mode 100644 index 25ccb24b..00000000 --- a/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElement.cs +++ /dev/null @@ -1,276 +0,0 @@ -using FrameworkInterfaces; -using FrameworkInterfaces.Undo; -using System; -using System.Windows.Media; -using System.Windows.Media.Imaging; - -namespace FrameworkUI.Demo -{ - /// - /// A demo element that showcases the undo/redo functionality. This element demonstrates how to use RecordPropertyChange for undo support. - /// - /// - /// - /// Authors: - /// - /// - /// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil - /// - /// - /// Woodrow Fields, USACE Risk Management Center, woodrow.l.fields@usace.army.mil - /// - /// - /// - /// - public class UndoDemoElement : ElementBase, IUndoableElement - { - private string _customValue = "Initial Value"; - private int _numericValue = 0; - private bool _booleanValue = false; - private DateTime _dateValue = DateTime.Today; - - /// - /// Initializes a new instance of the class. - /// - /// The name of the element. - /// The parent collection that contains this element. - public UndoDemoElement(string name, IElementCollection parentCollection) : base(name, parentCollection) - { - Name = name; - SetIsDirty(false); - } - - #region Properties with Undo Support - - /// - /// Gets or sets the name of the element with undo support. - /// - public override string Name - { - get => NameField; - set - { - if (NameField != value) - { - var oldValue = NameField; - NameField = value; - RecordPropertyChange(nameof(Name), oldValue, value); - } - } - } - - /// - /// Gets or sets the description with undo support. - /// - public override string Description - { - get => _description ?? "Undo Demo Element"; - set - { - if (_description != value) - { - var oldValue = _description; - _description = value; - RecordPropertyChange(nameof(Description), oldValue, value); - } - } - } - - /// - /// Gets or sets a custom string value with undo support. - /// - public string CustomValue - { - get => _customValue; - set - { - if (_customValue != value) - { - var oldValue = _customValue; - _customValue = value; - RecordPropertyChange(nameof(CustomValue), oldValue, value); - } - } - } - - /// - /// Gets or sets a numeric value with undo support. - /// - public int NumericValue - { - get => _numericValue; - set - { - if (_numericValue != value) - { - var oldValue = _numericValue; - _numericValue = value; - RecordPropertyChange(nameof(NumericValue), oldValue, value); - } - } - } - - /// - /// Gets or sets a boolean value with undo support. - /// - public bool BooleanValue - { - get => _booleanValue; - set - { - if (_booleanValue != value) - { - var oldValue = _booleanValue; - _booleanValue = value; - RecordPropertyChange(nameof(BooleanValue), oldValue, value); - } - } - } - - /// - /// Gets or sets a date value with undo support. - /// - public DateTime DateValue - { - get => _dateValue; - set - { - if (_dateValue != value) - { - var oldValue = _dateValue; - _dateValue = value; - RecordPropertyChange(nameof(DateValue), oldValue, value); - } - } - } - - #endregion - - #region Required Abstract Properties - - /// - /// Gets the creation date of the element. - /// - public override DateTime CreationDate => _creationDate; - - /// - /// Gets the last modified date of the element. - /// - public override DateTime LastModified => _lastModified; - - /// - /// Gets the name used when saving the element to disk. - /// - public override string NameOnDisk => Name; - - /// - /// Gets the image icon representing the element. - /// - private static readonly Lazy s_icon = new(() => { var img = new BitmapImage(new Uri("pack://application:,,,/FrameworkUI.Demo;component/Resources/Hazard_Icon.png")); img.Freeze(); return img; }); - /// - public override ImageSource ElementImage => s_icon.Value; - - /// - /// Gets a value indicating whether this element can be copied from an external project. - /// - public override bool CanCopyFromExternal => false; - - /// - /// Gets a value indicating whether the element is valid. - /// - public override bool IsValid => true; - - #endregion - - #region Required Abstract Methods - - /// - /// Creates a copy of the element. - /// - /// The name for the copied element. If null, a default name will be generated. - /// A copy of the element. - public override IElement Copy(string newName = null) - { - var copy = new UndoDemoElement(newName ?? $"{Name}_Copy", ParentCollection); - copy.CustomValue = this.CustomValue; - copy.NumericValue = this.NumericValue; - copy.BooleanValue = this.BooleanValue; - copy.DateValue = this.DateValue; - copy.Description = this.Description; - return copy; - } - - /// - /// Copies an element from an external project file. - /// - /// The name of the item to copy. - /// The full path to the external file. - /// Null, as external copying is not supported for this element type. - public override IElement CopyFromExternal(string itemName, string fullFileName) - { - return null; - } - - /// - /// Deletes the element and raises the appropriate events. - /// - public override void Delete() - { - bool cancel = false; - RaisePreviewDeleted(this, ref cancel); - if (!cancel) - { - RaiseDeleted(this); - } - } - - /// - /// Opens the element and loads its data from disk. Clears the undo history after loading. - /// - public override void Open() - { - // Simulate loading from disk - IsUndoEnabled = false; - // ... load data ... - IsUndoEnabled = true; - ClearUndoHistory(); - SetIsDirty(false); - } - - /// - /// Saves the element to disk and marks the current state as the undo save point. - /// - public override void Save() - { - bool cancel = false; - RaisePreviewObjectSaved(this, ref cancel); - if (!cancel) - { - // Simulate saving to disk - // ... save data ... - MarkUndoSavePoint(); - SetIsDirty(false); - RaiseObjectSaved(this); - } - } - - #endregion - - /// - /// Performs a batch update using a transaction. All changes within the transaction can be undone with a single Undo. - /// - /// The new custom string value. - /// The new numeric value. - /// The new boolean value. - public void PerformBatchUpdate(string newCustomValue, int newNumericValue, bool newBooleanValue) - { - // Using statement ensures transaction is committed when disposed - using (UndoManager.BeginTransaction("Batch Update")) - { - CustomValue = newCustomValue; - NumericValue = newNumericValue; - BooleanValue = newBooleanValue; - } - } - } -} diff --git a/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElementCollection.cs b/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElementCollection.cs deleted file mode 100644 index 74b46537..00000000 --- a/src/FrameworkUI.Demo/Model/Undo Demo/UndoDemoElementCollection.cs +++ /dev/null @@ -1,187 +0,0 @@ -using FrameworkInterfaces; - -namespace FrameworkUI.Demo -{ - /// - /// A demo element collection that showcases the undo/redo functionality for collection operations. This collection demonstrates how to use RecordAddElement and RecordRemoveElement for undo support. - /// - /// - /// - /// Authors: - /// - /// - /// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil - /// - /// - /// Woodrow Fields, USACE Risk Management Center, woodrow.l.fields@usace.army.mil - /// - /// - /// - /// - public class UndoDemoElementCollection : ElementCollectionBase - { - /// - /// Initializes a new instance of the class and adds initial demo elements. - /// - /// The parent project that contains this collection. - public UndoDemoElementCollection(IProject parentProject) : base(parentProject) - { - // Add some initial demo elements - Add(new UndoDemoElement("Demo Element 1", this)); - Add(new UndoDemoElement("Demo Element 2", this)); - Add(new UndoDemoElement("Demo Element 3", this)); - - // Mark as clean after initialization - SetIsDirty(false); - } - - /// - /// Gets the name of the collection. - /// - public override string Name => "Undo Demo Elements"; - - /// - /// Opens the collection and loads elements from disk. Clears the undo history after loading. - /// - public override void Open() - { - _opening = true; - // Simulate reading from disk - // ... - _opening = false; - ClearUndoHistory(); - SetIsDirty(false); - } - - /// - /// Adds an element to the collection with undo support. - /// - public override void Add(IElement item) - { - item.Deleted += ElementDeleted; - ElementList.Add((UndoDemoElement)item); - - // Record the add action for undo support (only if not opening) - if (!_opening) - { - RecordAddElement(item); - SetIsDirty(true); - } - - RaiseElementAddedEvent(item); - } - - /// - /// Inserts an element at the specified index with undo support. - /// - public override void Insert(int index, IElement item) - { - item.Deleted += ElementDeleted; - ElementList.Insert(index, (UndoDemoElement)item); - - // Record the add action for undo support - RecordAddElement(item, index); - SetIsDirty(true); - - RaiseElementAddedEvent(item); - } - - /// - /// Removes an element from the collection with undo support. - /// - public override bool Remove(IElement item) - { - if (item == null) return false; - - int index = ElementList.IndexOf((UndoDemoElement)item); - if (index < 0) return false; - - // Record the remove action for undo support before actually removing - RecordRemoveElement(item); - - item.Deleted -= ElementDeleted; - ElementList.Remove((UndoDemoElement)item); - SetIsDirty(true); - - RaiseElementRemoved(item); - return true; - } - - /// - /// Removes the element at the specified index with undo support. - /// - public override void RemoveAt(int index) - { - if (index < 0 || index >= ElementList.Count) return; - - var item = ElementList[index]; - - // Record the remove action for undo support - RecordRemoveElement(item); - - item.Deleted -= ElementDeleted; - ElementList.RemoveAt(index); - SetIsDirty(true); - - RaiseElementRemoved(item); - } - - /// - /// Moves an element within the collection with undo support. - /// - /// The current index of the element. - /// The new index where the element should be moved. - public void MoveElement(int oldIndex, int newIndex) - { - if (oldIndex < 0 || oldIndex >= ElementList.Count) return; - if (newIndex < 0 || newIndex >= ElementList.Count) return; - if (oldIndex == newIndex) return; - - var item = ElementList[oldIndex]; - - // Record the move action for undo support - RecordMoveElement(item, oldIndex, newIndex); - - ElementList.RemoveAt(oldIndex); - ElementList.Insert(newIndex, (UndoDemoElement)item); - SetIsDirty(true); - } - - /// - /// Deletes the collection and all its elements. - /// - public override void Delete() - { - // Clear all elements - foreach (var element in ElementList) - { - element.Delete(); - } - ElementList.Clear(); - } - - /// - /// Inserts an element from an external project at the specified index. - /// - /// The zero-based index at which the element should be inserted. - /// The name of the element to insert. - /// The type of the element. - /// The full path to the external project file. - public override void InsertFromExternalProject(int index, string elementName, string elementType, string fullFileName) - { - Insert(index, new UndoDemoElement(elementName, this)); - } - - /// - /// Creates a new demo element with undo support and adds it to the collection. - /// - /// The name of the new element. - /// The newly created element. - public UndoDemoElement CreateNewElement(string name) - { - var element = new UndoDemoElement(name, this); - Add(element); - return element; - } - } -} diff --git a/src/FrameworkUI.Demo/UI/ElementDocumentControl.xaml b/src/FrameworkUI.Demo/UI/ElementDocumentControl.xaml deleted file mode 100644 index d7fdd16d..00000000 --- a/src/FrameworkUI.Demo/UI/ElementDocumentControl.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - I am a document control - - diff --git a/src/FrameworkUI.Demo/UI/ElementDocumentControl.xaml.cs b/src/FrameworkUI.Demo/UI/ElementDocumentControl.xaml.cs deleted file mode 100644 index a575de5c..00000000 --- a/src/FrameworkUI.Demo/UI/ElementDocumentControl.xaml.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace FrameworkUI.Demo.UI -{ - /// - /// User control for displaying element documents in the main window. - /// - /// - /// - /// Authors: - /// - /// - /// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil - /// - /// - /// Woodrow Fields, USACE Risk Management Center, woodrow.l.fields@usace.army.mil - /// - /// - /// - /// - public partial class ElementDocumentControl : UserControl - { - /// - /// Initializes a new instance of the class. - /// - public ElementDocumentControl() - { - InitializeComponent(); - } - } -} diff --git a/src/FrameworkUI.Demo/UI/ElementPropertiesControl.xaml b/src/FrameworkUI.Demo/UI/ElementPropertiesControl.xaml deleted file mode 100644 index b20d8162..00000000 --- a/src/FrameworkUI.Demo/UI/ElementPropertiesControl.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - Prop 1 - Prop 2 - - - diff --git a/src/FrameworkUI.Demo/UI/ElementPropertiesControl.xaml.cs b/src/FrameworkUI.Demo/UI/ElementPropertiesControl.xaml.cs deleted file mode 100644 index d332dec3..00000000 --- a/src/FrameworkUI.Demo/UI/ElementPropertiesControl.xaml.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace FrameworkUI.Demo.UI -{ - /// - /// User control for displaying and editing element properties. - /// - /// - /// - /// Authors: - /// - /// - /// Haden Smith, USACE Risk Management Center, cole.h.smith@usace.army.mil - /// - /// - /// Woodrow Fields, USACE Risk Management Center, woodrow.l.fields@usace.army.mil - /// - /// - /// - /// - public partial class ElementPropertiesControl : UserControl - { - /// - /// Initializes a new instance of the class. - /// - public ElementPropertiesControl() - { - InitializeComponent(); - } - } -} diff --git a/src/FrameworkUI.Demo/UI/ThemeDemoControl.xaml b/src/FrameworkUI.Demo/UI/ThemeDemoControl.xaml deleted file mode 100644 index 8183483f..00000000 --- a/src/FrameworkUI.Demo/UI/ThemeDemoControl.xaml +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -