From 7d7cc91d557ec197243ecd66dfe8a19d1ea311d0 Mon Sep 17 00:00:00 2001 From: RMBGAME Date: Tue, 11 Jul 2023 04:05:08 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20=E9=80=9A=E7=94=A8=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/Styling/Controls/ContentLoader.axaml | 6 +- .../UI/Styling/Controls/PageBase.axaml | 78 +++++++++++++------ .../UI/Views/Abstractions/Pages/PageBase.cs | 19 ++++- .../UI/Views/Controls/ContentLoader.cs | 50 ++++++++++++ .../UI/Views/Pages/DebugPage.axaml | 19 +++++ .../UI/Views/Pages/GameListPage.axaml | 9 ++- 6 files changed, 153 insertions(+), 28 deletions(-) diff --git a/src/BD.WTTS.Client.Avalonia/UI/Styling/Controls/ContentLoader.axaml b/src/BD.WTTS.Client.Avalonia/UI/Styling/Controls/ContentLoader.axaml index 0ca6ee71d..0e444e1ec 100644 --- a/src/BD.WTTS.Client.Avalonia/UI/Styling/Controls/ContentLoader.axaml +++ b/src/BD.WTTS.Client.Avalonia/UI/Styling/Controls/ContentLoader.axaml @@ -6,7 +6,7 @@ x:CompileBindings="True"> - + @@ -50,7 +50,9 @@ + IsVisible="{TemplateBinding IsShowNoResultText}" + Text="{TemplateBinding NoResultMessage}" + Theme="{StaticResource SubtitleTextBlockStyle}" /> + + + + + + + + - - - + + + + + + + + + - - - + + + + diff --git a/src/BD.WTTS.Client.Avalonia/UI/Views/Abstractions/Pages/PageBase.cs b/src/BD.WTTS.Client.Avalonia/UI/Views/Abstractions/Pages/PageBase.cs index bf438534e..2e4755bd7 100644 --- a/src/BD.WTTS.Client.Avalonia/UI/Views/Abstractions/Pages/PageBase.cs +++ b/src/BD.WTTS.Client.Avalonia/UI/Views/Abstractions/Pages/PageBase.cs @@ -1,4 +1,3 @@ -using Avalonia.Controls; using Avalonia.Rendering.Composition; namespace BD.WTTS.UI.Views.Pages; @@ -47,6 +46,12 @@ public class PageBase : UserControl public static readonly StyledProperty HeaderBackgroundProperty = AvaloniaProperty.Register(nameof(HeaderBackground)); + public static readonly StyledProperty PaneContentProperty = + AvaloniaProperty.Register(nameof(PaneContent)); + + public static readonly StyledProperty IsPaneOpenProperty = + SplitView.IsPaneOpenProperty.AddOwner(); + public string Title { get => GetValue(TitleProperty); @@ -89,12 +94,24 @@ public class PageBase : UserControl set => SetValue(ActionContentProperty, value); } + public object? PaneContent + { + get => GetValue(PaneContentProperty); + set => SetValue(PaneContentProperty, value); + } + public bool IsShowBackgroundImage { get => GetValue(IsShowBackgroundImageProperty); set => SetValue(IsShowBackgroundImageProperty, value); } + public bool IsPaneOpen + { + get => GetValue(IsPaneOpenProperty); + set => SetValue(IsPaneOpenProperty, value); + } + public IBrush? HeaderBackground { get => GetValue(HeaderBackgroundProperty); diff --git a/src/BD.WTTS.Client.Avalonia/UI/Views/Controls/ContentLoader.cs b/src/BD.WTTS.Client.Avalonia/UI/Views/Controls/ContentLoader.cs index a09668219..6234685bf 100644 --- a/src/BD.WTTS.Client.Avalonia/UI/Views/Controls/ContentLoader.cs +++ b/src/BD.WTTS.Client.Avalonia/UI/Views/Controls/ContentLoader.cs @@ -1,4 +1,6 @@ using Avalonia.Controls; +using DynamicData; +using FluentAvalonia.Core; namespace BD.WTTS.UI.Views.Controls; @@ -40,6 +42,18 @@ public class ContentLoader : ContentControl public static readonly StyledProperty IsIndeterminateProperty = AvaloniaProperty.Register(nameof(IsIndeterminate), true); + /// + /// Defines the property + /// + public static readonly StyledProperty IsShowNoResultTextProperty = + AvaloniaProperty.Register(nameof(IsShowNoResultText), false); + + /// + /// Defines the property. + /// + public static readonly StyledProperty ItemsSourceProperty = + ItemsControl.ItemsSourceProperty.AddOwner(); + /// /// 是否正在加载中 /// @@ -55,6 +69,12 @@ public class ContentLoader : ContentControl set => SetValue(IsIndeterminateProperty, value); } + public bool IsShowNoResultText + { + get => GetValue(IsShowNoResultTextProperty); + set => SetValue(IsShowNoResultTextProperty, value); + } + /// /// 无结果时提示 /// @@ -85,6 +105,12 @@ public class ContentLoader : ContentControl set => SetValue(MaximumProperty, value); } + public IEnumerable? ItemsSource + { + get => GetValue(ItemsSourceProperty); + set => SetValue(ItemsSourceProperty, value); + } + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs e) { base.OnPropertyChanged(e); @@ -104,5 +130,29 @@ public class ContentLoader : ContentControl } } } + else if (e.Property == ItemsSourceProperty) + { + var items = e.GetNewValue(); + if (items == null) + { + IsLoading = true; + IsShowNoResultText = false; + } + else if (items.Count() == 0) + { + IsLoading = false; + IsShowNoResultText = true; + } + else if (items.Count() != 0) + { + IsLoading = false; + IsShowNoResultText = false; + } + else + { + IsLoading = true; + IsShowNoResultText = false; + } + } } } diff --git a/src/BD.WTTS.Client.Avalonia/UI/Views/Pages/DebugPage.axaml b/src/BD.WTTS.Client.Avalonia/UI/Views/Pages/DebugPage.axaml index 7452cb0d3..36bea663b 100644 --- a/src/BD.WTTS.Client.Avalonia/UI/Views/Pages/DebugPage.axaml +++ b/src/BD.WTTS.Client.Avalonia/UI/Views/Pages/DebugPage.axaml @@ -72,6 +72,25 @@ Text="Action Button" /> + + + + + + + + - +