/*********************************END*************************************************/

/*********************************GUI_EVENTS***********************************************/
        private void numericUpDownDBS_ValueChanged(object sender, EventArgs e)
        {
            HexEdit.SetSize(HexEdit.RowCount, (int)this.numericUpDownDBS.Value, BnkIdx);
        }
 private void comboBoxBank_SelectedIndexChanged(object sender, EventArgs e)
 {
     BnkIdx = (int)this.comboBoxBank.SelectedIndex;
     HexEdit.SetSize(HexEdit.RowCount, (int)this.numericUpDownDBS.Value, BnkIdx);
 }
        public ISOHostSample()
        {
            try
            {
                fedm = new FedmIscReader();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), "Error");
            }

            //declaration from Thread
            Thread MyThread = new Thread(new ThreadStart(ReadThread));

            fedm.SetTableSize(FedmIscReaderConst.ISO_TABLE, 128);

            config = new PortConnection();
            config.PortConfig(ref fedm);
            DialogResult reponse = config.ShowDialog();


            if (fedm.Connected == true)
            {
                try
                {
                    fedm.ReadCompleteConfiguration(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.ToString(), "Error");
                }
                // set Persistence Reset Time in Reader Configuration to zero
                // this speeds up inventory cycles
                int back = OBID.Fedm.ERROR_UNSUPPORTED_NAMESPACE;
                try
                {
                    back = fedm.TestConfigPara(OBID.ReaderConfig.Transponder.PersistenceReset.Antenna.No1.PersistenceResetTime);
                }
                catch (Exception ex)
                { // ignore Exception
                }
                // if reader supports this parameter, set it !
                if (0 == back)
                {
                    try
                    {
                        back = fedm.GetConfigPara(OBID.ReaderConfig.Transponder.PersistenceReset.Antenna.No1.PersistenceResetTime, out persistenceResetTime, false);
                        back = fedm.SetConfigPara(OBID.ReaderConfig.Transponder.PersistenceReset.Antenna.No1.PersistenceResetTime, (uint)0, false);
                        if (back == 1) // return value 1 indicates modified parameter
                        {
                            back = fedm.ApplyConfiguration(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, ex.ToString(), "Error");
                    }
                }
            }

            // Init Dialogs Authent
            authmifare_config = new AuthentMifare(this.fedm);
            authmyd_config    = new AuthentMYD(this.fedm);

            if (fedm.Connected == true && reponse == DialogResult.Cancel)
            {
                InitializeComponent();

                //set read Mode
                this.comboBoxMod.SelectedIndex = 1;

                //set bank for UHF
                this.comboBoxBank.SelectedIndex = 3;
                this.comboBoxBank.Enabled       = false;

                // set blockSize
                this.numericUpDownDBS.Minimum   = 1;
                this.numericUpDownDBS.Maximum   = 256;
                this.numericUpDownDBS.Increment = 1;
                this.numericUpDownDBS.Value     = 4;

                // set the number of blocks
                this.numericUpDownDBN.Minimum   = 1;
                this.numericUpDownDBN.Maximum   = 256;
                this.numericUpDownDBN.Increment = 1;
                this.numericUpDownDBN.Value     = 1;

                // set status of Authent Buttons
                this.button_Authent_myd.Enabled   = false;
                this.button_AuthentMifare.Enabled = false;

                this.checkBoxEnable.Checked = true;

                //Registry from Events send and receive
                fedm.AddEventListener(this, FeIscListenerConst.SEND_STRING_EVENT);
                fedm.AddEventListener(this, FeIscListenerConst.RECEIVE_STRING_EVENT);

                //Init from  TextEditor
                HexEdit.SetSize(128, 4, BnkIdx);

                //Thread starten in Background
                running = false;
                MyThread.IsBackground = true;
                MyThread.Start();
            }
            else
            {
                config.ShowDialog();
            }
        }