Skip to content

Commit 729cef7

Browse files
authored
从小幻影视迁移功能 (#1157)
1 parent 0934a05 commit 729cef7

23 files changed

+239
-92
lines changed

src/.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 如果要从更高级别的目录继承 .editorconfig 设置,请删除以下行
1+
# 如果要从更高级别的目录继承 .editorconfig 设置,请删除以下行
22
root = true
33

44
# c# 文件
@@ -484,6 +484,9 @@ dotnet_diagnostic.CA1030.severity = none
484484
# IL2067: Target parameter argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The parameter of method does not have matching annotations.
485485
dotnet_diagnostic.IL2067.severity = none
486486

487+
# VSTHRD002: Avoid problematic synchronous waits
488+
dotnet_diagnostic.VSTHRD002.severity = none
489+
487490
[*.{cs,vb}]
488491
dotnet_style_qualification_for_field = false:silent
489492
dotnet_style_qualification_for_property = false:silent

src/Desktop/BiliCopilot.UI/BiliCopilot.UI.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@
225225
<None Remove="Controls\Settings\PlayerControlSettingControl.xaml" />
226226
<None Remove="Controls\Settings\PromptTemplateSettingControl.xaml" />
227227
<None Remove="Controls\Settings\ScreenshotSettingControl.xaml" />
228+
<None Remove="Controls\Settings\ScrollSettingControl.xaml" />
228229
<None Remove="Controls\Settings\SearchRecommendSettingSection.xaml" />
229230
<None Remove="Controls\Settings\ThemeSettingControl.xaml" />
230231
<None Remove="Controls\Users\FansBody.xaml" />
@@ -1159,6 +1160,9 @@
11591160
<None Update="Assets\basic-mpv.conf">
11601161
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
11611162
</None>
1163+
<Page Update="Controls\Settings\ScrollSettingControl.xaml">
1164+
<Generator>MSBuild:Compile</Generator>
1165+
</Page>
11621166
<Page Update="Controls\Danmaku\DanmakuSendDialog.xaml">
11631167
<Generator>MSBuild:Compile</Generator>
11641168
</Page>

src/Desktop/BiliCopilot.UI/BiliCopilot.UI.csproj.user

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
<None Update="App.xaml">
1919
<SubType>Designer</SubType>
2020
</None>
21+
<Page Update="Controls\Settings\ScrollSettingControl.xaml">
22+
<SubType>Designer</SubType>
23+
</Page>
2124
<Page Update="Controls\Danmaku\DanmakuSendDialog.xaml">
2225
<SubType>Designer</SubType>
2326
</Page>

src/Desktop/BiliCopilot.UI/Controls/Core/OverlayTransportControls.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@
532532
RequestedTheme="Dark"
533533
Style="{StaticResource CaptionTextBlockStyle}"
534534
Text="{x:Bind GetTimeText(ViewModel.Player.Position), Mode=OneWay}"
535-
Visibility="{x:Bind ViewModel.IsProgressChanging, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}" />
535+
Visibility="{x:Bind ViewModel.IsPreviewProgressChanging, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}" />
536536
<TextBlock
537537
HorizontalAlignment="Right"
538538
VerticalAlignment="Center"
@@ -541,7 +541,7 @@
541541
RequestedTheme="Dark"
542542
Style="{StaticResource CaptionTextBlockStyle}"
543543
Text="{x:Bind GetTimeText(ViewModel.PreviewPosition), Mode=OneWay}"
544-
Visibility="{x:Bind ViewModel.IsProgressChanging, Mode=OneWay}" />
544+
Visibility="{x:Bind ViewModel.IsPreviewProgressChanging, Mode=OneWay}" />
545545
<local:CacheBar
546546
Grid.Column="1"
547547
Height="4"

src/Desktop/BiliCopilot.UI/Controls/Core/PlayerInteractivePanel.xaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<local:PlayerControlBase
33
x:Class="BiliCopilot.UI.Controls.Core.PlayerInteractivePanel"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
@@ -64,5 +64,21 @@
6464
HorizontalAlignment="Stretch"
6565
VerticalAlignment="Stretch"
6666
Fill="Transparent" />
67+
68+
<Border Visibility="{x:Bind ViewModel.Player.IsCompactOverlay, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
69+
<Border Visibility="{x:Bind ViewModel.IsControlsVisible, Mode=OneWay}">
70+
<Button
71+
Margin="0,0,16,0"
72+
HorizontalAlignment="Right"
73+
VerticalAlignment="Center"
74+
AutomationProperties.Name="{ext:Locale Name=ShowMenu}"
75+
Click="OnMenuButtonClick"
76+
Style="{StaticResource SidePlayerButtonStyle}"
77+
ToolTipService.ToolTip="{ext:Locale Name=ShowMenu}"
78+
Visibility="{x:Bind ViewModel.IsTouchControlsVisible, Mode=OneWay}">
79+
<ic:FluentIcon FontSize="14" Icon="HandPoint" />
80+
</Button>
81+
</Border>
82+
</Border>
6783
</Grid>
6884
</local:PlayerControlBase>

src/Desktop/BiliCopilot.UI/Controls/Core/PlayerInteractivePanel.xaml.cs

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Bili Copilot. All rights reserved.
1+
// Copyright (c) Bili Copilot. All rights reserved.
22

33
using BiliCopilot.UI.Toolkits;
44
using Microsoft.UI.Dispatching;
@@ -21,8 +21,6 @@ public sealed partial class PlayerInteractivePanel : PlayerControlBase
2121
private bool _isLeftButton;
2222
private bool _isRightButton;
2323
private bool _isHolding;
24-
private readonly HashSet<uint> _activeTouchPointers = [];
25-
private int _lastTouchPointerCount;
2624

2725
public PlayerInteractivePanel()
2826
{
@@ -89,12 +87,6 @@ protected override void OnPointerPressed(PointerRoutedEventArgs e)
8987
var width = ActualWidth;
9088
var sideWidth = Math.Max(80, width / 5d);
9189

92-
if (point.PointerDeviceType == Microsoft.UI.Input.PointerDeviceType.Touch)
93-
{
94-
_activeTouchPointers.Add(point.PointerId);
95-
_lastTouchPointerCount = _activeTouchPointers.Count;
96-
}
97-
9890
if (point.Position.X > width - sideWidth)
9991
{
10092
_interactiveArea = InteractiveArea.Aside;
@@ -161,11 +153,6 @@ protected override void OnPointerMoved(PointerRoutedEventArgs e)
161153
/// <inheritdoc/>
162154
protected override void OnPointerReleased(PointerRoutedEventArgs e)
163155
{
164-
if (e.Pointer.PointerDeviceType == Microsoft.UI.Input.PointerDeviceType.Touch)
165-
{
166-
_activeTouchPointers.Remove(e.Pointer.PointerId);
167-
}
168-
169156
if (PointerCaptures?.Any(p => p.PointerId == e.Pointer.PointerId) != true)
170157
{
171158
return;
@@ -212,14 +199,6 @@ protected override void OnPointerReleased(PointerRoutedEventArgs e)
212199
e.Handled = true;
213200
}
214201

215-
protected override void OnPointerCanceled(PointerRoutedEventArgs e)
216-
{
217-
if (e.Pointer.PointerDeviceType == Microsoft.UI.Input.PointerDeviceType.Touch)
218-
{
219-
_activeTouchPointers.Remove(e.Pointer.PointerId);
220-
}
221-
}
222-
223202
private void OnTempControlTimerTick(DispatcherQueueTimer sender, object args)
224203
{
225204
if (ViewModel == null)
@@ -282,17 +261,8 @@ private async void OnTapTimerTick(object? sender, object? e)
282261
{
283262
if (_isTouch)
284263
{
285-
if (_lastTouchPointerCount == 2)
286-
{
287-
FlyoutBase.GetAttachedFlyout(this).ShowAt(this, new FlyoutShowOptions
288-
{
289-
Position = _startPoint,
290-
});
291-
}
292-
else
293-
{
294-
ViewModel.IsControlsVisible = !ViewModel.IsControlsVisible;
295-
}
264+
ViewModel.IsControlsVisible = !ViewModel.IsControlsVisible;
265+
ViewModel.IsTouchControlsVisible = !ViewModel.IsTouchControlsVisible;
296266
}
297267
else if (_isLeftButton)
298268
{
@@ -433,4 +403,15 @@ private void OnFlyoutClosed(object sender, object e)
433403
{
434404
ViewModel.IsPopupVisible = false;
435405
}
406+
407+
private void OnMenuButtonClick(object sender, RoutedEventArgs e)
408+
{
409+
var btn = sender as FrameworkElement;
410+
var point = btn!.TransformToVisual(this).TransformPoint(new Point(0, 0));
411+
FlyoutBase.GetAttachedFlyout(this).ShowAt(this, new FlyoutShowOptions
412+
{
413+
Position = point,
414+
Placement = FlyoutPlacementMode.Right,
415+
});
416+
}
436417
}

src/Desktop/BiliCopilot.UI/Controls/Core/PlayerOverlay.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@
680680
HorizontalAlignment="Stretch"
681681
IsEnabled="{x:Bind ViewModel.IsSubtitleEnabled, Mode=OneWay}"
682682
ItemsSource="{x:Bind ViewModel.Fonts, Mode=OneWay}"
683-
SelectedItem="{x:Bind ViewModel.SubtitleFontFamily, Mode=OneWay}"
683+
Loaded="OnSubtitleFontComboLoaded"
684684
SelectionChanged="OnSubtitleFontChanged"
685685
SelectionChangedTrigger="Committed" />
686686
<TextBlock

src/Desktop/BiliCopilot.UI/Controls/Core/PlayerOverlay.xaml.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
// Copyright (c) Bili Copilot. All rights reserved.
1+
// Copyright (c) Bili Copilot. All rights reserved.
22

33
using BiliCopilot.UI.ViewModels.Items;
44
using Microsoft.UI.Dispatching;
55
using Microsoft.UI.Xaml.Input;
66
using Richasy.MpvKernel.Core.Enums;
77
using Richasy.WinUIKernel.Share.Base;
8+
using Richasy.WinUIKernel.Share.Toolkits;
89
using System.ComponentModel;
910

1011
namespace BiliCopilot.UI.Controls.Core;
@@ -276,13 +277,13 @@ private string GetSpeedText(double speed)
276277

277278
private void OnSubtitleFontChanged(object sender, SelectionChangedEventArgs e)
278279
{
279-
var item = e.AddedItems.FirstOrDefault() as string;
280-
if (ViewModel?.Player == null || ViewModel.Player?.IsPlaybackInitialized != true || string.IsNullOrEmpty(item) || ViewModel.SubtitleFontFamily == item)
280+
var item = e.AddedItems.FirstOrDefault() as SystemFont;
281+
if (ViewModel?.Player == null || ViewModel.Player?.IsPlaybackInitialized != true || item == null || ViewModel.SubtitleFontFamily == item.LocalName)
281282
{
282283
return;
283284
}
284285

285-
ViewModel.ChangeSubtitleFontFamilyCommand.Execute(item);
286+
ViewModel.ChangeSubtitleFontFamilyCommand.Execute(item.LocalName);
286287
}
287288

288289
private void OnSubtitleDelayChanged(NumberBox sender, NumberBoxValueChangedEventArgs args)
@@ -322,4 +323,14 @@ private void OnSourceItemClick(object sender, RoutedEventArgs e)
322323
selectedSource?.ActiveCommand.Execute(default);
323324
SourceFlyout?.Hide();
324325
}
326+
327+
private void OnSubtitleFontComboLoaded(object sender, RoutedEventArgs e)
328+
{
329+
var font = ViewModel.SubtitleFontFamily;
330+
var source = ViewModel.Fonts.FirstOrDefault(p => p.LocalName == font);
331+
if (source != null)
332+
{
333+
SubtitleFontComboBox.SelectedItem = source;
334+
}
335+
}
325336
}

src/Desktop/BiliCopilot.UI/Controls/Danmaku/DanmakuDisplayOptions.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<local:DanmakuControlBase
33
x:Class="BiliCopilot.UI.Controls.Danmaku.DanmakuDisplayOptions"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
@@ -62,7 +62,7 @@
6262
HorizontalAlignment="Stretch"
6363
Header="{ext:Locale Name=DanmakuFont}"
6464
ItemsSource="{x:Bind ViewModel.Fonts, Mode=OneWay}"
65-
SelectedItem="{x:Bind ViewModel.DanmakuFontFamily, Mode=TwoWay}" />
65+
SelectionChanged="OnDanmakuFontChanged" />
6666
<StackPanel Spacing="8">
6767
<TextBlock HorizontalAlignment="Left" Text="{ext:Locale Name=EnabledDanmakuMode}" />
6868
<Grid

src/Desktop/BiliCopilot.UI/Controls/Danmaku/DanmakuDisplayOptions.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using BiliCopilot.UI.Models.Constants;
44
using BiliCopilot.UI.Toolkits;
5+
using Richasy.WinUIKernel.Share.Toolkits;
56

67
namespace BiliCopilot.UI.Controls.Danmaku;
78

@@ -16,6 +17,7 @@ protected override void OnControlLoaded()
1617
{
1718
var renderer = SettingsToolkit.ReadLocalSetting(Models.Constants.SettingNames.DanmakuRenderer, DanmakuRendererType.Win2D);
1819
RendererComboBox.SelectedIndex = renderer == DanmakuRendererType.DirectX ? 0 : 1;
20+
DanmakuFontComboBox.SelectedItem = ViewModel.Fonts.FirstOrDefault(p => p.LocalName == ViewModel.DanmakuFontFamily);
1921
}
2022

2123
private void OnRendererChanged(object sender, SelectionChangedEventArgs e)
@@ -32,4 +34,13 @@ private void OnRendererChanged(object sender, SelectionChangedEventArgs e)
3234
ViewModel.Renderer = renderer;
3335
}
3436
}
37+
38+
private void OnDanmakuFontChanged(object sender, SelectionChangedEventArgs e)
39+
{
40+
var item = DanmakuFontComboBox.SelectedItem as SystemFont;
41+
if (item != null && ViewModel.DanmakuFontFamily != item.LocalName)
42+
{
43+
ViewModel.DanmakuFontFamily = item.LocalName;
44+
}
45+
}
3546
}

0 commit comments

Comments
 (0)