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

@@ -60,6 +60,6 @@ namespace HandyControl.Controls
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 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;
@@ -101,7 +101,7 @@ namespace HandyControl.Controls
/// <summary>
/// 预设的颜色(一共18个,两行)
/// </summary>
private readonly List<string> _colorPresetList = new List<string>
private readonly List<string> _colorPresetList = new()
{
"#f44336",
"#e91e63",
@@ -127,7 +127,7 @@ namespace HandyControl.Controls
/// <summary>
/// 颜色范围集合
/// </summary>
private readonly List<ColorRange> _colorRangeList = new List<ColorRange>
private readonly List<ColorRange> _colorRangeList = new()
{
new ColorRange
{
@@ -164,7 +164,7 @@ namespace HandyControl.Controls
/// <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, 255),
@@ -69,12 +69,12 @@ namespace HandyControl.Controls
/// <summary>
/// 存储所有的内容
/// </summary>
private readonly Dictionary<int, object> _contentDic = new Dictionary<int, object>();
private readonly Dictionary<int, object> _contentDic = new();
/// <summary>
/// 当前在显示范围内的项
/// </summary>
private readonly Dictionary<int, CoverFlowItem> _itemShowDic = new Dictionary<int, CoverFlowItem>();
private readonly Dictionary<int, CoverFlowItem> _itemShowDic = new();
/// <summary>
/// 相机
@@ -72,12 +72,12 @@ namespace HandyControl.Controls
var textureCoordinates = new PointCollection
{
new Point(0, 1),
new Point(1, 1),
new Point(1, 0),
new Point(0, 0),
new Point(1, 0),
new Point(1, 1)
new(0, 1),
new(1, 1),
new(1, 0),
new(0, 0),
new(1, 0),
new(1, 1)
};
var normals = new Vector3DCollection
@@ -16,7 +16,7 @@ namespace HandyControl.Controls
private IEnumerable _itemsSourceInternal;
private readonly Dictionary<object, CoverViewItem> _entryDic = new Dictionary<object, CoverViewItem>();
private readonly Dictionary<object, CoverViewItem> _entryDic = new();
private bool _isRefresh;
@@ -16,7 +16,7 @@ namespace HandyControl.Controls
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(
"IsClosed", typeof(bool), typeof(Dialog), new PropertyMetadata(ValueBoxes.FalseBox));
@@ -19,9 +19,9 @@ namespace HandyControl.Controls
{
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;
@@ -48,7 +48,7 @@ namespace HandyControl.Controls
/// <summary>
/// 图片保存对话框
/// </summary>
private static readonly SaveFileDialog SaveFileDialog = new SaveFileDialog
private static readonly SaveFileDialog SaveFileDialog = new()
{
Filter = $"{Lang.PngImg}|*.png"
};
@@ -62,7 +62,7 @@ namespace HandyControl.Controls
"DotDelayTime", typeof(double), typeof(LoadingBase),
new FrameworkPropertyMetadata(80.0, FrameworkPropertyMetadataOptions.AffectsRender));
protected readonly Canvas PrivateCanvas = new Canvas
protected readonly Canvas PrivateCanvas = new()
{
ClipToBounds = true
};
@@ -134,9 +134,9 @@ namespace HandyControl.Controls
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,
Math.Max(0.0, rt.Width - thick.Left - thick.Right),
Math.Max(0.0, rt.Height - thick.Top - thick.Bottom));
@@ -18,7 +18,7 @@ namespace HandyControl.Controls
private const string ElementVisualBrush = "PART_VisualBrush";
private VisualBrush _visualBrush = new VisualBrush();
private VisualBrush _visualBrush = new();
private readonly TranslateTransform _translateTransform;
@@ -40,7 +40,7 @@ namespace HandyControl.Controls
set => SetValue(VerticalOffsetProperty, value);
}
public static Magnifier Default => new Magnifier();
public static Magnifier Default => new();
public static readonly DependencyProperty ScaleProperty = DependencyProperty.Register(
"Scale", typeof(double), typeof(Magnifier), new PropertyMetadata(5.0, OnScaleChanged), ValidateHelper.IsInRangeOfPosDouble);
@@ -22,7 +22,7 @@ namespace HandyControl.Controls
private bool _added;
private readonly object _syncObj = new object();
private readonly object _syncObj = new();
private readonly int _id;
@@ -58,7 +58,7 @@ namespace HandyControl.Controls
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()
{
@@ -383,7 +383,7 @@ namespace HandyControl.Controls
private RadioButton CreateButton(int page)
{
return new RadioButton
return new()
{
Style = ResourceHelper.GetResourceInternal<Style>(ResourceToken.PaginationButtonStyle),
Content = page.ToString()
@@ -148,7 +148,7 @@ namespace HandyControl.Controls
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)
{
@@ -16,7 +16,7 @@ namespace HandyControl.Controls
private int _lineCount;
private readonly List<FlexItemInfo> _orderList = new List<FlexItemInfo>();
private readonly List<FlexItemInfo> _orderList = new();
#region Item
@@ -33,7 +33,7 @@ namespace HandyControl.Controls
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 =
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),
DisplayName = PropertyResolver.ResolveDisplayName(propertyDescriptor),
@@ -10,7 +10,7 @@ namespace HandyControl.Controls
{
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(sbyte)] = EditorTypeCode.SByteNumber,
@@ -33,7 +33,7 @@ namespace HandyControl.Controls
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
@@ -20,7 +20,7 @@ namespace HandyControl.Controls
/// <summary>
/// 选项卡字典
/// </summary>
internal Dictionary<int, TabItem> ItemDic = new Dictionary<int, TabItem>();
internal Dictionary<int, TabItem> ItemDic = new();
public static readonly DependencyPropertyKey FluidMoveDurationPropertyKey =
DependencyProperty.RegisterReadOnly("FluidMoveDuration", typeof(Duration), typeof(TabPanel),
@@ -240,10 +240,10 @@ namespace HandyControl.Controls
var positions = new Point3DCollection
{
new Point3D(-quarterWidth * flag, quarterHeight, 0),
new Point3D(-quarterWidth * flag, 0, 0),
new Point3D(quarterWidth * flag, 0, 0),
new Point3D(quarterWidth * flag, quarterHeight, 0)
new(-quarterWidth * flag, quarterHeight, 0),
new(-quarterWidth * flag, 0, 0),
new(quarterWidth * flag, 0, 0),
new(quarterWidth * flag, quarterHeight, 0)
};
var triangleIndices = new Int32Collection
@@ -258,10 +258,10 @@ namespace HandyControl.Controls
var textureCoordinates = new PointCollection
{
new Point(0, 0),
new Point(0, 1),
new Point(1, 1),
new Point(1, 0)
new(0, 0),
new(0, 1),
new(1, 1),
new(1, 0)
};
var geometry3D = new MeshGeometry3D
@@ -150,7 +150,7 @@ namespace HandyControl.Controls
/// <summary>
/// 刻度集合
/// </summary>
private readonly List<SpeTextBlock> _speBlockList = new List<SpeTextBlock>();
private readonly List<SpeTextBlock> _speBlockList = new();
/// <summary>
/// 初始化时时间
@@ -160,7 +160,7 @@ namespace HandyControl.Controls
/// <summary>
/// 时间段集合
/// </summary>
private readonly List<int> _timeSpeList = new List<int>
private readonly List<int> _timeSpeList = new()
{
7200000,
3600000,
@@ -22,9 +22,9 @@ namespace HandyControl.Controls
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;