/// <summary> /// Creates a filtered encoding list for the combo box. /// </summary> private void CreateFilteredEncodingList() { string text = FilterText; // if there is no filter the just list the encodings non-filtered.. if (text == string.Empty) { CreateUnFilteredEncodingList(); return; } // get an instance of the EncodingCharacterSet class.. var encodingCharacterSet = EncodingCharacterSet; // get the character sets contained in the EncodingCharacterSet class.. var charSets = encodingCharacterSet.GetCharacterSetList(SingleCodePageResults); CharacterSetComboBox.Items.Clear(); // loop through the character sets.. foreach (var item in charSets) { var encodings = encodingCharacterSet[item]; encodings = encodings.Where(FilterEncoding); if (encodings.ToList().Count > 0) { // add the character sets to the characterSetComboBox.. CharacterSetComboBox.Items.Add(new CharacterSetComboItem { CharacterSet = item, Tag = Data }); } } // set the index for the combo box.. if (CharacterSetComboBox.Items.Count > 0) { // ..if the combo box has any items.. CharacterSetComboBox.SelectedIndex = 0; } else { // if there are no character sets, clear the encoding combo box as well.. EncodingComboBox.Items.Clear(); } EncodingSelected?.Invoke(this, new OnEncodingSelectedEventArgs { Data = Data, Encoding = CurrentEncoding }); }
// the encoding combo box selected item was changed.. private void EncodingComboBox_SelectedIndexChanged(object sender, EventArgs e) { EncodingSelected?.Invoke(this, new OnEncodingSelectedEventArgs { Data = Data, Encoding = CurrentEncoding }); }