mirror of
https://github.com/Pixeval/Pixeval.git
synced 2025-04-03 23:11:33 +08:00
使用GeneratedDependencyProperty (#649)
* 使用GeneratedDependencyProperty * Update Directory.Packages.props
This commit is contained in:
parent
89e07113fa
commit
df7ef2f06c
3
.gitignore
vendored
3
.gitignore
vendored
@ -360,7 +360,6 @@ MigrationBackup/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
src/Pixeval/Assets/Binary/Pixeval.LoginProxy.zip
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
@ -369,5 +368,7 @@ src/Pixeval/Assets/Binary/Pixeval.LoginProxy.zip
|
||||
# Poly#
|
||||
src/*/Generated
|
||||
|
||||
.generated
|
||||
|
||||
# Package.appxmanifest
|
||||
# Package.appxmanifest
|
||||
|
@ -1,53 +1,54 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock" Version="0.1.250129-build.2033" />
|
||||
<PackageVersion Include="CommunityToolkit.Labs.WinUI.Shimmer" Version="0.1.240517-build.1678" />
|
||||
<PackageVersion Include="CommunityToolkit.Labs.WinUI.TitleBar" Version="0.0.1-build.2033" />
|
||||
<PackageVersion Include="CommunityToolkit.Labs.WinUI.TokenView" Version="0.1.241129-build.1830" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Triggers" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Collections" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Extensions" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Behaviors" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Animations" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Controls.ColorPicker" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Segmented" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Controls.TokenizingTextBox" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Converters" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Media" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageVersion Include="CommunityToolkit.HighPerformance" Version="8.4.0" />
|
||||
<PackageVersion Include="FluentIcons.WinUI" Version="1.1.271" />
|
||||
<PackageVersion Include="Microsoft.Graphics.Win2D" Version="1.3.1" />
|
||||
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.162" />
|
||||
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
|
||||
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.6.250108002" />
|
||||
<PackageVersion Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="3.0.0" />
|
||||
<PackageVersion Include="WinUI3Utilities" Version="1.1.7.16" />
|
||||
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.1" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.1.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.1" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="9.0.1" />
|
||||
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
|
||||
<PackageVersion Include="WebApiClientCore" Version="2.1.5" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
|
||||
<PackageVersion Include="PolySharp" Version="1.15.0" />
|
||||
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
|
||||
<PackageVersion Include="CommunityToolkit.Diagnostics" Version="8.4.0" />
|
||||
<PackageVersion Include="JsonPoke" Version="1.2.0" />
|
||||
<PackageVersion Include="LiteDB" Version="5.0.21" />
|
||||
<PackageVersion Include="MinVer" Version="6.0.0" />
|
||||
<PackageVersion Include="PininSharp" Version="1.2.0" />
|
||||
<PackageVersion Include="Pixeval.Extensions.Common" Version="4.3.4.1" />
|
||||
<PackageVersion Include="Pixeval.QRCoder" Version="1.4.5" />
|
||||
<PackageVersion Include="QuestPDF" Version="2024.12.3" />
|
||||
<PackageVersion Include="ReverseMarkdown" Version="4.6.0" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.6" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="2.1.5" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock" Version="0.1.250129-build.2033" />
|
||||
<PackageVersion Include="CommunityToolkit.Labs.WinUI.DependencyPropertyGenerator" Version="0.1.250129-build.2033" />
|
||||
<PackageVersion Include="CommunityToolkit.Labs.WinUI.Shimmer" Version="0.1.240517-build.1678" />
|
||||
<PackageVersion Include="CommunityToolkit.Labs.WinUI.TitleBar" Version="0.0.1-build.2033" />
|
||||
<PackageVersion Include="CommunityToolkit.Labs.WinUI.TokenView" Version="0.1.241129-build.1830" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Triggers" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Collections" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Primitives" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Extensions" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Behaviors" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Animations" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Controls.ColorPicker" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Segmented" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Controls.TokenizingTextBox" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Converters" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.WinUI.Media" Version="8.1.240916" />
|
||||
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageVersion Include="CommunityToolkit.HighPerformance" Version="8.4.0" />
|
||||
<PackageVersion Include="FluentIcons.WinUI" Version="1.1.271" />
|
||||
<PackageVersion Include="Microsoft.Graphics.Win2D" Version="1.3.1" />
|
||||
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.162" />
|
||||
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
|
||||
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.6.250108002" />
|
||||
<PackageVersion Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="3.0.0" />
|
||||
<PackageVersion Include="WinUI3Utilities" Version="1.1.7.16" />
|
||||
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.1" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.1.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.1" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="9.0.1" />
|
||||
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
|
||||
<PackageVersion Include="WebApiClientCore" Version="2.1.5" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
|
||||
<PackageVersion Include="PolySharp" Version="1.15.0" />
|
||||
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
|
||||
<PackageVersion Include="CommunityToolkit.Diagnostics" Version="8.4.0" />
|
||||
<PackageVersion Include="JsonPoke" Version="1.2.0" />
|
||||
<PackageVersion Include="LiteDB" Version="5.0.21" />
|
||||
<PackageVersion Include="MinVer" Version="6.0.0" />
|
||||
<PackageVersion Include="PininSharp" Version="1.2.0" />
|
||||
<PackageVersion Include="Pixeval.Extensions.Common" Version="4.3.5-dev-1" />
|
||||
<PackageVersion Include="Pixeval.QRCoder" Version="1.4.5" />
|
||||
<PackageVersion Include="QuestPDF" Version="2024.12.3" />
|
||||
<PackageVersion Include="ReverseMarkdown" Version="4.6.0" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.6" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="2.1.5" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -0,0 +1,39 @@
|
||||
// Copyright (c) Pixeval.Controls.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
public partial class AdvancedItemsView
|
||||
{
|
||||
[GeneratedDependencyProperty(DefaultValue = ItemsViewLayoutType.LinedFlow)]
|
||||
public partial ItemsViewLayoutType LayoutType { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 0d)]
|
||||
public partial double MinItemHeight { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 0d)]
|
||||
public partial double MinItemWidth { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 5d)]
|
||||
public partial double MinRowSpacing { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 5d)]
|
||||
public partial double MinColumnSpacing { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 100d)]
|
||||
public partial double LoadingOffset { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = -1)]
|
||||
public partial int SelectedIndex { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = true)]
|
||||
public partial bool CanLoadMore { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = false)]
|
||||
public partial bool IsLoadingMore { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 20)]
|
||||
public partial int LoadCount { get; set; }
|
||||
}
|
@ -14,7 +14,6 @@ using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Pixeval.Collections;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
@ -22,16 +21,6 @@ namespace Pixeval.Controls;
|
||||
/// <see cref="ItemsView.ItemsSource"/>属性推荐使用<see cref="AdvancedObservableCollection{T}"/>类型
|
||||
/// </summary>
|
||||
/// <remarks><see cref="ItemsView.ItemTemplate"/>中必须使用<see cref="ItemContainer"/>作为根元素</remarks>
|
||||
[DependencyProperty<ItemsViewLayoutType>("LayoutType", DependencyPropertyDefaultValue.Default, nameof(OnLayoutTypeChanged))]
|
||||
[DependencyProperty<double>("MinItemHeight", "0d", nameof(OnItemHeightChanged))]
|
||||
[DependencyProperty<double>("MinItemWidth", "0d", nameof(OnItemWidthChanged))]
|
||||
[DependencyProperty<double>("MinRowSpacing", "5d", nameof(OnMinRowSpacingChanged))]
|
||||
[DependencyProperty<double>("MinColumnSpacing", "5d", nameof(OnMinColumnSpacingChanged))]
|
||||
[DependencyProperty<double>("LoadingOffset", "100d")]
|
||||
[DependencyProperty<int>("SelectedIndex", "-1", nameof(OnSelectedIndexChanged))]
|
||||
[DependencyProperty<bool>("CanLoadMore", "true")]
|
||||
[DependencyProperty<bool>("IsLoadingMore", "false")]
|
||||
[DependencyProperty<int>("LoadCount", "20")]
|
||||
public sealed partial class AdvancedItemsView : ItemsView
|
||||
{
|
||||
public event Func<AdvancedItemsView, EventArgs, Task<bool>> LoadMoreRequested;
|
||||
@ -110,148 +99,134 @@ public sealed partial class AdvancedItemsView : ItemsView
|
||||
|
||||
#region PropertyChanged
|
||||
|
||||
private static void OnItemHeightChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnMinItemHeightPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var advancedItemsView = o.To<AdvancedItemsView>();
|
||||
var minItemHeight = advancedItemsView.MinItemHeight;
|
||||
switch (advancedItemsView.Layout)
|
||||
switch (Layout)
|
||||
{
|
||||
case RiverFlowLayout linedFlowLayout:
|
||||
linedFlowLayout.LineHeight = minItemHeight;
|
||||
linedFlowLayout.LineHeight = MinItemHeight;
|
||||
break;
|
||||
case UniformGridLayout uniformGridLayout:
|
||||
uniformGridLayout.MinItemHeight = minItemHeight;
|
||||
uniformGridLayout.MinItemHeight = MinItemHeight;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnItemWidthChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnMinItemWidthPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var advancedItemsView = o.To<AdvancedItemsView>();
|
||||
var minItemWidth = advancedItemsView.MinItemWidth;
|
||||
switch (advancedItemsView.Layout)
|
||||
switch (Layout)
|
||||
{
|
||||
case StaggeredLayout staggeredLayout:
|
||||
staggeredLayout.DesiredColumnWidth = minItemWidth;
|
||||
staggeredLayout.DesiredColumnWidth = MinItemWidth;
|
||||
break;
|
||||
case UniformGridLayout uniformGridLayout:
|
||||
uniformGridLayout.MinItemWidth = minItemWidth;
|
||||
uniformGridLayout.MinItemWidth = MinItemWidth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnMinRowSpacingChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnMinRowSpacingPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var advancedItemsView = o.To<AdvancedItemsView>();
|
||||
var minRowSpacing = advancedItemsView.MinRowSpacing;
|
||||
switch (advancedItemsView.Layout)
|
||||
switch (Layout)
|
||||
{
|
||||
case RiverFlowLayout linedFlowLayout:
|
||||
linedFlowLayout.LineSpacing = minRowSpacing;
|
||||
linedFlowLayout.LineSpacing = MinRowSpacing;
|
||||
break;
|
||||
case UniformGridLayout uniformGridLayout:
|
||||
uniformGridLayout.MinRowSpacing = minRowSpacing;
|
||||
uniformGridLayout.MinRowSpacing = MinRowSpacing;
|
||||
break;
|
||||
case StaggeredLayout staggeredLayout:
|
||||
staggeredLayout.RowSpacing = minRowSpacing;
|
||||
staggeredLayout.RowSpacing = MinRowSpacing;
|
||||
break;
|
||||
case StackLayout stackLayout when advancedItemsView.LayoutType is ItemsViewLayoutType.VerticalStack:
|
||||
stackLayout.Spacing = minRowSpacing;
|
||||
case StackLayout stackLayout when LayoutType is ItemsViewLayoutType.VerticalStack:
|
||||
stackLayout.Spacing = MinRowSpacing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnMinColumnSpacingChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnMinColumnSpacingPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var advancedItemsView = o.To<AdvancedItemsView>();
|
||||
var minColumnSpacing = advancedItemsView.MinColumnSpacing;
|
||||
switch (advancedItemsView.Layout)
|
||||
switch (Layout)
|
||||
{
|
||||
case RiverFlowLayout linedFlowLayout:
|
||||
linedFlowLayout.MinItemSpacing = minColumnSpacing;
|
||||
linedFlowLayout.MinItemSpacing = MinColumnSpacing;
|
||||
break;
|
||||
case UniformGridLayout uniformGridLayout:
|
||||
uniformGridLayout.MinColumnSpacing = minColumnSpacing;
|
||||
uniformGridLayout.MinColumnSpacing = MinColumnSpacing;
|
||||
break;
|
||||
case StaggeredLayout staggeredLayout:
|
||||
staggeredLayout.ColumnSpacing = minColumnSpacing;
|
||||
staggeredLayout.ColumnSpacing = MinColumnSpacing;
|
||||
break;
|
||||
case StackLayout stackLayout when advancedItemsView.LayoutType is ItemsViewLayoutType.HorizontalStack:
|
||||
stackLayout.Spacing = minColumnSpacing;
|
||||
case StackLayout stackLayout when LayoutType is ItemsViewLayoutType.HorizontalStack:
|
||||
stackLayout.Spacing = MinColumnSpacing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnLayoutTypeChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnLayoutTypePropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var advancedItemsView = o.To<AdvancedItemsView>();
|
||||
var minItemHeight = advancedItemsView.MinItemHeight;
|
||||
var minItemWidth = advancedItemsView.MinItemWidth;
|
||||
var minRowSpacing = advancedItemsView.MinRowSpacing;
|
||||
var minColumnSpacing = advancedItemsView.MinColumnSpacing;
|
||||
advancedItemsView.Layout = advancedItemsView.LayoutType switch
|
||||
Layout = LayoutType switch
|
||||
{
|
||||
ItemsViewLayoutType.LinedFlow => new RiverFlowLayout
|
||||
{
|
||||
// ItemsStretch = LinedFlowLayoutItemsStretch.Fill,
|
||||
LineHeight = minItemHeight,
|
||||
LineSpacing = minRowSpacing,
|
||||
MinItemSpacing = minColumnSpacing
|
||||
LineHeight = MinItemHeight,
|
||||
LineSpacing = MinRowSpacing,
|
||||
MinItemSpacing = MinColumnSpacing
|
||||
},
|
||||
ItemsViewLayoutType.Grid => new UniformGridLayout
|
||||
{
|
||||
ItemsStretch = UniformGridLayoutItemsStretch.Fill,
|
||||
MinItemHeight = minItemHeight,
|
||||
MinItemWidth = minItemWidth,
|
||||
MinColumnSpacing = minColumnSpacing,
|
||||
MinRowSpacing = minRowSpacing
|
||||
MinItemHeight = MinItemHeight,
|
||||
MinItemWidth = MinItemWidth,
|
||||
MinColumnSpacing = MinColumnSpacing,
|
||||
MinRowSpacing = MinRowSpacing
|
||||
},
|
||||
ItemsViewLayoutType.VerticalUniformStack => new UniformGridLayout
|
||||
{
|
||||
ItemsStretch = UniformGridLayoutItemsStretch.Fill,
|
||||
MaximumRowsOrColumns = 1,
|
||||
MinItemHeight = minItemHeight,
|
||||
MinItemWidth = minItemWidth,
|
||||
MinColumnSpacing = minColumnSpacing,
|
||||
MinRowSpacing = minRowSpacing,
|
||||
MinItemHeight = MinItemHeight,
|
||||
MinItemWidth = MinItemWidth,
|
||||
MinColumnSpacing = MinColumnSpacing,
|
||||
MinRowSpacing = MinRowSpacing,
|
||||
Orientation = Orientation.Horizontal
|
||||
},
|
||||
ItemsViewLayoutType.HorizontalUniformStack => new UniformGridLayout
|
||||
{
|
||||
ItemsStretch = UniformGridLayoutItemsStretch.Fill,
|
||||
MaximumRowsOrColumns = 1,
|
||||
MinItemHeight = minItemHeight,
|
||||
MinItemWidth = minItemWidth,
|
||||
MinColumnSpacing = minColumnSpacing,
|
||||
MinRowSpacing = minRowSpacing,
|
||||
MinItemHeight = MinItemHeight,
|
||||
MinItemWidth = MinItemWidth,
|
||||
MinColumnSpacing = MinColumnSpacing,
|
||||
MinRowSpacing = MinRowSpacing,
|
||||
Orientation = Orientation.Vertical
|
||||
},
|
||||
ItemsViewLayoutType.VerticalStack => new StackLayout
|
||||
{
|
||||
Spacing = minRowSpacing,
|
||||
Spacing = MinRowSpacing,
|
||||
Orientation = Orientation.Vertical
|
||||
},
|
||||
ItemsViewLayoutType.HorizontalStack => new StackLayout
|
||||
{
|
||||
Spacing = minColumnSpacing,
|
||||
Spacing = MinColumnSpacing,
|
||||
Orientation = Orientation.Horizontal
|
||||
},
|
||||
ItemsViewLayoutType.Staggered => new StaggeredLayout
|
||||
{
|
||||
ColumnSpacing = minColumnSpacing,
|
||||
RowSpacing = minRowSpacing,
|
||||
DesiredColumnWidth = minItemWidth
|
||||
ColumnSpacing = MinColumnSpacing,
|
||||
RowSpacing = MinRowSpacing,
|
||||
DesiredColumnWidth = MinItemWidth
|
||||
},
|
||||
_ => ThrowHelper.ArgumentOutOfRange<ItemsViewLayoutType, VirtualizingLayout>(advancedItemsView.LayoutType)
|
||||
_ => ThrowHelper.ArgumentOutOfRange<ItemsViewLayoutType, VirtualizingLayout>(LayoutType)
|
||||
};
|
||||
}
|
||||
|
||||
private static void OnSelectedIndexChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnSelectedIndexPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var advancedItemsView = o.To<AdvancedItemsView>();
|
||||
var selectedIndex = advancedItemsView.GetSelectedIndex();
|
||||
if (advancedItemsView.SelectedIndex != selectedIndex)
|
||||
advancedItemsView.Select(advancedItemsView.SelectedIndex);
|
||||
var selectedIndex = GetSelectedIndex();
|
||||
if (SelectedIndex != selectedIndex)
|
||||
Select(SelectedIndex);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -1,15 +1,21 @@
|
||||
// Copyright (c) Pixeval.Controls.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
using FluentIcons.Common;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<string>("Title")]
|
||||
[DependencyProperty<int>("Number")]
|
||||
[DependencyProperty<Symbol>("Symbol")]
|
||||
public sealed partial class AppBarNumberItem
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? Title { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial int Number { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial Symbol Symbol { get; set; }
|
||||
|
||||
public AppBarNumberItem() => InitializeComponent();
|
||||
}
|
||||
|
@ -1,14 +1,18 @@
|
||||
// Copyright (c) Pixeval.Controls.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
using FluentIcons.Common;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<string>("Text")]
|
||||
[DependencyProperty<Symbol>("Symbol")]
|
||||
public sealed partial class AppBarTextItem
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? Text { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial Symbol Symbol { get; set; }
|
||||
|
||||
public AppBarTextItem() => InitializeComponent();
|
||||
}
|
||||
|
@ -1,14 +1,18 @@
|
||||
// Copyright (c) Pixeval.Controls.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<string>("Text")]
|
||||
[DependencyProperty<Brush>("Fill")]
|
||||
public sealed partial class DigitalSignalItem
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? Text { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial Brush? Fill { get; set; }
|
||||
|
||||
public DigitalSignalItem() => InitializeComponent();
|
||||
}
|
||||
|
@ -1,17 +1,21 @@
|
||||
// Copyright (c) Pixeval.Controls.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<XamlUICommand>("Command")]
|
||||
[DependencyProperty<object>("CommandParameter", IsNullable = true)]
|
||||
public sealed partial class HeartButton
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial XamlUICommand Command { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial object? CommandParameter { get; set; }
|
||||
|
||||
public HeartButton() => InitializeComponent();
|
||||
|
||||
private void ToggleBookmarkButtonOnTapped(object sender, TappedRoutedEventArgs e)
|
||||
|
@ -4,14 +4,17 @@
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<string>("Text", propertyChanged: nameof(OnTextChanged))]
|
||||
[DependencyProperty<IconElement>("Icon", propertyChanged: nameof(OnIconChanged))]
|
||||
public partial class IconButton : Button
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? Text { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial IconElement? Icon { get; set; }
|
||||
|
||||
public IconButton()
|
||||
{
|
||||
DefaultStyleKey = typeof(IconButton);
|
||||
@ -33,9 +36,9 @@ public partial class IconButton : Button
|
||||
};
|
||||
}
|
||||
|
||||
private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnTextPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var textBlock = ((StackPanel)((Button)d).Content).FindDescendant<TextBlock>();
|
||||
var textBlock = ((StackPanel)Content).FindDescendant<TextBlock>();
|
||||
if (e.NewValue is null)
|
||||
{
|
||||
textBlock!.Visibility = Visibility.Collapsed;
|
||||
@ -45,8 +48,8 @@ public partial class IconButton : Button
|
||||
textBlock!.Text = (string)e.NewValue;
|
||||
}
|
||||
|
||||
private static void OnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnIconPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
((StackPanel)((Button)d).Content).FindDescendant<ContentPresenter>()!.Content = e.NewValue;
|
||||
((StackPanel)Content).FindDescendant<ContentPresenter>()!.Content = e.NewValue;
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,18 @@
|
||||
// Copyright (c) Pixeval.Controls.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
using FluentIcons.Common;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<Symbol>("Symbol")]
|
||||
[DependencyProperty<string>("Text")]
|
||||
public sealed partial class IconText
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial Symbol Symbol { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? Text { get; set; }
|
||||
|
||||
public IconText() => InitializeComponent();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
x:Class="Pixeval.Controls.LazyImage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Pixeval.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
CornerRadius="{ThemeResource ControlCornerRadius}"
|
||||
@ -11,7 +12,7 @@
|
||||
x:Name="ProgressRing"
|
||||
Width="{x:Bind _progressRingSize}"
|
||||
Height="{x:Bind _progressRingSize}"
|
||||
x:Load="{x:Bind ShowProgressRing, Mode=OneWay}" />
|
||||
IsActive="{x:Bind controls:C.IsNull(Source), Mode=OneWay}" />
|
||||
<Image
|
||||
HorizontalAlignment="{x:Bind HorizontalImageAlignment, Mode=OneWay}"
|
||||
VerticalAlignment="{x:Bind VerticalImageAlignment, Mode=OneWay}"
|
||||
|
@ -1,30 +1,28 @@
|
||||
// Copyright (c) Pixeval.Controls.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<ImageSource>("Source", DependencyPropertyDefaultValue.UnsetValue, nameof(OnSourceChanged), IsNullable = true)]
|
||||
[DependencyProperty<Stretch>("Stretch", "Microsoft.UI.Xaml.Media.Stretch.UniformToFill")]
|
||||
[DependencyProperty<HorizontalAlignment>("HorizontalImageAlignment", "Microsoft.UI.Xaml.HorizontalAlignment.Center")]
|
||||
[DependencyProperty<VerticalAlignment>("VerticalImageAlignment", "Microsoft.UI.Xaml.VerticalAlignment.Center")]
|
||||
[INotifyPropertyChanged]
|
||||
public sealed partial class LazyImage
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial ImageSource? Source { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = Stretch.UniformToFill)]
|
||||
public partial Stretch Stretch { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = HorizontalAlignment.Center)]
|
||||
public partial HorizontalAlignment HorizontalImageAlignment { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = VerticalAlignment.Center)]
|
||||
public partial VerticalAlignment VerticalImageAlignment { get; set; }
|
||||
|
||||
public LazyImage() => InitializeComponent();
|
||||
|
||||
private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
d.To<LazyImage>().OnPropertyChanged(nameof(ShowProgressRing));
|
||||
}
|
||||
|
||||
private bool ShowProgressRing => Source is null;
|
||||
|
||||
/// <summary>
|
||||
/// ReSharper disable once ConvertToConstant.Local
|
||||
/// </summary>
|
||||
|
@ -4,20 +4,25 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
using Pixeval.Utilities;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Actions;
|
||||
|
||||
/// <summary>
|
||||
/// An action that will change a specified property to a specified value when invoked.
|
||||
/// </summary>
|
||||
[DependencyProperty<PropertyPath>("PropertyName", DependencyPropertyDefaultValue.Default)]
|
||||
[DependencyProperty<object>("TargetObject", DependencyPropertyDefaultValue.Default)]
|
||||
public sealed partial class NavigatePropertyAction : DependencyObject, IAction
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial PropertyPath? PropertyName { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial object? TargetObject { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Executes the action.
|
||||
/// </summary>
|
||||
@ -39,6 +44,7 @@ public sealed partial class NavigatePropertyAction : DependencyObject, IAction
|
||||
|
||||
private void UpdatePropertyValue(object targetObject)
|
||||
{
|
||||
Debug.Assert(PropertyName is not null);
|
||||
var targetType = targetObject.GetType();
|
||||
var propertyInfo = targetType.GetRuntimeProperty(PropertyName.Path)!;
|
||||
ValidateProperty(targetType.Name, propertyInfo);
|
||||
|
@ -4,20 +4,28 @@
|
||||
using System;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Windows.System;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Used to display contributors, not illustrators
|
||||
/// </summary>
|
||||
[DependencyProperty<string>("PersonNickname")]
|
||||
[DependencyProperty<string>("PersonName")]
|
||||
[DependencyProperty<Uri>("PersonProfileNavigateUri")]
|
||||
[DependencyProperty<ImageSource>("PersonPicture")]
|
||||
public partial class PersonView
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? PersonNickname { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? PersonName { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial Uri? PersonProfileNavigateUri { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial ImageSource? PersonPicture { get; set; }
|
||||
|
||||
public PersonView() => InitializeComponent();
|
||||
|
||||
private async void ContentContainerOnClicked(object sender, RoutedEventArgs e) => await Launcher.LaunchUriAsync(PersonProfileNavigateUri);
|
||||
|
@ -13,11 +13,9 @@
|
||||
<DefaultLanguage>zh-CN</DefaultLanguage>
|
||||
<IsTrimmable>true</IsTrimmable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Windowing\TabPage.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Labs.WinUI.DependencyPropertyGenerator" />
|
||||
<PackageReference Include="CommunityToolkit.Labs.WinUI.Shimmer" />
|
||||
<PackageReference Include="FluentIcons.WinUI" />
|
||||
<PackageReference Include="Microsoft.Graphics.Win2D" />
|
||||
@ -48,9 +46,4 @@
|
||||
<ItemGroup>
|
||||
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="SourceItemGroup" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Windowing\TabPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -21,14 +21,14 @@
|
||||
</UserControl.Resources>
|
||||
<Grid
|
||||
VerticalAlignment="Center"
|
||||
Background="{x:Bind BadgeColor, Mode=OneWay}"
|
||||
Background="{x:Bind GetBrush(Mode), Mode=OneWay}"
|
||||
CornerRadius="{ThemeResource ControlCornerRadius}">
|
||||
<!-- ReSharper disable once UnusedMember.Local -->
|
||||
<TextBlock
|
||||
x:Name="BadgeTextBlock"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Text="{x:Bind Text, Mode=OneWay}" />
|
||||
Text="{x:Bind GetText(Mode), Mode=OneWay}" />
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal">
|
||||
|
@ -3,21 +3,23 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Windows.UI;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<bool>("UseSmall", "false", nameof(OnUseSmallPropertyChanged))]
|
||||
[DependencyProperty<string>("Text")]
|
||||
[DependencyProperty<Brush>("BadgeColor")]
|
||||
[DependencyProperty<BadgeMode>("Mode", propertyChanged: nameof(OnBadgeModePropertyChanged))]
|
||||
public sealed partial class PixevalBadge : UserControl
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial bool UseSmall { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial BadgeMode Mode { get; set; }
|
||||
|
||||
internal const string SmallState = "Small";
|
||||
internal const string NormalState = "Normal";
|
||||
|
||||
@ -33,21 +35,13 @@ public sealed partial class PixevalBadge : UserControl
|
||||
|
||||
public PixevalBadge() => InitializeComponent();
|
||||
|
||||
public static void OnUseSmallPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
d.To<PixevalBadge>().GoToState(e.NewValue.To<bool>());
|
||||
}
|
||||
partial void OnUseSmallPropertyChanged(DependencyPropertyChangedEventArgs e) => GoToState(e.NewValue.To<bool>());
|
||||
|
||||
public static void OnBadgeModePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var properties = _PropertySet[e.NewValue.To<BadgeMode>()];
|
||||
var badge = d.To<PixevalBadge>();
|
||||
badge.Text = properties.Text;
|
||||
badge.BadgeColor = new SolidColorBrush(properties.Background);
|
||||
}
|
||||
private void GoToState(bool useSmall) => _ = VisualStateManager.GoToState(this, useSmall ? SmallState : NormalState, true);
|
||||
|
||||
private void GoToState(bool useSmall)
|
||||
{
|
||||
_ = VisualStateManager.GoToState(this, useSmall ? SmallState : NormalState, true);
|
||||
}
|
||||
#pragma warning disable CA1822
|
||||
private string GetText(BadgeMode mode) => _PropertySet[mode].Text;
|
||||
|
||||
private SolidColorBrush GetBrush(BadgeMode mode) => new SolidColorBrush(_PropertySet[mode].Background);
|
||||
#pragma warning restore CA1822
|
||||
}
|
||||
|
@ -5,24 +5,31 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using Windows.Foundation;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<double>("LineSpacing", "0d", nameof(LayoutPropertyChanged))]
|
||||
[DependencyProperty<double>("MinItemSpacing", "0d", nameof(LayoutPropertyChanged))]
|
||||
[DependencyProperty<double>("LineHeight", "50d", nameof(LayoutPropertyChanged))]
|
||||
public sealed partial class RiverFlowLayout : VirtualizingLayout
|
||||
{
|
||||
private static void LayoutPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
[GeneratedDependencyProperty(DefaultValue = 0d)]
|
||||
public partial double LineSpacing { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 0d)]
|
||||
public partial double MinItemSpacing { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 50d)]
|
||||
public partial double LineHeight { get; set; }
|
||||
|
||||
partial void OnLineSpacingPropertyChanged(DependencyPropertyChangedEventArgs e) => OnLineHeightPropertyChanged(e);
|
||||
|
||||
partial void OnMinItemSpacingPropertyChanged(DependencyPropertyChangedEventArgs e) => OnLineHeightPropertyChanged(e);
|
||||
|
||||
partial void OnLineHeightPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is RiverFlowLayout jp)
|
||||
{
|
||||
jp.InvalidateMeasure();
|
||||
jp.InvalidateArrange();
|
||||
}
|
||||
InvalidateMeasure();
|
||||
InvalidateArrange();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -3,20 +3,21 @@
|
||||
|
||||
using System;
|
||||
using CommunityToolkit.Labs.WinUI;
|
||||
using CommunityToolkit.WinUI;
|
||||
using CommunityToolkit.WinUI.Controls;
|
||||
using Microsoft.UI.Xaml;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<ItemsViewLayoutType>("LayoutType", DependencyPropertyDefaultValue.Default, nameof(OnLayoutTypeChanged))]
|
||||
[DependencyProperty<double>("MinItemHeight", "250d")]
|
||||
[DependencyProperty<double>("MinItemWidth", "350d")]
|
||||
public partial class SkeletonView : UniformGrid
|
||||
{
|
||||
private static void OnLayoutTypeChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
}
|
||||
[GeneratedDependencyProperty]
|
||||
public partial ItemsViewLayoutType LayoutType { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 250d)]
|
||||
public partial double MinItemHeight { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 350d)]
|
||||
public partial double MinItemWidth { get; set; }
|
||||
|
||||
public SkeletonView()
|
||||
{
|
||||
@ -24,10 +25,12 @@ public partial class SkeletonView : UniformGrid
|
||||
ColumnSpacing = 5;
|
||||
SizeChanged += (_, _) =>
|
||||
{
|
||||
Columns = ActualWidth is double.PositiveInfinity or double.NegativeInfinity or double.NaN
|
||||
? 1 : (int)Math.Ceiling(ActualWidth / MinItemWidth);
|
||||
Rows = ActualHeight is double.PositiveInfinity or double.NegativeInfinity or double.NaN
|
||||
? 1 : (int)Math.Ceiling(ActualHeight / MinItemHeight);
|
||||
Columns = double.IsInfinity(ActualWidth) || double.IsNaN(ActualWidth)
|
||||
? 1
|
||||
: (int)Math.Ceiling(ActualWidth / MinItemWidth);
|
||||
Rows = double.IsInfinity(ActualHeight) || double.IsNaN(ActualHeight)
|
||||
? 1
|
||||
: (int)Math.Ceiling(ActualHeight / MinItemHeight);
|
||||
var count = Rows * Columns;
|
||||
while (count != Children.Count)
|
||||
{
|
||||
|
@ -2,19 +2,27 @@
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using System;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<FrameworkElement>("Header")]
|
||||
[DependencyProperty<Brush>("HeaderBackGround")]
|
||||
[DependencyProperty<FrameworkElement>("StickyContent")]
|
||||
[DependencyProperty<double>("ScrollRatio")]
|
||||
public sealed partial class StickyHeaderScrollView
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial FrameworkElement? Header { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial Brush? HeaderBackGround { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial FrameworkElement? StickyContent { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial double ScrollRatio { get; set; }
|
||||
|
||||
public StickyHeaderScrollView() => InitializeComponent();
|
||||
|
||||
/// <summary>
|
||||
|
@ -6,6 +6,5 @@
|
||||
xmlns:local="using:Pixeval.Controls.Timeline"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<ListView />
|
||||
</UserControl>
|
||||
|
@ -1,20 +1,15 @@
|
||||
// Copyright (c) Pixeval.Controls.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
namespace Pixeval.Controls.Timeline;
|
||||
|
||||
namespace Pixeval.Controls.Timeline
|
||||
public sealed partial class TimelineControl
|
||||
{
|
||||
[DependencyProperty<DataTemplate>("ItemTemplate")]
|
||||
public sealed partial class TimelineControl
|
||||
{
|
||||
public TimelineControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
[GeneratedDependencyProperty]
|
||||
public partial DataTemplate? ItemTemplate { get; set; }
|
||||
|
||||
public TimelineControl() => InitializeComponent();
|
||||
}
|
||||
|
@ -1,24 +1,30 @@
|
||||
// Copyright (c) Pixeval.Controls.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
using System;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls.Timeline;
|
||||
|
||||
[DependencyProperty<TimelineAxisPlacement>("FoldedDefaultPlacement", "Pixeval.Controls.Timeline.TimelineAxisPlacement.Left")]
|
||||
[DependencyProperty<double>("FoldThreshold", "-1.0")]
|
||||
[DependencyProperty<TimelineAxisPlacement>("TimelineAxisPlacement", "Pixeval.Controls.Timeline.TimelineAxisPlacement.Left", nameof(TimelineAxisPlacementPropertyChangedCallback))]
|
||||
[DependencyProperty<IconSource>("TitleIcon")]
|
||||
[DependencyProperty<SolidColorBrush>("TitleIconBackground", DependencyPropertyDefaultValue.Default)]
|
||||
public sealed partial class TimelineUnit : ContentControl
|
||||
{
|
||||
public TimelineUnit()
|
||||
{
|
||||
DefaultStyleKey = typeof(TimelineUnit);
|
||||
}
|
||||
[GeneratedDependencyProperty(DefaultValue = TimelineAxisPlacement.Left)]
|
||||
public partial TimelineAxisPlacement FoldedDefaultPlacement { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = -1.0d)]
|
||||
public partial double FoldThreshold { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = TimelineAxisPlacement.Left)]
|
||||
public partial TimelineAxisPlacement TimelineAxisPlacement { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial IconSource? TitleIcon { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial SolidColorBrush? TitleIconBackground { get; set; }
|
||||
|
||||
private bool _folded;
|
||||
private bool _differentDefaultAxisPlacement;
|
||||
@ -30,26 +36,24 @@ public sealed partial class TimelineUnit : ContentControl
|
||||
private ColumnDefinition _leftColumn = null!;
|
||||
private ContentControl _contentPresenter = null!;
|
||||
private double _containerHeightFixed;
|
||||
|
||||
|
||||
private static void TimelineAxisPlacementPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
public TimelineUnit() => DefaultStyleKey = typeof(TimelineUnit);
|
||||
|
||||
partial void OnTimelineAxisPlacementPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is TimelineUnit { IsLoaded: true } unit && e.NewValue is TimelineAxisPlacement placement)
|
||||
if (IsLoaded && e.NewValue is TimelineAxisPlacement placement)
|
||||
{
|
||||
unit._folded = !unit._folded;
|
||||
unit.AdjustAxisPlacement(placement, true); // unit._folded;
|
||||
_folded = !_folded;
|
||||
AdjustAxisPlacement(placement, true);
|
||||
}
|
||||
}
|
||||
|
||||
private double GetTimelineAxisHeight(bool isAuxAxis)
|
||||
{
|
||||
if (ActualHeight is not 0 && _containerHeightFixed is 0)
|
||||
{
|
||||
if (ActualHeight is not 0 && _containerHeightFixed is 0)
|
||||
_containerHeightFixed = ActualHeight;
|
||||
return isAuxAxis ? _containerHeightFixed : _containerHeightFixed - 45 is >= 0 and var value ? value : 0;
|
||||
}
|
||||
else
|
||||
return isAuxAxis ? _containerHeightFixed : _containerHeightFixed - 45 is >= 0 and var value ? value : 0;
|
||||
|
||||
return isAuxAxis ? _containerHeightFixed : Math.Max(_containerHeightFixed - 45, 0);
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
|
@ -0,0 +1,37 @@
|
||||
// Copyright (c) Pixeval.Controls.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.WinUI;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
public partial class ZoomableImage
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial object? Source { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial IReadOnlyList<int>? MsIntervals { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = true)]
|
||||
public partial bool IsPlaying { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 0)]
|
||||
public partial int ImageRotationDegree { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = false)]
|
||||
public partial bool ImageIsMirrored { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 1f)]
|
||||
public partial float ImageScale { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial ZoomableImageMode Mode { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = ZoomableImageMode.Fit)]
|
||||
public partial ZoomableImageMode InitMode { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = ZoomableImagePosition.AbsoluteCenter)]
|
||||
public partial ZoomableImagePosition InitPosition { get; set; }
|
||||
}
|
@ -27,22 +27,22 @@ public partial class ZoomableImage
|
||||
|
||||
private int[]? ClonedMsIntervals { get; set; }
|
||||
|
||||
private static void OnMsIntervalsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnMsIntervalsPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (EnsureNotDisposed(d) is not { } zoomableImage)
|
||||
if (IsDisposed)
|
||||
return;
|
||||
zoomableImage.ClonedMsIntervals = [.. zoomableImage.MsIntervals];
|
||||
ClonedMsIntervals = [.. MsIntervals ?? []];
|
||||
}
|
||||
|
||||
private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnSourcePropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (EnsureNotDisposed(d) is not { } zoomableImage)
|
||||
if (IsDisposed)
|
||||
return;
|
||||
zoomableImage.IsPlaying = true;
|
||||
zoomableImage._timerRunning = false;
|
||||
IsPlaying = true;
|
||||
_timerRunning = false;
|
||||
// 使CanvasControl具有大小,否则不会触发CanvasControlOnDraw
|
||||
zoomableImage.OriginalImageWidth = zoomableImage.OriginalImageHeight = 10;
|
||||
zoomableImage._needInitSource = true;
|
||||
OriginalImageWidth = OriginalImageHeight = 10;
|
||||
_needInitSource = true;
|
||||
}
|
||||
|
||||
private bool _needInitSource;
|
||||
@ -85,12 +85,12 @@ public partial class ZoomableImage
|
||||
_timerRunning = true;
|
||||
}
|
||||
|
||||
private static void OnIsPlayingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnIsPlayingPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (EnsureNotDisposed(d) is not { } zoomableImage)
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
zoomableImage._isPlayingInternal = zoomableImage.IsPlaying;
|
||||
_isPlayingInternal = IsPlaying;
|
||||
}
|
||||
|
||||
private void CanvasControlOnDraw(CanvasControl sender, CanvasDrawEventArgs e)
|
||||
|
@ -8,37 +8,37 @@ namespace Pixeval.Controls;
|
||||
|
||||
public partial class ZoomableImage
|
||||
{
|
||||
private static void OnImageRotationDegreeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnImageRotationDegreePropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (EnsureNotDisposed(d) is not { } zoomableImage)
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
if (zoomableImage.ImageRotationDegree % 90 is not 0)
|
||||
if (ImageRotationDegree % 90 is not 0)
|
||||
{
|
||||
ThrowHelper.Argument(zoomableImage.ImageRotationDegree, $"{nameof(ImageRotationDegree)} must be a multiple of 90");
|
||||
ThrowHelper.Argument(ImageRotationDegree, $"{nameof(ImageRotationDegree)} must be a multiple of 90");
|
||||
}
|
||||
|
||||
switch (zoomableImage.ImageRotationDegree)
|
||||
switch (ImageRotationDegree)
|
||||
{
|
||||
case >= 360:
|
||||
zoomableImage.ImageRotationDegree %= 360;
|
||||
ImageRotationDegree %= 360;
|
||||
return;
|
||||
case <= -360:
|
||||
zoomableImage.ImageRotationDegree = zoomableImage.ImageRotationDegree % 360 + 360;
|
||||
ImageRotationDegree = ImageRotationDegree % 360 + 360;
|
||||
return;
|
||||
case < 0:
|
||||
zoomableImage.ImageRotationDegree += 360;
|
||||
ImageRotationDegree += 360;
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新图片大小
|
||||
zoomableImage.OnPropertyChanged(nameof(ImageWidth));
|
||||
zoomableImage.OnPropertyChanged(nameof(ImageHeight));
|
||||
OnPropertyChanged(nameof(ImageWidth));
|
||||
OnPropertyChanged(nameof(ImageHeight));
|
||||
|
||||
// 更新图片位置
|
||||
zoomableImage.OnPropertyChanged(nameof(ImagePositionLeft));
|
||||
zoomableImage.OnPropertyChanged(nameof(ImagePositionTop));
|
||||
zoomableImage.OnPropertyChanged(nameof(ImagePositionRight));
|
||||
zoomableImage.OnPropertyChanged(nameof(ImagePositionBottom));
|
||||
OnPropertyChanged(nameof(ImagePositionLeft));
|
||||
OnPropertyChanged(nameof(ImagePositionTop));
|
||||
OnPropertyChanged(nameof(ImagePositionRight));
|
||||
OnPropertyChanged(nameof(ImagePositionBottom));
|
||||
}
|
||||
}
|
||||
|
@ -77,33 +77,33 @@ public partial class ZoomableImage
|
||||
{
|
||||
// 是NotFit则自动调整
|
||||
if (ImageScale is 1 or float.NaN || Math.Abs(GetScaledFactor(e.PreviousSize) - ImageScale) > 0.01)
|
||||
OnImageScaleChanged(ImageScale);
|
||||
OnImageScaleChangedInternal(ImageScale);
|
||||
else
|
||||
#pragma warning disable CA2245
|
||||
Mode = Mode;
|
||||
#pragma warning restore CA2245
|
||||
}
|
||||
|
||||
private static void OnImageScaleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnImageScalePropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (EnsureNotDisposed(d) is not { } zoomableImage)
|
||||
if (IsDisposed)
|
||||
return;
|
||||
zoomableImage.OnImageScaleChanged(e.OldValue.To<float>());
|
||||
OnImageScaleChangedInternal(e.OldValue.To<float>());
|
||||
}
|
||||
|
||||
private static void OnModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnModePropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (EnsureNotDisposed(d) is not { } zoomableImage)
|
||||
if (IsDisposed)
|
||||
return;
|
||||
switch (zoomableImage.Mode)
|
||||
switch (Mode)
|
||||
{
|
||||
case ZoomableImageMode.Original:
|
||||
zoomableImage.ImageScale = 1;
|
||||
zoomableImage.SetPosition(zoomableImage.InitPosition);
|
||||
ImageScale = 1;
|
||||
SetPosition(InitPosition);
|
||||
break;
|
||||
case ZoomableImageMode.Fit:
|
||||
zoomableImage.ImageScale = (float)zoomableImage.ScaledFactor;
|
||||
zoomableImage.SetPosition(zoomableImage.InitPosition);
|
||||
ImageScale = (float)ScaledFactor;
|
||||
SetPosition(InitPosition);
|
||||
break;
|
||||
case ZoomableImageMode.NotFit:
|
||||
break;
|
||||
@ -113,7 +113,7 @@ public partial class ZoomableImage
|
||||
}
|
||||
}
|
||||
|
||||
private void OnImageScaleChanged(float oldScale)
|
||||
private void OnImageScaleChangedInternal(float oldScale)
|
||||
{
|
||||
// 初始化时抑制动画
|
||||
if (_isInitMode || Source is null)
|
||||
|
@ -3,13 +3,13 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.UI.Input;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Pixeval.Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
@ -18,25 +18,10 @@ namespace Pixeval.Controls;
|
||||
/// 渲染:<see cref="CanvasControlOnDraw"/>,图片渲染逻辑<br/>
|
||||
/// 对外API:<see cref="Zoom(float)"/>、<see cref="SetPosition"/>
|
||||
/// </summary>
|
||||
[DependencyProperty<object>("Source", DependencyPropertyDefaultValue.Default, nameof(OnSourceChanged), IsNullable = true)]
|
||||
[DependencyProperty<IReadOnlyList<int>>("MsIntervals", DependencyPropertyDefaultValue.Default, nameof(OnMsIntervalsChanged))]
|
||||
[DependencyProperty<bool>("IsPlaying", "true", nameof(OnIsPlayingChanged))]
|
||||
[DependencyProperty<int>("ImageRotationDegree", "0", nameof(OnImageRotationDegreeChanged))]
|
||||
[DependencyProperty<bool>("ImageIsMirrored", "false")]
|
||||
[DependencyProperty<float>("ImageScale", "1f", nameof(OnImageScaleChanged))]
|
||||
[DependencyProperty<ZoomableImageMode>("Mode", DependencyPropertyDefaultValue.Default, nameof(OnModeChanged))]
|
||||
[DependencyProperty<ZoomableImageMode>("InitMode", "ZoomableImageMode.Fit")]
|
||||
[DependencyProperty<ZoomableImagePosition>("InitPosition", "ZoomableImagePosition.AbsoluteCenter")]
|
||||
[ObservableObject]
|
||||
public sealed partial class ZoomableImage : UserControl, IStructuralDisposalCompleter
|
||||
public sealed partial class ZoomableImage : UserControl, IStructuralDisposalCompleter, INotifyPropertyChanged
|
||||
{
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
public static ZoomableImage? EnsureNotDisposed(object? o)
|
||||
{
|
||||
return o is ZoomableImage { IsDisposed: false } image ? image : null;
|
||||
}
|
||||
|
||||
public ZoomableImage()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -122,4 +107,11 @@ public sealed partial class ZoomableImage : UserControl, IStructuralDisposalComp
|
||||
{
|
||||
((IStructuralDisposalCompleter) this).Hook();
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Diagnostics;
|
||||
|
||||
namespace Pixeval.SourceGen
|
||||
{
|
||||
|
@ -1,17 +1,19 @@
|
||||
// Copyright (c) Pixeval.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
using Pixeval.Util.UI;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Behaviors;
|
||||
|
||||
[DependencyProperty<string>("TargetText")]
|
||||
public partial class ButtonCopyBehavior : Behavior<Button>
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? TargetText { get; set; }
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
base.OnAttached();
|
||||
@ -23,6 +25,7 @@ public partial class ButtonCopyBehavior : Behavior<Button>
|
||||
base.OnDetaching();
|
||||
AssociatedObject.Click -= OnClick;
|
||||
}
|
||||
|
||||
private void OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(TargetText))
|
||||
|
@ -2,11 +2,11 @@
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using System;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Pixeval.Pages.IllustratorViewer;
|
||||
using Pixeval.Util.IO.Caching;
|
||||
using WinUI3Utilities.Attributes;
|
||||
using IllustrationCacheTable = Pixeval.Caching.CacheTable<
|
||||
Pixeval.Util.IO.Caching.PixevalIllustrationCacheKey,
|
||||
Pixeval.Util.IO.Caching.PixevalIllustrationCacheHeader,
|
||||
@ -14,30 +14,32 @@ using IllustrationCacheTable = Pixeval.Caching.CacheTable<
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<CommentItemViewModel>("ViewModel", propertyChanged: nameof(OnViewModelChanged))]
|
||||
public sealed partial class CommentItem
|
||||
{
|
||||
[GeneratedDependencyProperty(DefaultValue = null!)]
|
||||
public partial CommentItemViewModel ViewModel { get; set; }
|
||||
|
||||
public CommentItem() => InitializeComponent();
|
||||
|
||||
public event Action<CommentItemViewModel>? RepliesHyperlinkButtonClick;
|
||||
|
||||
public event Action<CommentItemViewModel>? DeleteHyperlinkButtonClick;
|
||||
|
||||
private static async void OnViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
async partial void OnViewModelPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is not CommentItem { ViewModel: { } viewModel } block)
|
||||
if (ViewModel is not { } viewModel)
|
||||
return;
|
||||
if (viewModel.HasReplies)
|
||||
_ = viewModel.LoadRepliesAsync();
|
||||
_ = viewModel.LoadAvatarSource();
|
||||
if (viewModel.IsStamp)
|
||||
{
|
||||
block.StickerImageContent.Source = await App.AppViewModel.AppServiceProvider.GetRequiredService<IllustrationCacheTable>().GetSourceFromCacheAsync(viewModel.StampSource);
|
||||
StickerImageContent.Source = await App.AppViewModel.AppServiceProvider.GetRequiredService<IllustrationCacheTable>().GetSourceFromCacheAsync(viewModel.StampSource);
|
||||
}
|
||||
else
|
||||
{
|
||||
block.CommentContent.RawText.Blocks.Clear();
|
||||
block.CommentContent.RawText.Blocks.Add(await viewModel.GetReplyContentParagraphAsync());
|
||||
CommentContent.RawText.Blocks.Clear();
|
||||
CommentContent.RawText.Blocks.Add(await viewModel.GetReplyContentParagraphAsync());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,16 +3,22 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<object>("ItemsSource")]
|
||||
[DependencyProperty<bool>("HasNoItem", "true")]
|
||||
[DependencyProperty<bool>("IsLoadingMore", "false")]
|
||||
public sealed partial class CommentView : IStructuralDisposalCompleter
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial object? ItemsSource { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = true)]
|
||||
public partial bool HasNoItem { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = false)]
|
||||
public partial bool IsLoadingMore { get; set; }
|
||||
|
||||
public CommentView() => InitializeComponent();
|
||||
|
||||
public event Action<CommentItemViewModel>? RepliesHyperlinkButtonClick;
|
||||
|
@ -1,12 +1,14 @@
|
||||
// Copyright (c) Pixeval.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using WinUI3Utilities.Attributes;
|
||||
using CommunityToolkit.WinUI;
|
||||
|
||||
namespace Pixeval.Controls.DialogContent;
|
||||
|
||||
[DependencyProperty<bool>("DeleteLocalFiles", "false")]
|
||||
public sealed partial class DownloadPageDeleteTasksDialog
|
||||
{
|
||||
[GeneratedDependencyProperty(DefaultValue = false)]
|
||||
public partial bool DeleteLocalFiles { get; set; }
|
||||
|
||||
public DownloadPageDeleteTasksDialog() => InitializeComponent();
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
// Copyright (c) Pixeval.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
public partial class DocumentViewer
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial NovelItemViewModel? NovelItem { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 1000d)]
|
||||
public partial double NovelMaxWidth { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 28d)]
|
||||
public partial double LineHeight { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 0)]
|
||||
public partial int CurrentPage { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = 0)]
|
||||
public partial int PageCount { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = false)]
|
||||
public partial bool IsMultiPage { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = true)]
|
||||
public partial bool LoadSuccessfully { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = false)]
|
||||
public partial bool IsLoading { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial DocumentViewerViewModel? ViewModel { get; set; }
|
||||
}
|
@ -5,65 +5,51 @@ using System.Collections.Generic;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Documents;
|
||||
using Pixeval.Utilities;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<NovelItemViewModel>("NovelItem", DependencyPropertyDefaultValue.UnsetValue, nameof(OnNovelItemChanged), IsNullable = true)]
|
||||
[DependencyProperty<double>("NovelMaxWidth", "1000d")]
|
||||
[DependencyProperty<double>("LineHeight", "28d")]
|
||||
[DependencyProperty<int>("CurrentPage", "0", nameof(OnCurrentPageChanged))]
|
||||
[DependencyProperty<int>("PageCount", "0", nameof(OnPageCountChanged))]
|
||||
[DependencyProperty<bool>("IsMultiPage", "false")]
|
||||
[DependencyProperty<bool>("LoadSuccessfully", "true")]
|
||||
[DependencyProperty<bool>("IsLoading", "false")]
|
||||
[DependencyProperty<DocumentViewerViewModel>("ViewModel", IsNullable = true)]
|
||||
public sealed partial class DocumentViewer
|
||||
{
|
||||
public DocumentViewer() => InitializeComponent();
|
||||
|
||||
public static async void OnNovelItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
async partial void OnNovelItemPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var viewer = d.To<DocumentViewer>();
|
||||
if (viewer.NovelItem is null)
|
||||
if (NovelItem is null)
|
||||
{
|
||||
viewer.ViewModel = null;
|
||||
ViewModel = null;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
viewer.LoadSuccessfully = false;
|
||||
viewer.IsLoading = true;
|
||||
viewer.ViewModel = await DocumentViewerViewModel.CreateAsync(viewer, viewer.NovelItem, _ => viewer.LoadSuccessfully = true);
|
||||
viewer.ViewModel.JumpToPageRequested += newPage => viewer.CurrentPage = newPage;
|
||||
viewer.ViewModel.Pages.CollectionChanged += (_, _) => viewer.PageCount = viewer.ViewModel.Pages.Count;
|
||||
viewer.PageCount = viewer.ViewModel.Pages.Count;
|
||||
if (viewer.CurrentPage is 0)
|
||||
viewer.UpdateContent();
|
||||
LoadSuccessfully = false;
|
||||
IsLoading = true;
|
||||
ViewModel = await DocumentViewerViewModel.CreateAsync(this, NovelItem, _ => LoadSuccessfully = true);
|
||||
ViewModel.JumpToPageRequested += newPage => CurrentPage = newPage;
|
||||
ViewModel.Pages.CollectionChanged += (_, _) => PageCount = ViewModel.Pages.Count;
|
||||
PageCount = ViewModel.Pages.Count;
|
||||
if (CurrentPage is 0)
|
||||
UpdateContent();
|
||||
else
|
||||
viewer.CurrentPage = 0;
|
||||
CurrentPage = 0;
|
||||
}
|
||||
finally
|
||||
{
|
||||
viewer.IsLoading = false;
|
||||
IsLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void OnCurrentPageChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnCurrentPagePropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var viewer = d.To<DocumentViewer>();
|
||||
if (viewer.NovelItem is null)
|
||||
if (NovelItem is null)
|
||||
return;
|
||||
|
||||
viewer.UpdateContent();
|
||||
UpdateContent();
|
||||
}
|
||||
|
||||
public static void OnPageCountChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnPageCountPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var viewer = d.To<DocumentViewer>();
|
||||
viewer.IsMultiPage = viewer.PageCount > 1;
|
||||
IsMultiPage = PageCount > 1;
|
||||
}
|
||||
|
||||
private void UpdateContent()
|
||||
|
@ -5,25 +5,26 @@ using System;
|
||||
using System.IO;
|
||||
using Windows.Foundation;
|
||||
using Windows.System;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Pixeval.Util.UI;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
using Symbol = FluentIcons.Common.Symbol;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<DownloadItemViewModel>("ViewModel", propertyChanged: nameof(OnViewModelChanged))]
|
||||
public sealed partial class DownloadItem
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial DownloadItemViewModel ViewModel { get; set; }
|
||||
|
||||
public event Action<DownloadItem, DownloadItemViewModel>? ViewModelChanged;
|
||||
|
||||
public event TypedEventHandler<DownloadItem, DownloadItemViewModel>? OpenIllustrationRequested;
|
||||
|
||||
private static void OnViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnViewModelPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d as DownloadItem is { } entry)
|
||||
entry.ViewModelChanged?.Invoke(entry, entry.ViewModel);
|
||||
ViewModelChanged?.Invoke(this, ViewModel);
|
||||
}
|
||||
|
||||
public DownloadItem() => InitializeComponent();
|
||||
|
@ -1,8 +1,8 @@
|
||||
// Copyright (c) Pixeval.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
@ -10,32 +10,42 @@ namespace Pixeval.Controls;
|
||||
/// This view is provided as a holder for, normally a list of items with optionally incremental loading functionality
|
||||
/// It features four additional properties in order to give a better UI experience
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <list type="bullet">
|
||||
/// <item>
|
||||
/// <see cref="HasNoItem"/> determines whether the list is empty, that is, not only it currently has no items presented, but also that no more item will be loaded. The correct image will be displayed to inform user when this property is <c>true</c>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <see cref="IsLoadingMore"/> determines whether the list is under loading, the correct image will be displayed to inform user when this property is <c>true</c>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <see cref="IsLoadingMore"/> takes higher priority than <see cref="HasNoItem"/>, i.e. If both of them are <c>true</c>, the effect of <see cref="IsLoadingMore"/> overwrites that of <see cref="HasNoItem"/>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
[DependencyProperty<bool>("HasNoItem", "true", nameof(OnHasNoItemChanged))]
|
||||
[DependencyProperty<bool>("IsLoadingMore", "false", nameof(OnHasNoItemChanged))]
|
||||
[DependencyProperty<object>("Content")]
|
||||
[DependencyProperty<string>("TeachingTipTitle")]
|
||||
public sealed partial class EntryView
|
||||
{
|
||||
/// <summary>
|
||||
/// determines whether the list is empty, that is, not only it currently has no items presented, but also that no more item will be loaded. The correct image will be displayed to inform user when this property is <see langword="true"/>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <see cref="IsLoadingMore"/> takes higher priority than <see cref="HasNoItem"/>, i.e. If both of them are <see langword="true"/>, the effect of <see cref="IsLoadingMore"/> overwrites that of <see cref="HasNoItem"/>
|
||||
/// </remarks>
|
||||
[GeneratedDependencyProperty(DefaultValue = true)]
|
||||
public partial bool HasNoItem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// determines whether the list is under loading, the correct image will be displayed to inform user when this property is <see langword="true"/>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <see cref="IsLoadingMore"/> takes higher priority than <see cref="HasNoItem"/>, i.e. If both of them are <see langword="true"/>, the effect of <see cref="IsLoadingMore"/> overwrites that of <see cref="HasNoItem"/>
|
||||
/// </remarks>
|
||||
[GeneratedDependencyProperty(DefaultValue = false)]
|
||||
public partial bool IsLoadingMore { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial object? Content { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? TeachingTipTitle { get; set; }
|
||||
|
||||
public EntryView() => InitializeComponent();
|
||||
|
||||
private static void OnHasNoItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnHasNoItemPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var control = (EntryView)d;
|
||||
control.HasNoItemStackPanel.Visibility = control is { HasNoItem: true, IsLoadingMore: false } ? Visibility.Visible : Visibility.Collapsed;
|
||||
control.SkeletonView.Visibility = control is { HasNoItem: true, IsLoadingMore: true } ? Visibility.Visible : Visibility.Collapsed;
|
||||
HasNoItemStackPanel.Visibility = this is { HasNoItem: true, IsLoadingMore: false } ? Visibility.Visible : Visibility.Collapsed;
|
||||
SkeletonView.Visibility = this is { HasNoItem: true, IsLoadingMore: true } ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
partial void OnIsLoadingMorePropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
OnHasNoItemPropertyChanged(e);
|
||||
}
|
||||
}
|
||||
|
@ -4,18 +4,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Markup;
|
||||
using Pixeval.CoreApi.Global.Enum;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<object>("SelectedEnum", DependencyPropertyDefaultValue.Default, nameof(OnSelectedEnumChanged), IsNullable = true)]
|
||||
public sealed partial class EnumComboBox : ComboBox
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial object? SelectedEnum { get; set; }
|
||||
|
||||
public new event EventHandler<SelectionChangedEventArgs>? SelectionChanged;
|
||||
|
||||
public EnumComboBox()
|
||||
@ -47,10 +49,9 @@ public sealed partial class EnumComboBox : ComboBox
|
||||
|
||||
public T GetSelectedItem<T>() where T : Enum => SelectedEnum is T t ? t : ThrowHelper.InvalidCast<T>();
|
||||
|
||||
private static void OnSelectedEnumChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnSelectedEnumPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var comboBox = sender.To<EnumComboBox>();
|
||||
comboBox.SelectedItem = comboBox.ItemsSource?.To<IEnumerable<StringRepresentableItem>>().FirstOrDefault(r => Equals(r.Item, comboBox.SelectedEnum));
|
||||
SelectedItem = ItemsSource?.To<IEnumerable<StringRepresentableItem>>().FirstOrDefault(r => Equals(r.Item, SelectedEnum));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using CommunityToolkit.WinUI;
|
||||
using CommunityToolkit.WinUI.Controls;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
@ -11,13 +12,14 @@ using Pixeval.CoreApi.Global.Enum;
|
||||
using Pixeval.CoreApi.Model;
|
||||
using Pixeval.Util;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls.FlyoutContent;
|
||||
|
||||
[DependencyProperty<SimpleWorkType>("Type", DependencyPropertyDefaultValue.Default, nameof(OnTypeChanged))]
|
||||
public sealed partial class BookmarkTagSelector : UserControl
|
||||
{
|
||||
[GeneratedDependencyProperty(DefaultValue = SimpleWorkType.IllustAndManga)]
|
||||
public partial SimpleWorkType Type { get; set; }
|
||||
|
||||
public bool IsPrivate
|
||||
{
|
||||
get;
|
||||
@ -39,7 +41,7 @@ public sealed partial class BookmarkTagSelector : UserControl
|
||||
ResetSource();
|
||||
}
|
||||
|
||||
private static void OnTypeChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) => o.To<BookmarkTagSelector>().ResetSource();
|
||||
partial void OnTypePropertyChanged(DependencyPropertyChangedEventArgs e) => ResetSource();
|
||||
|
||||
private void SelectedTags_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
|
@ -11,13 +11,14 @@ using Pixeval.CoreApi;
|
||||
using Pixeval.CoreApi.Global.Enum;
|
||||
using Pixeval.CoreApi.Net.Response;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls.FlyoutContent;
|
||||
|
||||
[DependencyProperty<CommentItemViewModel>("ViewModel")]
|
||||
public sealed partial class CommentRepliesBlock
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial CommentItemViewModel ViewModel { get; set; }
|
||||
|
||||
public CommentRepliesBlock() => InitializeComponent();
|
||||
|
||||
private void CommentView_OnRepliesHyperlinkButtonClick(CommentItemViewModel viewModel)
|
||||
|
@ -3,20 +3,24 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<string>("Header")]
|
||||
[DependencyProperty<ICollection<string>>("ItemsSource")]
|
||||
public sealed partial class IPListInput : StackPanel
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? Header { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial ICollection<string> ItemsSource { get; set; }
|
||||
|
||||
public IPListInput() => InitializeComponent();
|
||||
|
||||
private void AddItem(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs e)
|
||||
|
@ -6,14 +6,16 @@ using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Pixeval.Options;
|
||||
using Windows.Foundation;
|
||||
using CommunityToolkit.WinUI;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<IllustrationItemViewModel>("ViewModel", propertyChanged: nameof(OnViewModelChanged))]
|
||||
public sealed partial class IllustrationItem
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial IllustrationItemViewModel ViewModel { get; set; }
|
||||
|
||||
public event TypedEventHandler<IllustrationItem, IllustrationItemViewModel>? ViewModelChanged;
|
||||
|
||||
public event TypedEventHandler<IllustrationItem, IllustrationItemViewModel>? RequestOpenUserInfoPage;
|
||||
@ -24,12 +26,9 @@ public sealed partial class IllustrationItem
|
||||
|
||||
public event Func<TeachingTip> RequestTeachingTip = null!;
|
||||
|
||||
private static void OnViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnViewModelPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is IllustrationItem illustrationItem)
|
||||
{
|
||||
illustrationItem.ViewModelChanged?.Invoke(illustrationItem, illustrationItem.ViewModel);
|
||||
}
|
||||
ViewModelChanged?.Invoke(this, ViewModel);
|
||||
}
|
||||
|
||||
public IllustrationItem() => InitializeComponent();
|
||||
|
@ -3,26 +3,25 @@
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<IllustratorItemViewModel>("ViewModel", propertyChanged: nameof(OnViewModelChanged))]
|
||||
public sealed partial class IllustratorItem
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial IllustratorItemViewModel ViewModel { get; set; }
|
||||
|
||||
public event Action<IllustratorItem, IllustratorItemViewModel>? ViewModelChanged;
|
||||
|
||||
public event Func<TeachingTip> RequestTeachingTip = null!;
|
||||
|
||||
private static void OnViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnViewModelPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d as IllustratorItem is { } item)
|
||||
{
|
||||
item.ViewModelChanged?.Invoke(item, item.ViewModel);
|
||||
}
|
||||
ViewModelChanged?.Invoke(this, ViewModel);
|
||||
}
|
||||
|
||||
private const float RotatedRotation = 10f;
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Foundation;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
@ -13,14 +14,15 @@ using Pixeval.CoreApi.Global.Enum;
|
||||
using Pixeval.Messages;
|
||||
using Pixeval.Util.UI;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
using Symbol = FluentIcons.Common.Symbol;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<NovelItemViewModel>("ViewModel", propertyChanged: nameof(OnViewModelChanged))]
|
||||
public sealed partial class NovelItem
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial NovelItemViewModel ViewModel { get; set; }
|
||||
|
||||
public event TypedEventHandler<NovelItem, NovelItemViewModel>? ViewModelChanged;
|
||||
|
||||
public event TypedEventHandler<NovelItem, NovelItemViewModel>? OpenNovelRequested;
|
||||
@ -98,12 +100,9 @@ public sealed partial class NovelItem
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnViewModelPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is NovelItem item)
|
||||
{
|
||||
item.ViewModelChanged?.Invoke(item, item.ViewModel);
|
||||
}
|
||||
ViewModelChanged?.Invoke(this, ViewModel);
|
||||
}
|
||||
|
||||
private void TagButton_OnClicked(object sender, RoutedEventArgs e)
|
||||
|
@ -1,18 +1,24 @@
|
||||
// Copyright (c) Pixeval.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<string>("ToolTip")]
|
||||
[DependencyProperty<Visibility>("ButtonVisibility")]
|
||||
[DependencyProperty<bool>("IsPrev", "true", propertyChanged: nameof(OnIsPrevChanged))]
|
||||
public sealed partial class PageButton
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? ToolTip { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial Visibility ButtonVisibility { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = true)]
|
||||
public partial bool IsPrev { get; set; }
|
||||
|
||||
public PageButton() => InitializeComponent();
|
||||
|
||||
public event RoutedEventHandler? ButtonClick;
|
||||
@ -23,10 +29,9 @@ public sealed partial class PageButton
|
||||
|
||||
private void NextButton_OnRightTapped(object sender, RightTappedRoutedEventArgs e) => ButtonRightTapped?.Invoke(sender, e);
|
||||
|
||||
private static void OnIsPrevChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnIsPrevPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var button = (PageButton)o;
|
||||
if (!button.IsPrev)
|
||||
button.Image.RenderTransform = new ScaleTransform { ScaleX = -1 };
|
||||
if (!IsPrev)
|
||||
Image.RenderTransform = new ScaleTransform { ScaleX = -1 };
|
||||
}
|
||||
}
|
||||
|
@ -9,15 +9,20 @@ using Microsoft.UI.Xaml.Controls;
|
||||
using Windows.Foundation;
|
||||
using CommunityToolkit.WinUI;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<object>("ItemsSource", DependencyPropertyDefaultValue.Default, nameof(OnItemsSourceChanged))]
|
||||
[DependencyProperty<object>("SelectedItem", propertyChanged: nameof(OnSelectedItemChanged))]
|
||||
[DependencyProperty<object>("Header")]
|
||||
public sealed partial class SettingRadioButtons : UserControl
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial object? ItemsSource { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial object SelectedItem { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial object? Header { get; set; }
|
||||
|
||||
private RadioButtons Buttons => Content.To<RadioButtons>();
|
||||
|
||||
public SettingRadioButtons()
|
||||
@ -36,16 +41,14 @@ public sealed partial class SettingRadioButtons : UserControl
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnItemsSourceChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnItemsSourcePropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var buttons = sender.To<SettingRadioButtons>();
|
||||
|
||||
buttons.Buttons.ItemsSource = buttons.ItemsSource;
|
||||
Buttons.ItemsSource = ItemsSource;
|
||||
}
|
||||
|
||||
private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnSelectedItemPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
SelectedItemChanged(sender, e.NewValue);
|
||||
SelectedItemChanged(this, e.NewValue);
|
||||
}
|
||||
|
||||
public event TypedEventHandler<SettingRadioButtons, SelectionChangedEventArgs>? SelectionChanged;
|
||||
|
@ -3,28 +3,27 @@
|
||||
|
||||
using System;
|
||||
using Windows.UI;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Pixeval.CoreApi.Model;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<SpotlightItemViewModel>("ViewModel", propertyChanged: nameof(OnViewModelChanged))]
|
||||
public sealed partial class SpotlightItem
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial SpotlightItemViewModel ViewModel { get; set; }
|
||||
|
||||
public event Action<SpotlightItem, SpotlightItemViewModel>? ViewModelChanged;
|
||||
|
||||
public SpotlightItem() => InitializeComponent();
|
||||
|
||||
private static void OnViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnViewModelPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d as SpotlightItem is { } item)
|
||||
{
|
||||
item.ViewModelChanged?.Invoke(item, item.ViewModel);
|
||||
}
|
||||
ViewModelChanged?.Invoke(this, ViewModel);
|
||||
}
|
||||
|
||||
public SpotlightItem() => InitializeComponent();
|
||||
|
||||
private SolidColorBrush GetBackgroundBrush(SpotlightCategory category)
|
||||
{
|
||||
return new SolidColorBrush(category switch
|
||||
|
@ -3,14 +3,18 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using WinUI3Utilities.Attributes;
|
||||
using CommunityToolkit.WinUI;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<string>("PlaceholderText")]
|
||||
[DependencyProperty<ICollection<Token>>("TokenSource")]
|
||||
public sealed partial class TokenInput
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? PlaceholderText { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial ICollection<Token> TokenSource { get; set; }
|
||||
|
||||
public TokenInput() => InitializeComponent();
|
||||
|
||||
public Token Token { get; } = new();
|
||||
|
@ -1,81 +1,86 @@
|
||||
// Copyright (c) Pixeval.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using System;
|
||||
using Windows.System;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TokenInputTextBox"/> is intended to be used together with <see cref="TokenInput"/>, it contains a <see cref="TextBox"/>
|
||||
/// and a <see cref="TokenSubmitted"/> event to help user hook logic when a token is submitted, a token can be marked as case-sensitive
|
||||
/// or regex
|
||||
/// </summary>
|
||||
[DependencyProperty<string>("PlaceholderText")]
|
||||
[DependencyProperty<bool>("SubmitEnable")]
|
||||
[DependencyProperty<Token>("Token")]
|
||||
public partial class TokenInputTextBox : Control
|
||||
{
|
||||
private const string PartTokenTextBox = "TokenTextBox";
|
||||
private const string PartSubmitButton = "SubmitButton";
|
||||
|
||||
private Button? _submitButton;
|
||||
|
||||
private TextBox? _tokenTextBox;
|
||||
|
||||
public TokenInputTextBox() => DefaultStyleKey = typeof(TokenInputTextBox);
|
||||
|
||||
public event EventHandler<Token>? TokenSubmitted;
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
if (_tokenTextBox is not null)
|
||||
{
|
||||
_tokenTextBox.KeyDown -= TokenTextBoxOnKeyDown;
|
||||
}
|
||||
|
||||
if ((_tokenTextBox = GetTemplateChild(PartTokenTextBox) as TextBox) is not null)
|
||||
{
|
||||
_tokenTextBox.KeyDown += TokenTextBoxOnKeyDown;
|
||||
}
|
||||
|
||||
if (_submitButton is not null)
|
||||
{
|
||||
_submitButton.Click -= SubmitButtonOnClicked;
|
||||
}
|
||||
|
||||
if ((_submitButton = GetTemplateChild(PartSubmitButton) as Button) is not null)
|
||||
{
|
||||
_submitButton.Click += SubmitButtonOnClicked;
|
||||
}
|
||||
|
||||
base.OnApplyTemplate();
|
||||
}
|
||||
|
||||
private void SubmitButtonOnClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SubmitToken();
|
||||
}
|
||||
|
||||
private void TokenTextBoxOnKeyDown(object sender, KeyRoutedEventArgs e)
|
||||
{
|
||||
if (e.Key is VirtualKey.Enter or VirtualKey.Space)
|
||||
{
|
||||
SubmitToken();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void SubmitToken()
|
||||
{
|
||||
if (SubmitEnable && _tokenTextBox is { Text.Length: > 0 })
|
||||
{
|
||||
TokenSubmitted?.Invoke(this, Token.DeepClone());
|
||||
_tokenTextBox.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Copyright (c) Pixeval.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using System;
|
||||
using Windows.System;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TokenInputTextBox"/> is intended to be used together with <see cref="TokenInput"/>, it contains a <see cref="TextBox"/>
|
||||
/// and a <see cref="TokenSubmitted"/> event to help user hook logic when a token is submitted, a token can be marked as case-sensitive
|
||||
/// or regex
|
||||
/// </summary>
public partial class TokenInputTextBox : Control
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? PlaceholderText { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial bool SubmitEnable { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial Token Token { get; set; }
|
||||
|
||||
public event EventHandler<Token>? TokenSubmitted;
|
||||
|
||||
private const string PartTokenTextBox = "TokenTextBox";
|
||||
private const string PartSubmitButton = "SubmitButton";
|
||||
|
||||
private Button? _submitButton;
|
||||
|
||||
private TextBox? _tokenTextBox;
|
||||
|
||||
public TokenInputTextBox() => DefaultStyleKey = typeof(TokenInputTextBox);
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
if (_tokenTextBox is not null)
|
||||
{
|
||||
_tokenTextBox.KeyDown -= TokenTextBoxOnKeyDown;
|
||||
}
|
||||
|
||||
if ((_tokenTextBox = GetTemplateChild(PartTokenTextBox) as TextBox) is not null)
|
||||
{
|
||||
_tokenTextBox.KeyDown += TokenTextBoxOnKeyDown;
|
||||
}
|
||||
|
||||
if (_submitButton is not null)
|
||||
{
|
||||
_submitButton.Click -= SubmitButtonOnClicked;
|
||||
}
|
||||
|
||||
if ((_submitButton = GetTemplateChild(PartSubmitButton) as Button) is not null)
|
||||
{
|
||||
_submitButton.Click += SubmitButtonOnClicked;
|
||||
}
|
||||
|
||||
base.OnApplyTemplate();
|
||||
}
|
||||
|
||||
private void SubmitButtonOnClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SubmitToken();
|
||||
}
|
||||
|
||||
private void TokenTextBoxOnKeyDown(object sender, KeyRoutedEventArgs e)
|
||||
{
|
||||
if (e.Key is VirtualKey.Enter or VirtualKey.Space)
|
||||
{
|
||||
SubmitToken();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void SubmitToken()
|
||||
{
|
||||
if (SubmitEnable && _tokenTextBox is { Text.Length: > 0 })
|
||||
{
|
||||
TokenSubmitted?.Invoke(this, Token.DeepClone());
|
||||
_tokenTextBox.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,21 @@
|
||||
// Copyright (c) Pixeval.
|
||||
// Licensed under the GPL v3 License.
|
||||
using System.Linq;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Pixeval.Extensions;
|
||||
using Pixeval.Extensions.Common.Commands.Transformers;
|
||||
using WinUI3Utilities.Attributes;
|
||||
using Microsoft.UI.Xaml.Documents;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<TextTransformerType>("TransformerType", defaultValueType: DependencyPropertyDefaultValue.New)]
|
||||
public sealed partial class TranslatableTextBlock : UserControl
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial TextTransformerType TransformerType { get; set; }
|
||||
|
||||
public TranslatableTextBlock() => InitializeComponent();
|
||||
|
||||
private async void GetTranslationClicked(object sender, RoutedEventArgs e)
|
||||
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Windows.Foundation;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Pixeval.Pages.NovelViewer;
|
||||
@ -22,10 +22,6 @@ using Pixeval.Pages.IllustratorViewer;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// todo
|
||||
/// </summary>
|
||||
[ObservableObject]
|
||||
public sealed partial class WorkView : IEntryView<ISortableEntryViewViewModel>, IStructuralDisposalCompleter
|
||||
{
|
||||
public const double LandscapeHeight = 180;
|
||||
@ -60,10 +56,10 @@ public sealed partial class WorkView : IEntryView<ISortableEntryViewViewModel>,
|
||||
/// <summary>
|
||||
/// 在调用<see cref="ResetEngine"/>前为<see langword="null"/>
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
public partial ISortableEntryViewViewModel ViewModel { get; set; } = null!;
|
||||
[GeneratedDependencyProperty]
|
||||
public partial ISortableEntryViewViewModel ViewModel { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
[GeneratedDependencyProperty]
|
||||
public partial SimpleWorkType Type { get; set; }
|
||||
|
||||
private async void WorkItem_OnViewModelChanged(FrameworkElement sender, IWorkViewModel viewModel)
|
||||
@ -140,7 +136,6 @@ public sealed partial class WorkView : IEntryView<ISortableEntryViewViewModel>,
|
||||
AdvancedItemsView.LayoutType = LayoutType;
|
||||
AdvancedItemsView.ItemTemplate = this.GetResource<DataTemplate>("IllustrationItemDataTemplate");
|
||||
ViewModel = new IllustrationViewViewModel();
|
||||
OnPropertyChanged(nameof(ViewModel));
|
||||
ViewModel.ResetEngine(newEngine, itemsPerPage, itemLimit);
|
||||
ViewModelChanged?.Invoke(this, ViewModel);
|
||||
AdvancedItemsView.ItemsSource = ViewModel.View;
|
||||
@ -155,7 +150,6 @@ public sealed partial class WorkView : IEntryView<ISortableEntryViewViewModel>,
|
||||
AdvancedItemsView.LayoutType = ItemsViewLayoutType.Grid;
|
||||
AdvancedItemsView.ItemTemplate = this.GetResource<DataTemplate>("NovelItemDataTemplate");
|
||||
ViewModel = new NovelViewViewModel();
|
||||
OnPropertyChanged(nameof(ViewModel));
|
||||
ViewModel.ResetEngine(newEngine, itemsPerPage, itemLimit);
|
||||
ViewModelChanged?.Invoke(this, ViewModel);
|
||||
AdvancedItemsView.ItemsSource = ViewModel.View;
|
||||
|
@ -1,19 +1,25 @@
|
||||
// Copyright (c) Pixeval.
|
||||
// Licensed under the GPL v3 License.
|
||||
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
using Pixeval.Controls.Windowing;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Controls;
|
||||
|
||||
[DependencyProperty<object>("MenuItemsSource")]
|
||||
[DependencyProperty<object>("PaneContent")]
|
||||
[DependencyProperty<bool>("IsPaneOpen", "false")]
|
||||
public sealed partial class WorkViewerSplitView
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial object? MenuItemsSource { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial object? PaneContent { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = false)]
|
||||
public partial bool IsPaneOpen { get; set; }
|
||||
|
||||
public const double OpenPaneLength = 330;
|
||||
|
||||
public WorkViewerSplitView() => InitializeComponent();
|
||||
|
@ -25,9 +25,6 @@ using Windows.Foundation;
|
||||
|
||||
namespace Pixeval.Pages.Misc;
|
||||
|
||||
/// <summary>
|
||||
/// todo INotifyPropertyChanged
|
||||
/// </summary>
|
||||
public sealed partial class SettingsPage : IDisposable, INotifyPropertyChanged
|
||||
{
|
||||
private string CurrentVersion =>
|
||||
|
@ -6,6 +6,7 @@ using System.Collections.Frozen;
|
||||
using System.IO;
|
||||
using Windows.Storage;
|
||||
using Windows.System;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Pixeval.Controls;
|
||||
@ -13,13 +14,14 @@ using Pixeval.Controls.DialogContent;
|
||||
using Pixeval.Pages.IllustrationViewer;
|
||||
using Pixeval.Util.UI;
|
||||
using WinUI3Utilities;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Pages.Tags;
|
||||
|
||||
[DependencyProperty<TagsEntryViewModel>("ViewModel")]
|
||||
public sealed partial class TagsEntry
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial TagsEntryViewModel ViewModel { get; set; }
|
||||
|
||||
public event Action<TagsEntry, string>? TagClick;
|
||||
|
||||
public event Action<TagsEntry, TagsEntryViewModel>? FileDeleted;
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock" />
|
||||
<PackageReference Include="CommunityToolkit.Labs.WinUI.DependencyPropertyGenerator" />
|
||||
<PackageReference Include="CommunityToolkit.Labs.WinUI.Shimmer" />
|
||||
<PackageReference Include="CommunityToolkit.Labs.WinUI.TitleBar" />
|
||||
<PackageReference Include="CommunityToolkit.Labs.WinUI.TokenView" />
|
||||
@ -75,7 +76,7 @@
|
||||
|
||||
<!--Exposes PRI resources-->
|
||||
<Target Name="InjectAdditionalFiles" BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun" Condition="'$(DesignTimeBuild)' != 'true'">
|
||||
<RemoveDir Directories="Generated" />
|
||||
<RemoveDir Directories="Strings\.generated" />
|
||||
<ItemGroup>
|
||||
<TextFiles Include="%(TextFile.OutputTarget)">
|
||||
<Key>$([System.String]::Copy('%(TextFile.Key)').Replace('_', '/'))</Key>
|
||||
@ -93,11 +94,11 @@
|
||||
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="SourceItemGroup" />
|
||||
|
||||
<TextFile Include="Strings\*\*.md">
|
||||
<OutputTarget>Generated\%(RecursiveDir)TextGenerated.resjson</OutputTarget>
|
||||
<OutputTarget>Strings\.generated\%(RecursiveDir)TextGenerated.resjson</OutputTarget>
|
||||
<Key>%(Filename)</Key>
|
||||
</TextFile>
|
||||
<TextFile Include="Strings\*\*.txt">
|
||||
<OutputTarget>Generated\%(RecursiveDir)TextGenerated.resjson</OutputTarget>
|
||||
<OutputTarget>Strings\.generated\%(RecursiveDir)TextGenerated.resjson</OutputTarget>
|
||||
<Key>%(Filename)</Key>
|
||||
</TextFile>
|
||||
|
||||
|
@ -3,21 +3,27 @@
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.Xaml.Interactivity;
|
||||
using WinUI3Utilities.Attributes;
|
||||
|
||||
namespace Pixeval.Util.Triggers;
|
||||
|
||||
/// <summary>
|
||||
/// <seealso href="https://github.com/microsoft/XamlBehaviors/blob/master/src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions.Shared/Core/EventTriggerBehavior.cs"/>
|
||||
/// </summary>
|
||||
[DependencyProperty<string>("EventName", "\"Loaded\"", nameof(OnEventNameChanged))]
|
||||
[DependencyProperty<object>("SourceObject", DependencyPropertyDefaultValue.Default, nameof(OnSourceObjectChanged))]
|
||||
[DependencyProperty<bool>("IsActive", "true")]
|
||||
public partial class EventWithConditionTriggerBehavior : Trigger
|
||||
{
|
||||
[GeneratedDependencyProperty(DefaultValue = "Loaded")]
|
||||
public partial string EventName { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial object? SourceObject { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty(DefaultValue = true)]
|
||||
public partial bool IsActive { get; set; }
|
||||
|
||||
private Delegate? _eventHandler;
|
||||
private bool _isLoadedEventRegistered;
|
||||
private object? _resolvedSource;
|
||||
@ -67,7 +73,7 @@ public partial class EventWithConditionTriggerBehavior : Trigger
|
||||
}
|
||||
}
|
||||
|
||||
private object ComputeResolvedSource()
|
||||
private object? ComputeResolvedSource()
|
||||
{
|
||||
// If the SourceObject property is set at all, we want to use it. It is possible that it is data
|
||||
// bound and bindings haven't been evaluated yet. Plus, this makes the API more predictable.
|
||||
@ -134,25 +140,23 @@ public partial class EventWithConditionTriggerBehavior : Trigger
|
||||
_ = Interaction.ExecuteActions(_resolvedSource, Actions, eventArgs);
|
||||
}
|
||||
|
||||
private static void OnSourceObjectChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
|
||||
partial void OnSourceObjectPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var behavior = (EventWithConditionTriggerBehavior)dependencyObject;
|
||||
behavior.SetResolvedSource(behavior.ComputeResolvedSource());
|
||||
SetResolvedSource(ComputeResolvedSource());
|
||||
}
|
||||
|
||||
private static void OnEventNameChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
|
||||
partial void OnEventNamePropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var behavior = (EventWithConditionTriggerBehavior)dependencyObject;
|
||||
if (behavior.AssociatedObject is null || behavior._resolvedSource is null)
|
||||
if (AssociatedObject is null || _resolvedSource is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var oldEventName = (string)args.OldValue;
|
||||
var newEventName = (string)args.NewValue;
|
||||
var oldEventName = (string)e.OldValue;
|
||||
var newEventName = (string)e.NewValue;
|
||||
|
||||
behavior.UnregisterEvent(oldEventName);
|
||||
behavior.RegisterEvent(newEventName);
|
||||
UnregisterEvent(oldEventName);
|
||||
RegisterEvent(newEventName);
|
||||
}
|
||||
|
||||
internal static bool IsElementLoaded(FrameworkElement? element)
|
||||
|
Loading…
x
Reference in New Issue
Block a user