Skip to content

Commit 96c6c89

Browse files
committed
Modify message in error list
1 parent 15621b8 commit 96c6c89

17 files changed

+116
-131
lines changed

source/.editorconfig

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[*.cs]
2+
3+
# IDE0055: 修正格式
4+
dotnet_diagnostic.IDE0055.severity = none

source/Components/AvalonDock/Controls/LayoutAnchorableItem.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public class LayoutAnchorableItem : LayoutItem
3232
private ICommand _defaultHideCommand;
3333
private ICommand _defaultAutoHideCommand;
3434
private ICommand _defaultDockCommand;
35-
private ReentrantFlag _visibilityReentrantFlag = new ReentrantFlag();
36-
private ReentrantFlag _anchorableVisibilityReentrantFlag = new ReentrantFlag();
35+
private readonly ReentrantFlag _visibilityReentrantFlag = new ReentrantFlag();
36+
private readonly ReentrantFlag _anchorableVisibilityReentrantFlag = new ReentrantFlag();
3737
#endregion fields
3838

3939
#region Constructors

source/Components/AvalonDock/Controls/Shell/SystemParameters2.cs

+15-15
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class SystemParameters2 : INotifyPropertyChanged
2828
private delegate void _SystemMetricUpdate(IntPtr wParam, IntPtr lParam);
2929

3030
[ThreadStatic]
31-
private static SystemParameters2 _threadLocalSingleton;
31+
private static readonly SystemParameters2 _threadLocalSingleton;
3232

3333
private MessageWindow _messageHwnd;
3434

@@ -218,7 +218,7 @@ private void _InitializeThemeInfo()
218218
return;
219219
}
220220

221-
NativeMethods.GetCurrentThemeName(out var name, out var color, out var size);
221+
NativeMethods.GetCurrentThemeName(out var name, out var color, out _);
222222

223223
// Consider whether this is the most useful way to expose this...
224224
UxThemeName = System.IO.Path.GetFileNameWithoutExtension(name);
@@ -237,18 +237,18 @@ private void _InitializeWindowCornerRadius()
237237
// There aren't any known variations based on theme color.
238238
Assert.IsNeitherNullNorEmpty(UxThemeName);
239239

240-
// These radii are approximate. The way WPF does rounding is different than how
241-
// rounded-rectangle HRGNs are created, which is also different than the actual
242-
// round corners on themed Windows. For now we're not exposing anything to
243-
// mitigate the differences.
244-
var cornerRadius = default(CornerRadius);
245-
246-
// This list is known to be incomplete and very much not future-proof.
247-
// On XP there are at least a couple of shipped themes that this won't catch,
248-
// "Zune" and "Royale", but WPF doesn't know about these either.
249-
// If a new theme was to replace Aero, then this will fall back on "classic" behaviors.
250-
// This isn't ideal, but it's not the end of the world. WPF will generally have problems anyways.
251-
switch (UxThemeName.ToUpperInvariant())
240+
// These radii are approximate. The way WPF does rounding is different than how
241+
// rounded-rectangle HRGNs are created, which is also different than the actual
242+
// round corners on themed Windows. For now we're not exposing anything to
243+
// mitigate the differences.
244+
CornerRadius cornerRadius;
245+
246+
// This list is known to be incomplete and very much not future-proof.
247+
// On XP there are at least a couple of shipped themes that this won't catch,
248+
// "Zune" and "Royale", but WPF doesn't know about these either.
249+
// If a new theme was to replace Aero, then this will fall back on "classic" behaviors.
250+
// This isn't ideal, but it's not the end of the world. WPF will generally have problems anyways.
251+
switch (UxThemeName.ToUpperInvariant())
252252
{
253253
case "LUNA":
254254
cornerRadius = new CornerRadius(6, 6, 0, 0);
@@ -331,7 +331,7 @@ private SystemParameters2()
331331
};
332332
}
333333

334-
public static SystemParameters2 Current => _threadLocalSingleton ?? (_threadLocalSingleton = new SystemParameters2());
334+
public static SystemParameters2 Current => _threadLocalSingleton ?? new SystemParameters2();
335335

336336
private IntPtr _WndProc(IntPtr hwnd, WM msg, IntPtr wParam, IntPtr lParam)
337337
{

source/Components/AvalonDock/Controls/Shell/WindowChromeWorker.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ internal class WindowChromeWorker : DependencyObject
4848
private bool _isFixedUp = false;
4949
private bool _isUserResizing = false;
5050
private bool _hasUserMovedWindow = false;
51-
private Point _windowPosAtStartOfUserMove = default(Point);
51+
private Point _windowPosAtStartOfUserMove = default;
5252

5353
// Field to track attempts to force off Device Bitmaps on Win7.
5454
private int _blackGlassFixupAttemptCount;
@@ -424,7 +424,7 @@ private IntPtr _HandleNCHitTest(WM uMsg, IntPtr wParam, IntPtr lParam, out bool
424424
handled = false;
425425

426426
// Give DWM a chance at this first.
427-
if (Utility.IsOSVistaOrNewer && _chromeInfo.GlassFrameThickness != default(Thickness) && _isGlassEnabled)
427+
if (Utility.IsOSVistaOrNewer && _chromeInfo.GlassFrameThickness != default && _isGlassEnabled)
428428
{
429429
// If we're on Vista, give the DWM a chance to handle the message first.
430430
handled = NativeMethods.DwmDefWindowProc(_hwnd, uMsg, wParam, lParam, out lRet);
@@ -686,7 +686,7 @@ private void _UpdateFrameState(bool force)
686686
var frameState = NativeMethods.DwmIsCompositionEnabled();
687687

688688
if (!force && frameState == _isGlassEnabled) return;
689-
_isGlassEnabled = frameState && _chromeInfo.GlassFrameThickness != default(Thickness);
689+
_isGlassEnabled = frameState && _chromeInfo.GlassFrameThickness != default;
690690

691691
if (_isGlassEnabled)
692692
{

source/Components/AvalonDock/Converters/ActivateCommandLayoutItemFromLayoutModelConverter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public class ActivateCommandLayoutItemFromLayoutModelConverter : MarkupExtension
3434
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
3535
{
3636
//when this converter is called layout could be constructing so many properties here are potentially not valid
37-
var layoutModel = value as LayoutContent;
38-
if (layoutModel == null)
37+
if (!(value is LayoutContent layoutModel))
3938
return null;
4039

4140
if (layoutModel.Root == null)

source/Components/AvalonDock/Converters/AnchorableContextMenuHideVisibilityConverter.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
4646
if ((values.Count() == 2)
4747
&& (values[0] != DependencyProperty.UnsetValue)
4848
&& (values[1] != DependencyProperty.UnsetValue)
49-
&& (values[1] is bool))
49+
&& (values[1] is bool boolean))
5050
{
51-
var canClose = (bool)values[1];
51+
var canClose = boolean;
5252

5353
return canClose ? Visibility.Collapsed : values[0];
5454
}

source/Components/AvalonDock/Converters/AutoHideCommandLayoutItemFromLayoutModelConverter.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,16 @@ public class AutoHideCommandLayoutItemFromLayoutModelConverter : MarkupExtension
3737
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
3838
{
3939
//when this converter is called layout could be constructing so many properties here are potentially not valid
40-
var layoutModel = value as LayoutContent;
41-
if (layoutModel == null)
40+
if (value as LayoutContent == null)
4241
return null;
4342

44-
if (layoutModel.Root == null)
43+
if ((value as LayoutContent).Root == null)
4544
return null;
4645

47-
if (layoutModel.Root.Manager == null)
46+
if ((value as LayoutContent).Root.Manager == null)
4847
return null;
4948

50-
var layoutItemModel = layoutModel.Root.Manager.GetLayoutItemFromModel(layoutModel) as LayoutAnchorableItem;
51-
if (layoutItemModel == null)
49+
if (!((value as LayoutContent).Root.Manager.GetLayoutItemFromModel(value as LayoutContent) is LayoutAnchorableItem layoutItemModel))
5250
return Binding.DoNothing;
5351

5452
return layoutItemModel.AutoHideCommand;

source/Components/AvalonDock/Converters/HideCommandLayoutItemFromLayoutModelConverter.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public class HideCommandLayoutItemFromLayoutModelConverter : MarkupExtension, IV
3737
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
3838
{
3939
//when this converter is called layout could be constructing so many properties here are potentially not valid
40-
var layoutModel = value as LayoutContent;
41-
if (layoutModel == null)
40+
if (!(value is LayoutContent layoutModel))
4241
return null;
4342

4443
if (layoutModel.Root == null)
@@ -47,8 +46,7 @@ public object Convert(object value, Type targetType, object parameter, System.Gl
4746
if (layoutModel.Root.Manager == null)
4847
return null;
4948

50-
var layoutItemModel = layoutModel.Root.Manager.GetLayoutItemFromModel(layoutModel) as LayoutAnchorableItem;
51-
if (layoutItemModel == null)
49+
if (!(layoutModel.Root.Manager.GetLayoutItemFromModel(layoutModel) is LayoutAnchorableItem layoutItemModel))
5250
return Binding.DoNothing;
5351

5452
return layoutItemModel.HideCommand;

source/Components/AvalonDock/Converters/LayoutItemFromLayoutModelConverter.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public class LayoutItemFromLayoutModelConverter : MarkupExtension, IValueConvert
3535
/// <returns>A converted value.</returns>
3636
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
3737
{
38-
var layoutModel = value as LayoutContent;
39-
if (layoutModel == null)
38+
if (!(value is LayoutContent layoutModel))
4039
return null;
4140

4241
if (layoutModel.Root == null)
@@ -45,11 +44,10 @@ public object Convert(object value, Type targetType, object parameter, System.Gl
4544
if (layoutModel.Root.Manager == null)
4645
return null;
4746

48-
var layoutItemModel = layoutModel.Root.Manager.GetLayoutItemFromModel(layoutModel);
49-
if (layoutItemModel == null)
47+
if (layoutModel.Root.Manager.GetLayoutItemFromModel(layoutModel) == null)
5048
return Binding.DoNothing;
5149

52-
return layoutItemModel;
50+
return layoutModel.Root.Manager.GetLayoutItemFromModel(layoutModel);
5351
}
5452

5553
/// <summary>

source/Components/AvalonDock/Layout/LayoutAnchorable.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,11 @@ public void ToggleAutoHide()
485485
case AnchorSide.Bottom:
486486
if (parentGroup.Root.RootPanel.Orientation == Orientation.Vertical)
487487
{
488-
previousContainer = new LayoutAnchorablePane();
489-
previousContainer.DockMinHeight = AutoHideMinHeight;
490-
parentGroup.Root.RootPanel.Children.Add(previousContainer);
488+
previousContainer = new LayoutAnchorablePane
489+
{
490+
DockMinHeight = AutoHideMinHeight
491+
};
492+
parentGroup.Root.RootPanel.Children.Add(previousContainer);
491493
}
492494
else
493495
{

source/Components/AvalonDock/Layout/LayoutRoot.cs

+12-15
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ public void CollectGarbage()
367367
foreach (var contentReferencingEmptyPane in this.Descendents().OfType<LayoutContent>()
368368
.Where(c => ((ILayoutPreviousContainer)c).PreviousContainer == emptyPane && !c.IsFloating))
369369
{
370-
if (contentReferencingEmptyPane is LayoutAnchorable &&
371-
!((LayoutAnchorable)contentReferencingEmptyPane).IsVisible)
370+
if (contentReferencingEmptyPane is LayoutAnchorable anchorable &&
371+
!anchorable.IsVisible)
372372
continue;
373373

374374
((ILayoutPreviousContainer)contentReferencingEmptyPane).PreviousContainer = null;
@@ -850,15 +850,13 @@ private List<object> ReadElementList(XmlReader reader, bool isFloatingWindow)
850850
{
851851
if (isFloatingWindow)
852852
{
853-
var result = ReadElement(reader) as LayoutFloatingWindow;
854-
if (result == null) break;
855-
resultList.Add(result);
853+
if (!(ReadElement(reader) is LayoutFloatingWindow result)) break;
854+
resultList.Add(result);
856855
}
857856
else
858857
{
859-
var result = ReadElement(reader) as LayoutAnchorable;
860-
if (result == null) break;
861-
resultList.Add(result);
858+
if (!(ReadElement(reader) is LayoutAnchorable result)) break;
859+
resultList.Add(result);
862860
}
863861
}
864862

@@ -937,13 +935,12 @@ void DumpElement(ILayoutElement element, StringBuilder indent, int childID, bool
937935
Debug.Write($"{indent}{(indent.Length > 0 ? isLastChild ? " └─ " : " ├─ " : "")}{childID:D2} 0x{element.GetHashCode():X8} " +
938936
$"{element.GetType().Name} {(shortPropertyNames ? "P" : "Parent")}:0x{element.Parent?.GetHashCode() ?? 0:X8} " +
939937
$"{(shortPropertyNames ? "R" : "Root")}:0x{element.Root?.GetHashCode() ?? 0:X8}");
940-
var containerElement = element as ILayoutContainer;
941-
if (containerElement == null)
942-
{
943-
Debug.WriteLine("");
944-
return;
945-
}
946-
Debug.WriteLine($" {(shortPropertyNames ? "C" : "Children")}:{containerElement.ChildrenCount}");
938+
if (!(element is ILayoutContainer containerElement))
939+
{
940+
Debug.WriteLine("");
941+
return;
942+
}
943+
Debug.WriteLine($" {(shortPropertyNames ? "C" : "Children")}:{containerElement.ChildrenCount}");
947944
var nrChild = 0;
948945
indent.Append(isLastChild ? " " : " │ ");
949946
foreach (var child in containerElement.Children)

source/MLibTest/MLibTest/App.xaml.cs

+38-45
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,10 @@ private void Application_Startup(object sender, StartupEventArgs e)
116116
// Save session data and close application
117117
OnClosed(_appVM, _mainWindow);
118118

119-
var dispose = _appVM as IDisposable;
120-
if (dispose != null)
121-
dispose.Dispose();
119+
if (_appVM is IDisposable dispose)
120+
dispose.Dispose();
122121

123-
_mainWindow.DataContext = null;
122+
_mainWindow.DataContext = null;
124123
};
125124

126125
MainWindow.Show();
@@ -165,14 +164,13 @@ private void ConstructMainWindowSession(AppViewModel workSpace,
165164
Application.Current.MainWindow = _mainWindow;
166165
_mainWindow.DataContext = _appVM;
167166

168-
// Establish command binding to accept user input via commanding framework
169-
// workSpace.InitCommandBinding(win);
167+
// Establish command binding to accept user input via commanding framework
168+
// workSpace.InitCommandBinding(win);
170169

171-
ViewPosSizeModel viewSz;
172-
settings.SessionData.WindowPosSz.TryGetValue(settings.SessionData.MainWindowName
173-
, out viewSz);
170+
settings.SessionData.WindowPosSz.TryGetValue(settings.SessionData.MainWindowName
171+
, out ViewPosSizeModel viewSz);
174172

175-
viewSz.SetWindowsState(win);
173+
viewSz.SetWindowsState(win);
176174

177175
string lastActiveFile = settings.SessionData.LastActiveSolution;
178176

@@ -193,37 +191,33 @@ private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
193191
{
194192
try
195193
{
196-
AppViewModel wsVM = base.MainWindow.DataContext as AppViewModel;
197-
198-
if (wsVM != null)
199-
{
200-
var MainWindowCanClose = MainWindow as IMetroWindow;
201-
202-
if (MainWindowCanClose != null)
203-
{
204-
if (MainWindowCanClose.IsContentDialogVisible == true)
205-
{
206-
e.Cancel = true; // Lets not close with open dialog
207-
return;
208-
}
209-
}
210-
211-
// Close all open files and check whether application is ready to close
212-
if (wsVM.AppLifeCycle.Exit_CheckConditions(wsVM) == true)
213-
{
214-
// (other than exception and error handling)
215-
wsVM.AppLifeCycle.OnRequestClose(true);
216-
217-
_mainWindow.OnSaveLayout();
218-
e.Cancel = false;
219-
}
220-
else
221-
{
222-
wsVM.AppLifeCycle.CancelShutDown();
223-
e.Cancel = true;
224-
}
225-
}
226-
}
194+
if (base.MainWindow.DataContext is AppViewModel wsVM)
195+
{
196+
if (MainWindow is IMetroWindow MainWindowCanClose)
197+
{
198+
if (MainWindowCanClose.IsContentDialogVisible == true)
199+
{
200+
e.Cancel = true; // Lets not close with open dialog
201+
return;
202+
}
203+
}
204+
205+
// Close all open files and check whether application is ready to close
206+
if (wsVM.AppLifeCycle.Exit_CheckConditions(wsVM) == true)
207+
{
208+
// (other than exception and error handling)
209+
wsVM.AppLifeCycle.OnRequestClose(true);
210+
211+
_mainWindow.OnSaveLayout();
212+
e.Cancel = false;
213+
}
214+
else
215+
{
216+
wsVM.AppLifeCycle.CancelShutDown();
217+
e.Cancel = true;
218+
}
219+
}
220+
}
227221
catch (Exception exp)
228222
{
229223
Debug.WriteLine(exp);
@@ -241,10 +235,9 @@ private void OnClosed(AppViewModel appVM, IViewSize win)
241235
{
242236
var settings = GetService<ISettingsManager>();
243237

244-
ViewPosSizeModel viewSz;
245-
settings.SessionData.WindowPosSz.TryGetValue(settings.SessionData.MainWindowName
246-
, out viewSz);
247-
viewSz.GetWindowsState(win);
238+
settings.SessionData.WindowPosSz.TryGetValue(settings.SessionData.MainWindowName
239+
, out ViewPosSizeModel viewSz);
240+
viewSz.GetWindowsState(win);
248241

249242
_appVM.GetSessionData(settings.SessionData);
250243

source/MLibTest/MLibTest/Demos/ViewModels/Tools/ColorPickerViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal class ColorPickerViewModel : ToolViewModel
2828
/// </summary>
2929
public const string ToolTitle = "Color Picker";
3030

31-
private IWorkSpaceViewModel _workSpaceViewModel = null;
31+
private readonly IWorkSpaceViewModel _workSpaceViewModel = null;
3232

3333
private Color _SelectedBackgroundColor;
3434
private Color _SelectedAccentColor;

source/MLibTest/MLibTest/Demos/ViewModels/Tools/FileStatsViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class FileStatsViewModel : ToolViewModel
2222
/// </summary>
2323
public const string ToolTitle = "File Stats";
2424

25-
private IWorkSpaceViewModel _workSpaceViewModel = null;
25+
private readonly IWorkSpaceViewModel _workSpaceViewModel = null;
2626

2727
private DateTime _lastModified;
2828
private long _fileSize;

source/MLibTest/MLibTest_Components/Settings/Settings/Settings.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106
<Compile Include="UserProfile\ViewSize.cs" />
107107
</ItemGroup>
108108
<ItemGroup>
109+
<None Include="..\..\..\..\.editorconfig">
110+
<Link>.editorconfig</Link>
111+
</None>
109112
<None Include="packages.config" />
110113
</ItemGroup>
111114
<ItemGroup>

0 commit comments

Comments
 (0)