private void mpListViewChannels_SelectedIndexChanged(object sender, EventArgs e) { mpListViewMapped.BeginUpdate(); try { mpListViewMapped.Items.Clear(); if (mpListViewChannels.SelectedIndices == null) return; if (mpListViewChannels.SelectedIndices.Count != 1) return; Card card = ((CardInfo)mpComboBoxCard.SelectedItem).Card; ListViewItem selectedItem = mpListViewChannels.Items[mpListViewChannels.SelectedIndices[0]]; Channel selectedChannel = (Channel)selectedItem.Tag; IList<Channel> allChannels = Channel.ListAll(); List<ListViewItem> items = new List<ListViewItem>(); NotifyForm dlg = new NotifyForm("Searching for Similar Channels...", "This can take some time\n\nPlease be patient..."); dlg.Show(this); dlg.WaitForDisplay(); foreach (Channel channel in allChannels) { if (channel.IsRadio == false) continue; bool isMapped = false; IList<ChannelMap> list = channel.ReferringChannelMap(); foreach (ChannelMap map in list) { if (map.IdCard == card.IdCard) { isMapped = true; break; } } if (isMapped) continue; Levenstein comparer = new Levenstein(); float result = comparer.getSimilarity(selectedChannel.DisplayName, channel.DisplayName); IList<TuningDetail> details = channel.ReferringTuningDetail(); int imageIndex = GetImageIndex(details); ListViewItem item = new ListViewItem((result * 100f).ToString("f2") + "%", imageIndex); item.Tag = channel; item.SubItems.Add(channel.DisplayName); items.Add(item); } mpListViewMapped.Items.AddRange(items.ToArray()); mpListViewMapped.Sort(); dlg.Close(); } finally { mpListViewMapped.EndUpdate(); } }