2508281333
已點歌曲頁面自動定位至播放中歌曲 QRCode關閉按鈕偏移問題修正
This commit is contained in:
parent
9e44419710
commit
ed34f6c05a
@ -12,7 +12,7 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
private const int ItemHeight = 70;
|
private const int ItemHeight = 70;
|
||||||
private const int RowGap = 2;
|
private const int RowGap = 2;
|
||||||
private int itemsPerPage
|
public int itemsPerPage
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -203,12 +203,10 @@ namespace DualScreenDemo
|
|||||||
currentSongList = songs;
|
currentSongList = songs;
|
||||||
currentArtistList.Clear();
|
currentArtistList.Clear();
|
||||||
currentPageIndex = 0;
|
currentPageIndex = 0;
|
||||||
totalPages = (int)Math.Ceiling(songs.Count / (double)itemsPerPage);
|
totalPages = (int)Math.Ceiling(songs.Count / (double)itemsPerPage);
|
||||||
|
|
||||||
// 直接調用基礎刷新邏輯
|
// 直接調用基礎刷新邏輯
|
||||||
RefreshDisplayBase();
|
RefreshDisplayBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadSingers(List<Artist> artists)
|
public void LoadSingers(List<Artist> artists)
|
||||||
{
|
{
|
||||||
_isShowingSinger = true;
|
_isShowingSinger = true;
|
||||||
@ -219,18 +217,17 @@ namespace DualScreenDemo
|
|||||||
RefreshDisplayBase_Singer();
|
RefreshDisplayBase_Singer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadPlayedSongs(List<SongData> songs)
|
public void LoadPlayedSongs(List<SongData> songs,int page)
|
||||||
{
|
{
|
||||||
_isShowingSinger = false;
|
_isShowingSinger = false;
|
||||||
currentSongList = songs;
|
currentSongList = songs;
|
||||||
currentArtistList.Clear();
|
currentArtistList.Clear();
|
||||||
currentPageIndex = 0;
|
currentPageIndex = page;
|
||||||
totalPages = (int)Math.Ceiling(songs.Count / (double)itemsPerPage);
|
totalPages = (int)Math.Ceiling(songs.Count / (double)itemsPerPage);
|
||||||
|
|
||||||
// 直接調用基礎刷新邏輯
|
// 直接調用基礎刷新邏輯
|
||||||
RefreshDisplayBase();
|
RefreshDisplayBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshDisplay()
|
public void RefreshDisplay()
|
||||||
{
|
{
|
||||||
this.Controls.Clear(); // 清除所有 UI 元件
|
this.Controls.Clear(); // 清除所有 UI 元件
|
||||||
@ -562,8 +559,6 @@ namespace DualScreenDemo
|
|||||||
songLabel.BringToFront();
|
songLabel.BringToFront();
|
||||||
artistLabel.BringToFront();
|
artistLabel.BringToFront();
|
||||||
|
|
||||||
//songLabel.Controls.Add(artistLabel);
|
|
||||||
//artistLabel.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
|
|
||||||
songLabel.TextAlign = ContentAlignment.TopLeft;
|
songLabel.TextAlign = ContentAlignment.TopLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ namespace DualScreenDemo
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
string imagePath = Path.Combine(serverPath, data["QrCode"]["QrCodeBaseUI"]);
|
string imagePath = Path.Combine(serverPath, data["QrCode"]["QrCodeBaseUI"]);
|
||||||
if (!File.Exists(imagePath))
|
if (!File.Exists(imagePath))
|
||||||
{
|
{
|
||||||
@ -60,7 +60,7 @@ namespace DualScreenDemo
|
|||||||
|
|
||||||
using (qrCodeImage)
|
using (qrCodeImage)
|
||||||
{
|
{
|
||||||
|
|
||||||
using (Bitmap bitmap = new Bitmap(baseImage.Width, baseImage.Height))
|
using (Bitmap bitmap = new Bitmap(baseImage.Width, baseImage.Height))
|
||||||
{
|
{
|
||||||
using (Graphics g = Graphics.FromImage(bitmap))
|
using (Graphics g = Graphics.FromImage(bitmap))
|
||||||
@ -70,30 +70,28 @@ namespace DualScreenDemo
|
|||||||
// cropped qrcode 版型不同設定調整
|
// cropped qrcode 版型不同設定調整
|
||||||
g.DrawImage(baseImage, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
|
g.DrawImage(baseImage, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
|
||||||
Rectangle qrCodeRect = new Rectangle(41, 50, 227, 227);
|
Rectangle qrCodeRect = new Rectangle(41, 50, 227, 227);
|
||||||
|
|
||||||
g.DrawImage(qrCodeImage, qrCodeRect);
|
g.DrawImage(qrCodeImage, qrCodeRect);
|
||||||
}
|
}
|
||||||
pictureBoxQRCode.Image = new Bitmap(bitmap);
|
pictureBoxQRCode.Image = new Bitmap(bitmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ResizeAndPositionControl(pictureBoxQRCode, 975, 442, 226, 274);
|
ResizeAndPositionControl(pictureBoxQRCode, 975, 442, 226, 274);
|
||||||
|
|
||||||
|
|
||||||
Bitmap originalImage = new Bitmap(Path.Combine(serverPath, data["QrCode"]["QrCodeBaseUI"]));
|
Bitmap originalImage = new Bitmap(Path.Combine(serverPath, data["QrCode"]["QrCodeBaseUI"]));
|
||||||
|
|
||||||
|
|
||||||
//Rectangle closeQRCodeCropArea = new Rectangle(198, 6, 22, 22);
|
//Rectangle closeQRCodeCropArea = new Rectangle(198, 6, 22, 22);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
closeQRCodeButton = new Button { Text = "" };
|
closeQRCodeButton = new Button { Text = "" };
|
||||||
closeQRCodeButton.Name = "closeQRCodeButton";
|
closeQRCodeButton.Name = "closeQRCodeButton";
|
||||||
closeQRCodeButton.Location = new Point(259, 7);
|
|
||||||
closeQRCodeButton.Size = new Size(30, 30);
|
|
||||||
closeQRCodeButton.BackColor = Color.Transparent;
|
closeQRCodeButton.BackColor = Color.Transparent;
|
||||||
closeQRCodeButton.BackgroundImageLayout = ImageLayout.Stretch;
|
closeQRCodeButton.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
closeQRCodeButton.FlatStyle = FlatStyle.Flat;
|
closeQRCodeButton.FlatStyle = FlatStyle.Flat;
|
||||||
@ -102,6 +100,7 @@ namespace DualScreenDemo
|
|||||||
closeQRCodeButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
|
closeQRCodeButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
|
||||||
closeQRCodeButton.Click += CloseQRCodeButton_Click;
|
closeQRCodeButton.Click += CloseQRCodeButton_Click;
|
||||||
pictureBoxQRCode.Controls.Add(closeQRCodeButton);
|
pictureBoxQRCode.Controls.Add(closeQRCodeButton);
|
||||||
|
ResizeAndPositionControl(closeQRCodeButton, 193, 4, 25, 25);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -136,32 +136,32 @@ namespace DualScreenDemo
|
|||||||
// string serverPath = Utils.Env.GetPath("", "");
|
// string serverPath = Utils.Env.GetPath("", "");
|
||||||
string serverPath = Application.StartupPath;
|
string serverPath = Application.StartupPath;
|
||||||
|
|
||||||
// async Task<Bitmap> GetBitmapFromUriAsync(Uri uri)
|
//async Task<Bitmap> GetBitmapFromUriAsync(Uri uri)
|
||||||
// {
|
//{
|
||||||
// using HttpClient client = new HttpClient();
|
// using HttpClient client = new HttpClient();
|
||||||
// byte[] imageBytes = await client.GetByteArrayAsync(uri);
|
// byte[] imageBytes = await client.GetByteArrayAsync(uri);
|
||||||
|
|
||||||
// MemoryStream ms = new MemoryStream(imageBytes);
|
// MemoryStream ms = new MemoryStream(imageBytes);
|
||||||
// Bitmap bitmap = new Bitmap(ms);
|
// Bitmap bitmap = new Bitmap(ms);
|
||||||
// Bitmap clonedBitmap = new Bitmap(bitmap);
|
// Bitmap clonedBitmap = new Bitmap(bitmap);
|
||||||
// ms.Dispose();
|
// ms.Dispose();
|
||||||
|
|
||||||
// return clonedBitmap;
|
// return clonedBitmap;
|
||||||
// }
|
//}
|
||||||
|
|
||||||
|
|
||||||
// private async void LoadBackgroundImage()
|
//private async void LoadBackgroundImage()
|
||||||
// {
|
//{
|
||||||
// var data = LoadBtnConfigData();
|
// var data = LoadBtnConfigData();
|
||||||
// var hostdata = LoadBtnConfigData();
|
// var hostdata = LoadBtnConfigData();
|
||||||
// string test = hostdata["HeartBeatUrl"] + "/" + data["PrimaryFormBtn"]["AlertNormal1"];
|
// string test1 = hostdata["HeartBeatUrl"] + "/" + data["PrimaryFormBtn"]["AlertNormal1"];
|
||||||
// Console.WriteLine(test);
|
// Console.WriteLine(test1);
|
||||||
// Uri remoteUri = new Uri("http://zqd.superstar.dnsnet.cc/themes/superstar/button/1.主類別/主類別上方_新歌快報(未按).png");
|
// Uri remoteUri = new Uri("http://zqd.superstar.dnsnet.cc/themes/superstar/button/1.主類別/主類別上方_新歌快報(未按).png");
|
||||||
|
|
||||||
// Bitmap bitmap = await GetBitmapFromUriAsync(remoteUri);
|
// Bitmap bitmap = await GetBitmapFromUriAsync(remoteUri);
|
||||||
// this.BackgroundImage = bitmap;
|
// this.BackgroundImage = bitmap;
|
||||||
// this.BackgroundImageLayout = ImageLayout.Stretch; // Optional
|
// this.BackgroundImageLayout = ImageLayout.Stretch; // Optional
|
||||||
// }
|
//}
|
||||||
|
|
||||||
public int currentPage
|
public int currentPage
|
||||||
{
|
{
|
||||||
@ -179,7 +179,7 @@ namespace DualScreenDemo
|
|||||||
this.Invalidate(); // 重新繪製界面
|
this.Invalidate(); // 重新繪製界面
|
||||||
}
|
}
|
||||||
|
|
||||||
public const int itemsPerPage = 18;
|
public const int itemsPerPage = 16;
|
||||||
private WaveInEvent waveIn;
|
private WaveInEvent waveIn;
|
||||||
private WaveFileWriter waveWriter;
|
private WaveFileWriter waveWriter;
|
||||||
|
|
||||||
@ -340,12 +340,12 @@ 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, 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);
|
||||||
e.Graphics.DrawString(pageNumber, font, brush, point_PageNumber);
|
e.Graphics.DrawString(pageNumber, font, brush, point_PageNumber);
|
||||||
e.Graphics.DrawString(version.Substring(version.IndexOf("V"), 4), font, brush, point_verSion);
|
e.Graphics.DrawString(version.Substring(version.IndexOf("V"), 5), font, brush, point_verSion);
|
||||||
}
|
}
|
||||||
private void User_Paint(object sender, PaintEventArgs e)
|
private void User_Paint(object sender, PaintEventArgs e)
|
||||||
{
|
{
|
||||||
@ -2312,14 +2312,16 @@ namespace DualScreenDemo
|
|||||||
{
|
{
|
||||||
var data = LoadBtnConfigData();
|
var data = LoadBtnConfigData();
|
||||||
|
|
||||||
UpdateButtonBackgrounds(orderedSongsButton,orderedSongsActiveBackground);
|
UpdateButtonBackgrounds(orderedSongsButton, orderedSongsActiveBackground);
|
||||||
|
|
||||||
isOnOrderedSongsPage = true;
|
isOnOrderedSongsPage = true;
|
||||||
autoRefreshTimer.Start(); // 开始自动刷新
|
autoRefreshTimer.Start(); // 开始自动刷新
|
||||||
// 已點歌曲錨點
|
// 已點歌曲錨點
|
||||||
var List = SongList.GetHistory();
|
var List = SongList.GetHistory();
|
||||||
totalPages = (int)Math.Ceiling((double)List.Count / itemsPerPage);
|
totalPages = (int)Math.Ceiling((double)List.Count / itemsPerPage);
|
||||||
multiPagePanel.currentPageIndex = 0;
|
int index = List.FindIndex(song => song.GetState() == PlayState.Playing);
|
||||||
|
int page = 0;
|
||||||
|
if ((index+1) > multiPagePanel.itemsPerPage) page = Math.Abs((index+1) / multiPagePanel.itemsPerPage);
|
||||||
|
|
||||||
SetHotSongButtonsVisibility(false);
|
SetHotSongButtonsVisibility(false);
|
||||||
SetNewSongButtonsVisibility(false);
|
SetNewSongButtonsVisibility(false);
|
||||||
@ -2343,7 +2345,7 @@ namespace DualScreenDemo
|
|||||||
closeQRCodeButton.Visible = false;
|
closeQRCodeButton.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
multiPagePanel.LoadPlayedSongs(List);
|
multiPagePanel.LoadPlayedSongs(List,page);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 控制項Visible屬性設定
|
#region 控制項Visible屬性設定
|
||||||
@ -2419,5 +2421,40 @@ namespace DualScreenDemo
|
|||||||
activeButton.BackgroundImage = activeBackground;
|
activeButton.BackgroundImage = activeBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void HttpDownload(string fileUrl,string LocalLoc)
|
||||||
|
{
|
||||||
|
using HttpClient client = new HttpClient();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response= await client.GetAsync(fileUrl, HttpCompletionOption.ResponseHeadersRead);
|
||||||
|
|
||||||
|
var totalBytes = response.Content.Headers.ContentLength ?? -1L;
|
||||||
|
using var contentStream = await response.Content.ReadAsStreamAsync();
|
||||||
|
using var fileStream = new FileStream(LocalLoc, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||||
|
|
||||||
|
var buffer = new byte[8192];
|
||||||
|
long totalRead = 0;
|
||||||
|
int read;
|
||||||
|
while ((read = await contentStream.ReadAsync(buffer, 0, buffer.Length)) > 0)
|
||||||
|
{
|
||||||
|
await fileStream.WriteAsync(buffer, 0, read);
|
||||||
|
totalRead += read;
|
||||||
|
|
||||||
|
if (totalBytes > 0)
|
||||||
|
{
|
||||||
|
int progress = (int)((totalRead * 100) / totalBytes);
|
||||||
|
progressBar.Value = progress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("File Downloaded");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Download Failed:"+ex.Message);
|
||||||
|
Program.WriteLog("Download Failed:" + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user