private void btnRead_Click(object sender, System.EventArgs e) { try { if (txtFileLocation.Text.Trim().Length == 0) { MessageBox.Show(this.ParentForm, "Please choose a file to read.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } cboClassName.Items.Clear(); cboTargetName.Items.Clear(); cboTarget.Items.Clear(); lstEntities.Items.Clear(); txtEntityDefinition.Clear(); BspReader reader = new BspReader(); _entities = reader.Read(txtFileLocation.Text); _entityLookup = new Hashtable(); Hashtable classes = new Hashtable(); Hashtable targetNames = new Hashtable(); Hashtable targets = new Hashtable(); foreach (BspEntity entity in _entities) { // skip these until we figure out the right ent num if (entity.ClassName == "misc_mg42") { continue; } if (classes.ContainsKey(entity.ClassName)) { int count = (int)classes[entity.ClassName]; count++; classes[entity.ClassName] = count; } else { classes.Add(entity.ClassName, 1); } if (targetNames.ContainsKey(entity.TargetName)) { int count = (int)targetNames[entity.TargetName]; count++; targetNames[entity.TargetName] = count; } else { targetNames.Add(entity.TargetName, 1); } if (targets.ContainsKey(entity.Target)) { int count = (int)targets[entity.Target]; count++; targets[entity.Target] = count; } else { targets.Add(entity.Target, 1); } ListViewItem item = new ListViewItem(Convert.ToString(entity.Number)); item.SubItems.Add(entity.ClassName); lstEntities.Items.Add(item); _entityLookup.Add(Convert.ToString(entity.Number), entity); } cboClassName.Items.Add("All"); cboClassName.SelectedIndex = 0; cboTargetName.Items.Add("All"); cboTargetName.SelectedIndex = 0; cboTarget.Items.Add("All"); cboTarget.SelectedIndex = 0; ArrayList classList = new ArrayList(); ArrayList targetNameList = new ArrayList(); ArrayList targetList = new ArrayList(); foreach (string key in classes.Keys) { classList.Add(key); } foreach (string key in targetNames.Keys) { targetNameList.Add(key); } foreach (string key in targets.Keys) { targetList.Add(key); } classList.Sort(); targetNameList.Sort(); targetList.Sort(); foreach (string key in classList) { cboClassName.Items.Add(key); } foreach (string key in targetNameList) { cboTargetName.Items.Add(key); } foreach (string key in targetList) { cboTarget.Items.Add(key); } } catch (Exception ex) { MessageBox.Show(this.ParentForm, "Error reading bsp file. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }