0
내 모든 열려있는 창을 가로/세로로 바둑판 식으로 배열하고 싶습니다. 내가 함께 볼 수 있도록.어떻게 여러 wpf 창을 가로 또는 세로로 바꿀 수 있습니까?
이 날 도와주세요 ... -. ((
당신이 만든 모든 창에있는 WeakReferences를 저장하는 정적 속성입니다 수행하는 한 가지 방법은 타일을들을 수 전에 Windows의 목록을 가지고 있어야합니다내 모든 열려있는 창을 가로/세로로 바둑판 식으로 배열하고 싶습니다. 내가 함께 볼 수 있도록.어떻게 여러 wpf 창을 가로 또는 세로로 바꿀 수 있습니까?
이 날 도와주세요 ... -. ((
당신이 만든 모든 창에있는 WeakReferences를 저장하는 정적 속성입니다 수행하는 한 가지 방법은 타일을들을 수 전에 Windows의 목록을 가지고 있어야합니다, 이 같은 :
static List<WeakRef> _registeredWindows;
public void RegisterWindow(Window w)
{
_registeredWindows.Add(new WeakReference(w));
}
지금은 보이는 모든 등록 창 타일에 쉽게 :
public void TileRegisteredWindowsHorizontally()
{
// Find visible registered windows in horizontal order
var windows = (
from weak in _registeredWindows
let window = weak.Target as Window
where window!=null && window.Visibility==Visibility.Visible
orderby window.Left + window.Width/2 // Current horizontal center of window
select window
).ToList();
// Get screen size
double screenWidth = SystemParameters.PrimaryScreenWidth;
double screenHeight = SystemParameters.PrimaryScrenHeight;
// Update window positions to tile them
int count = windows.Count();
foreach(int i in Enumerable.Range(0, count))
{
var window = windows[i];
window.Left = i * screenWidth/count;
window.Width = screenWidth/count;
window.Top = 0;
window.Height = screenHeight;
}
}
작동 방법 : 첫 번째 쿼리 정렬 볼 라이브 창문의 WeakRefs를 검색 그것들은 센터에 의해 수평 적으로 배치된다. 끝의 루프는 창 위치를 조정합니다.
나는 7 년이되었지만, 'Window'를리스트에 직접 두는 대신 WeakReference라는리스트가있는 특별한 이유가 있단 말인가? – mcy
응답하기 전에 신청서에 대해 더 자세히 알아야한다고 생각합니다. – ChrisF