新增頁碼,動態調整解析度排版,插入端口錨點
This commit is contained in:
parent
4843851328
commit
339df0c183
@ -47,11 +47,12 @@ namespace DualScreenDemo
|
||||
string localAddress = GetLocalIPAddress(); // 使用获取的本地 IP
|
||||
string externalAddress = "";
|
||||
|
||||
// 读取外网地址
|
||||
// 讀取外網地址 沒有端口號
|
||||
string serverAddressFilePath = @"\\SVR01\superstarb\txt\ip.txt";
|
||||
if (File.Exists(serverAddressFilePath))
|
||||
{
|
||||
externalAddress = File.ReadAllText(serverAddressFilePath).Trim();
|
||||
Console.WriteLine("External address: " + externalAddress);
|
||||
}
|
||||
|
||||
// 启动服务器的逻辑
|
||||
@ -65,7 +66,8 @@ namespace DualScreenDemo
|
||||
// 如果有外网地址,也添加外网地址前缀
|
||||
if (!string.IsNullOrEmpty(externalAddress))
|
||||
{
|
||||
// 解析外网地址和端口
|
||||
// 錨點 2
|
||||
// 外網 IP 和 port 調整
|
||||
string[] parts = externalAddress.Split(':');
|
||||
string host = parts[0];
|
||||
int externalPort = parts.Length > 1 ? int.Parse(parts[1]) : port;
|
||||
@ -169,7 +171,11 @@ namespace DualScreenDemo
|
||||
return String.Format("http://{0}:{1}/", _localIP, _port);
|
||||
// return String.Format("http://111.246.145.170:8080/");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成隨機路徑
|
||||
/// </summary>
|
||||
/// <param name="baseDirectory"></param>
|
||||
/// <returns></returns>
|
||||
private static string CreateRandomFolderAndRedirectHTML(string baseDirectory)
|
||||
{
|
||||
string randomFolderName = Path.GetRandomFileName().Replace(".", "");
|
||||
|
@ -237,8 +237,26 @@ namespace DualScreenDemo
|
||||
public static int currentSongIndexInHistory = -1;
|
||||
public MultiPagePanel multiPagePanel;
|
||||
private List<Label> songLabels = new List<Label>();
|
||||
public int currentPage = 0;
|
||||
public int totalPages;
|
||||
private int _currentPage { get; set; }= 0;
|
||||
private int _totalPages { get; set; }
|
||||
|
||||
|
||||
public int currentPage
|
||||
{
|
||||
get { return _currentPage; }
|
||||
set { _currentPage = value; }
|
||||
}
|
||||
public int totalPages
|
||||
{
|
||||
get { return _totalPages; }
|
||||
set { _totalPages = value; }
|
||||
}
|
||||
|
||||
private void HandlePageChanged()
|
||||
{
|
||||
this.Invalidate(); // 重新繪製界面
|
||||
}
|
||||
|
||||
public const int itemsPerPage = 18;
|
||||
private const int RowsPerPage = 9;
|
||||
private const int Columns = 2;
|
||||
@ -262,7 +280,7 @@ namespace DualScreenDemo
|
||||
public Timer micControlTimer;
|
||||
|
||||
private SequenceManager sequenceManager = new SequenceManager();
|
||||
|
||||
/* 關機圖片調整區域 錨點3 */
|
||||
private PictureBox buttonMiddle;
|
||||
private PictureBox buttonTopRight;
|
||||
private PictureBox buttonTopLeft;
|
||||
@ -292,6 +310,7 @@ namespace DualScreenDemo
|
||||
|
||||
private Timer autoRefreshTimer;
|
||||
|
||||
//private Label pageNumberLabel; // 添加頁碼標籤
|
||||
public PrimaryForm()
|
||||
{
|
||||
Instance = this;
|
||||
@ -344,11 +363,13 @@ namespace DualScreenDemo
|
||||
|
||||
InitializePromotionsAndMenuPanel();
|
||||
SaveInitialControlStates(this);
|
||||
|
||||
// 包廂 + port 名稱
|
||||
this.Paint += PrimaryForm_Paint;
|
||||
|
||||
// 註冊多頁面面板的頁碼改變事件處理
|
||||
multiPagePanel.PageIndexChanged += HandlePageChanged;
|
||||
// 添加 Load 事件處理
|
||||
this.Load += PrimaryForm_Load;
|
||||
|
||||
}
|
||||
|
||||
// 添加 DPI 感知支持
|
||||
@ -370,21 +391,28 @@ namespace DualScreenDemo
|
||||
|
||||
private void PrimaryForm_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
||||
// 取得本機電腦的主機名稱 (hostname)
|
||||
string hostName = System.Net.Dns.GetHostName();
|
||||
|
||||
|
||||
// 顯示包廂名稱
|
||||
// 取主機名稱的最後 20 個字元 (如果長度不足 20,則取全部)
|
||||
string displayName = "包廂" + hostName.Substring(Math.Max(0, hostName.Length - 20));
|
||||
|
||||
|
||||
string pageNumber = (multiPagePanel.currentPageIndex + 1).ToString() + "/" + (multiPagePanel.totalPages).ToString();
|
||||
// 設定字型:
|
||||
// "微軟正黑體",大小 24,粗體 (Bold)
|
||||
Font font = new Font("微軟正黑體", 24, FontStyle.Bold);
|
||||
// 設定畫刷 (Brush):
|
||||
// 使用紅色 (Red) 來繪製文字
|
||||
Brush brush = new SolidBrush(Color.Red);
|
||||
|
||||
|
||||
PointF point = new PointF(500, 30);
|
||||
// 設定繪製文字的位置 (X=500, Y=30)
|
||||
PointF point_PCName = new PointF(500, 30);
|
||||
PointF point_pageNumber = new PointF(700, 30);
|
||||
|
||||
|
||||
e.Graphics.DrawString(displayName, font, brush, point);
|
||||
// 繪製文字:
|
||||
// `DrawString(要繪製的文字, 字型, 畫刷, 位置)`
|
||||
e.Graphics.DrawString(displayName, font, brush, point_PCName);
|
||||
e.Graphics.DrawString(pageNumber, font, brush, point_pageNumber);
|
||||
}
|
||||
|
||||
|
||||
@ -1642,7 +1670,28 @@ public class MultiPagePanel : Panel
|
||||
{
|
||||
private const int ItemHeight = 70;
|
||||
private const int RowGap = 2;
|
||||
private const int itemsPerPage = 16; // 每頁 16 首歌
|
||||
private int itemsPerPage
|
||||
{
|
||||
get
|
||||
{
|
||||
Screen screen = Screen.PrimaryScreen;
|
||||
int screenWidth = screen.Bounds.Width;
|
||||
int screenHeight = screen.Bounds.Height;
|
||||
if(screenWidth==1440 && screenHeight==900)
|
||||
{
|
||||
return 14;
|
||||
}
|
||||
else if(screenWidth==1024 && screenHeight==768)
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
else if(screenWidth == 1920 && screenHeight == 1080)
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
return 16; // 預設值
|
||||
}
|
||||
}
|
||||
private const float LeftColumnX = 0.03f;
|
||||
private const float RightColumnX = 0.52f;
|
||||
private const float SongWidth = 0.35f;
|
||||
@ -1666,14 +1715,35 @@ public class MultiPagePanel : Panel
|
||||
}
|
||||
private List<SongData> currentSongList = new List<SongData>();
|
||||
private List<Artist> currentArtistList = new List<Artist>();
|
||||
private int totalPages = 0;
|
||||
private int _totalPages = 0;
|
||||
private Point mouseDownLocation; // 新增字段
|
||||
private bool isDragging = false; // 新增字段
|
||||
|
||||
public event Action PageIndexChanged; // 新增事件
|
||||
public int currentPageIndex
|
||||
{
|
||||
get { return _currentPageIndex; }
|
||||
set { _currentPageIndex = value; }
|
||||
set
|
||||
{
|
||||
if (_currentPageIndex != value)
|
||||
{
|
||||
_currentPageIndex = value;
|
||||
// 觸發事件,通知頁面索引已改變
|
||||
PageIndexChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
public int totalPages
|
||||
{
|
||||
get { return _totalPages; }
|
||||
set
|
||||
{
|
||||
if (_totalPages != value)
|
||||
{
|
||||
_totalPages = value;
|
||||
// 觸發事件,通知頁面索引已改變
|
||||
PageIndexChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MultiPagePanel()
|
||||
@ -1874,10 +1944,19 @@ public class MultiPagePanel : Panel
|
||||
{
|
||||
artistLabel.Font = normalFont;
|
||||
}
|
||||
|
||||
// 計算位置 - 修改為先左邊8個,再右邊8個的順序
|
||||
bool isLeftColumn = index < 8; // 前8个在左边
|
||||
int row = isLeftColumn ? index : index - 8; // 如果是右边,需要减去8来计算正确的行号
|
||||
Screen screen = Screen.PrimaryScreen;
|
||||
int screenWidth = screen.Bounds.Width;
|
||||
int screenHeight = screen.Bounds.Height;
|
||||
int NumberOfItem = (screenWidth, screenHeight) switch
|
||||
{
|
||||
(1440, 900) => 7,
|
||||
(1024, 768) => 6,
|
||||
(1920, 1080) => 8,
|
||||
_ => 8 // 預設值
|
||||
};
|
||||
// 計算位置 - 依照NumberOfItem來計算
|
||||
bool isLeftColumn = index < NumberOfItem;
|
||||
int row = isLeftColumn ? index : index - NumberOfItem; // 如果是右边,需要减去8来计算正确的行号
|
||||
float startX = isLeftColumn ? LeftColumnX : RightColumnX;
|
||||
int y = row * (ItemHeight + RowGap);
|
||||
|
||||
@ -2068,10 +2147,26 @@ public class MultiPagePanel : Panel
|
||||
artistLabel.Text = artistText;
|
||||
artistLabel.Tag = song;
|
||||
artistLabel.AutoSize = false;
|
||||
Screen screen = Screen.PrimaryScreen;
|
||||
int screenWidth = screen.Bounds.Width;
|
||||
int screenHeight = screen.Bounds.Height;
|
||||
int NumberOfItem = 0;
|
||||
if(screenWidth==1440 && screenHeight==900)
|
||||
{
|
||||
NumberOfItem = 7;
|
||||
}
|
||||
else if(screenWidth==1024 && screenHeight==768)
|
||||
{
|
||||
NumberOfItem = 6;
|
||||
}
|
||||
else if(screenWidth == 1920 && screenHeight == 1080)
|
||||
{
|
||||
NumberOfItem = 8;
|
||||
}
|
||||
|
||||
// 計算位置 - 修改為先左邊8個,再右邊8個的順序
|
||||
bool isLeftColumn = index < 8; // 前8个在左边
|
||||
int row = isLeftColumn ? index : index - 8; // 如果是右边,需要减去8来计算正确的行号
|
||||
// 計算位置 - 依照NumberOfItem來計算
|
||||
bool isLeftColumn = index < NumberOfItem;
|
||||
int row = isLeftColumn ? index : index - NumberOfItem;
|
||||
float startX = isLeftColumn ? LeftColumnX : RightColumnX;
|
||||
int y = row * (ItemHeight + RowGap);
|
||||
|
||||
@ -3425,7 +3520,10 @@ public class MultiPagePanel : Panel
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加載送客畫面圖片
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Image LoadSendOffImage()
|
||||
{
|
||||
try
|
||||
|
Reference in New Issue
Block a user