Click here to Skip to main content
15,886,788 members
Articles / Programming Languages / C#

dotNETSender - Windows Messenger like GUI for net send command

Rate me:
Please Sign up or sign in to vote.
3.61/5 (19 votes)
7 May 20021 min read 287.7K   7K   92  
Windows Messenger like GUI for net send command
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace dotNETSender
{
	/// <summary>
	/// Summary description for SendDialog.
	/// </summary>
	public class SendDialog : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TextBox txMessage;
		private System.Windows.Forms.Button btSend;
		private System.Windows.Forms.Button btCancel;
		private Contact ct = new Contact();
		public System.Windows.Forms.StatusBar sbSendDlg;
		private System.Windows.Forms.ToolTip toolTipSend;
		private System.ComponentModel.IContainer components;

		public SendDialog(Contact contact)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			this.ct = contact;
			toolTipSend.SetToolTip(btSend,"Send Message");
			toolTipSend.SetToolTip(btCancel,"Cancel");
			this.Text += " to " +(string)contact.SystemName;
			//
			// 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(SendDialog));
			this.txMessage = new System.Windows.Forms.TextBox();
			this.btSend = new System.Windows.Forms.Button();
			this.btCancel = new System.Windows.Forms.Button();
			this.sbSendDlg = new System.Windows.Forms.StatusBar();
			this.toolTipSend = new System.Windows.Forms.ToolTip(this.components);
			this.SuspendLayout();
			// 
			// txMessage
			// 
			this.txMessage.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txMessage.Location = new System.Drawing.Point(8, 8);
			this.txMessage.Multiline = true;
			this.txMessage.Name = "txMessage";
			this.txMessage.Size = new System.Drawing.Size(288, 40);
			this.txMessage.TabIndex = 0;
			this.txMessage.Text = "";
			// 
			// btSend
			// 
			this.btSend.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btSend.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.btSend.Image = ((System.Drawing.Bitmap)(resources.GetObject("btSend.Image")));
			this.btSend.Location = new System.Drawing.Point(304, 8);
			this.btSend.Name = "btSend";
			this.btSend.Size = new System.Drawing.Size(40, 40);
			this.btSend.TabIndex = 1;
			this.btSend.Click += new System.EventHandler(this.btSend_Click);
			// 
			// btCancel
			// 
			this.btCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btCancel.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btCancel.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.btCancel.Image = ((System.Drawing.Bitmap)(resources.GetObject("btCancel.Image")));
			this.btCancel.Location = new System.Drawing.Point(352, 8);
			this.btCancel.Name = "btCancel";
			this.btCancel.Size = new System.Drawing.Size(40, 40);
			this.btCancel.TabIndex = 2;
			// 
			// sbSendDlg
			// 
			this.sbSendDlg.Dock = System.Windows.Forms.DockStyle.None;
			this.sbSendDlg.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.sbSendDlg.Location = new System.Drawing.Point(8, 52);
			this.sbSendDlg.Name = "sbSendDlg";
			this.sbSendDlg.Size = new System.Drawing.Size(384, 16);
			this.sbSendDlg.TabIndex = 3;
			this.sbSendDlg.Text = "Ready";
			this.sbSendDlg.TextChanged += new System.EventHandler(this.sbSendDlg_TextChanged);
			// 
			// SendDialog
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(402, 71);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.sbSendDlg,
																		  this.btCancel,
																		  this.btSend,
																		  this.txMessage});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.Name = "SendDialog";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "Send Message";
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// Sends the net send.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btSend_Click(object sender, System.EventArgs e)
		{
			btSend.Enabled = false;
			NetSender senderob = new NetSender(this,ct);
			senderob.NetSend(txMessage.Text);
		}

		/// <summary>
		/// On chnge of text, enable the send button
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void sbSendDlg_TextChanged(object sender, System.EventArgs e)
		{
			if (sbSendDlg.Text != "Sending message...")
			{
				this.btSend.Enabled = true;		
			}
		}
	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect Siemens
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions