Guest User

Untitled

a guest
Dec 9th, 2015
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12. namespace RPTMaintenance
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         Maintenance maint;
  17.  
  18.         public Form1()
  19.         {
  20.             InitializeComponent();
  21.  
  22.             maint = new Maintenance();
  23.             maint.Init();
  24.         }
  25.  
  26.         private void button1_Click(object sender, EventArgs e)
  27.         {
  28.             // start checking.
  29.             System.Threading.Timer T = new System.Threading.Timer(new TimerCallback(TimerEvent), null, 0, 120000);
  30.                        
  31.  
  32.  
  33.             notifyIcon1.Visible = true;
  34.             notifyIcon1.Icon = this.Icon;
  35.  
  36.             this.Visible = false;
  37.             notifyIcon1.ShowBalloonTip(3000, "RPT Maint Check", "I will be running in the background for you.", ToolTipIcon.Info);
  38.         }
  39.  
  40.         private void TimerEvent(object state)
  41.         {
  42.             // set maintenance
  43.             maint.SetMaintenance();
  44.  
  45.             if(maint.ShouldIBeHappy())
  46.             {
  47.                 MessageBox.Show("Hey! Server is online now!", "Finally",MessageBoxButtons.OK, MessageBoxIcon.Information);
  48.             }
  49.             else
  50.             {
  51.                 MessageBox.Show("no");
  52.             }
  53.  
  54.         }
  55.  
  56.         private void notifyIcon1_Click(object sender, EventArgs e)
  57.         {
  58.             notifyIcon1.Visible = false;
  59.             this.Visible = true;
  60.             this.Focus();
  61.         }
  62.  
  63.         private void Form1_Resize(object sender, EventArgs e)
  64.         {
  65.             if(this.WindowState == FormWindowState.Minimized)
  66.             {
  67.                 notifyIcon1.Visible = true;
  68.                 notifyIcon1.Icon = this.Icon;
  69.  
  70.                 this.Visible = false;
  71.                 notifyIcon1.ShowBalloonTip(3000, "RPT Maint Check", "I will be running in the background for you.", ToolTipIcon.Info);
  72.             }
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment