feat: clean up warnings.

This commit is contained in:
rabbitism
2024-07-30 18:33:30 +08:00
parent e1f91f612b
commit 15fb5a2d1b
167 changed files with 473 additions and 825 deletions

View File

@@ -1,6 +1,5 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core;
using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using Sandbox.ViewModels;

View File

@@ -1,9 +1,6 @@
using Foundation;
using UIKit;
using Avalonia;
using Avalonia.Controls;
using Avalonia.iOS;
using Avalonia.Media;
namespace Ursa.Demo.iOS;

View File

@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Avalonia;
using Avalonia.Controls.Shapes;
using Avalonia.Data.Converters;
using Avalonia.Media;
using Avalonia.Metadata;
@@ -25,7 +23,7 @@ public class IconNameConverter: IValueConverter
return AvaloniaProperty.UnsetValue;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

View File

@@ -1,7 +1,6 @@
using System;
using System.Globalization;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data.Converters;
using Avalonia.Media;
@@ -9,7 +8,7 @@ namespace Ursa.Demo.Converters;
public class IconNameToPathConverter: IValueConverter
{
private string[] paths = new[]
private readonly string[] _paths = new[]
{
"M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z",
"M16 12L9 2L2 12H3.86L0 18H7V22H11V18H18L14.14 12H16M20.14 12H22L15 2L12.61 5.41L17.92 13H15.97L19.19 18H24L20.14 12M13 19H17V22H13V19Z",
@@ -19,23 +18,23 @@ public class IconNameToPathConverter: IValueConverter
"M16.67,4H15V2H9V4H7.33A1.33,1.33 0 0,0 6,5.33V20.67C6,21.4 6.6,22 7.33,22H16.67A1.33,1.33 0 0,0 18,20.67V5.33C18,4.6 17.4,4 16.67,4Z",
"M12 2C6.5 2 2 6.5 2 12C2 17.5 6.5 22 12 22C17.5 22 22 17.5 22 12S17.5 2 12 2M12.5 13H11V7H12.5V11.3L16.2 9.2L17 10.5L12.5 13Z"
};
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is int i)
{
string s = paths[i % paths.Length];
var s = _paths[i % _paths.Length];
return StreamGeometry.Parse(s);
}
else if (value is string s)
{
int hash = s.GetHashCode();
string path = paths[Math.Abs(hash) % paths.Length];
var hash = s.GetHashCode();
var path = _paths[Math.Abs(hash) % _paths.Length];
return StreamGeometry.Parse(path);
}
return AvaloniaProperty.UnsetValue;
return AvaloniaProperty.UnsetValue;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
return AvaloniaProperty.UnsetValue;
}

View File

@@ -1,7 +1,6 @@
using System;
using System.Globalization;
using Avalonia;
using Avalonia.Data;
using Avalonia.Data.Converters;
using Avalonia.Media;
using Ursa.Controls;
@@ -10,7 +9,7 @@ namespace Ursa.Demo.Converters;
public class TimelineIconConverter: IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is TimelineItemType t)
{
@@ -25,7 +24,7 @@ public class TimelineIconConverter: IValueConverter
return AvaloniaProperty.UnsetValue;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

View File

@@ -14,11 +14,11 @@ public class ToolBarItemTemplateSelector: IDataTemplate
public Control? Build(object? param)
{
if (param is null) return null;
if (param is ToolBarSeparatorViewModel sep)
if (param is ToolBarSeparatorViewModel)
{
return new ToolBarSeparator();
}
if (param is ToolBarButtonItemViewModel vm)
if (param is ToolBarButtonItemViewModel)
{
return new Button()
{
@@ -27,7 +27,7 @@ public class ToolBarItemTemplateSelector: IDataTemplate
[!ToolBar.OverflowModeProperty] = new Binding(){Path = nameof(ToolBarItemViewModel.OverflowMode)},
};
}
if (param is ToolBarCheckBoxItemViweModel cb)
if (param is ToolBarCheckBoxItemViweModel)
{
return new CheckBox()
{
@@ -36,7 +36,7 @@ public class ToolBarItemTemplateSelector: IDataTemplate
[!ToolBar.OverflowModeProperty] = new Binding(){Path = nameof(ToolBarItemViewModel.OverflowMode)},
};
}
if (param is ToolBarComboBoxItemViewModel combo)
if (param is ToolBarComboBoxItemViewModel)
{
return new ComboBox()
{

View File

@@ -1,7 +1,6 @@
using System;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Ursa.Demo.Pages;
namespace Ursa.Demo.Converters;
@@ -10,16 +9,13 @@ public class ViewLocator: IDataTemplate
public Control? Build(object? param)
{
if (param is null) return null;
var name = param.GetType().Name!.Replace("ViewModel", "");
var name = param.GetType().Name.Replace("ViewModel", "");
var type = Type.GetType("Ursa.Demo.Pages."+name);
if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
else
{
return new TextBlock { Text = "Not Found: " + name };
}
return new TextBlock { Text = "Not Found: " + name };
}
public bool Match(object? data)

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Dialogs;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Dialogs;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -1,4 +1,3 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

View File

@@ -1,5 +1,4 @@
using System.Collections.ObjectModel;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using Avalonia.Markup.Xaml;
@@ -23,9 +22,9 @@ public partial class BannerDemo : UserControl
public class BannerDemoViewModel : ViewModelBase
{
private ObservableCollection<NotificationType> _types;
private ObservableCollection<NotificationType>? _types;
public ObservableCollection<NotificationType> Types
public ObservableCollection<NotificationType>? Types
{
get => _types;
set => SetProperty(ref _types, value);

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Ursa.Demo.ViewModels;
namespace Ursa.Demo.Pages;
@@ -10,6 +8,6 @@ public partial class ButtonGroupDemo : UserControl
public ButtonGroupDemo()
{
InitializeComponent();
this.DataContext = new ButtonGroupDemoViewModel();
DataContext = new ButtonGroupDemoViewModel();
}
}

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -1,7 +1,5 @@
using System.Diagnostics;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Ursa.Controls;
namespace Ursa.Demo.Pages;
@@ -13,12 +11,12 @@ public partial class DatePickerDemo : UserControl
InitializeComponent();
}
private void CalendarView_OnOnDateSelected(object? sender, CalendarDayButtonEventArgs e)
private void CalendarView_OnOnDateSelected(object? _, CalendarDayButtonEventArgs e)
{
Debug.WriteLine("Pressed: "+ e.Date?.ToLongDateString());
}
private void CalendarView_OnOnDatePreviewed(object? sender, CalendarDayButtonEventArgs e)
private void CalendarView_OnOnDatePreviewed(object? _, CalendarDayButtonEventArgs e)
{
Debug.WriteLine("Hovered: "+e.Date?.ToLongDateString());
}

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -1,4 +1,3 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

View File

@@ -2,7 +2,6 @@
x:Class="Ursa.Demo.Pages.DrawerDemo"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:common="clr-namespace:Ursa.Common;assembly=Ursa"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="https://irihi.tech/ursa"

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -1,9 +1,4 @@
using System;
using System.Net;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using CommunityToolkit.Mvvm.ComponentModel;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -1,7 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Pages;

View File

@@ -2,7 +2,6 @@
x:Class="Ursa.Demo.Pages.IntroductionDemo"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Ursa.Demo.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="https://irihi.tech/ursa"

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Pages;
@@ -10,9 +8,4 @@ public partial class KeyGestureInputDemo : UserControl
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}

View File

@@ -1,4 +1,3 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
using Ursa.Demo.ViewModels;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -1,9 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Shapes;
using Avalonia.Input;
using Avalonia.LogicalTree;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
using Ursa.Demo.ViewModels;
namespace Ursa.Demo.Pages;
@@ -13,15 +8,6 @@ public partial class NavMenuDemo : UserControl
public NavMenuDemo()
{
InitializeComponent();
this.DataContext = new NavMenuDemoViewModel();
}
private void InputElement_OnPointerPressed(object? sender, PointerPressedEventArgs e)
{
if (sender is Rectangle c)
{
c.ApplyStyling();
var ancestors = c.GetLogicalAncestors();
}
DataContext = new NavMenuDemoViewModel();
}
}

View File

@@ -1,7 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -55,7 +55,7 @@
Grid.Row="1"
Grid.Column="0"
HorizontalAlignment="Left">
<StackPanel Grid.Row="1">
<StackPanel>
<u:Divider Content="{Binding #input.Value, StringFormat='Int = {0}'}" />
<u:NumericIntUpDown
Name="input"
@@ -148,9 +148,9 @@
<CheckBox Content="IsReadOnly" IsChecked="{Binding IsReadOnly}" />
<Label Content="HorizontalAlignment" />
<ComboBox ItemsSource="{Binding Array_HorizontalAlignment}" SelectedItem="{Binding HorizontalAlignment}" />
<ComboBox ItemsSource="{Binding ArrayHorizontalAlignment}" SelectedItem="{Binding HorizontalAlignment}" />
<Label Content="HorizontalContentAlignment" />
<ComboBox ItemsSource="{Binding Array_HorizontalContentAlignment}" SelectedItem="{Binding HorizontalContentAlignment}" />
<ComboBox ItemsSource="{Binding ArrayHorizontalContentAlignment}" SelectedItem="{Binding HorizontalContentAlignment}" />
<TextBox
InnerLeftContent="InnerLeftContent"
@@ -166,7 +166,7 @@
Text="{Binding FormatString}" />
<Label Content="ParsingNumberStyle" />
<ComboBox ItemsSource="{Binding Array_ParsingNumberStyle}" SelectedItem="{Binding ParsingNumberStyle}" />
<ComboBox ItemsSource="{Binding ArrayParsingNumberStyle}" SelectedItem="{Binding ParsingNumberStyle}" />
<CheckBox Content="AllowSpin" IsChecked="{Binding AllowSpin}" />

View File

@@ -1,7 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using System;
using Avalonia.Controls;
using System.Diagnostics;
using Ursa.Controls;
using Ursa.Demo.ViewModels;
@@ -19,7 +16,9 @@ public partial class NumericUpDownDemo : UserControl
private void Numd_ValueChanged(object? sender, ValueChangedEventArgs<uint> e)
{
Trace.WriteLine($"{(sender as NumericUIntUpDown).Name} {e.OldValue} {e.NewValue}");
if (sender is NumericIntUpDown i)
{
Trace.WriteLine($"{i.Name} {e.OldValue} {e.NewValue}");
}
}
}

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Ursa.Demo.ViewModels;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Ursa.Demo.ViewModels;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Ursa.Demo.ViewModels;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Pages;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.Demo.Pages;

View File

@@ -4,7 +4,6 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="https://irihi.tech/ursa"
xmlns:vm="using:Ursa.Demo.ViewModels"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
x:DataType="vm:VerificationCodeDemoViewModel"
x:CompileBindings="True"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"

View File

@@ -1,7 +1,4 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
using Ursa.Controls;
namespace Ursa.Demo.Pages;
@@ -13,7 +10,7 @@ public partial class VerificationCodeDemo : UserControl
InitializeComponent();
}
private async void VerificationCode_OnComplete(object? sender, VerificationCodeCompleteEventArgs e)
private async void VerificationCode_OnComplete(object? _, VerificationCodeCompleteEventArgs e)
{
var text = string.Join(string.Empty, e.Code);
await MessageBox.ShowOverlayAsync(text);

View File

@@ -8,34 +8,29 @@ namespace Ursa.Demo.ViewModels;
public class BreadcrumbDemoViewModel: ObservableObject
{
public ObservableCollection<BreadcrumbDemoItem> Items1 { get; set; }
public BreadcrumbDemoViewModel()
{
Items1 = new ObservableCollection<BreadcrumbDemoItem>()
{
new BreadcrumbDemoItem() { Section = "Home", Icon = "Home" },
new BreadcrumbDemoItem() { Section = "Page 1", Icon = "Page" },
new BreadcrumbDemoItem() { Section = "Page 2", Icon = "Page" },
new BreadcrumbDemoItem() { Section = "Page 3", Icon = "Page" },
new BreadcrumbDemoItem() { Section = "Page 4", Icon = "Page", IsReadOnly = true},
};
}
public ObservableCollection<BreadcrumbDemoItem> Items1 { get; set; } =
[
new BreadcrumbDemoItem { Section = "Home", Icon = "Home" },
new BreadcrumbDemoItem { Section = "Page 1", Icon = "Page" },
new BreadcrumbDemoItem { Section = "Page 2", Icon = "Page" },
new BreadcrumbDemoItem { Section = "Page 3", Icon = "Page" },
new BreadcrumbDemoItem { Section = "Page 4", Icon = "Page", IsReadOnly = true }
];
}
public partial class BreadcrumbDemoItem: ObservableObject
{
public string Section { get; set; }
public string Icon { get; set; }
public string? Section { get; set; }
public string? Icon { get; set; }
[ObservableProperty] private bool _isReadOnly;
public ICommand Command { get; set; }
public BreadcrumbDemoItem()
{
Command = new RelayCommand(() =>
Command = new AsyncRelayCommand(async () =>
{
MessageBox.ShowOverlayAsync(Section);
await MessageBox.ShowOverlayAsync(Section ?? string.Empty);
});
}
}

View File

@@ -4,10 +4,8 @@ using System.Threading.Tasks;
using System.Windows.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Ursa.Common;
using Ursa.Controls;
using Ursa.Demo.Dialogs;
using Ursa.Demo.Pages;
namespace Ursa.Demo.ViewModels;

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;
using Avalonia.Animation;
using Avalonia.Controls;
using Avalonia.Data;
@@ -9,7 +8,6 @@ using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Layout;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
namespace Ursa.Demo.ViewModels;

View File

@@ -37,7 +37,7 @@ public partial class FormDemoViewModel : ObservableObject
public partial class DataModel : ObservableObject
{
private string _name;
private string _name = string.Empty;
[MinLength(10)]
public string Name
@@ -55,7 +55,7 @@ public partial class DataModel : ObservableObject
set => SetProperty(ref _number, value);
}
private string _email;
private string _email = string.Empty;
[EmailAddress]
public string Email

View File

@@ -1,4 +1,5 @@
using CommunityToolkit.Mvvm.Messaging;
using System;
using CommunityToolkit.Mvvm.Messaging;
namespace Ursa.Demo.ViewModels;
@@ -67,6 +68,7 @@ public class MainViewViewModel : ViewModelBase
MenuKeys.MenuKeyToolBar => new ToolBarDemoViewModel(),
MenuKeys.MenuKeyTimeBox => new TimeBoxDemoViewModel(),
MenuKeys.MenuKeyVerificationCode => new VerificationCodeDemoViewModel(),
_ => throw new ArgumentOutOfRangeException(nameof(s), s, null)
};
}
}

View File

@@ -14,10 +14,10 @@ public enum ControlStatus
public class MenuItemViewModel: ViewModelBase
{
public string MenuHeader { get; set; }
public string MenuIconName { get; set; }
public string Key { get; set; }
public string Status { get; set; }
public string? MenuHeader { get; set; }
public string? MenuIconName { get; set; }
public string? Key { get; set; }
public string? Status { get; set; }
public bool IsSeparator { get; set; }
public ObservableCollection<MenuItemViewModel> Children { get; set; } = new();
@@ -31,7 +31,7 @@ public class MenuItemViewModel: ViewModelBase
private void OnActivate()
{
if (IsSeparator) return;
WeakReferenceMessenger.Default.Send<string>(Key);
if (IsSeparator || Key is null) return;
WeakReferenceMessenger.Default.Send(Key);
}
}

View File

@@ -14,7 +14,7 @@ public class MessageBoxDemoViewModel: ObservableObject
private readonly string _shortMessage = "Welcome to Ursa Avalonia!";
private string _message;
private string _title;
private string? _title;
public ICommand DefaultMessageBoxCommand { get; set; }
public ICommand OkCommand { get; set; }

View File

@@ -1,11 +1,8 @@
using Avalonia.Controls;
using Avalonia.Layout;
using Avalonia.Layout;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Globalization;
using Ursa.Controls;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Ursa.Demo.ViewModels;
@@ -14,39 +11,36 @@ public partial class NumericUpDownDemoViewModel : ObservableObject
private double _oldWidth = 300;
[ObservableProperty] private bool _AutoWidth = true;
[ObservableProperty] private double _Width = Double.NaN;
[ObservableProperty] private uint _Value;
[ObservableProperty] private string _FontFamily = "Consolas";
[ObservableProperty] private bool _AllowDrag = false;
[ObservableProperty] private bool _IsReadOnly = false;
[ObservableProperty] private bool _autoWidth = true;
[ObservableProperty] private double _width = double.NaN;
[ObservableProperty] private uint _value;
[ObservableProperty] private string _fontFamily = "Consolas";
[ObservableProperty] private bool _allowDrag;
[ObservableProperty] private bool _isReadOnly;
[ObservableProperty] private Array _Array_HorizontalAlignment;
[ObservableProperty] private HorizontalAlignment _HorizontalAlignment = HorizontalAlignment.Center;
[ObservableProperty] private Array _arrayHorizontalAlignment;
[ObservableProperty] private HorizontalAlignment _horizontalAlignment = HorizontalAlignment.Center;
[ObservableProperty] private Array _Array_HorizontalContentAlignment;
[ObservableProperty] private HorizontalAlignment _HorizontalContentAlignment = HorizontalAlignment.Center;
[ObservableProperty] private object? _InnerLeftContent = "obj:0x";
[ObservableProperty] private string _Watermark = "Water mark showed";
[ObservableProperty] private string _FormatString = "X8";
[ObservableProperty] private Array _Array_ParsingNumberStyle;
[ObservableProperty] private NumberStyles _ParsingNumberStyle = NumberStyles.AllowHexSpecifier;
[ObservableProperty] private bool _AllowSpin = true;
[ObservableProperty] private bool _ShowButtonSpinner = true;
[ObservableProperty] private Array _arrayHorizontalContentAlignment;
[ObservableProperty] private HorizontalAlignment _horizontalContentAlignment = HorizontalAlignment.Center;
[ObservableProperty] private object? _innerLeftContent = "obj:0x";
[ObservableProperty] private string _watermark = "Water mark showed";
[ObservableProperty] private string _formatString = "X8";
[ObservableProperty] private Array _arrayParsingNumberStyle;
[ObservableProperty] private NumberStyles _parsingNumberStyle = NumberStyles.AllowHexSpecifier;
[ObservableProperty] private bool _allowSpin = true;
[ObservableProperty] private bool _showButtonSpinner = true;
[ObservableProperty] private UInt32 _Maximum = UInt32.MaxValue;
[ObservableProperty] private UInt32 _Minimum = UInt32.MinValue;
[ObservableProperty] private UInt32 _Step = 1;
[ObservableProperty] private UInt32 _maximum = UInt32.MaxValue;
[ObservableProperty] private UInt32 _minimum = UInt32.MinValue;
[ObservableProperty] private UInt32 _step = 1;
[ObservableProperty] private bool _IsEnable = true;
[ObservableProperty] private bool _isEnable = true;
[ObservableProperty] private string _CommandUpdateText = "Command not Execute";
uint v = 0;
[ObservableProperty] private string _commandUpdateText = "Command not Execute";
[RelayCommand]
// void Trythis()
void Trythis(uint v)
// void Trythis(object v)
{
CommandUpdateText = $"Command Exe,CommandParameter={v}";
}
@@ -54,12 +48,9 @@ public partial class NumericUpDownDemoViewModel : ObservableObject
public NumericUpDownDemoViewModel()
{
Array_HorizontalContentAlignment = Enum.GetValues(typeof(HorizontalAlignment));
Array_HorizontalAlignment = Enum.GetValues(typeof(HorizontalAlignment));
Array_ParsingNumberStyle = Enum.GetValues(typeof(NumberStyles));
NumericUIntUpDown numericUIntUpDown;
TextBox textBox;
ArrayHorizontalContentAlignment = Enum.GetValues(typeof(HorizontalAlignment));
ArrayHorizontalAlignment = Enum.GetValues(typeof(HorizontalAlignment));
ArrayParsingNumberStyle = Enum.GetValues(typeof(NumberStyles));
}
partial void OnAutoWidthChanged(bool value)
@@ -74,10 +65,4 @@ public partial class NumericUpDownDemoViewModel : ObservableObject
Width = _oldWidth;
}
}
partial void OnValueChanging(uint oldValue, uint newValue)
{
// Console.WriteLine(oldValue);
}
}

View File

@@ -1,9 +1,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows.Input;
using Avalonia.Collections;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
namespace Ursa.Demo.ViewModels;

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ursa.Demo.ViewModels
namespace Ursa.Demo.ViewModels
{
public class SkeletonDemoViewModel : ViewModelBase
{

View File

@@ -1,5 +1,4 @@
using System;
using System.Net;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

View File

@@ -23,21 +23,21 @@ public partial class ToolBarDemoViewModel : ObservableObject
{
Items = new()
{
new ToolBarButtonItemViewModel() { Content = "New", OverflowMode = OverflowMode.AsNeeded },
new ToolBarButtonItemViewModel() { Content = "Open" },
new ToolBarButtonItemViewModel() { Content = "Save1" },
new ToolBarButtonItemViewModel() { Content = "Save2" },
new ToolBarButtonItemViewModel { Content = "New", OverflowMode = OverflowMode.AsNeeded },
new ToolBarButtonItemViewModel { Content = "Open" },
new ToolBarButtonItemViewModel { Content = "Save1" },
new ToolBarButtonItemViewModel { Content = "Save2" },
new ToolBarSeparatorViewModel(),
new ToolBarButtonItemViewModel() { Content = "Save3" },
new ToolBarButtonItemViewModel() { Content = "Save4" },
new ToolBarButtonItemViewModel() { Content = "Save5" },
new ToolBarButtonItemViewModel() { Content = "Save6" },
new ToolBarButtonItemViewModel() { Content = "Save7" },
new ToolBarButtonItemViewModel { Content = "Save3" },
new ToolBarButtonItemViewModel { Content = "Save4" },
new ToolBarButtonItemViewModel { Content = "Save5" },
new ToolBarButtonItemViewModel { Content = "Save6" },
new ToolBarButtonItemViewModel { Content = "Save7" },
new ToolBarSeparatorViewModel(),
new ToolBarButtonItemViewModel() { Content = "Save8" },
new ToolBarCheckBoxItemViweModel() { Content = "Bold" },
new ToolBarCheckBoxItemViweModel() { Content = "Italic", OverflowMode = OverflowMode.Never },
new ToolBarComboBoxItemViewModel() { Content = "Font Size", Items = new() { "10", "12", "14" } }
new ToolBarButtonItemViewModel { Content = "Save8" },
new ToolBarCheckBoxItemViweModel { Content = "Bold" },
new ToolBarCheckBoxItemViweModel { Content = "Italic", OverflowMode = OverflowMode.Never },
new ToolBarComboBoxItemViewModel { Content = "Font Size", Items = ["10", "12", "14"] }
};
}
}
@@ -49,41 +49,40 @@ public abstract class ToolBarItemViewModel : ObservableObject
public class ToolBarButtonItemViewModel : ToolBarItemViewModel
{
public string Content { get; set; }
public ICommand Command { get; set; }
public string? Content { get; set; }
public ICommand? Command { get; set; }
public ToolBarButtonItemViewModel()
{
Command = new AsyncRelayCommand(async () => { await MessageBox.ShowOverlayAsync(Content); });
Command = new AsyncRelayCommand(async () => { await MessageBox.ShowOverlayAsync(Content ?? string.Empty); });
}
}
public class ToolBarCheckBoxItemViweModel : ToolBarItemViewModel
{
public string Content { get; set; }
public string? Content { get; set; }
public bool IsChecked { get; set; }
public ICommand Command { get; set; }
public ICommand? Command { get; set; }
public ToolBarCheckBoxItemViweModel()
{
Command = new AsyncRelayCommand(async () => { await MessageBox.ShowOverlayAsync(Content); });
Command = new AsyncRelayCommand(async () => { await MessageBox.ShowOverlayAsync(Content ?? string.Empty); });
}
}
public class ToolBarComboBoxItemViewModel : ToolBarItemViewModel
{
public string Content { get; set; }
public ObservableCollection<string> Items { get; set; }
public string? Content { get; set; }
public ObservableCollection<string>? Items { get; set; }
private string _selectedItem;
public string SelectedItem
private string? _selectedItem;
public string? SelectedItem
{
get => _selectedItem;
set
{
SetProperty(ref _selectedItem, value);
MessageBox.ShowOverlayAsync(value);
_ = MessageBox.ShowOverlayAsync(value ?? string.Empty);
}
}
}

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Input;
using Avalonia.Collections;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Ursa.Controls;

View File

@@ -1,7 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Styling;
namespace Ursa.Demo.Views;
@@ -11,14 +8,4 @@ public partial class MainView : UserControl
{
InitializeComponent();
}
private void ToggleButton_OnIsCheckedChanged(object? sender, RoutedEventArgs e)
{
var app = Application.Current;
if (app is not null)
{
var theme = app.ActualThemeVariant;
app.RequestedThemeVariant = theme == ThemeVariant.Dark ? ThemeVariant.Light : ThemeVariant.Dark;
}
}
}

View File

@@ -1,6 +1,3 @@
using System;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Ursa.Controls;
namespace Ursa.Demo.Views;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Ursa.Demo.Views;

View File

@@ -1,5 +1,4 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Prism.DryIoc;
using Prism.Ioc;

View File

@@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Controls;
namespace Ursa.PrismDialogDemo;

View File

@@ -1,6 +1,5 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using DryIoc;
using Ursa.Controls;
using Ursa.Controls.Options;
using Ursa.PrismExtension;
@@ -22,6 +21,7 @@ public partial class MainWindow : Window
_drawerService = drawerService;
}
// ReSharper disable once UnusedParameter.Local
private void OverlayDialogButton_OnClick(object? sender, RoutedEventArgs e)
{
_overlayDialogService.ShowModal("Default", null, null, new OverlayDialogOptions()
@@ -30,6 +30,7 @@ public partial class MainWindow : Window
});
}
// ReSharper disable once UnusedParameter.Local
private void AloneDialogButton_OnClick(object? sender, RoutedEventArgs e)
{
_aloneDialogService.ShowModal("Default", null, null, new DialogOptions()
@@ -38,6 +39,7 @@ public partial class MainWindow : Window
});
}
// ReSharper disable once UnusedParameter.Local
private void DrawerButton_OnClick(object? sender, RoutedEventArgs e)
{
_drawerService.ShowModal("Default", null, null, new DrawerOptions()

View File

@@ -1,5 +1,4 @@
using Avalonia.Controls;
using Ursa.Controls;
using Ursa.Controls;
namespace Ursa.PrismExtension;

View File

@@ -70,7 +70,7 @@
</Setter>
<Style Selector="^[Dot=True]">
<Setter Property="u:Badge.Template">
<Setter Property="Template">
<ControlTemplate TargetType="{x:Type u:Badge}">
<Grid
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"

View File

@@ -69,54 +69,54 @@
</Setter>
<Style Selector="^[Type=Information]">
<Style Selector="^.Bordered /template/ Border#PART_Container">
<Setter Property="Border.CornerRadius" Value="{DynamicResource BannerCornerRadius}" />
<Setter Property="CornerRadius" Value="{DynamicResource BannerCornerRadius}" />
<Setter Property="BorderBrush" Value="{DynamicResource BannerInformationBorderBrush}" />
</Style>
<Style Selector="^ /template/ Border#PART_Container">
<Setter Property="Background" Value="{DynamicResource BannerInformationBackground}" />
</Style>
<Style Selector="^ /template/ PathIcon#PART_BuildInIcon">
<Setter Property="PathIcon.Data" Value="{DynamicResource BannerInformationIconGeometry}" />
<Setter Property="PathIcon.Foreground" Value="{DynamicResource BannerInformationBorderBrush}" />
<Setter Property="Data" Value="{DynamicResource BannerInformationIconGeometry}" />
<Setter Property="Foreground" Value="{DynamicResource BannerInformationBorderBrush}" />
</Style>
</Style>
<Style Selector="^[Type=Success]">
<Style Selector="^.Bordered /template/ Border#PART_Container">
<Setter Property="Border.CornerRadius" Value="{DynamicResource BannerCornerRadius}" />
<Setter Property="CornerRadius" Value="{DynamicResource BannerCornerRadius}" />
<Setter Property="BorderBrush" Value="{DynamicResource BannerSuccessBorderBrush}" />
</Style>
<Style Selector="^ /template/ Border#PART_Container">
<Setter Property="Background" Value="{DynamicResource BannerSuccessBackground}" />
</Style>
<Style Selector="^ /template/ PathIcon#PART_BuildInIcon">
<Setter Property="PathIcon.Data" Value="{DynamicResource BannerSuccessIconGeometry}" />
<Setter Property="PathIcon.Foreground" Value="{DynamicResource BannerSuccessBorderBrush}" />
<Setter Property="Data" Value="{DynamicResource BannerSuccessIconGeometry}" />
<Setter Property="Foreground" Value="{DynamicResource BannerSuccessBorderBrush}" />
</Style>
</Style>
<Style Selector="^[Type=Warning]">
<Style Selector="^.Bordered /template/ Border#PART_Container">
<Setter Property="Border.CornerRadius" Value="{DynamicResource BannerCornerRadius}" />
<Setter Property="CornerRadius" Value="{DynamicResource BannerCornerRadius}" />
<Setter Property="BorderBrush" Value="{DynamicResource BannerWarningBorderBrush}" />
</Style>
<Style Selector="^ /template/ Border#PART_Container">
<Setter Property="Background" Value="{DynamicResource BannerWarningBackground}" />
</Style>
<Style Selector="^ /template/ PathIcon#PART_BuildInIcon">
<Setter Property="PathIcon.Data" Value="{DynamicResource BannerWarningIconGeometry}" />
<Setter Property="PathIcon.Foreground" Value="{DynamicResource BannerWarningBorderBrush}" />
<Setter Property="Data" Value="{DynamicResource BannerWarningIconGeometry}" />
<Setter Property="Foreground" Value="{DynamicResource BannerWarningBorderBrush}" />
</Style>
</Style>
<Style Selector="^[Type=Error]">
<Style Selector="^.Bordered /template/ Border#PART_Container">
<Setter Property="Border.CornerRadius" Value="{DynamicResource BannerCornerRadius}" />
<Setter Property="CornerRadius" Value="{DynamicResource BannerCornerRadius}" />
<Setter Property="BorderBrush" Value="{DynamicResource BannerErrorBorderBrush}" />
</Style>
<Style Selector="^ /template/ Border#PART_Container">
<Setter Property="Background" Value="{DynamicResource BannerErrorBackground}" />
</Style>
<Style Selector="^ /template/ PathIcon#PART_BuildInIcon">
<Setter Property="PathIcon.Data" Value="{DynamicResource BannerErrorIconGeometry}" />
<Setter Property="PathIcon.Foreground" Value="{DynamicResource BannerErrorBorderBrush}" />
<Setter Property="Data" Value="{DynamicResource BannerErrorIconGeometry}" />
<Setter Property="Foreground" Value="{DynamicResource BannerErrorBorderBrush}" />
</Style>
</Style>
</ControlTheme>

View File

@@ -1,7 +1,6 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:contracts="https://irihi.tech/shared"
xmlns:u="https://irihi.tech/ursa">
<!-- Add Resources Here -->
<ControlTheme x:Key="{x:Type u:DatePicker}" TargetType="u:DatePicker">

View File

@@ -165,7 +165,6 @@
<ScrollViewer Grid.Row="1">
<ContentPresenter
Name="PART_ContentPresenter"
Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="24,8"

View File

@@ -85,7 +85,6 @@
<ScrollViewer Grid.Row="1">
<ContentPresenter
Name="PART_ContentPresenter"
Grid.Row="1"
Margin="24,8"
Content="{TemplateBinding Content}" />
</ScrollViewer>

View File

@@ -113,10 +113,10 @@
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ Border#PART_Border">
<Setter Property="Border.Background" Value="{DynamicResource IPv4BoxPointeroverBackground}" />
<Setter Property="Background" Value="{DynamicResource IPv4BoxPointeroverBackground}" />
</Style>
<Style Selector="^:pressed /template/ Border#PART_Border">
<Setter Property="Border.Background" Value="{DynamicResource IPv4BoxPressedBackground}" />
<Setter Property="Background" Value="{DynamicResource IPv4BoxPressedBackground}" />
</Style>
<Style Selector="^:focus-within">
<Setter Property="Border.BorderBrush" Value="{DynamicResource IPv4BoxFocusBorderBrush}" />

View File

@@ -59,7 +59,7 @@
</Panel>
<ContentPresenter
Name="PART_ContentPresenter"
Grid.Column="1"
Grid.Row="0" Grid.Column="1"
Margin="8 0 0 0"
HorizontalAlignment="Center"
VerticalAlignment="Center"

View File

@@ -47,14 +47,14 @@
</ControlTemplate>
</Setter>
<Style Selector="^.Small /template/ Arc#PART_Arc">
<Setter Property="Arc.Width" Value="14" />
<Setter Property="Arc.Height" Value="14" />
<Setter Property="Arc.StrokeThickness" Value="2" />
<Setter Property="Width" Value="14" />
<Setter Property="Height" Value="14" />
<Setter Property="StrokeThickness" Value="2" />
</Style>
<Style Selector="^.Large /template/ Arc#PART_Arc">
<Setter Property="Arc.Width" Value="32" />
<Setter Property="Arc.Height" Value="32" />
<Setter Property="Arc.StrokeThickness" Value="5" />
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="StrokeThickness" Value="5" />
</Style>
</ControlTheme>

View File

@@ -1,7 +1,6 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Ursa.Converters;assembly=Ursa"
xmlns:u="https://irihi.tech/ursa">
<!-- Add Resources Here -->
<ControlTheme x:Key="{x:Type u:NumberDisplayerBase}" TargetType="u:NumberDisplayerBase">

View File

@@ -74,13 +74,13 @@
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="u:PaginationButton.Background" Value="{DynamicResource PaginationButtonPointeroverBackground}" />
<Setter Property="Background" Value="{DynamicResource PaginationButtonPointeroverBackground}" />
</Style>
<Style Selector="^:pressed">
<Setter Property="u:PaginationButton.Background" Value="{DynamicResource PaginationButtonPressedBackground}" />
<Setter Property="Background" Value="{DynamicResource PaginationButtonPressedBackground}" />
</Style>
<Style Selector="^:left">
<Setter Property="u:PaginationButton.Content">
<Setter Property="Content">
<Template>
<PathIcon
Width="12"
@@ -90,7 +90,7 @@
</Template>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="u:PaginationButton.Content">
<Setter Property="Content">
<Template>
<PathIcon
Width="12"
@@ -102,7 +102,7 @@
</Style>
</Style>
<Style Selector="^:right">
<Setter Property="u:PaginationButton.Content">
<Setter Property="Content">
<Template>
<PathIcon
Width="12"
@@ -112,7 +112,7 @@
</Template>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="u:PaginationButton.Content">
<Setter Property="Content">
<Template>
<PathIcon
Width="12"

View File

@@ -52,10 +52,10 @@
<Setter Property="IsVisible" Value="True"></Setter>
</Style>
<Style Selector="^:pointerover /template/ Border#PART_BackgroundBorder">
<Setter Property="Border.Background" Value="{DynamicResource TextBoxPointeroverBackground}" />
<Setter Property="Background" Value="{DynamicResource TextBoxPointeroverBackground}" />
</Style>
<Style Selector="^:focus-within /template/ Border#PART_BackgroundBorder">
<Setter Property="Border.BorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
</Style>
</ControlTheme>

View File

@@ -1,7 +1,6 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Ursa.Converters;assembly=Ursa"
xmlns:iri="https://irihi.tech/shared"
xmlns:u="https://irihi.tech/ursa">
<!-- Add Resources Here -->

View File

@@ -110,7 +110,7 @@
</ControlTemplate>
</Setter>
<Style Selector="^:last /template/ Rectangle.end">
<Setter Property="Rectangle.Fill" Value="Transparent" />
<Setter Property="Fill" Value="Transparent" />
</Style>
<Style Selector="^:empty-icon /template/ Ellipse#PART_DefaultIcon">
<Setter Property="IsVisible" Value="True"/>

View File

@@ -5,7 +5,7 @@ namespace Ursa.Themes.Semi.Converters;
public class BooleansToOpacityConverter: IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is bool b)
{
@@ -14,7 +14,7 @@ public class BooleansToOpacityConverter: IValueConverter
return 1;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

View File

@@ -1,5 +1,4 @@
using System.Globalization;
using Avalonia;
using Avalonia.Data.Converters;
using Avalonia.Media;
@@ -7,7 +6,7 @@ namespace Ursa.Themes.Semi.Converters;
public class BrushToColorConverter: IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is ISolidColorBrush b)
{
@@ -16,7 +15,7 @@ public class BrushToColorConverter: IValueConverter
return Colors.Transparent;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

View File

@@ -8,8 +8,6 @@ public class ClockHandLengthConverter(double ratio) : IValueConverter
public static ClockHandLengthConverter Hour { get; } = new(1-0.618);
public static ClockHandLengthConverter Minute { get; } = new(0.618);
public static ClockHandLengthConverter Second { get; } = new(1);
private double _ratio = ratio;
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
@@ -20,7 +18,7 @@ public class ClockHandLengthConverter(double ratio) : IValueConverter
return 0.0;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

View File

@@ -1,6 +1,5 @@
using System.Globalization;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data.Converters;
using Avalonia.Media;
using Ursa.Controls;
@@ -55,7 +54,7 @@ public class TimelineItemTypeToIconForegroundConverter: AvaloniaObject, IMultiVa
}
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
public object Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
{
if (values[0] is TimelineItemType type)
{

View File

@@ -20,10 +20,10 @@ public class SemiTheme: Styles
private static readonly ResourceDictionary _defaultResource = new zh_cn();
private readonly IServiceProvider? sp;
private readonly IServiceProvider? _sp;
public SemiTheme(IServiceProvider? provider = null)
{
sp = provider;
_sp = provider;
AvaloniaXamlLoader.Load(provider, this);
}

View File

@@ -61,7 +61,7 @@ public class Badge: HeaderedContentControl
static Badge()
{
HeaderProperty.Changed.AddClassHandler<Badge>((badge, args) => badge.UpdateBadgePosition());
HeaderProperty.Changed.AddClassHandler<Badge>((badge, _) => badge.UpdateBadgePosition());
}
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
@@ -86,7 +86,7 @@ public class Badge: HeaderedContentControl
{
var vertical = CornerPosition is CornerPosition.BottomLeft or CornerPosition.BottomRight ? 1 : -1;
var horizontal = CornerPosition is CornerPosition.TopRight or CornerPosition.BottomRight ? 1 : -1;
if (_badgeContainer is not null && base.Presenter?.Child is not null)
if (_badgeContainer is not null && Presenter?.Child is not null)
{
_badgeContainer.RenderTransform = new TransformGroup()
{

View File

@@ -3,9 +3,7 @@ using Avalonia.Controls;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Notifications;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
using Avalonia.Interactivity;
using Avalonia.Metadata;
using Irihi.Avalonia.Shared.Helpers;
namespace Ursa.Controls;
@@ -63,7 +61,7 @@ public class Banner: HeaderedContentControl
Button.ClickEvent.AddHandler(OnCloseClick, _closeButton);
}
private void OnCloseClick(object sender, RoutedEventArgs args)
private void OnCloseClick(object? sender, RoutedEventArgs args)
{
IsVisible = false;
}

View File

@@ -4,7 +4,6 @@ using Avalonia.Controls;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Templates;
using Avalonia.Input;
using Avalonia.LogicalTree;
namespace Ursa.Controls;

View File

@@ -1,10 +1,6 @@
using System.Net.Http.Headers;
using Avalonia;
using Avalonia.Collections;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.Media;
using Avalonia.Metadata;
using Irihi.Avalonia.Shared.Helpers;

View File

@@ -3,7 +3,6 @@ using Avalonia.Controls;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
using Avalonia.Layout;
using Ursa.Common;
namespace Ursa.Controls;

View File

@@ -156,7 +156,7 @@ public class Clock : TemplatedControl
private CancellationTokenSource _cts = new CancellationTokenSource();
private async void OnTimeChanged(AvaloniaPropertyChangedEventArgs<DateTime> args)
private void OnTimeChanged(AvaloniaPropertyChangedEventArgs<DateTime> args)
{
var oldSeconds = args.OldValue.Value.Second;
var time = args.NewValue.Value;
@@ -179,8 +179,14 @@ public class Clock : TemplatedControl
_cts.Cancel();
_cts.Dispose();
_cts = new CancellationTokenSource();
(_secondsAnimation.Children[0].Setters[0] as Setter).Value = oldSecondAngle;
(_secondsAnimation.Children[1].Setters[0] as Setter).Value = secondAngle;
if (_secondsAnimation.Children[0].Setters[0] is Setter start)
{
start.Value = oldSecondAngle;
}
if (_secondsAnimation.Children[1].Setters[0] is Setter end)
{
end.Value = secondAngle;
}
_secondsAnimation.RunAsync(this, _cts.Token);
}
}

View File

@@ -6,10 +6,8 @@ using Avalonia.Controls;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
using Avalonia.Data.Converters;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.LogicalTree;
using Irihi.Avalonia.Shared.Helpers;
using Irihi.Avalonia.Shared.Contracts;
@@ -145,7 +143,7 @@ public class MultiComboBox: SelectingItemsControl, IInnerContentControl
PseudoClasses.Set(PC_Empty, SelectedItems?.Count == 0);
}
private void OnBackgroundPointerPressed(object sender, PointerPressedEventArgs e)
private void OnBackgroundPointerPressed(object? sender, PointerPressedEventArgs e)
{
SetCurrentValue(IsDropDownOpenProperty, !IsDropDownOpen);
}

View File

@@ -1,5 +1,4 @@
using System.Windows.Input;
using Avalonia;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Mixins;
using Avalonia.Input;

View File

@@ -6,8 +6,6 @@ using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.LogicalTree;
using Avalonia.Media;
using Avalonia.Media.TextFormatting;
using Irihi.Avalonia.Shared.Common;
using Irihi.Avalonia.Shared.Helpers;
@@ -16,7 +14,6 @@ namespace Ursa.Controls;
[TemplatePart(PartNames.PART_Header, typeof(Control))]
public class TreeComboBoxItem: HeaderedItemsControl, ISelectable
{
private Control? _header;
private TreeComboBox? _treeComboBox;
public TreeComboBox? Owner => _treeComboBox;
@@ -58,7 +55,7 @@ public class TreeComboBoxItem: HeaderedItemsControl, ISelectable
{
base.OnApplyTemplate(e);
DoubleTappedEvent.RemoveHandler(OnDoubleTapped, this);
_header = e.NameScope.Find<Control>(PartNames.PART_Header);
e.NameScope.Find<Control>(PartNames.PART_Header);
DoubleTappedEvent.AddHandler(OnDoubleTapped, RoutingStrategies.Tunnel, true, this);
}
@@ -77,7 +74,7 @@ public class TreeComboBoxItem: HeaderedItemsControl, ISelectable
}
}
private void OnDoubleTapped(object sender, TappedEventArgs e)
private void OnDoubleTapped(object? sender, TappedEventArgs e)
{
if (this.ItemCount <= 0) return;
this.SetCurrentValue(IsExpandedProperty, !IsExpanded);
@@ -86,8 +83,6 @@ public class TreeComboBoxItem: HeaderedItemsControl, ISelectable
protected override bool NeedsContainerOverride(object? item, int index, out object? recycleKey)
{
TreeViewItem t = new TreeViewItem();
ComboBox c = new ComboBox();
return EnsureParent().NeedsContainerInternal(item, index, out recycleKey);
}

View File

@@ -1,7 +1,6 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using Avalonia;
using Avalonia.Collections;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
@@ -9,9 +8,9 @@ namespace Ursa.Controls;
public class ControlClassesInput: TemplatedControl
{
LinkedList<List<string>> _history = new();
LinkedList<List<string>> _undoHistory = new();
private bool _disableHistory = false;
private readonly LinkedList<List<string>> _history = [];
private readonly LinkedList<List<string>> _undoHistory = [];
private bool _disableHistory;
public int CountOfHistoricalRecord { get; set; } = 10;
@@ -34,12 +33,12 @@ public class ControlClassesInput: TemplatedControl
}
private ObservableCollection<string> _targetClasses;
private ObservableCollection<string>? _targetClasses;
internal static readonly DirectProperty<ControlClassesInput, ObservableCollection<string>> TargetClassesProperty = AvaloniaProperty.RegisterDirect<ControlClassesInput, ObservableCollection<string>>(
internal static readonly DirectProperty<ControlClassesInput, ObservableCollection<string>?> TargetClassesProperty = AvaloniaProperty.RegisterDirect<ControlClassesInput, ObservableCollection<string>?>(
nameof(TargetClasses), o => o.TargetClasses, (o, v) => o.TargetClasses = v);
public ObservableCollection<string> TargetClasses
public ObservableCollection<string>? TargetClasses
{
get => _targetClasses;
set => SetAndRaise(TargetClassesProperty, ref _targetClasses, value);
@@ -53,14 +52,13 @@ public class ControlClassesInput: TemplatedControl
static ControlClassesInput()
{
TargetClassesProperty.Changed.AddClassHandler<ControlClassesInput, ObservableCollection<string>>((o,e)=>o.OnClassesChanged(e));
TargetClassesProperty.Changed.AddClassHandler<ControlClassesInput, ObservableCollection<string>?>((o,e)=>o.OnClassesChanged(e));
SourceProperty.Changed.AddClassHandler<StyledElement, ControlClassesInput?>(HandleSourceChange);
}
public ControlClassesInput()
{
TargetClasses = new ObservableCollection<string>();
//TargetClasses.CollectionChanged += InccOnCollectionChanged;
}
private List<StyledElement> _targets = new();
@@ -83,7 +81,6 @@ public class ControlClassesInput: TemplatedControl
if (newValue is null)
{
SaveHistory(new List<string>(), true);
return;
}
else
{
@@ -93,11 +90,10 @@ public class ControlClassesInput: TemplatedControl
{
incc.CollectionChanged+=InccOnCollectionChanged;
}
return;
}
}
private void InccOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
private void InccOnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
if(_disableHistory) return;
SaveHistory(TargetClasses?.ToList() ?? new List<string>(), true);
@@ -123,7 +119,7 @@ public class ControlClassesInput: TemplatedControl
}
else
{
strings = _history.Last.Value;
strings = _history.Last?.Value ?? [];
}
if (!fromInput)
@@ -146,10 +142,10 @@ public class ControlClassesInput: TemplatedControl
_history.RemoveLast();
_undoHistory.AddFirst(node);
_disableHistory = true;
TargetClasses.Clear();
TargetClasses?.Clear();
foreach (var value in _history.Last.Value)
{
TargetClasses.Add(value);
TargetClasses?.Add(value);
}
_disableHistory = false;
SetClassesToTarget(false);
@@ -161,10 +157,10 @@ public class ControlClassesInput: TemplatedControl
_undoHistory.RemoveFirst();
_history.AddLast(node);
_disableHistory = true;
TargetClasses.Clear();
TargetClasses?.Clear();
foreach (var value in _history.Last.Value)
{
TargetClasses.Add(value);
TargetClasses?.Add(value);
}
_disableHistory = false;
SetClassesToTarget(false);

Some files were not shown because too many files have changed in this diff Show More