Merge branch 'upgrade' into badge
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
<Application
|
||||
x:Class="Ursa.Demo.App"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Ursa.Demo">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Application.Styles>
|
||||
<StyleInclude Source="avares://Semi.Avalonia/Themes/Index.axaml" />
|
||||
<StyleInclude Source="avares://Ursa.Themes.Semi/Index.axaml" />
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
</Application>
|
||||
@@ -1,7 +1,5 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Data.Core;
|
||||
using Avalonia.Data.Core.Plugins;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Ursa.Demo.ViewModels;
|
||||
using Ursa.Demo.Views;
|
||||
@@ -19,11 +17,16 @@ public partial class App : Application
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
// Line below is needed to remove Avalonia data validation.
|
||||
// Without this line you will get duplicate validations from both Avalonia and CT
|
||||
desktop.MainWindow = new MainWindow
|
||||
desktop.MainWindow = new MainWindow()
|
||||
{
|
||||
DataContext = new MainWindowViewModel(),
|
||||
DataContext = new MainViewViewModel(),
|
||||
};
|
||||
}
|
||||
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleView)
|
||||
{
|
||||
singleView.MainView = new MainView()
|
||||
{
|
||||
DataContext = new MainViewViewModel(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
using Avalonia;
|
||||
using System;
|
||||
|
||||
namespace Ursa.Demo;
|
||||
|
||||
class Program
|
||||
{
|
||||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
||||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
||||
// yet and stuff might break.
|
||||
[STAThread]
|
||||
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.LogToTrace();
|
||||
}
|
||||
@@ -1,33 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AvaloniaResource Include="Assets\**" />
|
||||
<None Remove=".gitignore" />
|
||||
<AvaloniaResource Include="Assets\**"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<TrimmerRootDescriptor Include="Roots.xml" />
|
||||
<TrimmerRootDescriptor Include="Roots.xml"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-rc1.1" />
|
||||
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)"/>
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-rc1.1" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
|
||||
<PackageReference Include="Semi.Avalonia" Version="11.0.0-rc1" />
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)"/>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0"/>
|
||||
<PackageReference Include="Semi.Avalonia" Version="11.0.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Ursa.Themes.Semi\Ursa.Themes.Semi.csproj" />
|
||||
<ProjectReference Include="..\..\src\Ursa\Ursa.csproj" />
|
||||
<ProjectReference Include="..\..\src\Ursa.Themes.Semi\Ursa.Themes.Semi.csproj"/>
|
||||
<ProjectReference Include="..\..\src\Ursa\Ursa.csproj"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
39
demo/Ursa.Demo/ViewModels/MainViewViewModel.cs
Normal file
39
demo/Ursa.Demo/ViewModels/MainViewViewModel.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public class MainViewViewModel : ViewModelBase
|
||||
{
|
||||
public MenuViewModel Menus { get; set; } = new MenuViewModel();
|
||||
|
||||
private object? _content;
|
||||
|
||||
public object? Content
|
||||
{
|
||||
get => _content;
|
||||
set => SetProperty(ref _content, value);
|
||||
}
|
||||
|
||||
public MainViewViewModel()
|
||||
{
|
||||
WeakReferenceMessenger.Default.Register<MainViewViewModel, string>(this, OnNavigation);
|
||||
}
|
||||
|
||||
|
||||
private void OnNavigation(MainViewViewModel vm, string s)
|
||||
{
|
||||
Content = s switch
|
||||
{
|
||||
MenuKeys.MenuKeyBadge => new BadgeDemoViewModel(),
|
||||
MenuKeys.MenuKeyBanner => new BannerDemoViewModel(),
|
||||
MenuKeys.MenuKeyButtonGroup => new ButtonGroupDemoViewModel(),
|
||||
MenuKeys.MenuKeyDivider => new DividerDemoViewModel(),
|
||||
MenuKeys.MenuKeyIpBox => new IPv4BoxDemoViewModel(),
|
||||
MenuKeys.MenuKeyLoading => new LoadingDemoViewModel(),
|
||||
MenuKeys.MenuKeyNavigation => new NavigationMenuDemoViewModel(),
|
||||
MenuKeys.MenuKeyPagination => new PaginationDemoViewModel(),
|
||||
MenuKeys.MenuKeyTagInput => new TagInputDemoViewModel(),
|
||||
MenuKeys.MenuKeyTimeline => new TimelineDemoViewModel(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,6 @@
|
||||
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
public MenuViewModel Menus { get; set; } = new MenuViewModel();
|
||||
|
||||
private object? _content;
|
||||
public object? Content
|
||||
{
|
||||
get => _content;
|
||||
set => SetProperty(ref _content, value);
|
||||
}
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
WeakReferenceMessenger.Default.Register<MainWindowViewModel, string>(this, OnNavigation);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void OnNavigation(MainWindowViewModel vm, string s)
|
||||
{
|
||||
Content = s switch
|
||||
{
|
||||
MenuKeys.MenuKeyBadge => new BadgeDemoViewModel(),
|
||||
MenuKeys.MenuKeyBanner => new BannerDemoViewModel(),
|
||||
MenuKeys.MenuKeyButtonGroup => new ButtonGroupDemoViewModel(),
|
||||
MenuKeys.MenuKeyDivider => new DividerDemoViewModel(),
|
||||
MenuKeys.MenuKeyIpBox => new IPv4BoxDemoViewModel(),
|
||||
MenuKeys.MenuKeyLoading => new LoadingDemoViewModel(),
|
||||
MenuKeys.MenuKeyNavigation => new NavigationMenuDemoViewModel(),
|
||||
MenuKeys.MenuKeyPagination => new PaginationDemoViewModel(),
|
||||
MenuKeys.MenuKeyTagInput => new TagInputDemoViewModel(),
|
||||
MenuKeys.MenuKeyTimeline => new TimelineDemoViewModel(),
|
||||
};
|
||||
}
|
||||
public MainViewViewModel MainViewViewModel { get; set; } = new MainViewViewModel();
|
||||
}
|
||||
85
demo/Ursa.Demo/Views/MainView.axaml
Normal file
85
demo/Ursa.Demo/Views/MainView.axaml
Normal file
@@ -0,0 +1,85 @@
|
||||
<UserControl
|
||||
x:Class="Ursa.Demo.Views.MainView"
|
||||
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"
|
||||
xmlns:vm="using:Ursa.Demo.ViewModels"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:MainViewViewModel"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Design.DataContext>
|
||||
<vm:MainViewViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
<Grid ColumnDefinitions="Auto, *" RowDefinitions="Auto, *">
|
||||
<Border
|
||||
Grid.RowSpan="2"
|
||||
Padding="8,4"
|
||||
VerticalAlignment="Stretch"
|
||||
Theme="{DynamicResource CardBorder}">
|
||||
<u:NavigationMenu ItemsSource="{Binding Menus.MenuItems}" ShowCollapseButton="True">
|
||||
<u:NavigationMenu.Header>
|
||||
<TextBlock
|
||||
Classes="H4"
|
||||
Text="Ursa"
|
||||
Theme="{DynamicResource TitleTextBlock}" />
|
||||
</u:NavigationMenu.Header>
|
||||
<u:NavigationMenu.Icon>
|
||||
<Image
|
||||
Width="48"
|
||||
Height="48"
|
||||
RenderOptions.BitmapInterpolationMode="HighQuality"
|
||||
Source="../Assets/Ursa.ico" />
|
||||
</u:NavigationMenu.Icon>
|
||||
<u:NavigationMenu.ItemTemplate>
|
||||
<converters:MenuDataTemplateSelector>
|
||||
<converters:MenuDataTemplateSelector.MenuTemplate>
|
||||
<DataTemplate DataType="vm:MenuItemViewModel">
|
||||
<u:NavigationMenuItem
|
||||
Command="{Binding ActivateCommand}"
|
||||
Header="{Binding MenuHeader}"
|
||||
ItemsSource="{Binding Children}">
|
||||
<u:NavigationMenuItem.Icon>
|
||||
<Border
|
||||
Width="10"
|
||||
Height="10"
|
||||
Background="{DynamicResource SemiBlue6}"
|
||||
CornerRadius="3" />
|
||||
</u:NavigationMenuItem.Icon>
|
||||
</u:NavigationMenuItem>
|
||||
</DataTemplate>
|
||||
</converters:MenuDataTemplateSelector.MenuTemplate>
|
||||
<converters:MenuDataTemplateSelector.SeparatorTemplate>
|
||||
<DataTemplate DataType="vm:MenuItemViewModel">
|
||||
<u:NavigationMenuSeparator Header="{Binding MenuHeader}" />
|
||||
</DataTemplate>
|
||||
</converters:MenuDataTemplateSelector.SeparatorTemplate>
|
||||
</converters:MenuDataTemplateSelector>
|
||||
</u:NavigationMenu.ItemTemplate>
|
||||
</u:NavigationMenu>
|
||||
</Border>
|
||||
|
||||
<ToggleButton
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Right"
|
||||
Content="Update Theme"
|
||||
IsCheckedChanged="ToggleButton_OnIsCheckedChanged" />
|
||||
<ContentControl
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="12"
|
||||
Content="{Binding Content}">
|
||||
<ContentControl.ContentTemplate>
|
||||
<converters:ViewLocator />
|
||||
</ContentControl.ContentTemplate>
|
||||
</ContentControl>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
24
demo/Ursa.Demo/Views/MainView.axaml.cs
Normal file
24
demo/Ursa.Demo/Views/MainView.axaml.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Styling;
|
||||
|
||||
namespace Ursa.Demo.Views;
|
||||
|
||||
public partial class MainView : UserControl
|
||||
{
|
||||
public MainView()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,87 +2,16 @@
|
||||
x:Class="Ursa.Demo.Views.MainWindow"
|
||||
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:pages="clr-namespace:Ursa.Demo.Pages"
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
xmlns:vm="using:Ursa.Demo.ViewModels"
|
||||
xmlns:views="clr-namespace:Ursa.Demo.Views"
|
||||
xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels"
|
||||
Title="Ursa.Demo"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
x:DataType="viewModels:MainWindowViewModel"
|
||||
Icon="/Assets/Ursa.ico"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Design.DataContext>
|
||||
<vm:MainWindowViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
<Grid ColumnDefinitions="Auto, *" RowDefinitions="Auto, *">
|
||||
<Border
|
||||
Grid.RowSpan="2"
|
||||
Padding="8,4"
|
||||
VerticalAlignment="Stretch"
|
||||
Theme="{DynamicResource CardBorder}">
|
||||
<u:NavigationMenu ItemsSource="{Binding Menus.MenuItems}" ShowCollapseButton="True">
|
||||
<u:NavigationMenu.Header>
|
||||
<TextBlock
|
||||
Classes="H4"
|
||||
Text="Ursa"
|
||||
Theme="{DynamicResource TitleTextBlock}" />
|
||||
</u:NavigationMenu.Header>
|
||||
<u:NavigationMenu.Icon>
|
||||
<Image
|
||||
Width="48"
|
||||
Height="48"
|
||||
RenderOptions.BitmapInterpolationMode="HighQuality"
|
||||
Source="../Assets/Ursa.ico" />
|
||||
</u:NavigationMenu.Icon>
|
||||
<u:NavigationMenu.ItemTemplate>
|
||||
<converters:MenuDataTemplateSelector>
|
||||
<converters:MenuDataTemplateSelector.MenuTemplate>
|
||||
<DataTemplate DataType="vm:MenuItemViewModel">
|
||||
<u:NavigationMenuItem
|
||||
Command="{Binding ActivateCommand}"
|
||||
Header="{Binding MenuHeader}"
|
||||
ItemsSource="{Binding Children}">
|
||||
<u:NavigationMenuItem.Icon>
|
||||
<Border
|
||||
Width="10"
|
||||
Height="10"
|
||||
Background="{DynamicResource SemiBlue6}"
|
||||
CornerRadius="3" />
|
||||
</u:NavigationMenuItem.Icon>
|
||||
</u:NavigationMenuItem>
|
||||
</DataTemplate>
|
||||
</converters:MenuDataTemplateSelector.MenuTemplate>
|
||||
<converters:MenuDataTemplateSelector.SeparatorTemplate>
|
||||
<DataTemplate DataType="vm:MenuItemViewModel">
|
||||
<u:NavigationMenuSeparator Header="{Binding MenuHeader}" />
|
||||
</DataTemplate>
|
||||
</converters:MenuDataTemplateSelector.SeparatorTemplate>
|
||||
</converters:MenuDataTemplateSelector>
|
||||
</u:NavigationMenu.ItemTemplate>
|
||||
</u:NavigationMenu>
|
||||
</Border>
|
||||
|
||||
<ToggleButton
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Right"
|
||||
Content="Update Theme"
|
||||
IsCheckedChanged="ToggleButton_OnIsCheckedChanged" />
|
||||
<ContentControl
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="12"
|
||||
Content="{Binding Content}">
|
||||
<ContentControl.ContentTemplate>
|
||||
<converters:ViewLocator />
|
||||
</ContentControl.ContentTemplate>
|
||||
</ContentControl>
|
||||
</Grid>
|
||||
|
||||
</Window>
|
||||
<views:MainView />
|
||||
</Window>
|
||||
@@ -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 MainWindow : Window
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<!-- This manifest is used on Windows only.
|
||||
Don't remove it as it might cause problems with window transparency and embeded controls.
|
||||
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
|
||||
<assemblyIdentity version="1.0.0.0" name="AvaloniaTest.Desktop"/>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on
|
||||
and is designed to work with. Uncomment the appropriate elements
|
||||
and Windows will automatically select the most compatible environment. -->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
||||
Reference in New Issue
Block a user