diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 755fd1b5e..050280019 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 23b5d429e..16558e6bd 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 71de8f30c..68daec498 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 54b614a06..dd8fc806e 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 000000000..3a63bea45 --- /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 01fb10137..4876fd6c8 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 1534dd8c8..af0ccc582 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 77bcdb67e..68ebef35e 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 4182d6a6a..5c0f1045f 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 43e6d95e8..1fa7e1661 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 ae203c4db..b70290140 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 6e2eb235c..5339ac4d9 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 bb72e099b..615210e20 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 49b1fe3cf..e07280f5c 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 2fdb4d6c5..4abc47962 100644 --- a/src/BiliLite.UWP/Styles/TabViewStyle.xaml +++ b/src/BiliLite.UWP/Styles/TabViewStyle.xaml @@ -24,16 +24,10 @@ - + - + @@ -74,8 +68,8 @@