From 778b81e10bc3d447db26c716517e07cdf309aca1 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sat, 16 Mar 2024 21:16:24 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=AF=92=E9=9C=9C=E5=BC=B9=E5=B9=95=E4=BD=BF=E5=8F=91=E9=80=81?= =?UTF-8?q?=E5=BC=B9=E5=B9=95=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/BiliLite.UWP.csproj | 1 + .../Controls/PlayerControl.xaml.cs | 29 ++++++++++--------- .../Extensions/DanmakuExtensions.cs | 9 ++++++ .../Extensions/MapperExtensions.cs | 18 ++++++++++++ .../Models/Common/Danmaku/BiliDanmakuItem.cs | 18 ++++++++++++ .../Services/FrostMasterDanmakuController.cs | 10 +++++-- .../Services/Interfaces/IDanmakuController.cs | 3 +- .../Services/NsDanmakuController.cs | 10 +++++-- src/BiliLite.UWP/Startup.cs | 1 + 9 files changed, 78 insertions(+), 21 deletions(-) create mode 100644 src/BiliLite.UWP/Models/Common/Danmaku/BiliDanmakuItem.cs diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index cd3bc778..fed18a0c 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -144,6 +144,7 @@ + diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs index 24ea6e0b..2db41690 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs @@ -42,6 +42,7 @@ using BiliLite.Models.Common.Video.PlayUrlInfos; using BiliLite.Services.Interfaces; using BiliLite.ViewModels; +using Microsoft.Extensions.DependencyInjection; //https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板 @@ -148,12 +149,12 @@ public PlayerControl() (int)SettingConstants.VideoDanmaku.DEFAULT_DANMAKU_ENGINE) == DanmakuEngineType.NSDanmaku; if (m_useNsDanmaku) { - m_danmakuController = new NsDanmakuController(); + m_danmakuController = App.ServiceProvider.GetRequiredService(); m_danmakuController.Init(DanmuControl); } else { - m_danmakuController = new FrostMasterDanmakuController(); + m_danmakuController = App.ServiceProvider.GetRequiredService(); m_danmakuController.Init(DanmakuCanvas); } } @@ -2591,13 +2592,13 @@ private async void BottomBtnSendDanmakuWide_Click(object sender, RoutedEventArgs SendDanmakuDialog sendDanmakuDialog = new SendDanmakuDialog(CurrentPlayItem.avid, CurrentPlayItem.cid, Player.Position); sendDanmakuDialog.DanmakuSended += new EventHandler((obj, arg) => { - m_danmakuController.Add(new DanmakuModel() + m_danmakuController.Add(new BiliDanmakuItem() { - color = NSDanmaku.Utils.ToColor(arg.color), - text = arg.text, - location = (DanmakuLocation)arg.location, - size = 25, - time = Player.Position + Color = NSDanmaku.Utils.ToColor(arg.color), + Text = arg.text, + Location = (DanmakuLocation)arg.location, + Size = 25, + Time = Player.Position }, true); }); await sendDanmakuDialog.ShowAsync(); @@ -2698,13 +2699,13 @@ private async void SendDanmaku() var result = await playerHelper.SendDanmaku(CurrentPlayItem.avid, CurrentPlayItem.cid, SendDanmakuTextBox.Text, Convert.ToInt32(Player.Position), modeInt, color); if (result) { - m_danmakuController.Add(new DanmakuModel() + m_danmakuController.Add(new BiliDanmakuItem() { - color = NSDanmaku.Utils.ToColor(color), - text = SendDanmakuTextBox.Text, - location = location, - size = 25, - time = Player.Position + Color = NSDanmaku.Utils.ToColor(color), + Text = SendDanmakuTextBox.Text, + Location = location, + Size = 25, + Time = Player.Position }, true); SendDanmakuTextBox.Text = ""; } diff --git a/src/BiliLite.UWP/Extensions/DanmakuExtensions.cs b/src/BiliLite.UWP/Extensions/DanmakuExtensions.cs index ffcf398b..9e323a1c 100644 --- a/src/BiliLite.UWP/Extensions/DanmakuExtensions.cs +++ b/src/BiliLite.UWP/Extensions/DanmakuExtensions.cs @@ -1,12 +1,21 @@ using Atelier39; +using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json.Linq; using System; using System.Net; +using BiliLite.Services; namespace BiliLite.Extensions { public static class DanmakuExtensions { + public static IServiceCollection AddDanmakuController(this IServiceCollection services) + { + services.AddTransient(); + services.AddTransient(); + return services; + } + public static void ParseAdvanceDanmaku(this DanmakuItem danmakuItem) { var content = danmakuItem.Text; diff --git a/src/BiliLite.UWP/Extensions/MapperExtensions.cs b/src/BiliLite.UWP/Extensions/MapperExtensions.cs index 117495c1..81f52854 100644 --- a/src/BiliLite.UWP/Extensions/MapperExtensions.cs +++ b/src/BiliLite.UWP/Extensions/MapperExtensions.cs @@ -8,6 +8,7 @@ using BiliLite.Models.Common; using BiliLite.Models.Common.Anime; using BiliLite.Models.Common.Comment; +using BiliLite.Models.Common.Danmaku; using BiliLite.Models.Common.Download; using BiliLite.Models.Common.Dynamic; using BiliLite.Models.Common.Home; @@ -28,6 +29,8 @@ using BiliLite.ViewModels.UserDynamic; using BiliLite.ViewModels.Video; using Microsoft.Extensions.DependencyInjection; +using NSDanmaku.Model; +using DanmakuMode = Atelier39.DanmakuMode; using DynamicType = Bilibili.App.Dynamic.V2.DynamicType; namespace BiliLite.Extensions @@ -55,6 +58,21 @@ public static IServiceCollection AddMapper(this IServiceCollection services) expression.CreateMap(); expression.CreateMap(); + var danmakuModeConvertDic = new Dictionary() + { + { DanmakuLocation.Scroll, DanmakuMode.Rolling }, + { DanmakuLocation.Top, DanmakuMode.Top }, + { DanmakuLocation.Bottom, DanmakuMode.Bottom }, + { DanmakuLocation.Position, DanmakuMode.Unknown }, + { DanmakuLocation.Other, DanmakuMode.Unknown }, + }; + expression.CreateMap(); + expression.CreateMap() + .ForMember(dest => dest.BaseFontSize, opt => opt.MapFrom(src => src.Size)) + .ForMember(dest => dest.TextColor, opt => opt.MapFrom(src => src.Color)) + .ForMember(dest => dest.StartMs, opt => opt.MapFrom(src => src.Time)) + .ForMember(dest => dest.Mode, opt => opt.MapFrom(src => danmakuModeConvertDic.GetValueOrDefault(src.Location))); + expression.CreateMap() .ForMember(dest => dest.Paths, opt => opt.MapFrom(src => new List())) .ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.EpisodeTitle)) diff --git a/src/BiliLite.UWP/Models/Common/Danmaku/BiliDanmakuItem.cs b/src/BiliLite.UWP/Models/Common/Danmaku/BiliDanmakuItem.cs new file mode 100644 index 00000000..46a81c64 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Danmaku/BiliDanmakuItem.cs @@ -0,0 +1,18 @@ +using Windows.UI; +using NSDanmaku.Model; + +namespace BiliLite.Models.Common.Danmaku +{ + public class BiliDanmakuItem + { + public string Text { get; set; } + + public double Size { get; set; } + + public Color Color { get; set; } + + public double Time { get; set; } + + public DanmakuLocation Location { get; set; } + } +} diff --git a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs index 63777b35..7301be7b 100644 --- a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs +++ b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs @@ -5,6 +5,8 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Atelier39; +using AutoMapper; +using BiliLite.Models.Common.Danmaku; using BiliLite.Services.Interfaces; using BiliLite.ViewModels.Video; using Microsoft.Graphics.Canvas.UI.Xaml; @@ -13,11 +15,13 @@ namespace BiliLite.Services { public class FrostMasterDanmakuController : IDanmakuController { + private readonly IMapper m_mapper; private CanvasAnimatedControl m_danmakuCanvas; private DanmakuFrostMaster m_danmakuMaster; - public FrostMasterDanmakuController() + public FrostMasterDanmakuController(IMapper mapper) { + m_mapper = mapper; DanmakuViewModel = new DanmakuViewModel() { ShowAreaControl = true, @@ -136,9 +140,9 @@ public override void Load(IEnumerable danmakuList) m_danmakuMaster.SetDanmakuList(realDanmakuList); } - public override void Add(object danmakuItem, bool owner) + public override void Add(BiliDanmakuItem danmakuItem, bool owner) { - var realDanmakuItem = danmakuItem as DanmakuItem; + var realDanmakuItem = m_mapper.Map(danmakuItem); m_danmakuMaster.AddRealtimeDanmaku(realDanmakuItem, false); } diff --git a/src/BiliLite.UWP/Services/Interfaces/IDanmakuController.cs b/src/BiliLite.UWP/Services/Interfaces/IDanmakuController.cs index b8248402..225a00fe 100644 --- a/src/BiliLite.UWP/Services/Interfaces/IDanmakuController.cs +++ b/src/BiliLite.UWP/Services/Interfaces/IDanmakuController.cs @@ -1,5 +1,6 @@ using System.Collections; using Windows.UI.Xaml.Controls; +using BiliLite.Models.Common.Danmaku; using BiliLite.ViewModels.Video; namespace BiliLite.Services.Interfaces @@ -142,7 +143,7 @@ public virtual void SetBolderStyle(int bolderStyle) /// /// 添加弹幕 /// - public abstract void Add(object danmakuItem, bool owner); + public abstract void Add(BiliDanmakuItem danmakuItem, bool owner); /// /// 暂停 diff --git a/src/BiliLite.UWP/Services/NsDanmakuController.cs b/src/BiliLite.UWP/Services/NsDanmakuController.cs index 872dafd6..b711aa30 100644 --- a/src/BiliLite.UWP/Services/NsDanmakuController.cs +++ b/src/BiliLite.UWP/Services/NsDanmakuController.cs @@ -5,6 +5,8 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; +using AutoMapper; +using BiliLite.Models.Common.Danmaku; using BiliLite.Services.Interfaces; using BiliLite.ViewModels.Video; using NSDanmaku.Controls; @@ -14,10 +16,12 @@ namespace BiliLite.Services { public class NsDanmakuController : IDanmakuController { + private readonly IMapper m_mapper; private Danmaku m_danmakuControl; - public NsDanmakuController() + public NsDanmakuController(IMapper mapper) { + m_mapper = mapper; DanmakuViewModel = new DanmakuViewModel() { ShowAreaControl = true, @@ -130,9 +134,9 @@ public override void Load(IEnumerable danmakuList) } } - public override void Add(object danmakuItem,bool owner) + public override void Add(BiliDanmakuItem danmakuItem,bool owner) { - var realDanmakuItem = danmakuItem as DanmakuModel; + var realDanmakuItem = m_mapper.Map(danmakuItem); m_danmakuControl.AddDanmu(realDanmakuItem, owner); } diff --git a/src/BiliLite.UWP/Startup.cs b/src/BiliLite.UWP/Startup.cs index 7b9367c1..c24fbe15 100644 --- a/src/BiliLite.UWP/Startup.cs +++ b/src/BiliLite.UWP/Startup.cs @@ -11,6 +11,7 @@ public void ConfigureServices(HostBuilderContext context, IServiceCollection ser { services.AddMapper(); services.AddViewModels(); + services.AddDanmakuController(); services.AddSingleton(); services.AddQrCodeService(); From ee320b69df5f3e98d9abe905a4dc443c8fd3f812 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sat, 16 Mar 2024 22:13:27 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=AF=92=E9=9C=9C=E5=BC=B9=E5=B9=95=E4=BD=BF=E6=97=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=BC=B9=E5=B9=95=E6=98=BE=E7=A4=BA=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/Controls/PlayerControl.xaml.cs | 15 +++++++++++++-- .../Services/FrostMasterDanmakuController.cs | 1 + .../Services/Interfaces/IDanmakuController.cs | 7 ++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs index 2db41690..941b42b5 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs @@ -842,6 +842,9 @@ private List FilterFrostDanmaku(IEnumerable danmakus) .SelectMany(x => x.Value.Take(max)); } + // 移除当前播放时间之前的弹幕,避免弹幕堆叠 + danmakus = danmakus.Where(x => x.StartMs > Player.Position * 1000); + return danmakus.ToList(); } @@ -917,6 +920,11 @@ private async void DanmuTimer_Tick(object sender, object e) { await LoadDanmaku(segIndex); } + else if (position < m_danmakuController.Position && !m_useNsDanmaku) + { + await LoadDanmaku(segIndex); + } + if (Buffering) { return; @@ -1331,13 +1339,16 @@ private async Task SetDanmaku(bool update = false) } else { - var segIndex = Math.Ceiling(Player.Position / (60 * 6d)); if (update) { + var segIndex = Math.Ceiling(Player.Position / (60 * 6d)); await LoadDanmaku(segIndex.ToInt32()); Notify.ShowMessageToast($"已更新弹幕"); } - await LoadDanmaku(1); + else + { + await LoadDanmaku(1); + } //var danmuList = (await danmakuParse.ParseBiliBili(Convert.ToInt64(CurrentPlayItem.cid))); ////await playerHelper.GetDanmaku(CurrentPlayItem.cid, 1) ; //danmakuPool = danmuList.GroupBy(x=>x.time_s).ToDictionary(x => x.Key, x => x.ToList()); diff --git a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs index 7301be7b..dc8f0c30 100644 --- a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs +++ b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs @@ -158,6 +158,7 @@ public override void Resume() public override void UpdateTime(long position) { + base.UpdateTime(position); m_danmakuMaster.UpdateTime((uint)position * 1000); } } diff --git a/src/BiliLite.UWP/Services/Interfaces/IDanmakuController.cs b/src/BiliLite.UWP/Services/Interfaces/IDanmakuController.cs index 225a00fe..d9d3e788 100644 --- a/src/BiliLite.UWP/Services/Interfaces/IDanmakuController.cs +++ b/src/BiliLite.UWP/Services/Interfaces/IDanmakuController.cs @@ -9,6 +9,8 @@ public abstract class IDanmakuController { public DanmakuViewModel DanmakuViewModel { get; protected set; } + public long Position { get; private set; } + public IDanmakuController() { DanmakuViewModel = new DanmakuViewModel(); @@ -166,6 +168,9 @@ public virtual void UpdateSize(double width, double height){} /// 更新时间 /// /// - public virtual void UpdateTime(long position){} + public virtual void UpdateTime(long position) + { + Position = position; + } } } From 593c96100863f5c5d90c766eb0a3dbd923c9a455 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sat, 23 Mar 2024 10:36:09 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=89=93=E5=BC=80=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=99=A8=E6=97=B6=E6=92=AD=E6=94=BE=E5=99=A8=E9=9F=B3=E9=87=8F?= =?UTF-8?q?=E5=81=8F=E4=BD=8E=E5=88=99=E6=8F=90=E7=A4=BA=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E9=9F=B3=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controls/PlayerControl.xaml.cs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs index 941b42b5..ac4c834d 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs @@ -208,7 +208,8 @@ private void PlayerControl_Unloaded(object sender, RoutedEventArgs e) } timer_focus.Stop(); } - private void PlayerControl_Loaded(object sender, RoutedEventArgs e) + + private async void PlayerControl_Loaded(object sender, RoutedEventArgs e) { m_danmakuController.Clear(); Window.Current.CoreWindow.KeyDown += PlayerControl_KeyDown; @@ -224,6 +225,7 @@ private void PlayerControl_Loaded(object sender, RoutedEventArgs e) updater.VideoProperties.Title = CurrentPlayItem.title; updater.Update(); } + _systemMediaTransportControls.ButtonPressed += _systemMediaTransportControls_ButtonPressed; LoadPlayerSetting(); @@ -232,6 +234,25 @@ private void PlayerControl_Loaded(object sender, RoutedEventArgs e) danmuTimer.Start(); timer_focus.Start(); + + // 检查音量是否偏低 + if (Player.Volume > 0.95) return; + var toolTipText = ""; + if (Player.Volume == 0) + { + toolTipText = "静音"; + } + else + { + toolTipText = "音量:" + Player.Volume.ToString("P"); + } + + TxtToolTip.Text = toolTipText; + ToolTip.Background = new SolidColorBrush(Color.FromArgb(90, 240, 240, 240)); + ToolTip.Visibility = Visibility.Visible; + await Task.Delay(2000); + ToolTip.Visibility = Visibility.Collapsed; + ToolTip.Background = new SolidColorBrush(Color.FromArgb(204, 255, 255, 255)); } private async void _systemMediaTransportControls_ButtonPressed(SystemMediaTransportControls sender, SystemMediaTransportControlsButtonPressedEventArgs args) From 65a94eea5398edf37f2e44af706454a915dd7ae1 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sat, 23 Mar 2024 10:36:55 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=851=E4=BD=8D?= =?UTF-8?q?=E4=BD=9C=E8=80=85=E7=9A=84=E8=A7=86=E9=A2=91=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=85=B3=E6=B3=A8=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/Controls/AttentionButton.xaml.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/BiliLite.UWP/Controls/AttentionButton.xaml.cs b/src/BiliLite.UWP/Controls/AttentionButton.xaml.cs index df1f09e0..fd6c0dd5 100644 --- a/src/BiliLite.UWP/Controls/AttentionButton.xaml.cs +++ b/src/BiliLite.UWP/Controls/AttentionButton.xaml.cs @@ -25,7 +25,16 @@ public AttentionButton() public int Attention { get => m_viewModel.Attention; - set => m_viewModel.Attention = value; + set + { + if (value < 0) + { + m_viewModel.Attention = 0; + return; + } + + m_viewModel.Attention = value; + } } public static readonly DependencyProperty UserIdProperty = From c77d4100b166a75436ed8604cda7fda2526f7b42 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sat, 23 Mar 2024 10:37:50 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=A9=BA=E9=97=B4=E5=8A=A8=E6=80=81=E6=98=BE=E7=A4=BA=E9=89=B4?= =?UTF-8?q?=E6=9D=83=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/Models/Requests/Api/User/DynamicAPI.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BiliLite.UWP/Models/Requests/Api/User/DynamicAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/User/DynamicAPI.cs index 7890502b..7ea075ec 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/User/DynamicAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/User/DynamicAPI.cs @@ -129,7 +129,8 @@ public ApiModel SpaceHistory(string mid, string dynamic_id = "") }; if (SettingService.Account.Logined) { - api.parameter += $"&access_key={SettingService.Account.AccessKey}"; + api.parameter += ApiHelper.MustParameter(AppKey, true); + api.parameter += ApiHelper.GetSign(api.parameter, AppKey); } return api; From 693dd5ea2bccc39437ef452927276ad2296c9ab8 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sat, 23 Mar 2024 10:38:58 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E9=98=BB=E6=AD=A2=E6=A0=87=E7=AD=BETab?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E8=A2=AB=E7=A9=BA=E6=A0=BC=E9=80=89=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/MainPage.xaml | 1 + src/BiliLite.UWP/MainPage.xaml.cs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/BiliLite.UWP/MainPage.xaml b/src/BiliLite.UWP/MainPage.xaml index 8c032893..dfab2139 100644 --- a/src/BiliLite.UWP/MainPage.xaml +++ b/src/BiliLite.UWP/MainPage.xaml @@ -23,6 +23,7 @@ VerticalContentAlignment="Stretch" Loaded="tabView_Loaded" IsAddTabButtonVisible="True" + PreviewKeyDown="TabView_OnPreviewKeyDown" TabCloseRequested="TabView_TabCloseRequested" AddTabButtonClick="TabView_AddTabButtonClick"> diff --git a/src/BiliLite.UWP/MainPage.xaml.cs b/src/BiliLite.UWP/MainPage.xaml.cs index 23360672..4050c59a 100644 --- a/src/BiliLite.UWP/MainPage.xaml.cs +++ b/src/BiliLite.UWP/MainPage.xaml.cs @@ -3,6 +3,7 @@ using System; using Windows.ApplicationModel.Core; using Windows.Foundation.Collections; +using Windows.System; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; @@ -265,5 +266,11 @@ private void tabView_TabItemsChanged(TabView sender, IVectorChangedEventArgs arg { } + + private void TabView_OnPreviewKeyDown(object sender, KeyRoutedEventArgs e) + { + if(e.Key == VirtualKey.Space) + e.Handled = true; + } } }