superstar_v2/PrimaryFormParts/PrimaryForm.VodScreen.cs

190 lines
7.5 KiB
C#

using System.IO;
using DBObj;
namespace DualScreenDemo
{
public partial class PrimaryForm
{
private Button vodButton;
private Button insertButton;
private Button albumButton;
private Button favoriteButton;
private Panel disabledPanel;
private Button vodScreenCloseButton;
private void InitializeButtonsForVodScreenPictureBox()
{
int screenWidth = 1920;
int screenHeight = 1080;
int pictureBoxWidth = 938;
int pictureBoxHeight = 209;
int xPosition = (screenWidth - pictureBoxWidth) / 2;
int yPosition = (screenHeight - pictureBoxHeight) / 2;
var data = LoadBtnConfigData();
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();
insertButton.Text = "";
ConfigureButton(insertButton, xPosition + 12, 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")),
InsertButton_Click);
insertButton.Visible = false;
albumButton = new Button();
albumButton.Text = "";
ConfigureButton(albumButton, xPosition + 142, yPosition + 35, 140, 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")),
AlbumButton_Click);
albumButton.Visible = false;
favoriteButton = new Button();
favoriteButton.Text = "";
ConfigureButton(favoriteButton, xPosition + 302, yPosition + 35, 140, 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")),
FavoriteButton_Click);
disabledPanel = new Panel();
disabledPanel.BackColor = Color.FromArgb(128, Color.Black);
disabledPanel.Dock = DockStyle.Fill;
disabledPanel.Visible = !isLoggedIn;
favoriteButton.Controls.Add(disabledPanel);
if (!isLoggedIn)
{
favoriteButton.Enabled = false;
favoriteButton.BackColor = SystemColors.Control;
}
favoriteButton.Visible = isLoggedIn;
vodScreenCloseButton = new Button();
vodScreenCloseButton.Text = "";
ConfigureButton(vodScreenCloseButton, xPosition + 462, 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")),
VodScreenCloseButton_Click);
this.Controls.Add(vodButton);
this.Controls.Add(insertButton);
this.Controls.Add(albumButton);
this.Controls.Add(favoriteButton);
this.Controls.Add(vodScreenCloseButton);
}
private void VodButton_Click(object sender, EventArgs e)
{
if (isOnOrderedSongsPage)
{
SetVodScreenPictureBoxAndButtonsVisibility(false);
SongList.Cancel(currentSelectedSong);
orderedSongsButton.PerformClick();
}
else
{
SetVodScreenPictureBoxAndButtonsVisibility(false);
SongList.Add(currentSelectedSong);
}
}
private void InsertButton_Click(object sender, EventArgs e)
{
SetVodScreenPictureBoxAndButtonsVisibility(false);
SongList.Insert(currentSelectedSong);
}
private void AlbumButton_Click(object sender, EventArgs e)
{
string name = currentSelectedSong.getArtist_A(false);
string query = $"SELECT * FROM song_library_cache WHERE artistA = '{name}' ORDER BY add_date DESC;";
var selectedSongs = SearchSongs_Mysql(query);
/*var selectedSongs = allSongs.Where(song => song.ArtistA == currentSelectedSong.ArtistA)
.OrderByDescending(song => song.AddedTime)
.ToList();*/
UpdateSongList(selectedSongs);
SetVodScreenPictureBoxAndButtonsVisibility(false);
}
private void FavoriteButton_Click(object sender, EventArgs e)
{
Console.WriteLine("Favorite Button Clicked");
InsertNewFavoriteSong(currentSelectedSong.getNumber());
var searchResults = SearchSongs_Mysql(SearchFavoriteSongs_Mysql());
// 重置分頁
currentPage = 0;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
// 更新多頁面面板的內容
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSongs(searchResults);
SetVodScreenPictureBoxAndButtonsVisibility(false);
}
private void VodScreenCloseButton_Click(object sender, EventArgs e)
{
SetVodScreenPictureBoxAndButtonsVisibility(false);
}
private void SetVodScreenPictureBoxAndButtonsVisibility(bool isVisible)
{
overlayPanel.Visible = isVisible;
VodScreenPictureBox.Visible = isVisible;
vodButton.Visible = isVisible;
insertButton.Visible = isVisible;
albumButton.Visible = isVisible;
favoriteButton.Visible = isVisible;
vodScreenCloseButton.Visible = isVisible;
if (isVisible)
{
if (isLoggedIn)
{
favoriteButton.Enabled = true;
favoriteButton.Controls.Remove(disabledPanel);
}
else
{
favoriteButton.Enabled = false;
}
overlayPanel.BringToFront();
VodScreenPictureBox.BringToFront();
vodButton.BringToFront();
insertButton.BringToFront();
albumButton.BringToFront();
favoriteButton.BringToFront();
vodScreenCloseButton.BringToFront();
}
}
}
}