// Constructor ( Copy style )
 public Source_MacRegion(
     Source_MacRegion source
 )
     : base()
 {
     this.Copy(source);
 }
        public bool Equals(Source_MacRegion rhs)
        {
            if (null == (System.Object)rhs)
            {
                return(false);
            }

            return(this.macRegion == rhs.macRegion);
        }
        // Constructor ( Copy style )

        public Source_MacRegion
        (
            Source_MacRegion source
        )
            :
            base()
        {
            this.Copy(source);
        }
        private void LoadRegion()
        {
            string                strCustomerRegion = "";
            ValueObject           CurrentRegion     = new ValueObject();
            ENUM_REGION_RESULT    enumMatch         = ENUM_REGION_RESULT.FAIL;
            rfid.Constants.Result result            = rfid.Constants.Result.OK;

            this.macRegion = new Source_MacRegion();
            result = macRegion.load(LakeChabotReader.MANAGED_ACCESS, this.reader.ReaderHandle);

            do
            {

                if (rfid.Constants.Result.OK != result)
                {
                    enumMatch = ENUM_REGION_RESULT.FAIL;
                    break;
                }

                //Push Data to list
                UInt32 shift = 1;
                foreach (rfid.Constants.MacRegion item in Enum.GetValues(typeof(rfid.Constants.MacRegion)))
                {
                    ValueObject vo = new ValueObject();

                    do
                    {
                        if ( (this.macRegion.MacRegionSupport & shift) <= 0 )
                            break;

                        //Add support region to regionComboBox.
                        if (item == rfid.Constants.MacRegion.CUSTOMER)//Customer region uses string.
                        {
                            result = reader.API_MacGetCustomerRegion( ref strCustomerRegion );

                            switch (result)
                            {
                                case rfid.Constants.Result.OK:
                                    vo.Name  = strCustomerRegion.ToString();
                                    vo.Value = Enum.Format( typeof(rfid.Constants.MacRegion), item, "d" );
                                    m_list.Add(vo);

                                    if (item == this.macRegion.MacRegion)
                                    {
                                        CurrentRegion = vo;
                                        enumMatch = ENUM_REGION_RESULT.OK;
                                    }
                                    break;

                                case rfid.Constants.Result.NOT_SUPPORTED:
                                    if (item == this.macRegion.MacRegion)
                                    {
                                        enumMatch = ENUM_REGION_RESULT.CUSTOMER_NON_SUPPORTED;
                                    }
                                    break;

                                case rfid.Constants.Result.FAILURE:
                                default:
                                    enumMatch = ENUM_REGION_RESULT.CUSTOMER_FAIL;
                                    break;
                            }

                        }
                        else
                        {
                            //Other region uses enum.
                            vo.Name  = item.ToString();
                            vo.Value = Enum.Format( typeof(rfid.Constants.MacRegion), item, "d" );
                            m_list.Add(vo);

                            //Check match region between support and current region setting.
                            if (item == this.macRegion.MacRegion)
                            {
                                CurrentRegion = vo;
                                enumMatch = ENUM_REGION_RESULT.OK;
                            }
                        }

                    }while(false);

                    shift <<= 0x01;
                }

            }while(false);

            switch (enumMatch)
            {
                case ENUM_REGION_RESULT.OK:
                    //Binding data
                    regionComboBox.DataSource    = m_list;
                    regionComboBox.DisplayMember = "Name";
                    regionComboBox.ValueMember   = "Value";

                    regionComboBox.SelectedIndex = regionComboBox.Items.IndexOf(CurrentRegion);
                    break;

                case ENUM_REGION_RESULT.FAIL:
                    RegionError("Read region unsuccessfully");
                    break;

                case ENUM_REGION_RESULT.CUSTOMER_NON_SUPPORTED:
                    RegionError("Not support customer region");
                    break;

                case ENUM_REGION_RESULT.CUSTOMER_FAIL:
                    RegionError("Get customer region unsuccessfully");
                    break;

                case ENUM_REGION_RESULT.NOT_MATCH:
                    RegionError("Region deosn't match \"RegionSupport\".");
                    break;
            }
        }
 public void Copy(Source_MacRegion from)
 {
     this.macRegion = from.macRegion;
 }
        public bool Equals(Source_MacRegion rhs)
        {
            if (null == (System.Object)rhs)
            {
                return false;
            }

            return this.macRegion == rhs.macRegion;
        }
 public void Copy(Source_MacRegion from)
 {
     this.macRegion = from.macRegion;
 }
        public ConfigureSettingsControl( LakeChabotReader reader )
        {
            if ( reader == null )
            {
                throw new ArgumentNullException( "reader", "Null reader passed to ConfigureGeneral CTOR()" );
            }

            if ( reader.Mode != rfidReader.OperationMode.BoundToReader )
            {
                throw new ArgumentOutOfRangeException( "reader", "Unbound reader passed to ConfigureGeneral()" );
            }

            InitializeComponent( );

            this.reader = reader;

            _timer           = new Timer( );
            _timer.Interval  = 5000;
            _timer.Tick     += new EventHandler( timer_Tick );

            string startupPowerState      = Properties.Settings.Default.startupPowerState;
            string startupOpMode          = Properties.Settings.Default.startupOperationalMode;
            int    startupAlgorithmNumber = Properties.Settings.Default.startupInventoryAlgorithm;

            rfid.Constants.Result result = rfid.Constants.Result.OK;

            //Interface radiobutton=============================================================
            UInt32 oemData = 0;
            rfid.Constants.Result status = reader.MacReadOemData( (ushort) enumOEM_ADDR.HOST_IF_SEL,
                                                                   ref     oemData                                );

            if (oemData == (uint)enumPORT.ENUM_PORT_USB)
            {
                rBtn_USB.Checked = true;
                rBtn_UART.Checked = false;
            }
            else
            {
                rBtn_USB.Checked = false;
                rBtn_UART.Checked = true;
            }

            // regionComboBox=============================================================
            ENUM_REGION_RESULT enumMatch = ENUM_REGION_RESULT.FAIL;

            this.macRegion = new Source_MacRegion();
            result = macRegion.load(LakeChabotReader.MANAGED_ACCESS, this.reader.ReaderHandle);

            do
            {
                if (rfid.Constants.Result.OK != result)
                {
                    enumMatch = ENUM_REGION_RESULT.FAIL;
                    break;
                }

                UInt32 shift = 1;

                foreach (rfid.Constants.MacRegion item in Enum.GetValues(typeof(rfid.Constants.MacRegion)))
                {

                    do
                    {
                        if ((this.macRegion.MacRegionSupport & shift) <= 0)
                            break;

                        //Add support region to regionComboBox.
                        if (item == rfid.Constants.MacRegion.CUSTOMER)//Customer region uses string.
                        {
                            result = reader.API_MacGetCustomerRegion( ref strCustomerRegion );

                            switch (result)
                            {
                                case rfid.Constants.Result.OK:
                                    regionComboBox.Items.Add(strCustomerRegion);

                                    if (item == this.macRegion.MacRegion)
                                    {
                                        enumMatch = ENUM_REGION_RESULT.CUSTOMER_OK;
                                    }
                                    break;

                                case rfid.Constants.Result.NOT_SUPPORTED:
                                    //Only hide the option.
                                    if (item == this.macRegion.MacRegion)
                                    {
                                        enumMatch = ENUM_REGION_RESULT.CUSTOMER_NON_SUPPORTED;
                                    }
                                    break;

                                case rfid.Constants.Result.FAILURE:
                                default:
                                    enumMatch = ENUM_REGION_RESULT.CUSTOMER_FAIL;
                                    break;
                            }

                        }
                        else
                        {
                            //Other region uses enum.
                            regionComboBox.Items.Add(item);

                            //Check match region between support and current region setting.
                            if (item == this.macRegion.MacRegion)
                            {
                                enumMatch = ENUM_REGION_RESULT.OK;
                            }
                        }

                    }while(false);

                    shift <<= 0x01;
                }

            }while(false);

            switch (enumMatch)
            {
                case ENUM_REGION_RESULT.OK:
                    regionComboBox.SelectedIndex = regionComboBox.Items.IndexOf(this.macRegion.MacRegion);
                    break;

                case ENUM_REGION_RESULT.FAIL:
                    RegionError("Read region unsuccessfully");
                    break;

                case ENUM_REGION_RESULT.CUSTOMER_OK:
                    //Customer region uses string.
                    regionComboBox.SelectedIndex = regionComboBox.Items.IndexOf(strCustomerRegion);
                    break;

                case ENUM_REGION_RESULT.CUSTOMER_NON_SUPPORTED:
                    RegionError("Not support customer region");
                    break;

                case ENUM_REGION_RESULT.CUSTOMER_FAIL:
                    RegionError("Get customer region fail");
                    break;

                case ENUM_REGION_RESULT.NOT_MATCH:
                    RegionError("Region deosn't match \"RegionSupport\".");
                    break;
            }

            // profileComboBox=============================================================
            this.profileList = new Source_LinkProfileList ( LakeChabotReader.MANAGED_ACCESS,
                                                            this.reader.ReaderHandle );

            this.profileList.load( );

            int count = 0;

            foreach ( Source_LinkProfile linkProfile in profileList )
            {
                profileComboBox.Items.Add( count + " : " + linkProfile.ToString( ) );

                ++ count;
            }

            profileComboBox.SelectedIndex = ( int ) profileList.getActiveProfileIndex( );

            this.profileComboBox.SelectedIndexChanged += new System.EventHandler( this.profileComboBox_SelectedIndexChanged );

            // Currently out of sync with 'new' model ~ no explicit read done
            // here or source provided ~ done via reader call...
            foreach ( rfid.Constants.SingulationAlgorithm item in Enum.GetValues( typeof( rfid.Constants.SingulationAlgorithm ) ) )
            {
                algorithmComboBox.Items.Add( item );
            }
            algorithmComboBox.Items.Remove(rfid.Constants.SingulationAlgorithm.UNKNOWN);

            // skipping err checking on these shortcut methods...

            Source_QueryParms queryParms = new Source_QueryParms( );

            queryParms.load( LakeChabotReader.MANAGED_ACCESS, reader.ReaderHandle );

            algorithmComboBox.SelectedIndex = algorithmComboBox.Items.IndexOf
                (
                    queryParms.SingulationAlgorithm
                );

            algorithmComboBox.SelectedIndexChanged += new System.EventHandler( this.algorithmComboBox_SelectedIndexChanged );
        }