This commit is contained in:
Lightczx
2023-09-18 10:02:58 +08:00
parent 68d8baa70c
commit 261794927c
14 changed files with 46 additions and 26 deletions

View File

@@ -11,8 +11,8 @@ public sealed partial class FrameworkElementHelper
{
private static void OnSquareLengthChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e)
{
Microsoft.UI.Xaml.Controls.Control control = (Microsoft.UI.Xaml.Controls.Control)dp;
control.Width = (double)e.NewValue;
control.Height = (double)e.NewValue;
FrameworkElement element = (FrameworkElement)dp;
element.Width = (double)e.NewValue;
element.Height = (double)e.NewValue;
}
}

View File

@@ -0,0 +1,12 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace Snap.Hutao.Control.Helper;
[DependencyProperty("IsTextSelectionEnabled", typeof(bool), false, IsAttached = true, AttachedType = typeof(InfoBar))]
public sealed partial class InfoBarHelper
{
}

View File

@@ -1,4 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shch="using:Snap.Hutao.Control.Helper">
<FontFamily x:Key="MiSans">ms-appx:///Resource/Font/MiSans-Regular.ttf#MiSans</FontFamily>
<FontFamily x:Key="CascadiaMonoAndMiSans">ms-appx:///Resource/Font/CascadiaMono.ttf#Cascadia Mono, ms-appx:///Resource/Font/MiSans-Regular.ttf#MiSans</FontFamily>
@@ -99,6 +102,7 @@
</Style>
<!-- TODO: When will DefaultInfoBarStyle added -->
<Style TargetType="InfoBar">
<Setter Property="shch:InfoBarHelper.IsTextSelectionEnabled" Value="False"/>
<Setter Property="FontFamily" Value="{StaticResource MiSans}"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="CloseButtonStyle" Value="{StaticResource InfoBarCloseButtonStyle}"/>
@@ -181,6 +185,7 @@
Foreground="{ThemeResource InfoBarTitleForeground}"
InfoBarPanel.HorizontalOrientationMargin="{StaticResource InfoBarTitleHorizontalOrientationMargin}"
InfoBarPanel.VerticalOrientationMargin="{StaticResource InfoBarTitleVerticalOrientationMargin}"
IsTextSelectionEnabled="{TemplateBinding shch:InfoBarHelper.IsTextSelectionEnabled}"
Text="{TemplateBinding Title}"
TextWrapping="WrapWholeWords"/>
<TextBlock
@@ -190,6 +195,7 @@
Foreground="{ThemeResource InfoBarMessageForeground}"
InfoBarPanel.HorizontalOrientationMargin="{StaticResource InfoBarMessageHorizontalOrientationMargin}"
InfoBarPanel.VerticalOrientationMargin="{StaticResource InfoBarMessageVerticalOrientationMargin}"
IsTextSelectionEnabled="{TemplateBinding shch:InfoBarHelper.IsTextSelectionEnabled}"
Text="{TemplateBinding Message}"
TextWrapping="WrapWholeWords"/>
<ContentPresenter

View File

@@ -7,7 +7,7 @@ namespace Snap.Hutao.Model.Metadata;
internal static class MonsterRelationship
{
public static MonsterRelationshipId Normalize(MonsterRelationshipId id)
public static MonsterRelationshipId Normalize(in MonsterRelationshipId id)
{
return (uint)id switch
{

View File

@@ -122,7 +122,7 @@
<None Remove="View\Control\SkillPivot.xaml" />
<None Remove="View\Control\StatisticsCard.xaml" />
<None Remove="View\Control\StatisticsSegmented.xaml" />
<None Remove="View\Control\Webview2Viewer.xaml" />
<None Remove="View\Control\WebViewer.xaml" />
<None Remove="View\Dialog\AchievementArchiveCreateDialog.xaml" />
<None Remove="View\Dialog\AchievementImportDialog.xaml" />
<None Remove="View\Dialog\CultivateProjectDialog.xaml" />
@@ -328,7 +328,7 @@
</ItemGroup>
<ItemGroup>
<Page Update="View\Control\Webview2Viewer.xaml">
<Page Update="View\Control\WebViewer.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>

View File

@@ -5,7 +5,7 @@ using Snap.Hutao.ViewModel.User;
namespace Snap.Hutao.View.Control;
internal interface IWebview2ViewerSource
internal interface IWebViewerSource
{
string GetSource(UserAndUid userAndUid);
}

View File

@@ -7,7 +7,7 @@ using Snap.Hutao.ViewModel.User;
namespace Snap.Hutao.View.Control;
[DependencyProperty("Source", typeof(string))]
internal sealed partial class StaticWebview2ViewerSource : DependencyObject, IWebview2ViewerSource
internal sealed partial class StaticWebview2ViewerSource : DependencyObject, IWebViewerSource
{
public string GetSource(UserAndUid userAndUid)
{

View File

@@ -1,9 +1,8 @@
<UserControl
x:Class="Snap.Hutao.View.Control.Webview2Viewer"
x:Class="Snap.Hutao.View.Control.WebViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Snap.Hutao.View.Control"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<UserControl.Transitions>

View File

@@ -13,8 +13,8 @@ using Snap.Hutao.Web.Bridge;
namespace Snap.Hutao.View.Control;
[DependencyProperty("SourceProvider", typeof(IWebview2ViewerSource))]
internal partial class Webview2Viewer : UserControl, IRecipient<UserChangedMessage>
[DependencyProperty("SourceProvider", typeof(IWebViewerSource))]
internal partial class WebViewer : UserControl, IRecipient<UserChangedMessage>
{
private readonly IServiceProvider serviceProvider;
private readonly RoutedEventHandler loadEventHandler;
@@ -23,7 +23,7 @@ internal partial class Webview2Viewer : UserControl, IRecipient<UserChangedMessa
private MiHoYoJSInterface? jsInterface;
private bool isFirstNavigate = true;
public Webview2Viewer()
public WebViewer()
{
InitializeComponent();
serviceProvider = Ioc.Default;

View File

@@ -12,6 +12,7 @@
xmlns:shc="using:Snap.Hutao.Control"
xmlns:shca="using:Snap.Hutao.Control.Animation"
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
xmlns:shch="using:Snap.Hutao.Control.Helper"
xmlns:shci="using:Snap.Hutao.Control.Image"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shvco="using:Snap.Hutao.View.Control"
@@ -167,13 +168,15 @@
<TextBlock Margin="16,0" Text="{Binding UserOptions.UserName}"/>
<ItemsControl
Margin="16,16,12,0"
Margin="16,8,12,0"
ItemsSource="{Binding HutaoAnnouncements}"
Visibility="{Binding HutaoAnnouncements.Count, Converter={StaticResource Int32ToVisibilityConverter}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<InfoBar
Title="{Binding Title}"
Margin="0,8,0,0"
shch:InfoBarHelper.IsTextSelectionEnabled="True"
CloseButtonCommand="{Binding DismissCommand}"
CloseButtonCommandParameter="{Binding}"
IsOpen="True"

View File

@@ -52,7 +52,7 @@
<Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}"/>
</Style>
</Flyout.FlyoutPresenterStyle>
<shvc:Webview2Viewer SourceProvider="{Binding VerifyUrlSource, Mode=OneWay}"/>
<shvc:WebViewer SourceProvider="{Binding VerifyUrlSource, Mode=OneWay}"/>
</Flyout>
</FlyoutBase.AttachedFlyout>
</Button>

View File

@@ -32,11 +32,11 @@
</Style>
</Flyout.FlyoutPresenterStyle>
<Grid>
<shvc:Webview2Viewer>
<shvc:Webview2Viewer.SourceProvider>
<shvc:WebViewer>
<shvc:WebViewer.SourceProvider>
<shvc:StaticWebview2ViewerSource Source="http://webstatic.mihoyo.com/ys/event/e20200923adopt_calculator/index.html?bbs_presentation_style=fullscreen&amp;bbs_auth_required=true&amp;utm_source=bbs&amp;utm_medium=mys&amp;utm_campaign=GameRecord"/>
</shvc:Webview2Viewer.SourceProvider>
</shvc:Webview2Viewer>
</shvc:WebViewer.SourceProvider>
</shvc:WebViewer>
</Grid>
</Flyout>
</FlyoutBase.AttachedFlyout>
@@ -57,11 +57,11 @@
</Style>
</Flyout.FlyoutPresenterStyle>
<Grid>
<shvc:Webview2Viewer>
<shvc:Webview2Viewer.SourceProvider>
<shvc:WebViewer>
<shvc:WebViewer.SourceProvider>
<shvc:StaticWebview2ViewerSource Source="https://webstatic.mihoyo.com/app/community-game-records/index.html"/>
</shvc:Webview2Viewer.SourceProvider>
</shvc:Webview2Viewer>
</shvc:WebViewer.SourceProvider>
</shvc:WebViewer>
</Grid>
</Flyout>
</FlyoutBase.AttachedFlyout>

View File

@@ -42,7 +42,7 @@ internal sealed partial class DailyNoteViewModel : Abstraction.ViewModel
public RuntimeOptions RuntimeOptions { get => runtimeOptions; }
public IWebview2ViewerSource VerifyUrlSource { get => new DailyNoteWebview2ViewerSource(); }
public IWebViewerSource VerifyUrlSource { get => new DailyNoteWebViewerSource(); }
/// <summary>
/// 用户与角色集合

View File

@@ -7,7 +7,7 @@ using Snap.Hutao.Web.Request.QueryString;
namespace Snap.Hutao.ViewModel.DailyNote;
internal sealed class DailyNoteWebview2ViewerSource : IWebview2ViewerSource
internal sealed class DailyNoteWebViewerSource : IWebViewerSource
{
public string GetSource(UserAndUid userAndUid)
{