diff --git a/HKCardOUT/ViewModels/RootViewModel.cs b/HKCardOUT/ViewModels/RootViewModel.cs index dde24c0..8711ed2 100644 --- a/HKCardOUT/ViewModels/RootViewModel.cs +++ b/HKCardOUT/ViewModels/RootViewModel.cs @@ -141,12 +141,26 @@ namespace HKCardOUT.ViewModels private void AdOpen() { - var SC = System.Windows.Forms.Screen.AllScreens.Count(); + try + { + var SC = System.Windows.Forms.Screen.AllScreens.Count(); - for (int i = 0; i < SC; i++) + for (int i = 0; i < SC; i++) + { + var win = new AdWindow(Ad[i].Ad); + var rectangle = System.Windows.Forms.Screen.AllScreens[i].WorkingArea; + win.Height = rectangle.Height; + win.Width = rectangle.Width; + win.Top = 0; + win.Left = rectangle.Left; + win.Owner = this.Main; + win.Show(); + } + } + catch { - var win = new AdWindow(Ad[i].Ad); - var rectangle = System.Windows.Forms.Screen.AllScreens[i].WorkingArea; + var win = new AdWindow("暂无广告"); + var rectangle = System.Windows.Forms.Screen.AllScreens[0].WorkingArea; win.Height = rectangle.Height; win.Width = rectangle.Width; win.Top = 0; @@ -154,6 +168,7 @@ namespace HKCardOUT.ViewModels win.Owner = this.Main; win.Show(); } + } #endregion