From 30b921854bfb87bd4b58e83e814e070f2b842f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B1=B3?= Date: Tue, 10 Sep 2024 23:39:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=92=AD=E6=94=BE=E5=99=A8?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=97=B6=E6=A0=B9=E6=8D=AE=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=E6=B5=81=E8=87=AA=E5=8A=A8=E9=80=82=E9=85=8D=E6=A8=AA?= =?UTF-8?q?=E5=B1=8F=E5=92=8C=E7=AB=96=E5=B1=8F=EF=BC=9B=E6=B8=85=E7=90=86?= =?UTF-8?q?=E5=86=97=E4=BD=99using=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Desktop/App.xaml.cs | 18 ++---- Desktop/DataSource/LoginStatus.cs | 14 ----- Desktop/DataSource/RetrieveData.cs | 12 ---- Desktop/GlobalUsings.cs | 12 +--- Desktop/MainWindow.xaml.cs | 14 ----- Desktop/Models/DataCard.cs | 5 +- Desktop/Models/HomePageModels.cs | 7 +-- Desktop/Models/ToolsPageModels.cs | 7 +-- Desktop/Models/VlcPlayModels.cs | 7 +-- Desktop/NetWork/Basics.cs | 11 +--- Desktop/NetWork/Get.cs | 20 ++----- Desktop/NetWork/Post.cs | 13 +---- Desktop/Views/Control/CardControl.xaml.cs | 14 +---- Desktop/Views/Pages/AboutPage.xaml.cs | 15 +---- Desktop/Views/Pages/DataPage.xaml.cs | 23 ++------ Desktop/Views/Pages/DefaultPage.xaml.cs | 14 ++--- Desktop/Views/Pages/HistoryPage.xaml.cs | 4 -- Desktop/Views/Pages/LogPage.xaml.cs | 2 - Desktop/Views/Pages/SettingsPage.xaml.cs | 18 ++---- Desktop/Views/Pages/ToolsPage.xaml.cs | 2 - Desktop/Views/Windows/AddRoom.xaml.cs | 31 ++-------- .../BarrageParameters/BarrageConfig.cs | 11 +--- .../Models/GetMessageInformationResult.cs | 8 +-- .../DanMuCanvas/Models/MessageInformation.cs | 8 +-- Desktop/Views/Windows/DanmaOnlyWindow.xaml.cs | 17 +----- Desktop/Views/Windows/QrLogin.xaml.cs | 17 ------ Desktop/Views/Windows/VlcPlayWindow.xaml.cs | 57 ++++++++++++------- Desktop/Views/Windows/WebPlayWindow.xaml.cs | 19 +------ Desktop/WindowsAPI.cs | 7 +-- 29 files changed, 90 insertions(+), 317 deletions(-) diff --git a/Desktop/App.xaml.cs b/Desktop/App.xaml.cs index 7b915cb43..c4c0be928 100644 --- a/Desktop/App.xaml.cs +++ b/Desktop/App.xaml.cs @@ -1,18 +1,12 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; -using System.Configuration; -using System.Data; -using System.Windows; -using Server; +using Core; using Core.LogModule; -using Core; -using static Server.Program; -using static Core.Network.Methods.User.UserInfo; -using Wpf.Ui; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; -using System; -using Microsoft.AspNetCore.Http.Features; +using Microsoft.Extensions.Hosting; using System.IO; +using System.Windows; +using Wpf.Ui; +using static Server.Program; diff --git a/Desktop/DataSource/LoginStatus.cs b/Desktop/DataSource/LoginStatus.cs index 0a7c2d069..74faa62e8 100644 --- a/Desktop/DataSource/LoginStatus.cs +++ b/Desktop/DataSource/LoginStatus.cs @@ -1,18 +1,4 @@ using Core; -using Core.LogModule; -using Core.RuntimeObject; -using Desktop.Models; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using Wpf.Ui.Controls; -using static Core.Network.Methods.Room; namespace Desktop.DataSource { diff --git a/Desktop/DataSource/RetrieveData.cs b/Desktop/DataSource/RetrieveData.cs index 34011dd25..0e79088a8 100644 --- a/Desktop/DataSource/RetrieveData.cs +++ b/Desktop/DataSource/RetrieveData.cs @@ -1,21 +1,9 @@ using Core; using Core.LogModule; -using Core.RuntimeObject; using Desktop.Models; using Desktop.Views.Pages; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Net.Http; -using System.Threading.Tasks; using System.Windows; using System.Windows.Media; -using System.Windows.Media.Imaging; -using Wpf.Ui.Controls; -using static Core.Network.Methods.Room; -using static Desktop.Views.Pages.DataPage; diff --git a/Desktop/GlobalUsings.cs b/Desktop/GlobalUsings.cs index 3e8beaf03..5d9e83349 100644 --- a/Desktop/GlobalUsings.cs +++ b/Desktop/GlobalUsings.cs @@ -1,12 +1,6 @@ global using Application = System.Windows.Application; -global using Timer = System.Threading.Timer; -global using UserControl = System.Windows.Controls.UserControl; -global using MessageBox = System.Windows.MessageBox; global using Color = System.Windows.Media.Color; global using ColorConverter = System.Windows.Media.ColorConverter; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; \ No newline at end of file +global using MessageBox = System.Windows.MessageBox; +global using Timer = System.Threading.Timer; +global using UserControl = System.Windows.Controls.UserControl; diff --git a/Desktop/MainWindow.xaml.cs b/Desktop/MainWindow.xaml.cs index eb20087f2..39eb87a97 100644 --- a/Desktop/MainWindow.xaml.cs +++ b/Desktop/MainWindow.xaml.cs @@ -1,31 +1,17 @@ using Core; using Core.LogModule; using Core.RuntimeObject; -using Desktop.Models; using Desktop.Views.Pages; using Desktop.Views.Windows; -using Masuit.Tools.Win32; using Microsoft.Extensions.DependencyInjection; using Notification.Wpf; using System.Diagnostics; using System.Reflection; -using System.Text; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Forms; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using Wpf.Ui; -using Wpf.Ui.Appearance; using Wpf.Ui.Controls; using static Core.RuntimeObject.Detect; using static Core.Tools.DokiDoki; -using static Server.WebAppServices.Api.get_system_resources; namespace Desktop { diff --git a/Desktop/Models/DataCard.cs b/Desktop/Models/DataCard.cs index 5d3ede8ff..7a5301dfc 100644 --- a/Desktop/Models/DataCard.cs +++ b/Desktop/Models/DataCard.cs @@ -1,8 +1,5 @@ -using System.ComponentModel; -using System.Windows; +using System.Windows; using System.Windows.Media; -using System.Windows.Media.Imaging; -using static Core.RuntimeObject.RoomCardClass; namespace Desktop.Models { diff --git a/Desktop/Models/HomePageModels.cs b/Desktop/Models/HomePageModels.cs index 1c70d179e..5bd944ef7 100644 --- a/Desktop/Models/HomePageModels.cs +++ b/Desktop/Models/HomePageModels.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel; namespace Desktop.Models { diff --git a/Desktop/Models/ToolsPageModels.cs b/Desktop/Models/ToolsPageModels.cs index af221b4de..ba6ea9d6f 100644 --- a/Desktop/Models/ToolsPageModels.cs +++ b/Desktop/Models/ToolsPageModels.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel; namespace Desktop.Models { diff --git a/Desktop/Models/VlcPlayModels.cs b/Desktop/Models/VlcPlayModels.cs index db170955c..f8f14d6cd 100644 --- a/Desktop/Models/VlcPlayModels.cs +++ b/Desktop/Models/VlcPlayModels.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel; using System.Windows; namespace Desktop.Models diff --git a/Desktop/NetWork/Basics.cs b/Desktop/NetWork/Basics.cs index a31b05c05..bd30e5502 100644 --- a/Desktop/NetWork/Basics.cs +++ b/Desktop/NetWork/Basics.cs @@ -1,14 +1,7 @@ -using Microsoft.AspNetCore.Mvc; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Desktop.NetWork +namespace Desktop.NetWork { public class Basics { - + } } diff --git a/Desktop/NetWork/Get.cs b/Desktop/NetWork/Get.cs index 59039b9b2..20fbf3275 100644 --- a/Desktop/NetWork/Get.cs +++ b/Desktop/NetWork/Get.cs @@ -1,18 +1,6 @@ -using AngleSharp.Dom; -using Core.LogModule; -using Core.RuntimeObject; +using Core.LogModule; using Newtonsoft.Json; -using SkiaSharp; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Net; using System.Net.Http; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; namespace Desktop.NetWork { @@ -53,7 +41,7 @@ public static T GetBody(string url, Dictionary _dic = null) using (HttpClient _httpClient = new HttpClient()) { - _httpClient.Timeout = new TimeSpan(0,0,8); + _httpClient.Timeout = new TimeSpan(0, 0, 8); HttpResponseMessage response = _httpClient.GetAsync($"{url}?{Parameter}").Result; response.EnsureSuccessStatusCode(); string responseBody = response.Content.ReadAsStringAsync().Result; @@ -65,7 +53,7 @@ public static T GetBody(string url, Dictionary _dic = null) { GetErrorCount++; if (GetErrorCount > 30) - { + { Log.Warn(nameof(GetBody), $"触发DesktopTips={GetErrorCount}"); GetErrorCount = 0; } @@ -78,7 +66,7 @@ public static T GetBody(string url, Dictionary _dic = null) { Log.Warn(nameof(GetBody), $"发起Get请求出错,URL:[{url}],错误堆栈:\r\n{ex.ToString()}", ex, false); } - + return default; } } diff --git a/Desktop/NetWork/Post.cs b/Desktop/NetWork/Post.cs index 04b5897a7..9e0bea4f1 100644 --- a/Desktop/NetWork/Post.cs +++ b/Desktop/NetWork/Post.cs @@ -1,17 +1,6 @@ -using AngleSharp.Io; -using Core.LogModule; -using Core.RuntimeObject; +using Core.LogModule; using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; using System.Net.Http; -using System.Text; -using System.Text.Json; -using System.Text.RegularExpressions; -using System.Threading.Tasks; namespace Desktop.NetWork { diff --git a/Desktop/Views/Control/CardControl.xaml.cs b/Desktop/Views/Control/CardControl.xaml.cs index 8e572ad15..9444ad1d2 100644 --- a/Desktop/Views/Control/CardControl.xaml.cs +++ b/Desktop/Views/Control/CardControl.xaml.cs @@ -1,23 +1,11 @@ using Core; using Core.LogModule; using Core.RuntimeObject; -using Desktop.Models; using Desktop.Views.Windows; -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using Wpf.Ui.Controls; namespace Desktop.Views.Control @@ -208,7 +196,7 @@ private void Snapshot_Task_Click(object sender, RoutedEventArgs e) }; Task.Run(() => { - var message = NetWork.Post.PostBody<(bool state, string message)>($"{Config.Core_RunConfig._DesktopIP}:{Config.Core_RunConfig._DesktopPort}/api/rec_task/generate_snapshot", dic,new TimeSpan(0,1,0)).Result; + var message = NetWork.Post.PostBody<(bool state, string message)>($"{Config.Core_RunConfig._DesktopIP}:{Config.Core_RunConfig._DesktopPort}/api/rec_task/generate_snapshot", dic, new TimeSpan(0, 1, 0)).Result; if (!message.state) { Log.Info(nameof(Snapshot_Task_Click), $"生成直播间录制快照失败,原因:{message.message}"); diff --git a/Desktop/Views/Pages/AboutPage.xaml.cs b/Desktop/Views/Pages/AboutPage.xaml.cs index 672dedeb6..1ae9f9afe 100644 --- a/Desktop/Views/Pages/AboutPage.xaml.cs +++ b/Desktop/Views/Pages/AboutPage.xaml.cs @@ -1,17 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; +using System.Windows.Controls; namespace Desktop.Views.Pages { diff --git a/Desktop/Views/Pages/DataPage.xaml.cs b/Desktop/Views/Pages/DataPage.xaml.cs index 5eb5b1db0..b775832ff 100644 --- a/Desktop/Views/Pages/DataPage.xaml.cs +++ b/Desktop/Views/Pages/DataPage.xaml.cs @@ -3,28 +3,17 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. -using System; -using System.Collections; -using System.Collections.Generic; +using Core; +using Core.LogModule; +using Desktop.Models; +using Desktop.Views.Windows; using System.Collections.ObjectModel; using System.Collections.Specialized; -using System.ComponentModel; -using System.Diagnostics.Metrics; using System.IO; -using System.Threading; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Imaging; -using Core; -using Core.LogModule; -using Desktop.Models; -using Desktop.Views.Windows; -using Masuit.Tools; -using Microsoft.AspNetCore.Http.HttpResults; -using Newtonsoft.Json; -using Wpf.Ui; using Wpf.Ui.Controls; using static Core.Network.Methods.Follow; using MenuItem = Wpf.Ui.Controls.MenuItem; @@ -197,7 +186,7 @@ public static void UpdatePageCount(int PageCount) public static void Refresher(object state) { - DataSource.RetrieveData.UI_RoomCards.RefreshRoomCards(); + DataSource.RetrieveData.UI_RoomCards.RefreshRoomCards(); } public class SortableObservableCollection : ObservableCollection { @@ -265,7 +254,7 @@ private void ScreenName_Click(object sender, RoutedEventArgs e) private void ScreenName() { - if (!string.IsNullOrEmpty(ScreenNameBox.Text)) + if (!string.IsNullOrEmpty(ScreenNameBox.Text)) { screen_name = ScreenNameBox.Text; } diff --git a/Desktop/Views/Pages/DefaultPage.xaml.cs b/Desktop/Views/Pages/DefaultPage.xaml.cs index fe78bd406..4a915a90d 100644 --- a/Desktop/Views/Pages/DefaultPage.xaml.cs +++ b/Desktop/Views/Pages/DefaultPage.xaml.cs @@ -6,13 +6,9 @@ using Core; using Core.LogModule; using Desktop.Models; -using SixLabors.ImageSharp.Drawing; -using System.Collections.ObjectModel; -using System.Net.Sockets; using System.Net; -using System.Windows; +using System.Net.Sockets; using static Server.WebAppServices.Api.get_system_resources; -using Castle.DynamicProxy; namespace Desktop.Views.Pages; @@ -114,7 +110,7 @@ public static void UpdateAnnouncement(object state) Log.Warn(nameof(UpdateAnnouncement), "更新公告出现错误,错误堆栈已写文本记录文件", ex, false); } } - + /// /// 检测代理状态 /// @@ -127,7 +123,7 @@ public static void ProxyDetection(object state) if (defaultProxy != null) { var proxyUri = defaultProxy.GetProxy(new Uri(Config.Core_RunConfig._LiveDomainName)); - if(proxyUri==null) + if (proxyUri == null) { SetProxyState("正常,未检测到代理"); return; @@ -156,7 +152,7 @@ public static void IpvDetection(object state) { try { - string url = Config.Core_RunConfig._LiveDomainName.ToLower().Replace("https://", "").Replace("http://",""); + string url = Config.Core_RunConfig._LiveDomainName.ToLower().Replace("https://", "").Replace("http://", ""); IPHostEntry hostEntry = Dns.GetHostEntry(url); foreach (IPAddress ipAddress in hostEntry.AddressList) { @@ -176,7 +172,7 @@ public static void IpvDetection(object state) Log.Info(nameof(IpvDetection), $"当前为IPv6访问状态", false); break; } - + tempSocket.Close(); break; } diff --git a/Desktop/Views/Pages/HistoryPage.xaml.cs b/Desktop/Views/Pages/HistoryPage.xaml.cs index 29bce614b..eeb187c28 100644 --- a/Desktop/Views/Pages/HistoryPage.xaml.cs +++ b/Desktop/Views/Pages/HistoryPage.xaml.cs @@ -4,11 +4,7 @@ // All Rights Reserved. using Core; -using Core.LogModule; -using Core.Tools; -using Desktop.Models; using System.Collections.ObjectModel; -using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Windows; diff --git a/Desktop/Views/Pages/LogPage.xaml.cs b/Desktop/Views/Pages/LogPage.xaml.cs index 8cb2bfc26..4b9474124 100644 --- a/Desktop/Views/Pages/LogPage.xaml.cs +++ b/Desktop/Views/Pages/LogPage.xaml.cs @@ -5,8 +5,6 @@ using Core.LogModule; using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Windows; namespace Desktop.Views.Pages; diff --git a/Desktop/Views/Pages/SettingsPage.xaml.cs b/Desktop/Views/Pages/SettingsPage.xaml.cs index d32078524..32ace9ca3 100644 --- a/Desktop/Views/Pages/SettingsPage.xaml.cs +++ b/Desktop/Views/Pages/SettingsPage.xaml.cs @@ -4,23 +4,13 @@ // All Rights Reserved. using Core; -using Desktop.Models; using Desktop.Views.Windows; -using Masuit.Tools; -using Microsoft.Extensions.DependencyInjection; -using System; using System.Diagnostics; using System.IO; -using System.Threading; using System.Windows; -using System.Windows.Controls; -using System.Windows.Media.Animation; using System.Windows.Media; -using System.Windows.Navigation; -using Wpf.Ui; -using Wpf.Ui.Appearance; +using System.Windows.Media.Animation; using Wpf.Ui.Controls; -using Wpf.Ui.Extensions; using static Core.RuntimeObject.Download.Basics; namespace Desktop.Views.Pages; @@ -128,7 +118,7 @@ public bool CheckConfiguration(ref bool Reboot) { MainWindow.SnackbarService.Show("保存失败", "请检查确保WebHook地址配置正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8)); return false; - } + } #endregion #region 文件路径相关设置检查 @@ -178,7 +168,7 @@ public bool CheckConfiguration(ref bool Reboot) #region 播放窗口设置 //弹幕速度设置 - if (string.IsNullOrEmpty(PlayWindowDanmaSpeed_InputBox.Text) && int.Parse(PlayWindowDanmaSpeed_InputBox.Text)>0) + if (string.IsNullOrEmpty(PlayWindowDanmaSpeed_InputBox.Text) && int.Parse(PlayWindowDanmaSpeed_InputBox.Text) > 0) { MainWindow.SnackbarService.Show("保存失败", "请检查确播放窗口弹幕速度参数配置正确且不为空", ControlAppearance.Danger, new SymbolIcon(SymbolRegular.SaveSearch20), TimeSpan.FromSeconds(8)); return false; @@ -335,7 +325,7 @@ public async void SaveConfiguration() Config.Core_RunConfig._DeleteOriginalFileAfterRepair = (bool)DeleteOriginalFileAfterRepair_SwitchControl.IsChecked; } //设置屏蔽词 - if(Config.Core_RunConfig._BlockBarrageList != BlockBarrageList_TextBox.Text) + if (Config.Core_RunConfig._BlockBarrageList != BlockBarrageList_TextBox.Text) { Config.Core_RunConfig._BlockBarrageList = BlockBarrageList_TextBox.Text; } diff --git a/Desktop/Views/Pages/ToolsPage.xaml.cs b/Desktop/Views/Pages/ToolsPage.xaml.cs index 11605a5d4..99c376001 100644 --- a/Desktop/Views/Pages/ToolsPage.xaml.cs +++ b/Desktop/Views/Pages/ToolsPage.xaml.cs @@ -6,8 +6,6 @@ using Core.LogModule; using Core.Tools; using Desktop.Models; -using System.Collections.ObjectModel; -using System.ComponentModel; using System.Windows; namespace Desktop.Views.Pages; diff --git a/Desktop/Views/Windows/AddRoom.xaml.cs b/Desktop/Views/Windows/AddRoom.xaml.cs index eba0a1475..55ab8258c 100644 --- a/Desktop/Views/Windows/AddRoom.xaml.cs +++ b/Desktop/Views/Windows/AddRoom.xaml.cs @@ -1,28 +1,7 @@ using Core; -using Desktop.Models; using Masuit.Tools; -using Microsoft.AspNetCore.Http.HttpResults; -using Net.Codecrete.QrCodeGenerator; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; using Wpf.Ui.Controls; -using static Desktop.Views.Pages.DataPage; -using static System.Net.Mime.MediaTypeNames; namespace Desktop.Views.Windows { @@ -52,7 +31,7 @@ public AddRoom(Mode mode) RoomId_TextBox.PlaceholderText = "请输入房间号"; break; case Mode.UidNumberMode: - RoomId_TextBox.PlaceholderText = "请输入UID,多个UID请使用逗号分割"; + RoomId_TextBox.PlaceholderText = "请输入UID,多个UID请使用逗号分割"; break; } } @@ -73,7 +52,7 @@ private void RemindChechBox_Click(object sender, RoutedEventArgs e) { if ((bool)RemindChechBox.IsChecked) { - _IsRemind= true; + _IsRemind = true; } else { @@ -85,7 +64,7 @@ private void RecDanmuChechBox_Click(object sender, RoutedEventArgs e) { if ((bool)RecDanmuChechBox.IsChecked) { - _IsDanmu = true; + _IsDanmu = true; } else { @@ -156,8 +135,8 @@ private void AddRoomSave_Click(object sender, RoutedEventArgs e) } case Mode.UidNumberMode: { - string UidStr = RoomId_TextBox.Text.Replace(",",","); - List UidList= new List(); + string UidStr = RoomId_TextBox.Text.Replace(",", ","); + List UidList = new List(); if (string.IsNullOrEmpty(UidStr)) { System.Windows.MessageBox.Show("请输入房间号"); diff --git a/Desktop/Views/Windows/DanMuCanvas/BarrageParameters/BarrageConfig.cs b/Desktop/Views/Windows/DanMuCanvas/BarrageParameters/BarrageConfig.cs index e92433892..9020e23e3 100644 --- a/Desktop/Views/Windows/DanMuCanvas/BarrageParameters/BarrageConfig.cs +++ b/Desktop/Views/Windows/DanMuCanvas/BarrageParameters/BarrageConfig.cs @@ -1,11 +1,6 @@ using Core; using Desktop.Views.Windows.DanMuCanvas.Models; -using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media; @@ -37,7 +32,7 @@ public class BarrageConfig #endregion #region 初始化 - public BarrageConfig(Canvas canvas,double width) + public BarrageConfig(Canvas canvas, double width) { //InitializeColors(); this.canvas = canvas; @@ -69,11 +64,11 @@ public void Barrage_Stroke(MessageInformation contentlist, int Index, bool IsSub grid.Children.Add(strokeTextBlock); } TextBlock textblock = new TextBlock(); - if(File.Exists("./typeface.ttf")) + if (File.Exists("./typeface.ttf")) { textblock.FontFamily = new FontFamily(new Uri("file:///" + System.IO.Path.GetFullPath("./")), "./#typeface"); } - + if (!string.IsNullOrEmpty(contentlist.nickName)) { textblock.Text = $"{contentlist.nickName}:{contentlist.content}"; diff --git a/Desktop/Views/Windows/DanMuCanvas/Models/GetMessageInformationResult.cs b/Desktop/Views/Windows/DanMuCanvas/Models/GetMessageInformationResult.cs index 505465326..fae2ded24 100644 --- a/Desktop/Views/Windows/DanMuCanvas/Models/GetMessageInformationResult.cs +++ b/Desktop/Views/Windows/DanMuCanvas/Models/GetMessageInformationResult.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Desktop.Views.Windows.DanMuCanvas.Models +namespace Desktop.Views.Windows.DanMuCanvas.Models { public class GetMessageInformationResult { diff --git a/Desktop/Views/Windows/DanMuCanvas/Models/MessageInformation.cs b/Desktop/Views/Windows/DanMuCanvas/Models/MessageInformation.cs index f7557d8dd..cf783a5ae 100644 --- a/Desktop/Views/Windows/DanMuCanvas/Models/MessageInformation.cs +++ b/Desktop/Views/Windows/DanMuCanvas/Models/MessageInformation.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Desktop.Views.Windows.DanMuCanvas.Models +namespace Desktop.Views.Windows.DanMuCanvas.Models { public class MessageInformation { diff --git a/Desktop/Views/Windows/DanmaOnlyWindow.xaml.cs b/Desktop/Views/Windows/DanmaOnlyWindow.xaml.cs index fb440405c..95c71061d 100644 --- a/Desktop/Views/Windows/DanmaOnlyWindow.xaml.cs +++ b/Desktop/Views/Windows/DanmaOnlyWindow.xaml.cs @@ -1,23 +1,12 @@ using Core.LiveChat; -using Core.LogModule; using Core.RuntimeObject; using Notification.Wpf; -using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Interop; using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; using Wpf.Ui.Controls; namespace Desktop.Views.Windows @@ -60,7 +49,7 @@ public DanmaOnlyWindow(RoomCardClass Card) Dispatcher.Invoke(() => { DanmaCollection.Add(new DanmaOnly { Message = $"等待直播间消息中..." }); - }); + }); }); } @@ -165,7 +154,7 @@ private void DanmaView_ContextMenuOpening(object sender, ContextMenuEventArgs e) private void Send_Danma_Button_Click(object sender, RoutedEventArgs e) { string T = DanmaOnly_DanmaInput.Text; - if(string.IsNullOrEmpty(T) && T.Length>20) + if (string.IsNullOrEmpty(T) && T.Length > 20) { return; } @@ -176,7 +165,7 @@ private void Send_Danma_Button_Click(object sender, RoutedEventArgs e) private void DanmaOnly_DanmaInput_TextChanged(object sender, TextChangedEventArgs e) { System.Windows.Controls.TextBox? textBox = sender as System.Windows.Controls.TextBox; - if (textBox!=null && textBox.Text.Length > 20) + if (textBox != null && textBox.Text.Length > 20) { int selectionStart = textBox.SelectionStart; textBox.Text = textBox.Text.Substring(0, 20); diff --git a/Desktop/Views/Windows/QrLogin.xaml.cs b/Desktop/Views/Windows/QrLogin.xaml.cs index 5d5e4f019..7929e70dc 100644 --- a/Desktop/Views/Windows/QrLogin.xaml.cs +++ b/Desktop/Views/Windows/QrLogin.xaml.cs @@ -1,27 +1,10 @@ using Core; using Core.LogModule; -using Desktop.Models; using Net.Codecrete.QrCodeGenerator; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Drawing; using System.IO; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; using System.Windows.Media.Imaging; -using System.Windows.Shapes; using Wpf.Ui.Controls; -using static Desktop.Views.Pages.DataPage; -using static System.Net.Mime.MediaTypeNames; namespace Desktop.Views.Windows { diff --git a/Desktop/Views/Windows/VlcPlayWindow.xaml.cs b/Desktop/Views/Windows/VlcPlayWindow.xaml.cs index 731cf9600..50412ba35 100644 --- a/Desktop/Views/Windows/VlcPlayWindow.xaml.cs +++ b/Desktop/Views/Windows/VlcPlayWindow.xaml.cs @@ -6,34 +6,15 @@ using Desktop.Views.Windows.DanMuCanvas.BarrageParameters; using LibVLCSharp.Shared; using LibVLCSharp.WPF; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.Extensions.DependencyInjection; using Notification.Wpf; -using SharpCompress.Common; -using SkiaSharp; -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Channels; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Controls.Primitives; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -using Wpf.Ui; using Wpf.Ui.Controls; using static Core.Config; -using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip; -using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar; using Key = System.Windows.Input.Key; using MenuItem = Wpf.Ui.Controls.MenuItem; @@ -75,6 +56,10 @@ public partial class VlcPlayWindow : FluentWindow /// 当前窗口的清晰度 /// public long CurrentWindowClarity = 10000; + /// + /// 宽高比是否初始化 + /// + public bool InitializeAspectRatio = false; public class DanMuOrbitInfo { public string Text { get; set; } @@ -115,6 +100,10 @@ public VlcPlayWindow(long uid) Task.Run(() => InitVlcPlay(uid)); Task.Run(() => SetClarityMenu()); } + /// + /// 初始化播放器和弹幕渲染Canvas + /// + /// public void InitVlcPlay(long uid) { PlaySteam(null); @@ -132,6 +121,9 @@ public void InitVlcPlay(long uid) }); } + /// + /// 获取和设置分辨率选项 + /// private void SetClarityMenu() { List DefinitionList = Core.RuntimeObject.Download.Basics.GetOptionalClarity(roomCard.RoomId, "http_hls", "fmp4", "avc"); @@ -169,7 +161,7 @@ private void SetClarityMenu() private void ModifyResolutionRightClickMenuEvent_Click(object sender, RoutedEventArgs e) { MenuItem clickedMenuItem = sender as MenuItem; - + Dispatcher.Invoke(() => { CurrentWindowClarity = (long)clickedMenuItem.Tag; // 获取被点击的菜单项的索引 @@ -188,6 +180,31 @@ private void MediaPlayer_Playing(object? sender, EventArgs e) Thread.Sleep(3000); vlcPlayModels.LoadingVisibility = Visibility.Collapsed; vlcPlayModels.OnPropertyChanged("LoadingVisibility"); + //初始化宽高比 + if (!InitializeAspectRatio) + { + if (_mediaPlayer != null && _mediaPlayer.Media != null && _mediaPlayer.Media.Tracks.Length > 0) + { + try + { + var videoWidth = _mediaPlayer.Media.Tracks[0].Data.Video.Width; + var videoHeight = _mediaPlayer.Media.Tracks[0].Data.Video.Height; + if (videoHeight > videoWidth) + { + Dispatcher.Invoke(() => + { + this.Width = 450; + this.Height = 800; + }); + + } + } + catch (Exception) { } + InitializeAspectRatio = true; + } + + + } }); } diff --git a/Desktop/Views/Windows/WebPlayWindow.xaml.cs b/Desktop/Views/Windows/WebPlayWindow.xaml.cs index 3cfda4687..a0e320fd7 100644 --- a/Desktop/Views/Windows/WebPlayWindow.xaml.cs +++ b/Desktop/Views/Windows/WebPlayWindow.xaml.cs @@ -1,21 +1,6 @@ using Core.LogModule; using Core.RuntimeObject; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Security.Cryptography; -using System.Security.Policy; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; using Wpf.Ui.Controls; namespace Desktop.Views.Windows @@ -36,11 +21,11 @@ public WebPlayWindow(long room_id) Task.Run(() => { _uid = RoomInfo.GetUid(_room_id); - + _nickname = RoomInfo.GetNickname(_uid); Dispatcher.Invoke(() => { - this.Title = RoomInfo.GetTitle(_uid); + this.Title = RoomInfo.GetTitle(_uid); UI_TitleBar.Title = $"{_nickname}({_room_id}) - {this.Title}(该直播间只有FLV流,使用WEB兼容模式播放)"; }); }); diff --git a/Desktop/WindowsAPI.cs b/Desktop/WindowsAPI.cs index 705d0b62e..48ad224bb 100644 --- a/Desktop/WindowsAPI.cs +++ b/Desktop/WindowsAPI.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; +using System.Runtime.InteropServices; namespace Desktop {