Merge branch 'main' into dark

This commit is contained in:
Dong Bin
2023-02-03 22:59:38 +08:00
committed by GitHub
23 changed files with 50 additions and 126 deletions

View File

@@ -1,5 +1,6 @@
using System;
using Avalonia;
using Avalonia.Dialogs;
using Avalonia.Media;
namespace Semi.Avalonia.Demo.Desktop;
@@ -26,7 +27,8 @@ class Program
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UseManagedSystemDialogs()
.UsePlatformDetect()
.With(new Win32PlatformOptions(){ UseCompositor = false})
.With(new Win32PlatformOptions())
.LogToTrace();
}

View File

@@ -11,9 +11,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview5" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.999-cibuild0029384-beta" />
</ItemGroup>
<ItemGroup>

View File

@@ -4,7 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Semi.Avalonia.Demo.Web">
<Application.Styles>
<FluentTheme Mode="Light" />
<FluentTheme />
<StyleInclude Source="avares://Semi.Avalonia/Themes/LightTheme.axaml" />
</Application.Styles>
</Application>

View File

@@ -1,25 +1,17 @@
using System.Runtime.Versioning;
using Avalonia;
using Avalonia.Media;
using Avalonia.Web;
using Semi.Avalonia.Demo.Web;
using Avalonia.Browser;
[assembly: SupportedOSPlatform("browser")]
internal partial class Program
{
private static void Main(string[] args) => BuildAvaloniaApp()
.With(new FontManagerOptions
{
FontFallbacks = new[]
{
new FontFallback
{
FontFamily = new FontFamily("avares://Semi.Avalonia.Demo.Web/Assets/SourceHanSansCN-Regular.otf#Source Han Sans CN")
}
}
})
.SetupBrowserApp("out");
private static void Main(string[] args)
{
BuildAvaloniaApp().SetupBrowserApp("out");
}
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>();

View File

@@ -19,8 +19,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview4" />
<PackageReference Include="Avalonia.Web" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Browser" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview5" />
</ItemGroup>
<ItemGroup>

View File

@@ -3,7 +3,6 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dialogs="clr-namespace:Avalonia.Dialogs;assembly=Avalonia.Dialogs"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"

View File

@@ -21,7 +21,8 @@ public partial class ManagedFileChooserDemo : UserControl
private async void OpenFileDialog(object sender, RoutedEventArgs args)
{
IStorageProvider sp = GetStorageProvider();
IStorageProvider? sp = GetStorageProvider();
if (sp is null) return;
var result = await sp.OpenFilePickerAsync(new FilePickerOpenOptions()
{
Title = "Open File",
@@ -31,7 +32,8 @@ public partial class ManagedFileChooserDemo : UserControl
}
private async void SelectFolderDialog(object sender, RoutedEventArgs args)
{
IStorageProvider sp = GetStorageProvider();
IStorageProvider? sp = GetStorageProvider();
if (sp is null) return;
var result = await sp.OpenFolderPickerAsync(new FolderPickerOpenOptions()
{
Title = "Select Folder",
@@ -40,27 +42,20 @@ public partial class ManagedFileChooserDemo : UserControl
}
private async void SaveFileDialog(object sender, RoutedEventArgs args)
{
IStorageProvider sp = GetStorageProvider();
IStorageProvider? sp = GetStorageProvider();
if (sp is null) return;
var result = await sp.SaveFilePickerAsync(new FilePickerSaveOptions()
{
Title = "Open File",
});
}
private IStorageProvider GetStorageProvider()
private IStorageProvider? GetStorageProvider()
{
return new ManagedStorageProvider<Window>(GetWindow(), null);
var topLevel = TopLevel.GetTopLevel(this);
return topLevel?.StorageProvider;
}
private static string FullPathOrName(IStorageItem? item)
{
if (item is null) return "(null)";
return item.TryGetUri(out var uri) ? uri.ToString() : item.Name;
}
Window GetWindow() => this.VisualRoot as Window ?? throw new NullReferenceException("Invalid Owner");
TopLevel GetTopLevel() => this.VisualRoot as TopLevel ?? throw new NullReferenceException("Invalid Owner");
List<FilePickerFileType>? GetFileTypes()
{
return new List<FilePickerFileType>

View File

@@ -12,7 +12,7 @@ namespace Semi.Avalonia.Demo.Pages;
public partial class NotificationDemo : UserControl
{
private MainWindow? _window;
private WindowNotificationManager _manager;
public NotificationDemo()
{
InitializeComponent();
@@ -21,14 +21,15 @@ public partial class NotificationDemo : UserControl
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToVisualTree(e);
_window = VisualRoot as MainWindow;
var topLevel = TopLevel.GetTopLevel(this);
_manager = new WindowNotificationManager(topLevel){ MaxItems = 3};
}
private void InfoButton_OnClick(object? sender, RoutedEventArgs e)
{
if (sender is Button b && b.Content is string s && Enum.TryParse<NotificationType>(s, out NotificationType t))
{
_window?.Notify(t);
_manager.Show(new Notification(t.ToString(), "This is message", t));
}
}
}

View File

@@ -11,9 +11,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview4" />
<PackageReference Include="Avalonia" Version="11.0.0-preview5" />
<!--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-preview4" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.999-cibuild0029384-beta" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.5.1" />
</ItemGroup>

View File

@@ -5,19 +5,8 @@ namespace Semi.Avalonia.Demo.Views;
public partial class MainWindow : Window
{
private readonly WindowNotificationManager _manager;
public MainWindow()
{
InitializeComponent();
_manager = new WindowNotificationManager(this)
{
Position = NotificationPosition.TopLeft,
MaxItems = 3
};
}
internal void Notify(NotificationType t)
{
_manager.Show(new Notification(t.ToString(), "This is a notification message", t));
}
}