2025-04-07 16:54:10 +08:00
|
|
|
using System.IO;
|
|
|
|
using DBObj;
|
|
|
|
namespace DualScreenDemo
|
|
|
|
{
|
|
|
|
public partial class PrimaryForm
|
|
|
|
{
|
|
|
|
private Button myFavoritesButton;
|
|
|
|
private Bitmap myFavoritesNormalBackground;
|
|
|
|
private Bitmap myFavoritesActiveBackground;
|
|
|
|
|
|
|
|
private string mobileNumber = string.Empty;
|
|
|
|
public static bool isPhoneNumberValid;
|
|
|
|
private bool showError = false;
|
|
|
|
private PictureBox FavoritePictureBox;
|
|
|
|
private Button[] favoriteNumberButton;
|
|
|
|
private Button enterFavoriteButton;
|
|
|
|
private Button newFavoriteButton;
|
|
|
|
private Button refillFavoriteButton;
|
|
|
|
private Button closeFavoriteButton;
|
|
|
|
private Label errorMessageLabel;
|
|
|
|
|
|
|
|
private void InitializeButtonsForFavoritePictureBox()
|
|
|
|
{
|
|
|
|
|
|
|
|
int[,] coords = new int[,]
|
|
|
|
{
|
2025-04-17 15:53:19 +08:00
|
|
|
{794, 508, 70, 65},
|
2025-06-17 09:31:00 +08:00
|
|
|
{873, 508, 70, 65},
|
|
|
|
{952, 508, 70, 65},
|
|
|
|
{1031, 508, 70, 65},
|
|
|
|
{1110, 508, 70, 65},
|
2025-04-17 15:53:19 +08:00
|
|
|
{794, 580, 70, 65},
|
2025-06-17 09:31:00 +08:00
|
|
|
{873, 580, 70, 65},
|
|
|
|
{952, 580, 70, 65},
|
|
|
|
{1031, 580, 70, 65},
|
|
|
|
{1110, 580, 70, 65}
|
2025-04-07 16:54:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
int screenW = Screen.PrimaryScreen.Bounds.Width;
|
|
|
|
int screenH = Screen.PrimaryScreen.Bounds.Height;
|
|
|
|
|
|
|
|
|
|
|
|
float widthRatio = screenW / (float)1440;
|
|
|
|
float heightRatio = screenH / (float)900;
|
|
|
|
|
|
|
|
favoriteNumberButton = new Button[10];
|
|
|
|
|
|
|
|
for (int i = 0; i < favoriteNumberButton.Length; i++)
|
|
|
|
{
|
|
|
|
favoriteNumberButton[i] = new Button();
|
|
|
|
|
|
|
|
ResizeAndPositionButton(favoriteNumberButton[i], coords[i, 0], coords[i, 1], coords[i, 2], coords[i, 3]);
|
|
|
|
|
|
|
|
|
|
|
|
string fileName = (i + 2).ToString("00");
|
2025-06-17 09:31:00 +08:00
|
|
|
string filePath = Path.Combine(Application.StartupPath, @"themes\superstar\我的最愛\我的最愛-" + fileName + ".png");
|
2025-04-07 16:54:10 +08:00
|
|
|
favoriteNumberButton[i].BackgroundImage = Image.FromFile(filePath);
|
|
|
|
favoriteNumberButton[i].BackgroundImageLayout = ImageLayout.Stretch;
|
|
|
|
favoriteNumberButton[i].FlatStyle = FlatStyle.Flat;
|
|
|
|
favoriteNumberButton[i].FlatAppearance.BorderSize = 0;
|
|
|
|
favoriteNumberButton[i].BackColor = Color.Transparent;
|
|
|
|
favoriteNumberButton[i].FlatAppearance.MouseDownBackColor = Color.Transparent;
|
|
|
|
favoriteNumberButton[i].FlatAppearance.MouseOverBackColor = Color.Transparent;
|
|
|
|
|
|
|
|
|
|
|
|
favoriteNumberButton[i].Name = "favoriteNumberButton" + i;
|
|
|
|
|
|
|
|
favoriteNumberButton[i].Tag = (i + 1).ToString();
|
|
|
|
if (i == 9)
|
|
|
|
{
|
|
|
|
favoriteNumberButton[i].Name = "favoriteNumberButton0";
|
|
|
|
favoriteNumberButton[i].Tag = "0";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
favoriteNumberButton[i].Click += FavoriteNumberButton_Click;
|
|
|
|
|
|
|
|
|
|
|
|
this.Controls.Add(favoriteNumberButton[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
enterFavoriteButton = new Button()
|
|
|
|
{
|
|
|
|
Name = "enterFavoriteButton"
|
|
|
|
};
|
2025-04-17 15:53:19 +08:00
|
|
|
ResizeAndPositionButton(enterFavoriteButton, 832, 657, 70, 65);
|
2025-06-17 09:31:00 +08:00
|
|
|
enterFavoriteButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\我的最愛\我的最愛-12.png"));
|
2025-04-07 16:54:10 +08:00
|
|
|
enterFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
|
|
|
enterFavoriteButton.FlatStyle = FlatStyle.Flat;
|
|
|
|
enterFavoriteButton.FlatAppearance.BorderSize = 0;
|
|
|
|
enterFavoriteButton.BackColor = Color.Transparent;
|
|
|
|
enterFavoriteButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
|
|
|
|
enterFavoriteButton.FlatAppearance.MouseOverBackColor = Color.Transparent;
|
|
|
|
enterFavoriteButton.Click += EnterFavoriteButton_Click;
|
|
|
|
|
|
|
|
|
|
|
|
newFavoriteButton = new Button()
|
|
|
|
{
|
|
|
|
Name = "newFavoriteButton"
|
|
|
|
};
|
2025-04-17 15:53:19 +08:00
|
|
|
ResizeAndPositionButton(newFavoriteButton, 916, 657, 70, 65);
|
2025-06-17 09:31:00 +08:00
|
|
|
newFavoriteButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\我的最愛\我的最愛-13.png"));
|
2025-04-07 16:54:10 +08:00
|
|
|
newFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
|
|
|
newFavoriteButton.FlatStyle = FlatStyle.Flat;
|
|
|
|
newFavoriteButton.FlatAppearance.BorderSize = 0;
|
|
|
|
newFavoriteButton.BackColor = Color.Transparent;
|
|
|
|
newFavoriteButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
|
|
|
|
newFavoriteButton.FlatAppearance.MouseOverBackColor = Color.Transparent;
|
|
|
|
newFavoriteButton.Click += NewFavoriteButton_Click;
|
|
|
|
|
|
|
|
|
|
|
|
refillFavoriteButton = new Button()
|
|
|
|
{
|
|
|
|
Name = "refillFavoriteButton"
|
|
|
|
};
|
2025-04-17 15:53:19 +08:00
|
|
|
ResizeAndPositionButton(refillFavoriteButton, 999, 657, 70, 65);
|
2025-06-17 09:31:00 +08:00
|
|
|
refillFavoriteButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\我的最愛\我的最愛-14.png"));
|
2025-04-07 16:54:10 +08:00
|
|
|
refillFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
|
|
|
refillFavoriteButton.FlatStyle = FlatStyle.Flat;
|
|
|
|
refillFavoriteButton.FlatAppearance.BorderSize = 0;
|
|
|
|
refillFavoriteButton.BackColor = Color.Transparent;
|
|
|
|
refillFavoriteButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
|
|
|
|
refillFavoriteButton.FlatAppearance.MouseOverBackColor = Color.Transparent;
|
|
|
|
refillFavoriteButton.Click += RefillFavoriteButton_Click;
|
|
|
|
|
|
|
|
|
|
|
|
closeFavoriteButton = new Button()
|
|
|
|
{
|
|
|
|
Name = "closeFavoriteButton"
|
|
|
|
};
|
2025-04-17 15:53:19 +08:00
|
|
|
ResizeAndPositionButton(closeFavoriteButton, 1083, 657, 70, 65);
|
2025-06-17 09:31:00 +08:00
|
|
|
closeFavoriteButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\我的最愛\我的最愛-15.png"));
|
2025-04-07 16:54:10 +08:00
|
|
|
closeFavoriteButton.BackgroundImageLayout = ImageLayout.Stretch;
|
|
|
|
closeFavoriteButton.FlatStyle = FlatStyle.Flat;
|
|
|
|
closeFavoriteButton.FlatAppearance.BorderSize = 0;
|
|
|
|
closeFavoriteButton.BackColor = Color.Transparent;
|
|
|
|
closeFavoriteButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
|
|
|
|
closeFavoriteButton.FlatAppearance.MouseOverBackColor = Color.Transparent;
|
|
|
|
closeFavoriteButton.Click += CloseFavoriteButton_Click;
|
|
|
|
|
|
|
|
|
|
|
|
errorMessageLabel = new Label
|
|
|
|
{
|
|
|
|
Text = "",
|
|
|
|
ForeColor = Color.Black,
|
|
|
|
Location = new Point(10, 250),
|
|
|
|
AutoSize = true
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
this.Controls.Add(enterFavoriteButton);
|
|
|
|
this.Controls.Add(newFavoriteButton);
|
|
|
|
this.Controls.Add(refillFavoriteButton);
|
|
|
|
this.Controls.Add(closeFavoriteButton);
|
|
|
|
this.Controls.Add(errorMessageLabel);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void FavoriteNumberButton_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
Button clickedButton = sender as Button;
|
|
|
|
if (clickedButton != null)
|
|
|
|
{
|
|
|
|
|
|
|
|
mobileNumber += clickedButton.Tag.ToString();
|
|
|
|
phonenumber = mobileNumber;
|
|
|
|
|
|
|
|
FavoritePictureBox.Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public static string phonenumber;
|
|
|
|
private void FavoritePictureBox_Paint(object sender, PaintEventArgs e)
|
|
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(mobileNumber))
|
|
|
|
{
|
2025-04-17 15:53:19 +08:00
|
|
|
|
2025-04-07 16:54:10 +08:00
|
|
|
using (Brush brush = new SolidBrush(Color.Black))
|
|
|
|
{
|
2025-04-17 15:53:19 +08:00
|
|
|
int screenW = Screen.PrimaryScreen.Bounds.Width;
|
|
|
|
int screenH = Screen.PrimaryScreen.Bounds.Height;
|
|
|
|
|
|
|
|
float widthRatio = screenW / 1920f;
|
|
|
|
float heightRatio = screenH / 1080f;
|
|
|
|
|
|
|
|
// 轉成縮放後的座標
|
|
|
|
int x = (int)(30 * widthRatio);
|
|
|
|
int y = (int)(90 * heightRatio);
|
|
|
|
Font font = new Font("Arial", 24*heightRatio);
|
2025-04-07 16:54:10 +08:00
|
|
|
|
|
|
|
if (showError)
|
|
|
|
{
|
|
|
|
string errorMessage;
|
|
|
|
if (!isPhoneNumberValid)
|
|
|
|
{
|
|
|
|
errorMessage = "查無此手機號碼!!!";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
errorMessage = "手機號碼輸入錯誤!!!";
|
|
|
|
}
|
|
|
|
e.Graphics.DrawString(errorMessage, font, brush, x, y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
e.Graphics.DrawString(mobileNumber, font, brush, x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void EnterFavoriteButton_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
if (mobileNumber.StartsWith("09") && mobileNumber.Length == 10)
|
|
|
|
{
|
2025-04-16 11:20:08 +08:00
|
|
|
if (checkPhoneNumberExist(mobileNumber))
|
2025-04-07 16:54:10 +08:00
|
|
|
{
|
|
|
|
isPhoneNumberValid = true;
|
2025-04-16 11:20:08 +08:00
|
|
|
//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);
|
|
|
|
|
2025-04-07 16:54:10 +08:00
|
|
|
ToggleFavoritePictureBoxButtonsVisibility();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
isPhoneNumberValid = false;
|
|
|
|
showError = true;
|
|
|
|
FavoritePictureBox.Invalidate();
|
|
|
|
FavoritePictureBox.Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2025-05-22 13:33:48 +08:00
|
|
|
showError = true;
|
|
|
|
isPhoneNumberValid = false;
|
2025-04-07 16:54:10 +08:00
|
|
|
FavoritePictureBox.Invalidate();
|
|
|
|
FavoritePictureBox.Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-05-13 15:21:19 +08:00
|
|
|
// 我的最愛新增
|
2025-04-07 16:54:10 +08:00
|
|
|
private void NewFavoriteButton_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
if (mobileNumber.StartsWith("09") && mobileNumber.Length == 10)
|
|
|
|
{
|
2025-04-16 11:20:08 +08:00
|
|
|
if (checkPhoneNumberExist(mobileNumber))
|
2025-04-07 16:54:10 +08:00
|
|
|
{
|
|
|
|
isPhoneNumberValid = true;
|
2025-05-22 13:33:48 +08:00
|
|
|
var searchResults = SearchSongs_Mysql(SearchFavoriteSongs_Mysql());
|
2025-04-16 11:20:08 +08:00
|
|
|
// 重置分頁
|
|
|
|
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
|
|
|
|
|
|
|
ToggleFavoritePictureBoxButtonsVisibility();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2025-05-22 13:33:48 +08:00
|
|
|
isPhoneNumberValid = true;
|
|
|
|
InsertNewFavoriteUser(mobileNumber);
|
|
|
|
if (checkPhoneNumberExist(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
|
|
|
|
{
|
|
|
|
showError = true;
|
|
|
|
isPhoneNumberValid = false;
|
|
|
|
FavoritePictureBox.Invalidate();
|
|
|
|
FavoritePictureBox.Refresh();
|
|
|
|
}
|
2025-04-16 11:20:08 +08:00
|
|
|
|
2025-04-07 16:54:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
showError = true;
|
2025-05-22 13:33:48 +08:00
|
|
|
isPhoneNumberValid = false;
|
2025-04-07 16:54:10 +08:00
|
|
|
FavoritePictureBox.Invalidate();
|
|
|
|
FavoritePictureBox.Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RefillFavoriteButton_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
|
|
|
|
mobileNumber = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
showError = false;
|
|
|
|
|
|
|
|
|
|
|
|
FavoritePictureBox.Invalidate();
|
|
|
|
FavoritePictureBox.Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void CloseFavoriteButton_Click(object sender, EventArgs e)
|
|
|
|
{
|
2025-05-08 10:09:14 +08:00
|
|
|
mobileNumber = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
showError = false;
|
|
|
|
|
|
|
|
|
|
|
|
FavoritePictureBox.Invalidate();
|
|
|
|
FavoritePictureBox.Refresh();
|
2025-04-07 16:54:10 +08:00
|
|
|
|
|
|
|
ToggleFavoritePictureBoxButtonsVisibility();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void MyFavoritesButton_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
newSongAlertButton.BackgroundImage = newSongAlertNormalBackground;
|
|
|
|
hotPlayButton.BackgroundImage = hotPlayNormalBackground;
|
|
|
|
singerSearchButton.BackgroundImage = singerSearchNormalBackground;
|
|
|
|
songSearchButton.BackgroundImage = songSearchNormalBackground;
|
|
|
|
languageSearchButton.BackgroundImage = languageSearchNormalBackground;
|
|
|
|
groupSearchButton.BackgroundImage = groupSearchNormalBackground;
|
|
|
|
categorySearchButton.BackgroundImage = categorySearchNormalBackground;
|
|
|
|
orderedSongsButton.BackgroundImage = orderedSongsNormalBackground;
|
|
|
|
myFavoritesButton.BackgroundImage = myFavoritesActiveBackground;
|
|
|
|
promotionsButton.BackgroundImage = promotionsNormalBackground;
|
|
|
|
deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground;
|
|
|
|
isOnOrderedSongsPage = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (!FavoritePictureBox.Visible)
|
|
|
|
{
|
|
|
|
|
2025-06-17 09:31:00 +08:00
|
|
|
ShowImageOnFavoritePictureBox(Path.Combine(Application.StartupPath, @"themes\superstar\我的最愛\我的最愛_工作區域.png"));
|
2025-04-07 16:54:10 +08:00
|
|
|
SetFavoritePictureBoxAndButtonsVisibility(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
ToggleFavoritePictureBoxButtonsVisibility();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pictureBoxQRCode != null)
|
|
|
|
{
|
|
|
|
pictureBoxQRCode.Visible = false;
|
|
|
|
closeQRCodeButton.Visible = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetPictureBoxToggleLightAndButtonsVisibility(false);
|
|
|
|
SetPictureBoxSceneSoundEffectsAndButtonsVisibility(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ShowImageOnFavoritePictureBox(string imagePath)
|
|
|
|
{
|
|
|
|
|
2025-04-15 14:32:22 +08:00
|
|
|
/*Bitmap originalImage = new Bitmap(imagePath);
|
2025-04-07 16:54:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(String.Format("Original Image Size: {0}x{1}", originalImage.Width, originalImage.Height));
|
|
|
|
|
|
|
|
|
|
|
|
Rectangle cropArea = new Rectangle(784, 393, 555, 442);
|
|
|
|
|
|
|
|
|
|
|
|
Bitmap croppedImage = CropImage(originalImage, cropArea);
|
|
|
|
|
|
|
|
|
|
|
|
FavoritePictureBox.Image = croppedImage;
|
|
|
|
|
|
|
|
|
|
|
|
ResizeAndPositionPictureBox(FavoritePictureBox, cropArea.X, cropArea.Y, 416, 323);
|
|
|
|
|
2025-04-15 14:32:22 +08:00
|
|
|
FavoritePictureBox.Visible = true;*/
|
|
|
|
if (File.Exists(imagePath))
|
|
|
|
{
|
|
|
|
// 直接載入完整圖
|
|
|
|
Bitmap image = new Bitmap(imagePath);
|
|
|
|
|
|
|
|
// 顯示在 PictureBox 上
|
|
|
|
FavoritePictureBox.Image = image;
|
|
|
|
|
|
|
|
// 設定 PictureBox 的大小與位置(依你的需要調整)
|
2025-06-17 09:31:00 +08:00
|
|
|
// ResizeAndPositionPictureBox(FavoritePictureBox, 773, 380, image.Width , image.Height);
|
|
|
|
// ResizeAndPositionPictureBox(FavoritePictureBox, 773, 380, (int)(image.Width * 0.8f) , (int)(image.Height * 0.8f));
|
|
|
|
// 不要用 ResizeAndPositionPictureBox 這東西是static 他會導致其他東西顯示錯誤
|
|
|
|
int screenW = Screen.PrimaryScreen.Bounds.Width;
|
|
|
|
int screenH = Screen.PrimaryScreen.Bounds.Height;
|
2025-04-15 14:32:22 +08:00
|
|
|
|
2025-06-17 09:31:00 +08:00
|
|
|
float widthRatio = screenW / (float)1440;
|
|
|
|
float heightRatio = screenH / (float)900;
|
|
|
|
|
|
|
|
|
|
|
|
FavoritePictureBox.Location = new Point(
|
|
|
|
(int)(773 * widthRatio),
|
|
|
|
(int)(380 * heightRatio)
|
|
|
|
);
|
|
|
|
FavoritePictureBox.Size = new Size(
|
|
|
|
(int)(image.Width * widthRatio),
|
|
|
|
(int)(image.Height * heightRatio)
|
|
|
|
);
|
2025-04-15 14:32:22 +08:00
|
|
|
}
|
2025-06-17 09:31:00 +08:00
|
|
|
FavoritePictureBox.Visible = true;
|
|
|
|
|
2025-04-15 14:32:22 +08:00
|
|
|
|
2025-04-07 16:54:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void ToggleFavoritePictureBoxButtonsVisibility()
|
|
|
|
{
|
|
|
|
|
|
|
|
bool areButtonsVisible = FavoritePictureBox.Visible;
|
|
|
|
|
|
|
|
|
|
|
|
SetFavoritePictureBoxAndButtonsVisibility(!areButtonsVisible);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SetFavoritePictureBoxAndButtonsVisibility(bool isVisible)
|
|
|
|
{
|
|
|
|
System.Action action = () =>
|
|
|
|
{
|
|
|
|
SuspendLayout();
|
|
|
|
|
|
|
|
|
|
|
|
FavoritePictureBox.Visible = isVisible;
|
|
|
|
|
|
|
|
|
|
|
|
if (isVisible) FavoritePictureBox.BringToFront();
|
|
|
|
|
|
|
|
|
|
|
|
enterFavoriteButton.Visible = isVisible;
|
|
|
|
newFavoriteButton.Visible = isVisible;
|
|
|
|
refillFavoriteButton.Visible = isVisible;
|
|
|
|
closeFavoriteButton.Visible = isVisible;
|
|
|
|
|
|
|
|
|
|
|
|
if (isVisible)
|
|
|
|
{
|
|
|
|
enterFavoriteButton.BringToFront();
|
|
|
|
newFavoriteButton.BringToFront();
|
|
|
|
refillFavoriteButton.BringToFront();
|
|
|
|
closeFavoriteButton.BringToFront();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (Button button in favoriteNumberButton)
|
|
|
|
{
|
|
|
|
button.Visible = isVisible;
|
|
|
|
|
|
|
|
if (isVisible)
|
|
|
|
button.BringToFront();
|
|
|
|
}
|
|
|
|
|
|
|
|
ResumeLayout();
|
|
|
|
};
|
|
|
|
|
|
|
|
if (this.InvokeRequired)
|
|
|
|
{
|
|
|
|
this.Invoke(action);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
action();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|