using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var timer = new Timer();
timer.Tick += (s, e) => { DisplayImage(); };
timer.Interval = 1000 * 60 * 15; // 15分
timer.Start();
this.Resize += (s, e) =>
{
var w = this.Width - 50;
var h = this.Height - 70;
pictureBox1.Left = 10;
pictureBox1.Top = 10;
pictureBox1.Width = w / 2;
pictureBox1.Height = h / 2;
pictureBox2.Left = w / 2 + 20;
pictureBox2.Top = 10;
pictureBox2.Width = w / 2;
pictureBox2.Height = h / 2;
pictureBox3.Left = 10;
pictureBox3.Top = h / 2 + 20;
pictureBox3.Width = w / 2;
pictureBox3.Height = h / 2;
pictureBox4.Left = w / 2 + 20;
pictureBox4.Top = h / 2 + 20;
pictureBox4.Width = w / 2;
pictureBox4.Height = h / 2;
};
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox3.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox4.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.BorderStyle = BorderStyle.FixedSingle;
pictureBox2.BorderStyle = BorderStyle.FixedSingle;
pictureBox3.BorderStyle = BorderStyle.FixedSingle;
pictureBox4.BorderStyle = BorderStyle.FixedSingle;
pictureBox1.BackColor = Color.White;
pictureBox2.BackColor = Color.White;
pictureBox3.BackColor = Color.White;
pictureBox4.BackColor = Color.White;
this.WindowState = FormWindowState.Maximized;
DisplayImage();
}
private void DisplayImage()
{
string dir = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\image\";
pictureBox1.ImageLocation = dir + "1.jpg";
pictureBox2.ImageLocation = dir + "2.jpg";
pictureBox3.ImageLocation = dir + "3.jpg";
pictureBox4.ImageLocation = dir + "4.jpg";
Text = DateTime.Now.ToString("工場掲示板 MM月dd日HH時mm分") + " 更新";
}
}
}