diff --git a/DBObj/SQLManager.cs b/DBObj/SQLManager.cs index 250dcaa..afd876e 100644 --- a/DBObj/SQLManager.cs +++ b/DBObj/SQLManager.cs @@ -71,7 +71,7 @@ namespace DBObj } public List SearchSongsByName(string keyword) { - string query = $"SELECT * FROM song_library_cache WHERE LOWER(song_name) LIKE CONCAT('%', LOWER('{keyword}'), '%');"; + string query = $"SELECT * FROM song_library_cache WHERE LOWER(song_name) LIKE CONCAT('%', LOWER('{keyword}'), '%') ORDER BY song_name DESC;"; return select_Mysql(query); } public SongData SearchSongByNumber(string songNumber) diff --git a/DBObj/SongList.cs b/DBObj/SongList.cs index 9e248e2..b26f30a 100644 --- a/DBObj/SongList.cs +++ b/DBObj/SongList.cs @@ -1,6 +1,7 @@ using DualScreenDemo; using System; using System.IO; +using System.Numerics; using System.Windows.Navigation; namespace DBObj { @@ -8,10 +9,10 @@ namespace DBObj { private static bool isWelcome = true; public static SongData welcome; - public static SongData close ; - private static SongData publicPlaying=null; + public static SongData close; + private static SongData publicPlaying = null; private static List publicSong = new(); - private static SongData playing=null; + private static SongData playing = null; private static List not_played = new List(); private static List played = new List(); public static List PublicSong() => publicSong; @@ -19,7 +20,7 @@ namespace DBObj public static SongData Current() { Console.WriteLine(not_played.Count + " Current " + playing); - return (playing ==null) ? publicPlaying : playing; + return (playing == null) ? publicPlaying : playing; } public static SongData Next() { @@ -57,17 +58,22 @@ namespace DBObj } private static SongData NextPublicSong() { - if (Program.room.IsClose()) { + if (Program.room.IsClose()) + { publicPlaying = close; - } else if(Program.room.IsOpen() && isWelcome){ + } + else if (Program.room.IsOpen() && isWelcome) + { isWelcome = false; publicPlaying = welcome; - } else { + } + else + { publicPlaying = publicSong[0]; publicSong.RemoveAt(0); publicSong.Add(publicPlaying); } - + return publicPlaying; } @@ -91,19 +97,28 @@ namespace DBObj { played.Add(new SongData(song, PlayState.NoFile)); } - + } + + public static void Cancel(SongData song) + { + not_played.Remove(song); + played.Remove(song); + chkCut(); + } + public static void Insert(SongData song) { - if (song.FileExistsInServers()) { - not_played.Insert(0, new SongData(song,PlayState.InsertPlayback)); + if (song.FileExistsInServers()) + { + not_played.Insert(0, new SongData(song, PlayState.InsertPlayback)); chkCut(); } else { played.Add(new SongData(song, PlayState.NoFile)); } - + } private static void chkCut() { @@ -113,21 +128,26 @@ namespace DBObj PrimaryForm.Instance.Invoke(new System.Action(() => PrimaryForm.Instance.videoPlayerForm.PlayNextSong())); else PrimaryForm.Instance.videoPlayerForm.PlayNextSong(); - } else { + } + else + { UpdateNextSongLabel(); } } - + public static void UpdateNextSongLabel() { - if (Program.room.IsClose()) { + if (Program.room.IsClose()) + { VideoPlayerForm.overlayForm.UpdateTopLeftLabel(" "); - } else { + } + else + { VideoPlayerForm.overlayForm.UpdateTopLeftLabel( (not_played.Count > 0) ? not_played[0].next_song_text() : "目前沒有下一首,請踴躍點歌!!!" ); } - + } public static void roomClose() { @@ -147,6 +167,6 @@ namespace DBObj not_played.Clear(); played.Clear(); } - + } } diff --git a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.ChinaSongs.cs b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.ChinaSongs.cs index a62302c..fd9f3fd 100644 --- a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.ChinaSongs.cs +++ b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.ChinaSongs.cs @@ -5,7 +5,7 @@ namespace DualScreenDemo private void ChinaSongsButton_Click(object sender, EventArgs e) { ResetCatBtnStatus(); - + chinaSongsButton.BackgroundImage = chinaActiveBackground; /*chinaSongs = allSongs.Where(song => song.SongGenre.Contains("F1")) .OrderByDescending(song => song.Plays) .ToList();*/ diff --git a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.LoveDuet.cs b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.LoveDuet.cs index ea75180..6a57eac 100644 --- a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.LoveDuet.cs +++ b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.LoveDuet.cs @@ -6,7 +6,7 @@ namespace DualScreenDemo { ResetCatBtnStatus(); - + loveDuetButton.BackgroundImage = loveDuetActiveBackground; /*loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1")) .OrderByDescending(song => song.Plays) .ToList();*/ diff --git a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.MedleyDance.cs b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.MedleyDance.cs index 10bca0b..06f24d9 100644 --- a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.MedleyDance.cs +++ b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.MedleyDance.cs @@ -5,7 +5,7 @@ namespace DualScreenDemo private void MedleyDanceButton_Click(object sender, EventArgs e) { ResetCatBtnStatus(); - + medleyDanceButton.BackgroundImage = medleyDanceActiveBackground; /*medleyDanceSongs = allSongs.Where(song => song.SongGenre.Contains("C1")) .OrderByDescending(song => song.Plays) .ToList();*/ diff --git a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.Nineties.cs b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.Nineties.cs index a0a37cb..c0a5c1a 100644 --- a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.Nineties.cs +++ b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.Nineties.cs @@ -5,7 +5,7 @@ namespace DualScreenDemo private void NinetiesButton_Click(object sender, EventArgs e) { ResetCatBtnStatus(); - + ninetiesButton.BackgroundImage = ninetiesActiveBackground; /*ninetiesSongs = allSongs.Where(song => song.SongGenre.Contains("D1")) .OrderByDescending(song => song.Plays) .ToList();*/ diff --git a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.NostalgicSongs.cs b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.NostalgicSongs.cs index c26ae74..4bd2ed5 100644 --- a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.NostalgicSongs.cs +++ b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.NostalgicSongs.cs @@ -5,7 +5,7 @@ namespace DualScreenDemo private void NostalgicSongsButton_Click(object sender, EventArgs e) { ResetCatBtnStatus(); - + nostalgicSongsButton.BackgroundImage = nostalgicSongsActiveBackground; /*nostalgicSongs = allSongs.Where(song => song.SongGenre.Contains("E1")) .OrderByDescending(song => song.Plays) .ToList();*/ diff --git a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.TalentShow.cs b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.TalentShow.cs index ee43cb9..3674e55 100644 --- a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.TalentShow.cs +++ b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.TalentShow.cs @@ -5,7 +5,7 @@ namespace DualScreenDemo private void TalentShowButton_Click(object sender, EventArgs e) { ResetCatBtnStatus(); - + talentShowButton.BackgroundImage = talentShowActiveBackground; /*talentShowSongs = allSongs.Where(song => song.SongGenre.Contains("B1")) .OrderByDescending(song => song.Plays) .ToList();*/ diff --git a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.VietnameseSongs.cs b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.VietnameseSongs.cs index 1dd7596..4a05b7f 100644 --- a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.VietnameseSongs.cs +++ b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.VietnameseSongs.cs @@ -4,8 +4,8 @@ namespace DualScreenDemo { private void VietnameseSongsButton_Click(object sender, EventArgs e) { - ResetCatBtnStatus(); - + ResetCatBtnStatus(); + vietnameseSongsButton.BackgroundImage = vietnameseActiveBackground; /*vietnameseSongs = allSongs.Where(song => song.SongGenre.Contains("G1")) .OrderByDescending(song => song.Plays) .ToList();*/ diff --git a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.cs b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.cs index 8daa23d..e863625 100644 --- a/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.cs +++ b/PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.cs @@ -62,91 +62,23 @@ namespace DualScreenDemo private void InitializeCategorySearchButtons() { - - loveDuetNormalBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_男女情歌(未按).png")); - talentShowNormalBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_選秀節目(未按).png")); - medleyDanceNormalBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_串燒舞曲(未按).png")); - ninetiesNormalBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_90年代(未按).png")); - nostalgicSongsNormalBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_懷舊老歌(未按).png")); - chinaNormalBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_中國大陸(未按).png")); - vietnameseNormalBackground= new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_越南歌曲(未按).png")); - - loveDuetActiveBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_男女情歌(已按).png")); - talentShowActiveBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_選秀節目(已按).png")); - medleyDanceActiveBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_串燒舞曲(已按).png")); - ninetiesActiveBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_90年代(已按).png")); - nostalgicSongsActiveBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_懷舊老歌(已按).png")); - chinaActiveBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_中國大陸(已按).png")); - vietnameseActiveBackground= new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_越南歌曲(已按).png")); - - loveDuetButton = new Button { Text = "", Visible = false }; - ConfigureButton(loveDuetButton, 1197, 225, 225, 50, - loveDuetNormalBackground, - loveDuetNormalBackground, - loveDuetActiveBackground, - LoveDuetButton_Click); - - loveDuetButton.MouseLeave += (sender, e) => loveDuetButton.BackgroundImage = loveDuetActiveBackground; + var data = LoadBtnConfigData(); - talentShowButton = new Button { Text = "", Visible = false }; - ConfigureButton(talentShowButton, 1197, 280, 225, 50, - talentShowNormalBackground, - talentShowNormalBackground, - talentShowNormalBackground, - TalentShowButton_Click); + InitializeButton(ref loveDuetButton, ref loveDuetNormalBackground, ref loveDuetActiveBackground, "loveDuetButton", 1197, 225, 225, 50, data["CategorySubBtn"]["LoveDuetNormal"], data["CategorySubBtn"]["LoveDuetActive"], LoveDuetButton_Click); - talentShowButton.MouseLeave += (sender, e) => talentShowButton.BackgroundImage = talentShowActiveBackground; + InitializeButton(ref talentShowButton, ref talentShowNormalBackground, ref talentShowActiveBackground, "talentShowButton", 1197, 280, 225, 50, data["CategorySubBtn"]["TalentNormal"], data["CategorySubBtn"]["TalentActive"], TalentShowButton_Click); + InitializeButton(ref medleyDanceButton, ref medleyDanceNormalBackground, ref medleyDanceActiveBackground, "medleyDanceButton", 1197, 335, 225, 50, data["CategorySubBtn"]["MedleyNormal"], data["CategorySubBtn"]["MedleyActive"], MedleyDanceButton_Click); - medleyDanceButton = new Button { Text = "", Visible = false }; - ConfigureButton(medleyDanceButton, 1197, 335, 225, 50, - medleyDanceNormalBackground, - medleyDanceNormalBackground, - medleyDanceNormalBackground, - MedleyDanceButton_Click); + InitializeButton(ref ninetiesButton, ref ninetiesNormalBackground, ref ninetiesActiveBackground, "ninetiesButton", 1197, 390, 225, 50, data["CategorySubBtn"]["NintiesNormail"], data["CategorySubBtn"]["NintiesActive"], NinetiesButton_Click); - medleyDanceButton.MouseLeave += (sender, e) => medleyDanceButton.BackgroundImage = medleyDanceActiveBackground; + InitializeButton(ref nostalgicSongsButton, ref nostalgicSongsNormalBackground, ref nostalgicSongsActiveBackground, "nostalgicSongsButton", 1197, 445, 225, 50, data["CategorySubBtn"]["NostalgicNormal"], data["CategorySubBtn"]["NostalgicActive"], NostalgicSongsButton_Click); + InitializeButton(ref chinaSongsButton, ref chinaNormalBackground, ref chinaActiveBackground, "chinaSongsButton", 1197, 500, 225, 50, data["CategorySubBtn"]["ChinaNormal"], data["CategorySubBtn"]["ChinaActive"], ChinaSongsButton_Click); - ninetiesButton = new Button { Text = "", Visible = false }; - ConfigureButton(ninetiesButton, 1197, 390, 225, 50, - ninetiesNormalBackground, - ninetiesNormalBackground, - ninetiesNormalBackground, - NinetiesButton_Click); + InitializeButton(ref vietnameseSongsButton, ref vietnameseNormalBackground, ref vietnameseActiveBackground, "vietnameseSongsButton", 1197, 555, 225, 50, data["CategorySubBtn"]["VietNormal"], data["CategorySubBtn"]["VietActive"], VietnameseSongsButton_Click); - ninetiesButton.MouseLeave += (sender, e) => ninetiesButton.BackgroundImage = ninetiesActiveBackground; - - - nostalgicSongsButton = new Button { Text = "", Visible = false }; - ConfigureButton(nostalgicSongsButton, 1197, 445, 225, 50, - nostalgicSongsNormalBackground, - nostalgicSongsNormalBackground, - nostalgicSongsNormalBackground, - NostalgicSongsButton_Click); - - nostalgicSongsButton.MouseLeave += (sender, e) => nostalgicSongsButton.BackgroundImage = nostalgicSongsActiveBackground; - - - chinaSongsButton = new Button { Text = "", Visible = false }; - ConfigureButton(chinaSongsButton, 1197, 500, 225, 50, - chinaNormalBackground, - chinaNormalBackground, - chinaNormalBackground, - ChinaSongsButton_Click); - - chinaSongsButton.MouseLeave += (sender, e) => chinaSongsButton.BackgroundImage = chinaActiveBackground; - - - vietnameseSongsButton = new Button { Text = "", Visible = false }; - ConfigureButton(vietnameseSongsButton, 1197, 555, 225, 50, - vietnameseNormalBackground, - vietnameseNormalBackground, - vietnameseNormalBackground, - VietnameseSongsButton_Click); - - vietnameseSongsButton.MouseLeave += (sender, e) => vietnameseSongsButton.BackgroundImage = vietnameseActiveBackground; } @@ -154,7 +86,6 @@ namespace DualScreenDemo { ResetPrimaryBtnStatus(); - //categorySearchButton.BackgroundImage = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別上方_類別查詢(已按).png")); categorySearchButton.BackgroundImage = categorySearchActiveBackground; isOnOrderedSongsPage = false; diff --git a/PrimaryFormParts/PrimaryForm.VodScreen.cs b/PrimaryFormParts/PrimaryForm.VodScreen.cs index f977cac..89f28ec 100644 --- a/PrimaryFormParts/PrimaryForm.VodScreen.cs +++ b/PrimaryFormParts/PrimaryForm.VodScreen.cs @@ -23,16 +23,32 @@ namespace DualScreenDemo int yPosition = (screenHeight - pictureBoxHeight) / 2; var data=LoadConfigData(); - - vodButton = new Button(); - vodButton.Text = ""; - ConfigureButton(vodButton, xPosition - 119, yPosition + 35, 110, 50, - new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\3.介面\\歌曲點播_點播.png")), - new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\3.介面\\歌曲點播_點播.png")), - new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\3.介面\\歌曲點播_點播.png")), - VodButton_Click); - vodButton.Visible = false; + if (isOnOrderedSongsPage) + { + vodButton = new Button(); + vodButton.Text = ""; + ConfigureButton(vodButton, xPosition - 119, yPosition + 35, 110, 50, + new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\3.介面\\歌曲點播-08.png")), + new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\3.介面\\歌曲點播-08.png")), + new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\3.介面\\歌曲點播-08.png")), + VodButton_Click); + + vodButton.Visible = false; + } + else + { + vodButton = new Button(); + vodButton.Text = ""; + ConfigureButton(vodButton, xPosition - 119, yPosition + 35, 110, 50, + new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\3.介面\\歌曲點播_點播.png")), + new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\3.介面\\歌曲點播_點播.png")), + new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\3.介面\\歌曲點播_點播.png")), + VodButton_Click); + + vodButton.Visible = false; + } + insertButton = new Button(); @@ -100,8 +116,18 @@ namespace DualScreenDemo } private void VodButton_Click(object sender, EventArgs e) { - SetVodScreenPictureBoxAndButtonsVisibility(false); - SongList.Add(currentSelectedSong); + if (isOnOrderedSongsPage) + { + SetVodScreenPictureBoxAndButtonsVisibility(false); + SongList.Cancel(currentSelectedSong); + orderedSongsButton.PerformClick(); + } + else + { + SetVodScreenPictureBoxAndButtonsVisibility(false); + SongList.Add(currentSelectedSong); + } + } private void InsertButton_Click(object sender, EventArgs e)