simplify new expression

This commit is contained in:
NaBian committed 2021-06-08 20:35:14 +08:00
1 parent 42b2cb3033
commit 193090da43
59 files changed
+149 -149

No files matched your search

@@ -26,8 +26,8 @@ namespace HandyControlDemo
GlobalShortcut.Init(new List<KeyBinding> GlobalShortcut.Init(new List<KeyBinding>
{ {
new KeyBinding(ViewModelLocator.Instance.Main.GlobalShortcutInfoCmd, Key.I, ModifierKeys.Control | ModifierKeys.Alt), new(ViewModelLocator.Instance.Main.GlobalShortcutInfoCmd, Key.I, ModifierKeys.Control | ModifierKeys.Alt),
new KeyBinding(ViewModelLocator.Instance.Main.GlobalShortcutWarningCmd, Key.E, ModifierKeys.Control | ModifierKeys.Alt) new(ViewModelLocator.Instance.Main.GlobalShortcutWarningCmd, Key.E, ModifierKeys.Control | ModifierKeys.Alt)
}); });
Dialog.SetToken(this, MessageToken.MainWindow); Dialog.SetToken(this, MessageToken.MainWindow);
@@ -18,7 +18,7 @@ namespace HandyControlDemo.Service
{ {
internal ObservableCollection<TabControlDemoModel> GetTabControlDemoDataList() internal ObservableCollection<TabControlDemoModel> GetTabControlDemoDataList()
{ {
return new ObservableCollection<TabControlDemoModel> return new()
{ {
new TabControlDemoModel new TabControlDemoModel
{ {
@@ -139,7 +139,7 @@ namespace HandyControlDemo.Service
internal List<AvatarModel> GetBlogDataList() internal List<AvatarModel> GetBlogDataList()
{ {
return new List<AvatarModel> return new()
{ {
new AvatarModel new AvatarModel
{ {
@@ -170,7 +170,7 @@ namespace HandyControlDemo.Service
internal List<AvatarModel> GetProjectDataList() internal List<AvatarModel> GetProjectDataList()
{ {
return new List<AvatarModel> return new()
{ {
new AvatarModel new AvatarModel
{ {
@@ -195,7 +195,7 @@ namespace HandyControlDemo.Service
internal List<AvatarModel> GetWebsiteDataList() internal List<AvatarModel> GetWebsiteDataList()
{ {
return new List<AvatarModel> return new()
{ {
new AvatarModel new AvatarModel
{ {
@@ -208,7 +208,7 @@ namespace HandyControlDemo.Service
internal ObservableCollection<CardModel> GetCardDataList() internal ObservableCollection<CardModel> GetCardDataList()
{ {
return new ObservableCollection<CardModel> return new()
{ {
new CardModel new CardModel
{ {
@@ -275,7 +275,7 @@ namespace HandyControlDemo.Service
internal CardModel GetCardData() internal CardModel GetCardData()
{ {
return new CardModel return new()
{ {
Content = $"/HandyControlDemo;component/Resources/Img/Album/{DateTime.Now.Second % 10 + 1}.jpg" Content = $"/HandyControlDemo;component/Resources/Img/Album/{DateTime.Now.Second % 10 + 1}.jpg"
}; };
@@ -283,7 +283,7 @@ namespace HandyControlDemo.Service
internal List<StepBarDemoModel> GetStepBarDemoDataList() internal List<StepBarDemoModel> GetStepBarDemoDataList()
{ {
return new List<StepBarDemoModel> return new()
{ {
new StepBarDemoModel new StepBarDemoModel
{ {
@@ -310,7 +310,7 @@ namespace HandyControlDemo.Service
internal ObservableCollection<CoverViewDemoModel> GetCoverViewDemoDataList() internal ObservableCollection<CoverViewDemoModel> GetCoverViewDemoDataList()
{ {
return new ObservableCollection<CoverViewDemoModel> return new()
{ {
new CoverViewDemoModel new CoverViewDemoModel
{ {
@@ -7,7 +7,7 @@ namespace HandyControlDemo.Tools
{ {
private static readonly string NameSpaceStr = typeof(AssemblyHelper).Assembly.GetName().Name; private static readonly string NameSpaceStr = typeof(AssemblyHelper).Assembly.GetName().Name;
private static readonly Dictionary<string, object> CacheDic = new Dictionary<string, object>(); private static readonly Dictionary<string, object> CacheDic = new();
public static void Register(string name, object instance) => CacheDic[name] = instance; public static void Register(string name, object instance) => CacheDic[name] = instance;
@@ -67,17 +67,17 @@ namespace HandyControlDemo.UserControl
var textEditorCustomStyle = ResourceHelper.GetResource<Style>("TextEditorCustom"); var textEditorCustomStyle = ResourceHelper.GetResource<Style>("TextEditorCustom");
_textEditor = new Dictionary<string, TextEditor> _textEditor = new Dictionary<string, TextEditor>
{ {
["XAML"] = new TextEditor ["XAML"] = new()
{ {
Style = textEditorCustomStyle, Style = textEditorCustomStyle,
SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML") SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML")
}, },
["C#"] = new TextEditor ["C#"] = new()
{ {
Style = textEditorCustomStyle, Style = textEditorCustomStyle,
SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#") SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#")
}, },
["VM"] = new TextEditor ["VM"] = new()
{ {
Style = textEditorCustomStyle, Style = textEditorCustomStyle,
SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#") SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#")
@@ -10,13 +10,13 @@ namespace HandyControlDemo.UserControl
{ {
public partial class GeometryDemoCtl public partial class GeometryDemoCtl
{ {
private readonly HashSet<string> _lineSet = new HashSet<string> private readonly HashSet<string> _lineSet = new()
{ {
"CheckedGeometry" "CheckedGeometry"
}; };
public ObservableCollection<GeometryItemModel> GeometryItems { get; set; } = public ObservableCollection<GeometryItemModel> GeometryItems { get; set; } =
new ObservableCollection<GeometryItemModel>(); new();
public GeometryDemoCtl() public GeometryDemoCtl()
{ {
@@ -50,7 +50,7 @@ namespace HandyControlDemo.ViewModel
#endif #endif
} }
public ObservableCollection<ChatInfoModel> ChatInfos { get; set; } = new ObservableCollection<ChatInfoModel>(); public ObservableCollection<ChatInfoModel> ChatInfos { get; set; } = new();
public RelayCommand<KeyEventArgs> SendStringCmd => new Lazy<RelayCommand<KeyEventArgs>>(() => public RelayCommand<KeyEventArgs> SendStringCmd => new Lazy<RelayCommand<KeyEventArgs>>(() =>
new RelayCommand<KeyEventArgs>(SendString)).Value; new RelayCommand<KeyEventArgs>(SendString)).Value;
@@ -58,7 +58,7 @@ namespace HandyControlDemo.ViewModel
public WindowDemoViewModel WindowDemo => SimpleIoc.Default.GetInstance<WindowDemoViewModel>(); public WindowDemoViewModel WindowDemo => SimpleIoc.Default.GetInstance<WindowDemoViewModel>();
public ItemsDisplayViewModel ContributorsView => new ItemsDisplayViewModel(SimpleIoc.Default.GetInstance<DataService>().GetContributorDataList); public ItemsDisplayViewModel ContributorsView => new(SimpleIoc.Default.GetInstance<DataService>().GetContributorDataList);
public ItemsDisplayViewModel BlogsView => SimpleIoc.Default.GetInstance<ItemsDisplayViewModel>("Blogs"); public ItemsDisplayViewModel BlogsView => SimpleIoc.Default.GetInstance<ItemsDisplayViewModel>("Blogs");
@@ -70,7 +70,7 @@ namespace HandyControlDemo.ViewModel
public PaginationDemoViewModel PaginationDemo => SimpleIoc.Default.GetInstance<PaginationDemoViewModel>(); public PaginationDemoViewModel PaginationDemo => SimpleIoc.Default.GetInstance<PaginationDemoViewModel>();
public ChatBoxViewModel ChatBox => new ChatBoxViewModel(); public ChatBoxViewModel ChatBox => new();
public CoverViewModel CoverView => SimpleIoc.Default.GetInstance<CoverViewModel>(); public CoverViewModel CoverView => SimpleIoc.Default.GetInstance<CoverViewModel>();
@@ -86,11 +86,11 @@ namespace HandyControlDemo.ViewModel
public SideMenuDemoViewModel SideMenuDemo => SimpleIoc.Default.GetInstance<SideMenuDemoViewModel>(); public SideMenuDemoViewModel SideMenuDemo => SimpleIoc.Default.GetInstance<SideMenuDemoViewModel>();
public TabControlDemoViewModel TabControlDemo => new TabControlDemoViewModel(SimpleIoc.Default.GetInstance<DataService>()); public TabControlDemoViewModel TabControlDemo => new(SimpleIoc.Default.GetInstance<DataService>());
public NonClientAreaViewModel NoUser => SimpleIoc.Default.GetInstance<NonClientAreaViewModel>(); public NonClientAreaViewModel NoUser => SimpleIoc.Default.GetInstance<NonClientAreaViewModel>();
public CardDemoViewModel CardDemo => new CardDemoViewModel(SimpleIoc.Default.GetInstance<DataService>()); public CardDemoViewModel CardDemo => new(SimpleIoc.Default.GetInstance<DataService>());
public SpriteDemoViewModel SpriteDemo => SimpleIoc.Default.GetInstance<SpriteDemoViewModel>(); public SpriteDemoViewModel SpriteDemo => SimpleIoc.Default.GetInstance<SpriteDemoViewModel>();
@@ -98,7 +98,7 @@ namespace HandyControlDemo.ViewModel
public SplitButtonDemoViewModel SplitButtonDemo => SimpleIoc.Default.GetInstance<SplitButtonDemoViewModel>(); public SplitButtonDemoViewModel SplitButtonDemo => SimpleIoc.Default.GetInstance<SplitButtonDemoViewModel>();
public TagDemoViewModel TagDemo => new TagDemoViewModel(SimpleIoc.Default.GetInstance<DataService>()); public TagDemoViewModel TagDemo => new(SimpleIoc.Default.GetInstance<DataService>());
#endregion #endregion
} }
@@ -9,7 +9,7 @@ namespace HandyControl.Collections
[Serializable] [Serializable]
public class ManualObservableCollection<T> : Collection<T>, INotifyCollectionChanged, INotifyPropertyChanged public class ManualObservableCollection<T> : Collection<T>, INotifyCollectionChanged, INotifyPropertyChanged
{ {
private readonly SimpleMonitor _monitor = new SimpleMonitor(); private readonly SimpleMonitor _monitor = new();
private const string CountString = "Count"; private const string CountString = "Count";
@@ -60,6 +60,6 @@ namespace HandyControl.Controls
return mySize; return mySize;
} }
private static Size ConvertThickness2Size(Thickness th) => new Size(th.Left + th.Right, th.Top + th.Bottom); private static Size ConvertThickness2Size(Thickness th) => new(th.Left + th.Right, th.Top + th.Bottom);
} }
} }
@@ -44,9 +44,9 @@ namespace HandyControl.Controls
private DispatcherTimer _updateTimer; private DispatcherTimer _updateTimer;
private readonly List<double> _widthList = new List<double>(); private readonly List<double> _widthList = new();
private readonly Dictionary<object, CarouselItem> _entryDic = new Dictionary<object, CarouselItem>(); private readonly Dictionary<object, CarouselItem> _entryDic = new();
private bool _isRefresh; private bool _isRefresh;
@@ -101,7 +101,7 @@ namespace HandyControl.Controls
/// <summary> /// <summary>
/// 预设的颜色(一共18个,两行) /// 预设的颜色(一共18个,两行)
/// </summary> /// </summary>
private readonly List<string> _colorPresetList = new List<string> private readonly List<string> _colorPresetList = new()
{ {
"#f44336", "#f44336",
"#e91e63", "#e91e63",
@@ -127,7 +127,7 @@ namespace HandyControl.Controls
/// <summary> /// <summary>
/// 颜色范围集合 /// 颜色范围集合
/// </summary> /// </summary>
private readonly List<ColorRange> _colorRangeList = new List<ColorRange> private readonly List<ColorRange> _colorRangeList = new()
{ {
new ColorRange new ColorRange
{ {
@@ -164,7 +164,7 @@ namespace HandyControl.Controls
/// <summary> /// <summary>
/// 颜色分隔集合 /// 颜色分隔集合
/// </summary> /// </summary>
private readonly List<Color> _colorSeparateList = new List<Color> private readonly List<Color> _colorSeparateList = new()
{ {
Color.FromRgb(255, 0, 0), Color.FromRgb(255, 0, 0),
Color.FromRgb(255, 0, 255), Color.FromRgb(255, 0, 255),
@@ -69,12 +69,12 @@ namespace HandyControl.Controls
/// <summary> /// <summary>
/// 存储所有的内容 /// 存储所有的内容
/// </summary> /// </summary>
private readonly Dictionary<int, object> _contentDic = new Dictionary<int, object>(); private readonly Dictionary<int, object> _contentDic = new();
/// <summary> /// <summary>
/// 当前在显示范围内的项 /// 当前在显示范围内的项
/// </summary> /// </summary>
private readonly Dictionary<int, CoverFlowItem> _itemShowDic = new Dictionary<int, CoverFlowItem>(); private readonly Dictionary<int, CoverFlowItem> _itemShowDic = new();
/// <summary> /// <summary>
/// 相机 /// 相机
@@ -72,12 +72,12 @@ namespace HandyControl.Controls
var textureCoordinates = new PointCollection var textureCoordinates = new PointCollection
{ {
new Point(0, 1), new(0, 1),
new Point(1, 1), new(1, 1),
new Point(1, 0), new(1, 0),
new Point(0, 0), new(0, 0),
new Point(1, 0), new(1, 0),
new Point(1, 1) new(1, 1)
}; };
var normals = new Vector3DCollection var normals = new Vector3DCollection
@@ -16,7 +16,7 @@ namespace HandyControl.Controls
private IEnumerable _itemsSourceInternal; private IEnumerable _itemsSourceInternal;
private readonly Dictionary<object, CoverViewItem> _entryDic = new Dictionary<object, CoverViewItem>(); private readonly Dictionary<object, CoverViewItem> _entryDic = new();
private bool _isRefresh; private bool _isRefresh;
@@ -16,7 +16,7 @@ namespace HandyControl.Controls
private AdornerContainer _container; private AdornerContainer _container;
private static readonly Dictionary<string, FrameworkElement> ContainerDic = new Dictionary<string, FrameworkElement>(); private static readonly Dictionary<string, FrameworkElement> ContainerDic = new();
public static readonly DependencyProperty IsClosedProperty = DependencyProperty.Register( public static readonly DependencyProperty IsClosedProperty = DependencyProperty.Register(
"IsClosed", typeof(bool), typeof(Dialog), new PropertyMetadata(ValueBoxes.FalseBox)); "IsClosed", typeof(bool), typeof(Dialog), new PropertyMetadata(ValueBoxes.FalseBox));
@@ -19,9 +19,9 @@ namespace HandyControl.Controls
{ {
public class GifImage : Image, IDisposable public class GifImage : Image, IDisposable
{ {
private static readonly Guid GifGuid = new Guid("{b96b3caa-0728-11d3-9d7b-0000f81ef32e}"); private static readonly Guid GifGuid = new("{b96b3caa-0728-11d3-9d7b-0000f81ef32e}");
private static readonly Guid GifSingleFrameGuid = new Guid("{b96b3cb0-0728-11d3-9d7b-0000f81ef32e}"); private static readonly Guid GifSingleFrameGuid = new("{b96b3cb0-0728-11d3-9d7b-0000f81ef32e}");
internal IntPtr NativeImage; internal IntPtr NativeImage;
@@ -48,7 +48,7 @@ namespace HandyControl.Controls
/// <summary> /// <summary>
/// 图片保存对话框 /// 图片保存对话框
/// </summary> /// </summary>
private static readonly SaveFileDialog SaveFileDialog = new SaveFileDialog private static readonly SaveFileDialog SaveFileDialog = new()
{ {
Filter = $"{Lang.PngImg}|*.png" Filter = $"{Lang.PngImg}|*.png"
}; };
@@ -62,7 +62,7 @@ namespace HandyControl.Controls
"DotDelayTime", typeof(double), typeof(LoadingBase), "DotDelayTime", typeof(double), typeof(LoadingBase),
new FrameworkPropertyMetadata(80.0, FrameworkPropertyMetadataOptions.AffectsRender)); new FrameworkPropertyMetadata(80.0, FrameworkPropertyMetadataOptions.AffectsRender));
protected readonly Canvas PrivateCanvas = new Canvas protected readonly Canvas PrivateCanvas = new()
{ {
ClipToBounds = true ClipToBounds = true
}; };
@@ -134,9 +134,9 @@ namespace HandyControl.Controls
set => SetValue(BorderDashOffsetProperty, value); set => SetValue(BorderDashOffsetProperty, value);
} }
private static Size ConvertThickness2Size(Thickness th) => new Size(th.Left + th.Right, th.Top + th.Bottom); private static Size ConvertThickness2Size(Thickness th) => new(th.Left + th.Right, th.Top + th.Bottom);
private static Rect DeflateRect(Rect rt, Thickness thick) => new Rect(rt.Left + thick.Left, private static Rect DeflateRect(Rect rt, Thickness thick) => new(rt.Left + thick.Left,
rt.Top + thick.Top, rt.Top + thick.Top,
Math.Max(0.0, rt.Width - thick.Left - thick.Right), Math.Max(0.0, rt.Width - thick.Left - thick.Right),
Math.Max(0.0, rt.Height - thick.Top - thick.Bottom)); Math.Max(0.0, rt.Height - thick.Top - thick.Bottom));
@@ -18,7 +18,7 @@ namespace HandyControl.Controls
private const string ElementVisualBrush = "PART_VisualBrush"; private const string ElementVisualBrush = "PART_VisualBrush";
private VisualBrush _visualBrush = new VisualBrush(); private VisualBrush _visualBrush = new();
private readonly TranslateTransform _translateTransform; private readonly TranslateTransform _translateTransform;
@@ -40,7 +40,7 @@ namespace HandyControl.Controls
set => SetValue(VerticalOffsetProperty, value); set => SetValue(VerticalOffsetProperty, value);
} }
public static Magnifier Default => new Magnifier(); public static Magnifier Default => new();
public static readonly DependencyProperty ScaleProperty = DependencyProperty.Register( public static readonly DependencyProperty ScaleProperty = DependencyProperty.Register(
"Scale", typeof(double), typeof(Magnifier), new PropertyMetadata(5.0, OnScaleChanged), ValidateHelper.IsInRangeOfPosDouble); "Scale", typeof(double), typeof(Magnifier), new PropertyMetadata(5.0, OnScaleChanged), ValidateHelper.IsInRangeOfPosDouble);
@@ -22,7 +22,7 @@ namespace HandyControl.Controls
private bool _added; private bool _added;
private readonly object _syncObj = new object(); private readonly object _syncObj = new();
private readonly int _id; private readonly int _id;
@@ -58,7 +58,7 @@ namespace HandyControl.Controls
private static int NextId; private static int NextId;
private static readonly Dictionary<string, NotifyIcon> NotifyIconDic = new Dictionary<string, NotifyIcon>(); private static readonly Dictionary<string, NotifyIcon> NotifyIconDic = new();
static NotifyIcon() static NotifyIcon()
{ {
@@ -383,7 +383,7 @@ namespace HandyControl.Controls
private RadioButton CreateButton(int page) private RadioButton CreateButton(int page)
{ {
return new RadioButton return new()
{ {
Style = ResourceHelper.GetResourceInternal<Style>(ResourceToken.PaginationButtonStyle), Style = ResourceHelper.GetResourceInternal<Style>(ResourceToken.PaginationButtonStyle),
Content = page.ToString() Content = page.ToString()
@@ -148,7 +148,7 @@ namespace HandyControl.Controls
set => SetValue(IsOpenProperty, ValueBoxes.BooleanBox(value)); set => SetValue(IsOpenProperty, ValueBoxes.BooleanBox(value));
} }
public static Poptip Default => new Poptip(); public static Poptip Default => new();
protected sealed override void OnTargetChanged(FrameworkElement element, bool isNew) protected sealed override void OnTargetChanged(FrameworkElement element, bool isNew)
{ {
@@ -16,7 +16,7 @@ namespace HandyControl.Controls
private int _lineCount; private int _lineCount;
private readonly List<FlexItemInfo> _orderList = new List<FlexItemInfo>(); private readonly List<FlexItemInfo> _orderList = new();
#region Item #region Item
@@ -33,7 +33,7 @@ namespace HandyControl.Controls
CommandBindings.Add(new CommandBinding(ControlCommands.SortByName, SortByName, (s, e) => e.CanExecute = ShowSortButton)); CommandBindings.Add(new CommandBinding(ControlCommands.SortByName, SortByName, (s, e) => e.CanExecute = ShowSortButton));
} }
public virtual PropertyResolver PropertyResolver { get; } = new PropertyResolver(); public virtual PropertyResolver PropertyResolver { get; } = new();
public static readonly RoutedEvent SelectedObjectChangedEvent = public static readonly RoutedEvent SelectedObjectChangedEvent =
EventManager.RegisterRoutedEvent("SelectedObjectChanged", RoutingStrategy.Bubble, EventManager.RegisterRoutedEvent("SelectedObjectChanged", RoutingStrategy.Bubble,
@@ -181,7 +181,7 @@ namespace HandyControl.Controls
} }
} }
protected virtual PropertyItem CreatePropertyItem(PropertyDescriptor propertyDescriptor) => new PropertyItem protected virtual PropertyItem CreatePropertyItem(PropertyDescriptor propertyDescriptor) => new()
{ {
Category = PropertyResolver.ResolveCategory(propertyDescriptor), Category = PropertyResolver.ResolveCategory(propertyDescriptor),
DisplayName = PropertyResolver.ResolveDisplayName(propertyDescriptor), DisplayName = PropertyResolver.ResolveDisplayName(propertyDescriptor),
@@ -10,7 +10,7 @@ namespace HandyControl.Controls
{ {
public class PropertyResolver public class PropertyResolver
{ {
private static readonly Dictionary<Type, EditorTypeCode> TypeCodeDic = new Dictionary<Type, EditorTypeCode> private static readonly Dictionary<Type, EditorTypeCode> TypeCodeDic = new()
{ {
[typeof(string)] = EditorTypeCode.PlainText, [typeof(string)] = EditorTypeCode.PlainText,
[typeof(sbyte)] = EditorTypeCode.SByteNumber, [typeof(sbyte)] = EditorTypeCode.SByteNumber,
@@ -33,7 +33,7 @@ namespace HandyControl.Controls
private BitmapSource _imageSource; private BitmapSource _imageSource;
private static readonly Guid BmpGuid = new Guid("{b96b3cab-0728-11d3-9d7b-0000f81ef32e}"); private static readonly Guid BmpGuid = new("{b96b3cab-0728-11d3-9d7b-0000f81ef32e}");
#region const #region const
@@ -20,7 +20,7 @@ namespace HandyControl.Controls
/// <summary> /// <summary>
/// 选项卡字典 /// 选项卡字典
/// </summary> /// </summary>
internal Dictionary<int, TabItem> ItemDic = new Dictionary<int, TabItem>(); internal Dictionary<int, TabItem> ItemDic = new();
public static readonly DependencyPropertyKey FluidMoveDurationPropertyKey = public static readonly DependencyPropertyKey FluidMoveDurationPropertyKey =
DependencyProperty.RegisterReadOnly("FluidMoveDuration", typeof(Duration), typeof(TabPanel), DependencyProperty.RegisterReadOnly("FluidMoveDuration", typeof(Duration), typeof(TabPanel),
@@ -240,10 +240,10 @@ namespace HandyControl.Controls
var positions = new Point3DCollection var positions = new Point3DCollection
{ {
new Point3D(-quarterWidth * flag, quarterHeight, 0), new(-quarterWidth * flag, quarterHeight, 0),
new Point3D(-quarterWidth * flag, 0, 0), new(-quarterWidth * flag, 0, 0),
new Point3D(quarterWidth * flag, 0, 0), new(quarterWidth * flag, 0, 0),
new Point3D(quarterWidth * flag, quarterHeight, 0) new(quarterWidth * flag, quarterHeight, 0)
}; };
var triangleIndices = new Int32Collection var triangleIndices = new Int32Collection
@@ -258,10 +258,10 @@ namespace HandyControl.Controls
var textureCoordinates = new PointCollection var textureCoordinates = new PointCollection
{ {
new Point(0, 0), new(0, 0),
new Point(0, 1), new(0, 1),
new Point(1, 1), new(1, 1),
new Point(1, 0) new(1, 0)
}; };
var geometry3D = new MeshGeometry3D var geometry3D = new MeshGeometry3D
@@ -150,7 +150,7 @@ namespace HandyControl.Controls
/// <summary> /// <summary>
/// 刻度集合 /// 刻度集合
/// </summary> /// </summary>
private readonly List<SpeTextBlock> _speBlockList = new List<SpeTextBlock>(); private readonly List<SpeTextBlock> _speBlockList = new();
/// <summary> /// <summary>
/// 初始化时时间 /// 初始化时时间
@@ -160,7 +160,7 @@ namespace HandyControl.Controls
/// <summary> /// <summary>
/// 时间段集合 /// 时间段集合
/// </summary> /// </summary>
private readonly List<int> _timeSpeList = new List<int> private readonly List<int> _timeSpeList = new()
{ {
7200000, 7200000,
3600000, 3600000,
@@ -22,9 +22,9 @@ namespace HandyControl.Controls
private const string ElementItemsSelected = "PART_ItemsSelected"; private const string ElementItemsSelected = "PART_ItemsSelected";
private readonly Dictionary<object, TransferEntry> _entryDic = new Dictionary<object, TransferEntry>(); private readonly Dictionary<object, TransferEntry> _entryDic = new();
private readonly List<TransferEntry> _entryList = new List<TransferEntry>(); private readonly List<TransferEntry> _entryList = new();
private SimpleItemsControl _itemsOrigin; private SimpleItemsControl _itemsOrigin;
@@ -8,11 +8,11 @@ namespace HandyControl.Data
public Guid Guid { get; } public Guid Guid { get; }
public static GifFrameDimension Time { get; } = new GifFrameDimension(new Guid("{6aedbd6d-3fb5-418a-83a6-7f45229dc872}")); public static GifFrameDimension Time { get; } = new(new Guid("{6aedbd6d-3fb5-418a-83a6-7f45229dc872}"));
public static GifFrameDimension Resolution { get; } = new GifFrameDimension(new Guid("{84236f7b-3bd3-428f-8dab-4ea1439ca315}")); public static GifFrameDimension Resolution { get; } = new(new Guid("{84236f7b-3bd3-428f-8dab-4ea1439ca315}"));
public static GifFrameDimension Page { get; } = new GifFrameDimension(new Guid("{7462dc86-6180-4c7e-8e3f-ee7333a7a483}")); public static GifFrameDimension Page { get; } = new(new Guid("{7462dc86-6180-4c7e-8e3f-ee7333a7a483}"));
public override bool Equals(object o) => o is GifFrameDimension format && Guid == format.Guid; public override bool Equals(object o) => o is GifFrameDimension format && Guid == format.Guid;
@@ -7,11 +7,11 @@ namespace HandyControl.Data
{ {
public readonly struct SystemVersionInfo public readonly struct SystemVersionInfo
{ {
public static SystemVersionInfo Windows10 => new SystemVersionInfo(10, 0, 10240); public static SystemVersionInfo Windows10 => new(10, 0, 10240);
public static SystemVersionInfo Windows10_1809 => new SystemVersionInfo(10, 0, 17763); public static SystemVersionInfo Windows10_1809 => new(10, 0, 17763);
public static SystemVersionInfo Windows10_1903 => new SystemVersionInfo(10, 0, 18362); public static SystemVersionInfo Windows10_1903 => new(10, 0, 18362);
public SystemVersionInfo(int major, int minor, int build) public SystemVersionInfo(int major, int minor, int build)
{ {
@@ -4,7 +4,7 @@
{ {
public static OperationResult<bool> Failed(string message = "") public static OperationResult<bool> Failed(string message = "")
{ {
return new OperationResult<bool> return new()
{ {
ResultType = ResultType.Failed, ResultType = ResultType.Failed,
Message = message, Message = message,
@@ -14,7 +14,7 @@
public static OperationResult<bool> Success(string message = "") public static OperationResult<bool> Success(string message = "")
{ {
return new OperationResult<bool> return new()
{ {
ResultType = ResultType.Success, ResultType = ResultType.Success,
Message = message, Message = message,
@@ -15,36 +15,36 @@ namespace HandyControl.Expression.Drawing
internal static Rect Bounds(this Size size) internal static Rect Bounds(this Size size)
{ {
return new Rect(0.0, 0.0, size.Width, size.Height); return new(0.0, 0.0, size.Width, size.Height);
} }
internal static Point Center(this Rect rect) internal static Point Center(this Rect rect)
{ {
return new Point(rect.X + rect.Width / 2.0, rect.Y + rect.Height / 2.0); return new(rect.X + rect.Width / 2.0, rect.Y + rect.Height / 2.0);
} }
internal static Vector Subtract(this Point lhs, Point rhs) internal static Vector Subtract(this Point lhs, Point rhs)
{ {
return new Vector(lhs.X - rhs.X, lhs.Y - rhs.Y); return new(lhs.X - rhs.X, lhs.Y - rhs.Y);
} }
internal static Thickness Subtract(this Rect lhs, Rect rhs) internal static Thickness Subtract(this Rect lhs, Rect rhs)
{ {
return new Thickness(rhs.Left - lhs.Left, return new(rhs.Left - lhs.Left,
rhs.Top - lhs.Top, lhs.Right - rhs.Right, rhs.Top - lhs.Top, lhs.Right - rhs.Right,
lhs.Bottom - rhs.Bottom); lhs.Bottom - rhs.Bottom);
} }
internal static Point Lerp(Point pointA, Point pointB, double alpha) internal static Point Lerp(Point pointA, Point pointB, double alpha)
{ {
return new Point( return new(
MathHelper.Lerp(pointA.X, pointB.X, alpha), MathHelper.Lerp(pointA.X, pointB.X, alpha),
MathHelper.Lerp(pointA.Y, pointB.Y, alpha)); MathHelper.Lerp(pointA.Y, pointB.Y, alpha));
} }
internal static Vector Lerp(Vector vectorA, Vector vectorB, double alpha) internal static Vector Lerp(Vector vectorA, Vector vectorB, double alpha)
{ {
return new Vector(MathHelper.Lerp(vectorA.X, vectorB.X, alpha), return new(MathHelper.Lerp(vectorA.X, vectorB.X, alpha),
MathHelper.Lerp(vectorA.Y, vectorB.Y, alpha)); MathHelper.Lerp(vectorA.Y, vectorB.Y, alpha));
} }
@@ -107,7 +107,7 @@ namespace HandyControl.Expression.Drawing
internal static Point RelativeToAbsolutePoint(Rect bound, Point relative) internal static Point RelativeToAbsolutePoint(Rect bound, Point relative)
{ {
return new Point(bound.X + relative.X * bound.Width, bound.Y + relative.Y * bound.Height); return new(bound.X + relative.X * bound.Width, bound.Y + relative.Y * bound.Height);
} }
internal static double SquaredDistance(Point lhs, Point rhs) internal static double SquaredDistance(Point lhs, Point rhs)
@@ -119,7 +119,7 @@ namespace HandyControl.Expression.Drawing
internal static Point Midpoint(Point lhs, Point rhs) internal static Point Midpoint(Point lhs, Point rhs)
{ {
return new Point((lhs.X + rhs.X) / 2.0, (lhs.Y + rhs.Y) / 2.0); return new((lhs.X + rhs.X) / 2.0, (lhs.Y + rhs.Y) / 2.0);
} }
internal static bool HasValidArea(this Size size) internal static bool HasValidArea(this Size size)
@@ -166,12 +166,12 @@ namespace HandyControl.Expression.Drawing
internal static Point Plus(this Point lhs, Point rhs) internal static Point Plus(this Point lhs, Point rhs)
{ {
return new Point(lhs.X + rhs.X, lhs.Y + rhs.Y); return new(lhs.X + rhs.X, lhs.Y + rhs.Y);
} }
internal static Point Minus(this Point lhs, Point rhs) internal static Point Minus(this Point lhs, Point rhs)
{ {
return new Point(lhs.X - rhs.X, lhs.Y - rhs.Y); return new(lhs.X - rhs.X, lhs.Y - rhs.Y);
} }
internal static Vector Normal(Point lhs, Point rhs) internal static Vector Normal(Point lhs, Point rhs)
@@ -156,7 +156,7 @@ namespace HandyControl.Expression.Media
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
private static Size GetArcSize(Rect bound) private static Size GetArcSize(Rect bound)
{ {
return new Size(bound.Width / 2.0, bound.Height / 2.0); return new(bound.Width / 2.0, bound.Height / 2.0);
} }
private static void IncreaseDuplicatedIndex(IList<double> values, ref int index) private static void IncreaseDuplicatedIndex(IList<double> values, ref int index)
@@ -73,7 +73,7 @@ namespace HandyControl.Expression.Shapes
protected abstract IGeometrySource CreateGeometrySource(); protected abstract IGeometrySource CreateGeometrySource();
protected override Size MeasureOverride(Size availableSize) => new Size(base.StrokeThickness, base.StrokeThickness); protected override Size MeasureOverride(Size availableSize) => new(base.StrokeThickness, base.StrokeThickness);
private void RealizeGeometry() => RenderedGeometryChanged?.Invoke(this, EventArgs.Empty); private void RealizeGeometry() => RenderedGeometryChanged?.Invoke(this, EventArgs.Empty);
} }
@@ -52,7 +52,7 @@ namespace HandyControl.Interactivity
new PropertyMetadata(null)); new PropertyMetadata(null));
private static readonly Dictionary<object, Storyboard> TransitionStoryboardDictionary = private static readonly Dictionary<object, Storyboard> TransitionStoryboardDictionary =
new Dictionary<object, Storyboard>(); new();
public Duration Duration public Duration Duration
{ {
@@ -27,7 +27,7 @@ namespace HandyControl.Interactivity
private static DateTime NextToLastPurgeTick = DateTime.MinValue; private static DateTime NextToLastPurgeTick = DateTime.MinValue;
internal static Dictionary<object, TagData> TagDictionary = new Dictionary<object, TagData>(); internal static Dictionary<object, TagData> TagDictionary = new();
public static readonly DependencyProperty TagPathProperty = DependencyProperty.Register("TagPath", public static readonly DependencyProperty TagPathProperty = DependencyProperty.Register("TagPath",
typeof(string), typeof(FluidMoveBehaviorBase), new PropertyMetadata(string.Empty)); typeof(string), typeof(FluidMoveBehaviorBase), new PropertyMetadata(string.Empty));
@@ -10,176 +10,176 @@ namespace HandyControl.Interactivity
/// <summary> /// <summary>
/// 搜索 /// 搜索
/// </summary> /// </summary>
public static RoutedCommand Search { get; } = new RoutedCommand(nameof(Search), typeof(ControlCommands)); public static RoutedCommand Search { get; } = new(nameof(Search), typeof(ControlCommands));
/// <summary> /// <summary>
/// 清除 /// 清除
/// </summary> /// </summary>
public static RoutedCommand Clear { get; } = new RoutedCommand(nameof(Clear), typeof(ControlCommands)); public static RoutedCommand Clear { get; } = new(nameof(Clear), typeof(ControlCommands));
/// <summary> /// <summary>
/// 切换 /// 切换
/// </summary> /// </summary>
public static RoutedCommand Switch { get; } = new RoutedCommand(nameof(Switch), typeof(ControlCommands)); public static RoutedCommand Switch { get; } = new(nameof(Switch), typeof(ControlCommands));
/// <summary> /// <summary>
/// 右转 /// 右转
/// </summary> /// </summary>
public static RoutedCommand RotateRight { get; } = new RoutedCommand(nameof(RotateRight), typeof(ControlCommands)); public static RoutedCommand RotateRight { get; } = new(nameof(RotateRight), typeof(ControlCommands));
/// <summary> /// <summary>
/// 左转 /// 左转
/// </summary> /// </summary>
public static RoutedCommand RotateLeft { get; } = new RoutedCommand(nameof(RotateLeft), typeof(ControlCommands)); public static RoutedCommand RotateLeft { get; } = new(nameof(RotateLeft), typeof(ControlCommands));
/// <summary> /// <summary>
/// 小 /// 小
/// </summary> /// </summary>
public static RoutedCommand Reduce { get; } = new RoutedCommand(nameof(Reduce), typeof(ControlCommands)); public static RoutedCommand Reduce { get; } = new(nameof(Reduce), typeof(ControlCommands));
/// <summary> /// <summary>
/// 大 /// 大
/// </summary> /// </summary>
public static RoutedCommand Enlarge { get; } = new RoutedCommand(nameof(Enlarge), typeof(ControlCommands)); public static RoutedCommand Enlarge { get; } = new(nameof(Enlarge), typeof(ControlCommands));
/// <summary> /// <summary>
/// 还原 /// 还原
/// </summary> /// </summary>
public static RoutedCommand Restore { get; } = new RoutedCommand(nameof(Restore), typeof(ControlCommands)); public static RoutedCommand Restore { get; } = new(nameof(Restore), typeof(ControlCommands));
/// <summary> /// <summary>
/// 打开 /// 打开
/// </summary> /// </summary>
public static RoutedCommand Open { get; } = new RoutedCommand(nameof(Open), typeof(ControlCommands)); public static RoutedCommand Open { get; } = new(nameof(Open), typeof(ControlCommands));
/// <summary> /// <summary>
/// 保存 /// 保存
/// </summary> /// </summary>
public static RoutedCommand Save { get; } = new RoutedCommand(nameof(Save), typeof(ControlCommands)); public static RoutedCommand Save { get; } = new(nameof(Save), typeof(ControlCommands));
/// <summary> /// <summary>
/// 选中 /// 选中
/// </summary> /// </summary>
public static RoutedCommand Selected { get; } = new RoutedCommand(nameof(Selected), typeof(ControlCommands)); public static RoutedCommand Selected { get; } = new(nameof(Selected), typeof(ControlCommands));
/// <summary> /// <summary>
/// 关闭 /// 关闭
/// </summary> /// </summary>
public static RoutedCommand Close { get; } = new RoutedCommand(nameof(Close), typeof(ControlCommands)); public static RoutedCommand Close { get; } = new(nameof(Close), typeof(ControlCommands));
/// <summary> /// <summary>
/// 取消 /// 取消
/// </summary> /// </summary>
public static RoutedCommand Cancel { get; } = new RoutedCommand(nameof(Cancel), typeof(ControlCommands)); public static RoutedCommand Cancel { get; } = new(nameof(Cancel), typeof(ControlCommands));
/// <summary> /// <summary>
/// 确定 /// 确定
/// </summary> /// </summary>
public static RoutedCommand Confirm { get; } = new RoutedCommand(nameof(Confirm), typeof(ControlCommands)); public static RoutedCommand Confirm { get; } = new(nameof(Confirm), typeof(ControlCommands));
/// <summary> /// <summary>
/// 是 /// 是
/// </summary> /// </summary>
public static RoutedCommand Yes { get; } = new RoutedCommand(nameof(Yes), typeof(ControlCommands)); public static RoutedCommand Yes { get; } = new(nameof(Yes), typeof(ControlCommands));
/// <summary> /// <summary>
/// 否 /// 否
/// </summary> /// </summary>
public static RoutedCommand No { get; } = new RoutedCommand(nameof(No), typeof(ControlCommands)); public static RoutedCommand No { get; } = new(nameof(No), typeof(ControlCommands));
/// <summary> /// <summary>
/// 关闭所有 /// 关闭所有
/// </summary> /// </summary>
public static RoutedCommand CloseAll { get; } = new RoutedCommand(nameof(CloseAll), typeof(ControlCommands)); public static RoutedCommand CloseAll { get; } = new(nameof(CloseAll), typeof(ControlCommands));
/// <summary> /// <summary>
/// 关闭其他 /// 关闭其他
/// </summary> /// </summary>
public static RoutedCommand CloseOther { get; } = new RoutedCommand(nameof(CloseOther), typeof(ControlCommands)); public static RoutedCommand CloseOther { get; } = new(nameof(CloseOther), typeof(ControlCommands));
/// <summary> /// <summary>
/// 上一个 /// 上一个
/// </summary> /// </summary>
public static RoutedCommand Prev { get; } = new RoutedCommand(nameof(Prev), typeof(ControlCommands)); public static RoutedCommand Prev { get; } = new(nameof(Prev), typeof(ControlCommands));
/// <summary> /// <summary>
/// 下一个 /// 下一个
/// </summary> /// </summary>
public static RoutedCommand Next { get; } = new RoutedCommand(nameof(Next), typeof(ControlCommands)); public static RoutedCommand Next { get; } = new(nameof(Next), typeof(ControlCommands));
/// <summary> /// <summary>
/// 跳转 /// 跳转
/// </summary> /// </summary>
public static RoutedCommand Jump { get; } = new RoutedCommand(nameof(Jump), typeof(ControlCommands)); public static RoutedCommand Jump { get; } = new(nameof(Jump), typeof(ControlCommands));
/// <summary> /// <summary>
/// 上午 /// 上午
/// </summary> /// </summary>
public static RoutedCommand Am { get; } = new RoutedCommand(nameof(Am), typeof(ControlCommands)); public static RoutedCommand Am { get; } = new(nameof(Am), typeof(ControlCommands));
/// <summary> /// <summary>
/// 下午 /// 下午
/// </summary> /// </summary>
public static RoutedCommand Pm { get; } = new RoutedCommand(nameof(Pm), typeof(ControlCommands)); public static RoutedCommand Pm { get; } = new(nameof(Pm), typeof(ControlCommands));
/// <summary> /// <summary>
/// 确认 /// 确认
/// </summary> /// </summary>
public static RoutedCommand Sure { get; } = new RoutedCommand(nameof(Sure), typeof(ControlCommands)); public static RoutedCommand Sure { get; } = new(nameof(Sure), typeof(ControlCommands));
/// <summary> /// <summary>
/// 小时改变 /// 小时改变
/// </summary> /// </summary>
public static RoutedCommand HourChange { get; } = new RoutedCommand(nameof(HourChange), typeof(ControlCommands)); public static RoutedCommand HourChange { get; } = new(nameof(HourChange), typeof(ControlCommands));
/// <summary> /// <summary>
/// 分钟改变 /// 分钟改变
/// </summary> /// </summary>
public static RoutedCommand MinuteChange { get; } = new RoutedCommand(nameof(MinuteChange), typeof(ControlCommands)); public static RoutedCommand MinuteChange { get; } = new(nameof(MinuteChange), typeof(ControlCommands));
/// <summary> /// <summary>
/// 秒改变 /// 秒改变
/// </summary> /// </summary>
public static RoutedCommand SecondChange { get; } = new RoutedCommand(nameof(SecondChange), typeof(ControlCommands)); public static RoutedCommand SecondChange { get; } = new(nameof(SecondChange), typeof(ControlCommands));
/// <summary> /// <summary>
/// 鼠标移动 /// 鼠标移动
/// </summary> /// </summary>
public static RoutedCommand MouseMove { get; } = new RoutedCommand(nameof(MouseMove), typeof(ControlCommands)); public static RoutedCommand MouseMove { get; } = new(nameof(MouseMove), typeof(ControlCommands));
/// <summary> /// <summary>
/// 打开链接 /// 打开链接
/// </summary> /// </summary>
public static OpenLinkCommand OpenLink { get; } = new OpenLinkCommand(); public static OpenLinkCommand OpenLink { get; } = new();
/// <summary> /// <summary>
/// 关闭程序 /// 关闭程序
/// </summary> /// </summary>
public static ShutdownAppCommand ShutdownApp { get; } = new ShutdownAppCommand(); public static ShutdownAppCommand ShutdownApp { get; } = new();
/// <summary> /// <summary>
/// 前置主窗口 /// 前置主窗口
/// </summary> /// </summary>
public static PushMainWindow2TopCommand PushMainWindow2Top { get; } = new PushMainWindow2TopCommand(); public static PushMainWindow2TopCommand PushMainWindow2Top { get; } = new();
/// <summary> /// <summary>
/// 关闭窗口 /// 关闭窗口
/// </summary> /// </summary>
public static CloseWindowCommand CloseWindow { get; } = new CloseWindowCommand(); public static CloseWindowCommand CloseWindow { get; } = new();
/// <summary> /// <summary>
/// 开始截图 /// 开始截图
/// </summary> /// </summary>
public static StartScreenshotCommand StartScreenshot { get; } = new StartScreenshotCommand(); public static StartScreenshotCommand StartScreenshot { get; } = new();
/// <summary> /// <summary>
/// 按照类别排序 /// 按照类别排序
/// </summary> /// </summary>
public static RoutedCommand SortByCategory { get; } = new RoutedCommand(nameof(SortByCategory), typeof(ControlCommands)); public static RoutedCommand SortByCategory { get; } = new(nameof(SortByCategory), typeof(ControlCommands));
/// <summary> /// <summary>
/// 按照名称排序 /// 按照名称排序
/// </summary> /// </summary>
public static RoutedCommand SortByName { get; } = new RoutedCommand(nameof(SortByName), typeof(ControlCommands)); public static RoutedCommand SortByName { get; } = new(nameof(SortByName), typeof(ControlCommands));
} }
} }
@@ -238,7 +238,7 @@ namespace HandyControl.Media.Animation
return AnimationHelper.ComposeGeometry(Strings, currentIterationValue); return AnimationHelper.ComposeGeometry(Strings, currentIterationValue);
} }
protected sealed override Duration GetNaturalDurationCore(Clock clock) => new Duration(LargestTimeSpanKeyTime); protected sealed override Duration GetNaturalDurationCore(Clock clock) => new(LargestTimeSpanKeyTime);
IList IKeyFrameAnimation.KeyFrames IList IKeyFrameAnimation.KeyFrames
{ {
@@ -7,7 +7,7 @@ namespace HandyControl.Themes
{ {
public class SharedResourceDictionary : ResourceDictionary public class SharedResourceDictionary : ResourceDictionary
{ {
public static Dictionary<Uri, ResourceDictionary> SharedDictionaries = new Dictionary<Uri, ResourceDictionary>(); public static Dictionary<Uri, ResourceDictionary> SharedDictionaries = new();
private Uri _sourceUri; private Uri _sourceUri;
@@ -21,7 +21,7 @@ namespace HandyControl.Tools.Converter
{ {
Figures = new PathFigureCollection Figures = new PathFigureCollection
{ {
new PathFigure(new Point(radius.TopLeft, 0), new PathSegment[] new(new Point(radius.TopLeft, 0), new PathSegment[]
{ {
new LineSegment(new Point(width - radius.TopRight, 0), false), new LineSegment(new Point(width - radius.TopRight, 0), false),
new ArcSegment(new Point(width, radius.TopRight), new Size(radius.TopRight, radius.TopRight), 90, false, SweepDirection.Clockwise, false), new ArcSegment(new Point(width, radius.TopRight), new Size(radius.TopRight, radius.TopRight), 90, false, SweepDirection.Clockwise, false),
@@ -23,7 +23,7 @@ namespace HandyControl.Tools.Extension
/// <returns></returns> /// <returns></returns>
public static int ToInt32Reverse(this Color color) => color.R | color.G << 8 | color.B << 18; public static int ToInt32Reverse(this Color color) => color.R | color.G << 8 | color.B << 18;
internal static List<byte> ToList(this Color color) => new List<byte> internal static List<byte> ToList(this Color color) => new()
{ {
color.R, color.R,
color.G, color.G,
@@ -5,7 +5,7 @@ namespace HandyControl.Tools.Extension
{ {
public static class ValueExtension public static class ValueExtension
{ {
public static Thickness Add(this Thickness a, Thickness b) => new Thickness(a.Left + b.Left, a.Top + b.Top, a.Right + b.Right, a.Bottom + b.Bottom); public static Thickness Add(this Thickness a, Thickness b) => new(a.Left + b.Left, a.Top + b.Top, a.Right + b.Right, a.Bottom + b.Bottom);
public static bool IsZero(this Thickness thickness) => public static bool IsZero(this Thickness thickness) =>
MathHelper.IsZero(thickness.Left) MathHelper.IsZero(thickness.Left)
@@ -7,7 +7,7 @@ namespace HandyControl.Tools
{ {
public class ComparerGenerator public class ComparerGenerator
{ {
private static readonly Dictionary<Type, ComparerTypeCode> TypeCodeDic = new Dictionary<Type, ComparerTypeCode> private static readonly Dictionary<Type, ComparerTypeCode> TypeCodeDic = new()
{ {
[typeof(DateTimeRange)] = ComparerTypeCode.DateTimeRange, [typeof(DateTimeRange)] = ComparerTypeCode.DateTimeRange,
}; };
@@ -12,7 +12,7 @@ namespace HandyControl.Tools
{ {
private static List<GifImageInfo> ImageInfoList; private static List<GifImageInfo> ImageInfoList;
private static readonly ReaderWriterLock RwImgListLock = new ReaderWriterLock(); private static readonly ReaderWriterLock RwImgListLock = new();
private static Thread AnimationThread; private static Thread AnimationThread;
@@ -11,7 +11,7 @@ namespace HandyControl.Tools
{ {
private static ObservableCollection<KeyBinding> KeyBindingCollection; private static ObservableCollection<KeyBinding> KeyBindingCollection;
private static readonly Dictionary<string, KeyBinding> CommandDic = new Dictionary<string, KeyBinding>(); private static readonly Dictionary<string, KeyBinding> CommandDic = new();
private static void KeyboardHook_KeyDown(object sender, KeyboardHookEventArgs e) => HitTest(e.Key); private static void KeyboardHook_KeyDown(object sender, KeyboardHookEventArgs e) => HitTest(e.Key);
@@ -21,7 +21,7 @@ namespace HandyControl.Tools
/// <returns></returns> /// <returns></returns>
public static ThicknessAnimation CreateAnimation(Thickness thickness = default, double milliseconds = 200) public static ThicknessAnimation CreateAnimation(Thickness thickness = default, double milliseconds = 200)
{ {
return new ThicknessAnimation(thickness, new Duration(TimeSpan.FromMilliseconds(milliseconds))) return new(thickness, new Duration(TimeSpan.FromMilliseconds(milliseconds)))
{ {
EasingFunction = new PowerEase { EasingMode = EasingMode.EaseInOut } EasingFunction = new PowerEase { EasingMode = EasingMode.EaseInOut }
}; };
@@ -35,7 +35,7 @@ namespace HandyControl.Tools
/// <returns></returns> /// <returns></returns>
public static DoubleAnimation CreateAnimation(double toValue, double milliseconds = 200) public static DoubleAnimation CreateAnimation(double toValue, double milliseconds = 200)
{ {
return new DoubleAnimation(toValue, new Duration(TimeSpan.FromMilliseconds(milliseconds))) return new(toValue, new Duration(TimeSpan.FromMilliseconds(milliseconds)))
{ {
EasingFunction = new PowerEase { EasingMode = EasingMode.EaseInOut } EasingFunction = new PowerEase { EasingMode = EasingMode.EaseInOut }
}; };
@@ -10,7 +10,7 @@ namespace HandyControl.Tools
/// </summary> /// </summary>
public class SingleOpenHelper public class SingleOpenHelper
{ {
private static readonly Dictionary<string, ISingleOpen> OpenDic = new Dictionary<string, ISingleOpen>(); private static readonly Dictionary<string, ISingleOpen> OpenDic = new();
/// <summary> /// <summary>
/// 根据指定的类型创建实例 /// 根据指定的类型创建实例
@@ -20,13 +20,13 @@ namespace HandyControl.Tools
/// <returns></returns> /// <returns></returns>
public static Window GetActiveWindow() => Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive); public static Window GetActiveWindow() => Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
private static readonly BitArray _cacheValid = new BitArray((int) InteropValues.CacheSlot.NumSlots); private static readonly BitArray _cacheValid = new((int) InteropValues.CacheSlot.NumSlots);
private static bool _setDpiX = true; private static bool _setDpiX = true;
private static bool _dpiInitialized; private static bool _dpiInitialized;
private static readonly object _dpiLock = new object(); private static readonly object _dpiLock = new();
private static int _dpi; private static int _dpi;
@@ -8,7 +8,7 @@ namespace HandyControl.Tools
{ {
public class SystemMenuHook public class SystemMenuHook
{ {
private static readonly Dictionary<int, HwndSource> DataDic = new Dictionary<int, HwndSource>(); private static readonly Dictionary<int, HwndSource> DataDic = new();
public static event Action<int> Click; public static event Action<int> Click;
@@ -30,13 +30,13 @@ namespace HandyControl.Tools.Interop
[SecurityCritical] [SecurityCritical]
internal HandleRef MakeHandleRef(object obj) internal HandleRef MakeHandleRef(object obj)
{ {
return new HandleRef(obj, handle); return new(obj, handle);
} }
[SecurityCritical] [SecurityCritical]
internal static BitmapHandle CreateFromHandle(IntPtr hbitmap, bool ownsHandle = true) internal static BitmapHandle CreateFromHandle(IntPtr hbitmap, bool ownsHandle = true)
{ {
return new BitmapHandle(ownsHandle) return new(ownsHandle)
{ {
handle = hbitmap, handle = hbitmap,
}; };
@@ -10,7 +10,7 @@ namespace HandyControl.Tools.Interop
private static HandleType[] HandleTypes; private static HandleType[] HandleTypes;
private static int HandleTypeCount; private static int HandleTypeCount;
private static readonly object HandleMutex = new object(); private static readonly object HandleMutex = new();
internal static IntPtr Add(IntPtr handle, int type) internal static IntPtr Add(IntPtr handle, int type)
{ {
@@ -21,7 +21,7 @@ namespace HandyControl.Tools.Interop
[SecurityCritical, SecuritySafeCritical] [SecurityCritical, SecuritySafeCritical]
internal static IconHandle GetInvalidIcon() internal static IconHandle GetInvalidIcon()
{ {
return new IconHandle(); return new();
} }
[SecurityCritical] [SecurityCritical]
@@ -19,7 +19,7 @@ namespace HandyControl.Tools.Interop
internal const int E_FAIL = unchecked((int) 0x80004005); internal const int E_FAIL = unchecked((int) 0x80004005);
internal static readonly IntPtr HRGN_NONE = new IntPtr(-1); internal static readonly IntPtr HRGN_NONE = new(-1);
[DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)] [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
[ResourceExposure(ResourceScope.None)] [ResourceExposure(ResourceScope.None)]
@@ -240,8 +240,8 @@ namespace HandyControl.Tools.Interop
Bottom = (int) rect.Bottom; Bottom = (int) rect.Bottom;
} }
public Point Position => new Point(Left, Top); public Point Position => new(Left, Top);
public Size Size => new Size(Width, Height); public Size Size => new(Width, Height);
public int Height public int Height
{ {
@@ -2,7 +2,7 @@
{ {
public class SynchronizedPool<T> : SimplePool<T> public class SynchronizedPool<T> : SimplePool<T>
{ {
private readonly object _lockObj = new object(); private readonly object _lockObj = new();
public SynchronizedPool(int maxPoolSize) : base(maxPoolSize) public SynchronizedPool(int maxPoolSize) : base(maxPoolSize)
{ {
@@ -9,7 +9,7 @@ namespace HandyControl.Tools
/// </summary> /// </summary>
public static class RegexJudgment public static class RegexJudgment
{ {
private static readonly RegexPatterns RegexPatterns = new RegexPatterns(); private static readonly RegexPatterns RegexPatterns = new();
/// <summary> /// <summary>
/// 判断字符串格式是否符合某种要求 /// 判断字符串格式是否符合某种要求