public void RefreshState() { if (this.SetMenu == null) { return; } RefreshMenuEventArgs e = new RefreshMenuEventArgs(); e.Actions = this.Actions; e.sender = this.sender; e.e = this.e; this.SetMenu(this, e); DpRow first_selected_row = null; DpRow last_selected_row = null; for (int i = 0; i < this.ActionTable.Rows.Count; i++) { DpRow row = this.ActionTable.Rows[i]; if (row.Style == DpRowStyle.Seperator) { continue; } ScriptAction action = (ScriptAction)row.Tag; if (action == null) { Debug.Assert(false, ""); continue; } if (this.Actions == null || this.Actions.IndexOf(action) == -1) { row.Selected = false; continue; } if (row.Count == 0) { continue; } Debug.Assert(row.Count >= 4, ""); // 刷新一行 row[0].Text = action.Name; string strText = ""; if (action.ShortcutKey != (char)0) { strText = new string(action.ShortcutKey, 1); strText = strText.ToUpper(); } row[1].Text = strText; row[2].Text = action.Comment; row[3].Text = action.ScriptEntry; row.Selected = action.Active; if (first_selected_row == null && row.Selected == true) { first_selected_row = row; } if (row.Selected == true) { last_selected_row = row; } } if (first_selected_row != null) { first_selected_row.EnsureVisible(); } if (last_selected_row != null && last_selected_row != first_selected_row) { last_selected_row.EnsureVisible(); } }
void FillList() { this.ActionTable.Rows.Clear(); if (Actions == null) { return; } DpRow first_item = null; for (int i = 0; i < Actions.Count; i++) { ScriptAction action = (ScriptAction)Actions[i]; DpRow item = new DpRow(); if (action.Name == "-") { item.Style = DpRowStyle.Seperator; } else { DpCell cell = new DpCell(action.Name); cell.Font = new Font(this.ActionTable.Font.FontFamily, 10, FontStyle.Bold, GraphicsUnit.Point); item.Add(cell); // 快捷键 cell = new DpCell(); if (action.ShortcutKey != (char)0) { cell.Text = new string(action.ShortcutKey, 1); cell.Text = cell.Text.ToUpper(); } item.Add(cell); // 说明 item.Add(new DpCell(action.Comment)); // 入口函数 cell = new DpCell(action.ScriptEntry); cell.ForeColor = SystemColors.GrayText; cell.Font = new Font(this.ActionTable.Font.FontFamily, 8, GraphicsUnit.Point); item.Add(cell); } if (action.Active == true) { item.Selected = true; // 2009/2/24 if (first_item == null) { first_item = item; } } this.ActionTable.Rows.Add(item); } if (first_item != null) { this.ActionTable.FocusedItem = first_item; first_item.EnsureVisible(); } }
void _displayTask(string strAction, ChargingTask task) { if (strAction == "add") { DpRow line = new DpRow(); line.Style = DpRowStyle.HorzGrid; line.BackColor = this.TaskBackColor; // SystemColors.Window; line.ForeColor = this.TaskForeColor; task.RefreshDisplay(line); line.Tag = task; this.dpTable_tasks.Rows.Add(line); if (this._bScrollBarTouched == false) { // TODO: 应该分为两种情况 希望看到最末事项的,和看中间的。信号是触动卷滚条到底部;拖动卷滚条到中部 this.dpTable_tasks.FocusedItem = line; line.EnsureVisible(); } } else if (strAction == "remove") { DpRow line = FindTaskLine(task); if (line != null) this.dpTable_tasks.Rows.Remove(line); else { // Debug.Assert(false, ""); } } else if (strAction == "refresh" || strAction == "refresh_and_visible") { DpRow line = FindTaskLine(task); if (line != null) { // 刷新显示 task.RefreshDisplay(line); if (this.StateSpeak != "[不朗读]") { string strContent = task.GetSpeakContent(line, this.StateSpeak); if (string.IsNullOrEmpty(strContent) == false) this.MainForm.Speak(strContent); } if (task.Action == "load_reader_info" && string.IsNullOrEmpty(task.ReaderXml) == false) task.RefreshPatronCardDisplay(line); if (this._bScrollBarTouched == false) { // 如果刷新的对象是 Focus 对象,则确保显示在视野范围内 // TODO: 当发现中途人触动了控件时,这个功能要禁用,以免对人的操作发生干扰 if (this.dpTable_tasks.FocusedItem == line) line.EnsureVisible(); else { if (strAction == "refresh_and_visible") line.EnsureVisible(); } } } } // 刷新读者摘要窗口 if (this._patronSummaryForm != null && this._patronSummaryForm.Visible && strAction == "add") this._patronSummaryForm.OnTaskStateChanged(strAction, task); }