Merge branch 'main' into dialog
This commit is contained in:
@@ -9,6 +9,7 @@ public static class MenuKeys
|
||||
public const string MenuKeyDialog = "Dialog";
|
||||
public const string MenuKeyDivider = "Divider";
|
||||
public const string MenuKeyDualBadge = "DualBadge";
|
||||
public const string MenuKeyEnumSelector = "EnumSelector";
|
||||
public const string MenuKeyImageViewer = "ImageViewer";
|
||||
public const string MenuKeyIpBox = "IPv4Box";
|
||||
public const string MenuKeyIconButton = "IconButton";
|
||||
@@ -18,7 +19,9 @@ public static class MenuKeys
|
||||
public const string MenuKeyNavigation = "Navigation";
|
||||
public const string MenuKeyNumericUpDown = "NumericUpDown";
|
||||
public const string MenuKeyPagination = "Pagination";
|
||||
public const string MenuKeyRangeSlider = "RangeSlider";
|
||||
public const string MenuKeyTagInput = "TagInput";
|
||||
public const string MenuKeyTimeline = "Timeline";
|
||||
public const string MenuKeyTwoTonePathIcon = "TwoTonePathIcon";
|
||||
|
||||
}
|
||||
@@ -13,10 +13,23 @@
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Margin="20" Spacing="20">
|
||||
<u:ButtonGroup Classes="Primary Solid" ItemsSource="{Binding Items}" />
|
||||
<u:ButtonGroup Classes="Primary" ItemsSource="{Binding Items}" />
|
||||
<u:ButtonGroup Classes="Primary Borderless" ItemsSource="{Binding Items}" />
|
||||
<u:ButtonGroup Classes="Primary Large" ItemsSource="{Binding Items}" />
|
||||
<u:ButtonGroup Classes="Primary Small" ItemsSource="{Binding Items}" />
|
||||
<u:ButtonGroup Classes="Primary Solid"
|
||||
CommandBinding="{Binding InvokeCommand}"
|
||||
ItemsSource="{Binding Items}" >
|
||||
<u:ButtonGroup.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:ButtonItem">
|
||||
<TextBlock>
|
||||
<Run Text="🐼"></Run>
|
||||
<Run Text="{Binding Name}"></Run>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</u:ButtonGroup.ItemTemplate>
|
||||
</u:ButtonGroup>
|
||||
|
||||
<u:ButtonGroup Classes="Primary"
|
||||
ContentBinding="{Binding Name}"
|
||||
CommandBinding="{Binding InvokeCommand}"
|
||||
ItemsSource="{Binding Items}" >
|
||||
</u:ButtonGroup>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
30
demo/Ursa.Demo/Pages/EnumSelectorDemo.axaml
Normal file
30
demo/Ursa.Demo/Pages/EnumSelectorDemo.axaml
Normal file
@@ -0,0 +1,30 @@
|
||||
<UserControl
|
||||
x:Class="Ursa.Demo.Pages.EnumSelectorDemo"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
xmlns:vm="clr-namespace:Ursa.Demo.ViewModels;assembly=Ursa.Demo"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:EnumSelectorDemoViewModel"
|
||||
mc:Ignorable="d">
|
||||
<StackPanel>
|
||||
<ToggleSwitch Name="description" Content="Show Description" />
|
||||
<TextBlock Text="Select Type" />
|
||||
<ComboBox
|
||||
Width="200"
|
||||
DisplayMemberBinding="{Binding Name}"
|
||||
ItemsSource="{Binding Types}"
|
||||
SelectedItem="{Binding SelectedType}" />
|
||||
<TextBlock Text="Select Value" />
|
||||
<u:EnumSelector
|
||||
Width="200"
|
||||
DisplayDescription="{Binding #description.IsChecked}"
|
||||
EnumType="{Binding SelectedType}"
|
||||
Value="{Binding Value}" />
|
||||
<TextBlock Text="{Binding Value}" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
13
demo/Ursa.Demo/Pages/EnumSelectorDemo.axaml.cs
Normal file
13
demo/Ursa.Demo/Pages/EnumSelectorDemo.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Ursa.Demo.Pages;
|
||||
|
||||
public partial class EnumSelectorDemo : UserControl
|
||||
{
|
||||
public EnumSelectorDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
52
demo/Ursa.Demo/Pages/RangeSliderDemo.axaml
Normal file
52
demo/Ursa.Demo/Pages/RangeSliderDemo.axaml
Normal file
@@ -0,0 +1,52 @@
|
||||
<UserControl
|
||||
x:Class="Ursa.Demo.Pages.RangeSliderDemo"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
xmlns:vm="using:Ursa.Demo.ViewModels"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:RangeSliderDemoViewModel"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Styles>
|
||||
<Style Selector="u|NumericDoubleUpDown">
|
||||
<Setter Property="Width" Value="300" />
|
||||
</Style>
|
||||
</UserControl.Styles>
|
||||
<StackPanel>
|
||||
<u:RangeSlider
|
||||
IsSnapToTick="True"
|
||||
TickFrequency="5"
|
||||
TickPlacement="TopLeft"
|
||||
Minimum="{Binding #range.Minimum, Mode=TwoWay}"
|
||||
Maximum="{Binding #range.Maximum, Mode=TwoWay}"
|
||||
LowerValue="{Binding #range.LowerValue, Mode=TwoWay}"
|
||||
UpperValue="{Binding #range.UpperValue, Mode=TwoWay}"/>
|
||||
<u:NumericDoubleUpDown InnerLeftContent="Minimum" Value="{Binding #range.Minimum, Mode=TwoWay}" />
|
||||
<u:NumericDoubleUpDown InnerLeftContent="Maximum" Value="{Binding #range.Maximum, Mode=TwoWay}" />
|
||||
<u:NumericDoubleUpDown InnerLeftContent="LowerValue" Value="{Binding #range.LowerValue, Mode=TwoWay}" />
|
||||
<u:NumericDoubleUpDown InnerLeftContent="UpperValue" Value="{Binding #range.UpperValue, Mode=TwoWay}" />
|
||||
<ComboBox ItemsSource="{Binding Orientations}" SelectedItem="{Binding Orientation}" />
|
||||
<u:RangeSlider
|
||||
Name="range"
|
||||
Margin="8"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Orientation="{Binding Orientation}"
|
||||
TickFrequency="5">
|
||||
<u:RangeSlider.Styles>
|
||||
<Style Selector="u|RangeSlider:horizontal">
|
||||
<Setter Property="Width" Value="400" />
|
||||
<Setter Property="Height" Value="40" />
|
||||
</Style>
|
||||
<Style Selector="u|RangeSlider:vertical">
|
||||
<Setter Property="Width" Value="40" />
|
||||
<Setter Property="Height" Value="400" />
|
||||
</Style>
|
||||
</u:RangeSlider.Styles>
|
||||
</u:RangeSlider>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
15
demo/Ursa.Demo/Pages/RangeSliderDemo.axaml.cs
Normal file
15
demo/Ursa.Demo/Pages/RangeSliderDemo.axaml.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Ursa.Demo.ViewModels;
|
||||
|
||||
namespace Ursa.Demo.Pages;
|
||||
|
||||
public partial class RangeSliderDemo : UserControl
|
||||
{
|
||||
public RangeSliderDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new RangeSliderDemoViewModel();
|
||||
}
|
||||
}
|
||||
18
demo/Ursa.Demo/Pages/TwoTonePathIconDemo.axaml
Normal file
18
demo/Ursa.Demo/Pages/TwoTonePathIconDemo.axaml
Normal file
@@ -0,0 +1,18 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Ursa.Demo.Pages.TwoTonePathIconDemo">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Size"></TextBlock>
|
||||
<Slider Name="width" Minimum="0" Maximum="100" Value="20" Width="300"></Slider>
|
||||
<ToggleSwitch Name="active" Content="Active"></ToggleSwitch>
|
||||
<u:TwoTonePathIcon
|
||||
IsActive="{Binding ElementName=active, Path=IsChecked}"
|
||||
Width="{Binding #width.Value}"
|
||||
Height="{Binding #width.Value}"
|
||||
Data="M12 3L2 12H5V20H19V12H22L12 3M13 18H11V16H13V18M13 14H11V8H13V14Z"/>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
13
demo/Ursa.Demo/Pages/TwoTonePathIconDemo.axaml.cs
Normal file
13
demo/Ursa.Demo/Pages/TwoTonePathIconDemo.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Ursa.Demo.Pages;
|
||||
|
||||
public partial class TwoTonePathIconDemo : UserControl
|
||||
{
|
||||
public TwoTonePathIconDemo()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
@@ -43,8 +43,21 @@
|
||||
<DataTemplate DataType="vm:MenuItemViewModel">
|
||||
<u:NavigationMenuItem
|
||||
Command="{Binding ActivateCommand}"
|
||||
Header="{Binding MenuHeader}"
|
||||
Header="{Binding}"
|
||||
ItemsSource="{Binding Children}">
|
||||
<u:NavigationMenuItem.HeaderTemplate>
|
||||
<DataTemplate x:DataType="vm:MenuItemViewModel">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock HorizontalAlignment="Left" Text="{Binding MenuHeader}" />
|
||||
<u:Badge
|
||||
Margin="8,0,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
BadgeContent="{Binding Status}"
|
||||
CornerPosition="TopRight" />
|
||||
</StackPanel>
|
||||
|
||||
</DataTemplate>
|
||||
</u:NavigationMenuItem.HeaderTemplate>
|
||||
<u:NavigationMenuItem.Icon>
|
||||
<Border
|
||||
Width="10"
|
||||
|
||||
Reference in New Issue
Block a user