using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; // The 'windowHandle' parameter will contain the window handle for the: // - Active window when run by hotkey // - Trigger target when run by a Trigger rule // - TitleBar Button owner when run by a TitleBar Button // - Jump List owner when run from a Taskbar Jump List // - Currently focused window if none of these match public static class DisplayFusionFunction { public static void Run(IntPtr windowHandle) { //make a list to hold the forms List
forms = new List(); //add forms for each split to the list of forms on monitors 1.1, 1.2, and 1.3 forms.Add(new WebsiteForm("binaryfortress.com", BFS.Monitor.GetMonitorBoundsByID(1))); forms.Add(new WebsiteForm("displayfusion.com", BFS.Monitor.GetMonitorBoundsByID(2))); //forms.Add(new WebsiteForm("voicebot.net", BFS.Monitor.GetMonitorBoundsByID(103))); //this will open the forms we added to the list by using our custom application context Application.Run(new MultipleFormApplicationContext(forms)); } //extend the ApplicationContext class to support opening multiple forms private class MultipleFormApplicationContext : ApplicationContext { internal MultipleFormApplicationContext(List forms) { //open each of the forms, and add our closing event to them foreach(Form form in forms) { form.FormClosed += OnFormClosed; form.Show(); } } //when all the forms close, make sure to exit the application private void OnFormClosed(object sender, EventArgs e) { if(Application.OpenForms.Count == 0) this.ExitThread(); } } //this form contains a web browser, and opens the url specified in fullscreen mode private class WebsiteForm : Form { private Rectangle FormBounds; private string Url; private WebBrowser Browser; private Timer RefreshTimer; public WebsiteForm(string url, Rectangle bounds) { //these variables will hold information about the form this.FormBounds = bounds; this.Url = url; //suspend the form layout this.SuspendLayout(); //initialize the browser this.Browser = new WebBrowser(); this.Browser.Dock = DockStyle.Fill; this.Controls.Add(this.Browser); //initialize the timer this.RefreshTimer = new Timer(); this.RefreshTimer.Interval = 2 * 1000 * 60; //2min in milliseconds this.RefreshTimer.Tick += this.TimerTick; this.RefreshTimer.Enabled = false; //initialize the form this.FormBorderStyle = FormBorderStyle.None; this.ShowInTaskbar = false; this.Load += this.FormLoad; //resume the form layout this.ResumeLayout(false); } protected override void Dispose(bool disposing) { this.Browser.Dispose(); this.RefreshTimer.Enabled = false; this.RefreshTimer.Dispose(); base.Dispose(disposing); } //when the form loads, set its size and position, navigate to the website, then start the timer private void FormLoad(object sender, EventArgs e) { this.Bounds = this.FormBounds; this.Browser.Navigate(this.Url); this.RefreshTimer.Enabled = true; } //every 2 minutes, tell the browser to refresh private void TimerTick(object sender, EventArgs e) { this.Browser.Refresh(); } } }