feat: remove more warnings.

This commit is contained in:
rabbitism
2024-07-30 18:48:59 +08:00
parent 15fb5a2d1b
commit 12e9e728d2
7 changed files with 24 additions and 27 deletions

2
Ursa.sln.DotSettings Normal file
View File

@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=axaml/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@@ -22,7 +22,7 @@ public partial class MainWindow : Window
} }
// ReSharper disable once UnusedParameter.Local // ReSharper disable once UnusedParameter.Local
private void OverlayDialogButton_OnClick(object? sender, RoutedEventArgs e) private void OverlayDialogButton_OnClick(object? sender, RoutedEventArgs _)
{ {
_overlayDialogService.ShowModal("Default", null, null, new OverlayDialogOptions() _overlayDialogService.ShowModal("Default", null, null, new OverlayDialogOptions()
{ {
@@ -31,7 +31,7 @@ public partial class MainWindow : Window
} }
// ReSharper disable once UnusedParameter.Local // ReSharper disable once UnusedParameter.Local
private void AloneDialogButton_OnClick(object? sender, RoutedEventArgs e) private void AloneDialogButton_OnClick(object? sender, RoutedEventArgs _)
{ {
_aloneDialogService.ShowModal("Default", null, null, new DialogOptions() _aloneDialogService.ShowModal("Default", null, null, new DialogOptions()
{ {
@@ -40,7 +40,7 @@ public partial class MainWindow : Window
} }
// ReSharper disable once UnusedParameter.Local // ReSharper disable once UnusedParameter.Local
private void DrawerButton_OnClick(object? sender, RoutedEventArgs e) private void DrawerButton_OnClick(object? sender, RoutedEventArgs _)
{ {
_drawerService.ShowModal("Default", null, null, new DrawerOptions() _drawerService.ShowModal("Default", null, null, new DrawerOptions()
{ {

View File

@@ -139,11 +139,12 @@ public class ControlClassesInput: TemplatedControl
public void UnDo() public void UnDo()
{ {
var node = _history.Last; var node = _history.Last;
if (node is null) return;
_history.RemoveLast(); _history.RemoveLast();
_undoHistory.AddFirst(node); _undoHistory.AddFirst(node.Value);
_disableHistory = true; _disableHistory = true;
TargetClasses?.Clear(); TargetClasses?.Clear();
foreach (var value in _history.Last.Value) foreach (var value in node.Value)
{ {
TargetClasses?.Add(value); TargetClasses?.Add(value);
} }
@@ -154,11 +155,12 @@ public class ControlClassesInput: TemplatedControl
public void Redo() public void Redo()
{ {
var node = _undoHistory.First; var node = _undoHistory.First;
if (node is null) return;
_undoHistory.RemoveFirst(); _undoHistory.RemoveFirst();
_history.AddLast(node); _history.AddLast(node);
_disableHistory = true; _disableHistory = true;
TargetClasses?.Clear(); TargetClasses?.Clear();
foreach (var value in _history.Last.Value) foreach (var value in node.Value)
{ {
TargetClasses?.Add(value); TargetClasses?.Add(value);
} }
@@ -168,6 +170,6 @@ public class ControlClassesInput: TemplatedControl
public void Clear() public void Clear()
{ {
SaveHistory(new List<string>(), false); SaveHistory([], false);
} }
} }

View File

@@ -260,10 +260,7 @@ public class CalendarView : TemplatedControl
ContextDate = ContextDate.With(startYear: range.start, endYear: range.end); ContextDate = ContextDate.With(startYear: range.start, endYear: range.end);
_dateContextSyncing = false; _dateContextSyncing = false;
UpdateYearButtons(); UpdateYearButtons();
return;
} }
if (Mode == CalendarViewMode.Century) return;
} }
/// <summary> /// <summary>

View File

@@ -310,7 +310,7 @@ public class DateRangePicker : DatePickerBase, IClearControl
private void OnTextChangedInternal(TextBox? textBox, AvaloniaProperty property, bool fromText = false) private void OnTextChangedInternal(TextBox? textBox, AvaloniaProperty property, bool fromText = false)
{ {
if (string.IsNullOrEmpty(textBox?.Text)) if (textBox?.Text is null || string.IsNullOrEmpty(textBox.Text))
{ {
SetCurrentValue(property, null); SetCurrentValue(property, null);
_startCalendar?.ClearSelection(); _startCalendar?.ClearSelection();

View File

@@ -132,11 +132,7 @@ public class IPv4Box: TemplatedControl
protected override void OnKeyDown(KeyEventArgs e) protected override void OnKeyDown(KeyEventArgs e)
{ {
if (_currentActivePresenter is null) _currentActivePresenter ??= _presenters[0];
{
_currentActivePresenter = _presenters[0];
}
var keymap = TopLevel.GetTopLevel(this)?.PlatformSettings?.HotkeyConfiguration; var keymap = TopLevel.GetTopLevel(this)?.PlatformSettings?.HotkeyConfiguration;
bool Match(List<KeyGesture> gestures) => gestures.Any(g => g.Matches(e)); bool Match(List<KeyGesture> gestures) => gestures.Any(g => g.Matches(e));
if (e.Key is Key.Enter or Key.Return) if (e.Key is Key.Enter or Key.Return)
@@ -220,7 +216,7 @@ public class IPv4Box: TemplatedControl
{ {
if (e.Handled) return; if (e.Handled) return;
var s = e.Text; var s = e.Text;
if (string.IsNullOrEmpty(s)) return; if (s is null || string.IsNullOrEmpty(s)) return;
if (s == ".") if (s == ".")
{ {
_currentActivePresenter?.HideCaret(); _currentActivePresenter?.HideCaret();
@@ -446,7 +442,7 @@ public class IPv4Box: TemplatedControl
private void DeleteImplementation(TextPresenter? presenter) private void DeleteImplementation(TextPresenter? presenter)
{ {
if(presenter is null) return; if(presenter is null) return;
var oldText = presenter.Text; var oldText = presenter.Text ?? string.Empty;
if (presenter.SelectionStart != presenter.SelectionEnd) if (presenter.SelectionStart != presenter.SelectionEnd)
{ {
presenter.DeleteSelection(); presenter.DeleteSelection();

View File

@@ -271,7 +271,7 @@ public class TimeBox : TemplatedControl
{ {
if (e.Handled) return; if (e.Handled) return;
string? s = e.Text; string? s = e.Text;
if (string.IsNullOrEmpty(s)) return; if (s is null || string.IsNullOrEmpty(s)) return;
if (!char.IsNumber(s[0])) return; if (!char.IsNumber(s[0])) return;
if (_currentActiveSectionIndex is null) return; if (_currentActiveSectionIndex is null) return;
@@ -413,7 +413,7 @@ public class TimeBox : TemplatedControl
private void ParseTimeSpan(bool showLeadingZero, bool skipParseFromText = false) private void ParseTimeSpan(bool showLeadingZero, bool skipParseFromText = false)
{ {
string format = showLeadingZero ? "D2" : ""; string format = showLeadingZero ? "D2" : "";
string millisecondformat = showLeadingZero ? "D3" : ""; string millisecondFormat = showLeadingZero ? "D3" : "";
if (!skipParseFromText) if (!skipParseFromText)
{ {
@@ -428,7 +428,7 @@ public class TimeBox : TemplatedControl
_hourText?.SetValue(TextPresenter.TextProperty, _values[0].ToString(format)); _hourText?.SetValue(TextPresenter.TextProperty, _values[0].ToString(format));
_minuteText?.SetValue(TextPresenter.TextProperty, _values[1].ToString(format)); _minuteText?.SetValue(TextPresenter.TextProperty, _values[1].ToString(format));
_secondText?.SetValue(TextPresenter.TextProperty, _values[2].ToString(format)); _secondText?.SetValue(TextPresenter.TextProperty, _values[2].ToString(format));
_milliSecondText?.SetValue(TextPresenter.TextProperty, _values[3].ToString(millisecondformat)); _milliSecondText?.SetValue(TextPresenter.TextProperty, _values[3].ToString(millisecondFormat));
} }
private void OnDragPanelPointerMoved(object? sender, PointerEventArgs e) private void OnDragPanelPointerMoved(object? sender, PointerEventArgs e)
@@ -479,14 +479,14 @@ public class TimeBox : TemplatedControl
/// <summary> /// <summary>
/// Set dragPanel IsVisible to false if AllowDrag is true, and select all text in the section /// Set dragPanel IsVisible to false if AllowDrag is true, and select all text in the section
/// </summary> /// </summary>
/// <param name="index">The index of section that will be enter</param> /// <param name="index">The index of section that will be entered</param>
private void EnterSection(int index) private void EnterSection(int index)
{ {
if (index < 0 || index > 3) return; if (index < 0 || index > 3) return;
if (AllowDrag) if (AllowDrag)
_dragPanels[index].IsVisible = false; _dragPanels[index].IsVisible = false;
ShowCaretInteral(index); ShowCaretInternal(index);
_presenters[index].SelectAll(); _presenters[index].SelectAll();
} }
@@ -494,7 +494,7 @@ public class TimeBox : TemplatedControl
{ {
if (!_isShowedCaret[index]) if (!_isShowedCaret[index])
{ {
ShowCaretInteral(index); ShowCaretInternal(index);
} }
_presenters[index].ClearSelection(); _presenters[index].ClearSelection();
var caretPosition = var caretPosition =
@@ -512,7 +512,7 @@ public class TimeBox : TemplatedControl
_presenters[index].ClearSelection(); _presenters[index].ClearSelection();
if (_isShowedCaret[index]) if (_isShowedCaret[index])
{ {
HideCaretInteral(index); HideCaretInternal(index);
} }
if (AllowDrag) if (AllowDrag)
@@ -703,13 +703,13 @@ public class TimeBox : TemplatedControl
return milliSecond; return milliSecond;
} }
private void ShowCaretInteral(int index) private void ShowCaretInternal(int index)
{ {
_presenters[index].ShowCaret(); _presenters[index].ShowCaret();
_isShowedCaret[index] = true; _isShowedCaret[index] = true;
} }
private void HideCaretInteral(int index) private void HideCaretInternal(int index)
{ {
_presenters[index].HideCaret(); _presenters[index].HideCaret();
_isShowedCaret[index] = false; _isShowedCaret[index] = false;