Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Avalonia preview5 #65

Merged
merged 6 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion demo/Semi.Avalonia.Demo.Desktop/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Avalonia;
using Avalonia.Dialogs;
using Avalonia.Media;

namespace Semi.Avalonia.Demo.Desktop;
Expand All @@ -26,7 +27,8 @@ public static void Main(string[] args) => BuildAvaloniaApp()
// 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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion demo/Semi.Avalonia.Demo.Web/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
18 changes: 5 additions & 13 deletions demo/Semi.Avalonia.Demo.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -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>();
Expand Down
4 changes: 2 additions & 2 deletions demo/Semi.Avalonia.Demo.Web/Semi.Avalonia.Demo.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 0 additions & 1 deletion demo/Semi.Avalonia.Demo/Pages/ManagedFileChooserDemo.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 9 additions & 14 deletions demo/Semi.Avalonia.Demo/Pages/ManagedFileChooserDemo.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public ManagedFileChooserDemo()

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",
Expand All @@ -31,7 +32,8 @@ private async void OpenFileDialog(object sender, RoutedEventArgs args)
}
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",
Expand All @@ -40,27 +42,20 @@ private async void SelectFolderDialog(object sender, RoutedEventArgs args)
}
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>
Expand Down
7 changes: 4 additions & 3 deletions demo/Semi.Avalonia.Demo/Pages/NotificationDemo.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Semi.Avalonia.Demo.Pages;

public partial class NotificationDemo : UserControl
{
private MainWindow? _window;
private WindowNotificationManager _manager;
public NotificationDemo()
{
InitializeComponent();
Expand All @@ -21,14 +21,15 @@ public NotificationDemo()
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));
}
}
}
4 changes: 2 additions & 2 deletions demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
11 changes: 0 additions & 11 deletions demo/Semi.Avalonia.Demo/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
17 changes: 8 additions & 9 deletions src/Semi.Avalonia/Controls/Carousel.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
<ControlTheme x:Key="{x:Type Carousel}" TargetType="Carousel">
<Setter Property="Template">
<ControlTemplate>
<Border
<ScrollViewer
Name="PART_ScrollViewer"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<CarouselPresenter
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsPresenter
Name="PART_ItemsPresenter"
Margin="{TemplateBinding Padding}"
IsVirtualized="{TemplateBinding IsVirtualized}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
PageTransition="{TemplateBinding PageTransition}"
SelectedIndex="{TemplateBinding SelectedIndex}" />
</Border>
ItemsPanel="{TemplateBinding ItemsPanel}" />
</ScrollViewer>
</ControlTemplate>
</Setter>
</ControlTheme>
Expand Down
5 changes: 1 addition & 4 deletions src/Semi.Avalonia/Controls/ComboBox.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,7 @@
<ItemsPresenter
Name="PART_ItemsPresenter"
Margin="{DynamicResource ComboBoxDropdownContentMargin}"
ItemTemplate="{TemplateBinding ItemTemplate}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
VirtualizationMode="{TemplateBinding VirtualizationMode}" />
ItemsPanel="{TemplateBinding ItemsPanel}" />
</ScrollViewer>
</Border>
</Popup>
Expand Down
2 changes: 0 additions & 2 deletions src/Semi.Avalonia/Controls/ContextMenu.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
<ItemsPresenter
Name="PART_ItemsPresenter"
Grid.IsSharedSizeScope="True"
ItemTemplate="{TemplateBinding ItemTemplate}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
KeyboardNavigation.TabNavigation="Continue" />
</ScrollViewer>
Expand Down
1 change: 0 additions & 1 deletion src/Semi.Avalonia/Controls/DatePicker.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<Setter Property="MinWidth" Value="296" />
<Setter Property="MaxHeight" Value="300" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="Background" Value="White" />
<Setter Property="CornerRadius" Value="6" />
<Setter Property="Template">
Expand Down
6 changes: 1 addition & 5 deletions src/Semi.Avalonia/Controls/ItemsControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<ItemsPresenter
Name="PART_ItemsPresenter"
ItemTemplate="{TemplateBinding ItemTemplate}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}" />
<ItemsPresenter Name="PART_ItemsPresenter" ItemsPanel="{TemplateBinding ItemsPanel}" />
</Border>
</ControlTemplate>
</Setter>
Expand Down
5 changes: 1 addition & 4 deletions src/Semi.Avalonia/Controls/ListBox.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
<ItemsPresenter
Name="PART_ItemsPresenter"
Margin="{TemplateBinding Padding}"
ItemTemplate="{TemplateBinding ItemTemplate}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
VirtualizationMode="{TemplateBinding VirtualizationMode}" />
ItemsPanel="{TemplateBinding ItemsPanel}" />
</ScrollViewer>
</Border>
</ControlTemplate>
Expand Down
9 changes: 5 additions & 4 deletions src/Semi.Avalonia/Controls/ManagedFileChooser.axaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dialogs="clr-namespace:Avalonia.Dialogs;assembly=Avalonia.Dialogs">
xmlns:dialogs="clr-namespace:Avalonia.Dialogs;assembly=Avalonia.Dialogs"
xmlns:internal="clr-namespace:Avalonia.Dialogs.Internal;assembly=Avalonia.Dialogs">
<!-- Add Resources Here -->
<Design.PreviewWith>
<Border
Expand All @@ -12,11 +13,11 @@
</Border>
</Design.PreviewWith>

<dialogs:ResourceSelectorConverter x:Key="Icons">
<internal:ResourceSelectorConverter x:Key="Icons">
<PathGeometry x:Key="Icon_Folder">M19,20H4C2.89,20 2,19.1 2,18V6C2,4.89 2.89,4 4,4H10L12,6H19A2,2 0 0,1 21,8H21L4,8V18L6.14,10H23.21L20.93,18.5C20.7,19.37 19.92,20 19,20Z</PathGeometry>
<PathGeometry x:Key="Icon_File">M13,9H18.5L13,3.5V9M6,2H14L20,8V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V4C4,2.89 4.89,2 6,2M15,18V16H6V18H15M18,14V12H6V14H18Z</PathGeometry>
<PathGeometry x:Key="Icon_Volume">M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M12,4A6,6 0 0,0 6,10C6,13.31 8.69,16 12.1,16L11.22,13.77C10.95,13.29 11.11,12.68 11.59,12.4L12.45,11.9C12.93,11.63 13.54,11.79 13.82,12.27L15.74,14.69C17.12,13.59 18,11.9 18,10A6,6 0 0,0 12,4M12,9A1,1 0 0,1 13,10A1,1 0 0,1 12,11A1,1 0 0,1 11,10A1,1 0 0,1 12,9M7,18A1,1 0 0,0 6,19A1,1 0 0,0 7,20A1,1 0 0,0 8,19A1,1 0 0,0 7,18M12.09,13.27L14.58,19.58L17.17,18.08L12.95,12.77L12.09,13.27Z</PathGeometry>
</dialogs:ResourceSelectorConverter>
</internal:ResourceSelectorConverter>
<ControlTheme x:Key="{x:Type dialogs:ManagedFileChooser}" TargetType="dialogs:ManagedFileChooser">
<Setter Property="dialogs:ManagedFileChooser.Template">
<ControlTemplate TargetType="dialogs:ManagedFileChooser">
Expand Down Expand Up @@ -169,7 +170,7 @@
<TextBlock.Text>
<Binding Path="Size">
<Binding.Converter>
<dialogs:FileSizeStringConverter />
<internal:FileSizeStringConverter />
</Binding.Converter>
</Binding>
</TextBlock.Text>
Expand Down
6 changes: 0 additions & 6 deletions src/Semi.Avalonia/Controls/Menu.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@
<ItemsPresenter
Name="PART_ItemsPresenter"
Grid.IsSharedSizeScope="True"
ItemTemplate="{TemplateBinding ItemTemplate}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}" />
</ScrollViewer>
</Border>
Expand Down Expand Up @@ -299,8 +297,6 @@
<ItemsPresenter
Name="PART_ItemsPresenter"
Grid.IsSharedSizeScope="True"
ItemTemplate="{TemplateBinding ItemTemplate}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}" />
</ScrollViewer>
</Border>
Expand Down Expand Up @@ -343,8 +339,6 @@
<ItemsPresenter
Name="PART_ItemsPresenter"
VerticalAlignment="Stretch"
ItemTemplate="{TemplateBinding ItemTemplate}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
KeyboardNavigation.TabNavigation="Continue" />
</Border>
Expand Down
2 changes: 0 additions & 2 deletions src/Semi.Avalonia/Controls/MenuFlyoutPresenter.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
Name="PART_ItemsPresenter"
Margin="{DynamicResource MenuFlyoutScrollerMargin}"
Grid.IsSharedSizeScope="True"
ItemTemplate="{TemplateBinding ItemTemplate}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}"
KeyboardNavigation.TabNavigation="Continue" />
</ScrollViewer>
Expand Down
6 changes: 1 addition & 5 deletions src/Semi.Avalonia/Controls/TabControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
CornerRadius="{TemplateBinding CornerRadius}">
<DockPanel>
<Panel DockPanel.Dock="{TemplateBinding TabStripPlacement}">
<ItemsPresenter
Name="PART_ItemsPresenter"
ItemTemplate="{TemplateBinding ItemTemplate}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}" />
<ItemsPresenter Name="PART_ItemsPresenter" ItemsPanel="{TemplateBinding ItemsPanel}" />
<Border Name="PART_BorderSeparator" Background="{DynamicResource TabItemLinePipePressedBorderBrush}" />
</Panel>
<ContentPresenter
Expand Down
6 changes: 1 addition & 5 deletions src/Semi.Avalonia/Controls/TabStrip.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Panel>
<ItemsPresenter
Name="PART_ItemsPresenter"
ItemTemplate="{TemplateBinding ItemTemplate}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}" />
<ItemsPresenter Name="PART_ItemsPresenter" ItemsPanel="{TemplateBinding ItemsPanel}" />
<Border
Name="PART_BorderSeparator"
Height="1"
Expand Down
2 changes: 0 additions & 2 deletions src/Semi.Avalonia/Controls/TreeView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
<ItemsPresenter
Name="PART_ItemsPresenter"
Margin="{TemplateBinding Padding}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}" />
</ScrollViewer>
</Border>
Expand Down Expand Up @@ -139,7 +138,6 @@
<ItemsPresenter
Name="PART_ItemsPresenter"
IsVisible="{TemplateBinding IsExpanded}"
Items="{TemplateBinding Items}"
ItemsPanel="{TemplateBinding ItemsPanel}" />
</StackPanel>
</ControlTemplate>
Expand Down
Loading