public void GetRegionList() { foreach ( MacRegion item in Enum.GetValues(typeof(MacRegion)) ) { ValueObject vo = new ValueObject(); if (item == MacRegion.CUSTOMER) { vo.Name = item.ToString(); } else { vo.Name = item.ToString(); } vo.Value = Enum.Format( typeof(MacRegion), item, "d" ); list.Add(vo); } }
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; } }