superstar_v2/PrimaryFormParts/PrimaryForm.VodScreen.cs

213 lines
8.8 KiB
C#
Raw Normal View History

2025-04-07 16:54:10 +08:00
using System.IO;
using DBObj;
using OverlayFormObj;
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;
2025-04-07 16:54:10 +08:00
int xPosition = (screenWidth - pictureBoxWidth) / 2;
int yPosition = (screenHeight - pictureBoxHeight) / 2;
vodButton = new Button();
vodButton.Text = "";
2025-04-17 15:53:19 +08:00
ResizeAndPositionButton(vodButton, xPosition - 119, yPosition + 35, 110, 50);
2025-04-07 16:54:10 +08:00
vodButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\點播介面\點播介面_點歌.png"));
vodButton.BackgroundImageLayout = ImageLayout.Stretch;
vodButton.FlatStyle = FlatStyle.Flat;
vodButton.FlatAppearance.BorderSize = 0;
vodButton.BackColor = Color.Transparent;
vodButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
vodButton.FlatAppearance.MouseOverBackColor = Color.Transparent;
vodButton.Click += VodButton_Click;
vodButton.Visible = false;
insertButton = new Button();
insertButton.Text = "";
2025-04-17 15:53:19 +08:00
ResizeAndPositionButton(insertButton, xPosition + 12 , yPosition + 35, 110, 50);
2025-04-07 16:54:10 +08:00
insertButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\點播介面\點播介面_插播.png"));
insertButton.BackgroundImageLayout = ImageLayout.Stretch;
insertButton.FlatStyle = FlatStyle.Flat;
insertButton.FlatAppearance.BorderSize = 0;
insertButton.BackColor = Color.Transparent;
insertButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
insertButton.FlatAppearance.MouseOverBackColor = Color.Transparent;
insertButton.Click += InsertButton_Click;
insertButton.Visible = false;
albumButton = new Button();
albumButton.Text = "";
2025-04-17 15:53:19 +08:00
ResizeAndPositionButton(albumButton, xPosition + 142, yPosition + 35, 140, 50);
2025-04-07 16:54:10 +08:00
albumButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\點播介面\點播介面_歷年專輯.png"));
albumButton.BackgroundImageLayout = ImageLayout.Stretch;
albumButton.FlatStyle = FlatStyle.Flat;
albumButton.FlatAppearance.BorderSize = 0;
albumButton.BackColor = Color.Transparent;
albumButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
albumButton.FlatAppearance.MouseOverBackColor = Color.Transparent;
albumButton.Click += AlbumButton_Click;
albumButton.Visible = false;
favoriteButton = new Button();
favoriteButton.Text = "";
2025-04-17 15:53:19 +08:00
ResizeAndPositionButton(favoriteButton, xPosition + 302, yPosition + 35, 140, 50);
2025-04-07 16:54:10 +08:00
favoriteButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\點播介面\點播介面_我的最愛.png"));
favoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
favoriteButton.FlatStyle = FlatStyle.Flat;
favoriteButton.FlatAppearance.BorderSize = 0;
favoriteButton.BackColor = Color.Transparent;
favoriteButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
favoriteButton.FlatAppearance.MouseOverBackColor = Color.Transparent;
disabledPanel = new Panel();
disabledPanel.BackColor = Color.FromArgb(128, Color.Black);
disabledPanel.Dock = DockStyle.Fill;
disabledPanel.Visible = !isLoggedIn;
2025-04-07 16:54:10 +08:00
favoriteButton.Controls.Add(disabledPanel);
favoriteButton.Click += FavoriteButton_Click;
if (!isLoggedIn) {
2025-04-07 16:54:10 +08:00
favoriteButton.Enabled = false;
favoriteButton.BackColor = SystemColors.Control;
}
favoriteButton.Visible = isLoggedIn;
2025-04-07 16:54:10 +08:00
vodScreenCloseButton = new Button();
vodScreenCloseButton.Text = "";
2025-04-17 15:53:19 +08:00
ResizeAndPositionButton(vodScreenCloseButton, xPosition + 462, yPosition + 35, 110, 50);
2025-04-07 16:54:10 +08:00
vodScreenCloseButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\點播介面\點播介面_關閉.png"));
vodScreenCloseButton.BackgroundImageLayout = ImageLayout.Stretch;
vodScreenCloseButton.FlatStyle = FlatStyle.Flat;
vodScreenCloseButton.FlatAppearance.BorderSize = 0;
vodScreenCloseButton.BackColor = Color.Transparent;
vodScreenCloseButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
vodScreenCloseButton.FlatAppearance.MouseOverBackColor = Color.Transparent;
vodScreenCloseButton.Click += VodScreenCloseButton_Click;
vodScreenCloseButton.Visible = false;
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)
{
2025-04-07 16:54:10 +08:00
OverlayForm.MainForm.AddSongToPlaylist(currentSelectedSong);
SetVodScreenPictureBoxAndButtonsVisibility(false);
}
private void InsertButton_Click(object sender, EventArgs e)
{
OverlayForm.MainForm.InsertSongToPlaylist(currentSelectedSong);
SetVodScreenPictureBoxAndButtonsVisibility(false);
}
private void AlbumButton_Click(object sender, EventArgs e)
{
2025-04-14 16:54:40 +08:00
string name = currentSelectedSong.ArtistA;
2025-04-22 15:25:58 +08:00
string query = $"SELECT * FROM song_library_cache WHERE artistA = '{name}' ORDER BY add_date DESC";
2025-04-14 16:54:40 +08:00
var selectedSongs = SearchSongs_Mysql(query);
/*var selectedSongs = allSongs.Where(song => song.ArtistA == currentSelectedSong.ArtistA)
2025-04-07 16:54:10 +08:00
.OrderByDescending(song => song.AddedTime)
2025-04-14 16:54:40 +08:00
.ToList();*/
2025-04-07 16:54:10 +08:00
UpdateSongList(selectedSongs);
SetVodScreenPictureBoxAndButtonsVisibility(false);
}
private void FavoriteButton_Click(object sender, EventArgs e)
{
Console.WriteLine("Favorite Button Clicked");
InsertNewFavoriteSong(currentSelectedSong.SongNumber);
var searchResults = SearchSongs_Mysql(SearchFavoriteSongs_Mysql());
// 重置分頁
currentPage = 0;
currentSongList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
// 更新多頁面面板的內容
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSongs(currentSongList);
2025-04-07 16:54:10 +08:00
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)
2025-04-07 16:54:10 +08:00
{
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();
}
}
}
}