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
private void OverlayDialogButton_OnClick(object? sender, RoutedEventArgs e)
private void OverlayDialogButton_OnClick(object? sender, RoutedEventArgs _)
{
_overlayDialogService.ShowModal("Default", null, null, new OverlayDialogOptions()
{
@@ -31,7 +31,7 @@ public partial class MainWindow : Window
}
// 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()
{
@@ -40,7 +40,7 @@ public partial class MainWindow : Window
}
// 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()
{

View File

@@ -139,11 +139,12 @@ public class ControlClassesInput: TemplatedControl
public void UnDo()
{
var node = _history.Last;
if (node is null) return;
_history.RemoveLast();
_undoHistory.AddFirst(node);
_undoHistory.AddFirst(node.Value);
_disableHistory = true;
TargetClasses?.Clear();
foreach (var value in _history.Last.Value)
foreach (var value in node.Value)
{
TargetClasses?.Add(value);
}
@@ -154,11 +155,12 @@ public class ControlClassesInput: TemplatedControl
public void Redo()
{
var node = _undoHistory.First;
if (node is null) return;
_undoHistory.RemoveFirst();
_history.AddLast(node);
_disableHistory = true;
TargetClasses?.Clear();
foreach (var value in _history.Last.Value)
foreach (var value in node.Value)
{
TargetClasses?.Add(value);
}
@@ -168,6 +170,6 @@ public class ControlClassesInput: TemplatedControl
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);
_dateContextSyncing = false;
UpdateYearButtons();
return;
}
if (Mode == CalendarViewMode.Century) return;
}
/// <summary>

View File

@@ -310,7 +310,7 @@ public class DateRangePicker : DatePickerBase, IClearControl
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);
_startCalendar?.ClearSelection();

View File

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

View File

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