2509011747

This commit is contained in:
jasonchenwork 2025-09-01 17:48:16 +08:00
parent 9d5ab28d96
commit 5cb15a9422
3 changed files with 100 additions and 321 deletions

View File

@ -2,7 +2,6 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using NAudio.Wave; using NAudio.Wave;
using Microsoft.Ink; using Microsoft.Ink;
using System.Text.RegularExpressions;
using DBObj; using DBObj;
using OverlayFormObj; using OverlayFormObj;
using Timer = System.Windows.Forms.Timer; using Timer = System.Windows.Forms.Timer;
@ -10,10 +9,8 @@ using IniParser.Model;
using IniParser; using IniParser;
using System.Text; using System.Text;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks;
using LibVLCSharp.WinForms; using LibVLCSharp.WinForms;
namespace DualScreenDemo namespace DualScreenDemo
{ {
public partial class PrimaryForm : Form public partial class PrimaryForm : Form
@ -80,62 +77,19 @@ namespace DualScreenDemo
private Button btnSimplifiedChinese; private Button btnSimplifiedChinese;
private Button btnTraditionalChinese; private Button btnTraditionalChinese;
private Button exitButton; private Button exitButton;
//private static Bitmap normalStateImage;
//private static Bitmap mouseOverImage;
//private static Bitmap mouseDownImage;
//private static Bitmap resizedNormalStateImage;
//private static Bitmap resizedMouseOverImage;
//private static Bitmap resizedMouseDownImage;
//private static Bitmap normalStateImageNewSongAlert;
//private static Bitmap mouseOverImageNewSongAlert;
//private static Bitmap mouseDownImageNewSongAlert;
//private static Bitmap resizedNormalStateImageForNewSongAlert;
//private static Bitmap resizedMouseOverImageForNewSongAlert;
//private static Bitmap resizedMouseDownImageForNewSongAlert;
//private static Bitmap normalStateImageArtistQuery;
//private static Bitmap mouseOverImageArtistQuery;
//private static Bitmap mouseDownImageArtistQuery;
//private static Bitmap resizedNormalStateImageForArtistQuery;
//private static Bitmap resizedMouseOverImageForArtistQuery;
//private static Bitmap resizedMouseDownImageForArtistQuery;
//private static Bitmap normalStateImageSongQuery;
//private static Bitmap mouseOverImageSongQuery;
//private static Bitmap mouseDownImageSongQuery;
//private static Bitmap resizedNormalStateImageForSongQuery;
//private static Bitmap resizedMouseOverImageForSongQuery;
//private static Bitmap resizedMouseDownImageForSongQuery;
//private static Bitmap normalStateImageLanguageQuery;
//private static Bitmap mouseOverImageLanguageQuery;
//private static Bitmap mouseDownImageLanguageQuery;
//private static Bitmap resizedNormalStateImageForLanguageQuery;
//private static Bitmap resizedMouseOverImageForLanguageQuery;
//private static Bitmap resizedMouseDownImageForLanguageQuery;
//private static Bitmap normalStateImageCategoryQuery;
//private static Bitmap mouseOverImageCategoryQuery;
//private static Bitmap mouseDownImageCategoryQuery;
//private static Bitmap resizedNormalStateImageForCategoryQuery;
//private static Bitmap resizedMouseOverImageForCategoryQuery;
//private static Bitmap resizedMouseDownImageForCategoryQuery;
//private static Bitmap normalStateImageForPromotionsAndMenu;
//private static Bitmap resizedNormalStateImageForPromotionsAndMenu;
//private static Bitmap normalStateImageForSyncScreen;
//private static Bitmap resizedNormalStateImageForSyncScreen;
//private static Bitmap normalStateImageForSceneSoundEffects;
//private static Bitmap resizedNormalStateImageForSceneSoundEffects;
//private static Bitmap normalStateImageForLightControl;
//private static Bitmap resizedNormalStateImageForLightControl;
public VideoPlayerForm videoPlayerForm; public VideoPlayerForm videoPlayerForm;
public List<Artist> currentArtistList; public List<Artist> currentArtistList;
public MultiPagePanel multiPagePanel; public MultiPagePanel multiPagePanel;
private List<Label> songLabels = new List<Label>(); private List<Label> songLabels = new List<Label>();
private int _currentPage { get; set; } = 0; private int _currentPage { get; set; } = 0;
private int _totalPages { get; set; } private int _totalPages { get; set; }
public VideoView videoView0 = new VideoView() { Dock = DockStyle.Fill}; public VideoView videoView0 = new VideoView() { Dock = DockStyle.Fill };
public VideoView videoView1 = new VideoView() { Dock = DockStyle.Fill}; public VideoView videoView1 = new VideoView() { Dock = DockStyle.Fill };
// string serverPath = Utils.Env.GetPath("", ""); // string serverPath = Utils.Env.GetPath("", "");
string serverPath = Application.StartupPath; string serverPath = Application.StartupPath;
public List<Control> _StartupcontrolsTop= new List<Control>();
public List<Control> _StartupcontrolsBottom= new List<Control>();
//async Task<Bitmap> GetBitmapFromUriAsync(Uri uri) //async Task<Bitmap> GetBitmapFromUriAsync(Uri uri)
//{ //{
// using HttpClient client = new HttpClient(); // using HttpClient client = new HttpClient();
@ -182,40 +136,27 @@ namespace DualScreenDemo
public const int itemsPerPage = 16; public const int itemsPerPage = 16;
private WaveInEvent waveIn; private WaveInEvent waveIn;
private WaveFileWriter waveWriter; private WaveFileWriter waveWriter;
private const int PanelStartLeft = 25; // 修改為實際需要的左邊距 private const int PanelStartLeft = 25; // 修改為實際需要的左邊距
private const int PanelStartTop = 227; // 修改為實際需要的上邊距 private const int PanelStartTop = 227; // 修改為實際需要的上邊距
private const int PanelEndLeft = 1175; // 修改為實際需要的右邊界 private const int PanelEndLeft = 1175; // 修改為實際需要的右邊界
private const int PanelEndTop = 739; // 修改為實際需要的下邊界 private const int PanelEndTop = 739; // 修改為實際需要的下邊界
private Timer lightControlTimer; private Timer lightControlTimer;
private SequenceManager sequenceManager = new SequenceManager(); private SequenceManager sequenceManager = new SequenceManager();
private PictureBox buttonMiddle; private PictureBox buttonMiddle;
private PictureBox buttonTopRight; private PictureBox buttonTopRight;
private PictureBox buttonTopLeft; private PictureBox buttonTopLeft;
private PictureBox buttonThanks; private PictureBox buttonThanks;
private Dictionary<Control, (Point Location, bool Visible)> initialControlStates = new Dictionary<Control, (Point Location, bool Visible)>(); private Dictionary<Control, (Point Location, bool Visible)> initialControlStates = new Dictionary<Control, (Point Location, bool Visible)>();
private Panel sendOffPanel; private Panel sendOffPanel;
//private static Bitmap normalStateImageHotSong;
//private static Bitmap mouseDownImageHotSong;
//private static Bitmap resizedNormalStateImageForHotSong;
//private static Bitmap resizedMouseDownImageForHotSong;
private PictureBox serviceBellPictureBox; // 添加为类成员变量 private PictureBox serviceBellPictureBox; // 添加为类成员变量
private Timer autoRefreshTimer; private Timer autoRefreshTimer;
private Timer timerCountdown; private Timer timerCountdown;
string Rtime; string Rtime;
bool test = false; bool Gaintest = true;
//private Label pageNumberLabel; // 添加頁碼標籤 //private Label pageNumberLabel; // 添加頁碼標籤
public PrimaryForm() public PrimaryForm()
{ {
Instance = this; Instance = this;
// 添加 DPI 感知支持 // 添加 DPI 感知支持
if (Environment.OSVersion.Version.Major >= 6) if (Environment.OSVersion.Version.Major >= 6)
{ {
@ -241,7 +182,6 @@ namespace DualScreenDemo
InitializeRecording(); InitializeRecording();
InitializeMediaPlayer(); InitializeMediaPlayer();
//LoadImages();
InitializeFormAndControls(); InitializeFormAndControls();
InitializeMultiPagePanel(); InitializeMultiPagePanel();
OverlayQRCodeOnImage(HttpServer.randomFolderPath); OverlayQRCodeOnImage(HttpServer.randomFolderPath);
@ -340,7 +280,7 @@ namespace DualScreenDemo
// 設定繪製文字的位置 (X=500, Y=30) // 設定繪製文字的位置 (X=500, Y=30)
PointF point_PCName = new PointF(450 * scaleX, 30 * scaleY); PointF point_PCName = new PointF(450 * scaleX, 30 * scaleY);
PointF point_PageNumber = new PointF(1390 * scaleX, 30 * scaleY); PointF point_PageNumber = new PointF(1390 * scaleX, 30 * scaleY);
PointF point_verSion = new PointF(1800 * scaleX-10, 30 * scaleY); PointF point_verSion = new PointF(1800 * scaleX - 10, 30 * scaleY);
// 繪製文字: // 繪製文字:
// `DrawString(要繪製的文字, 字型, 畫刷, 位置)` // `DrawString(要繪製的文字, 字型, 畫刷, 位置)`
e.Graphics.DrawString(displayName, font, brush, point_PCName); e.Graphics.DrawString(displayName, font, brush, point_PCName);
@ -591,56 +531,28 @@ namespace DualScreenDemo
pictureBox2.BringToFront(); pictureBox2.BringToFront();
pictureBox3.BringToFront(); pictureBox3.BringToFront();
pictureBox4.BringToFront(); pictureBox4.BringToFront();
pictureBoxQRCode.BringToFront();
pictureBoxZhuYinSingers.BringToFront();
pictureBoxZhuYinSongs.BringToFront();
pictureBoxEnglishSingers.BringToFront();
pictureBoxEnglishSongs.BringToFront();
pictureBoxWordCountSongs.BringToFront();
FavoritePictureBox.BringToFront();
promotionsPictureBox.BringToFront(); promotionsPictureBox.BringToFront();
pictureBoxToggleLight.BringToFront();
overlayPanel.BringToFront(); overlayPanel.BringToFront();
VodScreenPictureBox.BringToFront(); VodScreenPictureBox.BringToFront();
newSongAlertButton.BringToFront();
hotPlayButton.BringToFront();
singerSearchButton.BringToFront();
songSearchButton.BringToFront();
languageSearchButton.BringToFront();
groupSearchButton.BringToFront();
categorySearchButton.BringToFront();
serviceBellButton.BringToFront();
orderedSongsButton.BringToFront();
myFavoritesButton.BringToFront();
deliciousFoodButton.BringToFront();
promotionsButton.BringToFront();
mobileSongRequestButton.BringToFront(); mobileSongRequestButton.BringToFront();
qieGeButton.BringToFront();
musicUpButton.BringToFront();
musicDownButton.BringToFront(); Control[] controlsTopBtns = { newSongAlertButton,hotPlayButton,singerSearchButton,songSearchButton,
micUpButton.BringToFront(); languageSearchButton,groupSearchButton,categorySearchButton,serviceBellButton,orderedSongsButton,
micDownButton.BringToFront(); myFavoritesButton,deliciousFoodButton,promotionsButton};
originalSongButton.BringToFront();
replayButton.BringToFront(); _StartupcontrolsTop.AddRange(controlsTopBtns);
pauseButton.BringToFront();
playButton.BringToFront(); ToFront(_StartupcontrolsTop);
muteButton.BringToFront();
maleKeyButton.BringToFront(); Control[] controlsBottomBtns = {qieGeButton,musicUpButton,musicUpButton,musicDownButton,micUpButton,micDownButton,
femaleKeyButton.BringToFront(); originalSongButton,replayButton,pauseButton,playButton,muteButton,maleKeyButton,femaleKeyButton,standardKeyButton,
standardKeyButton.BringToFront(); soundEffectButton,pitchUpButton,pitchDownButton,syncScreenButton,toggleLightButton,btnPreviousPage,btnReturn,btnNextPage,
soundEffectButton.BringToFront(); btnApplause,btnSimplifiedChinese,btnTraditionalChinese};
pitchUpButton.BringToFront();
pitchDownButton.BringToFront(); _StartupcontrolsBottom.AddRange(controlsBottomBtns);
syncScreenButton.BringToFront();
toggleLightButton.BringToFront(); ToFront(_StartupcontrolsBottom);
btnPreviousPage.BringToFront();
btnReturn.BringToFront();
btnNextPage.BringToFront();
btnApplause.BringToFront();
btnSimplifiedChinese.BringToFront();
btnTraditionalChinese.BringToFront();
exitButton.BringToFront();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -863,7 +775,6 @@ namespace DualScreenDemo
Name = "overlayPanel", Name = "overlayPanel",
Dock = DockStyle.Fill, Dock = DockStyle.Fill,
BackColor = Color.FromArgb(128, 0, 0, 0), BackColor = Color.FromArgb(128, 0, 0, 0),
Visible = false Visible = false
}; };
@ -911,23 +822,6 @@ namespace DualScreenDemo
this.Controls.Add(pictureBoxSceneSoundEffects); this.Controls.Add(pictureBoxSceneSoundEffects);
} }
private void PhoneticButton_Click(object sender, EventArgs e)
{
var button = sender as Button;
if (button != null && button.Tag != null)
{
if (inputBoxZhuYinSingers.Visible)
{
inputBoxZhuYinSingers.Text += button.Tag.ToString();
}
else if (inputBoxZhuYinSongs.Visible)
{
inputBoxZhuYinSongs.Text += button.Tag.ToString();
}
}
}
private void LightControlTimer_Tick(object sender, EventArgs e) private void LightControlTimer_Tick(object sender, EventArgs e)
{ {
if (lightControlTimer.Tag != null) if (lightControlTimer.Tag != null)
@ -1017,14 +911,8 @@ namespace DualScreenDemo
Bitmap normalStateImage, Bitmap mouseOverImage, Bitmap mouseDownImage, Bitmap normalStateImage, Bitmap mouseOverImage, Bitmap mouseDownImage,
EventHandler clickEventHandler) EventHandler clickEventHandler)
{ {
ResizeAndPositionButton(button, posX, posY, width, height); ResizeAndPositionButton(button, posX, posY, width, height);
Rectangle cropArea = new Rectangle(button.Location.X, button.Location.Y, button.Size.Width, button.Size.Height);
//button.BackgroundImage = normalStateImage.Clone(cropArea, normalStateImage.PixelFormat);
button.BackgroundImage = normalStateImage; button.BackgroundImage = normalStateImage;
button.BackgroundImageLayout = ImageLayout.Stretch; button.BackgroundImageLayout = ImageLayout.Stretch;
button.FlatStyle = FlatStyle.Flat; button.FlatStyle = FlatStyle.Flat;
@ -1032,12 +920,6 @@ namespace DualScreenDemo
button.FlatAppearance.MouseDownBackColor = Color.Transparent; button.FlatAppearance.MouseDownBackColor = Color.Transparent;
button.FlatAppearance.MouseOverBackColor = Color.Transparent; button.FlatAppearance.MouseOverBackColor = Color.Transparent;
//button.MouseEnter += (sender, e) => button.BackgroundImage = mouseOverImage.Clone(cropArea, mouseOverImage.PixelFormat);
//button.MouseLeave += (sender, e) => button.BackgroundImage = normalStateImage.Clone(cropArea, normalStateImage.PixelFormat);
//button.MouseDown += (sender, e) => button.BackgroundImage = mouseDownImage.Clone(cropArea, mouseDownImage.PixelFormat);
//button.MouseUp += (sender, e) => button.BackgroundImage = normalStateImage.Clone(cropArea, normalStateImage.PixelFormat);
button.MouseEnter += (sender, e) => button.BackgroundImage = mouseOverImage; button.MouseEnter += (sender, e) => button.BackgroundImage = mouseOverImage;
button.MouseLeave += (sender, e) => button.BackgroundImage = normalStateImage; button.MouseLeave += (sender, e) => button.BackgroundImage = normalStateImage;
button.MouseDown += (sender, e) => button.BackgroundImage = mouseDownImage; button.MouseDown += (sender, e) => button.BackgroundImage = mouseDownImage;
@ -1146,15 +1028,16 @@ namespace DualScreenDemo
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MusicLowActive"])), new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MusicLowActive"])),
(sender, e) => { OverlayForm.MainForm.ShowTopRightLabelTime("音量 ↓", "a2 b4 a4"); }); (sender, e) => { OverlayForm.MainForm.ShowTopRightLabelTime("音量 ↓", "a2 b4 a4"); });
if (test) if (Gaintest)
{ {
musicUpButton.Click -= (sender, e) => { OverlayForm.MainForm.ShowTopRightLabelTime("音量 ↑", "a2 b3 a4"); };
musicUpButton.Click += (sender, e) => musicUpButton.Click += (sender, e) =>
{ {
videoPlayerForm.SetVolume(videoPlayerForm.GetVolume() + 5); videoPlayerForm.SetVolume(videoPlayerForm.GetVolume() + 5);
int vol = videoPlayerForm.GetVolume() - 100; int vol = videoPlayerForm.GetVolume() - 100;
OverlayForm.MainForm.ShowTopRightLabel(vol.ToString(), null); OverlayForm.MainForm.ShowTopRightLabel(vol.ToString(), null);
}; };
musicDownButton.Click -= (sender, e) => { OverlayForm.MainForm.ShowTopRightLabelTime("音量 ↓", "a2 b4 a4"); };
musicDownButton.Click += (sender, e) => musicDownButton.Click += (sender, e) =>
{ {
videoPlayerForm.SetVolume(videoPlayerForm.GetVolume() - 5); videoPlayerForm.SetVolume(videoPlayerForm.GetVolume() - 5);
@ -1453,18 +1336,6 @@ namespace DualScreenDemo
} }
} }
public static void WriteLog(string message)
{
string logFilePath = Path.Combine(Application.StartupPath, "txt", "logfile.txt");
using (StreamWriter sw = new StreamWriter(logFilePath, true))
{
sw.WriteLine(String.Format("{0}: {1}", DateTime.Now, message));
}
}
private void NextPageButton_Click(object sender, EventArgs e) private void NextPageButton_Click(object sender, EventArgs e)
{ {
multiPagePanel.LoadNextPage(); multiPagePanel.LoadNextPage();
@ -1522,126 +1393,7 @@ namespace DualScreenDemo
return destImage; return destImage;
} }
#region LoadImages //複製生成選取區域圖形
//private void LoadImages()
//{
// var data = LoadBtnConfigData();
// string selectedThemePath = ReadSelectedThemePath();
// string basePath = Path.Combine(serverPath, selectedThemePath);
// int targetWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
// int targetHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
// normalStateImage = new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["MainFrameWSubBtn"]));
// resizedNormalStateImage = ResizeImage(normalStateImage, targetWidth, targetHeight);
// mouseOverImage = new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["MainFrameBtnPressed"]));
// resizedMouseOverImage = ResizeImage(mouseOverImage, targetWidth, targetHeight);
// mouseDownImage = new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["MainFrameBtnPressed"]));
// resizedMouseDownImage = ResizeImage(mouseDownImage, targetWidth, targetHeight);
// normalStateImageNewSongAlert = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\1.新歌快報_未按.jpg"));
// resizedNormalStateImageForNewSongAlert = ResizeImage(normalStateImageNewSongAlert, targetWidth, targetHeight);
// mouseOverImageNewSongAlert = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\1.新歌快報_已按.jpg"));
// resizedMouseOverImageForNewSongAlert = ResizeImage(mouseOverImageNewSongAlert, targetWidth, targetHeight);
// mouseDownImageNewSongAlert = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\1.新歌快報_已按.jpg"));
// resizedMouseDownImageForNewSongAlert = ResizeImage(mouseDownImageNewSongAlert, targetWidth, targetHeight);
// normalStateImageArtistQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\3.歌星查詢_未按.jpg"));
// resizedNormalStateImageForArtistQuery = ResizeImage(normalStateImageArtistQuery, targetWidth, targetHeight);
// mouseOverImageArtistQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\3.歌星查詢_已按.jpg"));
// resizedMouseOverImageForArtistQuery = ResizeImage(mouseOverImageArtistQuery, targetWidth, targetHeight);
// mouseDownImageArtistQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\3.歌星查詢_已按.jpg"));
// resizedMouseDownImageForArtistQuery = ResizeImage(mouseDownImageArtistQuery, targetWidth, targetHeight);
// normalStateImageSongQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\4.歌名查詢_未按.jpg"));
// resizedNormalStateImageForSongQuery = ResizeImage(normalStateImageSongQuery, targetWidth, targetHeight);
// mouseOverImageSongQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\4.歌名查詢_已按.jpg"));
// resizedMouseOverImageForSongQuery = ResizeImage(mouseOverImageSongQuery, targetWidth, targetHeight);
// mouseDownImageSongQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\4.歌名查詢_已按.jpg"));
// resizedMouseDownImageForSongQuery = ResizeImage(mouseDownImageSongQuery, targetWidth, targetHeight);
// normalStateImageLanguageQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\5.語別查詢_未按.jpg"));
// resizedNormalStateImageForLanguageQuery = ResizeImage(normalStateImageLanguageQuery, targetWidth, targetHeight);
// mouseOverImageLanguageQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\5.語別查詢_已按.jpg"));
// resizedMouseOverImageForLanguageQuery = ResizeImage(mouseOverImageLanguageQuery, targetWidth, targetHeight);
// mouseDownImageLanguageQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\5.語別查詢_已按.jpg"));
// resizedMouseDownImageForLanguageQuery = ResizeImage(mouseDownImageLanguageQuery, targetWidth, targetHeight);
// normalStateImageCategoryQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\7.類別查詢_未按.jpg"));
// resizedNormalStateImageForCategoryQuery = ResizeImage(normalStateImageCategoryQuery, targetWidth, targetHeight);
// mouseOverImageCategoryQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\7.類別查詢_已按.jpg"));
// resizedMouseOverImageForCategoryQuery = ResizeImage(mouseOverImageCategoryQuery, targetWidth, targetHeight);
// mouseDownImageCategoryQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\7.類別查詢_已按.jpg"));
// resizedMouseDownImageForCategoryQuery = ResizeImage(mouseDownImageCategoryQuery, targetWidth, targetHeight);
// normalStateImageForPromotionsAndMenu = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\555021.jpg"));
// resizedNormalStateImageForPromotionsAndMenu = ResizeImage(normalStateImageForPromotionsAndMenu, targetWidth, targetHeight);
// try
// {
// string imagePath = Path.Combine(serverPath, "themes\\superstar\\主畫面\\選單內介面_同步畫面.jpg");
// if (File.Exists(imagePath))
// {
// normalStateImageForSyncScreen = new Bitmap(imagePath);
// resizedNormalStateImageForSyncScreen = ResizeImage(normalStateImageForSyncScreen, targetWidth, targetHeight);
// Console.WriteLine("Image loaded successfully.");
// }
// else
// {
// Console.WriteLine("Image file does not exist: " + imagePath);
// }
// }
// catch (Exception ex)
// {
// Console.WriteLine("Failed to load image: " + ex.Message);
// }
// normalStateImageForSceneSoundEffects = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\555022.jpg"));
// resizedNormalStateImageForSceneSoundEffects = ResizeImage(normalStateImageForSceneSoundEffects, targetWidth, targetHeight);
// normalStateImageHotSong = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\2.熱門排行_未按.jpg"));
// resizedNormalStateImageForHotSong = ResizeImage(normalStateImageHotSong, targetWidth, targetHeight);
// mouseDownImageHotSong = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\2.熱門排行_已按.jpg"));
// resizedMouseDownImageForHotSong = ResizeImage(mouseDownImageHotSong, targetWidth, targetHeight);
// normalStateImageForLightControl = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\選單內介面_燈光控制.jpg"));
// resizedNormalStateImageForLightControl = ResizeImage(normalStateImageForLightControl, targetWidth, targetHeight);
//}
#endregion
private Bitmap CropImage(Bitmap source, Rectangle section) private Bitmap CropImage(Bitmap source, Rectangle section)
{ {
@ -2302,9 +2054,9 @@ namespace DualScreenDemo
// 已點歌曲錨點 // 已點歌曲錨點
var List = SongList.GetHistory(); var List = SongList.GetHistory();
int index = List.FindIndex(song => song.GetState() == PlayState.Playing); int index = List.FindIndex(song => song.GetState() == PlayState.Playing);
int remainder=List.Count-index; int remainder = List.Count - index;
int pivot2 = index % multiPagePanel.itemsPerPage; int pivot2 = index % multiPagePanel.itemsPerPage;
int pivot = (List.Count -remainder)%multiPagePanel.itemsPerPage; int pivot = (List.Count - remainder) % multiPagePanel.itemsPerPage;
if (index != -1) if (index != -1)
{ {
if (remainder != 0 && index != 0) if (remainder != 0 && index != 0)
@ -2321,7 +2073,7 @@ namespace DualScreenDemo
} }
else if (pivot != 0) else if (pivot != 0)
{ {
int itemsToInsert = multiPagePanel.itemsPerPage - pivot2 ; int itemsToInsert = multiPagePanel.itemsPerPage - pivot2;
for (int i = 0; i < itemsToInsert; i++) for (int i = 0; i < itemsToInsert; i++)
{ {
@ -2335,7 +2087,7 @@ namespace DualScreenDemo
totalPages = (int)Math.Ceiling((double)List.Count / multiPagePanel.itemsPerPage); totalPages = (int)Math.Ceiling((double)List.Count / multiPagePanel.itemsPerPage);
index = List.FindIndex(song => song.GetState() == PlayState.Playing); index = List.FindIndex(song => song.GetState() == PlayState.Playing);
int page = 0; int page = 0;
if ((index+1) > multiPagePanel.itemsPerPage) page = Math.Abs((index+1) / multiPagePanel.itemsPerPage); if ((index + 1) > multiPagePanel.itemsPerPage) page = Math.Abs((index + 1) / multiPagePanel.itemsPerPage);
SetHotSongButtonsVisibility(false); SetHotSongButtonsVisibility(false);
SetNewSongButtonsVisibility(false); SetNewSongButtonsVisibility(false);
@ -2359,7 +2111,7 @@ namespace DualScreenDemo
closeQRCodeButton.Visible = false; closeQRCodeButton.Visible = false;
} }
multiPagePanel.LoadPlayedSongs(List,page); multiPagePanel.LoadPlayedSongs(List, page);
} }
#region Visible屬性設定 #region Visible屬性設定
@ -2435,12 +2187,20 @@ namespace DualScreenDemo
activeButton.BackgroundImage = activeBackground; activeButton.BackgroundImage = activeBackground;
} }
private async void HttpDownload(string fileUrl,string LocalLoc) public void ToFront(List<Control> controlList)
{
foreach (var control in controlList)
{
control.BringToFront();
}
}
private async void HttpDownload(string fileUrl, string LocalLoc)
{ {
using HttpClient client = new HttpClient(); using HttpClient client = new HttpClient();
try try
{ {
var response= await client.GetAsync(fileUrl, HttpCompletionOption.ResponseHeadersRead); var response = await client.GetAsync(fileUrl, HttpCompletionOption.ResponseHeadersRead);
var totalBytes = response.Content.Headers.ContentLength ?? -1L; var totalBytes = response.Content.Headers.ContentLength ?? -1L;
using var contentStream = await response.Content.ReadAsStreamAsync(); using var contentStream = await response.Content.ReadAsStreamAsync();
@ -2465,7 +2225,7 @@ namespace DualScreenDemo
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("Download Failed:"+ex.Message); Console.WriteLine("Download Failed:" + ex.Message);
Program.WriteLog("Download Failed:" + ex.Message); Program.WriteLog("Download Failed:" + ex.Message);
} }
} }

View File

@ -245,6 +245,22 @@ namespace DualScreenDemo
// 顯示「注音歌手搜尋」的圖片框 // 顯示「注音歌手搜尋」的圖片框
pictureBoxZhuYinSingers.Visible = true; pictureBoxZhuYinSingers.Visible = true;
} }
private void PhoneticButton_Click(object sender, EventArgs e)
{
var button = sender as Button;
if (button != null && button.Tag != null)
{
if (inputBoxZhuYinSingers.Visible)
{
inputBoxZhuYinSingers.Text += button.Tag.ToString();
}
else if (inputBoxZhuYinSongs.Visible)
{
inputBoxZhuYinSongs.Text += button.Tag.ToString();
}
}
}
private void ModifyButtonZhuYinSingers_Click(object sender, EventArgs e) private void ModifyButtonZhuYinSingers_Click(object sender, EventArgs e)
{ {
// 如果輸入框不為空,且包含輸入內容,則刪除最後一個字符 // 如果輸入框不為空,且包含輸入內容,則刪除最後一個字符

View File

@ -1,5 +1,5 @@
using System.IO; using System.IO;
using DirectShowLib; // using DirectShowLib;
using LibVLCSharp; using LibVLCSharp;
namespace DualScreenDemo.Services namespace DualScreenDemo.Services
@ -15,6 +15,7 @@ namespace DualScreenDemo.Services
{ {
Core.Initialize(); Core.Initialize();
_libVLC = new LibVLC( _libVLC = new LibVLC(
// "--reset-plugins-cache", //產生libvlc plugins設定cache,加快初次啟動速度,生成快取後註解關閉此設定。
"--verbose=-1", "--verbose=-1",
// enableDebugLogs: true, // enableDebugLogs: true,
"--audio-time-stretch", "--audio-time-stretch",
@ -84,7 +85,7 @@ namespace DualScreenDemo.Services
_media = new Media(filePath, FromType.FromPath); _media = new Media(filePath, FromType.FromPath);
_mediaPlayer.Media = addMediaOption(_media, audioTrackIndex); _mediaPlayer.Media = addMediaOption(_media, audioTrackIndex);
_mediaPlayer.Play(); _mediaPlayer.Play();
_mediaPlayer.Fullscreen=true; _mediaPlayer.Fullscreen = true;
_mediaPlayer.Mute = false; _mediaPlayer.Mute = false;
// _mediaPlayer.Stopped += (s, e) => Console.WriteLine("Player Stopped"); // _mediaPlayer.Stopped += (s, e) => Console.WriteLine("Player Stopped");
} }
@ -145,4 +146,6 @@ namespace DualScreenDemo.Services
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
} }
} }