private void btnProgramMCU_Click(object sender, EventArgs e)
        {
            string HexFileName=txtHexFileName.Text.Trim();
            if(HexFileName==String.Empty)
            {
            MessageBox.Show("No File Specified!",FRM_TITLE,MessageBoxButtons.OK,MessageBoxIcon.Error);
            return;
            }

            txtStatus.Clear();
            string SelectedItem=cmbDevice.SelectedItem.ToString().Trim();
            if(SelectedItem==STR_PIC18F24J50)
            {
            PIC18F2xJxx p=new PIC18F2xJxx(myPIC18Program);
            txtStatus.AppendText("Starting Erase!\r\n");
            Application.DoEvents();
            if(p.Erase()==true)
                txtStatus.AppendText("Erase Operation Done!\r\n");
            else
                {
                txtStatus.AppendText("Erase Operation Unsuccessful!");
                return;
                }

            txtStatus.AppendText("Starting to Program! Please wait...\r\n");
            Application.DoEvents();
            if(p.Program(HexFileName,txtStatus)==true)
                txtStatus.AppendText("Program Operation Done!");
            else
                {
                txtStatus.AppendText("Program Operation Unsuccessful!");
                return;
                }
            }
            else
            {
            txtStatus.AppendText("Device Unknown!");
            }
        }
 private void btnReadDevID_Click(object sender, EventArgs e)
 {
     txtStatus.Clear();
     string SelectedItem=cmbDevice.SelectedItem.ToString().Trim();
     if(SelectedItem==STR_PIC18F24J50)
     {
     PIC18F2xJxx p=new PIC18F2xJxx(myPIC18Program);
     txtStatus.AppendText("Starting Read Dev ID...\r\n");
     Application.DoEvents();
     ulong ? Result=p.ReadDeviceID();
     if(Result==null)
         txtStatus.AppendText("Error Reading Device ID!");
     else
         {
         if((Result&0xFFE0)==0x4C00)
             {
             string temp=String.Format("Found PIC18F24J50 Device ID: 0x{0:x4} Revision {1}",Result&0xFFE0,Result&0x1F);
             txtStatus.AppendText(temp);
             }
         else
             txtStatus.AppendText("Device Unknown!");
         }
     }
     else
     {
     txtStatus.AppendText("Device Unknown!");
     }
 }
 private void btnErase_Click(object sender, EventArgs e)
 {
     //StringBuilder strResult=new StringBuilder();
     txtStatus.Clear();
     string SelectedItem=cmbDevice.SelectedItem.ToString().Trim();
     if(SelectedItem==STR_PIC18F24J50)
     {
     PIC18F2xJxx p=new PIC18F2xJxx(myPIC18Program);
     txtStatus.AppendText("Starting Erase...\r\n");
     Application.DoEvents();
     if(p.Erase()==true)
         txtStatus.AppendText("Erase Operation Done!");
     else
         txtStatus.AppendText("Erase Operation Unsuccessful!");
     }
     else
     {
     txtStatus.AppendText("Device Unknown!");
     }
 }