public void initializeMonitors() {
#if (DEBUG)
this.debugLog.Add("initializeMonitors");
#endif
//MessageBox.Show("ConfigDocumentCompleted:" + this.action.ToString());
if (this.action != Actions.Config && this.action != Actions.Wallpaper) {
// Complete initialisation when config.html is loaded.
if (!this.configInitialised && this.config.browser.Url.Segments.Last().Equals(Constants.ConfigHtmlFile)) {
this.initForScreensaverAndWallpaper();
System.Drawing.Color backgroundColour = System.Drawing.ColorTranslator.FromHtml(this.config.getPersistantString("backgroundColour"));
int i = 0;
if (this.action == Actions.Test || this.action == Actions.Preview) {
int start = 0;
// Skip first monitor for preview
if (this.action == Actions.Preview) {
start = 1;
} else {
this.monitors = new Monitor[hwnds.Length];
}
for (i = start; i < hwnds.Length; i++) {
this.monitors[i] = new Monitor(hwnds[i], i, this);
this.monitors[i].FormClosed += new FormClosedEventHandler(this.OnFormClosed);
this.monitors[i].PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.PreviewKeyDown);
this.monitors[i].browser.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.PreviewKeyDown);
this.monitors[i].Show();
}
} else {
this.monitors = new Monitor[Screen.AllScreens.Length];
foreach (Screen screen in Screen.AllScreens) {
this.monitors[i] = new Monitor(screen.Bounds, i, this);
this.monitors[i].browser.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.PreviewKeyDown);
this.monitors[i].PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.PreviewKeyDown);
// Avoid white flash by hiding browser and setting form background colour. (Focus on browser on DocumentCompleted to process keystrokes)
this.monitors[i].browser.Hide();
try {
this.monitors[i].BackColor = backgroundColour;
} catch (System.ArgumentException ae) { }
this.monitors[i].Show();
i++;
}
}
this.MonitorsAndConfigReady();
}
}
}