void SelectCa(int n) { if (m_cab == null || m_cab.GetType() != m_atype[n]) { m_cab = (CaBase)System.Activator.CreateInstance(m_atype[n]); } m_labelDescription.Text = Helper.GetDescription(m_cab.GetType()); m_richTextBox.Clear(); // String replacement, order independent string str = m_cab.GetString(); CaType[] acat = m_cab.GetTypes(); for (int j = 0; j < acat.Length; j++) { str = str.Replace("$" + (j + 1), "~" + j + acat[j].ToString() + "~" + j); } // Save this away for hittesting purposes m_strParse = (string)str.Clone(); // && delimited pieces are links while (str.Length != 0) { int ichT = str.IndexOf("~"); if (ichT == -1) { m_richTextBox.AppendText(str); break; } if (ichT != 0) { m_richTextBox.AppendText(str.Substring(0, ichT)); } str = str.Remove(0, ichT + 2); // Now add the underlined text int ichStart = m_richTextBox.TextLength; int cchLink = str.IndexOf("~"); Debug.Assert(cchLink != -1); m_richTextBox.AppendText(str.Substring(0, cchLink)); str = str.Remove(0, cchLink + 2); m_richTextBox.Select(ichStart, cchLink); Color clr = m_richTextBox.SelectionColor; Font fnt = m_richTextBox.SelectionFont; m_richTextBox.SelectionColor = Color.Blue; m_richTextBox.SelectionFont = new Font(fnt.FontFamily, fnt.Size, /* FontStyle.Bold | */ FontStyle.Underline); m_richTextBox.Select(m_richTextBox.TextLength, 0); m_richTextBox.SelectionFont = fnt; m_richTextBox.SelectionColor = clr; } }
public CaNew(CaBase cab, string strTitle, string strKind, Type[] atype, string[] astrName) { // // Required for Windows Form Designer support // InitializeComponent(); m_atype = atype; m_cab = null; m_strParse = null; m_strKind = strKind; // To do - might want to pretty print these type names Text = strTitle; m_labelWhatType.Text = m_labelWhatType.Text.Replace("$1", strKind); m_labelText.Text = m_labelText.Text.Replace("$1", strKind); Array.Sort(astrName, atype); Array.Sort(astrName); m_comboBoxType.DataSource = astrName; m_cab = cab; if (cab != null) { m_comboBoxType.SelectedIndex = Array.IndexOf(atype, m_cab.GetType()); } else { m_comboBoxType.SelectedIndex = 0; } SelectCa(m_comboBoxType.SelectedIndex); }