49 lines
832 B
C#
49 lines
832 B
C#
using App;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using Timer = System.Windows.Forms.Timer;
|
|
|
|
class ScreenSaver
|
|
{
|
|
private readonly Timer timer = new();
|
|
|
|
public ScreenSaver()
|
|
{
|
|
timer.Interval = 1000;
|
|
timer.Tick += OnTick;
|
|
}
|
|
|
|
public void Run()
|
|
{
|
|
// Create windows for all screens.
|
|
foreach (Screen s in Screen.AllScreens) {
|
|
|
|
if (s.Primary) {
|
|
_ = new MainWindow(s.Bounds);
|
|
} else {
|
|
_ = new Window(s.Bounds);
|
|
}
|
|
}
|
|
|
|
timer.Start();
|
|
OnTick(null, null);
|
|
|
|
Application.Run();
|
|
}
|
|
|
|
private void OnTick(object? myObject, EventArgs? myEventArgs)
|
|
{
|
|
Update();
|
|
}
|
|
|
|
private static void Update()
|
|
{
|
|
// Update background color for all forms.
|
|
Color color = ColorUtil.TimeToColor(DateTime.Now);
|
|
|
|
foreach (Form form in Application.OpenForms) {
|
|
form.BackColor = color;
|
|
}
|
|
}
|
|
}
|