void OnLoadDetail() { if (this.OpenDetail == null) { return; } if (this.listView_records.SelectedItems.Count == 0) { return; } DoStop(); string strError = ""; // string[] paths = new string[this.listView_records.SelectedItems.Count]; List <string> path_list = new List <string>(); List <BiblioInfo> biblioInfo_list = new List <BiblioInfo>(); //int i = 0; foreach (ListViewItem item in this.listView_records.SelectedItems) { string strPath = item.Text; if (strPath.IndexOf("@") == -1) { path_list.Add(strPath); } else { BiblioInfo info = m_biblioTable[strPath] as BiblioInfo; if (info == null) { strError = "路径为 '" + strPath + "' 的事项在 m_biblioTable 中没有找到"; goto ERROR1; } biblioInfo_list.Add(info); } // paths[i++] = strPath; } OpenDetailEventArgs args = new OpenDetailEventArgs(); string[] paths = new string[path_list.Count]; path_list.CopyTo(paths); args.Paths = paths; args.BiblioInfos = biblioInfo_list; args.OpenNew = true; #if NO this.listView_records.Enabled = false; this.OpenDetail(this, args); this.listView_records.Enabled = true; #endif DoOpenDetail(args); return; ERROR1: MessageBox.Show(this, strError); }
/* * private void listView_records_DoubleClick(object sender, EventArgs e) * { * OnLoadDetail(); * * this.DialogResult = DialogResult.OK; * this.Close(); * } */ /// <summary> /// 装入第一条记录到详细窗 /// </summary> /// <param name="bCloseWindow">是否顺便关闭本窗口</param> public void LoadFirstDetail(bool bCloseWindow) { if (this.listView_records.Items.Count == 0) { return; } string strError = ""; string strPath = this.listView_records.Items[0].Text; if (strPath.IndexOf("@") == -1) { string[] paths = new string[1]; paths[0] = strPath; OpenDetailEventArgs args = new OpenDetailEventArgs(); args.Paths = paths; args.OpenNew = false; #if NO this.listView_records.Enabled = false; this.OpenDetail(this, args); this.listView_records.Enabled = true; #endif DoOpenDetail(args); } else { BiblioInfo info = m_biblioTable[strPath] as BiblioInfo; if (info == null) { strError = "路径为 '" + strPath + "' 的事项在 m_biblioTable 中没有找到"; goto ERROR1; } OpenDetailEventArgs args = new OpenDetailEventArgs(); args.Paths = null; args.BiblioInfos = new List <BiblioInfo>(); args.BiblioInfos.Add(info); args.OpenNew = false; #if NO this.listView_records.Enabled = false; this.OpenDetail(this, args); this.listView_records.Enabled = true; #endif DoOpenDetail(args); } if (bCloseWindow == true) { this.DialogResult = DialogResult.OK; this.Close(); } return; ERROR1: MessageBox.Show(this, strError); }
void DoOpenDetail(OpenDetailEventArgs args) { this.Visible = false; // 2018/10/31 避免在 OpenDetail 事件执行期间出现的 MessageBox.Show() 被本窗口遮挡出现无法用鼠标点按按钮的问题 this.listView_records.Enabled = false; this.OpenDetail(this, args); this.listView_records.Enabled = true; this.Visible = true; }
/* // 装入种 void browseWindow_OpenDetail(object sender, OpenDetailEventArgs e) { if (e.Paths.Length == 0) return; string strBiblioRecPath = e.Paths[0]; // 这里有一个重入的问题 Debug.Assert(m_nInSearching == 0, ""); this.LoadRecord(strBiblioRecPath); } */ void browseWindow_OpenDetail(object sender, OpenDetailEventArgs e) { int nRet = 0; if ((e.Paths == null || e.Paths.Length == 0) && e.BiblioInfos != null && e.BiblioInfos.Count > 0) { BiblioInfo info = e.BiblioInfos[0]; Debug.Assert(info != null, ""); if (this.stop.IsInLoop == true) { this.AddToPendingList(info.RecPath, ""); return; } string strError = ""; // TODO: 已经在 BeginLoop() 中了 nRet = this.LoadRecord(info, true, out strError); if (nRet == 2) this.AddToPendingList(info.RecPath, ""); else if (nRet != 1) { // MessageBox.Show(this, strError); this.ShowMessage(strError, "red", true); } return; } if (e.Paths.Length == 0) return; string strBiblioRecPath = e.Paths[0]; if (this.stop.IsInLoop == true) { this.AddToPendingList(strBiblioRecPath, ""); return; } #if NO // 这里有一个重入的问题 // TODO: 其实这里检查已经没有必要了。因为新的LoadRecord()函数已经检查了m_nInSearching if (m_nInSearching > 0) { /* this.m_strTempBiblioRecPath = strBiblioRecPath; API.PostMessage(this.Handle, WM_PREPARE, 0, 0); * */ this.AddToPendingList(strBiblioRecPath, ""); return; } #endif nRet = this.LoadRecordOld(strBiblioRecPath, "", true); // 2009/11/6 if (nRet == 2) { this.AddToPendingList(strBiblioRecPath, ""); return; } }
void OnLoadDetail() { if (this.OpenDetail == null) return; if (this.listView_records.SelectedItems.Count == 0) return; if (this.stop != null) stop.DoStop(); string strError = ""; // string[] paths = new string[this.listView_records.SelectedItems.Count]; List<string> path_list = new List<string>(); List<BiblioInfo> biblioInfo_list = new List<BiblioInfo>(); int i = 0; foreach (ListViewItem item in this.listView_records.SelectedItems) { string strPath = item.Text; if (strPath.IndexOf("@") == -1) path_list.Add(strPath); else { BiblioInfo info = m_biblioTable[strPath] as BiblioInfo; if (info == null) { strError = "路径为 '" + strPath + "' 的事项在 m_biblioTable 中没有找到"; goto ERROR1; } biblioInfo_list.Add(info); } // paths[i++] = strPath; } OpenDetailEventArgs args = new OpenDetailEventArgs(); string[] paths = new string[path_list.Count]; path_list.CopyTo(paths); args.Paths = paths; args.BiblioInfos = biblioInfo_list; args.OpenNew = true; this.listView_records.Enabled = false; this.OpenDetail(this, args); this.listView_records.Enabled = true; return; ERROR1: MessageBox.Show(this, strError); }
/* private void listView_records_DoubleClick(object sender, EventArgs e) { OnLoadDetail(); this.DialogResult = DialogResult.OK; this.Close(); } */ /// <summary> /// 装入第一条记录到详细窗 /// </summary> /// <param name="bCloseWindow">是否顺便关闭本窗口</param> public void LoadFirstDetail(bool bCloseWindow) { if (this.listView_records.Items.Count == 0) return; string strError = ""; string strPath = this.listView_records.Items[0].Text; if (strPath.IndexOf("@") == -1) { string[] paths = new string[1]; paths[0] = strPath; OpenDetailEventArgs args = new OpenDetailEventArgs(); args.Paths = paths; args.OpenNew = false; this.listView_records.Enabled = false; this.OpenDetail(this, args); this.listView_records.Enabled = true; } else { BiblioInfo info = m_biblioTable[strPath] as BiblioInfo; if (info == null) { strError = "路径为 '"+strPath+"' 的事项在 m_biblioTable 中没有找到"; goto ERROR1; } OpenDetailEventArgs args = new OpenDetailEventArgs(); args.Paths = null; args.BiblioInfos = new List<BiblioInfo>(); args.BiblioInfos.Add(info); args.OpenNew = false; this.listView_records.Enabled = false; this.OpenDetail(this, args); this.listView_records.Enabled = true; } if (bCloseWindow == true) { this.DialogResult = DialogResult.OK; this.Close(); } return; ERROR1: MessageBox.Show(this, strError); }
// 可能会抛出异常 /// <summary> /// 装入第一条记录到详细窗 /// </summary> /// <param name="bCloseWindow">是否顺便关闭本窗口</param> public void LoadFirstDetail(bool bCloseWindow) { if (this.listView_records.Items.Count == 0) { return; } string strError = ""; // 找到第一个记录行。注意可能有命令行,需要跳过 string strPath = GetFirstRecordPath(); // this.listView_records.Items[0].Text; // 2019/5/23 if (string.IsNullOrEmpty(strPath)) { strError = "当前浏览结果中没有任何记录行"; goto ERROR1; } if (strPath.IndexOf("@") == -1) { string[] paths = new string[1]; paths[0] = strPath; OpenDetailEventArgs args = new OpenDetailEventArgs { Paths = paths, OpenNew = false }; #if NO this.listView_records.Enabled = false; this.OpenDetail(this, args); this.listView_records.Enabled = true; #endif DoOpenDetail(args); } else { if (!(m_biblioTable[strPath] is BiblioInfo info)) { strError = "路径为 '" + strPath + "' 的事项在 m_biblioTable 中没有找到"; goto ERROR1; } OpenDetailEventArgs args = new OpenDetailEventArgs { Paths = null, BiblioInfos = new List <BiblioInfo>() }; args.BiblioInfos.Add(info); args.OpenNew = false; DoOpenDetail(args); } if (bCloseWindow == true) { this.DialogResult = DialogResult.OK; this.Close(); } return; ERROR1: try { MessageBox.Show(this, strError); } catch { throw new Exception(strError); } }