mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix panel selector global group name
This commit is contained in:
@@ -5,12 +5,13 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||||
|
Loaded="OnRootControlLoaded"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<SplitButton
|
<SplitButton
|
||||||
|
Name="RootSplitButton"
|
||||||
Padding="0,6"
|
Padding="0,6"
|
||||||
Click="SplitButtonClick"
|
Click="SplitButtonClick">
|
||||||
Loaded="SplitButtonLoaded">
|
|
||||||
<SplitButton.Content>
|
<SplitButton.Content>
|
||||||
<FontIcon Name="IconPresenter" Glyph=""/>
|
<FontIcon Name="IconPresenter" Glyph=""/>
|
||||||
</SplitButton.Content>
|
</SplitButton.Content>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace Snap.Hutao.Control.Panel;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class PanelSelector : UserControl
|
public sealed partial class PanelSelector : UserControl
|
||||||
{
|
{
|
||||||
private static readonly DependencyProperty CurrentProperty = Property<PanelSelector>.Depend(nameof(Current), "List");
|
private static readonly DependencyProperty CurrentProperty = Property<PanelSelector>.Depend(nameof(Current), "List", OnCurrentChanged);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造一个新的面板选择器
|
/// 构造一个新的面板选择器
|
||||||
@@ -30,51 +30,60 @@ public sealed partial class PanelSelector : UserControl
|
|||||||
set => SetValue(CurrentProperty, value);
|
set => SetValue(CurrentProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SplitButtonLoaded(object sender, RoutedEventArgs e)
|
private static void OnCurrentChanged(PanelSelector sender, string current)
|
||||||
{
|
{
|
||||||
MenuFlyout menuFlyout = (MenuFlyout)((SplitButton)sender).Flyout;
|
MenuFlyout menuFlyout = (MenuFlyout)sender.RootSplitButton.Flyout;
|
||||||
((RadioMenuFlyoutItem)menuFlyout.Items[0]).IsChecked = true;
|
RadioMenuFlyoutItem targetItem = menuFlyout.Items
|
||||||
|
.Cast<RadioMenuFlyoutItem>()
|
||||||
|
.Single(i => (string)i.Tag == current);
|
||||||
|
targetItem.IsChecked = true;
|
||||||
|
sender.IconPresenter.Glyph = ((FontIcon)targetItem.Icon).Glyph;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnCurrentChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||||
|
{
|
||||||
|
OnCurrentChanged((PanelSelector)obj, (string)args.NewValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRootControlLoaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// because the GroupName shares in global
|
||||||
|
// we have to impl a control scoped GroupName.
|
||||||
|
PanelSelector selector = (PanelSelector)sender;
|
||||||
|
MenuFlyout menuFlyout = (MenuFlyout)selector.RootSplitButton.Flyout;
|
||||||
|
int hash = GetHashCode();
|
||||||
|
foreach (RadioMenuFlyoutItem item in menuFlyout.Items.Cast<RadioMenuFlyoutItem>())
|
||||||
|
{
|
||||||
|
item.GroupName = $"PanelSelector{hash}Group";
|
||||||
|
}
|
||||||
|
|
||||||
|
OnCurrentChanged(selector, Current);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SplitButtonClick(SplitButton sender, SplitButtonClickEventArgs args)
|
private void SplitButtonClick(SplitButton sender, SplitButtonClickEventArgs args)
|
||||||
{
|
{
|
||||||
MenuFlyout menuFlyout = (MenuFlyout)sender.Flyout;
|
MenuFlyout menuFlyout = (MenuFlyout)sender.Flyout;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < menuFlyout.Items.Count; i++)
|
for (; i < menuFlyout.Items.Count; i++)
|
||||||
{
|
{
|
||||||
RadioMenuFlyoutItem current = (RadioMenuFlyoutItem)menuFlyout.Items[i];
|
if ((string)menuFlyout.Items[i].Tag == Current)
|
||||||
if (current.IsChecked)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
++i;
|
||||||
|
i %= menuFlyout.Items.Count; // move the count index to 0
|
||||||
if (i > menuFlyout.Items.Count)
|
|
||||||
{
|
|
||||||
i = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == menuFlyout.Items.Count)
|
|
||||||
{
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
RadioMenuFlyoutItem item = (RadioMenuFlyoutItem)menuFlyout.Items[i];
|
RadioMenuFlyoutItem item = (RadioMenuFlyoutItem)menuFlyout.Items[i];
|
||||||
item.IsChecked = true;
|
item.IsChecked = true;
|
||||||
UpdateState(item);
|
Current = (string)item.Tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RadioMenuFlyoutItemClick(object sender, RoutedEventArgs e)
|
private void RadioMenuFlyoutItemClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
RadioMenuFlyoutItem item = (RadioMenuFlyoutItem)sender;
|
RadioMenuFlyoutItem item = (RadioMenuFlyoutItem)sender;
|
||||||
UpdateState(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateState(RadioMenuFlyoutItem item)
|
|
||||||
{
|
|
||||||
Current = (string)item.Tag;
|
Current = (string)item.Tag;
|
||||||
IconPresenter.Glyph = ((FontIcon)item.Icon).Glyph;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,4 +27,9 @@ internal static class SettingKeys
|
|||||||
/// 静态资源合约V1
|
/// 静态资源合约V1
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string StaticResourceV1Contract = "StaticResourceV1Contract";
|
public const string StaticResourceV1Contract = "StaticResourceV1Contract";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 静态资源合约V2 成就图标与物品图标
|
||||||
|
/// </summary>
|
||||||
|
public const string StaticResourceV2Contract = "StaticResourceV2Contract";
|
||||||
}
|
}
|
||||||
@@ -33,9 +33,11 @@ public sealed partial class MainWindow : Window, IExtendedWindowSource, IRecipie
|
|||||||
|
|
||||||
Ioc.Default.GetRequiredService<IMessenger>().Register(this);
|
Ioc.Default.GetRequiredService<IMessenger>().Register(this);
|
||||||
|
|
||||||
// Query the StaticResourceV1Contract.
|
// Query the StaticResourceV1Contract & StaticResourceV2Contract.
|
||||||
// If not complete we should present the welcome view.
|
// If not complete we should present the welcome view.
|
||||||
ContentSwitchPresenter.Value = !LocalSetting.Get(SettingKeys.StaticResourceV1Contract, false);
|
ContentSwitchPresenter.Value =
|
||||||
|
!LocalSetting.Get(SettingKeys.StaticResourceV1Contract, false)
|
||||||
|
|| (!LocalSetting.Get(SettingKeys.StaticResourceV2Contract, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -92,7 +92,6 @@
|
|||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
<Border Background="{StaticResource CardBackgroundFillColorDefaultBrush}" CornerRadius="{StaticResource CompatCornerRadius}">
|
<Border Background="{StaticResource CardBackgroundFillColorDefaultBrush}" CornerRadius="{StaticResource CompatCornerRadius}">
|
||||||
@@ -124,7 +123,10 @@
|
|||||||
FontSize="24"
|
FontSize="24"
|
||||||
Text="{Binding TotalCount}"
|
Text="{Binding TotalCount}"
|
||||||
Visibility="{Binding ElementName=DetailExpander, Path=IsExpanded, Converter={StaticResource BoolToVisibilityRevertConverter}}"/>
|
Visibility="{Binding ElementName=DetailExpander, Path=IsExpanded, Converter={StaticResource BoolToVisibilityRevertConverter}}"/>
|
||||||
<shcp:PanelSelector x:Name="ItemsPanelSelector" Margin="6,0,6,0"/>
|
<shcp:PanelSelector
|
||||||
|
x:Name="ItemsPanelSelector"
|
||||||
|
Margin="6,0"
|
||||||
|
Current="Grid"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Expander.Header>
|
</Expander.Header>
|
||||||
|
|||||||
@@ -51,18 +51,27 @@ internal class WelcomeViewModel : ObservableObject
|
|||||||
|
|
||||||
private async Task OpenUIAsync()
|
private async Task OpenUIAsync()
|
||||||
{
|
{
|
||||||
List<DownloadSummary> downloadSummaries = new()
|
List<DownloadSummary> downloadSummaries = new();
|
||||||
|
|
||||||
|
if (!LocalSetting.Get(SettingKeys.StaticResourceV1Contract, false))
|
||||||
{
|
{
|
||||||
new(serviceProvider, "基础图标", "Bg"),
|
downloadSummaries.Add(new(serviceProvider, "基础图标", "Bg"));
|
||||||
new(serviceProvider, "角色图标", "AvatarIcon"),
|
downloadSummaries.Add(new(serviceProvider, "角色图标", "AvatarIcon"));
|
||||||
new(serviceProvider, "角色立绘图标", "GachaAvatarIcon"),
|
downloadSummaries.Add(new(serviceProvider, "角色立绘图标", "GachaAvatarIcon"));
|
||||||
new(serviceProvider, "角色立绘图像", "GachaAvatarImg"),
|
downloadSummaries.Add(new(serviceProvider, "角色立绘图像", "GachaAvatarImg"));
|
||||||
new(serviceProvider, "武器图标", "EquipIcon"),
|
downloadSummaries.Add(new(serviceProvider, "武器图标", "EquipIcon"));
|
||||||
new(serviceProvider, "武器立绘图标", "GachaEquipIcon"),
|
downloadSummaries.Add(new(serviceProvider, "武器立绘图标", "GachaEquipIcon"));
|
||||||
new(serviceProvider, "名片图像", "NameCardPic"),
|
downloadSummaries.Add(new(serviceProvider, "名片图像", "NameCardPic"));
|
||||||
new(serviceProvider, "天赋图标", "Skill"),
|
downloadSummaries.Add(new(serviceProvider, "天赋图标", "Skill"));
|
||||||
new(serviceProvider, "命之座图标", "Talent"),
|
downloadSummaries.Add(new(serviceProvider, "命之座图标", "Talent"));
|
||||||
};
|
}
|
||||||
|
|
||||||
|
if (!LocalSetting.Get(SettingKeys.StaticResourceV2Contract, false))
|
||||||
|
{
|
||||||
|
downloadSummaries.Add(new(serviceProvider, "成就图标", "AchievementIcon"));
|
||||||
|
downloadSummaries.Add(new(serviceProvider, "物品图标", "ItemIcon"));
|
||||||
|
downloadSummaries.Add(new(serviceProvider, "元素图标", "IconElement"));
|
||||||
|
}
|
||||||
|
|
||||||
DownloadSummaries = new(downloadSummaries);
|
DownloadSummaries = new(downloadSummaries);
|
||||||
|
|
||||||
@@ -70,8 +79,9 @@ internal class WelcomeViewModel : ObservableObject
|
|||||||
|
|
||||||
serviceProvider.GetRequiredService<IMessenger>().Send(new Message.WelcomeStateCompleteMessage());
|
serviceProvider.GetRequiredService<IMessenger>().Send(new Message.WelcomeStateCompleteMessage());
|
||||||
|
|
||||||
// Complete the StaticResourceV1Contract
|
// Complete StaticResourceContracts
|
||||||
LocalSetting.Set(SettingKeys.StaticResourceV1Contract, true);
|
LocalSetting.Set(SettingKeys.StaticResourceV1Contract, true);
|
||||||
|
LocalSetting.Set(SettingKeys.StaticResourceV2Contract, true);
|
||||||
|
|
||||||
new ToastContentBuilder()
|
new ToastContentBuilder()
|
||||||
.AddText("下载完成")
|
.AddText("下载完成")
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ public interface IJsResult
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 转换到Json字符串表示
|
/// 转换到Json字符串表示
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="options">序列化参数</param>
|
|
||||||
/// <returns>JSON字符串</returns>
|
/// <returns>JSON字符串</returns>
|
||||||
string ToString(JsonSerializerOptions options);
|
string ToString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class JsResult<TData> : IJsResult
|
|||||||
public TData Data { get; set; } = default!;
|
public TData Data { get; set; } = default!;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
string IJsResult.ToString(JsonSerializerOptions options)
|
string IJsResult.ToString()
|
||||||
{
|
{
|
||||||
return JsonSerializer.Serialize(this);
|
return JsonSerializer.Serialize(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Snap.Hutao.Web.Response;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 已知的返回代码
|
/// 已知的返回代码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum KnownReturnCode : int
|
public enum KnownReturnCode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 无效请求
|
/// 无效请求
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class Response<TData> : Response, IJsResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
string IJsResult.ToString(JsonSerializerOptions options)
|
string IJsResult.ToString()
|
||||||
{
|
{
|
||||||
return JsonSerializer.Serialize(this);
|
return JsonSerializer.Serialize(this);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user