mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
restrict combobox size
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Windows.Foundation;
|
||||
|
||||
namespace Snap.Hutao.Control;
|
||||
|
||||
[DependencyProperty("IsWidthRestricted", typeof(bool), true)]
|
||||
[DependencyProperty("IsHeightRestricted", typeof(bool), true)]
|
||||
internal sealed partial class SizeRestrictedContentControl : ContentControl
|
||||
{
|
||||
private double minContentWidth;
|
||||
private double minContentHeight;
|
||||
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
if (Content is FrameworkElement element)
|
||||
{
|
||||
element.Measure(availableSize);
|
||||
Size contentDesiredSize = element.DesiredSize;
|
||||
|
||||
if (IsWidthRestricted)
|
||||
{
|
||||
if (contentDesiredSize.Width > minContentWidth)
|
||||
{
|
||||
minContentWidth = contentDesiredSize.Width;
|
||||
}
|
||||
|
||||
element.MinWidth = minContentWidth;
|
||||
}
|
||||
|
||||
if (IsHeightRestricted)
|
||||
{
|
||||
if (contentDesiredSize.Height > minContentHeight)
|
||||
{
|
||||
minContentHeight = contentDesiredSize.Height;
|
||||
}
|
||||
|
||||
element.MinHeight = minContentHeight;
|
||||
}
|
||||
}
|
||||
|
||||
return base.MeasureOverride(availableSize);
|
||||
}
|
||||
}
|
||||
@@ -14,32 +14,32 @@ internal static class IntrinsicFrozen
|
||||
/// <summary>
|
||||
/// 所属地区
|
||||
/// </summary>
|
||||
public static readonly FrozenSet<string> AssociationTypes = Enum.GetValues<AssociationType>().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType<string>().ToFrozenSet();
|
||||
public static FrozenSet<string> AssociationTypes { get; } = Enum.GetValues<AssociationType>().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType<string>().ToFrozenSet();
|
||||
|
||||
/// <summary>
|
||||
/// 武器类型
|
||||
/// </summary>
|
||||
public static readonly FrozenSet<string> WeaponTypes = Enum.GetValues<WeaponType>().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType<string>().ToFrozenSet();
|
||||
public static FrozenSet<string> WeaponTypes { get; } = Enum.GetValues<WeaponType>().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType<string>().ToFrozenSet();
|
||||
|
||||
/// <summary>
|
||||
/// 物品类型
|
||||
/// </summary>
|
||||
public static readonly FrozenSet<string> ItemQualities = Enum.GetValues<QualityType>().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType<string>().ToFrozenSet();
|
||||
public static FrozenSet<string> ItemQualities { get; } = Enum.GetValues<QualityType>().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType<string>().ToFrozenSet();
|
||||
|
||||
/// <summary>
|
||||
/// 身材类型
|
||||
/// </summary>
|
||||
public static readonly FrozenSet<string> BodyTypes = Enum.GetValues<BodyType>().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType<string>().ToFrozenSet();
|
||||
public static FrozenSet<string> BodyTypes { get; } = Enum.GetValues<BodyType>().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType<string>().ToFrozenSet();
|
||||
|
||||
/// <summary>
|
||||
/// 战斗属性
|
||||
/// </summary>
|
||||
public static readonly FrozenSet<string> FightProperties = Enum.GetValues<FightProperty>().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType<string>().ToFrozenSet();
|
||||
public static FrozenSet<string> FightProperties { get; } = Enum.GetValues<FightProperty>().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType<string>().ToFrozenSet();
|
||||
|
||||
/// <summary>
|
||||
/// 元素名称
|
||||
/// </summary>
|
||||
public static readonly FrozenSet<string> ElementNames = FrozenSet.ToFrozenSet(
|
||||
public static FrozenSet<string> ElementNames { get; } = FrozenSet.ToFrozenSet(
|
||||
[
|
||||
SH.ModelIntrinsicElementNameFire,
|
||||
SH.ModelIntrinsicElementNameWater,
|
||||
@@ -50,7 +50,7 @@ internal static class IntrinsicFrozen
|
||||
SH.ModelIntrinsicElementNameRock,
|
||||
]);
|
||||
|
||||
public static readonly FrozenSet<string> MaterialTypeDescriptions = FrozenSet.ToFrozenSet(
|
||||
public static FrozenSet<string> MaterialTypeDescriptions { get; } = FrozenSet.ToFrozenSet(
|
||||
[
|
||||
SH.ModelMetadataMaterialCharacterAndWeaponEnhancementMaterial,
|
||||
SH.ModelMetadataMaterialCharacterEXPMaterial,
|
||||
|
||||
@@ -2012,6 +2012,9 @@
|
||||
<data name="ViewPageLaunchGameAppearanceAspectRatioHeader" xml:space="preserve">
|
||||
<value>分辨率</value>
|
||||
</data>
|
||||
<data name="ViewPageLaunchGameAppearanceAspectRatioPlaceHolder" xml:space="preserve">
|
||||
<value>快捷设置分辨率</value>
|
||||
</data>
|
||||
<data name="ViewPageLaunchGameAppearanceBorderlessDescription" xml:space="preserve">
|
||||
<value>将窗口创建为弹出窗口,不带框架</value>
|
||||
</data>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:shc="using:Snap.Hutao.Control"
|
||||
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
|
||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||
xmlns:shvg="using:Snap.Hutao.ViewModel.Game"
|
||||
@@ -60,14 +61,16 @@
|
||||
Content="{StaticResource FontIconContentSetting}"
|
||||
FontFamily="{StaticResource SymbolThemeFontFamily}"
|
||||
ToolTipService.ToolTip="{shcm:ResourceString Name=ViewPageHomeLaunchGameSettingAction}"/>
|
||||
<ComboBox
|
||||
Grid.Row="2"
|
||||
Grid.ColumnSpan="3"
|
||||
VerticalAlignment="Bottom"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding GameAccounts}"
|
||||
PlaceholderText="{shcm:ResourceString Name=ViewCardLaunchGameSelectAccountPlaceholder}"
|
||||
SelectedItem="{Binding SelectedGameAccount, Mode=TwoWay}"/>
|
||||
<shc:SizeRestrictedContentControl>
|
||||
<ComboBox
|
||||
Grid.Row="2"
|
||||
Grid.ColumnSpan="3"
|
||||
VerticalAlignment="Bottom"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding GameAccounts}"
|
||||
PlaceholderText="{shcm:ResourceString Name=ViewCardLaunchGameSelectAccountPlaceholder}"
|
||||
SelectedItem="{Binding SelectedGameAccount, Mode=TwoWay}"/>
|
||||
</shc:SizeRestrictedContentControl>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Button>
|
||||
</Button>
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:cwc="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:shc="using:Snap.Hutao.Control"
|
||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||
xmlns:shmm="using:Snap.Hutao.Model.Metadata"
|
||||
mc:Ignorable="d">
|
||||
@@ -22,11 +23,13 @@
|
||||
<StackPanel>
|
||||
<StackPanel Margin="0,0,0,0" VerticalAlignment="Top">
|
||||
<cwc:SettingsCard Header="{shcm:ResourceString Name=ViewControlBaseValueSliderLevel}">
|
||||
<ComboBox
|
||||
DisplayMemberPath="Level"
|
||||
ItemsSource="{x:Bind Source, Mode=OneWay}"
|
||||
SelectedItem="{x:Bind SelectedItem, Mode=TwoWay}"
|
||||
Style="{StaticResource SettingsContentComboBoxStyle}"/>
|
||||
<shc:SizeRestrictedContentControl>
|
||||
<ComboBox
|
||||
DisplayMemberPath="Level"
|
||||
ItemsSource="{x:Bind Source, Mode=OneWay}"
|
||||
SelectedItem="{x:Bind SelectedItem, Mode=TwoWay}"
|
||||
Style="{StaticResource SettingsContentComboBoxStyle}"/>
|
||||
</shc:SizeRestrictedContentControl>
|
||||
</cwc:SettingsCard>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
@@ -247,13 +247,14 @@
|
||||
</CommandBar.Content>
|
||||
|
||||
<AppBarElementContainer>
|
||||
<ComboBox
|
||||
Height="36"
|
||||
MinWidth="120"
|
||||
Margin="2,6,3,6"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Archives, Mode=OneWay}"
|
||||
SelectedItem="{Binding SelectedArchive, Mode=TwoWay}"/>
|
||||
<shc:SizeRestrictedContentControl>
|
||||
<ComboBox
|
||||
Height="36"
|
||||
Margin="2,6,3,6"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Archives, Mode=OneWay}"
|
||||
SelectedItem="{Binding SelectedArchive, Mode=TwoWay}"/>
|
||||
</shc:SizeRestrictedContentControl>
|
||||
</AppBarElementContainer>
|
||||
<AppBarButton
|
||||
Command="{Binding AddArchiveCommand}"
|
||||
|
||||
@@ -248,13 +248,15 @@
|
||||
<Pivot.RightHeader>
|
||||
<CommandBar DefaultLabelPosition="Right">
|
||||
<AppBarElementContainer>
|
||||
<ComboBox
|
||||
Height="36"
|
||||
MinWidth="160"
|
||||
Margin="6,6,6,6"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Projects}"
|
||||
SelectedItem="{Binding SelectedProject, Mode=TwoWay}"/>
|
||||
<shc:SizeRestrictedContentControl>
|
||||
<ComboBox
|
||||
Height="36"
|
||||
Margin="6,6,6,6"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Projects}"
|
||||
SelectedItem="{Binding SelectedProject, Mode=TwoWay}"/>
|
||||
</shc:SizeRestrictedContentControl>
|
||||
|
||||
</AppBarElementContainer>
|
||||
<AppBarButton
|
||||
Command="{Binding AddProjectCommand}"
|
||||
|
||||
@@ -231,13 +231,14 @@
|
||||
IsHitTestVisible="False"/>
|
||||
<Pivot>
|
||||
<Pivot.LeftHeader>
|
||||
<ComboBox
|
||||
Height="36"
|
||||
MinWidth="120"
|
||||
Margin="16,6,0,6"
|
||||
DisplayMemberPath="Uid"
|
||||
ItemsSource="{Binding Archives}"
|
||||
SelectedItem="{Binding SelectedArchive, Mode=TwoWay}"/>
|
||||
<shc:SizeRestrictedContentControl>
|
||||
<ComboBox
|
||||
Height="36"
|
||||
Margin="16,6,0,6"
|
||||
DisplayMemberPath="Uid"
|
||||
ItemsSource="{Binding Archives}"
|
||||
SelectedItem="{Binding SelectedArchive, Mode=TwoWay}"/>
|
||||
</shc:SizeRestrictedContentControl>
|
||||
</Pivot.LeftHeader>
|
||||
<Pivot.RightHeader>
|
||||
<CommandBar DefaultLabelPosition="Right">
|
||||
|
||||
@@ -171,13 +171,14 @@
|
||||
</cwc:SettingsCard.Description>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<shvc:Elevation Margin="0,0,36,0" Visibility="{Binding HutaoOptions.IsElevated, Converter={StaticResource BoolToVisibilityRevertConverter}}"/>
|
||||
<shccs:ComboBox2
|
||||
MinWidth="320"
|
||||
DisplayMemberPath="DisplayName"
|
||||
EnableMemberPath="IsNotCompatOnly"
|
||||
ItemsSource="{Binding KnownSchemes}"
|
||||
SelectedItem="{Binding SelectedScheme, Mode=TwoWay}"
|
||||
Style="{StaticResource DefaultComboBoxStyle}"/>
|
||||
<shc:SizeRestrictedContentControl>
|
||||
<shccs:ComboBox2
|
||||
DisplayMemberPath="DisplayName"
|
||||
EnableMemberPath="IsNotCompatOnly"
|
||||
ItemsSource="{Binding KnownSchemes}"
|
||||
SelectedItem="{Binding SelectedScheme, Mode=TwoWay}"
|
||||
Style="{StaticResource DefaultComboBoxStyle}"/>
|
||||
</shc:SizeRestrictedContentControl>
|
||||
</StackPanel>
|
||||
</cwc:SettingsCard>
|
||||
|
||||
@@ -217,11 +218,13 @@
|
||||
<ToggleSwitch Width="120" IsOn="{Binding Options.IsBorderless, Mode=TwoWay}"/>
|
||||
</cwc:SettingsCard>
|
||||
<cwc:SettingsCard Description="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceAspectRatioDescription}" Header="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceAspectRatioHeader}">
|
||||
<ComboBox
|
||||
Width="156"
|
||||
Margin="0,0,136,0"
|
||||
ItemsSource="{Binding Options.AspectRatios}"
|
||||
SelectedItem="{Binding Options.SelectedAspectRatio, Mode=TwoWay}"/>
|
||||
<shc:SizeRestrictedContentControl>
|
||||
<ComboBox
|
||||
Margin="0,0,136,0"
|
||||
ItemsSource="{Binding Options.AspectRatios}"
|
||||
PlaceholderText="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceAspectRatioPlaceHolder}"
|
||||
SelectedItem="{Binding Options.SelectedAspectRatio, Mode=TwoWay}"/>
|
||||
</shc:SizeRestrictedContentControl>
|
||||
</cwc:SettingsCard>
|
||||
<cwc:SettingsCard Description="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceScreenWidthDescription}" Header="-screen-width">
|
||||
<StackPanel Orientation="Horizontal" Spacing="16">
|
||||
@@ -247,13 +250,14 @@
|
||||
</cwc:SettingsCard>
|
||||
<cwc:SettingsCard Description="{shcm:ResourceString Name=ViewPageLaunchGameMonitorsDescription}" Header="-monitor">
|
||||
<StackPanel Orientation="Horizontal" Spacing="16">
|
||||
<ComboBox
|
||||
Width="156"
|
||||
VerticalAlignment="Center"
|
||||
DisplayMemberPath="Name"
|
||||
IsEnabled="{Binding Options.IsMonitorEnabled}"
|
||||
ItemsSource="{Binding Options.Monitors}"
|
||||
SelectedItem="{Binding Options.Monitor, Mode=TwoWay}"/>
|
||||
<shc:SizeRestrictedContentControl>
|
||||
<ComboBox
|
||||
VerticalAlignment="Center"
|
||||
DisplayMemberPath="Name"
|
||||
IsEnabled="{Binding Options.IsMonitorEnabled}"
|
||||
ItemsSource="{Binding Options.Monitors}"
|
||||
SelectedItem="{Binding Options.Monitor, Mode=TwoWay}"/>
|
||||
</shc:SizeRestrictedContentControl>
|
||||
<ToggleSwitch Width="120" IsOn="{Binding Options.IsMonitorEnabled, Mode=TwoWay}"/>
|
||||
</StackPanel>
|
||||
</cwc:SettingsCard>
|
||||
|
||||
@@ -192,19 +192,23 @@
|
||||
Description="{shcm:ResourceString Name=ViewPageSettingApperanceLanguageDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageSettingApperanceLanguageHeader}"
|
||||
HeaderIcon="{shcm:FontIcon Glyph=}">
|
||||
<ComboBox
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Options.Cultures}"
|
||||
SelectedItem="{Binding SelectedCulture, Mode=TwoWay}"/>
|
||||
<shc:SizeRestrictedContentControl>
|
||||
<ComboBox
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Options.Cultures}"
|
||||
SelectedItem="{Binding SelectedCulture, Mode=TwoWay}"/>
|
||||
</shc:SizeRestrictedContentControl>
|
||||
</cwc:SettingsCard>
|
||||
<cwc:SettingsCard
|
||||
Description="{shcm:ResourceString Name=ViewPageSettingBackdropMaterialDescription}"
|
||||
Header="{shcm:ResourceString Name=ViewPageSettingBackdropMaterialHeader}"
|
||||
HeaderIcon="{shcm:FontIcon Glyph=}">
|
||||
<ComboBox
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Options.BackdropTypes}"
|
||||
SelectedItem="{Binding SelectedBackdropType, Mode=TwoWay}"/>
|
||||
<shc:SizeRestrictedContentControl>
|
||||
<ComboBox
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Options.BackdropTypes}"
|
||||
SelectedItem="{Binding SelectedBackdropType, Mode=TwoWay}"/>
|
||||
</shc:SizeRestrictedContentControl>
|
||||
</cwc:SettingsCard>
|
||||
|
||||
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" Text="{shcm:ResourceString Name=ViewPageSettingKeyShortcutHeader}"/>
|
||||
@@ -240,13 +244,14 @@
|
||||
Content="Alt"
|
||||
IsChecked="{Binding HotKeyOptions.MouseClickRepeatForeverKeyCombination.ModifierHasAlt, Mode=TwoWay}"/>
|
||||
</cwc:UniformGrid>
|
||||
<ComboBox
|
||||
MinWidth="120"
|
||||
VerticalAlignment="Center"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding HotKeyOptions.VirtualKeys}"
|
||||
SelectedItem="{Binding HotKeyOptions.MouseClickRepeatForeverKeyCombination.KeyNameValue, Mode=TwoWay}"
|
||||
Style="{StaticResource DefaultComboBoxStyle}"/>
|
||||
<shc:SizeRestrictedContentControl>
|
||||
<ComboBox
|
||||
MinWidth="120"
|
||||
VerticalAlignment="Center"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding HotKeyOptions.VirtualKeys}"
|
||||
SelectedItem="{Binding HotKeyOptions.MouseClickRepeatForeverKeyCombination.KeyNameValue, Mode=TwoWay}"/>
|
||||
</shc:SizeRestrictedContentControl>
|
||||
<ToggleSwitch
|
||||
MinWidth="120"
|
||||
VerticalAlignment="Center"
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
PlaceholderText="Please input link"
|
||||
Text="{Binding Announcement.Link, Mode=TwoWay}"/>
|
||||
<TextBox
|
||||
Header="Link"
|
||||
Header="Version Threshold"
|
||||
PlaceholderText="Max present version(leave empty to present in any version)"
|
||||
Text="{Binding Announcement.MaxPresentVersion, Mode=TwoWay}"/>
|
||||
<TextBox
|
||||
@@ -124,14 +124,15 @@
|
||||
Header="Content"
|
||||
PlaceholderText="Please input content"
|
||||
Text="{Binding Announcement.Content, Mode=TwoWay}"/>
|
||||
<ComboBox
|
||||
Header="Severity"
|
||||
ItemsSource="{cwh:EnumValues Type=InfoBarSeverity}"
|
||||
SelectedItem="{Binding Announcement.Severity, Mode=TwoWay}"/>
|
||||
<shc:SizeRestrictedContentControl>
|
||||
<ComboBox
|
||||
Header="Severity"
|
||||
ItemsSource="{cwh:EnumValues Type=InfoBarSeverity}"
|
||||
SelectedItem="{Binding Announcement.Severity, Mode=TwoWay}"/>
|
||||
</shc:SizeRestrictedContentControl>
|
||||
<Button Command="{Binding UploadAnnouncementCommand}" Content="Upload"/>
|
||||
</StackPanel>
|
||||
</Expander>
|
||||
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</shc:ScopedPage>
|
||||
|
||||
Reference in New Issue
Block a user