Merge branch 'main' into dialog
This commit is contained in:
@@ -1,11 +1,35 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Ursa.Controls;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public class ButtonGroupDemoViewModel: ViewModelBase
|
||||
{
|
||||
public ObservableCollection<string> Items { get; set; } = new ()
|
||||
public ObservableCollection<ButtonItem> Items { get; set; } = new ()
|
||||
{
|
||||
"Ding", "Otter", "Husky", "Mr. 17", "Cass"
|
||||
new ButtonItem(){Name = "Ding" },
|
||||
new ButtonItem(){Name = "Otter" },
|
||||
new ButtonItem(){Name = "Husky" },
|
||||
new ButtonItem(){Name = "Mr. 17" },
|
||||
new ButtonItem(){Name = "Cass" },
|
||||
};
|
||||
}
|
||||
|
||||
public class ButtonItem
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public ICommand InvokeCommand { get; set; }
|
||||
|
||||
public ButtonItem()
|
||||
{
|
||||
InvokeCommand = new AsyncRelayCommand(Invoke);
|
||||
}
|
||||
|
||||
private async Task Invoke()
|
||||
{
|
||||
await MessageBox.ShowAsync("Hello " + Name);
|
||||
}
|
||||
}
|
||||
67
demo/Ursa.Demo/ViewModels/EnumSelectorDemoViewModel.cs
Normal file
67
demo/Ursa.Demo/ViewModels/EnumSelectorDemoViewModel.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Input;
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Layout;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public class EnumSelectorDemoViewModel: ObservableObject
|
||||
{
|
||||
public ObservableCollection<Type?> Types { get; set; }
|
||||
|
||||
private Type? _selectedType;
|
||||
public Type? SelectedType
|
||||
{
|
||||
get => _selectedType;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _selectedType, value);
|
||||
Value = null;
|
||||
}
|
||||
}
|
||||
|
||||
private object? _value;
|
||||
public object? Value
|
||||
{
|
||||
get => _value;
|
||||
set => SetProperty(ref _value, value);
|
||||
}
|
||||
|
||||
public EnumSelectorDemoViewModel()
|
||||
{
|
||||
Types = new ObservableCollection<Type?>()
|
||||
{
|
||||
typeof(HorizontalAlignment),
|
||||
typeof(VerticalAlignment),
|
||||
typeof(Orientation),
|
||||
typeof(Dock),
|
||||
typeof(GridResizeDirection),
|
||||
typeof(DayOfWeek),
|
||||
typeof(FillMode),
|
||||
typeof(IterationType),
|
||||
typeof(BindingMode),
|
||||
typeof(BindingPriority),
|
||||
typeof(StandardCursorType),
|
||||
typeof(Key),
|
||||
typeof(KeyModifiers),
|
||||
typeof(RoutingStrategies),
|
||||
typeof(CustomEnum),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public enum CustomEnum
|
||||
{
|
||||
[Description("是")]
|
||||
Yes,
|
||||
[Description("否")]
|
||||
No,
|
||||
}
|
||||
@@ -31,6 +31,7 @@ public class MainViewViewModel : ViewModelBase
|
||||
MenuKeys.MenuKeyDialog => new DialogDemoViewModel(),
|
||||
MenuKeys.MenuKeyDivider => new DividerDemoViewModel(),
|
||||
MenuKeys.MenuKeyDualBadge => new DualBadgeDemoViewModel(),
|
||||
MenuKeys.MenuKeyEnumSelector => new EnumSelectorDemoViewModel(),
|
||||
MenuKeys.MenuKeyImageViewer => new ImageViewerDemoViewModel(),
|
||||
MenuKeys.MenuKeyIconButton => new IconButtonDemoViewModel(),
|
||||
MenuKeys.MenuKeyIpBox => new IPv4BoxDemoViewModel(),
|
||||
@@ -40,8 +41,10 @@ public class MainViewViewModel : ViewModelBase
|
||||
MenuKeys.MenuKeyNavigation => new NavigationMenuDemoViewModel(),
|
||||
MenuKeys.MenuKeyNumericUpDown => new NumericUpDownDemoViewModel(),
|
||||
MenuKeys.MenuKeyPagination => new PaginationDemoViewModel(),
|
||||
MenuKeys.MenuKeyRangeSlider => new RangeSliderDemoViewModel(),
|
||||
MenuKeys.MenuKeyTagInput => new TagInputDemoViewModel(),
|
||||
MenuKeys.MenuKeyTimeline => new TimelineDemoViewModel(),
|
||||
MenuKeys.MenuKeyTwoTonePathIcon => new TwoTonePathIconDemoViewModel(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,19 @@ using CommunityToolkit.Mvvm.Messaging;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public enum ControlStatus
|
||||
{
|
||||
New,
|
||||
Beta,
|
||||
Stable,
|
||||
}
|
||||
|
||||
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 bool IsSeparator { get; set; }
|
||||
public ObservableCollection<MenuItemViewModel> Children { get; set; } = new();
|
||||
|
||||
@@ -14,21 +14,24 @@ public class MenuViewModel: ViewModelBase
|
||||
new() { MenuHeader = "Controls", IsSeparator = true },
|
||||
new() { MenuHeader = "Badge", Key = MenuKeys.MenuKeyBadge },
|
||||
new() { MenuHeader = "Banner", Key = MenuKeys.MenuKeyBanner },
|
||||
new() { MenuHeader = "ButtonGroup", Key = MenuKeys.MenuKeyButtonGroup },
|
||||
new() { MenuHeader = "Dialog", Key = MenuKeys.MenuKeyDialog },
|
||||
new() { MenuHeader = "ButtonGroup", Key = MenuKeys.MenuKeyButtonGroup, Status = "Updated"},
|
||||
new() { MenuHeader = "Divider", Key = MenuKeys.MenuKeyDivider },
|
||||
new() { MenuHeader = "DualBadge", Key = MenuKeys.MenuKeyDualBadge },
|
||||
new() { MenuHeader = "Enum Selector", Key = MenuKeys.MenuKeyEnumSelector },
|
||||
new() { MenuHeader = "IconButton", Key = MenuKeys.MenuKeyIconButton },
|
||||
new() { MenuHeader = "ImageViewer", Key = MenuKeys.MenuKeyImageViewer },
|
||||
new() { MenuHeader = "IPv4Box", Key = MenuKeys.MenuKeyIpBox },
|
||||
new() { MenuHeader = "KeyGestureInput", Key = MenuKeys.MenuKeyKeyGestureInput },
|
||||
new() { MenuHeader = "Loading", Key = MenuKeys.MenuKeyLoading },
|
||||
new() { MenuHeader = "Message Box", Key = MenuKeys.MenuKeyMessageBox },
|
||||
new() { MenuHeader = "Navigation", Key = MenuKeys.MenuKeyNavigation },
|
||||
new() { MenuHeader = "NumericUpDown", Key = MenuKeys.MenuKeyNumericUpDown },
|
||||
new() { MenuHeader = "Message Box", Key = MenuKeys.MenuKeyMessageBox, Status = "New" },
|
||||
new() { MenuHeader = "Navigation", Key = MenuKeys.MenuKeyNavigation, Status = "WIP" },
|
||||
new() { MenuHeader = "NumericUpDown", Key = MenuKeys.MenuKeyNumericUpDown, Status = "New" },
|
||||
new() { MenuHeader = "Pagination", Key = MenuKeys.MenuKeyPagination },
|
||||
new() { MenuHeader = "RangeSlider", Key = MenuKeys.MenuKeyRangeSlider, Status = "New"},
|
||||
new() { MenuHeader = "TagInput", Key = MenuKeys.MenuKeyTagInput },
|
||||
new() { MenuHeader = "Timeline", Key = MenuKeys.MenuKeyTimeline },
|
||||
new() { MenuHeader = "Timeline", Key = MenuKeys.MenuKeyTimeline, Status = "Updated" },
|
||||
new() { MenuHeader = "TwoTonePathIcon", Key = MenuKeys.MenuKeyTwoTonePathIcon, Status = "New"},
|
||||
};
|
||||
}
|
||||
}
|
||||
16
demo/Ursa.Demo/ViewModels/RangeSliderDemoViewModel.cs
Normal file
16
demo/Ursa.Demo/ViewModels/RangeSliderDemoViewModel.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Avalonia.Layout;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public partial class RangeSliderDemoViewModel: ObservableObject
|
||||
{
|
||||
public ObservableCollection<Orientation> Orientations { get; set; } = new ObservableCollection<Orientation>()
|
||||
{
|
||||
Orientation.Horizontal,
|
||||
Orientation.Vertical
|
||||
};
|
||||
|
||||
[ObservableProperty] private Orientation _orientation;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public class TwoTonePathIconDemoViewModel:ObservableObject
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user