forked from cwc/web-page-screensaver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
71 lines (60 loc) · 2.4 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Windows.Forms;
using Microsoft.Win32;
using System.IO;
namespace pl.polidea.lab.Web_Page_Screensaver
{
using System.Collections.Generic;
using System.Drawing;
static class Program
{
public static readonly string KEY = "Software\\Web-Page-Screensaver";
[STAThread]
static void Main(string[] args)
{
// Set version of embedded browser (http://weblog.west-wind.com/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version)
var exeName = Path.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", exeName, 0x2AF8, RegistryValueKind.DWord);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args.Length > 0 && args[0].ToLower().Contains("/p"))
return;
if (args.Length > 0 && args[0].ToLower().Contains("/c"))
{
Application.Run(new PreferencesForm());
}
else
{
var formsList = new List<Form>();
var screens = (new PreferencesManager()).EffectiveScreensList;
foreach (var screen in screens)
{
var screensaverForm = new ScreensaverForm(screen.ScreenNum)
{
Location = new Point(screen.Bounds.Left, screen.Bounds.Top),
Size = new Size(screen.Bounds.Width, screen.Bounds.Height)
};
FormStartPosition x = screensaverForm.StartPosition;
formsList.Add(screensaverForm);
}
Application.Run(new MultiFormContext(formsList));
}
}
}
public class MultiFormContext : ApplicationContext
{
public MultiFormContext(List<Form> forms)
{
foreach (var form in forms)
{
form.FormClosed += (s, args) =>
{
//When we have closed any form,
//end the program.
ExitThread();
};
form.Show();
}
}
}
}