我的最愛圖片調整
This commit is contained in:
parent
2b0b4d5ca0
commit
6f54a5109d
@ -206,7 +206,6 @@ namespace DualScreenDemo
|
||||
if (_indataHistory.Count == targetSequence.Length &&
|
||||
_indataHistory.SequenceEqual(targetSequence))
|
||||
{
|
||||
// 👇 這裡就是條件符合時要做的事情
|
||||
Console.WriteLine("Shutdown condition met. Application will now close.");
|
||||
ShutdownComputer();
|
||||
// 你可以呼叫其他方法、觸發事件、改狀態等等
|
||||
|
@ -179,11 +179,19 @@ namespace DualScreenDemo
|
||||
{
|
||||
if (!string.IsNullOrEmpty(mobileNumber))
|
||||
{
|
||||
using (Font font = new Font("Arial", 24))
|
||||
|
||||
using (Brush brush = new SolidBrush(Color.Black))
|
||||
{
|
||||
int x = 16;
|
||||
int y = 68;
|
||||
int screenW = Screen.PrimaryScreen.Bounds.Width;
|
||||
int screenH = Screen.PrimaryScreen.Bounds.Height;
|
||||
|
||||
float widthRatio = screenW / 1920f;
|
||||
float heightRatio = screenH / 1080f;
|
||||
|
||||
// 轉成縮放後的座標
|
||||
int x = (int)(30 * widthRatio);
|
||||
int y = (int)(90 * heightRatio);
|
||||
Font font = new Font("Arial", 24*heightRatio);
|
||||
|
||||
if (showError)
|
||||
{
|
||||
@ -312,7 +320,7 @@ namespace DualScreenDemo
|
||||
if (!FavoritePictureBox.Visible)
|
||||
{
|
||||
|
||||
ShowImageOnFavoritePictureBox(Path.Combine(Application.StartupPath, @"themes\superstar\其他介面\其他_我的最愛.jpg"));
|
||||
ShowImageOnFavoritePictureBox(Path.Combine(Application.StartupPath, @"themes\superstar\我的最愛\我的最愛_工作區域.jpg"));
|
||||
SetFavoritePictureBoxAndButtonsVisibility(true);
|
||||
}
|
||||
else
|
||||
@ -335,24 +343,24 @@ namespace DualScreenDemo
|
||||
private void ShowImageOnFavoritePictureBox(string imagePath)
|
||||
{
|
||||
|
||||
Bitmap originalImage = new Bitmap(imagePath);
|
||||
if (File.Exists(imagePath))
|
||||
{
|
||||
// 直接載入完整圖
|
||||
Bitmap image = new Bitmap(imagePath);
|
||||
|
||||
|
||||
Console.WriteLine(String.Format("Original Image Size: {0}x{1}", originalImage.Width, originalImage.Height));
|
||||
// 顯示在 PictureBox 上
|
||||
FavoritePictureBox.Image = image;
|
||||
|
||||
|
||||
Rectangle cropArea = new Rectangle(784, 393, 555, 442);
|
||||
// 設定 PictureBox 的大小與位置(依你的需要調整)
|
||||
ResizeAndPositionPictureBox(FavoritePictureBox, 773, 380, (int)(image.Width * 0.8f) , (int)(image.Height * 0.8f));
|
||||
|
||||
|
||||
Bitmap croppedImage = CropImage(originalImage, cropArea);
|
||||
FavoritePictureBox.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("圖片檔案不存在:" + imagePath);
|
||||
}
|
||||
|
||||
|
||||
FavoritePictureBox.Image = croppedImage;
|
||||
|
||||
|
||||
ResizeAndPositionPictureBox(FavoritePictureBox, cropArea.X, cropArea.Y, 416, 323);
|
||||
|
||||
FavoritePictureBox.Visible = true;
|
||||
}
|
||||
|
||||
private void ToggleFavoritePictureBoxButtonsVisibility()
|
||||
|
@ -371,22 +371,40 @@ namespace DualScreenDemo
|
||||
// 顯示包廂名稱
|
||||
// 取主機名稱的最後 20 個字元 (如果長度不足 20,則取全部)
|
||||
string displayName = "包廂" + hostName.Substring(Math.Max(0, hostName.Length - 20));
|
||||
string pageNumber = (multiPagePanel.currentPageIndex + 1).ToString() + "/" + (multiPagePanel.totalPages).ToString();
|
||||
string totalPages = multiPagePanel.totalPages.ToString() == "0" ? "1" : multiPagePanel.totalPages.ToString();
|
||||
string pageNumber = (multiPagePanel.currentPageIndex + 1).ToString() + "/" + totalPages;
|
||||
|
||||
// 最後確定要塗鴉的值
|
||||
displayName = displayName + " " + pageNumber;
|
||||
|
||||
// 基準解析度(你目前的設計基準)
|
||||
float baseWidth = 1920f;
|
||||
float baseHeight = 1080f;
|
||||
|
||||
// 實際螢幕解析度
|
||||
float actualWidth = Screen.PrimaryScreen.Bounds.Width;
|
||||
float actualHeight = Screen.PrimaryScreen.Bounds.Height;
|
||||
|
||||
// 計算縮放比例
|
||||
float scaleX = actualWidth / baseWidth;
|
||||
float scaleY = actualHeight / baseHeight;
|
||||
|
||||
|
||||
// 設定字型:
|
||||
// "微軟正黑體",大小 24,粗體 (Bold)
|
||||
Font font = new Font("微軟正黑體", 24, FontStyle.Bold);
|
||||
float fontSize = 24 * scaleY;
|
||||
Font font = new Font("微軟正黑體", fontSize, FontStyle.Bold);
|
||||
// 設定畫刷 (Brush):
|
||||
// 使用紅色 (Red) 來繪製文字
|
||||
Brush brush = new SolidBrush(Color.Red);
|
||||
|
||||
// 設定繪製文字的位置 (X=500, Y=30)
|
||||
PointF point_PCName = new PointF(500, 30);
|
||||
PointF point_pageNumber = new PointF(700, 30);
|
||||
|
||||
PointF point_PCName = new PointF(500 * scaleX, 30 * scaleY);
|
||||
|
||||
|
||||
// 繪製文字:
|
||||
// `DrawString(要繪製的文字, 字型, 畫刷, 位置)`
|
||||
e.Graphics.DrawString(displayName, font, brush, point_PCName);
|
||||
e.Graphics.DrawString(pageNumber, font, brush, point_pageNumber);
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
Reference in New Issue
Block a user