Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace RPTMaintenance
- {
- public partial class Form1 : Form
- {
- Maintenance maint;
- public Form1()
- {
- InitializeComponent();
- maint = new Maintenance();
- maint.Init();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- // start checking.
- System.Threading.Timer T = new System.Threading.Timer(new TimerCallback(TimerEvent), null, 0, 120000);
- notifyIcon1.Visible = true;
- notifyIcon1.Icon = this.Icon;
- this.Visible = false;
- notifyIcon1.ShowBalloonTip(3000, "RPT Maint Check", "I will be running in the background for you.", ToolTipIcon.Info);
- }
- private void TimerEvent(object state)
- {
- // set maintenance
- maint.SetMaintenance();
- if(maint.ShouldIBeHappy())
- {
- MessageBox.Show("Hey! Server is online now!", "Finally",MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show("no");
- }
- }
- private void notifyIcon1_Click(object sender, EventArgs e)
- {
- notifyIcon1.Visible = false;
- this.Visible = true;
- this.Focus();
- }
- private void Form1_Resize(object sender, EventArgs e)
- {
- if(this.WindowState == FormWindowState.Minimized)
- {
- notifyIcon1.Visible = true;
- notifyIcon1.Icon = this.Icon;
- this.Visible = false;
- notifyIcon1.ShowBalloonTip(3000, "RPT Maint Check", "I will be running in the background for you.", ToolTipIcon.Info);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment