System.Windows.Forms.Screen
은 WPF 내에서 완벽하게 작동하므로 WPF 디자이너는 WPF 디자이너가 WPF 전용 버전으로 바꾸는 데 별다른 이점이 없다고 생각합니다.
물론 좌표 변환을 수행해야합니다.
public class ScreenBoundsConverter
{
private Matrix _transform;
public ScreenBoundsConverter(Visual visual)
{
_transform =
PresentationSource.FromVisual(visual).CompositionTarget.TransformFromDevice;
}
public Rect ConvertBounds(Rectangle bounds)
{
var result = new Rect(bounds.X, bounds.Y, bounds.Width, bounds.Height);
result.Transform(_transform);
return result;
}
}
사용 예제 :
var converter = new ScreenBoundsConverter { Visual = this };
foreach(var screen in System.Windows.Forms.Screen.AllScreens)
{
Rect bounds = converter.ConvertBounds(screen.Bounds);
...
}
다음은 변환을 수행 할 수있는 쉬운 클래스입니다