Click here to Skip to main content
15,894,896 members
Articles / Programming Languages / C#

Message queuing: A message notification system and a brief introduction

Rate me:
Please Sign up or sign in to vote.
2.20/5 (3 votes)
21 Aug 2007CPOL3 min read 24.1K   177   14  
A simple application which can be a used for furture expansion and also an introcudtion to MSMQ.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Diagnostics;

namespace MessageNotification.NotifyIcon
{
	public class Rubbish2 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.ContextMenu contextMenu1;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.ContextMenu contextMenu2;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.Button button2;
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.MenuItem menuItem2;
		Icon iconRay = new Icon("E:\\WorkSpaces\\MessageNotification\\MIS.ico");


		public Rubbish2()
		{
			InitializeComponent();
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 
		private void InitializeComponent()
		{
			this.button1 = new System.Windows.Forms.Button();
			this.contextMenu1 = new System.Windows.Forms.ContextMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.contextMenu2 = new System.Windows.Forms.ContextMenu();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.button2 = new System.Windows.Forms.Button();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(53, 45);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(62, 21);
			this.button1.TabIndex = 0;
			this.button1.Text = "button1";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// contextMenu1
			// 
			this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						 this.menuItem1,
																						 this.menuItem2,
																						 this.menuItem3});
			this.contextMenu1.Popup += new System.EventHandler(this.contextMenu1_Popup);
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.Text = "Open Rayvarz eOffice";
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 2;
			this.menuItem3.Text = "Exite";
			this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
			// 
			// contextMenu2
			// 
			this.contextMenu2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						 this.menuItem4});
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 0;
			this.menuItem4.Text = "menu2";
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(53, 104);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(63, 21);
			this.button2.TabIndex = 4;
			this.button2.Text = "button2";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 1;
			this.menuItem2.Text = "-";
			// 
			// Rubbish2
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(242, 252);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Name = "Rubbish2";
			this.Text = "Form1";
			this.Closed += new System.EventHandler(this.Form1_Closed);
			this.ResumeLayout(false);

		}
		#endregion

//		[STAThread]
//		static void Main() 
//		{
//			Application.Run(new Form1());
//		}

		private void GetPoc1(MouseButtons mb) {	//delegate for callback
			if (mb == MouseButtons.Left) {
				///////////////////////////////Icon   LEFT CLICK AREA
				//MessageBox.Show("icon1");
			}
		}
		private MessageNotification.NotifyIcon.Rubbish1 o1 = MessageNotification.NotifyIcon.Rubbish1.Instance();
		public void button1_Click(object sender, System.EventArgs e) {
			o1.AddNotifyBox(this.iconRay.Handle,this.Text,"title","body");
			o1.ConnectMyMenu(this.Handle,this.contextMenu1.Handle);	// add mymenu
			o1._delegateOfCallBack = new MessageNotification.NotifyIcon.Rubbish1.delegateOfCallBack(GetPoc1);	//const callback
		}
		public void notice(string title,string body)
		{
			o1.DelNotifyBox();
			o1.AddNotifyBox(this.iconRay.Handle,this.Text,title,body);
			o1.ConnectMyMenu(this.Handle,this.contextMenu1.Handle);	// add mymenu
			o1._delegateOfCallBack = new MessageNotification.NotifyIcon.Rubbish1.delegateOfCallBack(GetPoc1);	//const callback
			
		}
		private void GetPoc2(MouseButtons mb) {
			if (mb == MouseButtons.Left) {
				Form1 frm1 = new Form1();
				frm1.Visible = true;
				frm1.Focus();
			}
		}
		private MessageNotification.NotifyIcon.Rubbish1 o2 = MessageNotification.NotifyIcon.Rubbish1.Instance();
		private void button2_Click(object sender, System.EventArgs e) {	// copy from button1_Click, ;-)

			o2.AddNotifyBox(this.Icon.Handle,this.Text,"icon1","click to start,click to startclick to start\rclick to start");
			o2.ConnectMyMenu(this.Handle,this.contextMenu2.Handle);
			o2._delegateOfCallBack = new MessageNotification.NotifyIcon.Rubbish1.delegateOfCallBack(GetPoc2);
			
		}

		private void menuItem3_Click(object sender, System.EventArgs e) {
			o1.DelNotifyBox();
			this.Close();
		}

		private void Form1_Closed(object sender, System.EventArgs e) {
			o1.DelNotifyBox();
			o2.DelNotifyBox();
			
		}

		private void contextMenu1_Popup(object sender, System.EventArgs e)
		{
		
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Iran (Islamic Republic of) Iran (Islamic Republic of)
I Hate Programming But I Have To Come Up With It .

Comments and Discussions