diff --git a/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj b/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj index d735ac7c..d3d99dea 100644 --- a/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj +++ b/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj @@ -901,8 +901,8 @@ ViewModel\WindowDemoViewModel.cs - - ViewModel\DemoViewModelBase!1.cs + + ViewModel\DemoViewModelBase`1.cs ViewModel\ItemsDisplayViewModel.cs diff --git a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems index 9ac8cea4..70321550 100644 --- a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems +++ b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems @@ -425,7 +425,7 @@ - + diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/DemoViewModelBase!1.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/DemoViewModelBase`1.cs similarity index 100% rename from src/Shared/HandyControlDemo_Shared/ViewModel/DemoViewModelBase!1.cs rename to src/Shared/HandyControlDemo_Shared/ViewModel/DemoViewModelBase`1.cs diff --git a/src/Shared/HandyControl_Shared/Collections/ManualObservableCollection!1.cs b/src/Shared/HandyControl_Shared/Collections/ManualObservableCollection!1.cs deleted file mode 100644 index e6bfcb77..00000000 --- a/src/Shared/HandyControl_Shared/Collections/ManualObservableCollection!1.cs +++ /dev/null @@ -1,191 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Collections.Specialized; -using System.ComponentModel; - -namespace HandyControl.Collections -{ - [Serializable] - public class ManualObservableCollection : Collection, INotifyCollectionChanged, INotifyPropertyChanged - { - private readonly SimpleMonitor _monitor = new(); - - private const string CountString = "Count"; - - private const string IndexerName = "Item[]"; - - private bool _canNotify = true; - - public bool CanNotify - { - get => _canNotify; - set - { - _canNotify = value; - - if (value) - { - if (_oldCount != Count) - { - OnPropertyChanged(CountString); - } - - OnPropertyChanged(IndexerName); - OnCollectionReset(); - } - else - { - _oldCount = Count; - } - } - } - - private int _oldCount; - - public event NotifyCollectionChangedEventHandler CollectionChanged; - - public event PropertyChangedEventHandler PropertyChanged; - - public ManualObservableCollection() - { - - } - - // ReSharper disable once AssignNullToNotNullAttribute - public ManualObservableCollection(List list) : base(list != null ? new List(list.Count) : list) => CopyFrom(list); - - public ManualObservableCollection(IEnumerable collection) - { - if (collection == null) throw new ArgumentNullException(nameof(collection)); - CopyFrom(collection); - } - - private void CopyFrom(IEnumerable collection) - { - var items = Items; - if (collection != null) - { - using var enumerator = collection.GetEnumerator(); - while (enumerator.MoveNext()) - { - items.Add(enumerator.Current); - } - } - } - - public void Move(int oldIndex, int newIndex) => MoveItem(oldIndex, newIndex); - - protected override void ClearItems() - { - CheckReentrancy(); - base.ClearItems(); - OnPropertyChanged(CountString); - OnPropertyChanged(IndexerName); - OnCollectionReset(); - } - - protected override void RemoveItem(int index) - { - CheckReentrancy(); - var removedItem = this[index]; - - base.RemoveItem(index); - - OnPropertyChanged(CountString); - OnPropertyChanged(IndexerName); - OnCollectionChanged(NotifyCollectionChangedAction.Remove, removedItem, index); - } - - protected override void InsertItem(int index, T item) - { - CheckReentrancy(); - base.InsertItem(index, item); - - OnPropertyChanged(CountString); - OnPropertyChanged(IndexerName); - OnCollectionChanged(NotifyCollectionChangedAction.Add, item, index); - } - - protected override void SetItem(int index, T item) - { - CheckReentrancy(); - var originalItem = this[index]; - base.SetItem(index, item); - - OnPropertyChanged(IndexerName); - OnCollectionChanged(NotifyCollectionChangedAction.Replace, originalItem, item, index); - } - - protected virtual void MoveItem(int oldIndex, int newIndex) - { - CheckReentrancy(); - - var removedItem = this[oldIndex]; - - base.RemoveItem(oldIndex); - base.InsertItem(newIndex, removedItem); - - OnPropertyChanged(IndexerName); - OnCollectionChanged(NotifyCollectionChangedAction.Move, removedItem, newIndex, oldIndex); - } - - protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) - { - if (!CanNotify || PropertyChanged == null) return; - - PropertyChanged.Invoke(this, e); - } - - protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e) - { - if (!CanNotify || CollectionChanged == null) return; - - using (BlockReentrancy()) - { - // ReSharper disable once PossibleNullReferenceException - CollectionChanged(this, e); - } - } - - protected IDisposable BlockReentrancy() - { - _monitor.Enter(); - return _monitor; - } - - protected void CheckReentrancy() - { - if (_monitor.Busy && CollectionChanged != null && CollectionChanged.GetInvocationList().Length > 1) - { - throw new InvalidOperationException("ObservableCollectionReentrancyNotAllowed"); - } - } - - private void OnPropertyChanged(string propertyName) => - OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); - - private void OnCollectionChanged(NotifyCollectionChangedAction action, object item, int index) => - OnCollectionChanged(new NotifyCollectionChangedEventArgs(action, item, index)); - - private void OnCollectionChanged(NotifyCollectionChangedAction action, object item, int index, int oldIndex) => - OnCollectionChanged(new NotifyCollectionChangedEventArgs(action, item, index, oldIndex)); - - private void OnCollectionChanged(NotifyCollectionChangedAction action, object oldItem, object newItem, int index) => - OnCollectionChanged(new NotifyCollectionChangedEventArgs(action, newItem, oldItem, index)); - - private void OnCollectionReset() => - OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); - - private class SimpleMonitor : IDisposable - { - public void Enter() => ++_busyCount; - - public void Dispose() => --_busyCount; - - public bool Busy => _busyCount > 0; - - private int _busyCount; - } - } -} diff --git a/src/Shared/HandyControl_Shared/Collections/ManualObservableCollection`1.cs b/src/Shared/HandyControl_Shared/Collections/ManualObservableCollection`1.cs new file mode 100644 index 00000000..645687e0 --- /dev/null +++ b/src/Shared/HandyControl_Shared/Collections/ManualObservableCollection`1.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.ComponentModel; + +namespace HandyControl.Collections +{ + [Serializable] + public class ManualObservableCollection : ObservableCollection + { + private const string CountString = "Count"; + + private const string IndexerName = "Item[]"; + + private int _oldCount; + + private bool _canNotify = true; + + public bool CanNotify + { + get => _canNotify; + set + { + _canNotify = value; + + if (value) + { + if (_oldCount != Count) + { + OnPropertyChanged(new PropertyChangedEventArgs(CountString)); + } + + OnPropertyChanged(new PropertyChangedEventArgs(IndexerName)); + OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); + + } + else + { + _oldCount = Count; + } + } + } + + protected override void OnPropertyChanged(PropertyChangedEventArgs e) + { + if (!CanNotify) return; + + base.OnPropertyChanged(e); + } + + protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) + { + if (!CanNotify) return; + + base.OnCollectionChanged(e); + } + } +} diff --git a/src/Shared/HandyControl_Shared/Tools/Pool/IPool!1.cs b/src/Shared/HandyControl_Shared/Collections/Pool/IPool`1.cs similarity index 72% rename from src/Shared/HandyControl_Shared/Tools/Pool/IPool!1.cs rename to src/Shared/HandyControl_Shared/Collections/Pool/IPool`1.cs index 5eeeac75..f3d9f9f6 100644 --- a/src/Shared/HandyControl_Shared/Tools/Pool/IPool!1.cs +++ b/src/Shared/HandyControl_Shared/Collections/Pool/IPool`1.cs @@ -1,4 +1,4 @@ -namespace HandyControl.Tools +namespace HandyControl.Collections { public interface IPool { diff --git a/src/Shared/HandyControl_Shared/Tools/Pool/SimplePool!1.cs b/src/Shared/HandyControl_Shared/Collections/Pool/SimplePool`1.cs similarity index 97% rename from src/Shared/HandyControl_Shared/Tools/Pool/SimplePool!1.cs rename to src/Shared/HandyControl_Shared/Collections/Pool/SimplePool`1.cs index f21a6670..b751b379 100644 --- a/src/Shared/HandyControl_Shared/Tools/Pool/SimplePool!1.cs +++ b/src/Shared/HandyControl_Shared/Collections/Pool/SimplePool`1.cs @@ -2,7 +2,7 @@ using System; -namespace HandyControl.Tools +namespace HandyControl.Collections { public class SimplePool : IPool { diff --git a/src/Shared/HandyControl_Shared/Tools/Pool/SynchronizedPool!1.cs b/src/Shared/HandyControl_Shared/Collections/Pool/SynchronizedPool`1.cs similarity index 93% rename from src/Shared/HandyControl_Shared/Tools/Pool/SynchronizedPool!1.cs rename to src/Shared/HandyControl_Shared/Collections/Pool/SynchronizedPool`1.cs index 196f69f5..39376efb 100644 --- a/src/Shared/HandyControl_Shared/Tools/Pool/SynchronizedPool!1.cs +++ b/src/Shared/HandyControl_Shared/Collections/Pool/SynchronizedPool`1.cs @@ -1,4 +1,4 @@ -namespace HandyControl.Tools +namespace HandyControl.Collections { public class SynchronizedPool : SimplePool { diff --git a/src/Shared/HandyControl_Shared/Tools/Queue/Deque!1.cs b/src/Shared/HandyControl_Shared/Collections/Queue/Deque`1.cs similarity index 99% rename from src/Shared/HandyControl_Shared/Tools/Queue/Deque!1.cs rename to src/Shared/HandyControl_Shared/Collections/Queue/Deque`1.cs index fc5fcf6b..fa179c63 100644 --- a/src/Shared/HandyControl_Shared/Tools/Queue/Deque!1.cs +++ b/src/Shared/HandyControl_Shared/Collections/Queue/Deque`1.cs @@ -5,7 +5,7 @@ using System.Collections; using System.Collections.Generic; using System.Threading; -namespace HandyControl.Tools +namespace HandyControl.Collections { [Serializable] public class Deque : IEnumerable, ICollection diff --git a/src/Shared/HandyControl_Shared/Data/Args/FunctionEventArgs!1.cs b/src/Shared/HandyControl_Shared/Data/Args/FunctionEventArgs`1.cs similarity index 100% rename from src/Shared/HandyControl_Shared/Data/Args/FunctionEventArgs!1.cs rename to src/Shared/HandyControl_Shared/Data/Args/FunctionEventArgs`1.cs diff --git a/src/Shared/HandyControl_Shared/Data/Operation/OperationResult!1.cs b/src/Shared/HandyControl_Shared/Data/Operation/OperationResult`1.cs similarity index 100% rename from src/Shared/HandyControl_Shared/Data/Operation/OperationResult!1.cs rename to src/Shared/HandyControl_Shared/Data/Operation/OperationResult`1.cs diff --git a/src/Shared/HandyControl_Shared/Expression/Media/GeometrySource!1.cs b/src/Shared/HandyControl_Shared/Expression/Media/GeometrySource`1.cs similarity index 100% rename from src/Shared/HandyControl_Shared/Expression/Media/GeometrySource!1.cs rename to src/Shared/HandyControl_Shared/Expression/Media/GeometrySource`1.cs diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems index 7032cb29..b9a816d2 100644 --- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems +++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems @@ -9,7 +9,7 @@ HandyControl - + @@ -83,7 +83,7 @@ - + @@ -242,7 +242,7 @@ - + @@ -269,7 +269,7 @@ - + @@ -295,7 +295,7 @@ - + @@ -307,15 +307,15 @@ - - + + - + @@ -335,7 +335,7 @@ - + @@ -397,10 +397,10 @@ - - - - + + + + diff --git a/src/Shared/HandyControl_Shared/Interactivity/AttachableCollection!1.cs b/src/Shared/HandyControl_Shared/Interactivity/AttachableCollection`1.cs similarity index 100% rename from src/Shared/HandyControl_Shared/Interactivity/AttachableCollection!1.cs rename to src/Shared/HandyControl_Shared/Interactivity/AttachableCollection`1.cs diff --git a/src/Shared/HandyControl_Shared/Interactivity/Behavior/Behavior!1.cs b/src/Shared/HandyControl_Shared/Interactivity/Behavior/Behavior`1.cs similarity index 100% rename from src/Shared/HandyControl_Shared/Interactivity/Behavior/Behavior!1.cs rename to src/Shared/HandyControl_Shared/Interactivity/Behavior/Behavior`1.cs diff --git a/src/Shared/HandyControl_Shared/Interactivity/EventTriggerBase!1.cs b/src/Shared/HandyControl_Shared/Interactivity/EventTriggerBase`1.cs similarity index 100% rename from src/Shared/HandyControl_Shared/Interactivity/EventTriggerBase!1.cs rename to src/Shared/HandyControl_Shared/Interactivity/EventTriggerBase`1.cs diff --git a/src/Shared/HandyControl_Shared/Interactivity/TriggerAction!1.cs b/src/Shared/HandyControl_Shared/Interactivity/TriggerAction`1.cs similarity index 100% rename from src/Shared/HandyControl_Shared/Interactivity/TriggerAction!1.cs rename to src/Shared/HandyControl_Shared/Interactivity/TriggerAction`1.cs diff --git a/src/Shared/HandyControl_Shared/Collections/DateTimeRangeComparer.cs b/src/Shared/HandyControl_Shared/Tools/Generator/DateTimeRangeComparer.cs similarity index 91% rename from src/Shared/HandyControl_Shared/Collections/DateTimeRangeComparer.cs rename to src/Shared/HandyControl_Shared/Tools/Generator/DateTimeRangeComparer.cs index 48e7f2fc..361ce4c0 100644 --- a/src/Shared/HandyControl_Shared/Collections/DateTimeRangeComparer.cs +++ b/src/Shared/HandyControl_Shared/Tools/Generator/DateTimeRangeComparer.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using HandyControl.Data; -namespace HandyControl.Collections +namespace HandyControl.Tools { public class DateTimeRangeComparer : IComparer {