我的最愛調整+點歌界面調整+包廂塗鴉調整
This commit is contained in:
parent
2ef9ec5075
commit
c3ca11a71c
@ -205,10 +205,19 @@ namespace DualScreenDemo
|
||||
{
|
||||
if (mobileNumber.StartsWith("09") && mobileNumber.Length == 10)
|
||||
{
|
||||
if (SongListManager.Instance.CheckIfPhoneNumberExists(mobileNumber))
|
||||
if (checkPhoneNumberExist(mobileNumber))
|
||||
{
|
||||
isPhoneNumberValid = true;
|
||||
SongListManager.Instance.UserLogin(mobileNumber);
|
||||
//SongListManager.Instance.UserLogin(mobileNumber);
|
||||
|
||||
var searchResults = SearchSongs_Mysql(SearchFavoriteSongs_Mysql());
|
||||
// 重置分頁
|
||||
currentPage = 0;
|
||||
currentSongList = searchResults;
|
||||
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
|
||||
// 更新多頁面面板的內容
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
|
||||
ToggleFavoritePictureBoxButtonsVisibility();
|
||||
}
|
||||
@ -234,23 +243,31 @@ namespace DualScreenDemo
|
||||
{
|
||||
if (mobileNumber.StartsWith("09") && mobileNumber.Length == 10)
|
||||
{
|
||||
if (SongListManager.Instance.CheckIfPhoneNumberExists(mobileNumber))
|
||||
if (checkPhoneNumberExist(mobileNumber))
|
||||
{
|
||||
isPhoneNumberValid = true;
|
||||
SongListManager.Instance.UserLogin(mobileNumber);
|
||||
var searchResults = SearchSongs_Mysql(SearchFavoriteSongs_Mysql());
|
||||
// 重置分頁
|
||||
currentPage = 0;
|
||||
currentSongList = searchResults;
|
||||
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
|
||||
// 更新多頁面面板的內容
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
|
||||
ToggleFavoritePictureBoxButtonsVisibility();
|
||||
}
|
||||
else
|
||||
{
|
||||
isPhoneNumberValid = true;
|
||||
/*isPhoneNumberValid = true;
|
||||
SongListManager.Instance.AddNewUser(mobileNumber);
|
||||
SongListManager.Instance.UserLogin(mobileNumber);
|
||||
|
||||
|
||||
List<SongData> emptySongList = new List<SongData> { new SongData("", "", "歡迎光臨 " + "(" + mobileNumber + ")", 0, "", "", "", "", DateTime.Now, "", "", "", "", "", "", "", "", "", "", "", "", 1) };
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(emptySongList);
|
||||
multiPagePanel.LoadSongs(emptySongList);*/
|
||||
ToggleFavoritePictureBoxButtonsVisibility();
|
||||
}
|
||||
}
|
||||
@ -276,8 +293,8 @@ namespace DualScreenDemo
|
||||
FavoritePictureBox.Invalidate();
|
||||
FavoritePictureBox.Refresh();
|
||||
|
||||
SongListManager.Instance.IsUserLoggedIn = false;
|
||||
SongListManager.Instance.UserPhoneNumber = string.Empty;
|
||||
//SongListManager.Instance.IsUserLoggedIn = false;
|
||||
//SongListManager.Instance.UserPhoneNumber = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,6 +7,8 @@ using System.Diagnostics;
|
||||
namespace DualScreenDemo{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
public bool isLoggedIn = false;
|
||||
public string userPhone = string.Empty;
|
||||
public List<SongData> SearchSongs_Mysql(string query)
|
||||
{
|
||||
List<SongData> searchResults = new List<SongData>();
|
||||
@ -90,7 +92,6 @@ namespace DualScreenDemo{
|
||||
|
||||
return searchResults;
|
||||
}
|
||||
|
||||
public List<Artist> SearchSingers_Mysql(string query){
|
||||
List<Artist> searchResults = new List<Artist>();
|
||||
Console.WriteLine(query);
|
||||
@ -132,6 +133,78 @@ namespace DualScreenDemo{
|
||||
return searchResults;
|
||||
|
||||
}
|
||||
public void InsertNewFavoriteSong(string songNumber){
|
||||
|
||||
string query = $"INSERT INTO FavoriteSongs (Phonenumber,SongNumber) VALUES ('{userPhone}','{songNumber}');";
|
||||
Console.WriteLine(query);
|
||||
string connectionString = "Server=192.168.11.4;Port=3306;Database=Karaoke-Kingpin;User=Karaoke-Kingpin;Password=ESM7yTPMnavFmbBH;";
|
||||
|
||||
using (var connection = new MySqlConnection(connectionString))
|
||||
{
|
||||
|
||||
connection.Open();
|
||||
Console.WriteLine("MyDB 連線成功!");
|
||||
|
||||
using (var command = new MySqlCommand(query, connection))
|
||||
{
|
||||
int rowsAffected = command.ExecuteNonQuery();
|
||||
if (rowsAffected > 0)
|
||||
{
|
||||
Console.WriteLine("插入成功!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("插入失敗(沒有資料被新增)");
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
Console.WriteLine("MyDB 連線已關閉!");
|
||||
}
|
||||
}
|
||||
public string SearchFavoriteSongs_Mysql(){
|
||||
string query = $"SELECT " +
|
||||
"sl.歌曲編號, sl.語別, sl.歌曲名稱, sl.點播次數, " +
|
||||
"sl.`歌星 A`, sl.`歌星 B`, sl.新增日期, " +
|
||||
"sl.`路徑 1`, sl.`路徑 2`, sl.歌曲檔名, sl.歌曲注音, sl.歌曲拼音, " +
|
||||
"sl.歌星A分類, sl.歌星B分類, sl.歌星A注音, sl.歌星B注音, " +
|
||||
"sl.歌星A簡體, sl.歌星B簡體, sl.歌名簡體, sl.分類, " +
|
||||
"sl.歌星A拼音, sl.歌星B拼音, sl.人聲 " +
|
||||
"FROM FavoriteSongs fs " +
|
||||
"JOIN SongLibrary sl ON fs.SongNumber = sl.歌曲編號 " +
|
||||
$"WHERE fs.Phonenumber = '{userPhone}';";
|
||||
return query;
|
||||
|
||||
}
|
||||
public bool checkPhoneNumberExist(string phonenumber){
|
||||
string connectionString = "Server=192.168.11.4;Port=3306;Database=Karaoke-Kingpin;User=Karaoke-Kingpin;Password=ESM7yTPMnavFmbBH;";
|
||||
bool exists = false;
|
||||
using (var connection = new MySqlConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
Console.WriteLine("MyDB 連線成功!");
|
||||
string query = $"SELECT COUNT(*) FROM FavoriteSongs WHERE Phonenumber = '{phonenumber}'";
|
||||
using (var command = new MySqlCommand(query, connection)){
|
||||
int count = Convert.ToInt32(command.ExecuteScalar());
|
||||
if (count > 0)
|
||||
{
|
||||
exists = true; // 存在
|
||||
userPhone= phonenumber;
|
||||
isLoggedIn = true;
|
||||
//點歌我的最愛按鈕,調整按鈕狀態
|
||||
favoriteButton.Enabled = true;
|
||||
favoriteButton.BackColor = Color.Transparent;
|
||||
disabledPanel.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
exists = false; // 不存在
|
||||
}
|
||||
}
|
||||
connection.Close();
|
||||
Console.WriteLine("MyDB 連線關閉!");
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
private int countforSearch = 0;
|
||||
private void writeLogforSearchTime(long elapsedMs){
|
||||
|
||||
|
@ -14,10 +14,10 @@ namespace DualScreenDemo
|
||||
|
||||
private void InitializeButtonsForVodScreenPictureBox()
|
||||
{
|
||||
int screenWidth = 1440;
|
||||
int screenHeight = 900;
|
||||
int pictureBoxWidth = 700;
|
||||
int pictureBoxHeight = 140;
|
||||
int screenWidth = 1920;
|
||||
int screenHeight = 1080;
|
||||
int pictureBoxWidth = 938;
|
||||
int pictureBoxHeight = 209;
|
||||
|
||||
int xPosition = (screenWidth - pictureBoxWidth) / 2;
|
||||
int yPosition = (screenHeight - pictureBoxHeight) / 2;
|
||||
@ -25,7 +25,7 @@ namespace DualScreenDemo
|
||||
|
||||
vodButton = new Button();
|
||||
vodButton.Text = "";
|
||||
ResizeAndPositionButton(vodButton, xPosition + 10, yPosition + 85, 110, 50);
|
||||
ResizeAndPositionButton(vodButton, xPosition - 119, yPosition + 40, 110, 50);
|
||||
vodButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\點播介面\點播介面_點歌.png"));
|
||||
vodButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
vodButton.FlatStyle = FlatStyle.Flat;
|
||||
@ -39,7 +39,7 @@ namespace DualScreenDemo
|
||||
|
||||
insertButton = new Button();
|
||||
insertButton.Text = "";
|
||||
ResizeAndPositionButton(insertButton, xPosition + 135, yPosition + 85, 110, 50);
|
||||
ResizeAndPositionButton(insertButton, xPosition + 2 , yPosition + 40, 110, 50);
|
||||
insertButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\點播介面\點播介面_插播.png"));
|
||||
insertButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
insertButton.FlatStyle = FlatStyle.Flat;
|
||||
@ -53,7 +53,7 @@ namespace DualScreenDemo
|
||||
|
||||
albumButton = new Button();
|
||||
albumButton.Text = "";
|
||||
ResizeAndPositionButton(albumButton, xPosition + 265, yPosition + 85, 140, 50);
|
||||
ResizeAndPositionButton(albumButton, xPosition + 122, yPosition + 40, 140, 50);
|
||||
albumButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\點播介面\點播介面_歷年專輯.png"));
|
||||
albumButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
albumButton.FlatStyle = FlatStyle.Flat;
|
||||
@ -67,7 +67,7 @@ namespace DualScreenDemo
|
||||
|
||||
favoriteButton = new Button();
|
||||
favoriteButton.Text = "";
|
||||
ResizeAndPositionButton(favoriteButton, xPosition + 425, yPosition + 85, 140, 50);
|
||||
ResizeAndPositionButton(favoriteButton, xPosition + 272, yPosition + 40, 140, 50);
|
||||
favoriteButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\點播介面\點播介面_我的最愛.png"));
|
||||
favoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
favoriteButton.FlatStyle = FlatStyle.Flat;
|
||||
@ -79,23 +79,24 @@ namespace DualScreenDemo
|
||||
disabledPanel = new Panel();
|
||||
disabledPanel.BackColor = Color.FromArgb(128, Color.Black);
|
||||
disabledPanel.Dock = DockStyle.Fill;
|
||||
disabledPanel.Visible = !IsUserLoggedIn();
|
||||
|
||||
disabledPanel.Visible = !isLoggedIn;
|
||||
|
||||
|
||||
favoriteButton.Controls.Add(disabledPanel);
|
||||
favoriteButton.Click += FavoriteButton_Click;
|
||||
|
||||
|
||||
if (!IsUserLoggedIn()) {
|
||||
if (!isLoggedIn) {
|
||||
favoriteButton.Enabled = false;
|
||||
favoriteButton.BackColor = SystemColors.Control;
|
||||
}
|
||||
favoriteButton.Visible = IsUserLoggedIn();
|
||||
favoriteButton.Visible = isLoggedIn;
|
||||
|
||||
|
||||
vodScreenCloseButton = new Button();
|
||||
vodScreenCloseButton.Text = "";
|
||||
ResizeAndPositionButton(vodScreenCloseButton, xPosition + 580, yPosition + 85, 110, 50);
|
||||
ResizeAndPositionButton(vodScreenCloseButton, xPosition + 422, yPosition + 40, 110, 50);
|
||||
vodScreenCloseButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\點播介面\點播介面_關閉.png"));
|
||||
vodScreenCloseButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
vodScreenCloseButton.FlatStyle = FlatStyle.Flat;
|
||||
@ -146,9 +147,16 @@ namespace DualScreenDemo
|
||||
{
|
||||
|
||||
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);
|
||||
|
||||
|
||||
SongListManager.Instance.AddToFavorite(currentSelectedSong.SongNumber);
|
||||
SetVodScreenPictureBoxAndButtonsVisibility(false);
|
||||
}
|
||||
|
||||
@ -183,7 +191,7 @@ namespace DualScreenDemo
|
||||
if (isVisible)
|
||||
{
|
||||
|
||||
if (IsUserLoggedIn())
|
||||
if (isLoggedIn)
|
||||
{
|
||||
favoriteButton.Enabled = true;
|
||||
favoriteButton.Controls.Remove(disabledPanel);
|
||||
|
@ -267,21 +267,39 @@ namespace DualScreenDemo
|
||||
string displayName = "包廂" + hostName.Substring(Math.Max(0, hostName.Length - 20));
|
||||
string totalPages = multiPagePanel.totalPages.ToString() == "0" ? "1" : multiPagePanel.totalPages.ToString();
|
||||
string pageNumber = (multiPagePanel.currentPageIndex + 1).ToString() + "/" + totalPages;
|
||||
|
||||
// 最後確定要塗鴉的值
|
||||
displayName = displayName + " " + pageNumber;
|
||||
|
||||
// 基準解析度(你目前的設計基準)
|
||||
float baseWidth = 1920f;
|
||||
float baseHeight = 1080f;
|
||||
|
||||
// 實際螢幕解析度
|
||||
float actualWidth = Screen.PrimaryScreen.Bounds.Width;
|
||||
float actualHeight = Screen.PrimaryScreen.Bounds.Height;
|
||||
|
||||
// 計算縮放比例
|
||||
float scaleX = actualWidth / baseWidth;
|
||||
float scaleY = actualHeight / baseHeight;
|
||||
|
||||
|
||||
// 設定字型:
|
||||
// "微軟正黑體",大小 24,粗體 (Bold)
|
||||
Font font = new Font("微軟正黑體", 24, FontStyle.Bold);
|
||||
float fontSize = 24 * scaleY;
|
||||
Font font = new Font("微軟正黑體", fontSize, FontStyle.Bold);
|
||||
// 設定畫刷 (Brush):
|
||||
// 使用紅色 (Red) 來繪製文字
|
||||
Brush brush = new SolidBrush(Color.Red);
|
||||
|
||||
// 設定繪製文字的位置 (X=500, Y=30)
|
||||
PointF point_PCName = new PointF(500, 30);
|
||||
PointF point_pageNumber = new PointF(700, 30);
|
||||
PointF point_PCName = new PointF(500 * scaleX, 30 * scaleY);
|
||||
|
||||
|
||||
// 繪製文字:
|
||||
// `DrawString(要繪製的文字, 字型, 畫刷, 位置)`
|
||||
e.Graphics.DrawString(displayName, font, brush, point_PCName);
|
||||
e.Graphics.DrawString(pageNumber, font, brush, point_pageNumber);
|
||||
|
||||
}
|
||||
|
||||
private void buttonMiddle_Click(object sender, EventArgs e)
|
||||
@ -1793,10 +1811,10 @@ namespace DualScreenDemo
|
||||
|
||||
VodScreenPictureBox.Image = originalImage;
|
||||
|
||||
int screenWidth = 1440;
|
||||
int screenHeight = 900;
|
||||
int pictureBoxWidth = 700;
|
||||
int pictureBoxHeight = 140;
|
||||
int screenWidth = 1920;
|
||||
int screenHeight = 1080;
|
||||
int pictureBoxWidth = 938;
|
||||
int pictureBoxHeight = 209;
|
||||
|
||||
int xPosition = (screenWidth - pictureBoxWidth) / 2;
|
||||
int yPosition = (screenHeight - pictureBoxHeight) / 2;
|
||||
|
@ -464,7 +464,7 @@ namespace DualScreenDemo
|
||||
wordCountSearchSongButton.BackgroundImage = wordCountSearchSongNormalBackground;
|
||||
// 隱藏與 WordCount 歌手相關的所有按鈕
|
||||
SetWordCountSongsAndButtonsVisibility(false);
|
||||
// 錨點 歌曲查詢改版
|
||||
// 歌曲查詢改版
|
||||
FindWordCountSongs();
|
||||
}
|
||||
/// <summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user