adjusted project structure

This commit is contained in:
NaBian committed 2021-09-05 13:26:48 +08:00
1 parent aa7310d495
commit 904b32f986
18 files changed
+79 -212

No files matched your search

@@ -901,8 +901,8 @@
<Resource Include="..\..\Shared\HandyControlDemo_Shared\ViewModel\Controls\WindowDemoViewModel.cs">
<Link>ViewModel\WindowDemoViewModel.cs</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\ViewModel\DemoViewModelBase!1.cs">
<Link>ViewModel\DemoViewModelBase!1.cs</Link>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\ViewModel\DemoViewModelBase`1.cs">
<Link>ViewModel\DemoViewModelBase`1.cs</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\ViewModel\Main\ItemsDisplayViewModel.cs">
<Link>ViewModel\ItemsDisplayViewModel.cs</Link>
@@ -425,7 +425,7 @@
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\TabControlDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\TagDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Controls\WindowDemoViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\DemoViewModelBase!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\DemoViewModelBase`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Main\ItemsDisplayViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Main\MainViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Main\NonClientAreaViewModel.cs" />
@@ -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<T> : Collection<T>, 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<T> list) : base(list != null ? new List<T>(list.Count) : list) => CopyFrom(list);
public ManualObservableCollection(IEnumerable<T> collection)
{
if (collection == null) throw new ArgumentNullException(nameof(collection));
CopyFrom(collection);
}
private void CopyFrom(IEnumerable<T> 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;
}
}
}
@@ -0,0 +1,58 @@
using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
namespace HandyControl.Collections
{
[Serializable]
public class ManualObservableCollection<T> : ObservableCollection<T>
{
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);
}
}
}
@@ -1,4 +1,4 @@
namespace HandyControl.Tools
namespace HandyControl.Collections
{
public interface IPool<T>
{
@@ -2,7 +2,7 @@
using System;
namespace HandyControl.Tools
namespace HandyControl.Collections
{
public class SimplePool<T> : IPool<T>
{
@@ -1,4 +1,4 @@
namespace HandyControl.Tools
namespace HandyControl.Collections
{
public class SynchronizedPool<T> : SimplePool<T>
{
@@ -5,7 +5,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Threading;
namespace HandyControl.Tools
namespace HandyControl.Collections
{
[Serializable]
public class Deque<T> : IEnumerable<T>, ICollection
@@ -9,7 +9,7 @@
<Import_RootNamespace>HandyControl</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Collections\ManualObservableCollection!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Collections\ManualObservableCollection`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\BackgroundSwitchElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\BorderElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\DataGridAttach.cs" />
@@ -83,7 +83,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\Tag\TagContainer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Text\SimpleText.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Window\GlowWindow.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Collections\DateTimeRangeComparer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Generator\DateTimeRangeComparer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\VisualWrapping.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Flex\FlexContentJustify.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Flex\FlexContentAlignment.cs" />
@@ -242,7 +242,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\Window\PopupWindow.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Window\Window.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Args\CancelRoutedEventArgs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Args\FunctionEventArgs!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Args\FunctionEventArgs`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Args\KeyboardHookEventArgs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Args\MouseHookEventArgs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Range\ColorRange.cs" />
@@ -269,7 +269,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Data\HandyControlConfig.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Info\MessageBoxInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\MouseHookMessageType.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Operation\OperationResult!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Operation\OperationResult`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Operation\OperationResult.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\ResourceToken.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Info\SystemVersionInfo.cs" />
@@ -295,7 +295,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Expression\Media\DrawingPropertyMetadataOptions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Expression\Media\GeometryEffect.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Expression\Media\GeometryEffectConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Expression\Media\GeometrySource!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Expression\Media\GeometrySource`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Expression\Media\IArcGeometrySourceParameters.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Expression\Media\IGeometrySource.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Expression\Media\IGeometrySourceExtensions.cs" />
@@ -307,15 +307,15 @@
<Compile Include="$(MSBuildThisFileDirectory)Expression\Shapes\Arc.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Expression\Shapes\PrimitiveShape.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\AdornerContainer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\AttachableCollection!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Behavior\Behavior!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\AttachableCollection`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Behavior\Behavior`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Behavior\Behavior.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Behavior\BehaviorCollection.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\ControlCommands.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\DefaultTriggerAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\EventToCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\EventTrigger.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\EventTriggerBase!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\EventTriggerBase`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\EventTriggerBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\ExceptionStringTable.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\ExtendedVisualStateManager.cs" />
@@ -335,7 +335,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\ShutdownAppCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\TagType.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\TransitionEffect.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\TriggerAction!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\TriggerAction`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\TriggerAction.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\TriggerActionCollection.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\TriggerBase.cs" />
@@ -397,10 +397,10 @@
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\Handle\SafeFileMappingHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\Handle\WpfSafeHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Behavior\MouseDragElementBehaviorEx.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Pool\IPool!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Pool\SimplePool!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Pool\SynchronizedPool!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Queue\Deque!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Collections\Pool\IPool`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Collections\Pool\SimplePool`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Collections\Pool\SynchronizedPool`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Collections\Queue\Deque`1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\RegexJudgment.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\RegexPatterns.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\StyleSelector\ButtonGroupItemStyleSelector.cs" />
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using HandyControl.Data;
namespace HandyControl.Collections
namespace HandyControl.Tools
{
public class DateTimeRangeComparer : IComparer<DateTimeRange>
{