This commit is contained in:
Hakoyu 2023-12-14 23:41:15 +08:00
parent f75f2970ad
commit 1e7b3751ac
9 changed files with 50 additions and 13 deletions

View File

@ -14,4 +14,5 @@
<c:NotEqualsConverter x:Key="NotEqualsConverter" /> <c:NotEqualsConverter x:Key="NotEqualsConverter" />
<c:NullToFalseConverter x:Key="NullToFalseConverter" /> <c:NullToFalseConverter x:Key="NullToFalseConverter" />
<c:AllTrueToCollapsedConverter x:Key="AllTrueToCollapsedConverter" /> <c:AllTrueToCollapsedConverter x:Key="AllTrueToCollapsedConverter" />
<c:BoolInverter x:Key="BoolInverter" />
</ResourceDictionary> </ResourceDictionary>

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace VPet.ModMaker.Converters;
public class BoolInverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is not bool b)
throw new ArgumentException("Value type not bool", nameof(value));
return !b;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

View File

@ -34,7 +34,7 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
/// <summary> /// <summary>
/// 不显示本体宠物 /// 不显示本体宠物
/// </summary> /// </summary>
public ObservableValue<bool> DontShowMainPet { get; } = new(true); public ObservableValue<bool> ShowMainPet { get; } = new(true);
#region ModInfo #region ModInfo
/// <summary> /// <summary>
@ -138,7 +138,7 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
DescriptionId.Value = $"{n}_{nameof(DescriptionId)}"; DescriptionId.Value = $"{n}_{nameof(DescriptionId)}";
}; };
Pets.CollectionChanged += Pets_CollectionChanged; Pets.CollectionChanged += Pets_CollectionChanged;
DontShowMainPet.ValueChanged += ShowMainPet_ValueChanged; ShowMainPet.ValueChanged += ShowMainPet_ValueChanged;
} }
private void ShowMainPet_ValueChanged( private void ShowMainPet_ValueChanged(
@ -151,10 +151,10 @@ public class ModInfoModel : I18nModel<I18nModInfoModel>
private void Pets_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) private void Pets_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{ {
if (DontShowMainPet.Value) if (ShowMainPet.Value)
PetDisplayedCount.Value = Pets.Count - Pets.Count(m => m.FromMain.Value);
else
PetDisplayedCount.Value = Pets.Count; PetDisplayedCount.Value = Pets.Count;
else
PetDisplayedCount.Value = Pets.Count - Pets.Count(m => m.FromMain.Value);
} }
public ModInfoModel(ModLoader loader) public ModInfoModel(ModLoader loader)

View File

@ -100,6 +100,7 @@
</Compile> </Compile>
<Compile Include="Converters\AllTrueToCollapsedConverter.cs" /> <Compile Include="Converters\AllTrueToCollapsedConverter.cs" />
<Compile Include="Converters\AnyFalseToVisibleConverter.cs" /> <Compile Include="Converters\AnyFalseToVisibleConverter.cs" />
<Compile Include="Converters\BoolInverter.cs" />
<Compile Include="Models\I18nModelBase.cs" /> <Compile Include="Models\I18nModelBase.cs" />
<Compile Include="Usings.cs" /> <Compile Include="Usings.cs" />
<Compile Include="Converters\BrushToMediaColorConverter.cs" /> <Compile Include="Converters\BrushToMediaColorConverter.cs" />

View File

@ -48,7 +48,10 @@
<Setter Property="Visibility"> <Setter Property="Visibility">
<Setter.Value> <Setter.Value>
<MultiBinding Converter="{StaticResource AllTrueToCollapsedConverter}"> <MultiBinding Converter="{StaticResource AllTrueToCollapsedConverter}">
<Binding Path="DataContext.ModInfo.DontShowMainPet.Value" RelativeSource="{RelativeSource AncestorType=Page}" /> <Binding
Converter="{StaticResource BoolInverter}"
Path="DataContext.ModInfo.ShowMainPet.Value"
RelativeSource="{RelativeSource AncestorType=Page}" />
<Binding Path="FromMain.Value" /> <Binding Path="FromMain.Value" />
</MultiBinding> </MultiBinding>
</Setter.Value> </Setter.Value>

View File

@ -48,7 +48,10 @@
<Setter Property="Visibility"> <Setter Property="Visibility">
<Setter.Value> <Setter.Value>
<MultiBinding Converter="{StaticResource AllTrueToCollapsedConverter}"> <MultiBinding Converter="{StaticResource AllTrueToCollapsedConverter}">
<Binding Path="DataContext.ModInfo.DontShowMainPet.Value" RelativeSource="{RelativeSource AncestorType=Page}" /> <Binding
Converter="{StaticResource BoolInverter}"
Path="DataContext.ModInfo.ShowMainPet.Value"
RelativeSource="{RelativeSource AncestorType=Page}" />
<Binding Path="FromMain.Value" /> <Binding Path="FromMain.Value" />
</MultiBinding> </MultiBinding>
</Setter.Value> </Setter.Value>

View File

@ -29,8 +29,8 @@
Text="{Binding Search.Value, UpdateSourceTrigger=PropertyChanged}" /> Text="{Binding Search.Value, UpdateSourceTrigger=PropertyChanged}" />
<pu:Switch <pu:Switch
Grid.Column="1" Grid.Column="1"
Content="{ll:Str 显示本体宠物}" Content="{ll:Str 显示本体宠物}"
IsChecked="{Binding ModInfo.DontShowMainPet.Value}" /> IsChecked="{Binding ModInfo.ShowMainPet.Value}" />
</Grid> </Grid>
<DataGrid <DataGrid
Grid.Row="1" Grid.Row="1"
@ -53,7 +53,10 @@
<Setter Property="Visibility"> <Setter Property="Visibility">
<Setter.Value> <Setter.Value>
<MultiBinding Converter="{StaticResource AllTrueToCollapsedConverter}"> <MultiBinding Converter="{StaticResource AllTrueToCollapsedConverter}">
<Binding Path="DataContext.ModInfo.DontShowMainPet.Value" RelativeSource="{RelativeSource AncestorType=Page}" /> <Binding
Converter="{StaticResource BoolInverter}"
Path="DataContext.ModInfo.ShowMainPet.Value"
RelativeSource="{RelativeSource AncestorType=Page}" />
<Binding Path="FromMain.Value" /> <Binding Path="FromMain.Value" />
</MultiBinding> </MultiBinding>
</Setter.Value> </Setter.Value>

View File

@ -52,7 +52,10 @@
<Setter Property="Visibility"> <Setter Property="Visibility">
<Setter.Value> <Setter.Value>
<MultiBinding Converter="{StaticResource AllTrueToCollapsedConverter}"> <MultiBinding Converter="{StaticResource AllTrueToCollapsedConverter}">
<Binding Path="DataContext.ModInfo.DontShowMainPet.Value" RelativeSource="{RelativeSource AncestorType=Page}" /> <Binding
Converter="{StaticResource BoolInverter}"
Path="DataContext.ModInfo.ShowMainPet.Value"
RelativeSource="{RelativeSource AncestorType=Page}" />
<Binding Path="FromMain.Value" /> <Binding Path="FromMain.Value" />
</MultiBinding> </MultiBinding>
</Setter.Value> </Setter.Value>

View File

@ -92,8 +92,7 @@
Grid.Row="1" Grid.Row="1"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
d:Text="{ll:Str 路径}" d:Text="{ll:Str 路径}"
Text="{Binding SourcePath}" Text="{Binding SourcePath}" />
TextWrapping="Wrap" />
</Grid> </Grid>
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>