From 1e9ab999a00592980760a11b81ed67049ab5c158 Mon Sep 17 00:00:00 2001
From: ProJend <55018532+ProJend@users.noreply.github.com>
Date: Tue, 17 Dec 2024 23:16:44 +0800
Subject: [PATCH] =?UTF-8?q?#925=20#900=20=E8=B0=83=E6=95=B4=E6=A0=87?=
=?UTF-8?q?=E7=AD=BE=E6=A0=8F=E6=A0=B7=E5=BC=8F=E3=80=81=E6=94=AF=E6=8C=81?=
=?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E7=9B=B8=E5=85=B3=E6=A0=B7=E5=BC=8F?=
=?UTF-8?q?=20(#932)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes #943 #925 #900 #864
实现左上角可点击,右上角不可点击
---
src/BiliLite.UWP/BiliLite.UWP.csproj | 1 +
.../Controls/PlayerControl.xaml.cs | 10 ++--
.../Controls/Settings/UISettingsControl.xaml | 26 ++++++----
.../Settings/UISettingsControl.xaml.cs | 30 ++++++++++++
.../Converters/InverseBooleanConverter.cs | 12 +++++
src/BiliLite.UWP/MainPage.xaml | 2 -
src/BiliLite.UWP/MainPage.xaml.cs | 25 ++++++----
.../Models/Common/SettingConstants.cs | 14 ++++--
src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs | 13 +++++
.../Pages/SeasonDetailPage.xaml.cs | 8 +++-
.../Pages/VideoDetailPage.xaml.cs | 11 ++++-
.../Services/FrostMasterDanmakuController.cs | 19 +-------
.../Services/NsDanmakuController.cs | 19 +-------
src/BiliLite.UWP/Styles/Converter.xaml | 1 +
src/BiliLite.UWP/Styles/TabViewStyle.xaml | 47 +++++++------------
.../ViewModels/Common/MainPageViewModel.cs | 5 ++
16 files changed, 143 insertions(+), 100 deletions(-)
create mode 100644 src/BiliLite.UWP/Converters/InverseBooleanConverter.cs
diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj
index 755fd1b5..05028001 100644
--- a/src/BiliLite.UWP/BiliLite.UWP.csproj
+++ b/src/BiliLite.UWP/BiliLite.UWP.csproj
@@ -186,6 +186,7 @@
VideoListView.xaml
+
EditPlaySpeedMenuDialog.xaml
diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs
index 23b5d429..16558e6b 100644
--- a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs
+++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs
@@ -173,7 +173,7 @@ public PlayerControl()
}
else
{
- m_danmakuController = App.ServiceProvider.GetRequiredService();
+ m_danmakuController = App.ServiceProvider.GetRequiredService();
m_danmakuController.Init(DanmakuCanvas);
}
}
@@ -496,7 +496,7 @@ private void LoadPlayerSetting()
{
//音量
Player.Volume = SettingService.GetValue(SettingConstants.Player.PLAYER_VOLUME, SettingConstants.Player.DEFAULT_PLAYER_VOLUME);
-
+
var lockPlayerVolume = SettingService.GetValue(SettingConstants.Player.LOCK_PLAYER_VOLUME, SettingConstants.Player.DEFAULT_LOCK_PLAYER_VOLUME);
if (!lockPlayerVolume)
{
@@ -1588,7 +1588,7 @@ private async Task ChangeQualityPlayVideo(BiliPlayUrlInfo qual
if (quality.PlayUrlType == BiliPlayUrlType.DASH)
{
var realPlayerType = (RealPlayerType)SettingService.GetValue(SettingConstants.Player.USE_REAL_PLAYER_TYPE, (int)SettingConstants.Player.DEFAULT_USE_REAL_PLAYER_TYPE);
- if (realPlayerType==RealPlayerType.Native)
+ if (realPlayerType == RealPlayerType.Native)
{
result = await Player.PlayerDashUseNative(quality.DashInfo, quality.UserAgent, quality.Referer, positon: _postion);
@@ -1681,10 +1681,6 @@ public void FullScreen(bool fullScreen)
BottomBtnFull.Visibility = Visibility.Collapsed;
BottomBtnFullWindows.Visibility = Visibility.Collapsed;
BottomBtnExitFullWindows.Visibility = Visibility.Collapsed;
- if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0)
- {
- TopControlBar.Margin = new Thickness(0, 48, 0, 0);
- }
//全屏
if (!view.IsFullScreenMode)
diff --git a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml
index 71de8f30..68daec49 100644
--- a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml
+++ b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml
@@ -330,16 +330,24 @@
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs
index 54b614a0..dd8fc806 100644
--- a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs
+++ b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs
@@ -306,6 +306,36 @@ private void LoadUI()
};
};
+ // 标签最小宽度
+ NumTabItemMinWidth.Value = SettingService.GetValue(SettingConstants.UI.TAB_ITEM_MIN_WIDTH, SettingConstants.UI.DEFAULT_TAB_ITEM_MIN_WIDTH);
+ NumTabItemMinWidth.Loaded += (sender, e) =>
+ {
+ NumTabItemMinWidth.ValueChanged += (obj, args) =>
+ {
+ SettingService.SetValue(SettingConstants.UI.TAB_ITEM_MIN_WIDTH, NumTabItemMinWidth.Value);
+ };
+ };
+
+ // 标签最大宽度
+ NumTabItemMaxWidth.Value = SettingService.GetValue(SettingConstants.UI.TAB_ITEM_MAX_WIDTH, SettingConstants.UI.DEFAULT_TAB_ITEM_MAX_WIDTH);
+ NumTabItemMaxWidth.Loaded += (sender, e) =>
+ {
+ NumTabItemMaxWidth.ValueChanged += (obj, args) =>
+ {
+ SettingService.SetValue(SettingConstants.UI.TAB_ITEM_MAX_WIDTH, NumTabItemMaxWidth.Value);
+ };
+ };
+
+ // 标签高度
+ NumTabHeight.Value = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT, SettingConstants.UI.DEFAULT_TAB_HEIGHT);
+ NumTabHeight.Loaded += (sender, e) =>
+ {
+ NumTabHeight.ValueChanged += (obj, args) =>
+ {
+ SettingService.SetValue(SettingConstants.UI.TAB_HEIGHT, NumTabHeight.Value);
+ };
+ };
+
//显示视频底部进度条
SwShowVideoBottomProgress.IsOn = SettingService.GetValue(SettingConstants.UI.SHOW_VIDEO_BOTTOM_VIRTUAL_PROGRESS_BAR, SettingConstants.UI.DEFAULT_SHOW_VIDEO_BOTTOM_VIRTUAL_PROGRESS_BAR);
SwShowVideoBottomProgress.Loaded += (sender, e) =>
diff --git a/src/BiliLite.UWP/Converters/InverseBooleanConverter.cs b/src/BiliLite.UWP/Converters/InverseBooleanConverter.cs
new file mode 100644
index 00000000..3a63bea4
--- /dev/null
+++ b/src/BiliLite.UWP/Converters/InverseBooleanConverter.cs
@@ -0,0 +1,12 @@
+using System;
+using Windows.UI.Xaml.Data;
+
+namespace BiliLite.Converters
+{
+ public class InverseBooleanConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, string language) => !(bool)value;
+
+ public object ConvertBack(object value, Type targetType, object parameter, string language) => throw new NotImplementedException();
+ }
+}
diff --git a/src/BiliLite.UWP/MainPage.xaml b/src/BiliLite.UWP/MainPage.xaml
index 01fb1013..4876fd6c 100644
--- a/src/BiliLite.UWP/MainPage.xaml
+++ b/src/BiliLite.UWP/MainPage.xaml
@@ -25,7 +25,6 @@
PreviewKeyDown="TabView_OnPreviewKeyDown"
TabCloseRequested="TabView_TabCloseRequested"
TabItemsChanged="tabView_TabItemsChanged"
- LayoutUpdated="TabView_OnLayoutUpdated"
TabWidthMode="SizeToContent">
diff --git a/src/BiliLite.UWP/MainPage.xaml.cs b/src/BiliLite.UWP/MainPage.xaml.cs
index 1534dd8c..af0ccc58 100644
--- a/src/BiliLite.UWP/MainPage.xaml.cs
+++ b/src/BiliLite.UWP/MainPage.xaml.cs
@@ -265,6 +265,9 @@ private void ClosePage(TabViewItem tabItem)
}
private void tabView_Loaded(object sender, RoutedEventArgs e)
{
+ // 根据Tab高度设置图片视图边距
+ gridViewer.Margin = new Thickness(0, m_viewModel.TabHeight, 0, 0);
+
var frame = new MyFrame();
frame.Navigate(typeof(HomePage));
@@ -325,17 +328,19 @@ private void InitTabViewStyle()
var styleKvp = dict.FirstOrDefault(x => x.Key.ToString().Contains("TabViewItem"));
- if (!(styleKvp.Value is Style style)) return;
- style.Setters.Add(new Setter(TabViewItem.MinWidthProperty, m_viewModel.TabItemMinWidth));
- style.Setters.Add(new Setter(TabViewItem.MaxWidthProperty, m_viewModel.TabItemMaxWidth));
- }
+ if (styleKvp.Value is Style style)
+ {
+ style.Setters.Add(new Setter(TabViewItem.MinWidthProperty, m_viewModel.TabItemMinWidth));
+ style.Setters.Add(new Setter(TabViewItem.MaxWidthProperty, m_viewModel.TabItemMaxWidth));
+ style.Setters.Add(new Setter(TabViewItem.HeightProperty, m_viewModel.TabHeight));
+ }
- private void TabView_OnLayoutUpdated(object sender, object e)
- {
- // TODO: LayoutUpdated调用频繁,后续更换其他事件
- var tabList = tabView.FindFirstChildByType();
- if (tabList == null) return;
- tabList.MaxWidth = tabView.ActualWidth - 175;
+ var tabStyleKvp = dict.FirstOrDefault(x => x.Key.ToString().Contains("TabViewListView"));
+
+ if (tabStyleKvp.Value is Style tabStyle)
+ {
+ tabStyle.Setters.Add(new Setter(TabViewItem.HeightProperty, m_viewModel.TabHeight));
+ }
}
}
}
diff --git a/src/BiliLite.UWP/Models/Common/SettingConstants.cs b/src/BiliLite.UWP/Models/Common/SettingConstants.cs
index 77bcdb67..68ebef35 100644
--- a/src/BiliLite.UWP/Models/Common/SettingConstants.cs
+++ b/src/BiliLite.UWP/Models/Common/SettingConstants.cs
@@ -1,7 +1,7 @@
-using System.Collections.Generic;
-using BiliLite.Models.Attributes;
+using BiliLite.Models.Attributes;
using BiliLite.Models.Common.Player;
using BiliLite.Services;
+using System.Collections.Generic;
namespace BiliLite.Models.Common
{
@@ -233,7 +233,13 @@ public class UI
public const string TAB_ITEM_MIN_WIDTH = "TabItemMinWidth";
[SettingDefaultValue]
- public const double DEFAULT_TAB_ITEM_MIN_WIDTH = 192;
+ public const double DEFAULT_TAB_ITEM_MIN_WIDTH = 0;
+
+ [SettingKey(typeof(double))]
+ public const string TAB_HEIGHT = "TabHeight";
+
+ [SettingDefaultValue]
+ public const double DEFAULT_TAB_HEIGHT = 40;
///
/// 是否启用动态磁贴
@@ -612,7 +618,7 @@ public class Player
[SettingKey(typeof(object))]
public const string FfmpegOptions = "FfmpegOptions";
- ///
+ ///
/// 使用外站视频替换无法播放的视频 bool
///
[SettingKey(typeof(bool))]
diff --git a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs
index 4182d6a6..5c0f1045 100644
--- a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs
+++ b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs
@@ -323,10 +323,23 @@ await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
if (e.NewState.IsFullscreen && !view.IsFullScreenMode)
{
view.TryEnterFullScreenMode();
+
+ if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) <= 0)
+ {
+ var marginOffset = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT,
+ SettingConstants.UI.DEFAULT_TAB_HEIGHT);
+ this.Margin = new Thickness(0, marginOffset * -1, 0, 0);
+ }
+ else
+ {
+ this.Margin = new Thickness(0, -40, 0, 0);
+ }
}
else if (view.IsFullScreenMode)
{
view.ExitFullScreenMode();
+
+ this.Margin = new Thickness(0);
}
});
}
diff --git a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs
index 43e6d95e..1fa7e166 100644
--- a/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs
+++ b/src/BiliLite.UWP/Pages/SeasonDetailPage.xaml.cs
@@ -275,7 +275,13 @@ private void PlayerControl_FullScreenEvent(object sender, bool e)
{
if (e)
{
- this.Margin = new Thickness(0, SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) == 0 ? -48 : -48, 0, 0);
+ if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) <= 0)
+ {
+ var marginOffset = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT,
+ SettingConstants.UI.DEFAULT_TAB_HEIGHT);
+ this.Margin = new Thickness(0, marginOffset * -1, 0, 0);
+ }
+
m_viewModel.DefaultRightInfoWidth = new GridLength(0, GridUnitType.Pixel);
BottomInfo.Height = new GridLength(0, GridUnitType.Pixel);
}
diff --git a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs
index ae203c4d..b7029014 100644
--- a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs
+++ b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs
@@ -449,14 +449,21 @@ private void PlayerControl_FullScreenEvent(object sender, bool e)
{
if (e)
{
- this.Margin = new Thickness(0, SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) == 0 ? -48 : -48, 0, 0);
+ if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) <= 0)
+ {
+ var marginOffset = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT,
+ SettingConstants.UI.DEFAULT_TAB_HEIGHT);
+ this.Margin = new Thickness(0, marginOffset * -1, 0, 0);
+ }
+
m_viewModel.DefaultRightInfoWidth = new GridLength(0, GridUnitType.Pixel);
BottomInfo.Height = new GridLength(0, GridUnitType.Pixel);
}
else
{
this.Margin = new Thickness(0);
- m_viewModel.DefaultRightInfoWidth = new GridLength(SettingService.GetValue(SettingConstants.UI.RIGHT_DETAIL_WIDTH, 320), GridUnitType.Pixel);
+ m_viewModel.DefaultRightInfoWidth = new GridLength(
+ SettingService.GetValue(SettingConstants.UI.RIGHT_DETAIL_WIDTH, 320), GridUnitType.Pixel);
BottomInfo.Height = GridLength.Auto;
}
}
diff --git a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs
index 6e2eb235..5339ac4d 100644
--- a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs
+++ b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs
@@ -6,7 +6,6 @@
using Windows.UI.Xaml.Controls;
using Atelier39;
using AutoMapper;
-using BiliLite.Models.Common;
using BiliLite.Models.Common.Danmaku;
using BiliLite.Services.Interfaces;
using BiliLite.ViewModels.Video;
@@ -115,23 +114,7 @@ public override void SetSpeed(int speed)
public override void SetTopMargin(double topMargin)
{
base.SetTopMargin(topMargin);
- if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0)
- {
- m_danmakuCanvas.Margin = DanmakuViewModel.Fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0);
- }
- else
- {
- m_danmakuCanvas.Margin = new Thickness(0, topMargin, 0, 0);
- }
- }
-
- public override void SetFullscreen(bool fullscreen)
- {
- base.SetFullscreen(fullscreen);
- if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0)
- {
- m_danmakuCanvas.Margin = fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0);
- }
+ m_danmakuCanvas.Margin = new Thickness(0, topMargin, 0, 0);
}
public override void SetOpacity(double opacity)
diff --git a/src/BiliLite.UWP/Services/NsDanmakuController.cs b/src/BiliLite.UWP/Services/NsDanmakuController.cs
index bb72e099..615210e2 100644
--- a/src/BiliLite.UWP/Services/NsDanmakuController.cs
+++ b/src/BiliLite.UWP/Services/NsDanmakuController.cs
@@ -12,7 +12,6 @@
using BiliLite.ViewModels.Video;
using NSDanmaku.Controls;
using NSDanmaku.Model;
-using BiliLite.Models.Common;
namespace BiliLite.Services
{
@@ -112,23 +111,7 @@ public override void SetSpeed(int speed)
public override void SetTopMargin(double topMargin)
{
base.SetTopMargin(topMargin);
- if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0)
- {
- m_danmakuControl.Margin = DanmakuViewModel.Fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0);
- }
- else
- {
- m_danmakuControl.Margin = new Thickness(0, topMargin, 0, 0);
- }
- }
-
- public override void SetFullscreen(bool fullscreen)
- {
- base.SetFullscreen(fullscreen);
- if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0)
- {
- m_danmakuControl.Margin = fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0);
- }
+ m_danmakuControl.Margin = new Thickness(0, topMargin, 0, 0);
}
public override void SetOpacity(double opacity)
diff --git a/src/BiliLite.UWP/Styles/Converter.xaml b/src/BiliLite.UWP/Styles/Converter.xaml
index 49b1fe3c..e07280f5 100644
--- a/src/BiliLite.UWP/Styles/Converter.xaml
+++ b/src/BiliLite.UWP/Styles/Converter.xaml
@@ -8,4 +8,5 @@
+
diff --git a/src/BiliLite.UWP/Styles/TabViewStyle.xaml b/src/BiliLite.UWP/Styles/TabViewStyle.xaml
index 2fdb4d6c..4abc4796 100644
--- a/src/BiliLite.UWP/Styles/TabViewStyle.xaml
+++ b/src/BiliLite.UWP/Styles/TabViewStyle.xaml
@@ -24,16 +24,10 @@
-
+
-
+
@@ -74,8 +68,8 @@
-
-
+
-
+
-
+
@@ -189,8 +183,7 @@
-
+
-
-
-
+
@@ -612,7 +600,6 @@
FontSize="10"
Glyph="" />
-
-
-
+
@@ -733,7 +723,6 @@
x:Name="ContentPresenter"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
- contract7NotPresent:CornerRadius="{ThemeResource ControlCornerRadius}"
AutomationProperties.AccessibilityView="Raw"
Background="{TemplateBinding Background}"
BackgroundSizing="{TemplateBinding BackgroundSizing}"
diff --git a/src/BiliLite.UWP/ViewModels/Common/MainPageViewModel.cs b/src/BiliLite.UWP/ViewModels/Common/MainPageViewModel.cs
index 21741414..3a391917 100644
--- a/src/BiliLite.UWP/ViewModels/Common/MainPageViewModel.cs
+++ b/src/BiliLite.UWP/ViewModels/Common/MainPageViewModel.cs
@@ -32,5 +32,10 @@ public class MainPageViewModel : BaseViewModel
: SettingService.GetValue(
SettingConstants.UI.TAB_ITEM_MIN_WIDTH,
SettingConstants.UI.DEFAULT_TAB_ITEM_MIN_WIDTH);
+
+ [DoNotNotify]
+ public double TabHeight => SettingService.GetValue(
+ SettingConstants.UI.TAB_HEIGHT,
+ SettingConstants.UI.DEFAULT_TAB_HEIGHT);
}
}