private void textBox_verifyResult_DoubleClick(object sender, EventArgs e) { if (this.Locate == null) { return; } if (textBox_verifyResult.Lines.Length == 0) { return; } int x = 0; int y = 0; API.GetEditCurrentCaretPos( this.textBox_verifyResult, out x, out y); string strLine = ""; try { strLine = textBox_verifyResult.Lines[y]; } catch { return; } // 析出"(字段名,子字段名, 字符位置)"值 int nRet = strLine.IndexOf("("); if (nRet == -1) { return; } strLine = strLine.Substring(nRet + 1); nRet = strLine.IndexOf(")"); if (nRet != -1) { strLine = strLine.Substring(0, nRet); } strLine = strLine.Trim(); LocateEventArgs e1 = new LocateEventArgs(); e1.Location = strLine; this.Locate(this, e1); }
void m_viewer_Locate(object sender, LocateEventArgs e) { string strError = ""; string[] parts = e.Location.Split(new char[] { ',' }); string strFieldName = ""; int nFieldIndex = 0; string strSubfieldName = ""; int nSubfieldIndex = 0; int nCharPos = 0; int nRet = 0; if (parts.Length == 0) return; if (parts.Length >= 1) { string strValue = parts[0].Trim(); nRet = strValue.IndexOf("#"); if (nRet == -1) strFieldName = strValue; else { strFieldName = strValue.Substring(0, nRet); string strNumber = strValue.Substring(nRet + 1); if (string.IsNullOrEmpty(strNumber) == false) { try { nFieldIndex = Convert.ToInt32(strNumber); } catch { strError = "字段位置 '" + strNumber + "' 格式不正确..."; goto ERROR1; } nFieldIndex--; } } } if (parts.Length >= 2) { string strValue = parts[1].Trim(); nRet = strValue.IndexOf("#"); if (nRet == -1) strSubfieldName = strValue; else { strSubfieldName = strValue.Substring(0, nRet); string strNumber = strValue.Substring(nRet + 1); if (string.IsNullOrEmpty(strNumber) == false) { try { nSubfieldIndex = Convert.ToInt32(strNumber); } catch { strError = "子字段位置 '" + strNumber + "' 格式不正确..."; goto ERROR1; } nSubfieldIndex--; } } } if (parts.Length >= 3) { string strValue = parts[2].Trim(); if (string.IsNullOrEmpty(strValue) == false) { try { nCharPos = Convert.ToInt32(strValue); } catch { strError = "字符位置 '" + strValue + "' 格式不正确..."; goto ERROR1; } if (nCharPos > 0) nCharPos--; } } Field field = this.m_marcEditor.Record.Fields[strFieldName, nFieldIndex]; if (field == null) { strError = "当前MARC编辑器中不存在 名为 '" + strFieldName + "' 位置为 " + nFieldIndex.ToString() + " 的字段"; goto ERROR1; } if (string.IsNullOrEmpty(strSubfieldName) == true) { // 字段名 if (nCharPos == -1) { this.m_marcEditor.SetActiveField(field, 2); } // 字段指示符 else if (nCharPos == -2) { this.m_marcEditor.SetActiveField(field, 1); } else { this.m_marcEditor.FocusedField = field; this.m_marcEditor.SelectCurEdit(nCharPos, 0); } this.m_marcEditor.EnsureVisible(); return; } this.m_marcEditor.FocusedField = field; this.m_marcEditor.EnsureVisible(); Subfield subfield = field.Subfields[strSubfieldName, nSubfieldIndex]; if (subfield == null) { strError = "当前MARC编辑器中不存在 名为 '" + strSubfieldName + "' 位置为 " + nSubfieldIndex.ToString() + " 的子字段"; goto ERROR1; } this.m_marcEditor.SelectCurEdit(subfield.Offset + 2, 0); return; ERROR1: MessageBox.Show(this, strError); }
private void textBox_verifyResult_DoubleClick(object sender, EventArgs e) { if (this.Locate == null) return; if (textBox_verifyResult.Lines.Length == 0) return; int x = 0; int y = 0; API.GetEditCurrentCaretPos( this.textBox_verifyResult, out x, out y); string strLine = ""; try { strLine = textBox_verifyResult.Lines[y]; } catch { return; } // 析出"(字段名,子字段名, 字符位置)"值 int nRet = strLine.IndexOf("("); if (nRet == -1) return; strLine = strLine.Substring(nRet + 1); nRet = strLine.IndexOf(")"); if (nRet != -1) strLine = strLine.Substring(0, nRet); strLine = strLine.Trim(); LocateEventArgs e1 = new LocateEventArgs(); e1.Location = strLine; this.Locate(this, e1); }