包廂號調整+同步畫面服務鈴調整

This commit is contained in:
jasonchenwork 2025-05-02 10:29:50 +08:00
parent 19a672eef0
commit c5a93a0828
3 changed files with 28 additions and 25 deletions

View File

@ -1059,40 +1059,43 @@ namespace DualScreenDemo
// 启动服务器的公共方法 // 启动服务器的公共方法
private static async Task HandleFavoriteRequest(HttpListenerContext context) private static async Task HandleFavoriteRequest(HttpListenerContext context)
{ {
/* try try
{ {
if (PrimaryForm.isPhoneNumberValid && !string.IsNullOrEmpty(PrimaryForm.phonenumber)) if (PrimaryForm.isPhoneNumberValid && !string.IsNullOrEmpty(PrimaryForm.Instance.userPhone))
{ {
string phone = PrimaryForm.phonenumber; // 直接通过类名访问 //string phone = PrimaryForm.phonenumber; // 直接通过类名访问
// 登录用户 // 登录用户
SongListManager.Instance.UserLogin(phone); //SongListManager.Instance.UserLogin(phone);
// 获取用户的收藏歌曲 // 获取用户的收藏歌曲
var favoriteSongs = SongListManager.Instance.GetFavoriteSongsByPhoneNumber(); var favoriteSongs=new List<SongData>(); //= SongListManager.Instance.GetFavoriteSongsByPhoneNumber();
string query =PrimaryForm.Instance.SearchFavoriteSongs_Mysql();
var searchResults = PrimaryForm.Instance.SearchSongs_Mysql(query);
// 创建响应数据 // 创建响应数据
var response = new var response = new
{ {
isLoggedIn = true, isLoggedIn = true,
favoriteSongList = favoriteSongs
favoriteSongList = searchResults
.Select(song => new .Select(song => new
{ {
song.Song, song.Song,
song.ArtistA, song.ArtistA,
song.SongNumber, song.SongNumber,
song.Category, //song.Category,
song.PhoneticNotation, //song.PhoneticNotation,
song.PinyinNotation, //song.PinyinNotation,
song.ArtistAPhonetic, //song.ArtistAPhonetic,
song.ArtistBPhonetic, //song.ArtistBPhonetic,
song.ArtistASimplified, song.ArtistASimplified,
song.ArtistBSimplified, song.ArtistBSimplified,
song.SongSimplified, song.SongSimplified,
song.SongGenre, //song.SongGenre,
song.ArtistAPinyin, //song.ArtistAPinyin,
song.ArtistBPinyin, //song.ArtistBPinyin,
song.HumanVoice, song.HumanVoice,
song.AddedTime, //song.AddedTime,
song.SongFilePathHost1, song.SongFilePathHost1,
song.SongFilePathHost2 // 例如语言类别等信息 song.SongFilePathHost2 // 例如语言类别等信息
}) })
@ -1143,11 +1146,11 @@ namespace DualScreenDemo
context.Response.ContentType = "application/json"; context.Response.ContentType = "application/json";
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
await SendResponseAsyncs(context, jsonResponse); await SendResponseAsyncs(context, jsonResponse);
}*/ }
} }
// 异步响应发送方法 // 异步响应发送方法
/*
private static async Task SendResponseAsyncs(HttpListenerContext context, string responseContent) private static async Task SendResponseAsyncs(HttpListenerContext context, string responseContent)
{ {
try try
@ -1162,7 +1165,7 @@ namespace DualScreenDemo
Console.WriteLine("Error sending response: " + ex.Message); Console.WriteLine("Error sending response: " + ex.Message);
} }
} }
*/
private static async Task HandleGetRequest(HttpListenerContext context, string baseDirectory, string requestedFile) private static async Task HandleGetRequest(HttpListenerContext context, string baseDirectory, string requestedFile)
{ {
try try

View File

@ -46,10 +46,11 @@ namespace DualScreenDemo
// 同步畫面 服務鈴
ConfigureButton(this.syncServiceBellButton, 1240, 17, 161, 161, ConfigureButton(this.syncServiceBellButton, 1240, 17, 161, 161,
resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen,
(sender, e) => SendCommandThroughSerialPort("a2 53 a4")); //(sender, e) => SendCommandThroughSerialPort("a2 53 a4"));
(sender,e)=>OnServiceBellButtonClick(sender,e));

View File

@ -264,7 +264,7 @@ namespace DualScreenDemo
// 顯示包廂名稱 // 顯示包廂名稱
// 取主機名稱的最後 20 個字元 (如果長度不足 20則取全部) // 取主機名稱的最後 20 個字元 (如果長度不足 20則取全部)
string displayName = "包廂" + hostName.Substring(Math.Max(0, hostName.Length - 20)); string displayName = "包廂" + hostName.Substring(Math.Max(0, hostName.Length - 3));
string totalPages = multiPagePanel.totalPages.ToString() == "0" ? "1" : multiPagePanel.totalPages.ToString(); string totalPages = multiPagePanel.totalPages.ToString() == "0" ? "1" : multiPagePanel.totalPages.ToString();
string pageNumber = (multiPagePanel.currentPageIndex + 1).ToString() + "/" + totalPages; string pageNumber = (multiPagePanel.currentPageIndex + 1).ToString() + "/" + totalPages;
@ -895,8 +895,6 @@ namespace DualScreenDemo
{ {
try try
{ {
byte[] commandBytes = HexStringToByteArray(command); byte[] commandBytes = HexStringToByteArray(command);
SerialPortManager.mySerialPort.Write(commandBytes, 0, commandBytes.Length); SerialPortManager.mySerialPort.Write(commandBytes, 0, commandBytes.Length);
} }
@ -2229,6 +2227,7 @@ namespace DualScreenDemo
} }
private bool isWaiting = false; private bool isWaiting = false;
//服務鈴事件
private async void OnServiceBellButtonClick(object sender, EventArgs e) private async void OnServiceBellButtonClick(object sender, EventArgs e)
{ {
if (isWaiting) return; if (isWaiting) return;
@ -2390,7 +2389,7 @@ namespace DualScreenDemo
float scaledFontSize = 84f * scaleY; float scaledFontSize = 84f * scaleY;
string hostName = System.Net.Dns.GetHostName(); string hostName = System.Net.Dns.GetHostName();
string displayName = "包廂" + hostName.Substring(Math.Max(0, hostName.Length - 20)); string displayName = "包廂" + hostName.Substring(Math.Max(0, hostName.Length - 3));
using (Font font = new Font("微軟正黑體", scaledFontSize, FontStyle.Bold)) using (Font font = new Font("微軟正黑體", scaledFontSize, FontStyle.Bold))
using (Brush brush = new SolidBrush(Color.Red)) using (Brush brush = new SolidBrush(Color.Red))