欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

wpf dual monitor

程序员文章站 2022-07-02 12:54:15
public partial class App : System.Windows.Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); SetupWindow... ......
public partial class app : system.windows.application
    {

        protected override void onstartup(startupeventargs e)
        {
            base.onstartup(e);           

            setupwindows();
        }
         
        private void setupwindows()
        {
            system.windows.forms.screen mainscreen = screen.allscreens[0]; ;
            winleft leftwin = new winleft()
            {
                windowstartuplocation = windowstartuplocation.manual,
                windowstate = system.windows.windowstate.normal,
                left = mainscreen.workingarea.left,
                top = mainscreen.workingarea.top,
                width = mainscreen.workingarea.width,
                height = mainscreen.workingarea.height
            };           

            system.windows.forms.screen secondaryscreen = screen.allscreens[1];
            winright rightwin = new winright()
            {
                windowstartuplocation = windowstartuplocation.manual,
                windowstate = system.windows.windowstate.normal,
                left = secondaryscreen.workingarea.left,
                top = secondaryscreen.workingarea.top,
                width = secondaryscreen.workingarea.width,
                height = secondaryscreen.workingarea.height
            };

           
            leftwin.show();
            leftwin.windowstate = windowstate.maximized;
            rightwin.show();
            rightwin.windowstate = windowstate.maximized;
            rightwin.owner = leftwin;
        }
    }

wpf dual monitor