add init 20250318
This commit is contained in:
commit
5e4a7c80b3
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
DualScreenSetup.exe
|
||||
Superstar.mdf
|
||||
Superstar_log.ldf
|
1
AddUrlAcl.bat
Normal file
1
AddUrlAcl.bat
Normal file
@ -0,0 +1 @@
|
||||
netsh http add urlacl url=http://192.168.11.7:9090/ user=Everyone
|
32
Artist.cs
Normal file
32
Artist.cs
Normal file
@ -0,0 +1,32 @@
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public class Artist
|
||||
{
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
public string Phonetic { get; set; }
|
||||
|
||||
|
||||
public string Category { get; set; }
|
||||
|
||||
|
||||
public int Strokes { get; set; }
|
||||
|
||||
|
||||
public Artist(string name, string phonetic, string category, int strokes)
|
||||
{
|
||||
Name = name;
|
||||
Phonetic = phonetic;
|
||||
Category = category;
|
||||
Strokes = strokes;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Name: {Name}, Phonetic: {Phonetic}, Category: {Category}, Strokes: {Strokes}";
|
||||
}
|
||||
}
|
||||
}
|
113
ArtistManager.cs
Normal file
113
ArtistManager.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SQLite;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public class ArtistManager
|
||||
{
|
||||
private static ArtistManager _instance;
|
||||
public List<Artist> AllArtists { get; private set; }
|
||||
|
||||
public static ArtistManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new ArtistManager();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public ArtistManager()
|
||||
{
|
||||
AllArtists = new List<Artist>();
|
||||
LoadArtists();
|
||||
|
||||
}
|
||||
|
||||
private void LoadArtists()
|
||||
{
|
||||
string databaseFileName = "KSongDatabase.db";
|
||||
string databasePath = Path.Combine(Application.StartupPath, databaseFileName);
|
||||
|
||||
Console.WriteLine(databasePath);
|
||||
string connectionString = String.Format("Data Source={0};Version=3;", databasePath);
|
||||
|
||||
using (var connection = new SQLiteConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
string sql = "SELECT 歌手姓名, 歌手注音, 歌手分類, 歌手筆畫 FROM ArtistLibrary";
|
||||
using (var command = new SQLiteCommand(sql, connection))
|
||||
{
|
||||
using (SQLiteDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
string artist = reader["歌手姓名"].ToString();
|
||||
string phonetic = reader["歌手注音"].ToString();
|
||||
string category = reader["歌手分類"].ToString();
|
||||
string strokesStr = reader["歌手筆畫"].ToString();
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(strokesStr))
|
||||
{
|
||||
// Console.WriteLine("歌手筆畫的值為空或無效");
|
||||
}
|
||||
|
||||
if (double.TryParse(strokesStr, out double strokesDouble))
|
||||
{
|
||||
int strokes = (int)Math.Round(strokesDouble);
|
||||
AllArtists.Add(new Artist(artist, phonetic, category, strokes));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Console.WriteLine($"Failed to parse '歌手筆畫' value: {strokesStr}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
connection.Close();
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Failed to load artists from SQLite database: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PrintAllArtists()
|
||||
{
|
||||
Console.WriteLine("All Artists:");
|
||||
foreach (var artist in AllArtists)
|
||||
{
|
||||
Console.WriteLine(artist.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public List<Artist> GetArtistsByCategoryAndStrokeCountRange(string category, int minStrokes, int maxStrokes)
|
||||
{
|
||||
if (category == "全部")
|
||||
{
|
||||
return AllArtists.Where(artist => artist.Strokes >= minStrokes && artist.Strokes <= maxStrokes).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return AllArtists.Where(artist => artist.Category == category && artist.Strokes >= minStrokes && artist.Strokes <= maxStrokes).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
AxInterop.WMPLib.dll
Normal file
BIN
AxInterop.WMPLib.dll
Normal file
Binary file not shown.
BIN
ButtonImages/11超.png
Normal file
BIN
ButtonImages/11超.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
ButtonImages/巨.png
Normal file
BIN
ButtonImages/巨.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
BIN
ButtonImages/星.png
Normal file
BIN
ButtonImages/星.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
BIN
ButtonImages/服務鈴.png
Normal file
BIN
ButtonImages/服務鈴.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 85 KiB |
BIN
ButtonImages/級.png
Normal file
BIN
ButtonImages/級.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
ButtonImages/超.png
Normal file
BIN
ButtonImages/超.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
12
ClickSequenceState.cs
Normal file
12
ClickSequenceState.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
|
||||
public enum ClickSequenceState
|
||||
{
|
||||
Initial,
|
||||
FirstClicked,
|
||||
SecondClicked,
|
||||
ThirdClicked,
|
||||
Completed
|
||||
}
|
||||
}
|
13
Clsid.cs
Normal file
13
Clsid.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public static class Clsid
|
||||
{
|
||||
public static readonly Guid LAVSplitter = new Guid("171252A0-8820-4AFE-9DF8-5C92B2D66B04");
|
||||
public static readonly Guid LAVVideoDecoder = new Guid("EE30215D-164F-4A92-A4EB-9D4C13390F9F");
|
||||
public static readonly Guid LAVAudioDecoder = new Guid("E8E73B6B-4CB3-44A4-BE99-4F7BCB96E491");
|
||||
public static readonly Guid VideoRenderer = new Guid("B87BEB7B-8D29-423F-AE4D-6582C10175AC");
|
||||
public static readonly Guid AudioSwitcher = new Guid("1367C6F9-3FDD-42E9-AE3A-BC57F4C40D6D");
|
||||
}
|
||||
}
|
14
ComInterop.cs
Normal file
14
ComInterop.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public class ComInterop
|
||||
{
|
||||
[DllImport("ole32.dll")]
|
||||
public static extern int CoInitializeEx(IntPtr pvReserved, int dwCoInit);
|
||||
|
||||
public const int COINIT_APARTMENTTHREADED = 0x2;
|
||||
public const int COINIT_MULTITHREADED = 0x0;
|
||||
}
|
||||
}
|
930
CommandHandler.cs
Normal file
930
CommandHandler.cs
Normal file
@ -0,0 +1,930 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public class CommandHandler
|
||||
{
|
||||
public static bool readyForSongListInput = false;
|
||||
|
||||
private readonly SongListManager songListManager;
|
||||
|
||||
public CommandHandler(SongListManager songListManager)
|
||||
{
|
||||
this.songListManager = songListManager;
|
||||
}
|
||||
|
||||
public async Task ProcessData(string indata)
|
||||
{
|
||||
string filePath = Path.Combine(Application.StartupPath, "dataLog.txt");
|
||||
if (CheckLogForShutdown(filePath))
|
||||
{
|
||||
Console.WriteLine("Shutdown condition met. Application will now close.");
|
||||
ShutdownComputer();
|
||||
}
|
||||
|
||||
switch (indata)
|
||||
{
|
||||
case "A261A4":
|
||||
HandleInputA();
|
||||
break;
|
||||
case "A262A4":
|
||||
HandleInputB();
|
||||
break;
|
||||
case "A263A4":
|
||||
ClearDisplay();
|
||||
break;
|
||||
case "A268A4":
|
||||
OverlayForm.MainForm.currentPage = 1;
|
||||
DisplaySongHistory();
|
||||
break;
|
||||
case "A26AA4":
|
||||
PreviousPage();
|
||||
break;
|
||||
case "A26BA4":
|
||||
NextPage();
|
||||
break;
|
||||
case "A271A4":
|
||||
HandleNewSongAnnouncements();
|
||||
break;
|
||||
case "A273A4":
|
||||
HandleHotSongAnnouncements();
|
||||
break;
|
||||
case "A267A4":
|
||||
SkipToNextSong();
|
||||
ClearDisplay();
|
||||
break;
|
||||
case "A269A4":
|
||||
ReplayCurrentSong();
|
||||
break;
|
||||
// 原唱
|
||||
case "A26CA4":
|
||||
Console.WriteLine("ToggleVocalRemoval Invoked");
|
||||
InvokeAction(() => VideoPlayerForm.Instance.ToggleVocalRemoval());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowOriginalSongLabel());
|
||||
break;
|
||||
// 導唱
|
||||
case "A26EA4":
|
||||
InvokeAction(() => VideoPlayerForm.Instance.ToggleVocalRemoval());
|
||||
break;
|
||||
case "A26DA4":
|
||||
PauseOrResumeSong();
|
||||
break;
|
||||
case "A276A4":
|
||||
ToggleMute();
|
||||
break;
|
||||
case "A274A4":
|
||||
HandleArtistAnnouncements();
|
||||
break;
|
||||
case "A2B3A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowVolumeUpLabel());
|
||||
break;
|
||||
case "A2B4A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowVolumeDownLabel());
|
||||
break;
|
||||
case "A2B5A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowMicUpLabel());
|
||||
break;
|
||||
case "A2B6A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowMicDownLabel());
|
||||
break;
|
||||
case "A2C2A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HidemicLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowStandardLabel());
|
||||
break;
|
||||
case "A2C3A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HidemicLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowProfessionalLabel());
|
||||
break;
|
||||
case "A2C4A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HidemicLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowSquareLabel());
|
||||
break;
|
||||
case "A2C1A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HidemicLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowSingDownLabel());
|
||||
break;
|
||||
case "A2D5A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowBrightLabel());
|
||||
break;
|
||||
case "A2D7A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowRomanticLabel());
|
||||
break;
|
||||
/* case "A27CA4":
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowMaleKeyLabel());
|
||||
break;
|
||||
case "A282A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowFemaleKeyLabel());
|
||||
break;*/
|
||||
case "A2D6A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowSoftLabel());
|
||||
break;
|
||||
case "A2D8A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowDynamicLabel());
|
||||
break;
|
||||
case "A275A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowTintLabel());
|
||||
break;
|
||||
case "A283A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowKeyUpLabel("↑升4調"));
|
||||
break;
|
||||
case "A282A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowKeyUpLabel("↑升3調"));
|
||||
break;
|
||||
case "A281A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowKeyUpLabel("↑升2調"));
|
||||
break;
|
||||
case "A280A4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowKeyUpLabel("↑升1調"));
|
||||
break;
|
||||
case "A27FA4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowStandardKeyLabel());
|
||||
break;
|
||||
case "A27EA4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowKeyDownLabel("↓降1調"));
|
||||
break;
|
||||
case "A27DA4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowKeyDownLabel("↓降2調"));
|
||||
break;
|
||||
case "A27CA4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowKeyDownLabel("↓降3調"));
|
||||
break;
|
||||
case "A27BA4":
|
||||
InvokeAction(() => OverlayForm.MainForm.HideAllLabels());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowKeyDownLabel("↓降4調"));
|
||||
break;
|
||||
default:
|
||||
if (Regex.IsMatch(indata, @"^A23\d+A4$"))
|
||||
{
|
||||
HandleNumberInput(indata);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InvokeAction(Action action)
|
||||
{
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(action);
|
||||
}
|
||||
else
|
||||
{
|
||||
action();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void SkipToNextSong()
|
||||
{
|
||||
if (PrimaryForm.Instance.InvokeRequired)
|
||||
{
|
||||
PrimaryForm.Instance.Invoke(new System.Action(() => PrimaryForm.Instance.videoPlayerForm.SkipToNextSong()));
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimaryForm.Instance.videoPlayerForm.SkipToNextSong();
|
||||
}
|
||||
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
OverlayForm.MainForm.ShowStandardLabel();
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
private static void ReplayCurrentSong()
|
||||
{
|
||||
if (PrimaryForm.Instance.InvokeRequired)
|
||||
{
|
||||
PrimaryForm.Instance.Invoke(new System.Action(() => PrimaryForm.Instance.videoPlayerForm.ReplayCurrentSong()));
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimaryForm.Instance.videoPlayerForm.ReplayCurrentSong();
|
||||
}
|
||||
}
|
||||
|
||||
private static void PauseOrResumeSong()
|
||||
{
|
||||
if (PrimaryForm.Instance.InvokeRequired)
|
||||
{
|
||||
PrimaryForm.Instance.Invoke(new System.Action(() => PrimaryForm.Instance.videoPlayerForm.PauseOrResumeSong()));
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimaryForm.Instance.videoPlayerForm.PauseOrResumeSong();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ToggleMute()
|
||||
{
|
||||
if (VideoPlayerForm.Instance.InvokeRequired)
|
||||
{
|
||||
VideoPlayerForm.Instance.Invoke(new System.Action(ToggleMute));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (VideoPlayerForm.Instance.isMuted)
|
||||
{
|
||||
|
||||
VideoPlayerForm.Instance.SetVolume(VideoPlayerForm.Instance.previousVolume);
|
||||
|
||||
VideoPlayerForm.Instance.isMuted = false;
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() => OverlayForm.MainForm.HideMuteLabel()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
VideoPlayerForm.Instance.previousVolume = VideoPlayerForm.Instance.GetVolume();
|
||||
VideoPlayerForm.Instance.SetVolume(-10000);
|
||||
|
||||
VideoPlayerForm.Instance.isMuted = true;
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() => OverlayForm.MainForm.ShowMuteLabel()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void HandleInputA()
|
||||
{
|
||||
|
||||
|
||||
OverlayForm.displayTimer.Stop();
|
||||
string input = "a";
|
||||
|
||||
|
||||
string songNumber = OverlayForm.ReadSongNumber();
|
||||
var song = songListManager.SearchSongByNumber(songNumber);
|
||||
|
||||
|
||||
|
||||
if (readyForSongListInput)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
OverlayForm.MainForm.OnUserInput(input);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayForm.MainForm.OnUserInput(input);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
if (song != null)
|
||||
{
|
||||
ClearDisplay();
|
||||
OverlayForm.MainForm.displayLabel.Text = String.Format("已點歌曲:{0}", song);
|
||||
OverlayForm.MainForm.AddSongToPlaylist(song);
|
||||
OverlayForm.MainForm.nextSongLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDisplay();
|
||||
OverlayForm.MainForm.displayLabel.Text = "輸入錯誤!!!";
|
||||
OverlayForm.MainForm.nextSongLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (song != null)
|
||||
{
|
||||
ClearDisplay();
|
||||
OverlayForm.MainForm.displayLabel.Text = String.Format("{0}", song);
|
||||
OverlayForm.MainForm.AddSongToPlaylist(song);
|
||||
OverlayForm.MainForm.nextSongLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDisplay();
|
||||
OverlayForm.MainForm.displayLabel.Text = "輸入錯誤!!!";
|
||||
OverlayForm.MainForm.nextSongLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void HandleInputB()
|
||||
{
|
||||
|
||||
OverlayForm.displayTimer.Stop();
|
||||
string input = "b";
|
||||
|
||||
|
||||
string songNumber = OverlayForm.ReadSongNumber();
|
||||
var song = songListManager.SearchSongByNumber(songNumber);
|
||||
|
||||
|
||||
|
||||
if (readyForSongListInput)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
OverlayForm.MainForm.OnUserInput(input);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayForm.MainForm.OnUserInput(input);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
if (song != null)
|
||||
{
|
||||
ClearDisplay();
|
||||
OverlayForm.MainForm.displayLabel.Text = String.Format("插播歌曲{0}", song);
|
||||
OverlayForm.MainForm.InsertSongToPlaylist(song);
|
||||
OverlayForm.MainForm.nextSongLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDisplay();
|
||||
OverlayForm.MainForm.displayLabel.Text = "輸入錯誤!!!";
|
||||
OverlayForm.MainForm.nextSongLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (song != null)
|
||||
{
|
||||
ClearDisplay();
|
||||
OverlayForm.MainForm.displayLabel.Text = String.Format("已點歌曲:{0}", song);
|
||||
OverlayForm.MainForm.nextSongLabel.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDisplay();
|
||||
OverlayForm.MainForm.displayLabel.Text = "輸入錯誤!!!";
|
||||
OverlayForm.MainForm.nextSongLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ClearDisplay()
|
||||
{
|
||||
|
||||
OverlayForm.displayTimer.Stop();
|
||||
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
|
||||
foreach (var control in OverlayForm.MainForm.Controls.OfType<Control>().ToArray())
|
||||
{
|
||||
if (control != OverlayForm.MainForm.displayLabel &&
|
||||
control != OverlayForm.MainForm.pauseLabel &&
|
||||
control != OverlayForm.MainForm.muteLabel &&
|
||||
control != OverlayForm.MainForm.volumeUpLabel &&
|
||||
control != OverlayForm.MainForm.volumeDownLabel &&
|
||||
control != OverlayForm.MainForm.micUpLabel &&
|
||||
control != OverlayForm.MainForm.micDownLabel &&
|
||||
control != OverlayForm.MainForm.standardKeyLabel &&
|
||||
control != OverlayForm.MainForm.keyUpLabel &&
|
||||
control != OverlayForm.MainForm.keyDownLabel &&
|
||||
control != OverlayForm.MainForm.maleKeyLabel &&
|
||||
control != OverlayForm.MainForm.femaleKeyLabel &&
|
||||
control != OverlayForm.MainForm.squareLabel &&
|
||||
control != OverlayForm.MainForm.professionalLabel &&
|
||||
control != OverlayForm.MainForm.standardLabel &&
|
||||
control != OverlayForm.MainForm.singDownLabel &&
|
||||
control != OverlayForm.MainForm.brightLabel &&
|
||||
control != OverlayForm.MainForm.softLabel &&
|
||||
control != OverlayForm.MainForm.autoLabel &&
|
||||
control != OverlayForm.MainForm.romanticLabel &&
|
||||
control != OverlayForm.MainForm.dynamicLabel &&
|
||||
control != OverlayForm.MainForm.tintLabel &&
|
||||
control != OverlayForm.MainForm.blackBackgroundPanel &&
|
||||
control != OverlayForm.MainForm.nextSongLabel)
|
||||
{
|
||||
OverlayForm.MainForm.Controls.Remove(control);
|
||||
control.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
OverlayForm.MainForm.displayLabel.Text = "";
|
||||
readyForSongListInput = false;
|
||||
OverlayForm.SetUIState(OverlayForm.UIState.Initial);
|
||||
Console.WriteLine(OverlayForm.MainForm.displayLabel.Text);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
foreach (var control in OverlayForm.MainForm.Controls.OfType<Control>().ToArray())
|
||||
{
|
||||
if (control != OverlayForm.MainForm.displayLabel &&
|
||||
control != OverlayForm.MainForm.pauseLabel &&
|
||||
control != OverlayForm.MainForm.muteLabel &&
|
||||
control != OverlayForm.MainForm.volumeUpLabel &&
|
||||
control != OverlayForm.MainForm.volumeDownLabel &&
|
||||
control != OverlayForm.MainForm.micUpLabel &&
|
||||
control != OverlayForm.MainForm.micDownLabel &&
|
||||
control != OverlayForm.MainForm.standardKeyLabel &&
|
||||
control != OverlayForm.MainForm.keyUpLabel &&
|
||||
control != OverlayForm.MainForm.keyDownLabel &&
|
||||
control != OverlayForm.MainForm.maleKeyLabel &&
|
||||
control != OverlayForm.MainForm.femaleKeyLabel &&
|
||||
control != OverlayForm.MainForm.squareLabel &&
|
||||
control != OverlayForm.MainForm.professionalLabel &&
|
||||
control != OverlayForm.MainForm.standardLabel &&
|
||||
control != OverlayForm.MainForm.singDownLabel &&
|
||||
control != OverlayForm.MainForm.brightLabel &&
|
||||
control != OverlayForm.MainForm.softLabel &&
|
||||
control != OverlayForm.MainForm.autoLabel &&
|
||||
control != OverlayForm.MainForm.romanticLabel &&
|
||||
control != OverlayForm.MainForm.dynamicLabel &&
|
||||
control != OverlayForm.MainForm.tintLabel &&
|
||||
control != OverlayForm.MainForm.blackBackgroundPanel &&
|
||||
control != OverlayForm.MainForm.nextSongLabel)
|
||||
{
|
||||
OverlayForm.MainForm.Controls.Remove(control);
|
||||
control.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
OverlayForm.MainForm.displayLabel.Text = "";
|
||||
Console.WriteLine("ClearDisplay called.");
|
||||
readyForSongListInput = false;
|
||||
OverlayForm.SetUIState(OverlayForm.UIState.Initial);
|
||||
Console.WriteLine(OverlayForm.MainForm.displayLabel.Text);
|
||||
}
|
||||
}
|
||||
private static void DisplaySongHistory()
|
||||
{
|
||||
ClearDisplay();
|
||||
|
||||
// 設定總歌曲數量
|
||||
OverlayForm.MainForm.totalSongs = PrimaryForm.playedSongsHistory.Count;
|
||||
|
||||
// 如果播放歷史為空
|
||||
if (OverlayForm.MainForm.totalSongs == 0)
|
||||
{
|
||||
Console.WriteLine("No song history available.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 計算總頁數
|
||||
int totalPages = (int)Math.Ceiling(OverlayForm.MainForm.totalSongs / (double)OverlayForm.MainForm.songsPerPage);
|
||||
int startIndex = (OverlayForm.MainForm.currentPage - 1) * OverlayForm.MainForm.songsPerPage;
|
||||
int endIndex = Math.Min(startIndex + OverlayForm.MainForm.songsPerPage, OverlayForm.MainForm.totalSongs);
|
||||
|
||||
// 準備傳遞給 UpdateHistoryLabel 的數據
|
||||
List<SongData> historySongs = new List<SongData>();
|
||||
List<PlayState> playStates = new List<PlayState>();
|
||||
|
||||
for (int i = startIndex; i < endIndex; i++)
|
||||
{
|
||||
historySongs.Add(PrimaryForm.playedSongsHistory[i]);
|
||||
playStates.Add(PrimaryForm.playStates[i]);
|
||||
}
|
||||
|
||||
// 調用 UpdateHistoryLabel 顯示數據
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
OverlayForm.MainForm.UpdateHistoryLabel(historySongs, playStates, OverlayForm.MainForm.currentPage, totalPages);
|
||||
OverlayForm.MainForm.nextSongLabel.Visible = false;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayForm.MainForm.UpdateHistoryLabel(historySongs, playStates, OverlayForm.MainForm.currentPage, totalPages);
|
||||
OverlayForm.MainForm.nextSongLabel.Visible = false;
|
||||
}
|
||||
|
||||
// 設定 UI 狀態
|
||||
OverlayForm.SetUIState(OverlayForm.UIState.PlayHistory);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void PreviousPage()
|
||||
{
|
||||
if (OverlayForm.CurrentUIState == OverlayForm.UIState.SelectingSong)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.PreviousPage();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.PreviousPage();
|
||||
}
|
||||
}
|
||||
else if (OverlayForm.CurrentUIState == OverlayForm.UIState.SelectingArtist)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.PreviousPage();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.PreviousPage();
|
||||
}
|
||||
}
|
||||
else if (OverlayForm.CurrentUIState == OverlayForm.UIState.PlayHistory)
|
||||
{
|
||||
if (OverlayForm.MainForm.currentPage > 1)
|
||||
{
|
||||
OverlayForm.MainForm.currentPage--;
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
DisplaySongHistory();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplaySongHistory();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Page turning is not allowed in the current state.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void NextPage()
|
||||
{
|
||||
if (OverlayForm.CurrentUIState == OverlayForm.UIState.SelectingSong)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.NextPage();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.NextPage();
|
||||
}
|
||||
}
|
||||
else if (OverlayForm.CurrentUIState == OverlayForm.UIState.SelectingArtist)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.NextPage();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.NextPage();
|
||||
}
|
||||
}
|
||||
else if (OverlayForm.CurrentUIState == OverlayForm.UIState.PlayHistory)
|
||||
{
|
||||
if (OverlayForm.MainForm.currentPage * OverlayForm.MainForm.songsPerPage < OverlayForm.MainForm.totalSongs)
|
||||
{
|
||||
OverlayForm.MainForm.currentPage++;
|
||||
if (OverlayForm.CurrentUIState == OverlayForm.UIState.PlayHistory)
|
||||
{
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
DisplaySongHistory();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplaySongHistory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Page turning is not allowed in the current state.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void HandleNewSongAnnouncements()
|
||||
{
|
||||
ClearDisplay();
|
||||
|
||||
|
||||
OverlayForm.CurrentCategory = OverlayForm.Category.NewSongs;
|
||||
|
||||
|
||||
string[] messages = new string[]
|
||||
{
|
||||
"新歌快訊",
|
||||
"1. 國語",
|
||||
"2. 台語",
|
||||
"3. 粵語",
|
||||
"4. 英語",
|
||||
"5. 日語",
|
||||
"6. 韓語",
|
||||
};
|
||||
|
||||
|
||||
readyForSongListInput = true;
|
||||
|
||||
|
||||
OverlayForm.SetUIState(OverlayForm.UIState.SelectingLanguage);
|
||||
|
||||
|
||||
UpdateDisplayLabels(messages);
|
||||
}
|
||||
|
||||
private static void HandleHotSongAnnouncements()
|
||||
{
|
||||
ClearDisplay();
|
||||
|
||||
|
||||
OverlayForm.CurrentCategory = OverlayForm.Category.HotSongs;
|
||||
|
||||
|
||||
string[] messages = new string[]
|
||||
{
|
||||
"熱門排行",
|
||||
"1. 國語",
|
||||
"2. 台語",
|
||||
"3. 粵語",
|
||||
"4. 英語",
|
||||
"5. 日語",
|
||||
"6. 韓語",
|
||||
};
|
||||
|
||||
|
||||
readyForSongListInput = true;
|
||||
|
||||
|
||||
OverlayForm.SetUIState(OverlayForm.UIState.SelectingLanguage);
|
||||
|
||||
|
||||
UpdateDisplayLabels(messages);
|
||||
}
|
||||
|
||||
private static void HandleArtistAnnouncements()
|
||||
{
|
||||
ClearDisplay();
|
||||
|
||||
|
||||
OverlayForm.CurrentCategory = OverlayForm.Category.Artists;
|
||||
|
||||
|
||||
string[] messages = new string[]
|
||||
{
|
||||
"歌星選歌",
|
||||
"1.男歌星",
|
||||
"2.女歌星",
|
||||
"3.團體",
|
||||
"4.外語",
|
||||
"5.全部",
|
||||
};
|
||||
|
||||
|
||||
readyForSongListInput = true;
|
||||
|
||||
|
||||
OverlayForm.SetUIState(OverlayForm.UIState.SelectingArtistCategory);
|
||||
|
||||
|
||||
UpdateDisplayLabels(messages);
|
||||
}
|
||||
|
||||
private static void UpdateDisplayLabels(string[] messages)
|
||||
{
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
|
||||
foreach (var control in OverlayForm.MainForm.Controls.OfType<Control>().ToArray())
|
||||
{
|
||||
if (control != OverlayForm.MainForm.displayLabel &&
|
||||
control != OverlayForm.MainForm.pauseLabel &&
|
||||
control != OverlayForm.MainForm.muteLabel &&
|
||||
control != OverlayForm.MainForm.volumeUpLabel &&
|
||||
control != OverlayForm.MainForm.volumeDownLabel &&
|
||||
control != OverlayForm.MainForm.micUpLabel &&
|
||||
control != OverlayForm.MainForm.micDownLabel &&
|
||||
control != OverlayForm.MainForm.standardKeyLabel &&
|
||||
control != OverlayForm.MainForm.keyUpLabel &&
|
||||
control != OverlayForm.MainForm.keyDownLabel &&
|
||||
control != OverlayForm.MainForm.maleKeyLabel &&
|
||||
control != OverlayForm.MainForm.femaleKeyLabel &&
|
||||
control != OverlayForm.MainForm.squareLabel &&
|
||||
control != OverlayForm.MainForm.professionalLabel &&
|
||||
control != OverlayForm.MainForm.standardLabel &&
|
||||
control != OverlayForm.MainForm.singDownLabel &&
|
||||
control != OverlayForm.MainForm.brightLabel &&
|
||||
control != OverlayForm.MainForm.softLabel &&
|
||||
control != OverlayForm.MainForm.autoLabel &&
|
||||
control != OverlayForm.MainForm.romanticLabel &&
|
||||
control != OverlayForm.MainForm.dynamicLabel &&
|
||||
control != OverlayForm.MainForm.tintLabel &&
|
||||
control != OverlayForm.MainForm.blackBackgroundPanel &&
|
||||
control != OverlayForm.MainForm.nextSongLabel)
|
||||
{
|
||||
OverlayForm.MainForm.Controls.Remove(control);
|
||||
control.Dispose();
|
||||
}
|
||||
}
|
||||
OverlayForm.MainForm.UpdateDisplayLabels(messages);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
foreach (var control in OverlayForm.MainForm.Controls.OfType<Control>().ToArray())
|
||||
{
|
||||
if (control != OverlayForm.MainForm.displayLabel &&
|
||||
control != OverlayForm.MainForm.pauseLabel &&
|
||||
control != OverlayForm.MainForm.muteLabel &&
|
||||
control != OverlayForm.MainForm.volumeUpLabel &&
|
||||
control != OverlayForm.MainForm.volumeDownLabel &&
|
||||
control != OverlayForm.MainForm.micUpLabel &&
|
||||
control != OverlayForm.MainForm.micDownLabel &&
|
||||
control != OverlayForm.MainForm.standardKeyLabel &&
|
||||
control != OverlayForm.MainForm.keyUpLabel &&
|
||||
control != OverlayForm.MainForm.keyDownLabel &&
|
||||
control != OverlayForm.MainForm.maleKeyLabel &&
|
||||
control != OverlayForm.MainForm.femaleKeyLabel &&
|
||||
control != OverlayForm.MainForm.squareLabel &&
|
||||
control != OverlayForm.MainForm.professionalLabel &&
|
||||
control != OverlayForm.MainForm.standardLabel &&
|
||||
control != OverlayForm.MainForm.singDownLabel &&
|
||||
control != OverlayForm.MainForm.brightLabel &&
|
||||
control != OverlayForm.MainForm.softLabel &&
|
||||
control != OverlayForm.MainForm.autoLabel &&
|
||||
control != OverlayForm.MainForm.romanticLabel &&
|
||||
control != OverlayForm.MainForm.dynamicLabel &&
|
||||
control != OverlayForm.MainForm.tintLabel &&
|
||||
control != OverlayForm.MainForm.blackBackgroundPanel &&
|
||||
control != OverlayForm.MainForm.nextSongLabel)
|
||||
{
|
||||
OverlayForm.MainForm.Controls.Remove(control);
|
||||
control.Dispose();
|
||||
}
|
||||
}
|
||||
OverlayForm.MainForm.UpdateDisplayLabels(messages);
|
||||
}
|
||||
}
|
||||
|
||||
private static void HandleNumberInput(string trimmedData)
|
||||
{
|
||||
string number = trimmedData;
|
||||
|
||||
|
||||
var match = Regex.Match(trimmedData, @"^A23(\d)A4$");
|
||||
if (match.Success)
|
||||
{
|
||||
number = match.Groups[1].Value;
|
||||
|
||||
Console.WriteLine($"Handling number: {number}");
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (readyForSongListInput)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
OverlayForm.MainForm.OnUserInput(number);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayForm.MainForm.OnUserInput(number);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
OverlayForm.DisplayNumberAtTopLeft(number);
|
||||
OverlayForm.MainForm.HideAllLabels();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayForm.DisplayNumberAtTopLeft(number);
|
||||
OverlayForm.MainForm.HideAllLabels();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckLogForShutdown(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
|
||||
string content = File.ReadAllText(filePath).Replace(Environment.NewLine, "");
|
||||
if (content.Length >= 6 && content.Substring(content.Length - 6) == "bbbaaa")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void ShutdownComputer()
|
||||
{
|
||||
try
|
||||
{
|
||||
ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe", "/c shutdown /s /f /t 0")
|
||||
{
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
Process process = Process.Start(processStartInfo);
|
||||
process.WaitForExit();
|
||||
Console.WriteLine("Computer is shutting down...");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error shutting down computer: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
DirectShowLib.dll
Normal file
BIN
DirectShowLib.dll
Normal file
Binary file not shown.
BIN
DualScreenKTVPlayStation.exe
Normal file
BIN
DualScreenKTVPlayStation.exe
Normal file
Binary file not shown.
2080
DualScreenKTVPlayStation.nsi
Normal file
2080
DualScreenKTVPlayStation.nsi
Normal file
File diff suppressed because it is too large
Load Diff
BIN
EPPlus.dll
Normal file
BIN
EPPlus.dll
Normal file
Binary file not shown.
BIN
FavoriteDatabase.db
Normal file
BIN
FavoriteDatabase.db
Normal file
Binary file not shown.
53
FilterEnumerator.cs
Normal file
53
FilterEnumerator.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using DirectShowLib;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public class FilterEnumerator
|
||||
{
|
||||
private static readonly Guid IID_IPropertyBag = new Guid("55272A00-42CB-11CE-8135-00AA004BB851");
|
||||
|
||||
public void EnumerateFilters()
|
||||
{
|
||||
ICreateDevEnum createDevEnum = (ICreateDevEnum)new CreateDevEnum();
|
||||
IEnumMoniker enumMoniker;
|
||||
int hr = createDevEnum.CreateClassEnumerator(FilterCategory.LegacyAmFilterCategory, out enumMoniker, 0);
|
||||
if (hr != 0 || enumMoniker == null)
|
||||
{
|
||||
Console.WriteLine("No filters found.");
|
||||
return;
|
||||
}
|
||||
|
||||
IMoniker[] monikers = new IMoniker[1];
|
||||
IntPtr fetched = Marshal.AllocHGlobal(sizeof(int));
|
||||
while (enumMoniker.Next(1, monikers, fetched) == 0)
|
||||
{
|
||||
int fetchedCount = Marshal.ReadInt32(fetched);
|
||||
if (fetchedCount > 0)
|
||||
{
|
||||
object objPropBag;
|
||||
Guid tempGuid = IID_IPropertyBag;
|
||||
monikers[0].BindToStorage(null, null, ref tempGuid, out objPropBag);
|
||||
IPropertyBag propBag = objPropBag as IPropertyBag;
|
||||
|
||||
object filterName = null;
|
||||
if (propBag != null)
|
||||
{
|
||||
propBag.Read("FriendlyName", out filterName, null);
|
||||
}
|
||||
|
||||
if (filterName != null)
|
||||
{
|
||||
Console.WriteLine("Filter: " + filterName.ToString());
|
||||
}
|
||||
|
||||
Marshal.ReleaseComObject(monikers[0]);
|
||||
}
|
||||
}
|
||||
Marshal.ReleaseComObject(enumMoniker);
|
||||
Marshal.FreeHGlobal(fetched);
|
||||
}
|
||||
}
|
||||
}
|
10
FormatTypes.cs
Normal file
10
FormatTypes.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public static class FormatTypes
|
||||
{
|
||||
public static readonly Guid VideoInfo = new Guid("05589F80-C356-11CE-BF01-00AA0055595A");
|
||||
public static readonly Guid WaveEx = new Guid("05589f81-c356-11ce-bf01-00aa0055595a");
|
||||
}
|
||||
}
|
1212
HttpServer.cs
Normal file
1212
HttpServer.cs
Normal file
File diff suppressed because it is too large
Load Diff
50
HttpServerManager.cs
Normal file
50
HttpServerManager.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public static class HttpServerManager
|
||||
{
|
||||
public static void StartServer()
|
||||
{
|
||||
int httpPort = 9090; // 你可以修改此端口
|
||||
string baseDirectory = Path.Combine(Application.StartupPath, @"themes\superstar\_www");
|
||||
|
||||
CleanUpDirectory(baseDirectory);
|
||||
HttpServer.StartServer(baseDirectory, httpPort, Program.songListManager);
|
||||
}
|
||||
|
||||
|
||||
private static void CleanUpDirectory(string baseDirectory)
|
||||
{
|
||||
string[] directoriesToKeep = { "css", "fonts", "superstar-pic", "手機點歌" };
|
||||
|
||||
var allDirectories = Directory.GetDirectories(baseDirectory);
|
||||
var allFiles = Directory.GetFiles(baseDirectory);
|
||||
|
||||
var filesToKeep = allFiles
|
||||
.Where(file => file.EndsWith(".html"))
|
||||
.Select(file => Path.GetFileName(file))
|
||||
.ToArray();
|
||||
|
||||
foreach (var dir in allDirectories)
|
||||
{
|
||||
var dirName = Path.GetFileName(dir);
|
||||
if (!directoriesToKeep.Contains(dirName))
|
||||
{
|
||||
Directory.Delete(dir, true);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var file in allFiles)
|
||||
{
|
||||
var fileName = Path.GetFileName(file);
|
||||
if (!filesToKeep.Contains(fileName))
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
INIFileParser.dll
Normal file
BIN
INIFileParser.dll
Normal file
Binary file not shown.
BIN
INIFileParser.dll.mdb
Normal file
BIN
INIFileParser.dll.mdb
Normal file
Binary file not shown.
1181
INIFileParser.xml
Normal file
1181
INIFileParser.xml
Normal file
File diff suppressed because it is too large
Load Diff
32
ImagePanel.cs
Normal file
32
ImagePanel.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public class ImagePanel : Panel
|
||||
{
|
||||
public ImagePanel()
|
||||
{
|
||||
this.DoubleBuffered = true;
|
||||
this.Size = new Size(1201, 496);
|
||||
this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
}
|
||||
|
||||
public void SetBackgroundImageFromFile(string filePath, Rectangle cropArea)
|
||||
{
|
||||
Image image = Image.FromFile(filePath);
|
||||
Bitmap bmp = new Bitmap(cropArea.Width, cropArea.Height);
|
||||
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
g.DrawImage(image,
|
||||
new Rectangle(0, 0, bmp.Width, bmp.Height),
|
||||
cropArea,
|
||||
GraphicsUnit.Pixel);
|
||||
}
|
||||
|
||||
this.BackgroundImage = bmp;
|
||||
}
|
||||
}
|
||||
}
|
BIN
Interop.WMPLib.dll
Normal file
BIN
Interop.WMPLib.dll
Normal file
Binary file not shown.
BIN
KSongDatabase.db
Normal file
BIN
KSongDatabase.db
Normal file
Binary file not shown.
77245
KSongDatabase.sql
Normal file
77245
KSongDatabase.sql
Normal file
File diff suppressed because it is too large
Load Diff
BIN
MediaFoundation.dll
Normal file
BIN
MediaFoundation.dll
Normal file
Binary file not shown.
7
MediaSubTypes.cs
Normal file
7
MediaSubTypes.cs
Normal file
@ -0,0 +1,7 @@
|
||||
using System;
|
||||
|
||||
public static class MediaSubTypes
|
||||
{
|
||||
public static readonly Guid YUY2 = new Guid("32595559-0000-0010-8000-00AA00389B71");
|
||||
public static readonly Guid IEEE_FLOAT = new Guid("00000003-0000-0010-8000-00AA00389B71");
|
||||
}
|
10
MediaTypes.cs
Normal file
10
MediaTypes.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public static class MediaTypes
|
||||
{
|
||||
public static readonly Guid Video = new Guid("73646976-0000-0010-8000-00AA00389B71");
|
||||
public static readonly Guid Audio = new Guid("73647561-0000-0010-8000-00AA00389B71");
|
||||
}
|
||||
}
|
BIN
Microsoft.IO.RecyclableMemoryStream.dll
Normal file
BIN
Microsoft.IO.RecyclableMemoryStream.dll
Normal file
Binary file not shown.
BIN
Microsoft.Ink.dll
Normal file
BIN
Microsoft.Ink.dll
Normal file
Binary file not shown.
BIN
NAudio.dll
Normal file
BIN
NAudio.dll
Normal file
Binary file not shown.
BIN
Newtonsoft.Json.dll
Normal file
BIN
Newtonsoft.Json.dll
Normal file
Binary file not shown.
172
OverlayForm/OverlayForm.Helpers.cs
Normal file
172
OverlayForm/OverlayForm.Helpers.cs
Normal file
@ -0,0 +1,172 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class OverlayForm
|
||||
{
|
||||
private readonly object imageLock = new object();
|
||||
|
||||
private void AdjustLabelPositions()
|
||||
{
|
||||
int labelHeight = displayLabels.First().Height;
|
||||
int totalHeight = displayLabels.Count * labelHeight;
|
||||
int startY = 100;
|
||||
|
||||
for (int i = 0; i < displayLabels.Count; i++)
|
||||
{
|
||||
Label label = displayLabels[i];
|
||||
int centerX = (this.Width - label.Width) / 2;
|
||||
int centerY = startY + i * labelHeight;
|
||||
label.Location = new Point(centerX, centerY);
|
||||
}
|
||||
|
||||
if (pauseLabel != null)
|
||||
{
|
||||
|
||||
pauseLabel.Location = new Point(this.Width - pauseLabel.Width - 10, 100);
|
||||
}
|
||||
|
||||
if (muteLabel != null)
|
||||
{
|
||||
|
||||
muteLabel.Location = new Point(this.Width - muteLabel.Width - 10, 140);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateMarqueeText(string newText, MarqueeStartPosition startPosition, Color textColor)
|
||||
{
|
||||
this.marqueeText = newText;
|
||||
this.marqueeTextColor = textColor;
|
||||
|
||||
// 使用顯示字體進行測量
|
||||
Font displayFont = new Font("Arial", 25, FontStyle.Bold);
|
||||
|
||||
using (Graphics graphics = this.CreateGraphics())
|
||||
{
|
||||
SizeF textSize = graphics.MeasureString(marqueeText, displayFont);
|
||||
int textWidth = (int)textSize.Width;
|
||||
switch (startPosition)
|
||||
{
|
||||
case MarqueeStartPosition.Middle:
|
||||
this.marqueeXPos = (this.Width / 2) - (textWidth / 2) - 100;
|
||||
break;
|
||||
case MarqueeStartPosition.Right:
|
||||
this.marqueeXPos = this.Width;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.Invalidate();
|
||||
blackBackgroundPanel.Invalidate();
|
||||
}
|
||||
|
||||
public void UpdateMarqueeTextSecondLine(string newText)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new MethodInvoker(() => UpdateMarqueeTextSecondLine(newText)));
|
||||
return;
|
||||
}
|
||||
|
||||
marqueeTextSecondLine = newText;
|
||||
SplitSecondLineText(newText);
|
||||
|
||||
using (Graphics graphics = this.CreateGraphics())
|
||||
{
|
||||
float textWidth = MeasureDisplayStringWidth(graphics, marqueeTextSecondLine, new Font("微軟正黑體", 40, FontStyle.Bold));
|
||||
marqueeXPosSecondLine = (int)((this.Width - textWidth) / 2);
|
||||
}
|
||||
|
||||
if (textSegments.Count > 1)
|
||||
{
|
||||
segmentSwitchTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
segmentSwitchTimer.Stop();
|
||||
}
|
||||
|
||||
// 重置計時器
|
||||
if (secondLineTimer != null)
|
||||
{
|
||||
secondLineTimer.Stop();
|
||||
secondLineTimer.Dispose();
|
||||
}
|
||||
|
||||
secondLineTimer = new System.Windows.Forms.Timer();
|
||||
secondLineTimer.Interval = 100;
|
||||
secondLineStartTime = DateTime.Now;
|
||||
|
||||
secondLineTimer.Tick += (sender, e) =>
|
||||
{
|
||||
if ((DateTime.Now - secondLineStartTime).TotalMilliseconds >= 30000) // 30秒
|
||||
{
|
||||
marqueeTextSecondLine = "";
|
||||
textSegments.Clear(); // 清除分段文本
|
||||
if (segmentSwitchTimer != null)
|
||||
{
|
||||
segmentSwitchTimer.Stop(); // 停止分段切換計時器
|
||||
}
|
||||
secondLineTimer.Stop();
|
||||
secondLineTimer.Dispose();
|
||||
this.Invalidate();
|
||||
blackBackgroundPanel.Invalidate();
|
||||
}
|
||||
};
|
||||
|
||||
secondLineTimer.Start();
|
||||
blackBackgroundPanel.Invalidate();
|
||||
}
|
||||
|
||||
public void UpdateMarqueeTextThirdLine(string newText)
|
||||
{
|
||||
|
||||
Console.WriteLine("UpdateMarqueeTextThirdLine called with text: " + newText);
|
||||
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new MethodInvoker(() => UpdateMarqueeTextThirdLine(newText)));
|
||||
return;
|
||||
}
|
||||
marqueeTextThirdLine = newText;
|
||||
marqueeXPosThirdLine = this.Width;
|
||||
|
||||
|
||||
Console.WriteLine("Marquee text position reset to: " + marqueeXPosThirdLine);
|
||||
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private void MarqueeTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
marqueeXPos -= 2; // 調整移動速度
|
||||
|
||||
// 使用與顯示相同的字體來計算文本寬度
|
||||
using (Graphics graphics = this.CreateGraphics())
|
||||
{
|
||||
float textWidth = MeasureDisplayStringWidth(graphics, marqueeText, new Font("微軟正黑體", 34, FontStyle.Bold));
|
||||
|
||||
// 當文本完全移出屏幕時重置位置
|
||||
if (marqueeXPos < -textWidth)
|
||||
{
|
||||
marqueeXPos = this.Width;
|
||||
}
|
||||
}
|
||||
|
||||
this.Invalidate();
|
||||
blackBackgroundPanel.Invalidate();
|
||||
}
|
||||
|
||||
private float MeasureDisplayStringWidth(Graphics graphics, string text, Font font)
|
||||
{
|
||||
// 使用提供的字體來測量文本寬度
|
||||
SizeF textSize = graphics.MeasureString(text, font);
|
||||
return textSize.Width;
|
||||
}
|
||||
}
|
||||
}
|
1170
OverlayForm/OverlayForm.Labels.cs
Normal file
1170
OverlayForm/OverlayForm.Labels.cs
Normal file
File diff suppressed because it is too large
Load Diff
1919
OverlayForm/OverlayForm.cs
Normal file
1919
OverlayForm/OverlayForm.cs
Normal file
File diff suppressed because it is too large
Load Diff
BIN
Pinyin4net.dll
Normal file
BIN
Pinyin4net.dll
Normal file
Binary file not shown.
11
PlayState.cs
Normal file
11
PlayState.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
|
||||
public enum PlayState
|
||||
{
|
||||
Playing,
|
||||
Played,
|
||||
NotPlayed,
|
||||
Skipped
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void ChinaSongsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
loveDuetButton.BackgroundImage = loveDuetNormalBackground;
|
||||
talentShowButton.BackgroundImage = talentShowNormalBackground;
|
||||
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
|
||||
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
|
||||
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
|
||||
chinaSongsButton.BackgroundImage = chinaActiveBackground;
|
||||
|
||||
|
||||
chinaSongs = allSongs.Where(song => song.SongGenre.Contains("F1"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = chinaSongs;
|
||||
totalPages = (int)Math.Ceiling((double)chinaSongs.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void LoveDuetButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
loveDuetButton.BackgroundImage = loveDuetActiveBackground;
|
||||
talentShowButton.BackgroundImage = talentShowNormalBackground;
|
||||
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
|
||||
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
|
||||
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
|
||||
chinaSongsButton.BackgroundImage = chinaNormalBackground;
|
||||
|
||||
|
||||
loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = loveDuetSongs;
|
||||
totalPages = (int)Math.Ceiling((double)loveDuetSongs.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void MedleyDanceButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
loveDuetButton.BackgroundImage = loveDuetNormalBackground;
|
||||
talentShowButton.BackgroundImage = talentShowNormalBackground;
|
||||
medleyDanceButton.BackgroundImage = medleyDanceActiveBackground;
|
||||
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
|
||||
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
|
||||
chinaSongsButton.BackgroundImage = chinaNormalBackground;
|
||||
|
||||
|
||||
medleyDanceSongs = allSongs.Where(song => song.SongGenre.Contains("C1"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = medleyDanceSongs;
|
||||
totalPages = (int)Math.Ceiling((double)medleyDanceSongs.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void NinetiesButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
loveDuetButton.BackgroundImage = loveDuetNormalBackground;
|
||||
talentShowButton.BackgroundImage = talentShowNormalBackground;
|
||||
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
|
||||
ninetiesButton.BackgroundImage = ninetiesActiveBackground;
|
||||
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
|
||||
chinaSongsButton.BackgroundImage = chinaNormalBackground;
|
||||
|
||||
|
||||
ninetiesSongs = allSongs.Where(song => song.SongGenre.Contains("D1"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = ninetiesSongs;
|
||||
totalPages = (int)Math.Ceiling((double)ninetiesSongs.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void NostalgicSongsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
loveDuetButton.BackgroundImage = loveDuetNormalBackground;
|
||||
talentShowButton.BackgroundImage = talentShowNormalBackground;
|
||||
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
|
||||
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
|
||||
nostalgicSongsButton.BackgroundImage = nostalgicSongsActiveBackground;
|
||||
chinaSongsButton.BackgroundImage = chinaNormalBackground;
|
||||
|
||||
|
||||
nostalgicSongs = allSongs.Where(song => song.SongGenre.Contains("E1"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = nostalgicSongs;
|
||||
totalPages = (int)Math.Ceiling((double)nostalgicSongs.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void TalentShowButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
loveDuetButton.BackgroundImage = loveDuetNormalBackground;
|
||||
talentShowButton.BackgroundImage = talentShowActiveBackground;
|
||||
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
|
||||
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
|
||||
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
|
||||
chinaSongsButton.BackgroundImage = chinaNormalBackground;
|
||||
|
||||
|
||||
talentShowSongs = allSongs.Where(song => song.SongGenre.Contains("B1"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = talentShowSongs;
|
||||
totalPages = (int)Math.Ceiling((double)talentShowSongs.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void VietnameseSongsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
loveDuetButton.BackgroundImage = loveDuetNormalBackground;
|
||||
talentShowButton.BackgroundImage = talentShowNormalBackground;
|
||||
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
|
||||
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
|
||||
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
|
||||
chinaSongsButton.BackgroundImage = chinaNormalBackground;
|
||||
|
||||
|
||||
vietnameseSongs = allSongs.Where(song => song.SongGenre.Contains("G1"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = vietnameseSongs;
|
||||
totalPages = (int)Math.Ceiling((double)vietnameseSongs.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
257
PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.cs
Normal file
257
PrimaryFormParts/CategorySearch/PrimaryForm.CategorySearch.cs
Normal file
@ -0,0 +1,257 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private Button categorySearchButton;
|
||||
private Bitmap categorySearchNormalBackground;
|
||||
private Bitmap categorySearchActiveBackground;
|
||||
|
||||
private Button loveDuetButton;
|
||||
private Bitmap loveDuetNormalBackground;
|
||||
private Bitmap loveDuetActiveBackground;
|
||||
private Button talentShowButton;
|
||||
private Bitmap talentShowNormalBackground;
|
||||
private Bitmap talentShowActiveBackground;
|
||||
private Button medleyDanceButton;
|
||||
private Bitmap medleyDanceNormalBackground;
|
||||
private Bitmap medleyDanceActiveBackground;
|
||||
private Button ninetiesButton;
|
||||
private Bitmap ninetiesNormalBackground;
|
||||
private Bitmap ninetiesActiveBackground;
|
||||
private Button nostalgicSongsButton;
|
||||
private Bitmap nostalgicSongsNormalBackground;
|
||||
private Bitmap nostalgicSongsActiveBackground;
|
||||
private Button chinaSongsButton;
|
||||
private Bitmap chinaNormalBackground;
|
||||
private Bitmap chinaActiveBackground;
|
||||
private Button vietnameseSongsButton;
|
||||
private Bitmap vietnameseNormalBackground;
|
||||
private Bitmap vietnameseActiveBackground;
|
||||
|
||||
private void InitializeButtonsForCategorySearch()
|
||||
{
|
||||
categorySearchButton = new Button { Text = "" };
|
||||
categorySearchButton.Name = "categorySearchButton";
|
||||
ResizeAndPositionButton(categorySearchButton, 731, 97, 99, 99);
|
||||
Rectangle categorySearchCropArea = new Rectangle(731, 97, 99, 99);
|
||||
categorySearchNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\ICON上方\\上方ICON_類別查詢-07.png"));
|
||||
categorySearchActiveBackground = mouseDownImage.Clone(categorySearchCropArea, mouseDownImage.PixelFormat);
|
||||
categorySearchButton.BackgroundImage = categorySearchNormalBackground;
|
||||
categorySearchButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
categorySearchButton.FlatStyle = FlatStyle.Flat;
|
||||
categorySearchButton.FlatAppearance.BorderSize = 0;
|
||||
categorySearchButton.Click += CategorySearchButton_Click;
|
||||
this.Controls.Add(categorySearchButton);
|
||||
}
|
||||
|
||||
private void InitializeCategorySearchButtons()
|
||||
{
|
||||
|
||||
loveDuetButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(loveDuetButton, 1214, 230, 209, 59);
|
||||
Rectangle loveDuetButtonCropArea = new Rectangle(1214, 230, 209, 59);
|
||||
loveDuetNormalBackground = normalStateImageCategoryQuery.Clone(loveDuetButtonCropArea, normalStateImageCategoryQuery.PixelFormat);
|
||||
loveDuetActiveBackground = mouseDownImageCategoryQuery.Clone(loveDuetButtonCropArea, mouseDownImageCategoryQuery.PixelFormat);
|
||||
loveDuetButton.BackgroundImage = loveDuetNormalBackground;
|
||||
loveDuetButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
loveDuetButton.FlatStyle = FlatStyle.Flat;
|
||||
loveDuetButton.FlatAppearance.BorderSize = 0;
|
||||
loveDuetButton.Click += LoveDuetButton_Click;
|
||||
this.Controls.Add(loveDuetButton);
|
||||
|
||||
|
||||
talentShowButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(talentShowButton, 1214, 293, 209, 58);
|
||||
Rectangle talentShowButtonCropArea = new Rectangle(1214, 293, 209, 58);
|
||||
talentShowNormalBackground = normalStateImageCategoryQuery.Clone(talentShowButtonCropArea, normalStateImageCategoryQuery.PixelFormat);
|
||||
talentShowActiveBackground = mouseDownImageCategoryQuery.Clone(talentShowButtonCropArea, mouseDownImageCategoryQuery.PixelFormat);
|
||||
talentShowButton.BackgroundImage = talentShowNormalBackground;
|
||||
talentShowButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
talentShowButton.FlatStyle = FlatStyle.Flat;
|
||||
talentShowButton.FlatAppearance.BorderSize = 0;
|
||||
talentShowButton.Click += TalentShowButton_Click;
|
||||
this.Controls.Add(talentShowButton);
|
||||
|
||||
|
||||
medleyDanceButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(medleyDanceButton, 1214, 356, 209, 58);
|
||||
Rectangle medleyDanceButtonCropArea = new Rectangle(1214, 356, 209, 58);
|
||||
medleyDanceNormalBackground = normalStateImageCategoryQuery.Clone(medleyDanceButtonCropArea, normalStateImageCategoryQuery.PixelFormat);
|
||||
medleyDanceActiveBackground = mouseDownImageCategoryQuery.Clone(medleyDanceButtonCropArea, mouseDownImageCategoryQuery.PixelFormat);
|
||||
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
|
||||
medleyDanceButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
medleyDanceButton.FlatStyle = FlatStyle.Flat;
|
||||
medleyDanceButton.FlatAppearance.BorderSize = 0;
|
||||
medleyDanceButton.Click += MedleyDanceButton_Click;
|
||||
this.Controls.Add(medleyDanceButton);
|
||||
|
||||
|
||||
ninetiesButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(ninetiesButton, 1214, 418, 209, 59);
|
||||
Rectangle ninetiesButtonCropArea = new Rectangle(1214, 418, 209, 59);
|
||||
ninetiesNormalBackground = normalStateImageCategoryQuery.Clone(ninetiesButtonCropArea, normalStateImageCategoryQuery.PixelFormat);
|
||||
ninetiesActiveBackground = mouseDownImageCategoryQuery.Clone(ninetiesButtonCropArea, mouseDownImageCategoryQuery.PixelFormat);
|
||||
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
|
||||
ninetiesButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
ninetiesButton.FlatStyle = FlatStyle.Flat;
|
||||
ninetiesButton.FlatAppearance.BorderSize = 0;
|
||||
ninetiesButton.Click += NinetiesButton_Click;
|
||||
this.Controls.Add(ninetiesButton);
|
||||
|
||||
|
||||
nostalgicSongsButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(nostalgicSongsButton, 1214, 481, 209, 59);
|
||||
Rectangle nostalgicSongsButtonCropArea = new Rectangle(1214, 481, 209, 59);
|
||||
nostalgicSongsNormalBackground = normalStateImageCategoryQuery.Clone(nostalgicSongsButtonCropArea, normalStateImageCategoryQuery.PixelFormat);
|
||||
nostalgicSongsActiveBackground = mouseDownImageCategoryQuery.Clone(nostalgicSongsButtonCropArea, mouseDownImageCategoryQuery.PixelFormat);
|
||||
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
|
||||
nostalgicSongsButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
nostalgicSongsButton.FlatStyle = FlatStyle.Flat;
|
||||
nostalgicSongsButton.FlatAppearance.BorderSize = 0;
|
||||
nostalgicSongsButton.Click += NostalgicSongsButton_Click;
|
||||
this.Controls.Add(nostalgicSongsButton);
|
||||
|
||||
|
||||
chinaSongsButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(chinaSongsButton, 1214, 544, 209, 58);
|
||||
Rectangle chinaCropArea = new Rectangle(1214, 544, 209, 58);
|
||||
|
||||
chinaNormalBackground = normalStateImageCategoryQuery.Clone(chinaCropArea, normalStateImageCategoryQuery.PixelFormat);
|
||||
chinaActiveBackground = mouseDownImageCategoryQuery.Clone(chinaCropArea, mouseDownImageCategoryQuery.PixelFormat);
|
||||
chinaSongsButton.BackgroundImage = chinaNormalBackground;
|
||||
chinaSongsButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
chinaSongsButton.FlatStyle = FlatStyle.Flat;
|
||||
chinaSongsButton.FlatAppearance.BorderSize = 0;
|
||||
chinaSongsButton.Click += ChinaSongsButton_Click;
|
||||
this.Controls.Add(chinaSongsButton);
|
||||
|
||||
vietnameseSongsButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(vietnameseSongsButton, 1214, 607, 209, 58);
|
||||
Rectangle vietnameseCropArea = new Rectangle(1214, 607, 209, 58);
|
||||
|
||||
vietnameseNormalBackground = normalStateImageCategoryQuery.Clone(vietnameseCropArea, normalStateImageCategoryQuery.PixelFormat);
|
||||
vietnameseActiveBackground = mouseDownImageCategoryQuery.Clone(vietnameseCropArea, mouseDownImageCategoryQuery.PixelFormat);
|
||||
vietnameseSongsButton.BackgroundImage = vietnameseNormalBackground;
|
||||
vietnameseSongsButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
vietnameseSongsButton.FlatStyle = FlatStyle.Flat;
|
||||
vietnameseSongsButton.FlatAppearance.BorderSize = 0;
|
||||
vietnameseSongsButton.Click += VietnameseSongsButton_Click;
|
||||
this.Controls.Add(vietnameseSongsButton);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void CategorySearchButton_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 = categorySearchActiveBackground;
|
||||
orderedSongsButton.BackgroundImage = orderedSongsNormalBackground;
|
||||
myFavoritesButton.BackgroundImage = myFavoritesNormalBackground;
|
||||
promotionsButton.BackgroundImage = promotionsNormalBackground;
|
||||
deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground;
|
||||
isOnOrderedSongsPage = false;
|
||||
|
||||
loveDuetButton.BackgroundImage = loveDuetActiveBackground;
|
||||
talentShowButton.BackgroundImage = talentShowNormalBackground;
|
||||
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
|
||||
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
|
||||
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
|
||||
chinaSongsButton.BackgroundImage = chinaNormalBackground;
|
||||
|
||||
|
||||
loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = loveDuetSongs;
|
||||
totalPages = (int)Math.Ceiling((double)loveDuetSongs.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
|
||||
|
||||
SetHotSongButtonsVisibility(false);
|
||||
SetNewSongButtonsVisibility(false);
|
||||
SetSingerSearchButtonsVisibility(false);
|
||||
SetSongSearchButtonsVisibility(false);
|
||||
SetPictureBoxLanguageButtonsVisibility(false);
|
||||
SetGroupButtonsVisibility(false);
|
||||
SetZhuYinSingersAndButtonsVisibility(false);
|
||||
SetZhuYinSongsAndButtonsVisibility(false);
|
||||
SetEnglishSingersAndButtonsVisibility(false);
|
||||
SetEnglishSongsAndButtonsVisibility(false);
|
||||
SetPinYinSingersAndButtonsVisibility(false);
|
||||
SetPinYinSongsAndButtonsVisibility(false);
|
||||
SetPictureBoxToggleLightAndButtonsVisibility(false);
|
||||
SetPictureBoxSceneSoundEffectsAndButtonsVisibility(false);
|
||||
SetPictureBoxCategoryAndButtonsVisibility(true);
|
||||
|
||||
|
||||
if (pictureBoxQRCode != null)
|
||||
{
|
||||
pictureBoxQRCode.Visible = false;
|
||||
closeQRCodeButton.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void TogglePictureBoxCategoryButtonsVisibility()
|
||||
{
|
||||
|
||||
bool areButtonsVisible = loveDuetButton.Visible;
|
||||
|
||||
|
||||
SetPictureBoxCategoryAndButtonsVisibility(!areButtonsVisible);
|
||||
}
|
||||
|
||||
private void SetPictureBoxCategoryAndButtonsVisibility(bool isVisible)
|
||||
{
|
||||
loveDuetButton.Visible = isVisible;
|
||||
loveDuetButton.BringToFront();
|
||||
|
||||
talentShowButton.Visible = isVisible;
|
||||
talentShowButton.BringToFront();
|
||||
|
||||
medleyDanceButton.Visible = isVisible;
|
||||
medleyDanceButton.BringToFront();
|
||||
|
||||
ninetiesButton.Visible = isVisible;
|
||||
ninetiesButton.BringToFront();
|
||||
|
||||
nostalgicSongsButton.Visible = isVisible;
|
||||
nostalgicSongsButton.BringToFront();
|
||||
|
||||
chinaSongsButton.Visible = isVisible;
|
||||
chinaSongsButton.BringToFront();
|
||||
|
||||
vietnameseSongsButton.Visible = isVisible;
|
||||
vietnameseSongsButton.BringToFront();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void GroupGuoYuButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
groupGuoYuButton.BackgroundImage = groupGuoYuActiveBackground;
|
||||
groupTaiYuButton.BackgroundImage = groupTaiYuNormalBackground;
|
||||
groupYueYuButton.BackgroundImage = groupYueYuNormalBackground;
|
||||
groupYingWenButton.BackgroundImage = groupYingWenNormalBackground;
|
||||
groupRiYuButton.BackgroundImage = groupRiYuNormalBackground;
|
||||
groupHanYuButton.BackgroundImage = groupHanYuNormalBackground;
|
||||
|
||||
guoYuSongs = allSongs.Where(song => song.Category == "國語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = guoYuSongs;
|
||||
totalPages = (int)Math.Ceiling((double)guoYuSongs.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void GroupHanYuButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
groupGuoYuButton.BackgroundImage = groupGuoYuNormalBackground;
|
||||
groupTaiYuButton.BackgroundImage = groupTaiYuNormalBackground;
|
||||
groupYueYuButton.BackgroundImage = groupYueYuNormalBackground;
|
||||
groupYingWenButton.BackgroundImage = groupYingWenNormalBackground;
|
||||
groupRiYuButton.BackgroundImage = groupRiYuNormalBackground;
|
||||
groupHanYuButton.BackgroundImage = groupHanYuActiveBackground;
|
||||
|
||||
hanYuSongs = allSongs.Where(song => song.Category == "韓語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = hanYuSongs;
|
||||
totalPages = (int)Math.Ceiling((double)hanYuSongs.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
31
PrimaryFormParts/GroupSearch/PrimaryForm.GroupSearch.RiYu.cs
Normal file
31
PrimaryFormParts/GroupSearch/PrimaryForm.GroupSearch.RiYu.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void GroupRiYuButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
groupGuoYuButton.BackgroundImage = groupGuoYuNormalBackground;
|
||||
groupTaiYuButton.BackgroundImage = groupTaiYuNormalBackground;
|
||||
groupYueYuButton.BackgroundImage = groupYueYuNormalBackground;
|
||||
groupYingWenButton.BackgroundImage = groupYingWenNormalBackground;
|
||||
groupRiYuButton.BackgroundImage = groupRiYuActiveBackground;
|
||||
groupHanYuButton.BackgroundImage = groupHanYuNormalBackground;
|
||||
|
||||
riYuSongs = allSongs.Where(song => song.Category == "日語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = riYuSongs;
|
||||
totalPages = (int)Math.Ceiling((double)riYuSongs.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void GroupTaiYuButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
groupGuoYuButton.BackgroundImage = groupGuoYuNormalBackground;
|
||||
groupTaiYuButton.BackgroundImage = groupTaiYuActiveBackground;
|
||||
groupYueYuButton.BackgroundImage = groupYueYuNormalBackground;
|
||||
groupYingWenButton.BackgroundImage = groupYingWenNormalBackground;
|
||||
groupRiYuButton.BackgroundImage = groupRiYuNormalBackground;
|
||||
groupHanYuButton.BackgroundImage = groupHanYuNormalBackground;
|
||||
|
||||
taiYuSongs = allSongs.Where(song => song.Category == "台語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = taiYuSongs;
|
||||
totalPages = (int)Math.Ceiling((double)taiYuSongs.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void GroupYingWenButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
groupGuoYuButton.BackgroundImage = groupGuoYuNormalBackground;
|
||||
groupTaiYuButton.BackgroundImage = groupTaiYuNormalBackground;
|
||||
groupYueYuButton.BackgroundImage = groupYueYuNormalBackground;
|
||||
groupYingWenButton.BackgroundImage = groupYingWenActiveBackground;
|
||||
groupRiYuButton.BackgroundImage = groupRiYuNormalBackground;
|
||||
groupHanYuButton.BackgroundImage = groupHanYuNormalBackground;
|
||||
|
||||
yingWenSongs = allSongs.Where(song => song.Category == "英文" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = yingWenSongs;
|
||||
totalPages = (int)Math.Ceiling((double)yingWenSongs.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void GroupYueYuButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
groupGuoYuButton.BackgroundImage = groupGuoYuNormalBackground;
|
||||
groupTaiYuButton.BackgroundImage = groupTaiYuNormalBackground;
|
||||
groupYueYuButton.BackgroundImage = groupYueYuActiveBackground;
|
||||
groupYingWenButton.BackgroundImage = groupYingWenNormalBackground;
|
||||
groupRiYuButton.BackgroundImage = groupRiYuNormalBackground;
|
||||
groupHanYuButton.BackgroundImage = groupHanYuNormalBackground;
|
||||
|
||||
yueYuSongs = allSongs.Where(song => song.Category == "粵語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = yueYuSongs;
|
||||
totalPages = (int)Math.Ceiling((double)yueYuSongs.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
187
PrimaryFormParts/GroupSearch/PrimaryForm.GroupSearch.cs
Normal file
187
PrimaryFormParts/GroupSearch/PrimaryForm.GroupSearch.cs
Normal file
@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private Button groupSearchButton;
|
||||
private Bitmap groupSearchNormalBackground;
|
||||
private Bitmap groupSearchActiveBackground;
|
||||
|
||||
private Button groupGuoYuButton;
|
||||
private Bitmap groupGuoYuNormalBackground;
|
||||
private Bitmap groupGuoYuActiveBackground;
|
||||
private Button groupTaiYuButton;
|
||||
private Bitmap groupTaiYuNormalBackground;
|
||||
private Bitmap groupTaiYuActiveBackground;
|
||||
private Button groupYueYuButton;
|
||||
private Bitmap groupYueYuNormalBackground;
|
||||
private Bitmap groupYueYuActiveBackground;
|
||||
private Button groupYingWenButton;
|
||||
private Bitmap groupYingWenNormalBackground;
|
||||
private Bitmap groupYingWenActiveBackground;
|
||||
private Button groupRiYuButton;
|
||||
private Bitmap groupRiYuNormalBackground;
|
||||
private Bitmap groupRiYuActiveBackground;
|
||||
private Button groupHanYuButton;
|
||||
private Bitmap groupHanYuNormalBackground;
|
||||
private Bitmap groupHanYuActiveBackground;
|
||||
|
||||
private void InitializeButtonsForGroupPictureBox()
|
||||
{
|
||||
|
||||
groupGuoYuButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(groupGuoYuButton, 1214, 230, 209, 59);
|
||||
Rectangle groupGuoYuButtonCropArea = new Rectangle(1214, 230, 209, 59);
|
||||
groupGuoYuNormalBackground = normalStateImageLanguageQuery.Clone(groupGuoYuButtonCropArea, normalStateImageLanguageQuery.PixelFormat);
|
||||
groupGuoYuActiveBackground = mouseDownImageLanguageQuery.Clone(groupGuoYuButtonCropArea, mouseDownImageLanguageQuery.PixelFormat);
|
||||
groupGuoYuButton.BackgroundImage = groupGuoYuNormalBackground;
|
||||
groupGuoYuButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
groupGuoYuButton.FlatStyle = FlatStyle.Flat;
|
||||
groupGuoYuButton.FlatAppearance.BorderSize = 0;
|
||||
groupGuoYuButton.Click += GroupGuoYuButton_Click;
|
||||
this.Controls.Add(groupGuoYuButton);
|
||||
|
||||
|
||||
groupTaiYuButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(groupTaiYuButton, 1214, 293, 209, 58);
|
||||
Rectangle groupTaiYuButtonCropArea = new Rectangle(1214, 293, 209, 58);
|
||||
groupTaiYuNormalBackground = normalStateImageLanguageQuery.Clone(groupTaiYuButtonCropArea, normalStateImageLanguageQuery.PixelFormat);
|
||||
groupTaiYuActiveBackground = mouseDownImageLanguageQuery.Clone(groupTaiYuButtonCropArea, mouseDownImageLanguageQuery.PixelFormat);
|
||||
groupTaiYuButton.BackgroundImage = groupTaiYuNormalBackground;
|
||||
groupTaiYuButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
groupTaiYuButton.FlatStyle = FlatStyle.Flat;
|
||||
groupTaiYuButton.FlatAppearance.BorderSize = 0;
|
||||
groupTaiYuButton.Click += GroupTaiYuButton_Click;
|
||||
this.Controls.Add(groupTaiYuButton);
|
||||
|
||||
|
||||
groupYueYuButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(groupYueYuButton, 1214, 356, 209, 58);
|
||||
Rectangle groupYueYuButtonCropArea = new Rectangle(1214, 356, 209, 58);
|
||||
groupYueYuNormalBackground = normalStateImageLanguageQuery.Clone(groupYueYuButtonCropArea, normalStateImageLanguageQuery.PixelFormat);
|
||||
groupYueYuActiveBackground = mouseDownImageLanguageQuery.Clone(groupYueYuButtonCropArea, mouseDownImageLanguageQuery.PixelFormat);
|
||||
groupYueYuButton.BackgroundImage = groupYueYuNormalBackground;
|
||||
groupYueYuButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
groupYueYuButton.FlatStyle = FlatStyle.Flat;
|
||||
groupYueYuButton.FlatAppearance.BorderSize = 0;
|
||||
groupYueYuButton.Click += GroupYueYuButton_Click;
|
||||
this.Controls.Add(groupYueYuButton);
|
||||
|
||||
|
||||
groupYingWenButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(groupYingWenButton, 1214, 418, 209, 59);
|
||||
Rectangle groupYingWenButtonCropArea = new Rectangle(1214, 418, 209, 59);
|
||||
groupYingWenNormalBackground = normalStateImageLanguageQuery.Clone(groupYingWenButtonCropArea, normalStateImageLanguageQuery.PixelFormat);
|
||||
groupYingWenActiveBackground = mouseDownImageLanguageQuery.Clone(groupYingWenButtonCropArea, mouseDownImageLanguageQuery.PixelFormat);
|
||||
groupYingWenButton.BackgroundImage = groupYingWenNormalBackground;
|
||||
groupYingWenButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
groupYingWenButton.FlatStyle = FlatStyle.Flat;
|
||||
groupYingWenButton.FlatAppearance.BorderSize = 0;
|
||||
groupYingWenButton.Click += GroupYingWenButton_Click;
|
||||
this.Controls.Add(groupYingWenButton);
|
||||
|
||||
|
||||
groupRiYuButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(groupRiYuButton, 1214, 481, 209, 59);
|
||||
Rectangle groupRiYuButtonCropArea = new Rectangle(1214, 481, 209, 59);
|
||||
groupRiYuNormalBackground = normalStateImageLanguageQuery.Clone(groupRiYuButtonCropArea, normalStateImageLanguageQuery.PixelFormat);
|
||||
groupRiYuActiveBackground = mouseDownImageLanguageQuery.Clone(groupRiYuButtonCropArea, mouseDownImageLanguageQuery.PixelFormat);
|
||||
groupRiYuButton.BackgroundImage = groupRiYuNormalBackground;
|
||||
groupRiYuButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
groupRiYuButton.FlatStyle = FlatStyle.Flat;
|
||||
groupRiYuButton.FlatAppearance.BorderSize = 0;
|
||||
groupRiYuButton.Click += GroupRiYuButton_Click;
|
||||
this.Controls.Add(groupRiYuButton);
|
||||
|
||||
|
||||
groupHanYuButton = new Button { Text = "", Visible = false };
|
||||
ResizeAndPositionButton(groupHanYuButton, 1214, 544, 209, 58);
|
||||
Rectangle groupHanYuButtonCropArea = new Rectangle(1214, 544, 209, 58);
|
||||
groupHanYuNormalBackground = normalStateImageLanguageQuery.Clone(groupHanYuButtonCropArea, normalStateImageLanguageQuery.PixelFormat);
|
||||
groupHanYuActiveBackground = mouseDownImageLanguageQuery.Clone(groupHanYuButtonCropArea, mouseDownImageLanguageQuery.PixelFormat);
|
||||
groupHanYuButton.BackgroundImage = groupHanYuNormalBackground;
|
||||
groupHanYuButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
groupHanYuButton.FlatStyle = FlatStyle.Flat;
|
||||
groupHanYuButton.FlatAppearance.BorderSize = 0;
|
||||
groupHanYuButton.Click += GroupHanYuButton_Click;
|
||||
this.Controls.Add(groupHanYuButton);
|
||||
}
|
||||
|
||||
private void GroupSongSelectionButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
newSongAlertButton.BackgroundImage = newSongAlertNormalBackground;
|
||||
hotPlayButton.BackgroundImage = hotPlayNormalBackground;
|
||||
singerSearchButton.BackgroundImage = singerSearchNormalBackground;
|
||||
songSearchButton.BackgroundImage = songSearchNormalBackground;
|
||||
languageSearchButton.BackgroundImage = languageSearchNormalBackground;
|
||||
groupSearchButton.BackgroundImage = groupSearchActiveBackground;
|
||||
categorySearchButton.BackgroundImage = categorySearchNormalBackground;
|
||||
orderedSongsButton.BackgroundImage = orderedSongsNormalBackground;
|
||||
myFavoritesButton.BackgroundImage = myFavoritesNormalBackground;
|
||||
promotionsButton.BackgroundImage = promotionsNormalBackground;
|
||||
deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground;
|
||||
isOnOrderedSongsPage = false;
|
||||
|
||||
groupGuoYuButton.BackgroundImage = groupGuoYuActiveBackground;
|
||||
groupTaiYuButton.BackgroundImage = groupTaiYuNormalBackground;
|
||||
groupYueYuButton.BackgroundImage = groupYueYuNormalBackground;
|
||||
groupYingWenButton.BackgroundImage = groupYingWenNormalBackground;
|
||||
groupRiYuButton.BackgroundImage = groupRiYuNormalBackground;
|
||||
groupHanYuButton.BackgroundImage = groupHanYuNormalBackground;
|
||||
|
||||
guoYuSongs = allSongs.Where(song => song.Category == "國語" && (song.ArtistACategory == "團" || song.ArtistBCategory == "團"))
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = guoYuSongs;
|
||||
totalPages = (int)Math.Ceiling((double)guoYuSongs.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
|
||||
|
||||
SetHotSongButtonsVisibility(false);
|
||||
SetNewSongButtonsVisibility(false);
|
||||
SetSingerSearchButtonsVisibility(false);
|
||||
SetSongSearchButtonsVisibility(false);
|
||||
SetPictureBoxLanguageButtonsVisibility(false);
|
||||
SetPictureBoxCategoryAndButtonsVisibility(false);
|
||||
SetZhuYinSingersAndButtonsVisibility(false);
|
||||
SetZhuYinSongsAndButtonsVisibility(false);
|
||||
SetEnglishSingersAndButtonsVisibility(false);
|
||||
SetEnglishSongsAndButtonsVisibility(false);
|
||||
SetPinYinSingersAndButtonsVisibility(false);
|
||||
SetPinYinSongsAndButtonsVisibility(false);
|
||||
SetPictureBoxToggleLightAndButtonsVisibility(false);
|
||||
SetPictureBoxSceneSoundEffectsAndButtonsVisibility(false);
|
||||
SetGroupButtonsVisibility(true);
|
||||
|
||||
|
||||
if (pictureBoxQRCode != null)
|
||||
{
|
||||
pictureBoxQRCode.Visible = false;
|
||||
closeQRCodeButton.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetGroupButtonsVisibility(bool isVisible)
|
||||
{
|
||||
Button[] pictureBox6Buttons = { groupGuoYuButton, groupTaiYuButton, groupYueYuButton, groupYingWenButton, groupRiYuButton, groupHanYuButton };
|
||||
|
||||
foreach (var button in pictureBox6Buttons)
|
||||
{
|
||||
button.Visible = isVisible;
|
||||
if (isVisible)
|
||||
{
|
||||
button.BringToFront();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
288
PrimaryFormParts/HotSong/PrimaryForm.HotSong.cs
Normal file
288
PrimaryFormParts/HotSong/PrimaryForm.HotSong.cs
Normal file
@ -0,0 +1,288 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private Button hotPlayButton;
|
||||
private Bitmap hotPlayNormalBackground;
|
||||
private Bitmap hotPlayActiveBackground;
|
||||
|
||||
private Button guoYuButtonHotSong;
|
||||
private Bitmap guoYuHotSongNormalBackground;
|
||||
private Bitmap guoYuHotSongActiveBackground;
|
||||
private Button taiYuButtonHotSong;
|
||||
private Bitmap taiYuHotSongNormalBackground;
|
||||
private Bitmap taiYuHotSongActiveBackground;
|
||||
private Button taiYuNewSongButtonHotSong;
|
||||
private Bitmap taiYuNewSongHotSongNormalBackground;
|
||||
private Bitmap taiYuNewSongHotSongActiveBackground;
|
||||
private Button guoYuNewSongButtonHotSong;
|
||||
private Bitmap guoYuNewSongHotSongNormalBackground;
|
||||
private Bitmap guoYuNewSongHotSongActiveBackground;
|
||||
private Button yueYuButtonHotSong;
|
||||
private Bitmap yueYuHotSongNormalBackground;
|
||||
private Bitmap yueYuHotSongActiveBackground;
|
||||
private Button yingWenButtonHotSong;
|
||||
private Bitmap yingWenHotSongNormalBackground;
|
||||
private Bitmap yingWenHotSongActiveBackground;
|
||||
private Button riYuButtonHotSong;
|
||||
private Bitmap riYuHotSongNormalBackground;
|
||||
private Bitmap riYuHotSongActiveBackground;
|
||||
private Button hanYuButtonHotSong;
|
||||
private Bitmap hanYuHotSongNormalBackground;
|
||||
private Bitmap hanYuHotSongActiveBackground;
|
||||
|
||||
|
||||
private void SetHotSongButtonsVisibility(bool isVisible)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
Button[] hotSongButtons = { guoYuButtonHotSong, taiYuButtonHotSong, taiYuNewSongButtonHotSong, guoYuNewSongButtonHotSong, yingWenButtonHotSong, riYuButtonHotSong, hanYuButtonHotSong };
|
||||
|
||||
|
||||
foreach (var button in hotSongButtons)
|
||||
{
|
||||
button.Visible = isVisible;
|
||||
|
||||
|
||||
if (isVisible)
|
||||
{
|
||||
button.BringToFront();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HotPlayButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
UpdateButtonBackgrounds(hotPlayButton, hotPlayActiveBackground);
|
||||
UpdateHotSongButtons(guoYuButtonHotSong, guoYuHotSongActiveBackground);
|
||||
isOnOrderedSongsPage = false;
|
||||
|
||||
int songLimit = ReadHotSongLimit();
|
||||
|
||||
guoYuSongs = GetSongsByCategory("國語", songLimit);
|
||||
UpdateSongList(guoYuSongs);
|
||||
|
||||
SetButtonsVisibility();
|
||||
HideQRCode();
|
||||
}
|
||||
|
||||
private void UpdateButtonBackgrounds(Button activeButton, Image activeBackground)
|
||||
{
|
||||
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 = myFavoritesNormalBackground;
|
||||
promotionsButton.BackgroundImage = promotionsNormalBackground;
|
||||
deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground;
|
||||
|
||||
activeButton.BackgroundImage = activeBackground;
|
||||
}
|
||||
|
||||
private void OnHotSongButtonClick(Button activeButton, Bitmap activeBackground, string category)
|
||||
{
|
||||
UpdateHotSongButtons(activeButton, activeBackground);
|
||||
|
||||
int songLimit = ReadHotSongLimit();
|
||||
|
||||
var selectedSongs = allSongs.Where(song => song.Category == category)
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.Take(songLimit)
|
||||
.ToList();
|
||||
|
||||
UpdateSongList(selectedSongs);
|
||||
}
|
||||
|
||||
private void UpdateHotSongButtons(Button activeButton, Image activeBackground)
|
||||
{
|
||||
guoYuButtonHotSong.BackgroundImage = guoYuHotSongNormalBackground;
|
||||
taiYuButtonHotSong.BackgroundImage = taiYuHotSongNormalBackground;
|
||||
taiYuNewSongButtonHotSong.BackgroundImage = taiYuNewSongHotSongNormalBackground;
|
||||
guoYuNewSongButtonHotSong.BackgroundImage = guoYuNewSongHotSongNormalBackground;
|
||||
yingWenButtonHotSong.BackgroundImage = yingWenHotSongNormalBackground;
|
||||
riYuButtonHotSong.BackgroundImage = riYuHotSongNormalBackground;
|
||||
hanYuButtonHotSong.BackgroundImage = hanYuHotSongNormalBackground;
|
||||
|
||||
activeButton.BackgroundImage = activeBackground;
|
||||
}
|
||||
|
||||
private List<SongData> GetSongsByCategory(string category, int limit)
|
||||
{
|
||||
return allSongs.Where(song => song.Category == category)
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.Take(limit)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private void UpdateSongList(List<SongData> songs)
|
||||
{
|
||||
currentPage = 0;
|
||||
currentSongList = songs;
|
||||
totalPages = (int)Math.Ceiling((double)songs.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
|
||||
private void SetButtonsVisibility()
|
||||
{
|
||||
SetNewSongButtonsVisibility(false);
|
||||
SetSingerSearchButtonsVisibility(false);
|
||||
SetSongSearchButtonsVisibility(false);
|
||||
SetPictureBoxLanguageButtonsVisibility(false);
|
||||
SetGroupButtonsVisibility(false);
|
||||
SetPictureBoxCategoryAndButtonsVisibility(false);
|
||||
SetZhuYinSingersAndButtonsVisibility(false);
|
||||
SetZhuYinSongsAndButtonsVisibility(false);
|
||||
SetEnglishSingersAndButtonsVisibility(false);
|
||||
SetEnglishSongsAndButtonsVisibility(false);
|
||||
SetPinYinSingersAndButtonsVisibility(false);
|
||||
SetPinYinSongsAndButtonsVisibility(false);
|
||||
SetPictureBoxToggleLightAndButtonsVisibility(false);
|
||||
SetPictureBoxSceneSoundEffectsAndButtonsVisibility(false);
|
||||
SetHotSongButtonsVisibility(true);
|
||||
}
|
||||
|
||||
private void HideQRCode()
|
||||
{
|
||||
if (pictureBoxQRCode != null)
|
||||
{
|
||||
pictureBoxQRCode.Visible = false;
|
||||
closeQRCodeButton.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeButtonsForHotSong()
|
||||
{
|
||||
|
||||
InitializeHotSongButton(ref guoYuNewSongButtonHotSong, "國語新歌", 1214, 230, 209, 58,
|
||||
normalStateImageHotSong,
|
||||
out guoYuNewSongHotSongNormalBackground,
|
||||
mouseDownImageHotSong,
|
||||
out guoYuNewSongHotSongActiveBackground,
|
||||
GuoYuNewSongButtonHotSong_Click);
|
||||
|
||||
InitializeHotSongButton(ref taiYuNewSongButtonHotSong, "台語新歌", 1214, 293, 209, 58,
|
||||
normalStateImageHotSong,
|
||||
out taiYuNewSongHotSongNormalBackground,
|
||||
mouseDownImageHotSong,
|
||||
out taiYuNewSongHotSongActiveBackground,
|
||||
TaiYuNewSongButtonHotSong_Click);
|
||||
|
||||
|
||||
InitializeHotSongButton(ref taiYuButtonHotSong, "台語", 1214, 418, 209, 58,
|
||||
normalStateImageHotSong,
|
||||
out taiYuHotSongNormalBackground,
|
||||
mouseDownImageHotSong,
|
||||
out taiYuHotSongActiveBackground,
|
||||
TaiYuButtonHotSong_Click);
|
||||
|
||||
|
||||
InitializeHotSongButton(ref yueYuButtonHotSong, "粵語", 1214, 356, 209, 58,
|
||||
normalStateImageHotSong,
|
||||
out yueYuHotSongNormalBackground,
|
||||
mouseDownImageHotSong,
|
||||
out yueYuHotSongActiveBackground,
|
||||
YueYuButtonHotSong_Click);
|
||||
|
||||
InitializeHotSongButton(ref guoYuButtonHotSong, "國語", 1214, 356, 209, 59,
|
||||
normalStateImageHotSong,
|
||||
out guoYuHotSongNormalBackground,
|
||||
mouseDownImageHotSong,
|
||||
out guoYuHotSongActiveBackground,
|
||||
GuoYuButtonHotSong_Click);
|
||||
|
||||
InitializeHotSongButton(ref yingWenButtonHotSong, "英文", 1214, 481, 209, 59,
|
||||
normalStateImageHotSong,
|
||||
out yingWenHotSongNormalBackground,
|
||||
mouseDownImageHotSong,
|
||||
out yingWenHotSongActiveBackground,
|
||||
YingWenButtonHotSong_Click);
|
||||
|
||||
InitializeHotSongButton(ref riYuButtonHotSong, "日語", 1214, 544, 209, 59,
|
||||
normalStateImageHotSong,
|
||||
out riYuHotSongNormalBackground,
|
||||
mouseDownImageHotSong,
|
||||
out riYuHotSongActiveBackground,
|
||||
RiYuButtonHotSong_Click);
|
||||
|
||||
InitializeHotSongButton(ref hanYuButtonHotSong, "韓語", 1214, 607, 209, 58,
|
||||
normalStateImageHotSong,
|
||||
out hanYuHotSongNormalBackground,
|
||||
mouseDownImageHotSong,
|
||||
out hanYuHotSongActiveBackground,
|
||||
HanYuButtonHotSong_Click);
|
||||
|
||||
}
|
||||
|
||||
private void InitializeHotSongButton(ref Button button, string buttonText, int x, int y, int width, int height,
|
||||
Image normalBackground, out Bitmap normalBackgroundOut,
|
||||
Image activeBackground, out Bitmap activeBackgroundOut,
|
||||
EventHandler clickEventHandler)
|
||||
{
|
||||
button = new Button {
|
||||
Text = "", // 移除文字
|
||||
Visible = false
|
||||
};
|
||||
ResizeAndPositionButton(button, x, y, width, height);
|
||||
|
||||
// 修改裁剪區域,避開文字部分
|
||||
Rectangle cropArea = new Rectangle(1214, y, 209, 58); // 使用固定的裁剪區域
|
||||
|
||||
normalBackgroundOut = new Bitmap(normalBackground).Clone(cropArea, normalBackground.PixelFormat);
|
||||
activeBackgroundOut = new Bitmap(activeBackground).Clone(cropArea, activeBackground.PixelFormat);
|
||||
|
||||
button.BackgroundImage = normalBackgroundOut;
|
||||
button.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button.FlatStyle = FlatStyle.Flat;
|
||||
button.FlatAppearance.BorderSize = 0;
|
||||
button.Click += clickEventHandler;
|
||||
this.Controls.Add(button);
|
||||
}
|
||||
|
||||
public static int ReadHotSongLimit()
|
||||
{
|
||||
string filePath = Path.Combine(Application.StartupPath, "SongLimitsSettings.txt");
|
||||
try
|
||||
{
|
||||
|
||||
var lines = File.ReadAllLines(filePath);
|
||||
foreach (var line in lines)
|
||||
{
|
||||
|
||||
if (line.StartsWith("HotSongLimit:"))
|
||||
{
|
||||
string valuePart = line.Split(':')[1].Trim();
|
||||
int limit;
|
||||
if (int.TryParse(valuePart, out limit))
|
||||
{
|
||||
return limit;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Failed to read song limits from file: " + ex.Message);
|
||||
return 100;
|
||||
}
|
||||
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
}
|
15
PrimaryFormParts/HotSong/PrimaryForm.HotSongCantonese.cs
Normal file
15
PrimaryFormParts/HotSong/PrimaryForm.HotSongCantonese.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void YueYuButtonHotSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnHotSongButtonClick(yueYuButtonHotSong, yueYuHotSongActiveBackground, "粵語");
|
||||
}
|
||||
}
|
||||
}
|
15
PrimaryFormParts/HotSong/PrimaryForm.HotSongChinese.cs
Normal file
15
PrimaryFormParts/HotSong/PrimaryForm.HotSongChinese.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void GuoYuButtonHotSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnHotSongButtonClick(guoYuButtonHotSong, guoYuHotSongActiveBackground, "國語");
|
||||
}
|
||||
}
|
||||
}
|
15
PrimaryFormParts/HotSong/PrimaryForm.HotSongEnglish.cs
Normal file
15
PrimaryFormParts/HotSong/PrimaryForm.HotSongEnglish.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void YingWenButtonHotSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnHotSongButtonClick(yingWenButtonHotSong, yingWenHotSongActiveBackground, "英文");
|
||||
}
|
||||
}
|
||||
}
|
15
PrimaryFormParts/HotSong/PrimaryForm.HotSongJapanese.cs
Normal file
15
PrimaryFormParts/HotSong/PrimaryForm.HotSongJapanese.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void RiYuButtonHotSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnHotSongButtonClick(riYuButtonHotSong, riYuHotSongActiveBackground, "日語");
|
||||
}
|
||||
}
|
||||
}
|
15
PrimaryFormParts/HotSong/PrimaryForm.HotSongKorean.cs
Normal file
15
PrimaryFormParts/HotSong/PrimaryForm.HotSongKorean.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void HanYuButtonHotSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnHotSongButtonClick(hanYuButtonHotSong, hanYuHotSongActiveBackground, "韓語");
|
||||
}
|
||||
}
|
||||
}
|
31
PrimaryFormParts/HotSong/PrimaryForm.HotSongMandarinNew.cs
Normal file
31
PrimaryFormParts/HotSong/PrimaryForm.HotSongMandarinNew.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void GuoYuNewSongButtonHotSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
// 重置其他按钮背景
|
||||
UpdateHotSongButtons(guoYuNewSongButtonHotSong, guoYuNewSongHotSongActiveBackground);
|
||||
|
||||
int songLimit = ReadHotSongLimit();
|
||||
|
||||
// 使用 AddedTime 排序
|
||||
var selectedSongs = allSongs.Where(song => song.Category == "國語")
|
||||
.OrderByDescending(song => song.AddedTime)
|
||||
.Take(songLimit)
|
||||
.ToList();
|
||||
|
||||
currentPage = 0;
|
||||
currentSongList = selectedSongs;
|
||||
totalPages = (int)Math.Ceiling((double)selectedSongs.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
15
PrimaryFormParts/HotSong/PrimaryForm.HotSongTaiwanese.cs
Normal file
15
PrimaryFormParts/HotSong/PrimaryForm.HotSongTaiwanese.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void TaiYuButtonHotSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnHotSongButtonClick(taiYuButtonHotSong, taiYuHotSongActiveBackground, "台語");
|
||||
}
|
||||
}
|
||||
}
|
32
PrimaryFormParts/HotSong/PrimaryForm.HotSongTaiwaneseNew.cs
Normal file
32
PrimaryFormParts/HotSong/PrimaryForm.HotSongTaiwaneseNew.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void TaiYuNewSongButtonHotSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
// 重置其他按钮背景
|
||||
UpdateHotSongButtons(taiYuNewSongButtonHotSong, taiYuNewSongHotSongActiveBackground);
|
||||
|
||||
int songLimit = ReadHotSongLimit();
|
||||
|
||||
// 使用 AddedTime 排序
|
||||
var selectedSongs = allSongs.Where(song => song.Category == "台語")
|
||||
.OrderByDescending(song => song.AddedTime)
|
||||
.Take(songLimit)
|
||||
.ToList();
|
||||
|
||||
currentPage = 0;
|
||||
currentSongList = selectedSongs;
|
||||
totalPages = (int)Math.Ceiling((double)selectedSongs.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
// using System;
|
||||
// using System.Linq;
|
||||
// using System.Windows.Forms;
|
||||
// using System.Drawing;
|
||||
|
||||
// namespace DualScreenDemo
|
||||
// {
|
||||
// public partial class PrimaryForm
|
||||
// {
|
||||
// private void TaiYuPopularButtonHotSong_Click(object sender, EventArgs e)
|
||||
// {
|
||||
// OnHotSongButtonClick(taiYuPopularButtonHotSong, taiYuPopularHotSongActiveBackground, "台語");
|
||||
// }
|
||||
// }
|
||||
// }
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void InitializeGuoYuButton()
|
||||
{
|
||||
Rectangle guoYuButtonCropArea = new Rectangle(1214, 230, 209, 59);
|
||||
InitializeButton(ref guoYuButton, "國語", 1214, 230, 209, 59, guoYuButtonCropArea, normalStateImageLanguageQuery, out guoYuNormalBackground, mouseDownImageLanguageQuery, out guoYuActiveBackground, GuoYuButton_Click);
|
||||
}
|
||||
|
||||
private void GuoYuButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnLanguageButtonClick(guoYuButton, guoYuActiveBackground, "國語");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void InitializeHanYuButton()
|
||||
{
|
||||
Rectangle hanYuButtonCropArea = new Rectangle(1214, 544, 209, 58);
|
||||
InitializeButton(ref hanYuButton, "韓語", 1214, 544, 209, 58, hanYuButtonCropArea, normalStateImageLanguageQuery, out hanYuNormalBackground, mouseDownImageLanguageQuery, out hanYuActiveBackground, HanYuButton_Click);
|
||||
}
|
||||
|
||||
private void HanYuButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnLanguageButtonClick(hanYuButton, hanYuActiveBackground, "韓語");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void InitializeKeYuButton()
|
||||
{
|
||||
Rectangle keYuButtonCropArea = new Rectangle(1214, 607, 209, 58);
|
||||
InitializeButton(ref keYuButton, "客語", 1214, 607, 209, 58, keYuButtonCropArea, normalStateImageLanguageQuery, out keYuNormalBackground, mouseDownImageLanguageQuery, out keYuActiveBackground, KeYuButton_Click);
|
||||
}
|
||||
|
||||
private void KeYuButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnLanguageButtonClick(keYuButton, keYuActiveBackground, "客語");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void InitializeRiYuButton()
|
||||
{
|
||||
Rectangle riYuButtonCropArea = new Rectangle(1214, 481, 209, 59);
|
||||
InitializeButton(ref riYuButton, "日語", 1214, 481, 209, 59, riYuButtonCropArea, normalStateImageLanguageQuery, out riYuNormalBackground, mouseDownImageLanguageQuery, out riYuActiveBackground, RiYuButton_Click);
|
||||
}
|
||||
|
||||
private void RiYuButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnLanguageButtonClick(riYuButton, riYuActiveBackground, "日語");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void InitializeTaiYuButton()
|
||||
{
|
||||
Rectangle taiYuButtonCropArea = new Rectangle(1214, 293, 209, 58);
|
||||
InitializeButton(ref taiYuButton, "台語", 1214, 293, 209, 58, taiYuButtonCropArea, normalStateImageLanguageQuery, out taiYuNormalBackground, mouseDownImageLanguageQuery, out taiYuActiveBackground, TaiYuButton_Click);
|
||||
}
|
||||
|
||||
private void TaiYuButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnLanguageButtonClick(taiYuButton, taiYuActiveBackground, "台語");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void InitializeYingWenButton()
|
||||
{
|
||||
Rectangle yingWenButtonCropArea = new Rectangle(1214, 418, 209, 59);
|
||||
InitializeButton(ref yingWenButton, "英文", 1214, 418, 209, 59, yingWenButtonCropArea, normalStateImageLanguageQuery, out yingWenNormalBackground, mouseDownImageLanguageQuery, out yingWenActiveBackground, YingWenButton_Click);
|
||||
}
|
||||
|
||||
private void YingWenButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnLanguageButtonClick(yingWenButton, yingWenActiveBackground, "英文");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void InitializeYueYuButton()
|
||||
{
|
||||
Rectangle yueYuButtonCropArea = new Rectangle(1214, 356, 209, 58);
|
||||
InitializeButton(ref yueYuButton, "粵語", 1214, 356, 209, 58, yueYuButtonCropArea, normalStateImageLanguageQuery, out yueYuNormalBackground, mouseDownImageLanguageQuery, out yueYuActiveBackground, YueYuButton_Click);
|
||||
}
|
||||
|
||||
private void YueYuButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OnLanguageButtonClick(yueYuButton, yueYuActiveBackground, "粵語");
|
||||
}
|
||||
}
|
||||
}
|
173
PrimaryFormParts/LanguageSearch/PrimaryForm.LanguageSearch.cs
Normal file
173
PrimaryFormParts/LanguageSearch/PrimaryForm.LanguageSearch.cs
Normal file
@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
|
||||
private void InitializeButton(ref Button button, string buttonText, int x, int y, int width, int height, Rectangle cropArea, Image normalBackground, out Bitmap normalBackgroundOut, Image activeBackground, out Bitmap activeBackgroundOut, EventHandler clickEventHandler)
|
||||
{
|
||||
button = new Button { Text = buttonText, Visible = false };
|
||||
ResizeAndPositionButton(button, x, y, width, height);
|
||||
normalBackgroundOut = new Bitmap(normalBackground).Clone(cropArea, normalBackground.PixelFormat);
|
||||
activeBackgroundOut = new Bitmap(activeBackground).Clone(cropArea, activeBackground.PixelFormat);
|
||||
button.BackgroundImage = normalBackgroundOut;
|
||||
button.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button.FlatStyle = FlatStyle.Flat;
|
||||
button.FlatAppearance.BorderSize = 0;
|
||||
button.Click += clickEventHandler;
|
||||
this.Controls.Add(button);
|
||||
}
|
||||
|
||||
private Button languageSearchButton;
|
||||
private Bitmap languageSearchNormalBackground;
|
||||
private Bitmap languageSearchActiveBackground;
|
||||
|
||||
private Button guoYuButton;
|
||||
private Bitmap guoYuNormalBackground;
|
||||
private Bitmap guoYuActiveBackground;
|
||||
private Button taiYuButton;
|
||||
private Bitmap taiYuNormalBackground;
|
||||
private Bitmap taiYuActiveBackground;
|
||||
private Button yueYuButton;
|
||||
private Bitmap yueYuNormalBackground;
|
||||
private Bitmap yueYuActiveBackground;
|
||||
private Button yingWenButton;
|
||||
private Bitmap yingWenNormalBackground;
|
||||
private Bitmap yingWenActiveBackground;
|
||||
private Button riYuButton;
|
||||
private Bitmap riYuNormalBackground;
|
||||
private Bitmap riYuActiveBackground;
|
||||
private Button hanYuButton;
|
||||
private Bitmap hanYuNormalBackground;
|
||||
private Bitmap hanYuActiveBackground;
|
||||
private Button keYuButton;
|
||||
private Bitmap keYuNormalBackground;
|
||||
private Bitmap keYuActiveBackground;
|
||||
|
||||
private void LanguageSongSelectionButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
newSongAlertButton.BackgroundImage = newSongAlertNormalBackground;
|
||||
hotPlayButton.BackgroundImage = hotPlayNormalBackground;
|
||||
singerSearchButton.BackgroundImage = singerSearchNormalBackground;
|
||||
songSearchButton.BackgroundImage = songSearchNormalBackground;
|
||||
languageSearchButton.BackgroundImage = languageSearchActiveBackground;
|
||||
groupSearchButton.BackgroundImage = groupSearchNormalBackground;
|
||||
categorySearchButton.BackgroundImage = categorySearchNormalBackground;
|
||||
orderedSongsButton.BackgroundImage = orderedSongsNormalBackground;
|
||||
myFavoritesButton.BackgroundImage = myFavoritesNormalBackground;
|
||||
promotionsButton.BackgroundImage = promotionsNormalBackground;
|
||||
deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground;
|
||||
isOnOrderedSongsPage = false;
|
||||
|
||||
guoYuButton.BackgroundImage = guoYuActiveBackground;
|
||||
taiYuButton.BackgroundImage = taiYuNormalBackground;
|
||||
yueYuButton.BackgroundImage = yueYuNormalBackground;
|
||||
yingWenButton.BackgroundImage = yingWenNormalBackground;
|
||||
riYuButton.BackgroundImage = riYuNormalBackground;
|
||||
hanYuButton.BackgroundImage = hanYuNormalBackground;
|
||||
keYuButton.BackgroundImage = keYuNormalBackground;
|
||||
|
||||
guoYuSongs = allSongs.Where(song => song.Category == "國語")
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = guoYuSongs;
|
||||
totalPages = (int)Math.Ceiling((double)guoYuSongs.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
|
||||
|
||||
SetHotSongButtonsVisibility(false);
|
||||
SetNewSongButtonsVisibility(false);
|
||||
SetSingerSearchButtonsVisibility(false);
|
||||
SetSongSearchButtonsVisibility(false);
|
||||
SetGroupButtonsVisibility(false);
|
||||
SetPictureBoxCategoryAndButtonsVisibility(false);
|
||||
SetZhuYinSingersAndButtonsVisibility(false);
|
||||
SetZhuYinSongsAndButtonsVisibility(false);
|
||||
SetEnglishSingersAndButtonsVisibility(false);
|
||||
SetEnglishSongsAndButtonsVisibility(false);
|
||||
SetPinYinSingersAndButtonsVisibility(false);
|
||||
SetPinYinSongsAndButtonsVisibility(false);
|
||||
SetPictureBoxToggleLightAndButtonsVisibility(false);
|
||||
SetPictureBoxSceneSoundEffectsAndButtonsVisibility(false);
|
||||
SetPictureBoxLanguageButtonsVisibility(true);
|
||||
|
||||
|
||||
if (pictureBoxQRCode != null)
|
||||
{
|
||||
pictureBoxQRCode.Visible = false;
|
||||
closeQRCodeButton.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLanguageButtonClick(Button activeButton, Image activeBackground, string category)
|
||||
{
|
||||
|
||||
guoYuButton.BackgroundImage = guoYuNormalBackground;
|
||||
taiYuButton.BackgroundImage = taiYuNormalBackground;
|
||||
yueYuButton.BackgroundImage = yueYuNormalBackground;
|
||||
yingWenButton.BackgroundImage = yingWenNormalBackground;
|
||||
riYuButton.BackgroundImage = riYuNormalBackground;
|
||||
hanYuButton.BackgroundImage = hanYuNormalBackground;
|
||||
keYuButton.BackgroundImage = keYuNormalBackground;
|
||||
|
||||
|
||||
activeButton.BackgroundImage = activeBackground;
|
||||
|
||||
|
||||
var selectedSongs = allSongs.Where(song => song.Category == category)
|
||||
.OrderByDescending(song => song.Plays)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = selectedSongs;
|
||||
totalPages = (int)Math.Ceiling((double)selectedSongs.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
|
||||
private void SetPictureBoxLanguageButtonsVisibility(bool isVisible)
|
||||
{
|
||||
guoYuButton.Visible = isVisible;
|
||||
guoYuButton.BringToFront();
|
||||
|
||||
taiYuButton.Visible = isVisible;
|
||||
taiYuButton.BringToFront();
|
||||
|
||||
yueYuButton.Visible = isVisible;
|
||||
yueYuButton.BringToFront();
|
||||
|
||||
yingWenButton.Visible = isVisible;
|
||||
yingWenButton.BringToFront();
|
||||
|
||||
riYuButton.Visible = isVisible;
|
||||
riYuButton.BringToFront();
|
||||
|
||||
hanYuButton.Visible = isVisible;
|
||||
hanYuButton.BringToFront();
|
||||
|
||||
keYuButton.Visible = isVisible;
|
||||
keYuButton.BringToFront();
|
||||
}
|
||||
|
||||
private void InitializeButtonsForPictureBoxLanguageQuery()
|
||||
{
|
||||
InitializeGuoYuButton();
|
||||
InitializeTaiYuButton();
|
||||
InitializeYueYuButton();
|
||||
InitializeYingWenButton();
|
||||
InitializeRiYuButton();
|
||||
InitializeHanYuButton();
|
||||
InitializeKeYuButton();
|
||||
}
|
||||
}
|
||||
}
|
258
PrimaryFormParts/NewSongAlert/PrimaryForm.NewSongAlert.cs
Normal file
258
PrimaryFormParts/NewSongAlert/PrimaryForm.NewSongAlert.cs
Normal file
@ -0,0 +1,258 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private Button newSongAlertButton;
|
||||
|
||||
private Bitmap newSongAlertNormalBackground;
|
||||
private Bitmap newSongAlertActiveBackground;
|
||||
|
||||
private Button guoYuButtonNewSong;
|
||||
private Bitmap guoYuNewSongNormalBackground;
|
||||
private Bitmap guoYuNewSongActiveBackground;
|
||||
private Button taiYuButtonNewSong;
|
||||
private Bitmap taiYuNewSongNormalBackground;
|
||||
private Bitmap taiYuNewSongActiveBackground;
|
||||
private Button yueYuButtonNewSong;
|
||||
private Bitmap yueYuNewSongNormalBackground;
|
||||
private Bitmap yueYuNewSongActiveBackground;
|
||||
private Button yingWenButtonNewSong;
|
||||
private Bitmap yingWenNewSongNormalBackground;
|
||||
private Bitmap yingWenNewSongActiveBackground;
|
||||
private Button riYuButtonNewSong;
|
||||
private Bitmap riYuNewSongNormalBackground;
|
||||
private Bitmap riYuNewSongActiveBackground;
|
||||
private Button hanYuButtonNewSong;
|
||||
private Bitmap hanYuNewSongNormalBackground;
|
||||
private Bitmap hanYuNewSongActiveBackground;
|
||||
|
||||
private void ToggleNewSongButtonsVisibility()
|
||||
{
|
||||
|
||||
bool areButtonsVisible = guoYuButtonNewSong.Visible;
|
||||
|
||||
|
||||
SetNewSongButtonsVisibility(!areButtonsVisible);
|
||||
}
|
||||
|
||||
private void SetNewSongButtonsVisibility(bool isVisible)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
Button[] pictureBox2Buttons = { guoYuButtonNewSong, taiYuButtonNewSong, yueYuButtonNewSong, yingWenButtonNewSong, riYuButtonNewSong, hanYuButtonNewSong };
|
||||
|
||||
|
||||
foreach (var button in pictureBox2Buttons)
|
||||
{
|
||||
button.Visible = isVisible;
|
||||
|
||||
|
||||
if (isVisible)
|
||||
{
|
||||
button.BringToFront();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void NewSongAlertButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
newSongAlertButton.BackgroundImage = newSongAlertActiveBackground;
|
||||
hotPlayButton.BackgroundImage = hotPlayNormalBackground;
|
||||
singerSearchButton.BackgroundImage = singerSearchNormalBackground;
|
||||
songSearchButton.BackgroundImage = songSearchNormalBackground;
|
||||
languageSearchButton.BackgroundImage = languageSearchNormalBackground;
|
||||
groupSearchButton.BackgroundImage = groupSearchNormalBackground;
|
||||
categorySearchButton.BackgroundImage = categorySearchNormalBackground;
|
||||
orderedSongsButton.BackgroundImage = orderedSongsNormalBackground;
|
||||
myFavoritesButton.BackgroundImage = myFavoritesNormalBackground;
|
||||
promotionsButton.BackgroundImage = promotionsNormalBackground;
|
||||
deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground;
|
||||
isOnOrderedSongsPage = false;
|
||||
|
||||
guoYuButtonNewSong.BackgroundImage = guoYuNewSongActiveBackground;
|
||||
taiYuButtonNewSong.BackgroundImage = taiYuNewSongNormalBackground;
|
||||
yueYuButtonNewSong.BackgroundImage = yueYuNewSongNormalBackground;
|
||||
yingWenButtonNewSong.BackgroundImage = yingWenNewSongNormalBackground;
|
||||
riYuButtonNewSong.BackgroundImage = riYuNewSongNormalBackground;
|
||||
hanYuButtonNewSong.BackgroundImage = hanYuNewSongNormalBackground;
|
||||
|
||||
int songLimit = ReadNewSongLimit();
|
||||
|
||||
guoYuSongs2 = allSongs.Where(song => song.Category == "國語")
|
||||
.OrderByDescending(song => song.AddedTime)
|
||||
.Take(songLimit)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = guoYuSongs2;
|
||||
totalPages = (int)Math.Ceiling((double)guoYuSongs2.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
|
||||
|
||||
SetHotSongButtonsVisibility(false);
|
||||
SetSingerSearchButtonsVisibility(false);
|
||||
SetSongSearchButtonsVisibility(false);
|
||||
SetPictureBoxLanguageButtonsVisibility(false);
|
||||
SetGroupButtonsVisibility(false);
|
||||
SetPictureBoxCategoryAndButtonsVisibility(false);
|
||||
SetZhuYinSingersAndButtonsVisibility(false);
|
||||
SetZhuYinSongsAndButtonsVisibility(false);
|
||||
SetEnglishSingersAndButtonsVisibility(false);
|
||||
SetEnglishSongsAndButtonsVisibility(false);
|
||||
SetPinYinSingersAndButtonsVisibility(false);
|
||||
SetPinYinSongsAndButtonsVisibility(false);
|
||||
SetPictureBoxToggleLightAndButtonsVisibility(false);
|
||||
SetPictureBoxSceneSoundEffectsAndButtonsVisibility(false);
|
||||
ToggleNewSongButtonsVisibility();
|
||||
|
||||
|
||||
if (pictureBoxQRCode != null)
|
||||
{
|
||||
pictureBoxQRCode.Visible = false;
|
||||
closeQRCodeButton.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeButtonsForNewSong()
|
||||
{
|
||||
|
||||
|
||||
guoYuButtonNewSong = new Button{ Text = "", Visible = false };
|
||||
|
||||
ResizeAndPositionButton(guoYuButtonNewSong, 1214, 230, 209, 59);
|
||||
Rectangle guoYuNewSongButtonCropArea = new Rectangle(1214, 230, 209, 59);
|
||||
guoYuNewSongNormalBackground = normalStateImageNewSongAlert.Clone(guoYuNewSongButtonCropArea, normalStateImageNewSongAlert.PixelFormat);
|
||||
guoYuNewSongActiveBackground = mouseDownImageNewSongAlert.Clone(guoYuNewSongButtonCropArea, mouseDownImageNewSongAlert.PixelFormat);
|
||||
guoYuButtonNewSong.BackgroundImage = guoYuNewSongNormalBackground;
|
||||
guoYuButtonNewSong.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
guoYuButtonNewSong.FlatStyle = FlatStyle.Flat;
|
||||
guoYuButtonNewSong.FlatAppearance.BorderSize = 0;
|
||||
|
||||
guoYuButtonNewSong.Click += GuoYuButtonNewSong_Click;
|
||||
|
||||
this.Controls.Add(guoYuButtonNewSong);
|
||||
|
||||
|
||||
taiYuButtonNewSong = new Button { Text = "", Visible = false };
|
||||
|
||||
ResizeAndPositionButton(taiYuButtonNewSong, 1214, 293, 209, 58);
|
||||
Rectangle taiYuNewSongButtonCropArea = new Rectangle(1214, 293, 209, 58);
|
||||
taiYuNewSongNormalBackground = normalStateImageNewSongAlert.Clone(taiYuNewSongButtonCropArea, normalStateImageNewSongAlert.PixelFormat);
|
||||
taiYuNewSongActiveBackground = mouseDownImageNewSongAlert.Clone(taiYuNewSongButtonCropArea, mouseDownImageNewSongAlert.PixelFormat);
|
||||
taiYuButtonNewSong.BackgroundImage = taiYuNewSongNormalBackground;
|
||||
taiYuButtonNewSong.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
taiYuButtonNewSong.FlatStyle = FlatStyle.Flat;
|
||||
taiYuButtonNewSong.FlatAppearance.BorderSize = 0;
|
||||
|
||||
taiYuButtonNewSong.Click += TaiYuButtonNewSong_Click;
|
||||
|
||||
this.Controls.Add(taiYuButtonNewSong);
|
||||
|
||||
|
||||
yueYuButtonNewSong = new Button { Text = "", Visible = false };
|
||||
|
||||
ResizeAndPositionButton(yueYuButtonNewSong, 1214, 356, 209, 58);
|
||||
Rectangle yueYuNewSongButtonCropArea = new Rectangle(1214, 356, 209, 58);
|
||||
yueYuNewSongNormalBackground = normalStateImageNewSongAlert.Clone(yueYuNewSongButtonCropArea, normalStateImageNewSongAlert.PixelFormat);
|
||||
yueYuNewSongActiveBackground = mouseDownImageNewSongAlert.Clone(yueYuNewSongButtonCropArea, mouseDownImageNewSongAlert.PixelFormat);
|
||||
yueYuButtonNewSong.BackgroundImage = yueYuNewSongNormalBackground;
|
||||
yueYuButtonNewSong.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
yueYuButtonNewSong.FlatStyle = FlatStyle.Flat;
|
||||
yueYuButtonNewSong.FlatAppearance.BorderSize = 0;
|
||||
|
||||
yueYuButtonNewSong.Click += YueYuButtonNewSong_Click;
|
||||
|
||||
this.Controls.Add(yueYuButtonNewSong);
|
||||
|
||||
|
||||
yingWenButtonNewSong = new Button { Text = "英文2", Visible = false };
|
||||
|
||||
ResizeAndPositionButton(yingWenButtonNewSong, 1214, 418, 209, 59);
|
||||
Rectangle yingWenNewSongButtonCropArea = new Rectangle(1214, 418, 209, 59);
|
||||
yingWenNewSongNormalBackground = normalStateImageNewSongAlert.Clone(yingWenNewSongButtonCropArea, normalStateImageNewSongAlert.PixelFormat);
|
||||
yingWenNewSongActiveBackground = mouseDownImageNewSongAlert.Clone(yingWenNewSongButtonCropArea, mouseDownImageNewSongAlert.PixelFormat);
|
||||
yingWenButtonNewSong.BackgroundImage = yingWenNewSongNormalBackground;
|
||||
yingWenButtonNewSong.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
yingWenButtonNewSong.FlatStyle = FlatStyle.Flat;
|
||||
yingWenButtonNewSong.FlatAppearance.BorderSize = 0;
|
||||
|
||||
yingWenButtonNewSong.Click += YingWenButtonNewSong_Click;
|
||||
|
||||
this.Controls.Add(yingWenButtonNewSong);
|
||||
|
||||
|
||||
riYuButtonNewSong = new Button { Text = "日語2", Visible = false };
|
||||
|
||||
ResizeAndPositionButton(riYuButtonNewSong, 1214, 481, 209, 59);
|
||||
Rectangle riYuNewSongButtonCropArea = new Rectangle(1214, 481, 209, 59);
|
||||
riYuNewSongNormalBackground = normalStateImageNewSongAlert.Clone(riYuNewSongButtonCropArea, normalStateImageNewSongAlert.PixelFormat);
|
||||
riYuNewSongActiveBackground = mouseDownImageNewSongAlert.Clone(riYuNewSongButtonCropArea, mouseDownImageNewSongAlert.PixelFormat);
|
||||
riYuButtonNewSong.BackgroundImage = riYuNewSongNormalBackground;
|
||||
riYuButtonNewSong.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
riYuButtonNewSong.FlatStyle = FlatStyle.Flat;
|
||||
riYuButtonNewSong.FlatAppearance.BorderSize = 0;
|
||||
|
||||
riYuButtonNewSong.Click += RiYuButtonNewSong_Click;
|
||||
|
||||
this.Controls.Add(riYuButtonNewSong);
|
||||
|
||||
|
||||
hanYuButtonNewSong = new Button { Text = "韓語2", Visible = false };
|
||||
|
||||
ResizeAndPositionButton(hanYuButtonNewSong, 1214, 544, 209, 58);
|
||||
Rectangle hanYuNewSongButtonCropArea = new Rectangle(1214, 544, 209, 58);
|
||||
hanYuNewSongNormalBackground = normalStateImageNewSongAlert.Clone(hanYuNewSongButtonCropArea, normalStateImageNewSongAlert.PixelFormat);
|
||||
hanYuNewSongActiveBackground = mouseDownImageNewSongAlert.Clone(hanYuNewSongButtonCropArea, mouseDownImageNewSongAlert.PixelFormat);
|
||||
hanYuButtonNewSong.BackgroundImage = hanYuNewSongNormalBackground;
|
||||
hanYuButtonNewSong.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
hanYuButtonNewSong.FlatStyle = FlatStyle.Flat;
|
||||
hanYuButtonNewSong.FlatAppearance.BorderSize = 0;
|
||||
|
||||
hanYuButtonNewSong.Click += HanYuButtonNewSong_Click;
|
||||
|
||||
this.Controls.Add(hanYuButtonNewSong);
|
||||
}
|
||||
|
||||
public static int ReadNewSongLimit()
|
||||
{
|
||||
string filePath = Path.Combine(Application.StartupPath, "SongLimitsSettings.txt");
|
||||
try
|
||||
{
|
||||
|
||||
var lines = File.ReadAllLines(filePath);
|
||||
foreach (var line in lines)
|
||||
{
|
||||
|
||||
if (line.StartsWith("NewSongLimit:"))
|
||||
{
|
||||
string valuePart = line.Split(':')[1].Trim();
|
||||
int limit;
|
||||
if (int.TryParse(valuePart, out limit))
|
||||
{
|
||||
return limit;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Failed to read song limits from file: " + ex.Message);
|
||||
return 100;
|
||||
}
|
||||
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void YueYuButtonNewSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
guoYuButtonNewSong.BackgroundImage = guoYuNewSongNormalBackground;
|
||||
taiYuButtonNewSong.BackgroundImage = taiYuNewSongNormalBackground;
|
||||
yueYuButtonNewSong.BackgroundImage = yueYuNewSongActiveBackground;
|
||||
yingWenButtonNewSong.BackgroundImage = yingWenNewSongNormalBackground;
|
||||
riYuButtonNewSong.BackgroundImage = riYuNewSongNormalBackground;
|
||||
hanYuButtonNewSong.BackgroundImage = hanYuNewSongNormalBackground;
|
||||
|
||||
int songLimit = ReadNewSongLimit();
|
||||
|
||||
yueYuSongs2 = allSongs.Where(song => song.Category == "粵語")
|
||||
.OrderByDescending(song => song.AddedTime)
|
||||
.Take(songLimit)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = yueYuSongs2;
|
||||
totalPages = (int)Math.Ceiling((double)yueYuSongs2.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void GuoYuButtonNewSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
guoYuButtonNewSong.BackgroundImage = guoYuNewSongActiveBackground;
|
||||
taiYuButtonNewSong.BackgroundImage = taiYuNewSongNormalBackground;
|
||||
yueYuButtonNewSong.BackgroundImage = yueYuNewSongNormalBackground;
|
||||
yingWenButtonNewSong.BackgroundImage = yingWenNewSongNormalBackground;
|
||||
riYuButtonNewSong.BackgroundImage = riYuNewSongNormalBackground;
|
||||
hanYuButtonNewSong.BackgroundImage = hanYuNewSongNormalBackground;
|
||||
|
||||
int songLimit = ReadNewSongLimit();
|
||||
|
||||
guoYuSongs2 = allSongs.Where(song => song.Category == "國語")
|
||||
.OrderByDescending(song => song.AddedTime)
|
||||
.Take(songLimit)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = guoYuSongs2;
|
||||
totalPages = (int)Math.Ceiling((double)guoYuSongs2.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void YingWenButtonNewSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
guoYuButtonNewSong.BackgroundImage = guoYuNewSongNormalBackground;
|
||||
taiYuButtonNewSong.BackgroundImage = taiYuNewSongNormalBackground;
|
||||
yueYuButtonNewSong.BackgroundImage = yueYuNewSongNormalBackground;
|
||||
yingWenButtonNewSong.BackgroundImage = yingWenNewSongActiveBackground;
|
||||
riYuButtonNewSong.BackgroundImage = riYuNewSongNormalBackground;
|
||||
hanYuButtonNewSong.BackgroundImage = hanYuNewSongNormalBackground;
|
||||
|
||||
int songLimit = ReadNewSongLimit();
|
||||
|
||||
yingWenSongs2 = allSongs.Where(song => song.Category == "英文")
|
||||
.OrderByDescending(song => song.AddedTime)
|
||||
.Take(songLimit)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = yingWenSongs2;
|
||||
totalPages = (int)Math.Ceiling((double)yingWenSongs2.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void RiYuButtonNewSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
guoYuButtonNewSong.BackgroundImage = guoYuNewSongNormalBackground;
|
||||
taiYuButtonNewSong.BackgroundImage = taiYuNewSongNormalBackground;
|
||||
yueYuButtonNewSong.BackgroundImage = yueYuNewSongNormalBackground;
|
||||
yingWenButtonNewSong.BackgroundImage = yingWenNewSongNormalBackground;
|
||||
riYuButtonNewSong.BackgroundImage = riYuNewSongActiveBackground;
|
||||
hanYuButtonNewSong.BackgroundImage = hanYuNewSongNormalBackground;
|
||||
|
||||
int songLimit = ReadNewSongLimit();
|
||||
|
||||
riYuSongs2 = allSongs.Where(song => song.Category == "日語")
|
||||
.OrderByDescending(song => song.AddedTime)
|
||||
.Take(songLimit)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = riYuSongs2;
|
||||
totalPages = (int)Math.Ceiling((double)riYuSongs2.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void HanYuButtonNewSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
guoYuButtonNewSong.BackgroundImage = guoYuNewSongNormalBackground;
|
||||
taiYuButtonNewSong.BackgroundImage = taiYuNewSongNormalBackground;
|
||||
yueYuButtonNewSong.BackgroundImage = yueYuNewSongNormalBackground;
|
||||
yingWenButtonNewSong.BackgroundImage = yingWenNewSongNormalBackground;
|
||||
riYuButtonNewSong.BackgroundImage = riYuNewSongNormalBackground;
|
||||
hanYuButtonNewSong.BackgroundImage = hanYuNewSongActiveBackground;
|
||||
|
||||
int songLimit = ReadNewSongLimit();
|
||||
|
||||
hanYuSongs2 = allSongs.Where(song => song.Category == "韓語")
|
||||
.OrderByDescending(song => song.AddedTime)
|
||||
.Take(songLimit)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = hanYuSongs2;
|
||||
totalPages = (int)Math.Ceiling((double)hanYuSongs2.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void TaiYuButtonNewSong_Click(object sender, EventArgs e)
|
||||
{
|
||||
guoYuButtonNewSong.BackgroundImage = guoYuNewSongNormalBackground;
|
||||
taiYuButtonNewSong.BackgroundImage = taiYuNewSongActiveBackground;
|
||||
yueYuButtonNewSong.BackgroundImage = yueYuNewSongNormalBackground;
|
||||
yingWenButtonNewSong.BackgroundImage = yingWenNewSongNormalBackground;
|
||||
riYuButtonNewSong.BackgroundImage = riYuNewSongNormalBackground;
|
||||
hanYuButtonNewSong.BackgroundImage = hanYuNewSongNormalBackground;
|
||||
|
||||
int songLimit = ReadNewSongLimit();
|
||||
|
||||
taiYuSongs2 = allSongs.Where(song => song.Category == "台語")
|
||||
.OrderByDescending(song => song.AddedTime)
|
||||
.Take(songLimit)
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = taiYuSongs2;
|
||||
totalPages = (int)Math.Ceiling((double)taiYuSongs2.Count / itemsPerPage);
|
||||
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
}
|
||||
}
|
416
PrimaryFormParts/PrimaryForm.Favorite.cs
Normal file
416
PrimaryFormParts/PrimaryForm.Favorite.cs
Normal file
@ -0,0 +1,416 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
|
||||
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[,]
|
||||
{
|
||||
{799, 508, 70, 65},
|
||||
{878, 508, 70, 65},
|
||||
{957, 508, 70, 65},
|
||||
{1036, 508, 70, 65},
|
||||
{1115, 508, 70, 65},
|
||||
{799, 580, 70, 65},
|
||||
{878, 580, 70, 65},
|
||||
{957, 580, 70, 65},
|
||||
{1036, 580, 70, 65},
|
||||
{1115, 580, 70, 65}
|
||||
};
|
||||
|
||||
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");
|
||||
string filePath = Path.Combine(Application.StartupPath, @"themes\superstar\我的最愛\我的最愛-" + fileName + ".jpg");
|
||||
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"
|
||||
};
|
||||
ResizeAndPositionButton(enterFavoriteButton, 842, 652, 70, 65);
|
||||
enterFavoriteButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\我的最愛\我的最愛-12.jpg"));
|
||||
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"
|
||||
};
|
||||
ResizeAndPositionButton(newFavoriteButton, 921, 652, 70, 65);
|
||||
newFavoriteButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\我的最愛\我的最愛-13.jpg"));
|
||||
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"
|
||||
};
|
||||
ResizeAndPositionButton(refillFavoriteButton, 999, 652, 70, 65);
|
||||
refillFavoriteButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\我的最愛\我的最愛-14.jpg"));
|
||||
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"
|
||||
};
|
||||
ResizeAndPositionButton(closeFavoriteButton, 1078, 652, 70, 65);
|
||||
closeFavoriteButton.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\我的最愛\我的最愛-15.jpg"));
|
||||
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();
|
||||
Console.WriteLine("Number button clicked: " + clickedButton.Tag.ToString());
|
||||
phonenumber = mobileNumber;
|
||||
|
||||
FavoritePictureBox.Invalidate();
|
||||
}
|
||||
}
|
||||
public static string phonenumber;
|
||||
private void FavoritePictureBox_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(mobileNumber))
|
||||
{
|
||||
using (Font font = new Font("Arial", 24))
|
||||
using (Brush brush = new SolidBrush(Color.Black))
|
||||
{
|
||||
int x = 16;
|
||||
int y = 68;
|
||||
|
||||
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)
|
||||
{
|
||||
if (SongListManager.Instance.CheckIfPhoneNumberExists(mobileNumber))
|
||||
{
|
||||
isPhoneNumberValid = true;
|
||||
SongListManager.Instance.UserLogin(mobileNumber);
|
||||
|
||||
ToggleFavoritePictureBoxButtonsVisibility();
|
||||
}
|
||||
else
|
||||
{
|
||||
isPhoneNumberValid = false;
|
||||
showError = true;
|
||||
FavoritePictureBox.Invalidate();
|
||||
FavoritePictureBox.Refresh();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
showError = true;
|
||||
isPhoneNumberValid = true;
|
||||
FavoritePictureBox.Invalidate();
|
||||
FavoritePictureBox.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void NewFavoriteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (mobileNumber.StartsWith("09") && mobileNumber.Length == 10)
|
||||
{
|
||||
if (SongListManager.Instance.CheckIfPhoneNumberExists(mobileNumber))
|
||||
{
|
||||
isPhoneNumberValid = true;
|
||||
SongListManager.Instance.UserLogin(mobileNumber);
|
||||
|
||||
ToggleFavoritePictureBoxButtonsVisibility();
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
ToggleFavoritePictureBoxButtonsVisibility();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
showError = true;
|
||||
isPhoneNumberValid = true;
|
||||
FavoritePictureBox.Invalidate();
|
||||
FavoritePictureBox.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void RefillFavoriteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
mobileNumber = string.Empty;
|
||||
|
||||
|
||||
showError = false;
|
||||
|
||||
|
||||
FavoritePictureBox.Invalidate();
|
||||
FavoritePictureBox.Refresh();
|
||||
|
||||
SongListManager.Instance.IsUserLoggedIn = false;
|
||||
SongListManager.Instance.UserPhoneNumber = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
private void CloseFavoriteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
ShowImageOnFavoritePictureBox(Path.Combine(Application.StartupPath, @"themes\superstar\其他介面\其他_我的最愛.jpg"));
|
||||
SetFavoritePictureBoxAndButtonsVisibility(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ToggleFavoritePictureBoxButtonsVisibility();
|
||||
}
|
||||
|
||||
|
||||
if (pictureBoxQRCode != null)
|
||||
{
|
||||
pictureBoxQRCode.Visible = false;
|
||||
closeQRCodeButton.Visible = false;
|
||||
}
|
||||
|
||||
SetPictureBoxToggleLightAndButtonsVisibility(false);
|
||||
SetPictureBoxSceneSoundEffectsAndButtonsVisibility(false);
|
||||
}
|
||||
|
||||
private void ShowImageOnFavoritePictureBox(string imagePath)
|
||||
{
|
||||
|
||||
Bitmap originalImage = new Bitmap(imagePath);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
FavoritePictureBox.Visible = true;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
PrimaryFormParts/PrimaryForm.OrderedSongs.cs
Normal file
15
PrimaryFormParts/PrimaryForm.OrderedSongs.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private Button orderedSongsButton;
|
||||
private Bitmap orderedSongsNormalBackground;
|
||||
private Bitmap orderedSongsActiveBackground;
|
||||
}
|
||||
}
|
173
PrimaryFormParts/PrimaryForm.Promotions.cs
Normal file
173
PrimaryFormParts/PrimaryForm.Promotions.cs
Normal file
@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private Button promotionsButton;
|
||||
private Bitmap promotionsNormalBackground;
|
||||
private Bitmap promotionsActiveBackground;
|
||||
private Button previousPromotionButton;
|
||||
private Button nextPromotionButton;
|
||||
private Button closePromotionsButton;
|
||||
|
||||
private void InitializePromotionsButton()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 設定基礎位置和間距
|
||||
int baseX = Screen.PrimaryScreen.Bounds.Width - 300;
|
||||
int baseY = Screen.PrimaryScreen.Bounds.Height - 120;
|
||||
int buttonSpacing = 90;
|
||||
|
||||
// 共用的按鈕設置
|
||||
void ConfigurePromotionButton(Button button, string imagePath, Point location)
|
||||
{
|
||||
button.Size = new Size(80, 80);
|
||||
button.BackColor = Color.Transparent;
|
||||
button.FlatStyle = FlatStyle.Flat;
|
||||
button.FlatAppearance.BorderSize = 0;
|
||||
button.FlatAppearance.MouseOverBackColor = Color.Transparent;
|
||||
button.FlatAppearance.MouseDownBackColor = Color.Transparent;
|
||||
button.Location = location;
|
||||
|
||||
using (var stream = new MemoryStream(File.ReadAllBytes(Path.Combine(Application.StartupPath, imagePath))))
|
||||
{
|
||||
var image = Image.FromStream(stream);
|
||||
if (image.PixelFormat != System.Drawing.Imaging.PixelFormat.Format32bppArgb)
|
||||
{
|
||||
var bitmap = new Bitmap(image.Width, image.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
using (var g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
g.Clear(Color.Transparent);
|
||||
g.DrawImage(image, 0, 0, image.Width, image.Height);
|
||||
}
|
||||
button.BackgroundImage = bitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
button.BackgroundImage = image;
|
||||
}
|
||||
}
|
||||
button.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
}
|
||||
|
||||
// 配置各個按鈕
|
||||
previousPromotionButton = new Button { Name = "previousPromotionButton", Visible = true };
|
||||
ConfigurePromotionButton(previousPromotionButton, "themes\\superstar\\上一頁.png", new Point(baseX, baseY));
|
||||
previousPromotionButton.Click += PreviousPromotionButton_Click;
|
||||
|
||||
closePromotionsButton = new Button { Name = "closePromotionsButton", Visible = false };
|
||||
ConfigurePromotionButton(closePromotionsButton, "themes\\superstar\\退出.png", new Point(baseX + buttonSpacing, baseY));
|
||||
closePromotionsButton.Click += ClosePromotionsButton_Click;
|
||||
|
||||
nextPromotionButton = new Button { Name = "nextPromotionButton", Visible = true };
|
||||
ConfigurePromotionButton(nextPromotionButton, "themes\\superstar\\下一頁.png", new Point(baseX + (buttonSpacing * 2), baseY));
|
||||
nextPromotionButton.Click += NextPromotionButton_Click;
|
||||
|
||||
this.Controls.Add(previousPromotionButton);
|
||||
this.Controls.Add(closePromotionsButton);
|
||||
this.Controls.Add(nextPromotionButton);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"初始化按鈕時發生錯誤: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private List<Image> LoadPromotionsImages()
|
||||
{
|
||||
List<Image> images = new List<Image>();
|
||||
string newsFolderPath = Path.Combine(Application.StartupPath, "news");
|
||||
|
||||
string[] imageFiles = Directory.GetFiles(newsFolderPath, "*.jpg");
|
||||
|
||||
foreach (string filePath in imageFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
images.Add(Image.FromFile(filePath));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error loading image: " + filePath + ". Exception: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return images;
|
||||
}
|
||||
|
||||
private void promotionsButton_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 = myFavoritesNormalBackground;
|
||||
promotionsButton.BackgroundImage = promotionsActiveBackground;
|
||||
deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground;
|
||||
isOnOrderedSongsPage = false;
|
||||
|
||||
|
||||
promotionsAndMenuPanel.LoadImages(promotions);
|
||||
promotionsAndMenuPanel.Visible = true;
|
||||
promotionsAndMenuPanel.BringToFront();
|
||||
|
||||
previousPromotionButton.Visible = true;
|
||||
previousPromotionButton.BringToFront();
|
||||
nextPromotionButton.Visible = true;
|
||||
nextPromotionButton.BringToFront();
|
||||
|
||||
closePromotionsButton.Visible = true;
|
||||
closePromotionsButton.BringToFront();
|
||||
|
||||
|
||||
if (pictureBoxQRCode != null)
|
||||
{
|
||||
pictureBoxQRCode.Visible = false;
|
||||
closeQRCodeButton.Visible = false;
|
||||
}
|
||||
|
||||
SetPictureBoxToggleLightAndButtonsVisibility(false);
|
||||
}
|
||||
|
||||
private void PreviousPromotionButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
promotionsAndMenuPanel.LoadPreviousPage();
|
||||
}
|
||||
|
||||
private void NextPromotionButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
promotionsAndMenuPanel.LoadNextPage();
|
||||
}
|
||||
|
||||
private void ClosePromotionsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
promotionsAndMenuPanel.Visible = false;
|
||||
previousPromotionButton.Visible = false;
|
||||
nextPromotionButton.Visible = false;
|
||||
closePromotionsButton.Visible = false;
|
||||
|
||||
HotPlayButton_Click(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
47
PrimaryFormParts/PrimaryForm.PromotionsAndMenuPanel.cs
Normal file
47
PrimaryFormParts/PrimaryForm.PromotionsAndMenuPanel.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private PromotionsAndMenuPanel promotionsAndMenuPanel;
|
||||
|
||||
private void InitializePromotionsAndMenuPanel()
|
||||
{
|
||||
promotionsAndMenuPanel = new PromotionsAndMenuPanel();
|
||||
ResizeAndPositionControl(promotionsAndMenuPanel, 0, 0, 1440, 900);
|
||||
this.Controls.Add(promotionsAndMenuPanel);
|
||||
|
||||
promotions = LoadPromotionsImages();
|
||||
menu = LoadMenuImages();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private List<Image> LoadMenuImages()
|
||||
{
|
||||
List<Image> images = new List<Image>();
|
||||
string foodsFolderPath = Path.Combine(Application.StartupPath, "foods");
|
||||
|
||||
string[] imageFiles = Directory.GetFiles(foodsFolderPath, "*.jpg");
|
||||
|
||||
foreach (string filePath in imageFiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
images.Add(Image.FromFile(filePath));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error loading image: " + filePath + ". Exception: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return images;
|
||||
}
|
||||
}
|
||||
}
|
142
PrimaryFormParts/PrimaryForm.QRCode.cs
Normal file
142
PrimaryFormParts/PrimaryForm.QRCode.cs
Normal file
@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm : Form
|
||||
{
|
||||
private PictureBox pictureBoxQRCode;
|
||||
private Button closeQRCodeButton;
|
||||
|
||||
private void OverlayQRCodeOnImage(string randomFolderPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string imagePath = Path.Combine(Application.StartupPath, "themes/superstar/cropped_qrcode.jpg");
|
||||
if (!File.Exists(imagePath))
|
||||
{
|
||||
Console.WriteLine("Base image not found: " + imagePath);
|
||||
return;
|
||||
}
|
||||
|
||||
using (Image baseImage = Image.FromFile(imagePath))
|
||||
{
|
||||
|
||||
string serverAddressFilePath = Path.Combine(Application.StartupPath, "txt", "ip.txt");
|
||||
if (!File.Exists(serverAddressFilePath))
|
||||
{
|
||||
Console.WriteLine("Server address file not found: " + serverAddressFilePath);
|
||||
return;
|
||||
}
|
||||
|
||||
string serverAddress = File.ReadAllText(serverAddressFilePath).Trim();
|
||||
|
||||
// 根据地址格式生成不同的URL
|
||||
string qrContent = serverAddress.Contains(":") ?
|
||||
String.Format("http://{0}/{1}/windows.html", serverAddress, randomFolderPath) :
|
||||
String.Format("http://{0}:{1}/{2}/windows.html", serverAddress, 9090, randomFolderPath);
|
||||
Console.WriteLine("QR Content: " + qrContent);
|
||||
|
||||
|
||||
string qrImagePath = Path.Combine(Application.StartupPath, "themes/superstar/_www", randomFolderPath, "qrcode.png");
|
||||
if (!File.Exists(qrImagePath))
|
||||
{
|
||||
Console.WriteLine("QR code image not found: " + qrImagePath);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Image qrCodeImage = null;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var fs = new FileStream(qrImagePath, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
qrCodeImage = Image.FromStream(fs);
|
||||
}
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error loading QR code image: " + ex.Message);
|
||||
System.Threading.Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
if (qrCodeImage == null)
|
||||
{
|
||||
Console.WriteLine("Failed to load QR code image after multiple attempts.");
|
||||
return;
|
||||
}
|
||||
|
||||
using (qrCodeImage)
|
||||
{
|
||||
|
||||
using (Bitmap bitmap = new Bitmap(baseImage.Width, baseImage.Height))
|
||||
{
|
||||
using (Graphics g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
|
||||
g.DrawImage(baseImage, 0, 0);
|
||||
|
||||
|
||||
|
||||
Rectangle qrCodeRect = new Rectangle(32, 39, 165, 165);
|
||||
|
||||
g.DrawImage(qrCodeImage, qrCodeRect);
|
||||
}
|
||||
|
||||
|
||||
pictureBoxQRCode.Image = new Bitmap(bitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ResizeAndPositionControl(pictureBoxQRCode, 975, 442, 226, 274);
|
||||
|
||||
|
||||
Bitmap originalImage = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\cropped_qrcode.jpg"));
|
||||
|
||||
|
||||
Rectangle closeQRCodeCropArea = new Rectangle(198, 6, 22, 22);
|
||||
|
||||
|
||||
Bitmap closeQRCodeCroppedImage = new Bitmap(closeQRCodeCropArea.Width, closeQRCodeCropArea.Height);
|
||||
using (Graphics g = Graphics.FromImage(closeQRCodeCroppedImage))
|
||||
{
|
||||
g.DrawImage(originalImage, new Rectangle(0, 0, closeQRCodeCropArea.Width, closeQRCodeCropArea.Height), closeQRCodeCropArea, GraphicsUnit.Pixel);
|
||||
}
|
||||
|
||||
|
||||
closeQRCodeButton = new Button { Text = "" };
|
||||
closeQRCodeButton.Name = "closeQRCodeButton";
|
||||
ResizeAndPositionButton(closeQRCodeButton, 1173, 448, 22, 22);
|
||||
closeQRCodeButton.BackgroundImage = closeQRCodeCroppedImage;
|
||||
closeQRCodeButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
closeQRCodeButton.FlatStyle = FlatStyle.Flat;
|
||||
closeQRCodeButton.FlatAppearance.BorderSize = 0;
|
||||
closeQRCodeButton.Click += CloseQRCodeButton_Click;
|
||||
this.Controls.Add(closeQRCodeButton);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error in OverlayQRCodeOnImage: " + ex.Message);
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
Console.WriteLine("Inner exception: " + ex.InnerException.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseQRCodeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxQRCode.Visible = false;
|
||||
closeQRCodeButton.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
205
PrimaryFormParts/PrimaryForm.SoundEffects.cs
Normal file
205
PrimaryFormParts/PrimaryForm.SoundEffects.cs
Normal file
@ -0,0 +1,205 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using NAudio.Wave;
|
||||
using WMPLib;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm : Form
|
||||
{
|
||||
private WindowsMediaPlayer mediaPlayer;
|
||||
private IWavePlayer waveOut;
|
||||
private AudioFileReader audioFileReader;
|
||||
private PictureBox pictureBoxSceneSoundEffects;
|
||||
private Button constructionButton;
|
||||
private Button marketButton;
|
||||
private Button drivingButton;
|
||||
private Button airportButton;
|
||||
private Button officeButton;
|
||||
private Button closeButton;
|
||||
|
||||
private void InitializeMediaPlayer()
|
||||
{
|
||||
mediaPlayer = new WindowsMediaPlayer();
|
||||
}
|
||||
|
||||
private void InitializeSoundEffectButtons()
|
||||
{
|
||||
|
||||
constructionButton = new Button
|
||||
{
|
||||
Name = "constructionButton",
|
||||
};
|
||||
ConfigureButton(constructionButton, 876, 494, 148, 64,
|
||||
resizedNormalStateImageForSceneSoundEffects, resizedNormalStateImageForSceneSoundEffects, resizedNormalStateImageForSceneSoundEffects,
|
||||
ConstructionButton_Click);
|
||||
this.Controls.Add(constructionButton);
|
||||
|
||||
|
||||
marketButton = new Button
|
||||
{
|
||||
Name = "marketButton",
|
||||
};
|
||||
ConfigureButton(marketButton, 1037, 495, 148, 63,
|
||||
resizedNormalStateImageForSceneSoundEffects, resizedNormalStateImageForSceneSoundEffects, resizedNormalStateImageForSceneSoundEffects,
|
||||
MarketButton_Click);
|
||||
this.Controls.Add(marketButton);
|
||||
|
||||
|
||||
drivingButton = new Button
|
||||
{
|
||||
Name = "drivingButton",
|
||||
};
|
||||
ConfigureButton(drivingButton, 876, 570, 148, 63,
|
||||
resizedNormalStateImageForSceneSoundEffects, resizedNormalStateImageForSceneSoundEffects, resizedNormalStateImageForSceneSoundEffects,
|
||||
DrivingButton_Click);
|
||||
this.Controls.Add(drivingButton);
|
||||
|
||||
|
||||
airportButton = new Button
|
||||
{
|
||||
Name = "airportButton",
|
||||
};
|
||||
ConfigureButton(airportButton, 1037, 570, 148, 63,
|
||||
resizedNormalStateImageForSceneSoundEffects, resizedNormalStateImageForSceneSoundEffects, resizedNormalStateImageForSceneSoundEffects,
|
||||
AirportButton_Click);
|
||||
this.Controls.Add(airportButton);
|
||||
|
||||
|
||||
officeButton = new Button
|
||||
{
|
||||
Name = "officeButton",
|
||||
};
|
||||
ConfigureButton(officeButton, 876, 646, 148, 64,
|
||||
resizedNormalStateImageForSceneSoundEffects, resizedNormalStateImageForSceneSoundEffects, resizedNormalStateImageForSceneSoundEffects,
|
||||
OfficeButton_Click);
|
||||
this.Controls.Add(officeButton);
|
||||
|
||||
|
||||
closeButton = new Button
|
||||
{
|
||||
Name = "closeButton",
|
||||
};
|
||||
|
||||
ConfigureButton(closeButton, 1036, 646, 150, 63,
|
||||
resizedNormalStateImageForSceneSoundEffects, resizedNormalStateImageForSceneSoundEffects, resizedNormalStateImageForSceneSoundEffects,
|
||||
CloseButton_Click);
|
||||
this.Controls.Add(closeButton);
|
||||
}
|
||||
|
||||
private void SoundEffectButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
SetHotSongButtonsVisibility(false);
|
||||
SetNewSongButtonsVisibility(false);
|
||||
SetSingerSearchButtonsVisibility(false);
|
||||
SetSongSearchButtonsVisibility(false);
|
||||
|
||||
if (!pictureBoxSceneSoundEffects.Visible)
|
||||
{
|
||||
ShowImageOnPictureBoxSceneSoundEffects(Path.Combine(Application.StartupPath, @"themes\superstar\555022.jpg"));
|
||||
SetPictureBoxSceneSoundEffectsAndButtonsVisibility(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
TogglePictureBoxSceneSoundEffectsButtonsVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
private void ConstructionButton_Click(object sender, EventArgs e) => PlaySound(@"sounds\1857.mp3");
|
||||
private void MarketButton_Click(object sender, EventArgs e) => PlaySound(@"sounds\13472_Audio Trimmer.mp3");
|
||||
private void DrivingButton_Click(object sender, EventArgs e) => PlaySound(@"sounds\kc1.mp3");
|
||||
private void AirportButton_Click(object sender, EventArgs e) => PlayMediaSound(@"sounds\xm2401.m4a");
|
||||
private void OfficeButton_Click(object sender, EventArgs e) => PlayMediaSound(@"sounds\y1640.m4a");
|
||||
private void CloseButton_Click(object sender, EventArgs e) => TogglePictureBoxSceneSoundEffectsButtonsVisibility();
|
||||
|
||||
private void PlaySound(string filePath)
|
||||
{
|
||||
waveOut?.Dispose();
|
||||
audioFileReader?.Dispose();
|
||||
|
||||
waveOut = new WaveOutEvent();
|
||||
audioFileReader = new AudioFileReader(Path.Combine(Application.StartupPath, filePath));
|
||||
waveOut.Init(audioFileReader);
|
||||
waveOut.Play();
|
||||
}
|
||||
|
||||
private void PlayMediaSound(string filePath)
|
||||
{
|
||||
mediaPlayer.URL = Path.Combine(Application.StartupPath, filePath);
|
||||
mediaPlayer.controls.play();
|
||||
}
|
||||
|
||||
public void PlayApplauseSound()
|
||||
{
|
||||
mediaPlayer.URL = Path.Combine(Application.StartupPath, "zs.m4a");
|
||||
mediaPlayer.controls.play();
|
||||
}
|
||||
|
||||
private void ShowImageOnPictureBoxSceneSoundEffects(string imagePath)
|
||||
{
|
||||
|
||||
Bitmap originalImage = new Bitmap(imagePath);
|
||||
|
||||
|
||||
Rectangle cropArea = new Rectangle(859, 427, 342, 295);
|
||||
|
||||
|
||||
Bitmap croppedImage = CropImage(originalImage, cropArea);
|
||||
|
||||
|
||||
pictureBoxSceneSoundEffects.Image = croppedImage;
|
||||
|
||||
|
||||
ResizeAndPositionPictureBox(pictureBoxSceneSoundEffects, cropArea.X, cropArea.Y, cropArea.Width, cropArea.Height);
|
||||
|
||||
pictureBoxSceneSoundEffects.Visible = true;
|
||||
}
|
||||
|
||||
private void TogglePictureBoxSceneSoundEffectsButtonsVisibility()
|
||||
{
|
||||
|
||||
bool areButtonsVisible = pictureBoxSceneSoundEffects.Visible;
|
||||
|
||||
|
||||
SetPictureBoxSceneSoundEffectsAndButtonsVisibility(!areButtonsVisible);
|
||||
}
|
||||
|
||||
|
||||
private void SetPictureBoxSceneSoundEffectsAndButtonsVisibility(bool isVisible)
|
||||
{
|
||||
|
||||
pictureBoxSceneSoundEffects.Visible = isVisible;
|
||||
|
||||
if (isVisible)
|
||||
{
|
||||
|
||||
pictureBoxSceneSoundEffects.BringToFront();
|
||||
}
|
||||
|
||||
|
||||
List<Button> soundEffectButtons = new List<Button>
|
||||
{
|
||||
constructionButton,
|
||||
marketButton,
|
||||
drivingButton,
|
||||
airportButton,
|
||||
officeButton,
|
||||
closeButton
|
||||
};
|
||||
|
||||
|
||||
foreach (Button button in soundEffectButtons)
|
||||
{
|
||||
button.Visible = isVisible;
|
||||
if (isVisible)
|
||||
{
|
||||
button.BringToFront();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
161
PrimaryFormParts/PrimaryForm.SyncScreen.cs
Normal file
161
PrimaryFormParts/PrimaryForm.SyncScreen.cs
Normal file
@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm : Form
|
||||
{
|
||||
public Panel primaryScreenPanel;
|
||||
public Button syncServiceBellButton;
|
||||
public Button syncCutSongButton;
|
||||
public Button syncReplayButton;
|
||||
public Button syncOriginalSongButton;
|
||||
public Button syncMuteButton;
|
||||
public Button syncPauseButton;
|
||||
public Button syncPlayButton;
|
||||
public Button syncVolumeUpButton;
|
||||
public Button syncVolumeDownButton;
|
||||
public Button syncMicUpButton;
|
||||
public Button syncMicDownButton;
|
||||
public Button syncCloseButton;
|
||||
|
||||
private void InitializeSyncScreen()
|
||||
{
|
||||
this.primaryScreenPanel = new System.Windows.Forms.Panel();
|
||||
this.syncServiceBellButton = new System.Windows.Forms.Button();
|
||||
this.syncCutSongButton = new System.Windows.Forms.Button();
|
||||
this.syncReplayButton = new System.Windows.Forms.Button();
|
||||
this.syncOriginalSongButton = new System.Windows.Forms.Button();
|
||||
this.syncMuteButton = new System.Windows.Forms.Button();
|
||||
this.syncPauseButton = new System.Windows.Forms.Button();
|
||||
this.syncPlayButton = new System.Windows.Forms.Button();
|
||||
this.syncVolumeUpButton = new System.Windows.Forms.Button();
|
||||
this.syncVolumeDownButton = new System.Windows.Forms.Button();
|
||||
this.syncMicUpButton = new System.Windows.Forms.Button();
|
||||
this.syncMicDownButton = new System.Windows.Forms.Button();
|
||||
this.syncCloseButton = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ResizeAndPositionControl(this.primaryScreenPanel, 0, 0, 1440, 900);
|
||||
this.primaryScreenPanel.TabIndex = 0;
|
||||
this.primaryScreenPanel.BorderStyle = BorderStyle.FixedSingle;
|
||||
this.primaryScreenPanel.BackColor = System.Drawing.Color.Black;
|
||||
|
||||
|
||||
|
||||
|
||||
ConfigureButton(this.syncServiceBellButton, 1240, 17, 161, 161,
|
||||
resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen,
|
||||
(sender, e) => SendCommandThroughSerialPort("a2 53 a4"));
|
||||
|
||||
|
||||
|
||||
|
||||
ConfigureButton(this.syncCutSongButton, 1218, 195, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, (sender, e) => videoPlayerForm.SkipToNextSong());
|
||||
|
||||
|
||||
|
||||
|
||||
ConfigureButton(this.syncReplayButton, 1218, 265, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, ReplayButton_Click);
|
||||
|
||||
|
||||
|
||||
|
||||
ConfigureButton(this.syncOriginalSongButton, 1218, 335, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, null);
|
||||
|
||||
|
||||
|
||||
|
||||
ConfigureButton(this.syncMuteButton, 1218, 406, 205, 55, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, MuteUnmuteButton_Click);
|
||||
|
||||
|
||||
|
||||
|
||||
ConfigureButton(this.syncPauseButton, 1218, 475, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, SyncPauseButton_Click);
|
||||
ConfigureButton(this.syncPlayButton, 1218, 475, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, SyncPlayButton_Click);
|
||||
|
||||
|
||||
|
||||
|
||||
ConfigureButton(this.syncVolumeUpButton, 1218, 546, 205, 55, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, null);
|
||||
this.syncVolumeUpButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowVolumeUpLabel(); volumeUpTimer.Start(); };
|
||||
this.syncVolumeUpButton.MouseUp += (sender, e) => { OverlayForm.MainForm.HideAllLabels(); volumeUpTimer.Stop(); };
|
||||
|
||||
|
||||
|
||||
|
||||
ConfigureButton(this.syncVolumeDownButton, 1218, 616, 205, 55, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, null);
|
||||
this.syncVolumeDownButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowVolumeDownLabel(); volumeDownTimer.Start(); };
|
||||
this.syncVolumeDownButton.MouseUp += (sender, e) => { OverlayForm.MainForm.HideAllLabels(); volumeDownTimer.Stop(); };
|
||||
|
||||
|
||||
|
||||
|
||||
ConfigureButton(this.syncMicUpButton, 1218, 686, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, null);
|
||||
this.syncMicUpButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowMicUpLabel(); micControlTimer.Tag = "a2 b5 a4"; micControlTimer.Start(); };
|
||||
this.syncMicUpButton.MouseUp += (sender, e) => { OverlayForm.MainForm.HideAllLabels(); micControlTimer.Stop(); };
|
||||
|
||||
|
||||
|
||||
|
||||
ConfigureButton(this.syncMicDownButton, 1218, 756, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, null);
|
||||
this.syncMicDownButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowMicDownLabel(); micControlTimer.Tag = "a2 b6 a4"; micControlTimer.Start(); };
|
||||
this.syncMicDownButton.MouseUp += (sender, e) => { OverlayForm.MainForm.HideAllLabels(); micControlTimer.Stop(); };
|
||||
|
||||
|
||||
|
||||
|
||||
ConfigureButton(this.syncCloseButton, 1218, 826, 205, 56, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, resizedNormalStateImageForSyncScreen, SyncCloseButton_Click);
|
||||
|
||||
|
||||
|
||||
|
||||
this.ClientSize = new System.Drawing.Size(1440, 900);
|
||||
this.Controls.Add(this.primaryScreenPanel);
|
||||
this.Controls.Add(this.syncCloseButton);
|
||||
this.Name = "PrimaryForm";
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
||||
private void SyncPauseButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
videoPlayerForm.Pause();
|
||||
|
||||
|
||||
syncPauseButton.Visible = false;
|
||||
syncPlayButton.Visible = true;
|
||||
syncPlayButton.BringToFront();
|
||||
pauseButton.Visible = false;
|
||||
playButton.Visible = true;
|
||||
}
|
||||
|
||||
private void SyncPlayButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
videoPlayerForm.Play();
|
||||
|
||||
|
||||
syncPauseButton.Visible = true;
|
||||
syncPauseButton.BringToFront();
|
||||
syncPlayButton.Visible = false;
|
||||
pauseButton.Visible = true;
|
||||
playButton.Visible = false;
|
||||
}
|
||||
|
||||
private void SyncCloseButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
VideoPlayerForm.Instance.ClosePrimaryScreenPanel();
|
||||
}
|
||||
|
||||
private void SyncScreenButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
videoPlayerForm.IsSyncToPrimaryMonitor = true;
|
||||
videoPlayerForm.SyncToPrimaryMonitor();
|
||||
}
|
||||
}
|
||||
}
|
338
PrimaryFormParts/PrimaryForm.ToggleLight.cs
Normal file
338
PrimaryFormParts/PrimaryForm.ToggleLight.cs
Normal file
@ -0,0 +1,338 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private Button btnTurnOn;
|
||||
private Button btnTurnOff;
|
||||
private Button btnBright;
|
||||
private Button btnRomantic;
|
||||
private Button btnAuto;
|
||||
private Button btnColorTuning;
|
||||
private Button btnSoft;
|
||||
private Button btnDynamic;
|
||||
private Button btnDeskLamp;
|
||||
private Button btnStageLight;
|
||||
private Button btnShelfLight;
|
||||
private Button btnWallLight;
|
||||
private Button btnBrightnessUp1;
|
||||
private Button btnBrightnessDown1;
|
||||
private Button btnBrightnessUp2;
|
||||
private Button btnBrightnessDown2;
|
||||
|
||||
private PictureBox pictureBoxToggleLight;
|
||||
|
||||
private void InitializeButtonsForPictureBoxToggleLight()
|
||||
{
|
||||
btnTurnOn = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnTurnOn, 604, 410, 122, 62,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
null);
|
||||
btnTurnOn.Click += (sender, e) =>
|
||||
{
|
||||
|
||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||
{
|
||||
|
||||
byte[] commandBytes = new byte[] { 0xA2, 0xDB, 0xA4 };
|
||||
|
||||
|
||||
SerialPortManager.mySerialPort.Write(commandBytes, 0, commandBytes.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Serial port is not open. Cannot send track correction command.");
|
||||
}
|
||||
};
|
||||
btnTurnOff = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnTurnOff, 753, 411, 122, 62,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
null);
|
||||
btnTurnOff.Click += (sender, e) =>
|
||||
{
|
||||
SendCommandThroughSerialPort("a2 dc a4");
|
||||
};
|
||||
|
||||
btnBright = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnBright, 901, 411, 122, 62,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
null);
|
||||
btnBright.Click += (sender, e) =>
|
||||
{
|
||||
|
||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||
{
|
||||
|
||||
byte[] commandBytes = new byte[] { 0xA2, 0xD5, 0xA4 };
|
||||
|
||||
|
||||
SerialPortManager.mySerialPort.Write(commandBytes, 0, commandBytes.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Serial port is not open. Cannot send track correction command.");
|
||||
}
|
||||
};
|
||||
|
||||
btnRomantic = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnRomantic, 1049, 411, 122, 62,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
(sender, e) => SendCommandThroughSerialPort("a2 d7 a4"));
|
||||
|
||||
btnAuto = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnAuto, 1049, 494, 123, 63,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
null);
|
||||
btnColorTuning = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnColorTuning, 1049, 579, 123, 63,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
(sender, e) => SendCommandThroughSerialPort("a2 75 a4"));
|
||||
|
||||
btnSoft = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnSoft, 901, 495, 122, 62,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
(sender, e) => SendCommandThroughSerialPort("a2 d6 a4"));
|
||||
|
||||
btnDynamic = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnDynamic, 901, 579, 123, 62,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
(sender, e) => SendCommandThroughSerialPort("a2 d8 a4"));
|
||||
|
||||
btnDeskLamp = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnDeskLamp, 1048, 662, 124, 64,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
(sender, e) => SendCommandThroughSerialPort("a2 fb a4"));
|
||||
|
||||
btnStageLight = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnStageLight, 900, 662, 124, 64,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
(sender, e) => SendCommandThroughSerialPort("a2 fa a4"));
|
||||
|
||||
btnShelfLight = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnShelfLight, 752, 662, 124, 64,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
(sender, e) => SendCommandThroughSerialPort("a2 f9 a4"));
|
||||
|
||||
btnWallLight = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnWallLight, 604, 662, 124, 64,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
(sender, e) => SendCommandThroughSerialPort("a2 f8 a4"));
|
||||
|
||||
btnBrightnessUp1 = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnBrightnessUp1, 603, 495, 122, 62,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
null);
|
||||
|
||||
btnBrightnessUp1.MouseDown += (sender, e) =>
|
||||
{
|
||||
lightControlTimer.Tag = "a2 d9 a4";
|
||||
lightControlTimer.Start();
|
||||
};
|
||||
|
||||
|
||||
btnBrightnessUp1.MouseUp += (sender, e) =>
|
||||
{
|
||||
lightControlTimer.Stop();
|
||||
};
|
||||
btnBrightnessDown1 = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnBrightnessDown1, 605, 579, 122, 62,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
null);
|
||||
btnBrightnessDown1.MouseDown += (sender, e) => { lightControlTimer.Tag = "a2 da a4"; lightControlTimer.Start(); };
|
||||
btnBrightnessDown1.MouseUp += (sender, e) => { lightControlTimer.Stop(); };
|
||||
btnBrightnessUp2 = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnBrightnessUp2, 753, 495, 123, 62,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
null);
|
||||
btnBrightnessUp2.MouseDown += (sender, e) => { lightControlTimer.Tag = "a2 f6 a4"; lightControlTimer.Start(); };
|
||||
btnBrightnessUp2.MouseUp += (sender, e) => { lightControlTimer.Stop(); };
|
||||
btnBrightnessDown2 = new Button{ Text = "" };
|
||||
|
||||
|
||||
ConfigureButton(btnBrightnessDown2, 753, 579, 123, 62,
|
||||
resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl, resizedNormalStateImageForLightControl,
|
||||
null);
|
||||
btnBrightnessDown2.MouseDown += (sender, e) => { lightControlTimer.Tag = "a2 f7 a4"; lightControlTimer.Start(); };
|
||||
btnBrightnessDown2.MouseUp += (sender, e) => { lightControlTimer.Stop(); };
|
||||
|
||||
|
||||
this.Controls.Add(btnTurnOn);
|
||||
this.Controls.Add(btnTurnOff);
|
||||
this.Controls.Add(btnBright);
|
||||
this.Controls.Add(btnRomantic);
|
||||
this.Controls.Add(btnAuto);
|
||||
this.Controls.Add(btnColorTuning);
|
||||
this.Controls.Add(btnSoft);
|
||||
this.Controls.Add(btnDynamic);
|
||||
this.Controls.Add(btnDeskLamp);
|
||||
this.Controls.Add(btnStageLight);
|
||||
this.Controls.Add(btnShelfLight);
|
||||
this.Controls.Add(btnWallLight);
|
||||
this.Controls.Add(btnBrightnessUp1);
|
||||
this.Controls.Add(btnBrightnessDown1);
|
||||
this.Controls.Add(btnBrightnessUp2);
|
||||
this.Controls.Add(btnBrightnessDown2);
|
||||
}
|
||||
|
||||
|
||||
private void ToggleLightButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
SetHotSongButtonsVisibility(false);
|
||||
SetNewSongButtonsVisibility(false);
|
||||
SetSingerSearchButtonsVisibility(false);
|
||||
SetSongSearchButtonsVisibility(false);
|
||||
|
||||
|
||||
if (!pictureBoxToggleLight.Visible)
|
||||
{
|
||||
|
||||
ShowImageOnPictureBoxToggleLight(Path.Combine(Application.StartupPath, @"themes\superstar\選單內介面_燈光控制.jpg"));
|
||||
SetPictureBoxToggleLightAndButtonsVisibility(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
TogglePictureBoxToggleLightButtonsVisibility();
|
||||
}
|
||||
|
||||
|
||||
if (pictureBoxQRCode != null)
|
||||
{
|
||||
pictureBoxQRCode.Visible = false;
|
||||
closeQRCodeButton.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowImageOnPictureBoxToggleLight(string imagePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(imagePath))
|
||||
{
|
||||
MessageBox.Show($"找不到圖片文件: {imagePath}");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var stream = new MemoryStream(File.ReadAllBytes(imagePath)))
|
||||
{
|
||||
var originalImage = new Bitmap(stream);
|
||||
Rectangle cropArea = new Rectangle(570, 359, 630, 379);
|
||||
|
||||
using (var croppedImage = new Bitmap(cropArea.Width, cropArea.Height))
|
||||
{
|
||||
using (var g = Graphics.FromImage(croppedImage))
|
||||
{
|
||||
g.DrawImage(originalImage,
|
||||
new Rectangle(0, 0, cropArea.Width, cropArea.Height),
|
||||
cropArea,
|
||||
GraphicsUnit.Pixel);
|
||||
}
|
||||
|
||||
pictureBoxToggleLight.Image?.Dispose();
|
||||
pictureBoxToggleLight.Image = new Bitmap(croppedImage);
|
||||
}
|
||||
|
||||
ResizeAndPositionPictureBox(pictureBoxToggleLight, cropArea.X, cropArea.Y, cropArea.Width, cropArea.Height);
|
||||
pictureBoxToggleLight.Visible = true;
|
||||
pictureBoxToggleLight.BringToFront();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"載入燈光控制圖片時發生錯誤: {ex.Message}\n路徑: {imagePath}");
|
||||
}
|
||||
}
|
||||
|
||||
private void TogglePictureBoxToggleLightButtonsVisibility()
|
||||
{
|
||||
|
||||
bool areButtonsVisible = pictureBoxToggleLight.Visible;
|
||||
|
||||
|
||||
SetPictureBoxToggleLightAndButtonsVisibility(!areButtonsVisible);
|
||||
}
|
||||
|
||||
private void SetPictureBoxToggleLightAndButtonsVisibility(bool isVisible)
|
||||
{
|
||||
|
||||
pictureBoxToggleLight.Visible = isVisible;
|
||||
|
||||
|
||||
btnTurnOn.Visible = isVisible;
|
||||
btnTurnOff.Visible = isVisible;
|
||||
btnBright.Visible = isVisible;
|
||||
btnRomantic.Visible = isVisible;
|
||||
btnAuto.Visible = isVisible;
|
||||
btnColorTuning.Visible = isVisible;
|
||||
btnSoft.Visible = isVisible;
|
||||
btnDynamic.Visible = isVisible;
|
||||
btnDeskLamp.Visible = isVisible;
|
||||
btnStageLight.Visible = isVisible;
|
||||
btnShelfLight.Visible = isVisible;
|
||||
btnWallLight.Visible = isVisible;
|
||||
btnBrightnessUp1.Visible = isVisible;
|
||||
btnBrightnessDown1.Visible = isVisible;
|
||||
btnBrightnessUp2.Visible = isVisible;
|
||||
btnBrightnessDown2.Visible = isVisible;
|
||||
|
||||
if (isVisible)
|
||||
{
|
||||
|
||||
pictureBoxToggleLight.BringToFront();
|
||||
|
||||
|
||||
btnTurnOn.BringToFront();
|
||||
btnTurnOff.BringToFront();
|
||||
btnBright.BringToFront();
|
||||
btnRomantic.BringToFront();
|
||||
btnAuto.BringToFront();
|
||||
btnColorTuning.BringToFront();
|
||||
btnSoft.BringToFront();
|
||||
btnDynamic.BringToFront();
|
||||
btnDeskLamp.BringToFront();
|
||||
btnStageLight.BringToFront();
|
||||
btnShelfLight.BringToFront();
|
||||
btnWallLight.BringToFront();
|
||||
btnBrightnessUp1.BringToFront();
|
||||
btnBrightnessDown1.BringToFront();
|
||||
btnBrightnessUp2.BringToFront();
|
||||
btnBrightnessDown2.BringToFront();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
211
PrimaryFormParts/PrimaryForm.VodScreen.cs
Normal file
211
PrimaryFormParts/PrimaryForm.VodScreen.cs
Normal file
@ -0,0 +1,211 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
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 = 1440;
|
||||
int screenHeight = 900;
|
||||
int pictureBoxWidth = 700;
|
||||
int pictureBoxHeight = 140;
|
||||
|
||||
int xPosition = (screenWidth - pictureBoxWidth) / 2;
|
||||
int yPosition = (screenHeight - pictureBoxHeight) / 2;
|
||||
|
||||
|
||||
vodButton = new Button();
|
||||
vodButton.Text = "";
|
||||
ResizeAndPositionButton(vodButton, xPosition + 10, yPosition + 85, 110, 50);
|
||||
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 = "";
|
||||
ResizeAndPositionButton(insertButton, xPosition + 135, yPosition + 85, 110, 50);
|
||||
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 = "";
|
||||
ResizeAndPositionButton(albumButton, xPosition + 265, yPosition + 85, 140, 50);
|
||||
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 = "";
|
||||
ResizeAndPositionButton(favoriteButton, xPosition + 425, yPosition + 85, 140, 50);
|
||||
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 = !IsUserLoggedIn();
|
||||
|
||||
|
||||
favoriteButton.Controls.Add(disabledPanel);
|
||||
favoriteButton.Click += FavoriteButton_Click;
|
||||
|
||||
|
||||
if (!IsUserLoggedIn()) {
|
||||
favoriteButton.Enabled = false;
|
||||
favoriteButton.BackColor = SystemColors.Control;
|
||||
}
|
||||
favoriteButton.Visible = IsUserLoggedIn();
|
||||
|
||||
|
||||
vodScreenCloseButton = new Button();
|
||||
vodScreenCloseButton.Text = "";
|
||||
ResizeAndPositionButton(vodScreenCloseButton, xPosition + 580, yPosition + 85, 110, 50);
|
||||
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)
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
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");
|
||||
|
||||
|
||||
SongListManager.Instance.AddToFavorite(currentSelectedSong.SongNumber);
|
||||
SetVodScreenPictureBoxAndButtonsVisibility(false);
|
||||
}
|
||||
|
||||
private void VodScreenCloseButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
SetVodScreenPictureBoxAndButtonsVisibility(false);
|
||||
}
|
||||
|
||||
|
||||
private bool IsUserLoggedIn()
|
||||
{
|
||||
|
||||
return SongListManager.Instance.IsUserLoggedIn;
|
||||
}
|
||||
|
||||
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 (IsUserLoggedIn())
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3343
PrimaryFormParts/PrimaryForm.cs
Normal file
3343
PrimaryFormParts/PrimaryForm.cs
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,571 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
using IniParser;
|
||||
using IniParser.Model;
|
||||
using System.Text;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private PictureBox pictureBoxZhuYinSingers;
|
||||
|
||||
private Button[] phoneticButtonsForSingers;
|
||||
private Button modifyButtonZhuYinSingers;
|
||||
private Button clearButtonZhuYinSingers;
|
||||
private Button closeButtonZhuYinSingers;
|
||||
|
||||
private string[] phoneticSymbols;
|
||||
private (int X, int Y, int Width, int Height)[] phoneticButtonCoords;
|
||||
private Dictionary<string, (string normal, string mouseDown, string mouseOver)> phoneticButtonImages;
|
||||
|
||||
private (int X, int Y, int Width, int Height) modifyButtonZhuYinCoords;
|
||||
private (int X, int Y, int Width, int Height) clearButtonZhuYinCoords;
|
||||
private (int X, int Y, int Width, int Height) closeButtonZhuYinCoords;
|
||||
|
||||
private RichTextBox inputBoxZhuYinSingers;
|
||||
|
||||
private (int X, int Y, int Width, int Height) inputBoxZhuYinCoords;
|
||||
private string inputBoxFontName;
|
||||
private float inputBoxFontSize;
|
||||
private FontStyle inputBoxFontStyle;
|
||||
private Color inputBoxForeColor;
|
||||
|
||||
private void ZhuyinSearchSingersButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
zhuyinSearchButton.BackgroundImage = zhuyinSearchActiveBackground;
|
||||
englishSearchButton.BackgroundImage = englishSearchNormalBackground;
|
||||
pinyinSearchButton.BackgroundImage = pinyinSearchNormalBackground;
|
||||
wordCountSearchButton.BackgroundImage = wordCountSearchNormalBackground;
|
||||
handWritingSearchButton.BackgroundImage = handWritingSearchNormalBackground;
|
||||
|
||||
|
||||
var configData = LoadConfigData();
|
||||
string imagePath = Path.Combine(Application.StartupPath, configData["ImagePaths"]["ZhuYinSingers"]);
|
||||
|
||||
ShowImageOnPictureBoxZhuYinSingers(Path.Combine(Application.StartupPath, imagePath));
|
||||
|
||||
|
||||
|
||||
SetEnglishSingersAndButtonsVisibility(false);
|
||||
SetPinYinSingersAndButtonsVisibility(false);
|
||||
SetHandWritingForSingersAndButtonsVisibility(false);
|
||||
SetZhuYinSingersAndButtonsVisibility(true);
|
||||
SetPictureBoxArtistSearchAndButtonsVisibility(false);
|
||||
pictureBoxZhuYinSingers.Visible = true;
|
||||
}
|
||||
|
||||
private void LoadPhoneticSymbolsFromConfig()
|
||||
{
|
||||
var parser = new FileIniDataParser();
|
||||
string iniFilePath = "config.ini";
|
||||
|
||||
|
||||
IniData data;
|
||||
using (var reader = new StreamReader(iniFilePath, Encoding.UTF8))
|
||||
{
|
||||
data = parser.ReadData(reader);
|
||||
}
|
||||
|
||||
string symbols = data["PhoneticSymbols"]["Symbols"];
|
||||
phoneticSymbols = symbols.Split(',');
|
||||
}
|
||||
|
||||
private IniData LoadConfigData()
|
||||
{
|
||||
var parser = new FileIniDataParser();
|
||||
string iniFilePath = "config.ini";
|
||||
|
||||
using (var reader = new StreamReader(iniFilePath, Encoding.UTF8))
|
||||
{
|
||||
return parser.ReadData(reader);
|
||||
}
|
||||
}
|
||||
|
||||
private string[] LoadPhoneticSymbols(IniData data)
|
||||
{
|
||||
string symbols = data["PhoneticSymbols"]["Symbols"];
|
||||
return symbols.Split(',');
|
||||
}
|
||||
|
||||
private (int X, int Y, int Width, int Height)[] LoadButtonCoordinates(IniData data, string section, int buttonCount)
|
||||
{
|
||||
var buttonList = new List<(int X, int Y, int Width, int Height)>();
|
||||
|
||||
for (int i = 1; i <= buttonCount; i++)
|
||||
{
|
||||
var coordString = data[section][$"button{i}"];
|
||||
var coords = coordString.Split(',');
|
||||
buttonList.Add((int.Parse(coords[0]), int.Parse(coords[1]), int.Parse(coords[2]), int.Parse(coords[3])));
|
||||
}
|
||||
|
||||
return buttonList.ToArray();
|
||||
}
|
||||
|
||||
private Dictionary<string, (string normal, string mouseDown, string mouseOver)> LoadButtonImages(IniData data, string section, int buttonCount)
|
||||
{
|
||||
var buttonImages = new Dictionary<string, (string normal, string mouseDown, string mouseOver)>();
|
||||
|
||||
for (int i = 0; i < 35; i++)
|
||||
{
|
||||
buttonImages[$"button{i}"] = (
|
||||
data[section][$"button{i}_normal"],
|
||||
data[section][$"button{i}_mouseDown"],
|
||||
data[section][$"button{i}_mouseOver"]
|
||||
);
|
||||
}
|
||||
|
||||
return buttonImages;
|
||||
}
|
||||
|
||||
private (int X, int Y, int Width, int Height) LoadSpecialButtonCoordinates(IniData data, string section, string buttonKey)
|
||||
{
|
||||
var coords = data[section][buttonKey].Split(',');
|
||||
return (int.Parse(coords[0]), int.Parse(coords[1]), int.Parse(coords[2]), int.Parse(coords[3]));
|
||||
}
|
||||
|
||||
private (string normal, string mouseDown, string mouseOver) LoadButtonImages(IniData data, string section)
|
||||
{
|
||||
return (
|
||||
data[section]["normal"],
|
||||
data[section]["mouseDown"],
|
||||
data[section]["mouseOver"]
|
||||
);
|
||||
}
|
||||
|
||||
private void InitializePhoneticButtons()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
|
||||
phoneticSymbols = LoadPhoneticSymbols(data);
|
||||
phoneticButtonCoords = LoadButtonCoordinates(data, "PhoneticButtonCoordinates", 35);
|
||||
phoneticButtonImages = LoadButtonImages(data, "PhoneticButtonImages", 35);
|
||||
|
||||
phoneticButtonsForSingers = new Button[35];
|
||||
for (int i = 0; i < 35; i++)
|
||||
{
|
||||
var buttonImages = phoneticButtonImages[$"button{i}"];
|
||||
CreatePhoneticButton(i, buttonImages.normal, buttonImages.mouseDown, buttonImages.mouseOver);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreatePhoneticButton(int index, string normalImagePath, string mouseDownImagePath, string mouseOverImagePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
phoneticButtonsForSingers[index] = new Button
|
||||
{
|
||||
Name = $"phoneticButton_{phoneticSymbols[index]}",
|
||||
BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, normalImagePath)),
|
||||
BackgroundImageLayout = ImageLayout.Stretch,
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
FlatAppearance = { BorderSize = 0 }
|
||||
};
|
||||
|
||||
ResizeAndPositionButton(phoneticButtonsForSingers[index], phoneticButtonCoords[index].X, phoneticButtonCoords[index].Y,
|
||||
phoneticButtonCoords[index].Width, phoneticButtonCoords[index].Height);
|
||||
|
||||
Image normalImage = Image.FromFile(Path.Combine(Application.StartupPath, normalImagePath));
|
||||
Image mouseDownImage = Image.FromFile(Path.Combine(Application.StartupPath, mouseDownImagePath));
|
||||
Image mouseOverImage = Image.FromFile(Path.Combine(Application.StartupPath, mouseOverImagePath));
|
||||
|
||||
phoneticButtonsForSingers[index].MouseDown += (s, e) => phoneticButtonsForSingers[index].BackgroundImage = mouseDownImage;
|
||||
phoneticButtonsForSingers[index].MouseUp += (s, e) => phoneticButtonsForSingers[index].BackgroundImage = normalImage;
|
||||
phoneticButtonsForSingers[index].MouseEnter += (s, e) => phoneticButtonsForSingers[index].BackgroundImage = mouseOverImage;
|
||||
phoneticButtonsForSingers[index].MouseLeave += (s, e) => phoneticButtonsForSingers[index].BackgroundImage = normalImage;
|
||||
phoneticButtonsForSingers[index].Click += PhoneticButton_Click;
|
||||
phoneticButtonsForSingers[index].Tag = phoneticSymbols[index];
|
||||
|
||||
this.Controls.Add(phoneticButtonsForSingers[index]);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error creating button at index {index}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeButtonsForZhuYinSingers()
|
||||
{
|
||||
LoadPhoneticSymbolsFromConfig();
|
||||
InitializePhoneticButtons();
|
||||
InitializeSpecialButtonsForZhuYinSingers();
|
||||
InitializeInputBoxZhuYinSingers();
|
||||
}
|
||||
|
||||
private Image RemoveWhiteBorder(string imagePath)
|
||||
{
|
||||
Bitmap bmp = new Bitmap(imagePath);
|
||||
|
||||
|
||||
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
|
||||
BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, bmp.PixelFormat);
|
||||
|
||||
IntPtr ptr = bmpData.Scan0;
|
||||
int bytes = Math.Abs(bmpData.Stride) * bmp.Height;
|
||||
byte[] rgbValues = new byte[bytes];
|
||||
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
|
||||
|
||||
for (int y = 0; y < bmp.Height; y++)
|
||||
{
|
||||
for (int x = 0; x < bmp.Width; x++)
|
||||
{
|
||||
int position = (y * bmpData.Stride) + (x * 4);
|
||||
byte b = rgbValues[position];
|
||||
byte g = rgbValues[position + 1];
|
||||
byte r = rgbValues[position + 2];
|
||||
byte a = rgbValues[position + 3];
|
||||
|
||||
|
||||
if ((x < 5 || x > bmp.Width - 5 || y < 5 || y > bmp.Height - 5) && r == 255 && g == 255 && b == 255)
|
||||
{
|
||||
rgbValues[position] = 255;
|
||||
rgbValues[position + 1] = 255;
|
||||
rgbValues[position + 2] = 255;
|
||||
rgbValues[position + 3] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes);
|
||||
bmp.UnlockBits(bmpData);
|
||||
|
||||
return bmp;
|
||||
}
|
||||
|
||||
private void InitializeSpecialButtonsForZhuYinSingers()
|
||||
{
|
||||
|
||||
InitializeModifyButtonZhuYinSingers();
|
||||
|
||||
|
||||
InitializeClearButtonZhuYinSingers();
|
||||
|
||||
|
||||
InitializeCloseButtonZhuYinSingers();
|
||||
}
|
||||
|
||||
private void InitializeModifyButtonZhuYinSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
modifyButtonZhuYinCoords = LoadSpecialButtonCoordinates(data, "SpecialButtonCoordinates", "modifyButtonZhuYinSingers");
|
||||
var buttonImages = LoadButtonImages(data, "ModifyButtonImagesZhuYin");
|
||||
|
||||
modifyButtonZhuYinSingers = CreateSpecialButton(
|
||||
"btnModifyZhuYinSingers",
|
||||
modifyButtonZhuYinCoords,
|
||||
buttonImages.normal,
|
||||
buttonImages.mouseOver,
|
||||
buttonImages.mouseDown,
|
||||
ModifyButtonZhuYinSingers_Click
|
||||
);
|
||||
}
|
||||
|
||||
private void ModifyButtonZhuYinSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (this.Controls.Contains(inputBoxZhuYinSingers) && inputBoxZhuYinSingers.Text.Length > 0)
|
||||
{
|
||||
inputBoxZhuYinSingers.Text = inputBoxZhuYinSingers.Text.Substring(0, inputBoxZhuYinSingers.Text.Length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeClearButtonZhuYinSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
clearButtonZhuYinCoords = LoadSpecialButtonCoordinates(data, "SpecialButtonCoordinates", "clearButtonZhuYinSingers");
|
||||
var buttonImages = LoadButtonImages(data, "ClearButtonImagesZhuYin");
|
||||
|
||||
clearButtonZhuYinSingers = CreateSpecialButton(
|
||||
"btnClearZhuYinSingers",
|
||||
clearButtonZhuYinCoords,
|
||||
buttonImages.normal,
|
||||
buttonImages.mouseOver,
|
||||
buttonImages.mouseDown,
|
||||
ClearButtonZhuYinSingers_Click
|
||||
);
|
||||
}
|
||||
|
||||
private void ClearButtonZhuYinSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.Controls.Contains(inputBoxZhuYinSingers) && inputBoxZhuYinSingers.Text.Length > 0)
|
||||
{
|
||||
inputBoxZhuYinSingers.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeCloseButtonZhuYinSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
closeButtonZhuYinCoords = LoadSpecialButtonCoordinates(data, "SpecialButtonCoordinates", "closeButtonZhuYinSingers");
|
||||
var buttonImages = LoadButtonImages(data, "CloseButtonImagesZhuYin");
|
||||
|
||||
closeButtonZhuYinSingers = CreateSpecialButton(
|
||||
"btnCloseZhuYinSingers",
|
||||
closeButtonZhuYinCoords,
|
||||
buttonImages.normal,
|
||||
buttonImages.mouseOver,
|
||||
buttonImages.mouseDown,
|
||||
CloseButtonZhuYinSingers_Click
|
||||
);
|
||||
}
|
||||
|
||||
private void CloseButtonZhuYinSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxZhuYinSingers.Visible = false;
|
||||
SetZhuYinSingersAndButtonsVisibility(false);
|
||||
}
|
||||
|
||||
private Button CreateSpecialButton(string name, (int X, int Y, int Width, int Height) coords, string normalImagePath, string mouseOverImagePath, string mouseDownImagePath, EventHandler clickEventHandler)
|
||||
{
|
||||
var button = new Button
|
||||
{
|
||||
Name = name,
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
FlatAppearance = { BorderSize = 0, MouseDownBackColor = Color.Transparent, MouseOverBackColor = Color.Transparent },
|
||||
BackgroundImageLayout = ImageLayout.Stretch,
|
||||
BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, normalImagePath))
|
||||
};
|
||||
|
||||
ResizeAndPositionButton(button, coords.X, coords.Y, coords.Width, coords.Height);
|
||||
|
||||
button.MouseEnter += (sender, e) => button.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, mouseOverImagePath));
|
||||
button.MouseLeave += (sender, e) => button.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, normalImagePath));
|
||||
button.MouseDown += (sender, e) => button.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, mouseDownImagePath));
|
||||
button.MouseUp += (sender, e) => button.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, normalImagePath));
|
||||
|
||||
button.Click += clickEventHandler;
|
||||
this.Controls.Add(button);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
private void InitializeInputBoxZhuYinSingers()
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadInputBoxConfig();
|
||||
|
||||
inputBoxZhuYinSingers = new RichTextBox
|
||||
{
|
||||
Name = "inputBoxZhuYinSingers",
|
||||
ForeColor = inputBoxForeColor,
|
||||
Font = new Font(inputBoxFontName, inputBoxFontSize, inputBoxFontStyle),
|
||||
ScrollBars = RichTextBoxScrollBars.None
|
||||
};
|
||||
|
||||
ResizeAndPositionControl(inputBoxZhuYinSingers, inputBoxZhuYinCoords.X, inputBoxZhuYinCoords.Y, inputBoxZhuYinCoords.Width, inputBoxZhuYinCoords.Height);
|
||||
|
||||
inputBoxZhuYinSingers.TextChanged += (sender, e) =>
|
||||
{
|
||||
string searchText = inputBoxZhuYinSingers.Text;
|
||||
var relatedSongs = allSongs
|
||||
.Where(song => (song.ArtistAPhonetic?.StartsWith(searchText, StringComparison.OrdinalIgnoreCase) ?? false) ||
|
||||
(song.ArtistBPhonetic?.StartsWith(searchText, StringComparison.OrdinalIgnoreCase) ?? false))
|
||||
.ToList();
|
||||
|
||||
currentPage = 0;
|
||||
currentSongList = relatedSongs;
|
||||
totalPages = (int)Math.Ceiling((double)relatedSongs.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(relatedSongs);
|
||||
};
|
||||
|
||||
this.Controls.Add(inputBoxZhuYinSingers);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error initializing inputBoxZhuYinSingers: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadInputBoxConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
var parser = new FileIniDataParser();
|
||||
string iniFilePath = "config.ini";
|
||||
|
||||
IniData data;
|
||||
using (var reader = new StreamReader(iniFilePath, Encoding.UTF8))
|
||||
{
|
||||
data = parser.ReadData(reader);
|
||||
}
|
||||
|
||||
inputBoxZhuYinCoords = (
|
||||
int.Parse(data["InputBoxZhuYinSingers"]["X"]),
|
||||
int.Parse(data["InputBoxZhuYinSingers"]["Y"]),
|
||||
int.Parse(data["InputBoxZhuYinSingers"]["Width"]),
|
||||
int.Parse(data["InputBoxZhuYinSingers"]["Height"])
|
||||
);
|
||||
|
||||
inputBoxFontName = data["InputBoxZhuYinSingers"]["FontName"];
|
||||
inputBoxFontSize = float.Parse(data["InputBoxZhuYinSingers"]["FontSize"]);
|
||||
inputBoxFontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), data["InputBoxZhuYinSingers"]["FontStyle"]);
|
||||
inputBoxForeColor = Color.FromName(data["InputBoxZhuYinSingers"]["ForeColor"]);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error loading inputBox configuration: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private (int X, int Y, int Width, int Height) pictureBoxZhuYinSingerCoords;
|
||||
|
||||
private void LoadPictureBoxZhuYinSingerCoordsFromConfig()
|
||||
{
|
||||
var parser = new FileIniDataParser();
|
||||
IniData data = parser.ReadFile("config.ini");
|
||||
|
||||
var coords = data["PictureBoxZhuYinSingers"];
|
||||
pictureBoxZhuYinSingerCoords = (
|
||||
int.Parse(coords["X"]),
|
||||
int.Parse(coords["Y"]),
|
||||
int.Parse(coords["Width"]),
|
||||
int.Parse(coords["Height"])
|
||||
);
|
||||
}
|
||||
|
||||
private void ShowImageOnPictureBoxZhuYinSingers(string imagePath)
|
||||
{
|
||||
|
||||
LoadPictureBoxZhuYinSingerCoordsFromConfig();
|
||||
|
||||
|
||||
Bitmap originalImage = new Bitmap(imagePath);
|
||||
|
||||
|
||||
Rectangle displayArea = new Rectangle(pictureBoxZhuYinSingerCoords.X, pictureBoxZhuYinSingerCoords.Y, pictureBoxZhuYinSingerCoords.Width, pictureBoxZhuYinSingerCoords.Height);
|
||||
|
||||
|
||||
pictureBoxZhuYinSingers.Image = originalImage;
|
||||
|
||||
|
||||
ResizeAndPositionPictureBox(pictureBoxZhuYinSingers, displayArea.X, displayArea.Y, displayArea.Width, displayArea.Height);
|
||||
|
||||
pictureBoxZhuYinSingers.Visible = true;
|
||||
}
|
||||
|
||||
private void SetZhuYinSingersAndButtonsVisibility(bool isVisible)
|
||||
{
|
||||
System.Action action = () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
SuspendLayout();
|
||||
|
||||
if (pictureBoxZhuYinSingers == null)
|
||||
{
|
||||
Console.WriteLine("pictureBoxZhuYinSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
pictureBoxZhuYinSingers.Visible = isVisible;
|
||||
if (isVisible) pictureBoxZhuYinSingers.BringToFront();
|
||||
}
|
||||
|
||||
if (phoneticButtonsForSingers == null)
|
||||
{
|
||||
Console.WriteLine("phoneticButtonsForSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var button in phoneticButtonsForSingers)
|
||||
{
|
||||
if (button == null)
|
||||
{
|
||||
Console.WriteLine("One of the phoneticButtonsForSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
button.Visible = isVisible;
|
||||
if (isVisible) button.BringToFront();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modifyButtonZhuYinSingers == null)
|
||||
{
|
||||
Console.WriteLine("modifyButtonZhuYinSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
modifyButtonZhuYinSingers.Visible = isVisible;
|
||||
if (isVisible) modifyButtonZhuYinSingers.BringToFront();
|
||||
}
|
||||
|
||||
if (clearButtonZhuYinSingers == null)
|
||||
{
|
||||
Console.WriteLine("clearButtonZhuYinSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
clearButtonZhuYinSingers.Visible = isVisible;
|
||||
if (isVisible) clearButtonZhuYinSingers.BringToFront();
|
||||
}
|
||||
|
||||
if (closeButtonZhuYinSingers == null)
|
||||
{
|
||||
Console.WriteLine("closeButtonZhuYinSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
closeButtonZhuYinSingers.Visible = isVisible;
|
||||
if (isVisible) closeButtonZhuYinSingers.BringToFront();
|
||||
}
|
||||
|
||||
if (inputBoxZhuYinSingers == null)
|
||||
{
|
||||
Console.WriteLine("inputBoxZhuYinSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
inputBoxZhuYinSingers.Visible = isVisible;
|
||||
if (isVisible) inputBoxZhuYinSingers.BringToFront();
|
||||
}
|
||||
|
||||
ResumeLayout();
|
||||
PerformLayout();
|
||||
|
||||
|
||||
pictureBoxZhuYinSingers?.Refresh();
|
||||
if (phoneticButtonsForSingers != null)
|
||||
{
|
||||
foreach (var button in phoneticButtonsForSingers)
|
||||
{
|
||||
button?.Refresh();
|
||||
}
|
||||
}
|
||||
modifyButtonZhuYinSingers?.Refresh();
|
||||
clearButtonZhuYinSingers?.Refresh();
|
||||
closeButtonZhuYinSingers?.Refresh();
|
||||
inputBoxZhuYinSingers?.Refresh();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error in SetZhuYinSingersAndButtonsVisibility: " + ex.Message);
|
||||
}
|
||||
};
|
||||
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(action);
|
||||
}
|
||||
else
|
||||
{
|
||||
action();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,435 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using IniParser;
|
||||
using IniParser.Model;
|
||||
using System.Text;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private PictureBox pictureBoxEnglishSingers;
|
||||
|
||||
private Button[] numberButtonsForSingers;
|
||||
private Button[] letterButtonsForEnglishSingers;
|
||||
private Button modifyButtonEnglishSingers;
|
||||
private Button clearButtonEnglishSingers;
|
||||
private Button closeButtonEnglishSingers;
|
||||
|
||||
private (int X, int Y, int Width, int Height) modifyButtonEnglishCoords;
|
||||
private (int X, int Y, int Width, int Height) clearButtonEnglishCoords;
|
||||
private (int X, int Y, int Width, int Height) closeButtonEnglishCoords;
|
||||
|
||||
private RichTextBox inputBoxEnglishSingers;
|
||||
|
||||
private void EnglishSearchSingersButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
zhuyinSearchButton.BackgroundImage = zhuyinSearchNormalBackground;
|
||||
englishSearchButton.BackgroundImage = englishSearchActiveBackground;
|
||||
pinyinSearchButton.BackgroundImage = pinyinSearchNormalBackground;
|
||||
wordCountSearchButton.BackgroundImage = wordCountSearchNormalBackground;
|
||||
handWritingSearchButton.BackgroundImage = handWritingSearchNormalBackground;
|
||||
|
||||
bool shouldBeVisible = !pictureBoxEnglishSingers.Visible;
|
||||
|
||||
|
||||
var configData = LoadConfigData();
|
||||
string imagePath = Path.Combine(Application.StartupPath, configData["ImagePaths"]["EnglishSingers"]);
|
||||
|
||||
ShowImageOnPictureBoxEnglishSingers(Path.Combine(Application.StartupPath, imagePath));
|
||||
|
||||
SetZhuYinSingersAndButtonsVisibility(false);
|
||||
SetPinYinSingersAndButtonsVisibility(false);
|
||||
SetHandWritingForSingersAndButtonsVisibility(false);
|
||||
SetEnglishSingersAndButtonsVisibility(true);
|
||||
SetPictureBoxArtistSearchAndButtonsVisibility(false);
|
||||
pictureBoxEnglishSingers.Visible = true;
|
||||
}
|
||||
|
||||
private (int X, int Y, int Width, int Height)[] numberButtonCoords;
|
||||
|
||||
private void LoadNumberButtonCoordsFromConfig()
|
||||
{
|
||||
var parser = new FileIniDataParser();
|
||||
IniData data = parser.ReadFile("config.ini");
|
||||
|
||||
var buttonList = new List<(int X, int Y, int Width, int Height)>();
|
||||
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
var coordString = data["NumberButtonCoordinates"][$"button{i}"];
|
||||
var coords = coordString.Split(',');
|
||||
buttonList.Add((int.Parse(coords[0]), int.Parse(coords[1]), int.Parse(coords[2]), int.Parse(coords[3])));
|
||||
}
|
||||
|
||||
numberButtonCoords = buttonList.ToArray();
|
||||
}
|
||||
|
||||
private Button CreateButton(string name, (int X, int Y, int Width, int Height) coords, string normalImagePath, string mouseDownImagePath, string mouseOverImagePath, EventHandler clickEventHandler)
|
||||
{
|
||||
var button = new Button
|
||||
{
|
||||
Name = name,
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
FlatAppearance = { BorderSize = 0, MouseDownBackColor = Color.Transparent, MouseOverBackColor = Color.Transparent },
|
||||
BackgroundImageLayout = ImageLayout.Stretch,
|
||||
BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, normalImagePath))
|
||||
};
|
||||
|
||||
ResizeAndPositionButton(button, coords.X, coords.Y, coords.Width, coords.Height);
|
||||
|
||||
button.MouseEnter += (sender, e) => button.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, mouseOverImagePath));
|
||||
button.MouseLeave += (sender, e) => button.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, normalImagePath));
|
||||
button.MouseDown += (sender, e) => button.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, mouseDownImagePath));
|
||||
button.MouseUp += (sender, e) => button.BackgroundImage = Image.FromFile(Path.Combine(Application.StartupPath, normalImagePath));
|
||||
|
||||
button.Click += clickEventHandler;
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
private void InitializeNumberButtonsForSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
numberButtonCoords = LoadButtonCoordinates(data, "NumberButtonCoordinates", 10);
|
||||
var buttonImages = LoadButtonImages(data, "NumberButtonImages", 10);
|
||||
|
||||
numberButtonsForSingers = new Button[10];
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
string normalImagePath = buttonImages[$"button{i}"].normal;
|
||||
string mouseDownImagePath = buttonImages[$"button{i}"].mouseDown;
|
||||
string mouseOverImagePath = buttonImages[$"button{i}"].mouseOver;
|
||||
|
||||
|
||||
if (normalImagePath == null || mouseDownImagePath == null || mouseOverImagePath == null)
|
||||
{
|
||||
Console.WriteLine($"Error: One or more image paths for button{i} are null.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
numberButtonsForSingers[i] = CreateButton(
|
||||
$"numberButton_{i}",
|
||||
numberButtonCoords[i],
|
||||
normalImagePath,
|
||||
mouseDownImagePath,
|
||||
mouseOverImagePath,
|
||||
NumberButtonForSingers_Click
|
||||
);
|
||||
numberButtonsForSingers[i].Tag = (i + 1) % 10;
|
||||
this.Controls.Add(numberButtonsForSingers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void NumberButtonForSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var button = sender as Button;
|
||||
if (button != null && button.Tag != null)
|
||||
{
|
||||
if (inputBoxEnglishSingers.Visible)
|
||||
{
|
||||
inputBoxEnglishSingers.Text += button.Tag.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeLetterButtonsForEnglishSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
var buttonImages = LoadButtonImages(data, "EnglishLetterButtonImages", 26);
|
||||
string qwertyLayout = "QWERTYUIOPASDFGHJKLZXCVBNM";
|
||||
letterButtonsForEnglishSingers = new Button[26];
|
||||
|
||||
for (int i = 0; i < 26; i++)
|
||||
{
|
||||
var coords = data["EnglishLetterButtonCoordinates"][$"button{i}"].Split(',');
|
||||
letterButtonsForEnglishSingers[i] = CreateButton(
|
||||
$"letterButton_{qwertyLayout[i]}",
|
||||
(int.Parse(coords[0]), int.Parse(coords[1]), int.Parse(coords[2]), int.Parse(coords[3])),
|
||||
buttonImages[$"button{i}"].normal,
|
||||
buttonImages[$"button{i}"].mouseDown,
|
||||
buttonImages[$"button{i}"].mouseOver,
|
||||
LetterButtonEnglishSingers_Click
|
||||
);
|
||||
letterButtonsForEnglishSingers[i].Tag = qwertyLayout[i];
|
||||
this.Controls.Add(letterButtonsForEnglishSingers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void LetterButtonEnglishSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var button = sender as Button;
|
||||
if (button != null && button.Tag != null)
|
||||
{
|
||||
if (inputBoxEnglishSingers.Visible)
|
||||
{
|
||||
inputBoxEnglishSingers.Text += button.Tag.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeButtonsForEnglishSingers()
|
||||
{
|
||||
InitializeNumberButtonsForSingers();
|
||||
InitializeLetterButtonsForEnglishSingers();
|
||||
|
||||
|
||||
InitializeModifyButtonEnglishSingers();
|
||||
|
||||
|
||||
InitializeClearButtonEnglishSingers();
|
||||
|
||||
|
||||
InitializeCloseButtonEnglishSingers();
|
||||
|
||||
InitializeInputBoxEnglishSingers();
|
||||
}
|
||||
|
||||
private void InitializeModifyButtonEnglishSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
modifyButtonEnglishCoords = LoadSpecialButtonCoordinates(data, "SpecialButtonCoordinates", "modifyButtonEnglishSingers");
|
||||
var buttonImages = LoadButtonImages(data, "ModifyButtonImagesEnglish");
|
||||
|
||||
modifyButtonEnglishSingers = CreateSpecialButton(
|
||||
"btnModifyEnglishSingers",
|
||||
modifyButtonEnglishCoords,
|
||||
buttonImages.normal,
|
||||
buttonImages.mouseOver,
|
||||
buttonImages.mouseDown,
|
||||
ModifyButtonEnglishSingers_Click
|
||||
);
|
||||
|
||||
this.Controls.Add(modifyButtonEnglishSingers);
|
||||
}
|
||||
|
||||
private void ModifyButtonEnglishSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (this.Controls.Contains(inputBoxEnglishSingers) && inputBoxEnglishSingers.Text.Length > 0)
|
||||
{
|
||||
inputBoxEnglishSingers.Text = inputBoxEnglishSingers.Text.Substring(0, inputBoxEnglishSingers.Text.Length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeClearButtonEnglishSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
clearButtonEnglishCoords = LoadSpecialButtonCoordinates(data, "SpecialButtonCoordinates", "clearButtonEnglishSingers");
|
||||
var buttonImages = LoadButtonImages(data, "ClearButtonImagesEnglish");
|
||||
|
||||
clearButtonEnglishSingers = CreateSpecialButton(
|
||||
"btnClearEnglishSingers",
|
||||
clearButtonEnglishCoords,
|
||||
buttonImages.normal,
|
||||
buttonImages.mouseOver,
|
||||
buttonImages.mouseDown,
|
||||
ClearButtonEnglishSingers_Click
|
||||
);
|
||||
|
||||
this.Controls.Add(clearButtonEnglishSingers);
|
||||
}
|
||||
|
||||
private void ClearButtonEnglishSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.Controls.Contains(inputBoxEnglishSingers) && inputBoxEnglishSingers.Text.Length > 0)
|
||||
{
|
||||
inputBoxEnglishSingers.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeCloseButtonEnglishSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
closeButtonEnglishCoords = LoadSpecialButtonCoordinates(data, "SpecialButtonCoordinates", "closeButtonEnglishSingers");
|
||||
var buttonImages = LoadButtonImages(data, "CloseButtonImagesEnglish");
|
||||
|
||||
closeButtonEnglishSingers = CreateSpecialButton(
|
||||
"btnCloseEnglishSingers",
|
||||
closeButtonEnglishCoords,
|
||||
buttonImages.normal,
|
||||
buttonImages.mouseOver,
|
||||
buttonImages.mouseDown,
|
||||
CloseButtonEnglishSingers_Click
|
||||
);
|
||||
|
||||
this.Controls.Add(closeButtonEnglishSingers);
|
||||
}
|
||||
|
||||
private void CloseButtonEnglishSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
pictureBoxEnglishSingers.Visible = false;
|
||||
SetEnglishSingersAndButtonsVisibility(false);
|
||||
}
|
||||
|
||||
private void InitializeInputBoxEnglishSingers()
|
||||
{
|
||||
try
|
||||
{
|
||||
var parser = new FileIniDataParser();
|
||||
parser.Parser.Configuration.AssigmentSpacer = "";
|
||||
parser.Parser.Configuration.CommentString = "#";
|
||||
parser.Parser.Configuration.CaseInsensitive = true;
|
||||
|
||||
|
||||
IniData data;
|
||||
using (var reader = new StreamReader("config.ini", System.Text.Encoding.UTF8))
|
||||
{
|
||||
data = parser.ReadData(reader);
|
||||
}
|
||||
|
||||
int x = int.Parse(data["InputBoxEnglishSingers"]["X"]);
|
||||
int y = int.Parse(data["InputBoxEnglishSingers"]["Y"]);
|
||||
int width = int.Parse(data["InputBoxEnglishSingers"]["Width"]);
|
||||
int height = int.Parse(data["InputBoxEnglishSingers"]["Height"]);
|
||||
string fontName = data["InputBoxEnglishSingers"]["FontName"];
|
||||
float fontSize = float.Parse(data["InputBoxEnglishSingers"]["FontSize"]);
|
||||
FontStyle fontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), data["InputBoxEnglishSingers"]["FontStyle"]);
|
||||
Color foreColor = Color.FromName(data["InputBoxEnglishSingers"]["ForeColor"]);
|
||||
|
||||
inputBoxEnglishSingers = new RichTextBox
|
||||
{
|
||||
Visible = false,
|
||||
Name = "inputBoxEnglishSingers",
|
||||
ForeColor = foreColor,
|
||||
Font = new Font(fontName, fontSize / 900 * Screen.PrimaryScreen.Bounds.Height, fontStyle)
|
||||
};
|
||||
|
||||
ResizeAndPositionControl(inputBoxEnglishSingers, x, y, width, height);
|
||||
|
||||
inputBoxEnglishSingers.TextChanged += (sender, e) =>
|
||||
{
|
||||
string searchText = inputBoxEnglishSingers.Text;
|
||||
var searchResults = allArtists.Where(artist => artist.Name.Replace(" ", "").StartsWith(searchText)).ToList();
|
||||
|
||||
currentPage = 0;
|
||||
currentArtistList = searchResults;
|
||||
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSingers(currentArtistList);
|
||||
};
|
||||
|
||||
this.Controls.Add(inputBoxEnglishSingers);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"An error occurred: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowImageOnPictureBoxEnglishSingers(string imagePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
var parser = new FileIniDataParser();
|
||||
parser.Parser.Configuration.AssigmentSpacer = "";
|
||||
parser.Parser.Configuration.CommentString = "#";
|
||||
parser.Parser.Configuration.CaseInsensitive = true;
|
||||
|
||||
|
||||
IniData data;
|
||||
using (var reader = new StreamReader("config.ini", System.Text.Encoding.UTF8))
|
||||
{
|
||||
data = parser.ReadData(reader);
|
||||
}
|
||||
|
||||
int x = int.Parse(data["PictureBoxEnglishSingers"]["X"]);
|
||||
int y = int.Parse(data["PictureBoxEnglishSingers"]["Y"]);
|
||||
int width = int.Parse(data["PictureBoxEnglishSingers"]["Width"]);
|
||||
int height = int.Parse(data["PictureBoxEnglishSingers"]["Height"]);
|
||||
|
||||
|
||||
Bitmap originalImage = new Bitmap(imagePath);
|
||||
|
||||
|
||||
pictureBoxEnglishSingers.Image = originalImage;
|
||||
|
||||
|
||||
ResizeAndPositionPictureBox(pictureBoxEnglishSingers, x, y, width, height);
|
||||
|
||||
pictureBoxEnglishSingers.Visible = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"An error occurred: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void SetEnglishSingersAndButtonsVisibility(bool isVisible)
|
||||
{
|
||||
System.Action action = () =>
|
||||
{
|
||||
SuspendLayout();
|
||||
|
||||
pictureBoxEnglishSingers.Visible = isVisible;
|
||||
if (isVisible) pictureBoxEnglishSingers.BringToFront();
|
||||
|
||||
foreach (var button in numberButtonsForSingers)
|
||||
{
|
||||
button.Visible = isVisible;
|
||||
if (isVisible) button.BringToFront();
|
||||
}
|
||||
|
||||
foreach (var button in letterButtonsForEnglishSingers)
|
||||
{
|
||||
button.Visible = isVisible;
|
||||
if (isVisible) button.BringToFront();
|
||||
}
|
||||
|
||||
|
||||
if (modifyButtonEnglishSingers != null)
|
||||
{
|
||||
modifyButtonEnglishSingers.Visible = isVisible;
|
||||
if (isVisible) modifyButtonEnglishSingers.BringToFront();
|
||||
}
|
||||
|
||||
if (clearButtonEnglishSingers != null)
|
||||
{
|
||||
clearButtonEnglishSingers.Visible = isVisible;
|
||||
if (isVisible) clearButtonEnglishSingers.BringToFront();
|
||||
}
|
||||
|
||||
closeButtonEnglishSingers.Visible = isVisible;
|
||||
if (isVisible) closeButtonEnglishSingers.BringToFront();
|
||||
|
||||
inputBoxEnglishSingers.Visible = isVisible;
|
||||
if (isVisible) inputBoxEnglishSingers.BringToFront();
|
||||
|
||||
ResumeLayout();
|
||||
PerformLayout();
|
||||
|
||||
|
||||
pictureBoxEnglishSingers.Refresh();
|
||||
foreach (var button in numberButtonsForSingers.Concat(letterButtonsForEnglishSingers))
|
||||
{
|
||||
button.Refresh();
|
||||
}
|
||||
|
||||
|
||||
modifyButtonEnglishSingers.Refresh();
|
||||
clearButtonEnglishSingers.Refresh();
|
||||
closeButtonEnglishSingers.Refresh();
|
||||
inputBoxEnglishSingers.Refresh();
|
||||
};
|
||||
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(action);
|
||||
}
|
||||
else
|
||||
{
|
||||
action();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,306 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Ink;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private PictureBox pictureBoxHandWritingSingers;
|
||||
|
||||
private Button refillButtonHandWritingSingers;
|
||||
private Button clearButtonHandWritingSingers;
|
||||
private Button closeButtonForSingers;
|
||||
|
||||
private (int X, int Y, int Width, int Height) refillButtonHandWritingCoords;
|
||||
private (int X, int Y, int Width, int Height) clearButtonHandWritingCoords;
|
||||
private (int X, int Y, int Width, int Height) closeButtonHandWritingCoords;
|
||||
|
||||
private void HandWritingSearchButtonForSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.SuspendLayout();
|
||||
|
||||
zhuyinSearchButton.BackgroundImage = zhuyinSearchNormalBackground;
|
||||
englishSearchButton.BackgroundImage = englishSearchNormalBackground;
|
||||
pinyinSearchButton.BackgroundImage = pinyinSearchNormalBackground;
|
||||
wordCountSearchButton.BackgroundImage = wordCountSearchNormalBackground;
|
||||
handWritingSearchButton.BackgroundImage = handWritingSearchActiveBackground;
|
||||
|
||||
|
||||
EnableDoubleBuffering(handWritingPanelForSingers);
|
||||
EnableDoubleBuffering(handwritingInputBoxForSingers);
|
||||
EnableDoubleBuffering(candidateListBoxForSingers);
|
||||
EnableDoubleBuffering(pictureBoxHandWritingSingers);
|
||||
EnableDoubleBuffering(refillButtonHandWritingSingers);
|
||||
EnableDoubleBuffering(closeButtonForSingers);
|
||||
|
||||
|
||||
var configData = LoadConfigData();
|
||||
string handWritingImagePath = Path.Combine(Application.StartupPath, configData["ImagePaths"]["HandWritingSingers"]);
|
||||
|
||||
ShowImageOnPictureBoxHandWritingSingers(Path.Combine(Application.StartupPath, handWritingImagePath));
|
||||
SetZhuYinSingersAndButtonsVisibility(false);
|
||||
SetEnglishSingersAndButtonsVisibility(false);
|
||||
SetPinYinSingersAndButtonsVisibility(false);
|
||||
SetPictureBoxArtistSearchAndButtonsVisibility(false);
|
||||
SetHandWritingForSingersAndButtonsVisibility(true);
|
||||
|
||||
this.ResumeLayout();
|
||||
}
|
||||
|
||||
private Panel handWritingPanelForSingers;
|
||||
private InkOverlay inkOverlayForSingers;
|
||||
private RichTextBox handwritingInputBoxForSingers;
|
||||
private ListBox candidateListBoxForSingers;
|
||||
|
||||
|
||||
private void InitializeHandWritingForSingers()
|
||||
{
|
||||
InitializeHandWritingPanelForSingers();
|
||||
InitializeInkOverlayForSingers();
|
||||
InitializeHandwritingInputBoxForSingers();
|
||||
InitializeCandidateListBoxForSingers();
|
||||
InitializeSpecialButtonsForHandWritingSingers();
|
||||
}
|
||||
|
||||
private void InitializeHandWritingPanelForSingers()
|
||||
{
|
||||
|
||||
handWritingPanelForSingers = new Panel
|
||||
{
|
||||
BorderStyle = BorderStyle.FixedSingle,
|
||||
Visible = false
|
||||
};
|
||||
|
||||
|
||||
ResizeAndPositionControl(handWritingPanelForSingers, 366, 448, 650, 260);
|
||||
|
||||
|
||||
this.Controls.Add(handWritingPanelForSingers);
|
||||
}
|
||||
|
||||
private void InitializeInkOverlayForSingers()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
inkOverlayForSingers = new InkOverlay(handWritingPanelForSingers);
|
||||
inkOverlayForSingers.Enabled = false;
|
||||
inkOverlayForSingers.Ink = new Ink();
|
||||
inkOverlayForSingers.DefaultDrawingAttributes.Color = Color.Black;
|
||||
inkOverlayForSingers.DefaultDrawingAttributes.Width = 100;
|
||||
inkOverlayForSingers.Stroke += new InkCollectorStrokeEventHandler(InkOverlayForSingers_Stroke);
|
||||
|
||||
|
||||
inkOverlayForSingers.Enabled = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Failed to initialize ink overlay for singers: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void InkOverlayForSingers_Stroke(object sender, InkCollectorStrokeEventArgs e)
|
||||
{
|
||||
|
||||
RecognizeInk(inkOverlayForSingers, candidateListBoxForSingers);
|
||||
}
|
||||
|
||||
private void InitializeHandwritingInputBoxForSingers()
|
||||
{
|
||||
|
||||
handwritingInputBoxForSingers = new RichTextBox
|
||||
{
|
||||
Font = new Font("微軟正黑體", (float)26 / 900 * Screen.PrimaryScreen.Bounds.Height, FontStyle.Regular),
|
||||
Visible = false
|
||||
};
|
||||
ResizeAndPositionControl(handwritingInputBoxForSingers, 366, 373, 541, 62);
|
||||
this.Controls.Add(handwritingInputBoxForSingers);
|
||||
|
||||
handwritingInputBoxForSingers.TextChanged += (sender, e) =>
|
||||
{
|
||||
string searchText = handwritingInputBoxForSingers.Text;
|
||||
|
||||
|
||||
var searchResults = allArtists.Where(artist => artist.Name.StartsWith(searchText)).ToList();
|
||||
|
||||
currentPage = 0;
|
||||
currentArtistList = searchResults;
|
||||
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSingers(currentArtistList);
|
||||
};
|
||||
}
|
||||
|
||||
private void InitializeCandidateListBoxForSingers()
|
||||
{
|
||||
|
||||
candidateListBoxForSingers = new ListBox
|
||||
{
|
||||
Font = new Font("微軟正黑體", (float)26 / 900 * Screen.PrimaryScreen.Bounds.Height, FontStyle.Regular),
|
||||
Visible = false
|
||||
};
|
||||
ResizeAndPositionControl(candidateListBoxForSingers, 350 + 679, 448, 115, 260);
|
||||
candidateListBoxForSingers.SelectedIndexChanged += CandidateListBoxForSingers_SelectedIndexChanged;
|
||||
this.Controls.Add(candidateListBoxForSingers);
|
||||
}
|
||||
|
||||
private void CandidateListBoxForSingers_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (candidateListBoxForSingers.SelectedIndex != -1)
|
||||
{
|
||||
string selectedWord = candidateListBoxForSingers.SelectedItem.ToString();
|
||||
handwritingInputBoxForSingers.Text += selectedWord;
|
||||
candidateListBoxForSingers.Visible = false;
|
||||
|
||||
|
||||
if (inkOverlayForSingers != null)
|
||||
{
|
||||
inkOverlayForSingers.Ink.DeleteStrokes();
|
||||
handWritingPanelForSingers.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowImageOnPictureBoxHandWritingSingers(string imagePath)
|
||||
{
|
||||
|
||||
Bitmap originalImage = new Bitmap(imagePath);
|
||||
|
||||
|
||||
Rectangle displayArea = new Rectangle(350, 360, 810, 360);
|
||||
|
||||
|
||||
pictureBoxHandWritingSingers.Image = originalImage;
|
||||
|
||||
|
||||
ResizeAndPositionPictureBox(pictureBoxHandWritingSingers, displayArea.X, displayArea.Y, displayArea.Width, displayArea.Height);
|
||||
|
||||
pictureBoxHandWritingSingers.Visible = true;
|
||||
}
|
||||
|
||||
private void SetHandWritingForSingersAndButtonsVisibility(bool isVisible)
|
||||
{
|
||||
|
||||
EnableDoubleBuffering(handWritingPanelForSingers);
|
||||
EnableDoubleBuffering(handwritingInputBoxForSingers);
|
||||
EnableDoubleBuffering(candidateListBoxForSingers);
|
||||
EnableDoubleBuffering(pictureBoxHandWritingSingers);
|
||||
EnableDoubleBuffering(refillButtonHandWritingSingers);
|
||||
EnableDoubleBuffering(clearButtonHandWritingSingers);
|
||||
EnableDoubleBuffering(closeButtonForSingers);
|
||||
|
||||
|
||||
handWritingPanelForSingers.Visible = isVisible;
|
||||
handwritingInputBoxForSingers.Visible = isVisible;
|
||||
inkOverlayForSingers.Enabled = isVisible;
|
||||
candidateListBoxForSingers.Visible = isVisible;
|
||||
pictureBoxHandWritingSingers.Visible = isVisible;
|
||||
refillButtonHandWritingSingers.Visible = isVisible;
|
||||
clearButtonHandWritingSingers.Visible = isVisible;
|
||||
closeButtonForSingers.Visible = isVisible;
|
||||
|
||||
if (isVisible)
|
||||
{
|
||||
|
||||
pictureBoxHandWritingSingers.BringToFront();
|
||||
handWritingPanelForSingers.BringToFront();
|
||||
handwritingInputBoxForSingers.BringToFront();
|
||||
candidateListBoxForSingers.BringToFront();
|
||||
refillButtonHandWritingSingers.BringToFront();
|
||||
clearButtonHandWritingSingers.BringToFront();
|
||||
closeButtonForSingers.BringToFront();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeSpecialButtonsForHandWritingSingers()
|
||||
{
|
||||
|
||||
InitializeRefillButtonHandwritingSingers();
|
||||
|
||||
|
||||
InitializeClearButtonHandWritingSingers();
|
||||
|
||||
|
||||
InitializeCloseButtonForSingers();
|
||||
}
|
||||
|
||||
private void InitializeRefillButtonHandwritingSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
refillButtonHandWritingCoords = LoadSpecialButtonCoordinates(data, "SpecialButtonCoordinates", "refillButtonHandWritingSingers");
|
||||
var buttonImages = LoadButtonImages(data, "RefillButtonImagesHandWriting");
|
||||
|
||||
refillButtonHandWritingSingers = CreateSpecialButton(
|
||||
"refillButtonHandWritingSingers",
|
||||
refillButtonHandWritingCoords,
|
||||
buttonImages.normal,
|
||||
buttonImages.mouseOver,
|
||||
buttonImages.mouseDown,
|
||||
RefillButtonHandWritingSingers_Click
|
||||
);
|
||||
}
|
||||
|
||||
private void RefillButtonHandWritingSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
handwritingInputBoxForSingers.Text = "";
|
||||
}
|
||||
|
||||
private void InitializeClearButtonHandWritingSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
clearButtonHandWritingCoords = LoadSpecialButtonCoordinates(data, "SpecialButtonCoordinates", "clearButtonHandWritingSingers");
|
||||
var buttonImages = LoadButtonImages(data, "ClearButtonImagesHandWriting");
|
||||
|
||||
clearButtonHandWritingSingers = CreateSpecialButton(
|
||||
"clearButtonHandWritingSingers",
|
||||
clearButtonHandWritingCoords,
|
||||
buttonImages.normal,
|
||||
buttonImages.mouseOver,
|
||||
buttonImages.mouseDown,
|
||||
|
||||
ClearButtonHandWritingSingers_Click
|
||||
);
|
||||
}
|
||||
|
||||
private void ClearButtonHandWritingSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.Controls.Contains(handWritingPanelForSingers) && inkOverlayForSingers != null)
|
||||
{
|
||||
inkOverlayForSingers.Ink.DeleteStrokes();
|
||||
handWritingPanelForSingers.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeCloseButtonForSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
closeButtonHandWritingCoords = LoadSpecialButtonCoordinates(data, "SpecialButtonCoordinates", "closeButtonForSingers");
|
||||
var buttonImages = LoadButtonImages(data, "CloseButtonImagesHandWriting");
|
||||
|
||||
closeButtonForSingers = CreateSpecialButton(
|
||||
"closeButtonForSingers",
|
||||
closeButtonHandWritingCoords,
|
||||
buttonImages.normal,
|
||||
buttonImages.mouseOver,
|
||||
buttonImages.mouseDown,
|
||||
CloseButtonForSingers_Click
|
||||
);
|
||||
}
|
||||
|
||||
private void CloseButtonForSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
this.SuspendLayout();
|
||||
|
||||
SetHandWritingForSingersAndButtonsVisibility(false);
|
||||
|
||||
|
||||
this.ResumeLayout();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,365 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using IniParser;
|
||||
using IniParser.Model;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private PictureBox pictureBoxPinYinSingers;
|
||||
private Button[] letterButtonsForPinYinSingers;
|
||||
private Button modifyButtonPinYinSingers;
|
||||
private Button clearButtonPinYinSingers;
|
||||
private Button closeButtonPinYinSingers;
|
||||
|
||||
private (int X, int Y, int Width, int Height) modifyButtonPinYinCoords;
|
||||
private (int X, int Y, int Width, int Height) clearButtonPinYinCoords;
|
||||
private (int X, int Y, int Width, int Height) closeButtonPinYinCoords;
|
||||
|
||||
private RichTextBox inputBoxPinYinSingers;
|
||||
|
||||
private void PinyinSingerSearchButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
zhuyinSearchButton.BackgroundImage = zhuyinSearchNormalBackground;
|
||||
englishSearchButton.BackgroundImage = englishSearchNormalBackground;
|
||||
pinyinSearchButton.BackgroundImage = pinyinSearchActiveBackground;
|
||||
wordCountSearchButton.BackgroundImage = wordCountSearchNormalBackground;
|
||||
handWritingSearchButton.BackgroundImage = handWritingSearchNormalBackground;
|
||||
|
||||
|
||||
var configData = LoadConfigData();
|
||||
string pinyinImagePath = Path.Combine(Application.StartupPath, configData["ImagePaths"]["PinYinSingers"]);
|
||||
|
||||
ShowImageOnPictureBoxPinYinSingers(Path.Combine(Application.StartupPath, pinyinImagePath));
|
||||
|
||||
|
||||
|
||||
SetZhuYinSingersAndButtonsVisibility(false);
|
||||
SetEnglishSingersAndButtonsVisibility(false);
|
||||
SetPinYinSingersAndButtonsVisibility(true);
|
||||
SetPictureBoxArtistSearchAndButtonsVisibility(false);
|
||||
pictureBoxPinYinSingers.Visible = true;
|
||||
}
|
||||
|
||||
private void InitializeLetterButtonsForPinYinSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
var buttonImages = LoadButtonImages(data, "PinYinLetterButtonImages", 26);
|
||||
string qwertyLayout = "QWERTYUIOPASDFGHJKLZXCVBNM";
|
||||
letterButtonsForPinYinSingers = new Button[26];
|
||||
|
||||
for (int i = 0; i < 26; i++)
|
||||
{
|
||||
var coords = data["PinYinLetterButtonCoordinates"][$"button{i}"].Split(',');
|
||||
letterButtonsForPinYinSingers[i] = CreateButton(
|
||||
$"letterButton_{qwertyLayout[i]}",
|
||||
(int.Parse(coords[0]), int.Parse(coords[1]), int.Parse(coords[2]), int.Parse(coords[3])),
|
||||
buttonImages[$"button{i}"].normal,
|
||||
buttonImages[$"button{i}"].mouseDown,
|
||||
buttonImages[$"button{i}"].mouseOver,
|
||||
LetterButtonPinYinSingers_Click
|
||||
);
|
||||
letterButtonsForPinYinSingers[i].Tag = qwertyLayout[i];
|
||||
this.Controls.Add(letterButtonsForPinYinSingers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void LetterButtonPinYinSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var button = sender as Button;
|
||||
if (button != null && button.Tag != null)
|
||||
{
|
||||
if (inputBoxPinYinSingers.Visible)
|
||||
{
|
||||
inputBoxPinYinSingers.Text += button.Tag.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeButtonsForPinYinSingers()
|
||||
{
|
||||
InitializeLetterButtonsForPinYinSingers();
|
||||
InitializeSpecialButtonsForPinYinSingers();
|
||||
InitializeInputBoxPinYinSingers();
|
||||
}
|
||||
|
||||
private void InitializeSpecialButtonsForPinYinSingers()
|
||||
{
|
||||
|
||||
InitializeModifyButtonPinYinSingers();
|
||||
|
||||
|
||||
InitializeClearButtonPinYinSingers();
|
||||
|
||||
|
||||
InitializeCloseButtonPinYinSingers();
|
||||
}
|
||||
|
||||
private void InitializeModifyButtonPinYinSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
modifyButtonPinYinCoords = LoadSpecialButtonCoordinates(data, "SpecialButtonCoordinates", "modifyButtonPinYinSingers");
|
||||
var buttonImages = LoadButtonImages(data, "ModifyButtonImagesPinYin");
|
||||
|
||||
modifyButtonPinYinSingers = CreateSpecialButton(
|
||||
"btnModifyPinYinSingers",
|
||||
modifyButtonPinYinCoords,
|
||||
buttonImages.normal,
|
||||
buttonImages.mouseOver,
|
||||
buttonImages.mouseDown,
|
||||
ModifyButtonPinYinSingers_Click
|
||||
);
|
||||
}
|
||||
|
||||
private void ModifyButtonPinYinSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (this.Controls.Contains(inputBoxPinYinSingers) && inputBoxPinYinSingers.Text.Length > 0)
|
||||
{
|
||||
inputBoxPinYinSingers.Text = inputBoxPinYinSingers.Text.Substring(0, inputBoxPinYinSingers.Text.Length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeClearButtonPinYinSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
clearButtonPinYinCoords = LoadSpecialButtonCoordinates(data, "SpecialButtonCoordinates", "clearButtonPinYinSingers");
|
||||
var buttonImages = LoadButtonImages(data, "ClearButtonImagesPinYin");
|
||||
|
||||
clearButtonPinYinSingers = CreateSpecialButton(
|
||||
"btnClearPinYinSingers",
|
||||
clearButtonPinYinCoords,
|
||||
buttonImages.normal,
|
||||
buttonImages.mouseOver,
|
||||
buttonImages.mouseDown,
|
||||
ClearButtonPinYinSingers_Click
|
||||
);
|
||||
}
|
||||
|
||||
private void ClearButtonPinYinSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.Controls.Contains(inputBoxPinYinSingers) && inputBoxPinYinSingers.Text.Length > 0)
|
||||
{
|
||||
inputBoxPinYinSingers.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeCloseButtonPinYinSingers()
|
||||
{
|
||||
var data = LoadConfigData();
|
||||
closeButtonPinYinCoords = LoadSpecialButtonCoordinates(data, "SpecialButtonCoordinates", "closeButtonPinYinSingers");
|
||||
var buttonImages = LoadButtonImages(data, "CloseButtonImagesPinYin");
|
||||
|
||||
closeButtonPinYinSingers = CreateSpecialButton(
|
||||
"btnClosePinYinSingers",
|
||||
closeButtonPinYinCoords,
|
||||
buttonImages.normal,
|
||||
buttonImages.mouseOver,
|
||||
buttonImages.mouseDown,
|
||||
CloseButtonPinYinSingers_Click
|
||||
);
|
||||
}
|
||||
|
||||
private void CloseButtonPinYinSingers_Click(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxPinYinSingers.Visible = false;
|
||||
SetPinYinSingersAndButtonsVisibility(false);
|
||||
}
|
||||
|
||||
private void InitializeInputBoxPinYinSingers()
|
||||
{
|
||||
try
|
||||
{
|
||||
var parser = new FileIniDataParser();
|
||||
parser.Parser.Configuration.AssigmentSpacer = "";
|
||||
parser.Parser.Configuration.CommentString = "#";
|
||||
parser.Parser.Configuration.CaseInsensitive = true;
|
||||
|
||||
|
||||
IniData data;
|
||||
using (var reader = new StreamReader("config.ini", System.Text.Encoding.UTF8))
|
||||
{
|
||||
data = parser.ReadData(reader);
|
||||
}
|
||||
|
||||
int x = int.Parse(data["InputBoxPinYinSingers"]["X"]);
|
||||
int y = int.Parse(data["InputBoxPinYinSingers"]["Y"]);
|
||||
int width = int.Parse(data["InputBoxPinYinSingers"]["Width"]);
|
||||
int height = int.Parse(data["InputBoxPinYinSingers"]["Height"]);
|
||||
string fontName = data["InputBoxPinYinSingers"]["FontName"];
|
||||
float fontSize = float.Parse(data["InputBoxPinYinSingers"]["FontSize"]);
|
||||
FontStyle fontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), data["InputBoxPinYinSingers"]["FontStyle"]);
|
||||
Color foreColor = Color.FromName(data["InputBoxPinYinSingers"]["ForeColor"]);
|
||||
|
||||
inputBoxPinYinSingers = new RichTextBox
|
||||
{
|
||||
Visible = false,
|
||||
Name = "inputBoxPinYinSingers",
|
||||
ForeColor = foreColor,
|
||||
Font = new Font(fontName, fontSize / 900 * Screen.PrimaryScreen.Bounds.Height, fontStyle)
|
||||
};
|
||||
|
||||
ResizeAndPositionControl(inputBoxPinYinSingers, x, y, width, height);
|
||||
|
||||
inputBoxPinYinSingers.TextChanged += (sender, e) =>
|
||||
{
|
||||
string searchText = inputBoxPinYinSingers.Text;
|
||||
var searchResults = allSongs.Where(song => song.ArtistAPinyin.Replace(" ", "").StartsWith(searchText))
|
||||
.Union(allSongs.Where(song => song.ArtistBPinyin.Replace(" ", "").StartsWith(searchText)))
|
||||
.ToList();
|
||||
currentPage = 0;
|
||||
currentSongList = searchResults;
|
||||
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
|
||||
|
||||
};
|
||||
|
||||
this.Controls.Add(inputBoxPinYinSingers);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"An error occurred: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private (int X, int Y, int Width, int Height) pictureBoxPinYinSingerCoords;
|
||||
|
||||
private void LoadPictureBoxPinYinSingerCoordsFromConfig()
|
||||
{
|
||||
var parser = new FileIniDataParser();
|
||||
IniData data = parser.ReadFile("config.ini");
|
||||
|
||||
var coords = data["PictureBoxPinYinSingers"];
|
||||
pictureBoxPinYinSingerCoords = (
|
||||
int.Parse(coords["X"]),
|
||||
int.Parse(coords["Y"]),
|
||||
int.Parse(coords["Width"]),
|
||||
int.Parse(coords["Height"])
|
||||
);
|
||||
}
|
||||
|
||||
private void ShowImageOnPictureBoxPinYinSingers(string imagePath)
|
||||
{
|
||||
|
||||
LoadPictureBoxPinYinSingerCoordsFromConfig();
|
||||
|
||||
|
||||
Bitmap originalImage = new Bitmap(imagePath);
|
||||
|
||||
|
||||
Rectangle displayArea = new Rectangle(pictureBoxPinYinSingerCoords.X, pictureBoxPinYinSingerCoords.Y, pictureBoxPinYinSingerCoords.Width, pictureBoxPinYinSingerCoords.Height);
|
||||
|
||||
|
||||
pictureBoxPinYinSingers.Image = originalImage;
|
||||
|
||||
|
||||
ResizeAndPositionPictureBox(pictureBoxPinYinSingers, displayArea.X, displayArea.Y, displayArea.Width, displayArea.Height);
|
||||
|
||||
pictureBoxPinYinSingers.Visible = true;
|
||||
}
|
||||
|
||||
private void SetPinYinSingersAndButtonsVisibility(bool isVisible)
|
||||
{
|
||||
System.Action action = () =>
|
||||
{
|
||||
SuspendLayout();
|
||||
|
||||
if (pictureBoxPinYinSingers == null)
|
||||
{
|
||||
Console.WriteLine("pictureBoxPinYinSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
pictureBoxPinYinSingers.Visible = isVisible;
|
||||
if (isVisible) pictureBoxPinYinSingers.BringToFront();
|
||||
pictureBoxPinYinSingers.Refresh();
|
||||
}
|
||||
|
||||
if (letterButtonsForPinYinSingers == null)
|
||||
{
|
||||
Console.WriteLine("letterButtonsForPinYinSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var button in letterButtonsForPinYinSingers)
|
||||
{
|
||||
if (button == null)
|
||||
{
|
||||
Console.WriteLine("A button in letterButtonsForPinYinSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
button.Visible = isVisible;
|
||||
if (isVisible) button.BringToFront();
|
||||
button.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modifyButtonPinYinSingers == null)
|
||||
{
|
||||
Console.WriteLine("modifyButtonPinYinSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
modifyButtonPinYinSingers.Visible = isVisible;
|
||||
if (isVisible) modifyButtonPinYinSingers.BringToFront();
|
||||
modifyButtonPinYinSingers.Refresh();
|
||||
}
|
||||
|
||||
if (clearButtonPinYinSingers == null)
|
||||
{
|
||||
Console.WriteLine("clearButtonPinYinSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
clearButtonPinYinSingers.Visible = isVisible;
|
||||
if (isVisible) clearButtonPinYinSingers.BringToFront();
|
||||
clearButtonPinYinSingers.Refresh();
|
||||
}
|
||||
|
||||
if (closeButtonPinYinSingers == null)
|
||||
{
|
||||
Console.WriteLine("closeButtonPinYinSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
closeButtonPinYinSingers.Visible = isVisible;
|
||||
if (isVisible) closeButtonPinYinSingers.BringToFront();
|
||||
closeButtonPinYinSingers.Refresh();
|
||||
}
|
||||
|
||||
if (inputBoxPinYinSingers == null)
|
||||
{
|
||||
Console.WriteLine("inputBoxPinYinSingers is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
inputBoxPinYinSingers.Visible = isVisible;
|
||||
if (isVisible) inputBoxPinYinSingers.BringToFront();
|
||||
inputBoxPinYinSingers.Refresh();
|
||||
}
|
||||
|
||||
ResumeLayout();
|
||||
PerformLayout();
|
||||
};
|
||||
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(action);
|
||||
}
|
||||
else
|
||||
{
|
||||
action();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Ink;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private void InitializeButtonsForPictureBoxArtistSearch()
|
||||
{
|
||||
|
||||
int[,] coords = new int[,]
|
||||
{
|
||||
{651, 292, 752, 400},
|
||||
{760, 292, 861, 400},
|
||||
{869, 292, 972, 399},
|
||||
{652, 401, 752, 502},
|
||||
{760, 401, 861, 504},
|
||||
{869, 398, 972, 502},
|
||||
{651, 502, 753, 607},
|
||||
{759, 504, 863, 607},
|
||||
{869, 503, 973, 608},
|
||||
{981, 501, 1083, 609}
|
||||
};
|
||||
|
||||
int screenW = Screen.PrimaryScreen.Bounds.Width;
|
||||
int screenH = Screen.PrimaryScreen.Bounds.Height;
|
||||
|
||||
|
||||
float widthRatio = screenW / (float)1440;
|
||||
float heightRatio = screenH / (float)900;
|
||||
|
||||
numberButtonsArtistSearch = new Button[10];
|
||||
|
||||
for (int i = 0; i < numberButtonsArtistSearch.Length; i++)
|
||||
{
|
||||
numberButtonsArtistSearch[i] = new Button();
|
||||
|
||||
|
||||
ConfigureButton(
|
||||
numberButtonsArtistSearch[i],
|
||||
coords[i, 0],
|
||||
coords[i, 1],
|
||||
coords[i, 2] - coords[i, 0],
|
||||
coords[i, 3] - coords[i, 1],
|
||||
|
||||
resizedNormalStateImageFor6_1,
|
||||
resizedMouseOverImageFor6_1,
|
||||
resizedMouseDownImageFor6_1,
|
||||
null
|
||||
);
|
||||
|
||||
int newXForArtistSearch = (int)(((numberButtonsArtistSearch[i].Location.X / widthRatio) + offsetXArtistSearch) * widthRatio);
|
||||
int newYForArtistSearch = (int)(((numberButtonsArtistSearch[i].Location.Y / heightRatio) + offsetXArtistSearch) * heightRatio);
|
||||
numberButtonsArtistSearch[i].Location = new Point(newXForArtistSearch, newYForArtistSearch);
|
||||
|
||||
|
||||
numberButtonsArtistSearch[i].Name = "NumberButtonArtistSearch" + i;
|
||||
|
||||
numberButtonsArtistSearch[i].Tag = (i + 1).ToString();
|
||||
if (i == 9)
|
||||
{
|
||||
numberButtonsArtistSearch[i].Name = "NumberButtonArtistSearch0";
|
||||
numberButtonsArtistSearch[i].Tag = "0";
|
||||
}
|
||||
|
||||
|
||||
numberButtonsArtistSearch[i].Click += ArtistButton_Click;
|
||||
|
||||
|
||||
this.Controls.Add(numberButtonsArtistSearch[i]);
|
||||
}
|
||||
|
||||
|
||||
modifyButtonArtistSearch = new Button {
|
||||
Name = "ModifyButtonArtistSearch",
|
||||
Tag = "Modify",
|
||||
Visible = false
|
||||
};
|
||||
|
||||
ConfigureButton(modifyButtonArtistSearch, 978, 292, 1081 - 978, 397 - 292, resizedNormalStateImageFor6_1, resizedMouseOverImageFor6_1, resizedMouseDownImageFor6_1, ModifyButtonArtist_Click);
|
||||
int newX = (int)(((modifyButtonArtistSearch.Location.X / widthRatio) + offsetXArtistSearch) * widthRatio);
|
||||
int newY = (int)(((modifyButtonArtistSearch.Location.Y / widthRatio) + offsetYArtistSearch) * heightRatio);
|
||||
modifyButtonArtistSearch.Location = new Point(newX, newY);
|
||||
this.Controls.Add(modifyButtonArtistSearch);
|
||||
|
||||
|
||||
closeButtonArtistSearch = new Button {
|
||||
Name = "CloseButtonArtistSearch",
|
||||
Tag = "Close",
|
||||
Visible = false
|
||||
};
|
||||
|
||||
ConfigureButton(closeButtonArtistSearch, 982, 147, 1082 - 982, 250 - 147, resizedNormalStateImageFor6_1, resizedMouseOverImageFor6_1, resizedMouseDownImageFor6_1, CloseButtonArtistSearch_Click);
|
||||
newX = (int)(((closeButtonArtistSearch.Location.X / widthRatio) + offsetXArtistSearch) * widthRatio);
|
||||
newY = (int)(((closeButtonArtistSearch.Location.Y / widthRatio) + offsetYArtistSearch) * heightRatio);
|
||||
closeButtonArtistSearch.Location = new Point(newX, newY);
|
||||
this.Controls.Add(closeButtonArtistSearch);
|
||||
|
||||
inputBoxArtistSearch = new RichTextBox();
|
||||
inputBoxArtistSearch.Name = "inputBoxArtistSearch";
|
||||
ResizeAndPositionControl(inputBoxArtistSearch, 645 + offsetXArtistSearch, 197 + offsetXArtistSearch, 986 - 645, 281 - 197);
|
||||
inputBoxArtistSearch.ForeColor = Color.Black;
|
||||
inputBoxArtistSearch.Font = new Font("細明體", (float)26 / 900 * Screen.PrimaryScreen.Bounds.Height, FontStyle.Regular);
|
||||
|
||||
inputBoxArtistSearch.TextChanged += (sender, e) =>
|
||||
{
|
||||
string searchText = inputBoxArtistSearch.Text;
|
||||
int targetLength = 0;
|
||||
|
||||
|
||||
if (int.TryParse(searchText, out targetLength))
|
||||
{
|
||||
|
||||
var searchResults = allArtists.Where(artist => artist.Name.Replace(" ", "").Length == targetLength).ToList();
|
||||
|
||||
currentPage = 0;
|
||||
currentArtistList = searchResults;
|
||||
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
|
||||
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSingers(currentArtistList);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
currentArtistList.Clear();
|
||||
}
|
||||
};
|
||||
|
||||
this.Controls.Add(inputBoxArtistSearch);
|
||||
}
|
||||
|
||||
|
||||
private void ArtistButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
var button = sender as Button;
|
||||
if (button != null && button.Tag != null)
|
||||
{
|
||||
inputBoxArtistSearch.Text += button.Tag.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void WordCountSearchButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
zhuyinSearchButton.BackgroundImage = zhuyinSearchNormalBackground;
|
||||
englishSearchButton.BackgroundImage = englishSearchNormalBackground;
|
||||
pinyinSearchButton.BackgroundImage = pinyinSearchNormalBackground;
|
||||
wordCountSearchButton.BackgroundImage = wordCountSearchActiveBackground;
|
||||
handWritingSearchButton.BackgroundImage = handWritingSearchNormalBackground;
|
||||
|
||||
|
||||
bool shouldBeVisible = !pictureBoxArtistSearch.Visible;
|
||||
|
||||
|
||||
if (shouldBeVisible)
|
||||
{
|
||||
ShowImageOnPictureBoxArtistSearch(Path.Combine(Application.StartupPath, @"themes\superstar\6-1.png"));
|
||||
}
|
||||
|
||||
SetEnglishSingersAndButtonsVisibility(false);
|
||||
SetPinYinSingersAndButtonsVisibility(false);
|
||||
SetHandWritingForSingersAndButtonsVisibility(false);
|
||||
SetZhuYinSingersAndButtonsVisibility(false);
|
||||
SetPictureBoxArtistSearchAndButtonsVisibility(shouldBeVisible);
|
||||
pictureBoxArtistSearch.Visible = shouldBeVisible;
|
||||
}
|
||||
|
||||
private void CloseButtonArtistSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
SetPictureBoxArtistSearchAndButtonsVisibility(false);
|
||||
}
|
||||
}
|
||||
}
|
113
PrimaryFormParts/SingerSearch/PrimaryForm.SingerSearch.cs
Normal file
113
PrimaryFormParts/SingerSearch/PrimaryForm.SingerSearch.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public partial class PrimaryForm
|
||||
{
|
||||
private Button zhuyinSearchButton;
|
||||
private Bitmap zhuyinSearchNormalBackground;
|
||||
private Bitmap zhuyinSearchActiveBackground;
|
||||
private Button englishSearchButton;
|
||||
private Bitmap englishSearchNormalBackground;
|
||||
private Bitmap englishSearchActiveBackground;
|
||||
private Button pinyinSearchButton;
|
||||
private Bitmap pinyinSearchNormalBackground;
|
||||
private Bitmap pinyinSearchActiveBackground;
|
||||
|
||||
|
||||
|
||||
private Button wordCountSearchButton;
|
||||
private Bitmap wordCountSearchNormalBackground;
|
||||
private Bitmap wordCountSearchActiveBackground;
|
||||
private Button handWritingSearchButton;
|
||||
private Bitmap handWritingSearchNormalBackground;
|
||||
private Bitmap handWritingSearchActiveBackground;
|
||||
|
||||
private void SingerSearchButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
newSongAlertButton.BackgroundImage = newSongAlertNormalBackground;
|
||||
hotPlayButton.BackgroundImage = hotPlayNormalBackground;
|
||||
singerSearchButton.BackgroundImage = singerSearchActiveBackground;
|
||||
songSearchButton.BackgroundImage = songSearchNormalBackground;
|
||||
languageSearchButton.BackgroundImage = languageSearchNormalBackground;
|
||||
groupSearchButton.BackgroundImage = groupSearchNormalBackground;
|
||||
categorySearchButton.BackgroundImage = categorySearchNormalBackground;
|
||||
orderedSongsButton.BackgroundImage = orderedSongsNormalBackground;
|
||||
myFavoritesButton.BackgroundImage = myFavoritesNormalBackground;
|
||||
promotionsButton.BackgroundImage = promotionsNormalBackground;
|
||||
deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground;
|
||||
isOnOrderedSongsPage = false;
|
||||
|
||||
|
||||
SetHotSongButtonsVisibility(false);
|
||||
SetNewSongButtonsVisibility(false);
|
||||
SetSongSearchButtonsVisibility(false);
|
||||
SetPictureBoxLanguageButtonsVisibility(false);
|
||||
SetGroupButtonsVisibility(false);
|
||||
SetPictureBoxCategoryAndButtonsVisibility(false);
|
||||
SetZhuYinSingersAndButtonsVisibility(false);
|
||||
SetZhuYinSongsAndButtonsVisibility(false);
|
||||
SetEnglishSingersAndButtonsVisibility(false);
|
||||
SetEnglishSongsAndButtonsVisibility(false);
|
||||
SetPinYinSingersAndButtonsVisibility(false);
|
||||
SetPinYinSongsAndButtonsVisibility(false);
|
||||
SetPictureBoxToggleLightAndButtonsVisibility(false);
|
||||
SetPictureBoxSceneSoundEffectsAndButtonsVisibility(false);
|
||||
SetSingerSearchButtonsVisibility(true);
|
||||
|
||||
|
||||
if (pictureBoxQRCode != null)
|
||||
{
|
||||
pictureBoxQRCode.Visible = false;
|
||||
closeQRCodeButton.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSingerSearchButtonsVisibility(bool isVisible)
|
||||
{
|
||||
Button[] singerSearchButtons = { zhuyinSearchButton, englishSearchButton, pinyinSearchButton, wordCountSearchButton, handWritingSearchButton };
|
||||
|
||||
foreach (var button in singerSearchButtons)
|
||||
{
|
||||
button.Visible = isVisible;
|
||||
if (isVisible)
|
||||
{
|
||||
button.BringToFront();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeButtonsForSingerSearch()
|
||||
{
|
||||
|
||||
InitializeSearchButton(ref zhuyinSearchButton, "zhuyinSearchButton", 1214, 230, 209, 59, ref zhuyinSearchNormalBackground, ref zhuyinSearchActiveBackground, normalStateImageArtistQuery, mouseDownImageArtistQuery, ZhuyinSearchSingersButton_Click);
|
||||
|
||||
|
||||
InitializeSearchButton(ref englishSearchButton, "englishSearchButton", 1214, 293, 209, 58, ref englishSearchNormalBackground, ref englishSearchActiveBackground, normalStateImageArtistQuery, mouseDownImageArtistQuery, EnglishSearchSingersButton_Click);
|
||||
|
||||
|
||||
InitializeSearchButton(ref pinyinSearchButton, "pinyinSearchButton", 1214, 356, 209, 58, ref pinyinSearchNormalBackground, ref pinyinSearchActiveBackground, normalStateImageArtistQuery, mouseDownImageArtistQuery, PinyinSingerSearchButton_Click);
|
||||
|
||||
InitializeSearchButton(ref wordCountSearchButton, "strokeCountSearchButton", 1214, 418, 209, 59, ref wordCountSearchNormalBackground, ref wordCountSearchActiveBackground, normalStateImageArtistQuery, mouseDownImageArtistQuery, WordCountSearchButton_Click);
|
||||
|
||||
InitializeSearchButton(ref handWritingSearchButton, "handWritingSearchButton", 1214, 481, 209, 59, ref handWritingSearchNormalBackground, ref handWritingSearchActiveBackground, normalStateImageArtistQuery, mouseDownImageArtistQuery, HandWritingSearchButtonForSingers_Click);
|
||||
}
|
||||
|
||||
private void InitializeSearchButton(ref Button button, string name, int x, int y, int width, int height, ref Bitmap normalBackground, ref Bitmap activeBackground, Bitmap normalImage, Bitmap activeImage, EventHandler clickEventHandler)
|
||||
{
|
||||
button = new Button { Text = "", Visible = true, Name = name };
|
||||
ResizeAndPositionButton(button, x, y, width, height);
|
||||
Rectangle buttonCropArea = new Rectangle(x, y, width, height);
|
||||
normalBackground = normalImage.Clone(buttonCropArea, normalImage.PixelFormat);
|
||||
activeBackground = activeImage.Clone(buttonCropArea, activeImage.PixelFormat);
|
||||
button.BackgroundImage = normalBackground;
|
||||
button.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
button.FlatStyle = FlatStyle.Flat;
|
||||
button.FlatAppearance.BorderSize = 0;
|
||||
button.Click += clickEventHandler;
|
||||
this.Controls.Add(button);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user