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 m_genDataViewer_SetMenu(object sender, RefreshMenuEventArgs e) { if (e.Actions == null || this.m_detailHostObj == null) return; Type classType = m_detailHostObj.GetType(); foreach (ScriptAction action in e.Actions) { string strFuncName = action.ScriptEntry + "_setMenu"; if (string.IsNullOrEmpty(strFuncName) == true) continue; DigitalPlatform.Script.SetMenuEventArgs e1 = new DigitalPlatform.Script.SetMenuEventArgs(); e1.Action = action; e1.sender = e.sender; e1.e = e.e; classType = m_detailHostObj.GetType(); while (classType != null) { try { // 有两个参数的成员函数 classType.InvokeMember(strFuncName, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod , null, this.m_detailHostObj, new object[] { sender, e1 }); break; } catch (System.MissingMethodException/*ex*/) { classType = classType.BaseType; if (classType == null) break; } } } }
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(); }