同步畫面螢幕解析度
This commit is contained in:
parent
70cabac740
commit
6079ddd2a6
@ -399,7 +399,7 @@ namespace DualScreenDemo
|
||||
throw; // Rethrow the exception to handle it further up the call stack
|
||||
}
|
||||
}
|
||||
|
||||
// 同步畫面事件
|
||||
public void SyncToPrimaryMonitor()
|
||||
{
|
||||
PrimaryForm.Instance.primaryScreenPanel.Visible = true;
|
||||
@ -441,11 +441,35 @@ namespace DualScreenDemo
|
||||
// Console.WriteLine("VMR9 is not initialized.");
|
||||
return;
|
||||
}
|
||||
int designWidth = 1620;
|
||||
int designHeight = 1080;
|
||||
|
||||
int actualWidth = PrimaryForm.Instance.primaryScreenPanel.Width;
|
||||
int actualHeight = PrimaryForm.Instance.primaryScreenPanel.Height;
|
||||
|
||||
// 等比例縮放(不會超出,fit)
|
||||
float scaleX = (float)actualWidth / designWidth;
|
||||
float scaleY = (float)actualHeight / designHeight;
|
||||
float scale = Math.Min(scaleX, scaleY);
|
||||
|
||||
// 計算縮放後的尺寸(但起點仍是 0,0)
|
||||
int newWidth = (int)(designWidth * scale);
|
||||
int newHeight = (int)(designHeight * scale);
|
||||
|
||||
// trash location with trash flexible of screen size.
|
||||
if (actualWidth == 1024){
|
||||
newWidth = (int)(newWidth * 0.84f);
|
||||
}
|
||||
else if (actualWidth == 1440){
|
||||
newWidth = (int)(newWidth * 0.9f);
|
||||
}
|
||||
videoWindowPrimary = (IVideoWindow)videoRendererPrimary;
|
||||
videoWindowPrimary.put_Owner(PrimaryForm.Instance.primaryScreenPanel.Handle); // 设置为 primaryScreenPanel 的句柄
|
||||
videoWindowPrimary.put_Owner(PrimaryForm.Instance.primaryScreenPanel.Handle);
|
||||
videoWindowPrimary.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren);
|
||||
videoWindowPrimary.SetWindowPosition(0, 0, 1620, 1080); // 调整视频窗口大小以填满黑色区域
|
||||
|
||||
// ⬅ 左上角對齊(固定從 0,0 開始)
|
||||
videoWindowPrimary.SetWindowPosition(0, 0, newWidth, newHeight);
|
||||
|
||||
videoWindowPrimary.put_Visible(OABool.True);
|
||||
|
||||
// Console.WriteLine("Video window configured successfully.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user