private void txtRecordContent_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar != '.') { return; } Point pntPos; switch (m_enmCurrentType) { case enmShowType.Layer4: int intIndex = txtRecordContent.Text.LastIndexOf(' '); if (intIndex < 0) { return; } pntPos = txtRecordContent.GetPositionFromCharIndex(txtRecordContent.SelectionStart); pntPos.Offset(txtRecordContent.Location.X + 2, txtRecordContent.Location.Y + 2); UpdateLocation(pntPos, txtRecordContent); m_lstShow.Items.Clear(); m_lstShow.Items.AddRange(m_strLayer1Arr); m_lstShow.Location = pntPos; m_lstShow.Visible = true; m_enmCurrentType = enmShowType.Layer1; break; case enmShowType.Layer1: pntPos = txtRecordContent.GetPositionFromCharIndex(txtRecordContent.TextLength); pntPos.Offset(txtRecordContent.Location.X + 2, txtRecordContent.Location.Y + 2); UpdateLocation(pntPos, txtRecordContent); m_lstShow.Items.Clear(); m_lstShow.Items.AddRange(m_strLayer2Arr); m_lstShow.Location = pntPos; m_lstShow.Visible = true; m_enmCurrentType = enmShowType.Layer2; break; case enmShowType.Layer2: pntPos = txtRecordContent.GetPositionFromCharIndex(txtRecordContent.TextLength); pntPos.Offset(txtRecordContent.Location.X + 2, txtRecordContent.Location.Y + 2); UpdateLocation(pntPos, txtRecordContent); m_lstShow.Items.Clear(); m_lstShow.Items.AddRange(m_strLayer3Arr); m_lstShow.Location = pntPos; m_lstShow.Visible = true; m_enmCurrentType = enmShowType.Layer3; break; } }
private void m_lstShow_DoubleClick(object sender, System.EventArgs e) { string strValue = m_lstShow.SelectedItem.ToString(); Point pntPos; switch (m_enmCurrentType) { case enmShowType.Layer1: int intIndex = txtRecordContent.Text.LastIndexOf(' '); txtRecordContent.Text = txtRecordContent.Text.Substring(0, intIndex) + strValue; m_lstShow.Visible = false; txtRecordContent.Focus(); txtRecordContent.SelectionStart = txtRecordContent.TextLength; break; case enmShowType.Layer2: txtRecordContent.Text = txtRecordContent.Text.Remove(txtRecordContent.Text.Length - 1, 1) + strValue; m_lstShow.Visible = false; txtRecordContent.Focus(); txtRecordContent.SelectionStart = txtRecordContent.TextLength; break; case enmShowType.Layer3: pntPos = txtRecordContent.GetPositionFromCharIndex(txtRecordContent.TextLength); pntPos.Offset(txtRecordContent.Location.X + 2, txtRecordContent.Location.Y + 2); UpdateLocation(pntPos, txtRecordContent); m_lstShow.Items.Clear(); m_lstShow.Items.AddRange(m_strLayer4Arr); m_lstShow.Location = pntPos; m_enmCurrentType = enmShowType.Layer4; break; case enmShowType.Layer4: txtRecordContent.Text = txtRecordContent.Text.Remove(txtRecordContent.Text.Length - 1, 1) + strValue; m_lstShow.Visible = false; txtRecordContent.Focus(); txtRecordContent.SelectionStart = txtRecordContent.TextLength; break; } }