187 lines
4.9 KiB
C#
187 lines
4.9 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using System.Windows.Forms;
|
|
using System.Data;
|
|
using GZTW.AyaNova.BLL;
|
|
|
|
|
|
namespace NotifyTray
|
|
{
|
|
/// <summary>
|
|
/// Summary description for MainForm.
|
|
/// </summary>
|
|
public class MainForm : System.Windows.Forms.Form
|
|
{
|
|
private System.Timers.Timer timer1;
|
|
private System.Windows.Forms.NotifyIcon TrayIcon;
|
|
private System.Windows.Forms.ContextMenu TrayMenu;
|
|
private System.Windows.Forms.MenuItem menuExit;
|
|
private System.ComponentModel.IContainer components;
|
|
|
|
public MainForm()
|
|
{
|
|
//
|
|
// Required for Windows Form Designer support
|
|
//
|
|
InitializeComponent();
|
|
|
|
//
|
|
// TODO: Add any constructor code after InitializeComponent call
|
|
//
|
|
}
|
|
|
|
/// <summary>
|
|
/// Clean up any resources being used.
|
|
/// </summary>
|
|
protected override void Dispose( bool disposing )
|
|
{
|
|
if( disposing )
|
|
{
|
|
if (components != null)
|
|
{
|
|
components.Dispose();
|
|
}
|
|
}
|
|
base.Dispose( disposing );
|
|
}
|
|
|
|
#region Windows Form Designer generated code
|
|
/// <summary>
|
|
/// Required method for Designer support - do not modify
|
|
/// the contents of this method with the code editor.
|
|
/// </summary>
|
|
private void InitializeComponent()
|
|
{
|
|
this.components = new System.ComponentModel.Container();
|
|
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
|
|
this.timer1 = new System.Timers.Timer();
|
|
this.TrayIcon = new System.Windows.Forms.NotifyIcon(this.components);
|
|
this.TrayMenu = new System.Windows.Forms.ContextMenu();
|
|
this.menuExit = new System.Windows.Forms.MenuItem();
|
|
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
|
|
//
|
|
// timer1
|
|
//
|
|
this.timer1.Interval = 500;
|
|
this.timer1.SynchronizingObject = this;
|
|
this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
|
|
//
|
|
// TrayIcon
|
|
//
|
|
this.TrayIcon.ContextMenu = this.TrayMenu;
|
|
this.TrayIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("TrayIcon.Icon")));
|
|
this.TrayIcon.Text = "Processing...";
|
|
this.TrayIcon.Visible = true;
|
|
//
|
|
// TrayMenu
|
|
//
|
|
this.TrayMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
|
this.menuExit});
|
|
//
|
|
// menuExit
|
|
//
|
|
this.menuExit.Index = 0;
|
|
this.menuExit.Text = "E&xit";
|
|
this.menuExit.Click += new System.EventHandler(this.menuExit_Click);
|
|
//
|
|
// MainForm
|
|
//
|
|
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
|
this.ClientSize = new System.Drawing.Size(396, 23);
|
|
this.MinimumSize = new System.Drawing.Size(404, 47);
|
|
this.Name = "MainForm";
|
|
this.ShowInTaskbar = false;
|
|
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
|
|
this.Resize += new System.EventHandler(this.MainForm_Resize);
|
|
this.Load += new System.EventHandler(this.MainForm_Load);
|
|
((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
|
|
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// The main entry point for the application.
|
|
/// </summary>
|
|
[STAThread]
|
|
static void Main()
|
|
{
|
|
Application.Run(new MainForm());
|
|
}
|
|
|
|
// __ _ _ ___ ____ __ __ __ __ __ ___ ___
|
|
// / _)( )( )/ __)(_ _)/ \( \/ ) / _)/ \( \( _)
|
|
// ( (_ )()( \__ \ )( ( () )) ( ( (_( () )) ) )) _)
|
|
// \__) \__/ (___/ (__) \__/(_/\/\_) \__)\__/(___/(___)
|
|
//
|
|
|
|
|
|
private void MainForm_Load(object sender, System.EventArgs e)
|
|
{
|
|
GZTW.AyaNova.BLL.AyaBizUtils.Initialize();
|
|
timer1.Start();
|
|
|
|
}
|
|
|
|
private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
|
{
|
|
timer1.Stop();
|
|
this.Hide();
|
|
//Cursor.Current = Cursors.WaitCursor;
|
|
|
|
#if (DEBUG)
|
|
//testing interval (30 seconds)
|
|
timer1.Interval=30000;
|
|
#else
|
|
//5 minutes
|
|
timer1.Interval=300000;
|
|
#endif
|
|
|
|
|
|
this.TrayIcon.Text="Processing deliveries....";
|
|
|
|
//PROCESS NOTIFICATIONS
|
|
|
|
GenProcess.GO("121605GENERATOR", "121605GENERATOR");
|
|
this.TrayIcon.Text = "Last run: " + DateTime.Now.ToString();
|
|
|
|
|
|
|
|
//Cursor.Current = Cursors.Default;
|
|
timer1.Start();
|
|
}
|
|
|
|
//private Exception GetInnerMostException(Exception ex)
|
|
//{
|
|
// Exception exRet = ex;
|
|
// while (exRet.InnerException != null)
|
|
// {
|
|
// exRet = exRet.InnerException;
|
|
// }
|
|
|
|
// return exRet;
|
|
//}
|
|
private void menuExit_Click(object sender, System.EventArgs e)
|
|
{
|
|
this.TrayIcon.Visible=false;
|
|
Application.Exit();
|
|
}
|
|
|
|
private void MainForm_Resize(object sender, System.EventArgs e)
|
|
{
|
|
if (FormWindowState.Minimized == WindowState)
|
|
Hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//==================================================
|
|
|
|
}
|
|
}
|