using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.Net;
using System.Net.Sockets;
namespace hyperT
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
private System.Windows.Forms.StatusBarPanel statusBarPanel2;
private System.Windows.Forms.StatusBarPanel statusBarPanel3;
private System.Windows.Forms.StatusBarPanel statusBarPanel4;
private System.Windows.Forms.StatusBarPanel statusBarPanel5;
private System.Windows.Forms.StatusBarPanel statusBarPanel6;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.ToolBarButton toolBarButton1;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.ToolBarButton toolBarButton2;
private System.Windows.Forms.ToolBarButton toolBarButton3;
private System.Windows.Forms.ToolBarButton toolBarButton4;
private System.ComponentModel.IContainer components;
private AxMSCommLib.AxMSComm axMSComm1;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.LinkLabel linkLabel2;
Form2 f2= new Form2();
public static string rem="",total,fin,t1,ht,t2="";
private System.Windows.Forms.MenuItem menuItem7;
public static string hex;
public Form1()
{
//
// 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(Form1));
this.panel1 = new System.Windows.Forms.Panel();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel4 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel5 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel6 = new System.Windows.Forms.StatusBarPanel();
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.axMSComm1 = new AxMSCommLib.AxMSComm();
this.linkLabel2 = new System.Windows.Forms.LinkLabel();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel5)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel6)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.axMSComm1)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panel1.Controls.Add(this.richTextBox1);
this.panel1.Controls.Add(this.linkLabel1);
this.panel1.Location = new System.Drawing.Point(0, 32);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(488, 216);
this.panel1.TabIndex = 1;
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(0, 0);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(472, 208);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);
//
// linkLabel1
//
this.linkLabel1.Location = new System.Drawing.Point(168, 32);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.TabIndex = 6;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "linkLabel1";
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2,
this.menuItem3,
this.menuItem4,
this.menuItem5});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem6});
this.menuItem1.Text = "File";
//
// menuItem6
//
this.menuItem6.Index = 0;
this.menuItem6.Text = "Exit";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.Text = "Edit";
//
// menuItem3
//
this.menuItem3.Index = 2;
this.menuItem3.Text = "View";
//
// menuItem4
//
this.menuItem4.Index = 3;
this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem7});
this.menuItem4.Text = "Call";
//
// menuItem7
//
this.menuItem7.Index = 0;
this.menuItem7.Text = "Connect";
//
// menuItem5
//
this.menuItem5.Index = 4;
this.menuItem5.Text = "";
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 251);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusBarPanel1,
this.statusBarPanel2,
this.statusBarPanel3,
this.statusBarPanel4,
this.statusBarPanel5,
this.statusBarPanel6});
this.statusBar1.ShowPanels = true;
this.statusBar1.Size = new System.Drawing.Size(478, 22);
this.statusBar1.TabIndex = 3;
//
// statusBarPanel1
//
this.statusBarPanel1.Text = "Disconnected";
//
// statusBarPanel2
//
this.statusBarPanel2.Text = "Auto Detect";
//
// statusBarPanel3
//
this.statusBarPanel3.Text = "9600,n,8,1";
//
// statusBarPanel4
//
this.statusBarPanel4.Text = "SCROLL";
//
// statusBarPanel5
//
this.statusBarPanel5.Text = "CAPS";
//
// statusBarPanel6
//
this.statusBarPanel6.Text = "NUM";
//
// toolBar1
//
this.toolBar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton1,
this.toolBarButton2,
this.toolBarButton3,
this.toolBarButton4});
this.toolBar1.DropDownArrows = true;
this.toolBar1.ImageList = this.imageList1;
this.toolBar1.Location = new System.Drawing.Point(0, 0);
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(478, 29);
this.toolBar1.TabIndex = 4;
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
//
// toolBarButton1
//
this.toolBarButton1.ImageIndex = 2;
this.toolBarButton1.ToolTipText = "New";
//
// toolBarButton2
//
this.toolBarButton2.ImageIndex = 1;
this.toolBarButton2.ToolTipText = "Connect";
//
// toolBarButton3
//
this.toolBarButton3.ImageIndex = 0;
this.toolBarButton3.ToolTipText = "Disconnect";
//
// toolBarButton4
//
this.toolBarButton4.ImageIndex = 3;
this.toolBarButton4.ToolTipText = "properties";
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// axMSComm1
//
this.axMSComm1.Enabled = true;
this.axMSComm1.Location = new System.Drawing.Point(432, 0);
this.axMSComm1.Name = "axMSComm1";
this.axMSComm1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMSComm1.OcxState")));
this.axMSComm1.Size = new System.Drawing.Size(38, 38);
this.axMSComm1.TabIndex = 5;
this.axMSComm1.OnComm += new System.EventHandler(this.axMSComm1_OnComm);
//
// linkLabel2
//
this.linkLabel2.Location = new System.Drawing.Point(128, 8);
this.linkLabel2.Name = "linkLabel2";
this.linkLabel2.Size = new System.Drawing.Size(80, 16);
this.linkLabel2.TabIndex = 6;
this.linkLabel2.TabStop = true;
this.linkLabel2.Text = "Send";
this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(478, 273);
this.Controls.Add(this.linkLabel2);
this.Controls.Add(this.axMSComm1);
this.Controls.Add(this.toolBar1);
this.Controls.Add(this.statusBar1);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "HyperTerminal";
this.Load += new System.EventHandler(this.Form1_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel5)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel6)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.axMSComm1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch (toolBar1.Buttons.IndexOf(e.Button))
{
case 0 :
richTextBox1.Text="";
rem="";
t2="";
break;
case 1 :
if(Form2.port!="TCP/IP(Winsock)")
{
if (axMSComm1.PortOpen)
{
axMSComm1.PortOpen = false;
}
try
{
short pp=short.Parse(Form2.port);
axMSComm1.CommPort=pp;
axMSComm1.Settings="9600,N,8,1";
}
catch(Exception ex)
{
MessageBox.Show("Please Enter Port No:");
break;
}
try
{
axMSComm1.PortOpen=true;
}
catch(Exception te)
{
MessageBox.Show("Open failed");
}
if(axMSComm1.PortOpen!=true)
{
MessageBox.Show("Port does not exist");
}
else
{
statusBarPanel1.Text="Connect";
}
}
else
{
MessageBox.Show("Unable to connect to IPaddress:" +Form2.ip+" & port no:"+Form2.pno+"");
}
break;
case 2 :
axMSComm1.PortOpen = false;
statusBarPanel1.Text="Disconnected";
break;
case 3 :
f2.ShowDialog();
break;
}
}
private void menuItem6_Click(object sender, System.EventArgs e)
{
Close();
}
private void axMSComm1_OnComm(object sender, System.EventArgs e)
{
}
private void linkLabel2_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
t1="";
for(int i=0;i<richTextBox1.Text.Length;i++)
{
string fi=richTextBox1.Text.Substring(i,1);
if(fi=="\n"||fi==" "||fi=="\r")
{
}
else
{
t1+=fi;
}
}
int t=t1.Length-t2.Length;
string total=t1.Substring(t2.Length,t);
try
{
axMSComm1.Output=total;
Thread.Sleep(200);
}
catch(Exception ex)
{
MessageBox.Show("Serial communication Error");
}
try
{
string r= axMSComm1.Input.ToString();
richTextBox1.Text+=r;
}
catch(Exception ie){
MessageBox.Show(ie.Message);
}
rem=richTextBox1.Text;
t2="";
for(int j=0;j<rem.Length;j++)
{
string f1=rem.Substring(j,1);
if(f1=="\n"||f1==" "||f1=="\r")
{
}
else
{
t2+=f1;
}
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
rem=richTextBox1.Text;
}
private void richTextBox1_TextChanged(object sender, System.EventArgs e)
{
}
}
}