using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.IO; using System.Text; using System.Text.RegularExpressions; using System.Threading; namespace WindowsApplication1 { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label10; private System.Windows.Forms.Button button1; string fileName=null; private System.Windows.Forms.Label label11; private System.Windows.Forms.Button button2; string line=null; string output=null; int lines=0; string temp2=null; int i=1; int three=0; string[] final=null; string[] finalOutput1=null; string[] finalOutput=null; int length=0; string inputLine=null; string whichDataAddress=null; private System.Windows.Forms.Label label12; private System.Windows.Forms.Button button3; string fileToWrite=null; private System.Windows.Forms.RichTextBox poorTextBox9; private System.Windows.Forms.RichTextBox poorTextBox11; private System.Windows.Forms.Button button4; int labelx=8; int richTextBoxx=184; int y=104; int checkBoxLocationX=368; int checkBoxLocationY=448; Label label; RichTextBox richTextBox; CheckBox checkBox; int noOfForLoop=0; private System.Windows.Forms.Label label2; int noOfTextBoxes=0; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.poorTextBox9 = new System.Windows.Forms.RichTextBox(); this.button1 = new System.Windows.Forms.Button(); this.label11 = new System.Windows.Forms.Label(); this.button2 = new System.Windows.Forms.Button(); this.label12 = new System.Windows.Forms.Label(); this.poorTextBox11 = new System.Windows.Forms.RichTextBox(); this.button3 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 // this.label1.Font = new System.Drawing.Font("Comic Sans MS", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label1.Location = new System.Drawing.Point(128, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(688, 56); this.label1.TabIndex = 0; this.label1.Text = "The Code That Works, like the degree that works ;)"; // // label10 // this.label10.Font = new System.Drawing.Font("Comic Sans MS", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label10.Location = new System.Drawing.Point(360, 96); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(200, 40); this.label10.TabIndex = 17; this.label10.Text = "The file to be opened is:-"; // // poorTextBox9 // this.poorTextBox9.Location = new System.Drawing.Point(632, 96); this.poorTextBox9.Name = "poorTextBox9"; this.poorTextBox9.Size = new System.Drawing.Size(328, 32); this.poorTextBox9.TabIndex = 18; this.poorTextBox9.Text = ""; this.poorTextBox9.KeyDown += new System.Windows.Forms.KeyEventHandler(this.poorTextBox9_KeyDown); // // button1 // this.button1.Font = new System.Drawing.Font("Comic Sans MS", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button1.Location = new System.Drawing.Point(824, 136); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(136, 40); this.button1.TabIndex = 19; this.button1.Text = "File Browser!"; this.button1.Click += new System.EventHandler(this.button1_Click); // // label11 // this.label11.Font = new System.Drawing.Font("Comic Sans MS", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label11.Location = new System.Drawing.Point(368, 344); this.label11.Name = "label11"; this.label11.Size = new System.Drawing.Size(416, 72); this.label11.TabIndex = 20; this.label11.Text = "Please mention which Data Address/Addresses have been changed (Please remember th" + "at you can change multiple values at a time if you wish)."; // // button2 // this.button2.Font = new System.Drawing.Font("Comic Sans MS", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button2.Location = new System.Drawing.Point(816, 496); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(144, 32); this.button2.TabIndex = 22; this.button2.Text = "Update the file!"; this.button2.Click += new System.EventHandler(this.button2_Click); // // label12 // this.label12.Font = new System.Drawing.Font("Comic Sans MS", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label12.Location = new System.Drawing.Point(360, 208); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(408, 80); this.label12.TabIndex = 23; this.label12.Text = "The file in which you wish to store new information(Please remember mentioning of" + " an already exisiting file would overwrite that file):-"; // // poorTextBox11 // this.poorTextBox11.Location = new System.Drawing.Point(784, 224); this.poorTextBox11.Name = "poorTextBox11"; this.poorTextBox11.Size = new System.Drawing.Size(176, 32); this.poorTextBox11.TabIndex = 24; this.poorTextBox11.Text = ""; // // button3 // this.button3.Font = new System.Drawing.Font("Comic Sans MS", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button3.Location = new System.Drawing.Point(824, 272); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(144, 40); this.button3.TabIndex = 25; this.button3.Text = "File Browser!"; this.button3.Click += new System.EventHandler(this.button3_Click); // // button4 // this.button4.Font = new System.Drawing.Font("Comic Sans MS", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.button4.Location = new System.Drawing.Point(376, 576); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(152, 40); this.button4.TabIndex = 26; this.button4.Text = "Exit!"; this.button4.Click += new System.EventHandler(this.button4_Click); // // label2 // this.label2.Font = new System.Drawing.Font("Comic Sans MS", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label2.ForeColor = System.Drawing.Color.Red; this.label2.Location = new System.Drawing.Point(368, 160); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(448, 23); this.label2.TabIndex = 27; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.AutoScroll = true; this.ClientSize = new System.Drawing.Size(941, 580); this.Controls.Add(this.label2); this.Controls.Add(this.button4); this.Controls.Add(this.button3); this.Controls.Add(this.poorTextBox11); this.Controls.Add(this.label12); this.Controls.Add(this.button2); this.Controls.Add(this.label11); this.Controls.Add(this.button1); this.Controls.Add(this.poorTextBox9); this.Controls.Add(this.label10); this.Controls.Add(this.label1); this.Name = "Form1"; this.Text = "MIT Lincoln DataSet Parsing Code (Beta Version -- Still Work in Progress on this " + "application)"; this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } /*This method basically is the event handler for the button that chooses which file do we need to parse * and eventually modify.*/ private void button1_Click(object sender, System.EventArgs e) { OpenFileDialog fileChooser=new OpenFileDialog(); //Opens the file dialog DialogResult result=fileChooser.ShowDialog(); //Checks the result, if the user hit a OK or Cancel if (result == DialogResult.Cancel) return; fileName=fileChooser.FileName; //Storing the filename of the file choosen by the user in the file dialog if (fileName == "" || fileName==null) //Checking if the filename is not empty MessageBox.Show("Invalid File Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); poorTextBox9.Text=fileChooser.FileName; //Showing the filename of the file choosen by the user in the textBox. /*This loop basically removes the labels, textboxes, and checkboxes so that if a new file is choosen by * the user has less values or more, it can be adjusted with*/ for(int o=0;o=lines) break; temp2 += finalOutput[(8*i)+(three*3)]+" "; //This is the formula I use to acess specific entres for the destination address. i++;three++; } finalOutput1=null; finalOutput1 = temp2.Split(new char[] {' '}); //now we parse the string that contains all the destination addresses. temp2=null; //The following loop is used to remove the duplicates and only capture the distinct value for (int z=0; z=lines) break; if (finalOutput1[i]!=null) temp2 += finalOutput1[i]+" "; i++; } final=null; final = temp2.Split(new char[] {' '}); length=0; length=final.Length; length=length-2; labelx=8; richTextBoxx=184; y=104; checkBoxLocationX=368; checkBoxLocationY=448; noOfForLoop=0; /*This loop basically creates as many textboxes, checkboxes and label as many distinct values are * there in the file that had been parsed. Specific to the object being created, I have intialised * some specific properties of theirs to make sure user interface looks right.*/ for (int inner=0; inner