private void Timer_Tick(object sender, EventArgs e) { // 日付を取得 EventProcessor.GetToday(); // 時間をfor文で調べる for (var i = 0; i < EventProcessor.Times.Count; i++) { var timeString = DateTime.Now.ToLongTimeString(); if (DateTime.Now > EventProcessor.Times[i]) { EventProcessor.CurentClassNum = i; } if (timeString == EventProcessor.Times[i].AddMinutes(-EventProcessor.PreTime).ToLongTimeString()) { NotifyIcon.ShowBalloonTip(5000, "お知らせ", $"{EventProcessor.EventNames[i]}の{EventProcessor.PreTime}分前になりました。", ToolTipIcon.Info); } if (timeString == EventProcessor.Times[i].ToLongTimeString()) { try { Process.Start(EventProcessor.URLs[i]); } catch { MessageBox.Show("URLが開けませんでした", "URL Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public Main() { EventProcessor.GetToday(); EventProcessor.Load(); forms = new Form[4]; AddTask(); for (int i = 0; i < buttonNames.Length; i++) { GenerateButton(buttonNames[i], new Point(350, i * 50 + (i + 1) * 50)); } Timer timer = new Timer() { Interval = 1000, Enabled = true }; timer.Tick += Timer_Tick; }