/// ------------------------------------------------------------------------------------ public UndefinedPhoneticCharactersDlg(PaProject project, UndefinedPhoneticCharactersInfoList list) : this() { m_project = project; if (project != null) { chkShowUndefinedCharDlg.Checked = m_project.ShowUndefinedCharsDlg; chkIgnoreInSearches.Checked = m_project.IgnoreUndefinedCharsInSearches; } list.Sort(CompareUndefinedCharValues); var projectName = (project == null ? string.Empty : project.Name); lblInfo.Text = string.Format(m_infoFmt, projectName, Application.ProductName); LoadCharGrid(list); m_gridWhere.Tag = null; HandleCharGridRowChanged(null, null); }
/// ------------------------------------------------------------------------------------ private void HandleCharGridRowChanged(object sender, EventArgs e) { var rowIndex = m_gridChars.CurrentCellAddress.Y; if (rowIndex < 0) { return; } char currChar; if (m_gridChars["char", rowIndex].Value is char) { currChar = (char)m_gridChars["char", rowIndex].Value; } else { m_gridWhere.Rows.Clear(); return; } if (m_gridWhere.Tag is char && (char)m_gridWhere.Tag == currChar) { return; } m_gridWhere.Tag = currChar; m_gridWhere.Rows.Clear(); if (m_udpciList.TryGetValue(currChar, out m_currUdpcil)) { pgpWhere.Text = string.Format(m_codepointHdgFmt, (int)currChar); m_currUdpcil = m_udpciList[currChar]; m_gridWhere.RowCount = m_udpciList[currChar].Count; if (m_gridWhere.RowCount > 0) { m_gridWhere.CurrentCell = m_gridWhere[0, 0]; } } }
/// ------------------------------------------------------------------------------------ private void LoadCharGrid(UndefinedPhoneticCharactersInfoList list) { Utils.WaitCursors(true); m_gridChars.Rows.Clear(); DataGridViewRow prevRow = null; int count = 0; char prevChar = (char)0; for (int i = list.Count - 1; i >= 0; i--) { if (prevChar != list[i].Character) { if (prevRow != null) { prevRow.Cells["count"].Value = count; } count = 0; prevChar = list[i].Character; m_udpciList[prevChar] = new UndefinedPhoneticCharactersInfoList(); m_gridChars.Rows.Insert(0, new object[] { string.Format(m_codepointColFmt, (int)prevChar), prevChar, 0 }); prevRow = m_gridChars.Rows[0]; } count++; m_udpciList[prevChar].Add(list[i]); } if (prevRow != null) { prevRow.Cells["count"].Value = count; } m_gridChars.AutoResizeColumns(); m_gridChars.CurrentCell = m_gridChars[0, 0]; Utils.WaitCursors(false); }