기존의 닷넷 프로그래밍에서는 System.Windows.Forms.SystemInformation.MonitorCount를 이용해서 현재 시스템에 장착된 모니터의 갯수를 알 수 있었다.
또 해당되는 모니터의 상세한 정보를 얻고자 할 경우에는 System.Window.Forms.Screen.AllScreens[index].WorkingArea;와 같이 해당되는 모니터의 정보를 알아낼 수 있었다.
하지만 WPF에서는 기본적으로 모니터와 관련된 속성이나 기능을 추가로 제공되지 않는 것 같다.
실제로 몇몇 경우에는 듀얼 모니터를 활용하는 경우가 많고 또 개발시에도 듀얼 모니터를 이용하는 경우가 많기 때문에 WPF Application의 출력 모니터 지정은 꼭 필요한 기능중에 하나이다.
실제로 몇몇 경우에는 듀얼 모니터를 활용하는 경우가 많고 또 개발시에도 듀얼 모니터를 이용하는 경우가 많기 때문에 WPF Application의 출력 모니터 지정은 꼭 필요한 기능중에 하나이다.
아래와 같은 코드를 이용하면 이와 같은 상황을 해결할 수 있다.
fullScreenWindow.WindowStartupLocation = WindowStartupLocation.Manual;
System.Drawing.Rectangle workingArea = System.Windows.Forms.Screen.AllScreens[1].WorkingArea;
fullScreenWindow.Left = workingArea.Left;
fullScreenWindow.Top = workingArea.Top;
fullScreenWindow.Width = workingArea.Width;
fullScreenWindow.Height = workingArea.Height;fullScreenWindow.WindowState = WindowState.Maximized;
fullScreenWindow.WindowStyle = WindowStyle.None;
fullScreenWindow.Topmost = true;
fullScreenWindow.Show();
System.Drawing.Rectangle workingArea = System.Windows.Forms.Screen.AllScreens[1].WorkingArea;
fullScreenWindow.Left = workingArea.Left;
fullScreenWindow.Top = workingArea.Top;
fullScreenWindow.Width = workingArea.Width;
fullScreenWindow.Height = workingArea.Height;fullScreenWindow.WindowState = WindowState.Maximized;
fullScreenWindow.WindowStyle = WindowStyle.None;
fullScreenWindow.Topmost = true;
fullScreenWindow.Show();
WindowStartupLocation을 메뉴얼로 지정해야 위치를 지정하기 용의하며 위의 소스의 핵심은
System.Drawing.Rectangle workingArea = System.Windows.Forms.Screen.AllScreens[1].WorkingArea; 이다.
AllScreens[1]이라고 했기 때문에 이는 Primary Monitor가 아닌 Second Monitor의 정보를 가져와서 임시라 Ractangle을 하나 생성하고 이 정보를 바탕으로 출력하려고 하는 WPF Window를 셋팅한다.
위 소스를 사용하려면,
System.Windows.Forms와 System.Drawing 두개의 NET Component를 참조 추가해야만 사용할 수 있습니다.
[참고]
단순히 멀티 모니터 전체를 덮는 창을 설정하려면, 이렇게 하세요.
System.Drawing.Rectangle workingArea = System.Windows.Forms.Screen.AllScreens[1].WorkingArea; 이다.
AllScreens[1]이라고 했기 때문에 이는 Primary Monitor가 아닌 Second Monitor의 정보를 가져와서 임시라 Ractangle을 하나 생성하고 이 정보를 바탕으로 출력하려고 하는 WPF Window를 셋팅한다.
위 소스를 사용하려면,
System.Windows.Forms와 System.Drawing 두개의 NET Component를 참조 추가해야만 사용할 수 있습니다.
[참고]
단순히 멀티 모니터 전체를 덮는 창을 설정하려면, 이렇게 하세요.
this.WindowStartupLocation = WindowStartupLocation.Manual;
this.Left = 0;
this.Top = 0;
this.Width = SystemParameters.VirtualScreenWidth;
this.Height = SystemParameters.VirtualScreenHeight;
this.WindowStyle = WindowStyle.None;
this.Topmost = true;
this.Show();
SystemParameters.VirtualScreenWidth;
SystemParameters.VirtualScreenHeight;
이 두 가지에는 멀티 모니터 전체의 크기가 계산된 값이 저장되어 있습니다.
이 경우, 1번 모니터의 Left, Top이 0 즉, 가장 왼쪽, 상단에 있어야만 정상적으로 표시될 것입니다.
댓글 없음:
댓글 쓰기