配置文件:
<!--在哪个屏幕加载界面 0 主 1副-->
<add key="ShowScreen" value="1" />
<!--屏幕调试模式-->
<add key="ShowScreenDebug" value="1" />
private void Main_Load(object sender, EventArgs e)
{
ShowScreen = int.Parse(ConfigurationDispose.GetConfiguration("ShowScreen"));
ShowScreenDebug = int.Parse(ConfigurationDispose.GetConfiguration("ShowScreenDebug"));
showOnMonitor(ShowScreen);
}
private bool showOnMonitor(int showOnMonitor)
{
if (ShowScreenDebug == 1)
{
return true;
}
if (Screen.AllScreens.Count() != 2)
{
return false;
}
Screen[] sc;
sc = Screen.AllScreens;
if (showOnMonitor >= sc.Length)
{
showOnMonitor = 0;
}
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(sc[showOnMonitor].Bounds.Left, sc[showOnMonitor].Bounds.Top);
// If you intend the form to be maximized, change it to normal then maximized.
//this.WindowState = FormWindowState.Normal;
//this.WindowState = FormWindowState.Maximized;
return true;
}