用方法替代Converter (#500)

This commit is contained in:
Poker 2024-06-12 13:59:24 +08:00 committed by GitHub
parent f7d9f0487a
commit 4a0b8cb33d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
47 changed files with 266 additions and 699 deletions

139
src/Pixeval.Controls/C.cs Normal file
View File

@ -0,0 +1,139 @@
#region Copyright
// GPL v3 License
//
// Pixeval/Pixeval
// Copyright (c) 2024 Pixeval/C.cs
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Globalization;
using Windows.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
using WinUI3Utilities;
using Windows.UI.Text;
using Microsoft.UI.Text;
namespace Pixeval.Controls;
/// <summary>
/// Converters
/// </summary>
public static class C
{
public static bool Negation(bool value) => !value;
public static bool IsNull(object? value) => value is null;
public static bool IsNotNull(object? value) => value is not null;
public static Visibility ToVisibility(bool value) => value ? Visibility.Visible : Visibility.Collapsed;
public static Visibility ToVisibilityNegation(bool value) => value ? Visibility.Collapsed : Visibility.Visible;
public static Visibility IsNullToVisibility(object? value) => value is null ? Visibility.Visible : Visibility.Collapsed;
public static Visibility IsNotNullToVisibility(object? value) => value is null ? Visibility.Collapsed : Visibility.Visible;
public static bool IsNotZero(int value) => value is not 0;
public static bool IsNotZeroL(long value) => value is not 0;
public static Visibility IsNotZeroDToVisibility(double value) => value is not 0 ? Visibility.Visible : Visibility.Collapsed;
public static unsafe Color ToAlphaColor(uint color)
{
var ptr = &color;
var c = (byte*)ptr;
return Color.FromArgb(c[3], c[2], c[1], c[0]);
}
public static SolidColorBrush ToSolidColorBrush(uint value) => new(value.GetAlphaColor());
public static unsafe uint ToAlphaUInt(Color color)
{
uint ret;
var ptr = &ret;
var c = (byte*)ptr;
c[0] = color.B;
c[1] = color.G;
c[2] = color.R;
c[3] = color.A;
return ret;
}
public static string CultureDateTimeDateFormatter(DateTime value, CultureInfo culture) =>
value.ToString(culture.DateTimeFormat.ShortDatePattern);
public static string CultureDateTimeOffsetDateFormatter(DateTimeOffset value, CultureInfo culture) =>
value.ToString(culture.DateTimeFormat.ShortDatePattern);
public static string CultureDateTimeFormatter(DateTime value, CultureInfo culture) =>
value.ToString(culture.DateTimeFormat.FullDateTimePattern);
public static string CultureDateTimeOffsetFormatter(DateTimeOffset value, CultureInfo culture) =>
value.ToString(culture.DateTimeFormat.FullDateTimePattern);
public static FontFamily ToFontFamily(string value) => new(value);
public static string ToPercentageString(object value, int precision)
{
var p = "F" + precision;
return value switch
{
uint i => (i * 100).ToString(p),
int i => (i * 100).ToString(p),
short i => (i * 100).ToString(p),
ushort i => (i * 100).ToString(p),
long i => (i * 100).ToString(p),
ulong i => (i * 100).ToString(p),
float i => (i * 100).ToString(p),
double i => (i * 100).ToString(p),
decimal i => (i * 100).ToString(p),
_ => "NaN"
} + "%";
}
public static string PlusOneToString(int value) => (value + 1).ToString();
public static CommandBarLabelPosition LabelIsNullToVisibility(string? value) =>
value is null ? CommandBarLabelPosition.Collapsed : CommandBarLabelPosition.Default;
public static ItemsViewSelectionMode ToSelectionMode(bool value) =>
value ? ItemsViewSelectionMode.Multiple : ItemsViewSelectionMode.None;
public static string IntEllipsis(int value) =>
value < 1000 ? value.ToString() : $"{value / 1000d:0.#}k";
public static double DoubleComplementary(double value) => 1 - value;
public static FontWeight ToFontWeight(Enum value) => value.GetHashCode() switch
{
0 => FontWeights.Thin,
1 => FontWeights.ExtraLight,
2 => FontWeights.Light,
3 => FontWeights.SemiLight,
4 => FontWeights.Normal,
5 => FontWeights.Medium,
6 => FontWeights.SemiBold,
7 => FontWeights.Bold,
8 => FontWeights.ExtraBold,
9 => FontWeights.Black,
10 => FontWeights.ExtraBlack,
_ => ThrowHelper.ArgumentOutOfRange<Enum, FontWeight>(value)
};
}

View File

@ -1,33 +0,0 @@
#region Copyright (c) ${File.SolutionName}/${File.ProjectName}
// GPL v3 License
//
// Pixeval/Pixeval.Controls
// Copyright (c) 2023 Pixeval.Controls/BoolNegationToVisibilityConverter.cs
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class BoolNegationToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => value.To<bool>() ? Visibility.Collapsed : Visibility.Visible;
public object ConvertBack(object value, Type targetType, object parameter, string language) => value.To<Visibility>() is Visibility.Collapsed;
}

View File

@ -1,13 +0,0 @@
using System;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class BoolToCommandBarLabelPositionConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => value.To<bool>() ? CommandBarLabelPosition.Default : CommandBarLabelPosition.Collapsed;
public object ConvertBack(object value, Type targetType, object parameter, string language) => value.To<CommandBarLabelPosition>() is CommandBarLabelPosition.Default;
}

View File

@ -1,13 +0,0 @@
using System;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class BoolToSelectionModeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => value.To<bool>() ? ItemsViewSelectionMode.Multiple : ItemsViewSelectionMode.None;
public object ConvertBack(object value, Type targetType, object parameter, string language) => value.To<ItemsViewSelectionMode>() is ItemsViewSelectionMode.Multiple;
}

View File

@ -1,12 +0,0 @@
using System;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class ComplementaryDoubleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => 1 - value.To<double>();
public object ConvertBack(object value, Type targetType, object parameter, string language) => 1 - value.To<double>();
}

View File

@ -1,12 +0,0 @@
using System;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class DisplayIndexConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => (value.To<int>() + 1).ToString();
public object ConvertBack(object value, Type targetType, object parameter, string language) => int.Parse(value.To<string>()) - 1;
}

View File

@ -1,33 +0,0 @@
#region Copyright (c) Pixeval/Pixeval.Controls
// GPL v3 License
//
// Pixeval/Pixeval.Controls
// Copyright (c) 2023 Pixeval.Controls/FloatToVector3Converter.cs
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class DoubleToBoolToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => value.To<double>() is not 0 ? Visibility.Visible : Visibility.Collapsed;
public object ConvertBack(object value, Type targetType, object parameter, string language) => value.To<Visibility>() is Visibility.Visible ? 1d : 0d;
}

View File

@ -1,33 +0,0 @@
#region Copyright
// GPL v3 License
//
// Pixeval/Pixeval.Controls
// Copyright (c) 2024 Pixeval.Controls/LabelNullableVisibilityConverter.cs
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class LabelNullableVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => value.To<string?>() is null ? CommandBarLabelPosition.Collapsed : CommandBarLabelPosition.Default;
public object ConvertBack(object value, Type targetType, object parameter, string language) => ThrowHelper.NotSupported<object>();
}

View File

@ -1,40 +0,0 @@
#region Copyright
// GPL v3 License
//
// Pixeval/Pixeval.Controls
// Copyright (c) 2024 Pixeval.Controls/LongToDoubleConverter.cs
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class LongToDoubleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return (double)value.To<long>();
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return (long)value.To<double>();
}
}

View File

@ -1,12 +0,0 @@
using System;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class NullableToBoolConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object parameter, string language) => value is not null;
public object ConvertBack(object value, Type targetType, object parameter, string language) => ThrowHelper.NotSupported<object>();
}

View File

@ -1,38 +0,0 @@
#region Copyright
// GPL v3 License
//
// Pixeval/Pixeval.Controls
// Copyright (c) 2024 Pixeval.Controls/NullableToVisibilityConverter.cs
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class NullableToVisibilityConverter : IValueConverter
{
public bool Negative { get; set; }
public object Convert(object? value, Type targetType, object parameter, string language) => Negative ^ value is null ? Visibility.Collapsed : Visibility.Visible;
public object ConvertBack(object value, Type targetType, object parameter, string language) => ThrowHelper.NotSupported<object>();
}

View File

@ -1,36 +0,0 @@
#region Copyright
// GPL v3 License
//
// Pixeval/Pixeval.Controls
// Copyright (c) 2024 Pixeval.Controls/NumberEllipsisConverter.cs
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class NumberEllipsisConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var v = value.To<int>();
return v < 1000 ? v.ToString() : $"{v / 1000d:0.#}k";
}
public object ConvertBack(object value, Type targetType, object parameter, string language) => ThrowHelper.NotSupported<object>();
}

View File

@ -1,48 +0,0 @@
#region Copyright (c) Pixeval/Pixeval
// GPL v3 License
//
// Pixeval/Pixeval
// Copyright (c) 2023 Pixeval/NumberToPercentageConverter.cs
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class NumberToPercentageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var p = "F" + parameter.To<string>();
return value switch
{
uint i => (i * 100).ToString(p),
int i => (i * 100).ToString(p),
short i => (i * 100).ToString(p),
ushort i => (i * 100).ToString(p),
long i => (i * 100).ToString(p),
ulong i => (i * 100).ToString(p),
float i => (i * 100).ToString(p),
double i => (i * 100).ToString(p),
decimal i => (i * 100).ToString(p),
_ => "NaN"
} + "%";
}
public object ConvertBack(object value, Type targetType, object parameter, string language) => ThrowHelper.NotSupported<object>();
}

View File

@ -1,13 +0,0 @@
using System;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Media;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class StringToFontFamilyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => new FontFamily(value.To<string>());
public object ConvertBack(object value, Type targetType, object parameter, string language) => value.To<FontFamily>().Source;
}

View File

@ -1,35 +0,0 @@
#region Copyright
// GPL v3 License
//
// Pixeval/Pixeval.Controls
// Copyright (c) 2024 Pixeval.Controls/UIntToBrushConverter.cs
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Media;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class UIntToBrushConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => new SolidColorBrush(value.To<uint>().GetAlphaColor());
public object ConvertBack(object value, Type targetType, object parameter, string language) => value.To<SolidColorBrush>().Color.GetAlphaUInt();
}

View File

@ -1,33 +0,0 @@
#region Copyright
// GPL v3 License
//
// Pixeval/Pixeval.Controls
// Copyright (c) 2024 Pixeval.Controls/UIntToColorConverter.cs
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using Windows.UI;
using Microsoft.UI.Xaml.Data;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class UIntToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => value.To<uint>().GetAlphaColor();
public object ConvertBack(object value, Type targetType, object parameter, string language) => value.To<Color>().GetAlphaUInt();
}

View File

@ -19,7 +19,6 @@
#endregion
using System;
using Windows.Foundation;
using CommunityToolkit.Labs.WinUI;
using CommunityToolkit.WinUI.Controls;
using Microsoft.UI.Xaml;

View File

@ -2,59 +2,53 @@
x:Class="Pixeval.Controls.CommentItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Pixeval.Controls"
xmlns:controls1="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:converters1="using:Pixeval.Controls.Converters"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="using:FluentIcons.WinUI"
xmlns:local="using:Pixeval.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pixeval="using:Pixeval.AppManagement"
mc:Ignorable="d">
<UserControl.Resources>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters1:CultureDateConverter x:Key="CultureDateConverter" />
<converters1:LabelNullableVisibilityConverter x:Key="LabelNullableVisibilityConverter" />
</UserControl.Resources>
<controls1:DockPanel HorizontalSpacing="10" VerticalSpacing="5">
<controls1:SwitchPresenter
<controls:DockPanel HorizontalSpacing="10" VerticalSpacing="5">
<controls:SwitchPresenter
Margin="57,0,0,0"
controls1:DockPanel.Dock="Bottom"
controls:DockPanel.Dock="Bottom"
Value="{x:Bind ViewModel.IsStamp, Mode=OneWay}">
<controls1:Case>
<controls1:Case.Value>
<controls:Case>
<controls:Case.Value>
<x:Boolean>True</x:Boolean>
</controls1:Case.Value>
<controls:LazyImage
</controls:Case.Value>
<local:LazyImage
x:Name="StickerImageContent"
MaxHeight="100"
HorizontalAlignment="Left"
Stretch="Uniform" />
</controls1:Case>
<controls1:Case>
<controls1:Case.Value>
</controls:Case>
<controls:Case>
<controls:Case.Value>
<x:Boolean>False</x:Boolean>
</controls1:Case.Value>
</controls:Case.Value>
<RichTextBlock
x:Name="CommentContent"
FontSize="{StaticResource CaptionTextBlockFontSize}"
LineHeight="14.4"
TextWrapping="Wrap" />
</controls1:Case>
</controls1:SwitchPresenter>
</controls:Case>
</controls:SwitchPresenter>
<CommandBar
controls1:DockPanel.Dock="Right"
controls:DockPanel.Dock="Right"
DefaultLabelPosition="Right"
OverflowButtonVisibility="Collapsed">
<AppBarButton
Click="DeleteReplyHyperlinkButton_OnClicked"
Icon="{fluent:SymbolIcon Symbol=Delete}"
LabelPosition="Collapsed"
Visibility="{x:Bind ViewModel.IsMe, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind local:C.ToVisibility(ViewModel.IsMe), Mode=OneWay}" />
<AppBarButton
Click="OpenRepliesHyperlinkButton_OnClicked"
Icon="{fluent:SymbolIcon Symbol=Chat}"
Label="{x:Bind ViewModel.RepliesCount, Mode=OneWay}"
LabelPosition="{x:Bind ViewModel.RepliesCount, Converter={StaticResource LabelNullableVisibilityConverter}, Mode=OneWay}" />
LabelPosition="{x:Bind local:C.LabelIsNullToVisibility(ViewModel.RepliesCount), Mode=OneWay}" />
</CommandBar>
<Button
HorizontalAlignment="Stretch"
@ -62,23 +56,23 @@
Background="Transparent"
BorderThickness="0"
Click="PosterPersonPicture_OnClicked">
<controls1:DockPanel HorizontalSpacing="10" LastChildFill="False">
<controls:DockPanel HorizontalSpacing="10" LastChildFill="False">
<PersonPicture
Width="35"
Height="35"
controls1:DockPanel.Dock="Left"
controls:DockPanel.Dock="Left"
ProfilePicture="{x:Bind ViewModel.AvatarSource, Mode=OneWay}" />
<TextBlock
controls1:DockPanel.Dock="Top"
controls:DockPanel.Dock="Top"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{x:Bind ViewModel.Poster, Mode=OneWay}" />
<!-- TipTextColor -->
<TextBlock
controls1:DockPanel.Dock="Bottom"
controls:DockPanel.Dock="Bottom"
Foreground="{ThemeResource PixevalTipTextForeground}"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{x:Bind ViewModel.PostDate, Converter={StaticResource CultureDateConverter}, Mode=OneWay}" />
</controls1:DockPanel>
Text="{x:Bind local:C.CultureDateTimeOffsetDateFormatter(ViewModel.PostDate, pixeval:AppSettings.CurrentCulture), Mode=OneWay}" />
</controls:DockPanel>
</Button>
</controls1:DockPanel>
</controls:DockPanel>
</UserControl>

View File

@ -1,41 +0,0 @@
#region Copyright
// GPL v3 License
//
// Pixeval/Pixeval
// Copyright (c) 2024 Pixeval/CultureDateConverter.cs
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using Microsoft.UI.Xaml.Data;
using Pixeval.AppManagement;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
public class CultureDateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return value switch
{
DateTime t => t.ToString(AppSettings.CurrentCulture.DateTimeFormat.ShortDatePattern),
DateTimeOffset t => t.ToString(AppSettings.CurrentCulture.DateTimeFormat.ShortDatePattern),
_ => ThrowHelper.ArgumentOutOfRange<object, string>(value)
};
}
public object ConvertBack(object value, Type targetType, object parameter, string language) => ThrowHelper.NotSupported<object>();
}

View File

@ -1,28 +0,0 @@
using System;
using Microsoft.UI.Xaml.Data;
using Windows.UI.Text;
using Microsoft.UI.Text;
using Pixeval.Options;
using WinUI3Utilities;
namespace Pixeval.Controls.Converters;
internal class FontWeightConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language) => value.To<FontWeightsOption>() switch
{
FontWeightsOption.Thin => FontWeights.Thin,
FontWeightsOption.ExtraLight => FontWeights.ExtraLight,
FontWeightsOption.Light => FontWeights.Light,
FontWeightsOption.SemiLight => FontWeights.SemiLight,
FontWeightsOption.Normal => FontWeights.Normal,
FontWeightsOption.Medium => FontWeights.Medium,
FontWeightsOption.SemiBold => FontWeights.SemiBold,
FontWeightsOption.Bold => FontWeights.Bold,
FontWeightsOption.ExtraBold => FontWeights.ExtraBold,
FontWeightsOption.Black => FontWeights.Black,
FontWeightsOption.ExtraBlack => FontWeights.ExtraBlack,
_ => ThrowHelper.ArgumentOutOfRange<object, FontWeight>(value)
};
public object ConvertBack(object value, Type targetType, object parameter, string language) => ThrowHelper.NotSupported<object>();
}

View File

@ -24,7 +24,6 @@ using Windows.Foundation;
using Windows.System;
using Microsoft.UI.Xaml;
using Pixeval.Download;
using Pixeval.Pages.Download;
using Pixeval.Util.UI;
using WinUI3Utilities;
using WinUI3Utilities.Attributes;

View File

@ -4,7 +4,6 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.WinUI.Collections;
using Pixeval.Collections;
using Pixeval.Download.Models;
using Pixeval.Pages.Download;
namespace Pixeval.Controls;

View File

@ -3,7 +3,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Pixeval.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -11,7 +10,6 @@
VerticalSpacing="1"
mc:Ignorable="d">
<controls:DockPanel.Resources>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<TeachingTip
x:Name="QrCodeTeachingTip"
Title="{x:Bind TeachingTipTitle, Mode=OneWay}"
@ -27,7 +25,7 @@
Margin="-5,0"
controls:DockPanel.Dock="Bottom"
IsIndeterminate="True"
Visibility="{x:Bind IsLoadingMore, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind local:C.ToVisibility(IsLoadingMore), Mode=OneWay}" />
<Grid>
<StackPanel
x:Name="HasNoItemStackPanel"

View File

@ -4,14 +4,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Pixeval.Controls"
xmlns:controls1="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Pixeval.Controls.FlyoutContent"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<controls1:DockPanel.Resources>
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
</controls1:DockPanel.Resources>
<controls:PixivReplyBar
x:Name="ReplyBar"
Margin="10"
@ -21,7 +17,7 @@
<!-- ReSharper disable once UnusedMember.Local -->
<controls:CommentView
x:Name="CommentView"
HasNoItem="{x:Bind ViewModel.RepliesIsNotNull, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}"
HasNoItem="{x:Bind controls:C.Negation(ViewModel.RepliesIsNotNull), Mode=OneWay}"
ItemsSource="{x:Bind ViewModel.Replies, Mode=OneWay}"
RepliesHyperlinkButtonClick="CommentView_OnRepliesHyperlinkButtonClick" />
</controls1:DockPanel>

View File

@ -3,8 +3,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:converters1="using:Pixeval.Controls.Converters"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="using:FluentIcons.WinUI"
@ -21,8 +19,6 @@
<ToolTip Content="{x:Bind ViewModel.Tooltip, Mode=OneWay}" Placement="Right" />
</ToolTipService.ToolTip>
<Grid.Resources>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters1:NullableToVisibilityConverter x:Key="NullableToVisibilityConverter" Negative="True" />
<ExponentialEase
x:Key="EasingFunction"
EasingMode="EaseOut"
@ -72,7 +68,7 @@
VerticalAlignment="Center"
Source="{x:Bind ViewModel.ThumbnailSource, Mode=OneWay}"
Stretch="UniformToFill" />
<labs:Shimmer Visibility="{x:Bind ViewModel.ThumbnailSource, Converter={StaticResource NullableToVisibilityConverter}, Mode=OneWay}" />
<labs:Shimmer Visibility="{x:Bind local:C.IsNullToVisibility(ViewModel.ThumbnailSource), Mode=OneWay}" />
<local:HeartButton
x:Name="HeartButton"
HorizontalAlignment="Left"
@ -87,22 +83,22 @@
<local:PixevalBadge
controls:DockPanel.Dock="Left"
Mode="Ai"
Visibility="{x:Bind ViewModel.IsAiGenerated, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind local:C.ToVisibility(ViewModel.IsAiGenerated), Mode=OneWay}" />
<local:PixevalBadge
controls:DockPanel.Dock="Left"
Mode="{x:Bind ViewModel.XRestrictionCaption, Mode=OneWay}"
Visibility="{x:Bind ViewModel.IsXRestricted, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind local:C.ToVisibility(ViewModel.IsXRestricted), Mode=OneWay}" />
<local:PixevalBadge
controls:DockPanel.Dock="Left"
Mode="Gif"
Visibility="{x:Bind ViewModel.IsUgoira, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind local:C.ToVisibility(ViewModel.IsUgoira), Mode=OneWay}" />
<Grid controls:DockPanel.Dock="Right">
<fluent:SymbolIcon
Foreground="{StaticResource LayerFillColorDefaultBrush}"
IsFilled="True"
Symbol="SquareMultiple"
Visibility="{x:Bind ViewModel.IsManga, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
<fluent:SymbolIcon Symbol="SquareMultiple" Visibility="{x:Bind ViewModel.IsManga, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind local:C.ToVisibility(ViewModel.IsManga), Mode=OneWay}" />
<fluent:SymbolIcon Symbol="SquareMultiple" Visibility="{x:Bind local:C.ToVisibility(ViewModel.IsManga), Mode=OneWay}" />
</Grid>
</controls:DockPanel>
</Grid>

View File

@ -3,7 +3,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="using:FluentIcons.WinUI"
@ -13,9 +12,6 @@
AspectRatio="15:8"
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
mc:Ignorable="d">
<controls:ConstrainedBox.Resources>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
</controls:ConstrainedBox.Resources>
<!-- 图片长宽均为5故为(3*5):(3+5) -->
<Grid>
<Grid.RowDefinitions>
@ -58,7 +54,7 @@
<local:PixevalBadge
Mode="Following"
UseSmall="True"
Visibility="{x:Bind ViewModel.IsFollowed, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind local:C.ToVisibility(ViewModel.IsFollowed), Mode=OneWay}" />
</StackPanel>
</StackPanel>
<Button

View File

@ -3,8 +3,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:converters1="using:Pixeval.Controls.Converters"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
@ -12,14 +10,12 @@
xmlns:local="using:Pixeval.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="using:Pixeval.CoreApi.Model"
xmlns:pixeval="using:Pixeval.AppManagement"
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
PointerEntered="NovelItem_OnPointerEntered"
PointerExited="NovelItem_OnPointerExited"
mc:Ignorable="d">
<Grid.Resources>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters1:CultureDateConverter x:Key="CultureDateConverter" />
<converters1:NumberEllipsisConverter x:Key="NumberEllipsisConverter" />
<!-- ReSharper disable once Xaml.RedundantResource -->
<Storyboard x:Key="ThumbnailStoryboard">
<DoubleAnimation
@ -76,7 +72,7 @@
Foreground="DarkGray"
MaxLines="1"
Style="{StaticResource BodyTextBlockStyle}"
Text="{x:Bind ViewModel.PublishDate, Converter={StaticResource CultureDateConverter}, Mode=OneWay}"
Text="{x:Bind local:C.CultureDateTimeOffsetDateFormatter(ViewModel.PublishDate, pixeval:AppSettings.CurrentCulture), Mode=OneWay}"
TextTrimming="CharacterEllipsis"
TextWrapping="WrapWholeWords" />
<TextBlock
@ -95,15 +91,15 @@
<local:IconText
controls:DockPanel.Dock="Right"
Symbol="TextAlignLeft"
Text="{x:Bind ViewModel.TextLength, Converter={StaticResource NumberEllipsisConverter}, Mode=OneWay}" />
Text="{x:Bind local:C.IntEllipsis(ViewModel.TextLength), Mode=OneWay}" />
<local:IconText
controls:DockPanel.Dock="Right"
Symbol="Heart"
Text="{x:Bind ViewModel.TotalBookmarks, Converter={StaticResource NumberEllipsisConverter}, Mode=OneWay}" />
Text="{x:Bind local:C.IntEllipsis(ViewModel.TotalBookmarks), Mode=OneWay}" />
<local:IconText
controls:DockPanel.Dock="Right"
Symbol="Eye"
Text="{x:Bind ViewModel.TotalView, Converter={StaticResource NumberEllipsisConverter}, Mode=OneWay}" />
Text="{x:Bind local:C.IntEllipsis(ViewModel.TotalView), Mode=OneWay}" />
</controls:DockPanel>
<controls:DockPanel
controls:DockPanel.Dock="Bottom"
@ -112,11 +108,11 @@
<local:PixevalBadge
controls:DockPanel.Dock="Right"
Mode="Ai"
Visibility="{x:Bind ViewModel.IsAiGenerated, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind local:C.ToVisibility(ViewModel.IsAiGenerated), Mode=OneWay}" />
<local:PixevalBadge
controls:DockPanel.Dock="Right"
Mode="{x:Bind ViewModel.XRestrictionCaption, Mode=OneWay}"
Visibility="{x:Bind ViewModel.IsXRestricted, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind local:C.ToVisibility(ViewModel.IsXRestricted), Mode=OneWay}" />
</controls:DockPanel>
<ItemsControl
x:Name="TagsList"

View File

@ -3,7 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:Pixeval.Controls.Converters"
xmlns:controls1="using:Pixeval.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="using:FluentIcons.WinUI"
xmlns:local="using:Pixeval.Controls.Settings"
@ -20,10 +20,9 @@
<Setter Property="IsMoreButtonVisible" Value="True" />
<Setter Property="IsAlphaEnabled" Value="True" />
</Style>
<converters:UIntToColorConverter x:Key="UIntToColorConverter" />
</controls:SettingsCard.Resources>
<controls:ColorPickerButton
ColorPickerStyle="{StaticResource ColorPickerStyle}"
Loaded="ColorPicker_OnLoaded"
SelectedColor="{x:Bind Entry.Value, Converter={StaticResource UIntToColorConverter}, Mode=TwoWay}" />
SelectedColor="{x:Bind controls1:C.ToAlphaColor(Entry.Value), BindBack=controls1:C.ToAlphaUInt, Mode=TwoWay}" />
</controls:SettingsCard>

View File

@ -3,7 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:Pixeval.Controls.Converters"
xmlns:controls1="using:Pixeval.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="using:FluentIcons.WinUI"
xmlns:local="using:Pixeval.Settings"
@ -15,14 +15,11 @@
<controls:SettingsCard.HeaderIcon>
<fluent:SymbolIcon Symbol="{x:Bind Entry.HeaderIcon}" />
</controls:SettingsCard.HeaderIcon>
<controls:SettingsCard.Resources>
<converters:StringToFontFamilyConverter x:Key="StringToFontFamilyConverter" />
</controls:SettingsCard.Resources>
<controls:SettingsCard.Description>
<HyperlinkButton
Click="OpenLinkViaTag_OnClicked"
Content="{x:Bind Entry.Description}"
Tag="ms-settings:fonts"
Click="OpenLinkViaTag_OnClicked" />
Tag="ms-settings:fonts" />
</controls:SettingsCard.Description>
<ComboBox
x:Uid="/SettingsPage/AppFontFamilyComboBox"
@ -32,7 +29,7 @@
SelectionChanged="Selector_OnSelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="x:String">
<TextBlock FontFamily="{x:Bind Converter={StaticResource StringToFontFamilyConverter}}" Text="{x:Bind}" />
<TextBlock FontFamily="{x:Bind controls1:C.ToFontFamily((x:String))}" Text="{x:Bind}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>

View File

@ -3,15 +3,12 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:Pixeval.Controls.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Pixeval.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pixeval="using:Pixeval.AppManagement"
LastChildFill="False"
mc:Ignorable="d">
<controls:DockPanel.Resources>
<converters:CultureDateConverter x:Key="CultureDateConverter" />
</controls:DockPanel.Resources>
<controls:ConstrainedBox controls:DockPanel.Dock="Top" AspectRatio="40:21">
<local:LazyImage CornerRadius="0" Source="{x:Bind ViewModel.ThumbnailSource, Mode=OneWay}" />
</controls:ConstrainedBox>
@ -35,6 +32,6 @@
<TextBlock
controls:DockPanel.Dock="Right"
Foreground="DarkGray"
Text="{x:Bind ViewModel.Entry.PublishDate, Converter={StaticResource CultureDateConverter}, Mode=OneWay}" />
Text="{x:Bind local:C.CultureDateTimeOffsetDateFormatter(ViewModel.Entry.PublishDate, pixeval:AppSettings.CurrentCulture), Mode=OneWay}" />
</controls:DockPanel>
</controls:DockPanel>

View File

@ -12,10 +12,7 @@ public sealed partial class SpotlightItem
{
public event Action<SpotlightItem, SpotlightItemViewModel>? ViewModelChanged;
public SpotlightItem()
{
InitializeComponent();
}
public SpotlightItem() => InitializeComponent();
private static void OnViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{

View File

@ -3,15 +3,11 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls1="using:Pixeval.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="using:FluentIcons.WinUI"
xmlns:labs="using:CommunityToolkit.Labs.WinUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<UserControl.Resources>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
</UserControl.Resources>
<StackPanel
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
@ -32,11 +28,11 @@
<fluent:SymbolIcon
FontSize="{StaticResource SmallIconFontSize}"
Symbol="TextChangeCase"
Visibility="{x:Bind CaseSensitive, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind controls1:C.ToVisibility(CaseSensitive)}" />
<fluent:SymbolIcon
FontSize="{StaticResource SmallIconFontSize}"
Symbol="Code"
Visibility="{x:Bind IsRegularExpression, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind controls1:C.ToVisibility(IsRegularExpression)}" />
</StackPanel>
</DataTemplate>
</labs:TokenView.ItemTemplate>

View File

@ -4,7 +4,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Pixeval.Controls"
xmlns:controls1="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="using:FluentIcons.WinUI"
xmlns:flyoutContent="using:Pixeval.Controls.FlyoutContent"
@ -13,7 +12,6 @@
Loaded="WorkContainer_OnLoaded"
mc:Ignorable="d">
<UserControl.Resources>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<TeachingTip
x:Name="AddToBookmarkTeachingTip"
x:Uid="/WorkContainer/AddToBookmarkTeachingTip"
@ -61,7 +59,7 @@
<CommandBar
x:Name="CommandBar"
DefaultLabelPosition="Right"
Visibility="{x:Bind WorkView.ViewModel.IsSelecting, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
Visibility="{x:Bind controls:C.ToVisibility(WorkView.ViewModel.IsSelecting), Mode=OneWay}">
<AppBarButton
Click="CancelSelectionButton_OnClicked"
Icon="{fluent:SymbolIcon Symbol=SelectAllOff}"

View File

@ -2,7 +2,6 @@
x:Class="Pixeval.Controls.WorkView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:Pixeval.Controls.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:flyoutContent="using:Pixeval.Controls.FlyoutContent"
xmlns:local="using:Pixeval.Controls"
@ -10,7 +9,6 @@
Unloaded="WorkView_OnUnloaded"
mc:Ignorable="d">
<UserControl.Resources>
<converters:BoolToSelectionModeConverter x:Key="BoolToSelectionModeConverter" />
<DataTemplate x:Key="NovelItemDataTemplate" x:DataType="local:NovelItemViewModel">
<ItemContainer>
<local:NovelItem
@ -53,7 +51,7 @@
IsItemInvokedEnabled="True"
ItemInvoked="ItemsView_OnItemInvoked"
SelectionChanged="WorkView_OnSelectionChanged"
SelectionMode="{x:Bind ViewModel.IsSelecting, Converter={StaticResource BoolToSelectionModeConverter}, Mode=OneWay}">
SelectionMode="{x:Bind local:C.ToSelectionMode(ViewModel.IsSelecting), Mode=OneWay}">
<local:AdvancedItemsView.ItemTransitionProvider>
<LinedFlowLayoutItemCollectionTransitionProvider />
</local:AdvancedItemsView.ItemTransitionProvider>

View File

@ -3,7 +3,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Pixeval.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Pixeval.Pages.Capability"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -11,9 +10,6 @@
xmlns:pixeval="using:Pixeval"
Loaded="BookmarksPage_OnLoaded"
mc:Ignorable="d">
<controls:EnhancedPage.Resources>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
</controls:EnhancedPage.Resources>
<controls:WorkContainer x:Name="WorkContainer">
<controls:WorkContainer.CommandBarElements>
<controls:NotifyOnLoadedComboBox
@ -30,7 +26,7 @@
x:Name="PrivacyPolicyComboBox"
SelectionChanged="ComboBox_OnSelectionChanged"
Style="{StaticResource PrivacyPolicyComboBoxStyle}"
Visibility="{x:Bind _viewModel.IsMe, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind controls:C.ToVisibility(_viewModel.IsMe)}" />
<controls:EnumComboBox
x:Name="SimpleWorkTypeComboBox"
SelectedEnum="{x:Bind pixeval:App.AppViewModel.AppSettings.SimpleWorkType}"

View File

@ -4,13 +4,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Pixeval.Controls"
xmlns:controls1="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<controls:EnhancedPage.Resources>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
</controls:EnhancedPage.Resources>
<controls1:DockPanel>
<!-- 由于现在内容只有一个所以当内容隐藏的时候StackPanel也隐藏 -->
<StackPanel
@ -18,13 +14,13 @@
Margin="{StaticResource ComboBoxLeftIndent}"
controls1:DockPanel.Dock="Top"
Orientation="Horizontal"
Visibility="{x:Bind IsMe, Converter={StaticResource BoolToVisibilityConverter}}">
Visibility="{x:Bind controls:C.ToVisibility(IsMe)}">
<controls:EnumComboBox
x:Name="PrivacyPolicyComboBox"
VerticalAlignment="Center"
SelectionChanged="PrivacyPolicyComboBox_OnSelectionChanged"
Style="{StaticResource PrivacyPolicyComboBoxStyle}"
Visibility="{x:Bind IsMe, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind controls:C.ToVisibility(IsMe)}" />
</StackPanel>
<controls:IllustratorView x:Name="IllustratorView" />
</controls1:DockPanel>

View File

@ -4,8 +4,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Pixeval.Controls"
xmlns:controls1="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:converters1="using:Pixeval.Controls.Converters"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:flyoutContent="using:Pixeval.Controls.FlyoutContent"
@ -20,11 +18,6 @@
Unloaded="IllustrationViewerPage_OnUnloaded"
mc:Ignorable="d">
<controls:EnhancedWindowPage.Resources>
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters1:NumberToPercentageConverter x:Key="NumberToPercentageConverter" />
<converters1:NullableToVisibilityConverter x:Key="NullableToVisibilityConverter" />
<converters1:DisplayIndexConverter x:Key="DisplayIndexConverter" />
<Thickness x:Key="NormalMargin">0,48,0,0</Thickness>
<AcrylicBrush
x:Key="BottomCommandSectionBackground"
@ -68,7 +61,7 @@
controls1:DockPanel.Dock="Left"
ButtonClick="PrevButton_OnClicked"
ButtonRightTapped="PrevButton_OnRightTapped"
ButtonVisibility="{x:Bind _viewModel.PrevButtonText, Converter={StaticResource NullableToVisibilityConverter}, Mode=OneWay}"
ButtonVisibility="{x:Bind controls:C.IsNotNullToVisibility(_viewModel.PrevButtonText), Mode=OneWay}"
IsPrev="True"
ToolTip="{x:Bind _viewModel.PrevButtonText, Mode=OneWay}" />
<controls:PageButton
@ -76,7 +69,7 @@
controls1:DockPanel.Dock="Right"
ButtonClick="NextButton_OnClicked"
ButtonRightTapped="NextButton_OnRightTapped"
ButtonVisibility="{x:Bind _viewModel.NextButtonText, Converter={StaticResource NullableToVisibilityConverter}, Mode=OneWay}"
ButtonVisibility="{x:Bind controls:C.IsNotNullToVisibility(_viewModel.NextButtonText), Mode=OneWay}"
IsPrev="False"
ToolTip="{x:Bind _viewModel.NextButtonText, Mode=OneWay}" />
</controls1:DockPanel>
@ -145,7 +138,7 @@
NumberOfPages="{x:Bind _viewModel.PageCount, Mode=OneWay}"
PreviousButtonVisibility="Visible"
SelectedPageIndex="{x:Bind _viewModel.CurrentPageIndex, Mode=TwoWay}"
Visibility="{x:Bind _viewModel.CurrentIllustration.IsManga, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind controls:C.ToVisibility(_viewModel.CurrentIllustration.IsManga), Mode=OneWay}" />
<CommandBar DefaultLabelPosition="Collapsed" OverflowButtonVisibility="Collapsed">
<AppBarButton
Command="{x:Bind _viewModel.CurrentIllustration.BookmarkCommand, Mode=OneWay}"
@ -161,7 +154,7 @@
<AppBarButton
Command="{x:Bind _viewModel.CurrentIllustration.MangaSaveCommand, Mode=OneWay}"
CommandParameter="{x:Bind HWnd}"
Visibility="{x:Bind _viewModel.CurrentIllustration.IsManga, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind controls:C.ToVisibility(_viewModel.CurrentIllustration.IsManga), Mode=OneWay}" />
</CommandBar>
</controls1:DockPanel>
</Border>
@ -285,7 +278,7 @@
Command="{x:Bind _viewModel.InfoAndCommentsCommand}"
IsChecked="{x:Bind EntryViewerSplitView.IsPaneOpen, Mode=TwoWay}"
RightTapped="OpenPane_OnRightTapped" />
<AppBarButton Command="{x:Bind _viewModel.CurrentImage.PlayGifCommand, Mode=OneWay}" Visibility="{x:Bind _viewModel.CurrentIllustration.IsUgoira, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
<AppBarButton Command="{x:Bind _viewModel.CurrentImage.PlayGifCommand, Mode=OneWay}" Visibility="{x:Bind controls:C.ToVisibility(_viewModel.CurrentIllustration.IsUgoira), Mode=OneWay}" />
<AppBarSeparator />
<AppBarButton
Command="{x:Bind _viewModel.CurrentPage.CopyCommand, Mode=OneWay}"
@ -302,11 +295,11 @@
<AppBarButton
Command="{x:Bind _viewModel.CurrentIllustration.MangaSaveCommand, Mode=OneWay}"
CommandParameter="{x:Bind HWnd}"
Visibility="{x:Bind _viewModel.CurrentIllustration.IsManga, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind controls:C.ToVisibility(_viewModel.CurrentIllustration.IsManga), Mode=OneWay}" />
<AppBarButton
Command="{x:Bind _viewModel.CurrentIllustration.MangaSaveAsCommand, Mode=OneWay}"
CommandParameter="{x:Bind HWnd}"
Visibility="{x:Bind _viewModel.CurrentIllustration.IsManga, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind controls:C.ToVisibility(_viewModel.CurrentIllustration.IsManga), Mode=OneWay}" />
<AppBarSeparator />
<AppBarButton Command="{x:Bind _viewModel.CurrentImage.SetAsCommand, Mode=OneWay}">
<AppBarButton.Flyout>
@ -337,8 +330,8 @@
<TextBlock
controls1:DockPanel.Dock="Left"
Style="{StaticResource TextBlockStyle}"
Visibility="{x:Bind _viewModel.CurrentIllustration.IsManga, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<Run Text="{x:Bind _viewModel.CurrentPageIndex, Converter={StaticResource DisplayIndexConverter}, Mode=OneWay}" />
Visibility="{x:Bind controls:C.ToVisibility(_viewModel.CurrentIllustration.IsManga), Mode=OneWay}">
<Run Text="{x:Bind controls:C.PlusOneToString(_viewModel.CurrentPageIndex), Mode=OneWay}" />
<Run Text="/" />
<Run Text="{x:Bind _viewModel.PageCount, Mode=OneWay}" />
</TextBlock>
@ -359,8 +352,8 @@
Margin="-5,-3,0,0"
controls1:DockPanel.Dock="Left"
Style="{StaticResource TextBlockStyle}"
Text="{x:Bind _viewModel.CurrentImage.Scale, Converter={StaticResource NumberToPercentageConverter}, ConverterParameter=2, Mode=OneWay}"
ToolTipService.ToolTip="{x:Bind _viewModel.CurrentImage.Scale, Converter={StaticResource NumberToPercentageConverter}, ConverterParameter=2, Mode=OneWay}" />
Text="{x:Bind controls:C.ToPercentageString(_viewModel.CurrentImage.Scale, 2), Mode=OneWay}"
ToolTipService.ToolTip="{x:Bind controls:C.ToPercentageString(_viewModel.CurrentImage.Scale, 2), Mode=OneWay}" />
</controls1:DockPanel>
</controls1:TitleBar.Footer>
</controls1:TitleBar>
@ -391,7 +384,7 @@
<VisualStateGroup>
<VisualState x:Name="Normal">
<VisualState.StateTriggers>
<StateTrigger IsActive="{x:Bind _viewModel.IsFullScreen, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}" />
<StateTrigger IsActive="{x:Bind controls:C.Negation(_viewModel.IsFullScreen), Mode=OneWay}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="EntryViewerSplitView.Margin" Value="{StaticResource NormalMargin}" />

View File

@ -3,15 +3,9 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Pixeval.Controls"
xmlns:converters="using:Pixeval.Controls.Converters"
xmlns:converters1="using:CommunityToolkit.WinUI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<controls:EnhancedWindowPage.Resources>
<converters1:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters:BoolNegationToVisibilityConverter x:Key="BoolNegationToVisibilityConverter" />
</controls:EnhancedWindowPage.Resources>
<Grid>
<controls:ZoomableImage
HorizontalAlignment="Stretch"
@ -26,7 +20,7 @@
<controls:ZoomableImage.ContextFlyout>
<!-- PrimaryCommands 点击后不会自动隐藏Flyout -->
<CommandBarFlyout>
<AppBarButton Command="{x:Bind _viewModel.PlayGifCommand}" Visibility="{x:Bind _viewModel.IllustrationViewModel.IsUgoira, Converter={StaticResource BoolToVisibilityConverter}}" />
<AppBarButton Command="{x:Bind _viewModel.PlayGifCommand}" Visibility="{x:Bind controls:C.ToVisibility(_viewModel.IllustrationViewModel.IsUgoira)}" />
<AppBarButton
Command="{x:Bind _viewModel.OriginalIllustrationViewModel.BookmarkCommand}"
CommandParameter="{x:Bind _viewModel.DownloadParameter}"
@ -65,7 +59,7 @@
</CommandBarFlyout>
</controls:ZoomableImage.ContextFlyout>
</controls:ZoomableImage>
<Grid Visibility="{x:Bind _viewModel.LoadSuccessfully, Converter={StaticResource BoolNegationToVisibilityConverter}, Mode=OneWay}">
<Grid Visibility="{x:Bind controls:C.ToVisibilityNegation(_viewModel.LoadSuccessfully), Mode=OneWay}">
<Rectangle Fill="{ThemeResource PixevalAppAcrylicBrush}" />
<StackPanel
HorizontalAlignment="Center"

View File

@ -4,19 +4,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Pixeval.Controls"
xmlns:controls1="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:converters1="using:Pixeval.Controls.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="using:FluentIcons.WinUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windowing="using:Pixeval.Controls.Windowing"
mc:Ignorable="d">
<controls:EnhancedPage.Resources>
<converters1:BoolNegationToVisibilityConverter x:Key="BoolNegationToVisibilityConverter" />
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters1:ComplementaryDoubleConverter x:Key="ComplementaryDoubleConverter" />
<converters1:DoubleToBoolToVisibilityConverter x:Key="DoubleToBoolToVisibilityConverter" />
</controls:EnhancedPage.Resources>
<Grid>
<controls:StickyHeaderScrollView
x:Name="StickyHeaderScrollView"
@ -41,7 +33,7 @@
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalSpacing="50"
Opacity="{x:Bind StickyHeaderScrollView.ScrollRatio, Converter={StaticResource ComplementaryDoubleConverter}, Mode=OneWay}">
Opacity="{x:Bind controls:C.DoubleComplementary(StickyHeaderScrollView.ScrollRatio), Mode=OneWay}">
<PersonPicture
x:Name="ProfileImage"
Width="100"
@ -61,7 +53,7 @@
IsTextSelectionEnabled="True"
Style="{StaticResource TitleTextBlockStyle}"
Text="{x:Bind _viewModel.Name}" />
<controls:PixevalBadge Mode="Premium" Visibility="{x:Bind _viewModel.IsPremium, Converter={StaticResource BoolToVisibilityConverter}}" />
<controls:PixevalBadge Mode="Premium" Visibility="{x:Bind controls:C.ToVisibility(_viewModel.IsPremium)}" />
</StackPanel>
<TextBlock
x:Name="SubtitleBlock"
@ -87,7 +79,7 @@
controls1:DockPanel.Dock="Left"
Opacity="{x:Bind StickyHeaderScrollView.ScrollRatio, Mode=OneWay}"
OverflowButtonVisibility="Collapsed"
Visibility="{x:Bind StickyHeaderScrollView.ScrollRatio, Converter={StaticResource DoubleToBoolToVisibilityConverter}, Mode=OneWay}">
Visibility="{x:Bind controls:C.IsNotZeroDToVisibility(StickyHeaderScrollView.ScrollRatio), Mode=OneWay}">
<AppBarElementContainer Padding="20,0" VerticalContentAlignment="Center">
<PersonPicture
Width="35"
@ -106,7 +98,7 @@
HorizontalAlignment="Left"
Mode="Premium"
UseSmall="True"
Visibility="{x:Bind _viewModel.IsPremium, Converter={StaticResource BoolToVisibilityConverter}}" />
Visibility="{x:Bind controls:C.ToVisibility(_viewModel.IsPremium)}" />
</StackPanel>
</AppBarElementContainer>
<controls:AppButtonItem
@ -135,9 +127,9 @@
Symbol="BookOpen" />
</CommandBar>
<CommandBar DefaultLabelPosition="Right">
<AppBarButton Command="{x:Bind _viewModel.FollowCommand}" Visibility="{x:Bind _viewModel.IsFollowed, Converter={StaticResource BoolNegationToVisibilityConverter}, Mode=OneWay}" />
<AppBarButton Command="{x:Bind _viewModel.FollowPrivatelyCommand}" Visibility="{x:Bind _viewModel.IsFollowed, Converter={StaticResource BoolNegationToVisibilityConverter}, Mode=OneWay}" />
<AppBarButton Command="{x:Bind _viewModel.UnfollowCommand}" Visibility="{x:Bind _viewModel.IsFollowed, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
<AppBarButton Command="{x:Bind _viewModel.FollowCommand}" Visibility="{x:Bind controls:C.ToVisibilityNegation(_viewModel.IsFollowed), Mode=OneWay}" />
<AppBarButton Command="{x:Bind _viewModel.FollowPrivatelyCommand}" Visibility="{x:Bind controls:C.ToVisibilityNegation(_viewModel.IsFollowed), Mode=OneWay}" />
<AppBarButton Command="{x:Bind _viewModel.UnfollowCommand}" Visibility="{x:Bind controls:C.ToVisibility(_viewModel.IsFollowed), Mode=OneWay}" />
<AppBarSeparator />
<AppBarButton Command="{x:Bind _viewModel.GenerateLinkCommand}" CommandParameter="{x:Bind HWnd}" />
<AppBarButton Command="{x:Bind _viewModel.GenerateWebLinkCommand}" CommandParameter="{x:Bind HWnd}" />
@ -193,6 +185,7 @@
</controls:StickyHeaderScrollView.StickyContent>
</controls:StickyHeaderScrollView>
<controls1:TitleBar
x:Name="Bar"
Title="{x:Bind _viewModel.Name}"
VerticalAlignment="Top"
Window="{x:Bind windowing:WindowFactory.GetForkedWindows(HWnd)}">

View File

@ -5,7 +5,6 @@
xmlns:app="using:Pixeval.AppManagement"
xmlns:controls="using:Pixeval.Controls"
xmlns:controls2="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:Pixeval.Controls.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="using:FluentIcons.WinUI"
xmlns:local="using:Pixeval.Pages.Login"
@ -16,9 +15,6 @@
Loaded="LoginPage_OnLoaded"
Unloaded="LoginPage_OnUnloaded"
mc:Ignorable="d">
<controls:EnhancedWindowPage.Resources>
<converters:BoolNegationToVisibilityConverter x:Key="BoolNegationToVisibilityConverter" />
</controls:EnhancedWindowPage.Resources>
<controls2:DockPanel>
<controls2:TitleBar
Title="{x:Bind app:AppInfo.AppIdentifier}"
@ -204,7 +200,7 @@
Grid.Column="0"
Child="{x:Bind _viewModel.WebView, Mode=OneWay}"
CornerRadius="{ThemeResource ControlCornerRadius}"
Visibility="{x:Bind _viewModel.IsFinished, Converter={StaticResource BoolNegationToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind controls:C.ToVisibilityNegation(_viewModel.IsFinished), Mode=OneWay}" />
</Grid>
</controls2:DockPanel>
</controls2:DockPanel>

View File

@ -3,9 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Pixeval.Controls"
xmlns:controls2="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:converters1="using:Pixeval.Controls.Converters"
xmlns:controls1="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="using:FluentIcons.WinUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -15,14 +13,13 @@
Loaded="MainPage_OnLoaded"
mc:Ignorable="d">
<controls:EnhancedWindowPage.Resources>
<converters1:NullableToVisibilityConverter x:Key="NullableToVisibilityConverter" />
<DataTemplate x:Key="CommonSuggestionModelTemplate" x:DataType="pages:SuggestionModel">
<controls2:DockPanel Padding="0,10" HorizontalSpacing="10">
<controls1:DockPanel Padding="0,10" HorizontalSpacing="10">
<ContentPresenter
x:Name="IconContentPresenter"
HorizontalAlignment="Left"
VerticalAlignment="Center"
controls2:DockPanel.Dock="Left"
controls1:DockPanel.Dock="Left"
Content="{x:Bind FontIcon}" />
<StackPanel VerticalAlignment="Center" Spacing="1">
<TextBlock
@ -38,9 +35,9 @@
Text="{x:Bind TranslatedName}"
TextTrimming="CharacterEllipsis"
TextWrapping="WrapWholeWords"
Visibility="{x:Bind TranslatedName, Converter={StaticResource NullableToVisibilityConverter}}" />
Visibility="{x:Bind controls:C.IsNotNullToVisibility(TranslatedName)}" />
</StackPanel>
</controls2:DockPanel>
</controls1:DockPanel>
</DataTemplate>
<pages:SuggestionModelDataTemplateSelector
x:Key="SuggestionModelDataTemplateSelector"
@ -50,31 +47,31 @@
NovelHeader="/MainPage/NovelHeaderSuggestionTextBlock"
SettingEntryHeader="/MainPage/SettingsEntryHeaderSuggestionTextBlock" />
</controls:EnhancedWindowPage.Resources>
<controls2:DockPanel>
<controls2:TitleBar
<controls1:DockPanel>
<controls1:TitleBar
Title="{x:Bind pixeval:AppInfo.AppIdentifier}"
VerticalAlignment="Top"
controls2:DockPanel.Dock="Top"
controls1:DockPanel.Dock="Top"
DisplayMode="Tall"
IsPaneButtonVisible="True"
PaneButtonClick="TitleBar_OnPaneButtonClicked"
Window="{x:Bind windowing:WindowFactory.GetForkedWindows(HWnd)}">
<controls2:TitleBar.Icon>
<controls1:TitleBar.Icon>
<ImageIcon Source="ms-appx:///Assets/Images/logo.svg" />
</controls2:TitleBar.Icon>
<controls2:TitleBar.Footer>
</controls1:TitleBar.Icon>
<controls1:TitleBar.Footer>
<PersonPicture
Grid.Column="0"
MaxHeight="35"
ProfilePicture="{x:Bind _viewModel.AvatarSource, Mode=OneWay}"
Tapped="SelfAvatar_OnTapped"
ToolTipService.ToolTip="{x:Bind _viewModel.UserName}" />
</controls2:TitleBar.Footer>
<controls2:TitleBar.Content>
<controls2:DockPanel>
</controls1:TitleBar.Footer>
<controls1:TitleBar.Content>
<controls1:DockPanel>
<CommandBar
Margin="0,-4"
controls2:DockPanel.Dock="Right"
controls1:DockPanel.Dock="Right"
DefaultLabelPosition="Collapsed"
OverflowButtonVisibility="Collapsed">
<AppBarButton
@ -108,9 +105,9 @@
</TransitionCollection>
</AutoSuggestBox.ItemContainerTransitions>
</AutoSuggestBox>
</controls2:DockPanel>
</controls2:TitleBar.Content>
</controls2:TitleBar>
</controls1:DockPanel>
</controls1:TitleBar.Content>
</controls1:TitleBar>
<NavigationView
x:Name="NavigationView"
IsBackButtonVisible="Collapsed"
@ -192,5 +189,5 @@
</NavigationView.FooterMenuItems>
<Frame x:Name="MainPageRootFrame" Navigated="MainPageRootFrame_OnNavigated" />
</NavigationView>
</controls2:DockPanel>
</controls1:DockPanel>
</controls:EnhancedWindowPage>

View File

@ -5,8 +5,6 @@
xmlns:appManagement="using:Pixeval.AppManagement"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:controls1="using:Pixeval.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:converters1="using:Pixeval.Controls.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="using:FluentIcons.WinUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -24,9 +22,6 @@
<Setter Property="Margin" Value="1,28,0,4" />
</Style.Setters>
</Style>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
<converters1:NullableToVisibilityConverter x:Key="NullableToVisibilityConverter" />
</controls1:EnhancedWindowPage.Resources>
<controls:DockPanel VerticalSpacing="10">
<TextBlock
@ -91,17 +86,17 @@
Width="35"
Height="35"
IsActive="True"
IsIndeterminate="{x:Bind ViewModel.DownloadingUpdate, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}"
Visibility="{x:Bind ViewModel.CheckingUpdate, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"
IsIndeterminate="{x:Bind controls1:C.Negation(ViewModel.DownloadingUpdate), Mode=OneWay}"
Visibility="{x:Bind controls1:C.ToVisibility(ViewModel.CheckingUpdate), Mode=OneWay}"
Value="{x:Bind ViewModel.DownloadingUpdateProgress, Mode=OneWay}" />
<TextBlock
VerticalAlignment="Center"
Text="{x:Bind ViewModel.UpdateMessage, Mode=OneWay}"
Visibility="{x:Bind ViewModel.UpdateMessage, Converter={StaticResource NullableToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind controls1:C.IsNotNullToVisibility(ViewModel.UpdateMessage), Mode=OneWay}" />
<Button
x:Uid="/SettingsPage/CheckForUpdatesButton"
Click="CheckForUpdateButton_OnClicked"
IsEnabled="{x:Bind ViewModel.CheckingUpdate, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}" />
IsEnabled="{x:Bind controls1:C.Negation(ViewModel.CheckingUpdate), Mode=OneWay}" />
</StackPanel>
<controls:SettingsExpander.Items>
<controls:SettingsCard
@ -142,7 +137,7 @@
x:Uid="/SettingsPage/ReleaseNotesHyperlinkButton"
Click="ReleaseNotesHyperlink_OnClicked"
Tag="Newest"
Visibility="{x:Bind ViewModel.NewestVersion, Converter={StaticResource NullableToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind controls1:C.IsNotNullToVisibility(ViewModel.NewestVersion), Mode=OneWay}" />
</InfoBar.ActionButton>
</InfoBar>

View File

@ -4,8 +4,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Pixeval.Controls"
xmlns:controls1="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:converters1="using:Pixeval.Controls.Converters"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:flyoutContent="using:Pixeval.Controls.FlyoutContent"
@ -20,13 +18,6 @@
Unloaded="NovelViewerPage_OnUnloaded"
mc:Ignorable="d">
<controls:EnhancedWindowPage.Resources>
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters1:NullableToVisibilityConverter x:Key="NullableToVisibilityConverter" />
<converters1:DisplayIndexConverter x:Key="DisplayIndexConverter" />
<converters1:UIntToBrushConverter x:Key="UIntToBrushConverter" />
<converters1:FontWeightConverter x:Key="FontWeightConverter" />
<converters1:StringToFontFamilyConverter x:Key="StringToFontFamilyConverter" />
<Thickness x:Key="NormalMargin">0,48,0,0</Thickness>
<AcrylicBrush
x:Key="BottomCommandSectionBackground"
@ -76,22 +67,22 @@
</ScrollView>
</controls1:DockPanel>
</SplitView.Pane>
<Grid Background="{x:Bind _viewModel.NovelBackgroundEntry.Value, Converter={StaticResource UIntToBrushConverter}, Mode=OneWay}">
<Grid Background="{x:Bind controls:C.ToSolidColorBrush(_viewModel.NovelBackgroundEntry.Value), Mode=OneWay}">
<controls:DocumentViewer
x:Name="DocumentViewer"
ActualThemeChanged="{x:Bind _viewModel.OnFrameworkElementOnActualThemeChanged}"
CurrentPage="{x:Bind _viewModel.CurrentPageIndex, Mode=TwoWay}"
FontFamily="{x:Bind _viewModel.NovelFontFamilyEntry.Value, Converter={StaticResource StringToFontFamilyConverter}, Mode=OneWay}"
FontFamily="{x:Bind controls:C.ToFontFamily(_viewModel.NovelFontFamilyEntry.Value), Mode=OneWay}"
FontSize="{x:Bind _viewModel.NovelFontSizeEntry.Value, Mode=OneWay}"
FontWeight="{x:Bind _viewModel.NovelFontWeightEntry.Value, Converter={StaticResource FontWeightConverter}, Mode=OneWay}"
Foreground="{x:Bind _viewModel.NovelFontColorEntry.Value, Converter={StaticResource UIntToBrushConverter}, Mode=OneWay}"
FontWeight="{x:Bind controls:C.ToFontWeight(_viewModel.NovelFontWeightEntry.Value), Mode=OneWay}"
Foreground="{x:Bind controls:C.ToSolidColorBrush(_viewModel.NovelFontColorEntry.Value), Mode=OneWay}"
LineHeight="{x:Bind _viewModel.NovelLineHeightEntry.Value, Mode=OneWay}"
NovelItem="{x:Bind _viewModel.CurrentNovel, Mode=OneWay}"
NovelMaxWidth="{x:Bind _viewModel.NovelMaxWidthEntry.Value, Mode=OneWay}"
PageCount="{x:Bind _viewModel.PageCount, Mode=TwoWay}"
Tapped="DocumentViewer_OnTapped" />
<Grid Visibility="{x:Bind DocumentViewer.IsLoading, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<Grid Visibility="{x:Bind controls:C.ToVisibility(DocumentViewer.IsLoading), Mode=OneWay}">
<Rectangle Fill="{ThemeResource PixevalAppAcrylicBrush}" />
<StackPanel
HorizontalAlignment="Center"
@ -112,7 +103,7 @@
controls1:DockPanel.Dock="Left"
ButtonClick="PrevButton_OnClicked"
ButtonRightTapped="PrevButton_OnRightTapped"
ButtonVisibility="{x:Bind _viewModel.PrevButtonText, Converter={StaticResource NullableToVisibilityConverter}, Mode=OneWay}"
ButtonVisibility="{x:Bind controls:C.IsNotNullToVisibility(_viewModel.PrevButtonText), Mode=OneWay}"
IsPrev="True"
ToolTip="{x:Bind _viewModel.PrevButtonText, Mode=OneWay}" />
<controls:PageButton
@ -120,7 +111,7 @@
controls1:DockPanel.Dock="Right"
ButtonClick="NextButton_OnClicked"
ButtonRightTapped="NextButton_OnRightTapped"
ButtonVisibility="{x:Bind _viewModel.NextButtonText, Converter={StaticResource NullableToVisibilityConverter}, Mode=OneWay}"
ButtonVisibility="{x:Bind controls:C.IsNotNullToVisibility(_viewModel.NextButtonText), Mode=OneWay}"
IsPrev="False"
ToolTip="{x:Bind _viewModel.NextButtonText, Mode=OneWay}" />
</controls1:DockPanel>
@ -189,7 +180,7 @@
NumberOfPages="{x:Bind DocumentViewer.PageCount, Mode=OneWay}"
PreviousButtonVisibility="Visible"
SelectedPageIndex="{x:Bind DocumentViewer.CurrentPage, Mode=TwoWay}"
Visibility="{x:Bind DocumentViewer.IsMultiPage, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" />
Visibility="{x:Bind controls:C.ToVisibility(DocumentViewer.IsMultiPage), Mode=OneWay}" />
<CommandBar
HorizontalAlignment="Center"
DefaultLabelPosition="Collapsed"
@ -364,8 +355,8 @@
<TextBlock
controls1:DockPanel.Dock="Left"
Style="{StaticResource TextBlockStyle}"
Visibility="{x:Bind DocumentViewer.IsMultiPage, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<Run Text="{x:Bind DocumentViewer.CurrentPage, Converter={StaticResource DisplayIndexConverter}, Mode=OneWay}" />
Visibility="{x:Bind controls:C.ToVisibility(DocumentViewer.IsMultiPage), Mode=OneWay}">
<Run Text="{x:Bind controls:C.PlusOneToString(DocumentViewer.CurrentPage), Mode=OneWay}" />
<Run Text="/" />
<Run Text="{x:Bind DocumentViewer.PageCount, Mode=OneWay}" />
</TextBlock>
@ -407,7 +398,7 @@
<VisualStateGroup>
<VisualState x:Name="Normal">
<VisualState.StateTriggers>
<StateTrigger IsActive="{x:Bind _viewModel.IsFullScreen, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}" />
<StateTrigger IsActive="{x:Bind controls:C.Negation(_viewModel.IsFullScreen), Mode=OneWay}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="EntryViewerSplitView.Margin" Value="{StaticResource NormalMargin}" />

View File

@ -35,7 +35,7 @@
x:Uid="/TagsEntry/GoToPageItem"
Click="GoToPageItem_OnClicked"
Icon="{fluent:SymbolIcon Symbol=OpenFolder}"
IsEnabled="{x:Bind IsNotZero(ViewModel.Id), Mode=OneWay}" />
IsEnabled="{x:Bind controls1:C.IsNotZeroL(ViewModel.Id), Mode=OneWay}" />
<AppBarButton
x:Uid="/TagsEntry/DeleteItem"
Click="DeleteItem_OnClicked"

View File

@ -83,6 +83,4 @@ public sealed partial class TagsEntry
}
}
}
private bool IsNotZero(long id) => id is not 0;
}

View File

@ -1,22 +1,20 @@
<pixevalControls:EnhancedPage
<controls2:EnhancedPage
x:Class="Pixeval.Pages.WorkInfoPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:converters1="using:Pixeval.Controls.Converters"
xmlns:controls2="using:Pixeval.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:fluent="using:FluentIcons.WinUI"
xmlns:labs="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock"
xmlns:local="using:Pixeval.Pages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="using:Pixeval.CoreApi.Model"
xmlns:pixevalControls="using:Pixeval.Controls"
xmlns:pixeval="using:Pixeval.AppManagement"
Background="{ThemeResource PixevalPanelBackgroundThemeBrush}"
Unloaded="WorkInfoPage_OnUnloaded"
mc:Ignorable="d">
<pixevalControls:EnhancedPage.Resources>
<converters:StringFormatConverter x:Key="StringFormatConverter" />
<converters1:NullableToVisibilityConverter x:Key="NullableToVisibilityConverter" />
<controls2:EnhancedPage.Resources>
<Style
x:Key="InfoPageSectionHeaderTextBlockStyle"
BasedOn="{StaticResource CaptionTextBlockStyle}"
@ -33,7 +31,7 @@
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="MaxHeight" Value="200" />
</Style>
</pixevalControls:EnhancedPage.Resources>
</controls2:EnhancedPage.Resources>
<ScrollViewer
HorizontalScrollBarVisibility="Disabled"
HorizontalScrollMode="Disabled"
@ -90,13 +88,13 @@
<TextBlock
x:Uid="/WorkInfoPage/IllustrationDimensionTextBlock"
Style="{StaticResource InfoPageSectionHeaderTextBlockStyle}"
Visibility="{x:Bind _viewModel.IllustrationDimensionText, Converter={StaticResource NullableToVisibilityConverter}}" />
Visibility="{x:Bind controls2:C.IsNotNullToVisibility(_viewModel.IllustrationDimensionText)}" />
<TextBlock
Style="{StaticResource InfoPageSectionContentTextBlockStyle}"
Text="{x:Bind _viewModel.IllustrationDimensionText}"
Visibility="{x:Bind _viewModel.IllustrationDimensionText, Converter={StaticResource NullableToVisibilityConverter}}" />
Visibility="{x:Bind controls2:C.IsNotNullToVisibility(_viewModel.IllustrationDimensionText)}" />
<TextBlock x:Uid="/WorkInfoPage/WorkUploadDateTextBlock" Style="{StaticResource InfoPageSectionHeaderTextBlockStyle}" />
<TextBlock Style="{StaticResource InfoPageSectionContentTextBlockStyle}" Text="{x:Bind _viewModel.Entry.CreateDate, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:yyyy-M-d HH:mm:ss}'}" />
<TextBlock Style="{StaticResource InfoPageSectionContentTextBlockStyle}" Text="{x:Bind controls2:C.CultureDateTimeOffsetFormatter(_viewModel.Entry.CreateDate, pixeval:AppSettings.CurrentCulture)}" />
<TextBlock x:Uid="/WorkInfoPage/WorkTagListTextBlock" Style="{StaticResource InfoPageSectionHeaderTextBlockStyle}" />
<ItemsRepeater Margin="{StaticResource StackLayoutEntryPadding}" ItemsSource="{x:Bind _viewModel.Entry.Tags}">
<ItemsRepeater.Layout>
@ -124,4 +122,4 @@
</ItemsRepeater>
</StackPanel>
</ScrollViewer>
</pixevalControls:EnhancedPage>
</controls2:EnhancedPage>

View File

@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Pixeval.CoreApi.Model;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Metadata.Profiles.Exif;