public void CreateMenu(object sender, GenerateDataEventArgs e) { ScriptActionCollection actions = new ScriptActionCollection(); if (sender is MarcEditor || sender == null) { } if (sender is BinaryResControl || sender is MarcEditor) { // 856字段 actions.NewItem("创建维护856字段", "创建维护856字段", "Manage856", false); } if (sender is EntityEditForm || sender is EntityControl || sender is BindingForm) { // 创建索取号 actions.NewItem("创建索取号", "为册记录创建索取号", "CreateCallNumber", false); // 管理索取号 actions.NewItem("管理索取号", "为册记录管理索取号", "ManageCallNumber", false); } this.ScriptActions = actions; }
public void CreateMenu(object sender, GenerateDataEventArgs e) { ScriptActionCollection actions = new ScriptActionCollection(); if (sender is MarcEditor || sender == null) { // 规整ISBN为13 actions.NewItem("规整ISBN-13", "对020$a中ISBN进行规整", "HyphenISBN_13", false); // 规整ISBN为10 actions.NewItem("规整ISBN-10", "对020$a中ISBN进行规整", "HyphenISBN_10", false); //245$c<-- 100$a actions.NewItem("245$c<-- 100$a", "将100$a内容拷贝入245字段$c", "Copy100aTo245c", false); //7xx$a<-- 245$c actions.NewItem("7xx$a<-- 245$c", "将245$c内容拷贝入7xx字段$a", "Copy245cTo7xxa", false); // 出版地 actions.NewItem("260$a$b <-- 020$a", "根据020$a中ISBN出版社代码, 自动创建出版社子字段260$a$b", "AddPublisher", false); // 维护 260 出版地 出版社 actions.NewItem("维护260对照表", "ISBN出版社代码 和 260字段$a出版地$b出版社名 的对照表", "Manage260", false); // 分割行 actions.NewSeperator(); actions.NewItem("加入封面图片 URL", "将来自亚马逊的封面图片 URL 加入 856 字段", "AddCoverImageUrl", false); // 分割行 actions.NewSeperator(); } if (sender is BinaryResControl || sender is MarcEditor) { // 856字段 actions.NewItem("创建维护856字段", "创建维护856字段", "Manage856", false); } if (sender is EntityEditForm || sender is EntityControl) { // 创建索取号 actions.NewItem("创建索取号", "为册记录创建索取号", "CreateCallNumber", false); // 管理索取号 actions.NewItem("管理索取号", "为册记录管理索取号", "ManageCallNumber", false); } this.ScriptActions = actions; }
private void entityEditControl1_ControlKeyDown(object sender, ControlKeyEventArgs e) { if (e.e.KeyCode == Keys.A && e.e.Control == true) { if (this.GenerateData != null) { GenerateDataEventArgs e1 = new GenerateDataEventArgs(); e1.FocusedControl = sender; // sender为 EntityEditControl this.GenerateData(this, e1); } e.e.SuppressKeyPress = true; // 2015/5/28 return; } }
// 获得索取号 void button_getAccessNo_Click(object sender, EventArgs e) { if (this.GenerateData != null) { GenerateDataEventArgs e1 = new GenerateDataEventArgs(); if (Control.ModifierKeys == Keys.Control) { e1.ScriptEntry = "ManageCallNumber"; } else { e1.ScriptEntry = "CreateCallNumber"; } e1.FocusedControl = sender; // sender为最原始的子控件 this.GenerateData(this, e1); } }
// 接管Ctrl+各种键 protected override bool ProcessDialogKey( Keys keyData) { // Ctrl + A 自动录入功能 if ((keyData & Keys.Control) == Keys.Control && (keyData & (~Keys.Control)) == Keys.A) // 2007/5/15 修改,原来的行是CTRL+C和CTRL+A都起作用,CTRL+C是副作用。 // && (keyData & Keys.A) == Keys.A) { if (this.XmlEditor != null) { GenerateDataEventArgs ea = new GenerateDataEventArgs(); this.XmlEditor.OnGenerateData(ea); return(true); } } return(false); }
// 接管Ctrl+各种键 protected override bool ProcessDialogKey( Keys keyData) { // Ctrl + A 自动录入功能 if ((keyData & Keys.Control) == Keys.Control && (keyData & (~Keys.Control)) == Keys.A) // 2007/5/15 修改,原来的行是CTRL+C和CTRL+A都起作用,CTRL+C是副作用。 // && (keyData & Keys.A) == Keys.A) { if (this.XmlEditor != null) { GenerateDataEventArgs ea = new GenerateDataEventArgs(); this.XmlEditor.OnGenerateData(ea); return true; } } return false; }
// 创建数据 void menu_generateData_Click(object sender, EventArgs e) { if (this.GenerateData != null) { GenerateDataEventArgs e1 = new GenerateDataEventArgs(); e1.FocusedControl = this.ListView; e1.ScriptEntry = ""; // 启动Ctrl+A菜单 this.GenerateData(this, e1); } else { MessageBox.Show(this, "EntityControl没有挂接GenerateData事件"); } }
// entityeditcontrol的某个输入域触发了按键 private void entityEditControl_editing_ControlKeyDown(object sender, ControlKeyEventArgs e) { string strAction = "copy"; bool bUp = false; Debug.WriteLine("keycode=" + e.e.KeyCode.ToString()); if (e.e.KeyCode == Keys.A && e.e.Control == true) { if (this.GenerateData != null) { GenerateDataEventArgs e1 = new GenerateDataEventArgs(); e1.FocusedControl = sender; // sender为 EntityEditControl this.GenerateData(this, e1); } e.e.SuppressKeyPress = true; // 2015/5/28 return; } else if (e.e.KeyCode == Keys.PageDown && e.e.Control == true) { // this.button_editing_nextRecord_Click(null, null); this.toolStripButton_next_Click(null, null); return; } else if (e.e.KeyCode == Keys.PageUp && e.e.Control == true) { // this.button_editing_prevRecord_Click(null, null); this.toolStripButton_prev_Click(null, null); return; } else if (e.e.KeyCode == Keys.OemOpenBrackets && e.e.Control == true) { bUp = true; // 从上面拷贝 } else if (e.e.KeyCode == Keys.OemCloseBrackets && e.e.Control == true) { bUp = false; // 从下面拷贝 } else if (e.e.KeyCode == Keys.OemMinus && e.e.Control == true) { bUp = true; // 从上面减量 strAction = "minus"; } else if (e.e.KeyCode == Keys.Oemplus && e.e.Control == true) { bUp = true; // 从上面增量 strAction = "plus"; } else if (e.e.KeyCode == Keys.D0 && e.e.Control == true) { bUp = false; // 从下面减量 strAction = "minus"; } else if (e.e.KeyCode == Keys.D9 && e.e.Control == true) { bUp = false; // 从下面增量 strAction = "plus"; } else { return; } string strError = ""; BookItem bookitem = GetPrevOrNextItem(bUp, out strError); if (bookitem == null) { return; } switch (e.Name) { case "PublishTime": this.entityEditControl_editing.PublishTime = DoAction(strAction, bookitem.PublishTime); break; case "Seller": this.entityEditControl_editing.Seller = DoAction(strAction, bookitem.Seller); break; case "Source": this.entityEditControl_editing.Source = DoAction(strAction, bookitem.Source); break; case "Intact": this.entityEditControl_editing.Intact = DoAction(strAction, bookitem.Intact); break; case "Binding": this.entityEditControl_editing.Binding = DoAction(strAction, bookitem.Binding); break; case "Operations": this.entityEditControl_editing.Operations = DoAction(strAction, bookitem.Operations); break; case "Price": this.entityEditControl_editing.Price = DoAction(strAction, bookitem.Price); break; case "Barcode": this.entityEditControl_editing.Barcode = DoAction(strAction, bookitem.Barcode); break; case "State": this.entityEditControl_editing.State = DoAction(strAction, bookitem.State); break; case "Location": this.entityEditControl_editing.LocationString = DoAction(strAction, bookitem.Location); break; case "Comment": this.entityEditControl_editing.Comment = DoAction(strAction, bookitem.Comment); break; case "Borrower": Console.Beep(); //this.entityEditControl_editing.Borrower = bookitem.Borrower; break; case "BorrowDate": Console.Beep(); //this.entityEditControl_editing.BorrowDate = bookitem.BorrowDate; break; case "BorrowPeriod": Console.Beep(); //this.entityEditControl_editing.BorrowPeriod = bookitem.BorrowPeriod; break; case "RecPath": Console.Beep(); //this.entityEditControl_editing.RecPath = bookitem.RecPath; break; case "BookType": this.entityEditControl_editing.BookType = DoAction(strAction, bookitem.BookType); break; case "RegisterNo": this.entityEditControl_editing.RegisterNo = DoAction(strAction, bookitem.RegisterNo); break; case "MergeComment": this.entityEditControl_editing.MergeComment = DoAction(strAction, bookitem.MergeComment); break; case "BatchNo": this.entityEditControl_editing.BatchNo = DoAction(strAction, bookitem.BatchNo); break; case "Volume": this.entityEditControl_editing.Volume = DoAction(strAction, bookitem.Volume); break; case "AccessNo": this.entityEditControl_editing.AccessNo = DoAction(strAction, bookitem.AccessNo); break; case "RefID": Console.Beep(); // this.entityEditControl_editing.RefID = bookitem.RefID; // 2009/6/2 break; default: Debug.Assert(false, "未知的栏目名称 '" + e.Name + "'"); return; } }
public void CreateMenu(object sender, GenerateDataEventArgs e) { ScriptActionCollection actions = new ScriptActionCollection(); if (sender is MarcEditor || sender == null) { #if TESTING actions.NewItem("调试用", "调试用", "Test", false); #endif // 加拼音 actions.NewItem("加拼音", "给全部定义的子字段加拼音", "AddPinyin", false, 'P'); // 删除拼音 actions.NewItem("删除拼音", "删除全部拼音子字段", "RemovePinyin", false); // 清除拼音缓存 actions.NewItem("清除拼音缓存", "清除存储的以前选择过的汉字和拼音对照关系", "ClearPinyinCache", false); // 分割行 actions.NewSeperator(); // 规整 ISSN 为13 actions.NewItem("规整为ISSN-13", "对011$a中ISSN进行规整", "HyphenISSN_13", false); // 规整 ISSN 为 8 actions.NewItem("规整为ISSN-8", "对011$a中ISSN进行规整", "HyphenISSN_8", false); // 分割行 actions.NewSeperator(); // 102国家代码 地区代码 actions.NewItem("102$a$b <-- 010$a", "根据010$a中ISBN出版社代码, 自动创建102字段$a国家代码$b地区代码", "Add102", false); // 410 <-- 225 actions.NewItem("410 <-- 225", "将225$a内容加入410 $1200 $a", "Copy225To410", false); // 7*1$a <-- 200$f actions.NewItem("7*1$a <-- 200$f", "将200$f内容加入701/711字段$a", "Copy200fTo7x1a", false); // 7*2$a <-- 200$g actions.NewItem("7*2$a <-- 200$g", "将200$g内容加入702/712字段$a", "Copy200gTo7x2a", false); #if NO // 905$d <-- 690$a actions.NewItem("905$d <-- 690$a", "将690$a内容加入905字段$d", "Copy690aTo905d", false); // 加入著者号 actions.NewItem("加入著者号", "根据701/711/702/712$a内容, 创建905$e", "AddAuthorNumber", false); // 加入种次号 actions.NewItem("加入种次号", "根据905$d内容, 创建905$e", "AddZhongcihao", false); // 维护种次号 actions.NewItem("维护种次号", "根据905$d内容中的类号, 出现维护种次号的界面", "ManageZhongcihao", false); #endif // 出版地 actions.NewItem("210$a$c <-- 010$a", "根据010$a中ISBN出版社代码, 自动创建出版社子字段210$a$c", "AddPublisher", false); // 分割行 actions.NewSeperator(); // 维护 102 国家代码 地区代码 actions.NewItem("维护102对照表", "ISBN出版社代码 和 102字段$a国家代码$b地区代码 的对照表", "Manage102", false); // 维护 210 出版地 出版社 actions.NewItem("维护210对照表", "ISBN出版社代码 和 210字段$a出版地$c出版社名 的对照表", "Manage210", false); // 分割行 actions.NewSeperator(); // 打印单张卡片 actions.NewItem("打印单张卡片", "打印单张目录卡片", "PrintSingleCard", false); } if (sender is BinaryResControl || sender is MarcEditor) { // 856字段 actions.NewItem("创建维护856字段", "创建维护856字段", "Manage856", false); } if (sender is EntityEditForm || sender is EntityControl || sender is BindingForm) { // 创建索取号 actions.NewItem("创建索取号", "为册记录创建索取号", "CreateCallNumber", false); // 管理索取号 actions.NewItem("管理索取号", "为册记录管理索取号", "ManageCallNumber", false); } this.ScriptActions = actions; }
public override void CreateCallNumber(object sender, GenerateDataEventArgs e) { base.CreateCallNumber(sender, e); }
protected override void OnKeyPress(KeyPressEventArgs e) { switch (e.KeyChar) { case '\\': { if (this.m_marcEditor.m_nFocusCol != 3) break; // 为何不起作用? // Ctrl + \ 还是输入 \ if (Control.ModifierKeys == Keys.Control) break; int nOldStart = this.SelectionStart; string strTemp = this.Text; /* if (nOldStart < strTemp.Length) strTemp = strTemp.Remove(nOldStart, 1); */ #if BIDI_SUPPORT strTemp = strTemp.Insert(nOldStart, "\x200e" + new string((char)Record.KERNEL_SUBFLD, 1)); #else strTemp = strTemp.Insert(nOldStart, new string((char)Record.KERNEL_SUBFLD, 1)); #endif this.Text = strTemp; this.SelectionStart = nOldStart; e.Handled = true; #if BIDI_SUPPORT this.SelectionStart += 2; #else this.SelectionStart++; #endif return; } break; case (char)Keys.Enter: { if (this.MarcEditor.EnterAsAutoGenerate == true) { GenerateDataEventArgs ea = new GenerateDataEventArgs(); this.m_marcEditor.OnGenerateData(ea); } else { // 后插字段 // this.MarcEditor.InsertAfterFieldWithoutDlg(); // parameters: // nAutoComplate 0: false; 1: true; -1:保持当前记忆状态 this.MarcEditor.InsertField(this.MarcEditor.FocusedFieldIndex, 0, 1); // false, true } e.Handled = true; return; } case (char)Keys.Back: { if (this.Overwrite == true) { e.Handled = true; Console.Beep(); return; /* 这个功能本来不错,但是被禁止了 int nOldSelectionStart = this.SelectionStart; if (nOldSelectionStart > 0) { this.Text = this.Text.Remove(nOldSelectionStart - 1, 1); this.Text = this.Text.Insert(nOldSelectionStart - 1, " "); this.SelectionStart = nOldSelectionStart - 1; return; } * */ } #if BIDI_SUPPORT int nStart = this.SelectionStart - 1; if (this.SelectionLength == 0 && nStart > 0) { // 如果删除的正好是方向字符 if (this.Text[nStart] == 0x200e && this.Text.Length >= nStart + 1 + 1) { // 一同删除 this.Text = this.Text.Remove(nStart-1, 2); this.SelectionStart = nStart-1; // 2011/12/5 上面两行曾经有BUG e.Handled = true; } // 如果删除位置的左方正好是方向字符 else if (nStart > 0 && this.Text[nStart - 1] == 0x200e) { // 一同删除 this.Text = this.Text.Remove(nStart - 1, 2); this.SelectionStart = nStart - 1; e.Handled = true; } } #endif } break; default: { if (this.Overwrite == true) { if ((Control.ModifierKeys == Keys.Control) // || Control.ModifierKeys == Keys.Shift || Control.ModifierKeys == Keys.Alt) { break; } int nOldSelectionStart = this.SelectionStart; if (nOldSelectionStart < this.Text.Length) { /* if (this.Text.Length >= this.MaxLength - 1) // 2008/12/18 { this.Text = this.Text.Remove(this.SelectionStart, 1); this.SelectionStart = nOldSelectionStart; } * */ if (this.Text.Length >= this.MaxLength) // 2009/3/6 changed { this.Text = this.Text.Remove(this.SelectionStart, 1 + (this.Text.Length - this.MaxLength)); this.SelectionStart = nOldSelectionStart; } } else { Console.Beep(); // 表示拒绝了输入的字符 } } } break; } base.OnKeyPress(e); }
/* // 接管回车键,变成给后面新增字段 // 可以改写到OnKeyPress中? /// <summary> /// 缺省窗口过程 /// </summary> /// <param name="m">消息</param> protected override void DefWndProc(ref Message m) { switch (m.Msg) { case API.WM_CHAR: { int nKey =API.LoWord(m.WParam.ToInt32()); switch (nKey) { case (int)Keys.Enter: { // 后插字段 this.MarcEditor.InsertAfterFieldNoDlg(); return; } case (int)Keys.Back: { if (this.Overwrite == true) { int nOldSelectionStart = this.SelectionStart; if (nOldSelectionStart > 0) { this.Text = this.Text.Remove(nOldSelectionStart - 1, 1); this.Text = this.Text.Insert(nOldSelectionStart - 1, " "); this.SelectionStart = nOldSelectionStart - 1; return; } } } break; default: { if (this.Overwrite == true) { if ((Control.ModifierKeys == Keys.Control) || Control.ModifierKeys == Keys.Shift || Control.ModifierKeys == Keys.Alt) { break; } int nOldSelectionStart = this.SelectionStart; if (nOldSelectionStart < this.Text.Length) { this.Text = this.Text.Remove(this.SelectionStart, 1); this.SelectionStart = nOldSelectionStart; } } } break; } } break; } base.DefWndProc(ref m); } */ // 接管Ctrl+各种键 /// <summary> /// 处理对话框键 /// </summary> /// <param name="keyData">System.Windows.Forms.Keys 值之一,它表示要处理的键。</param> /// <returns>如果控件处理并使用击键,则为 true;否则为 false,以允许进一步处理</returns> protected override bool ProcessDialogKey( Keys keyData) { // 去掉Control/Shift/Alt 以后的纯净的键码 // 2008/11/30 changed Keys pure_key = (keyData & (~(Keys.Control | Keys.Shift | Keys.Alt))); // Ctrl + M if (Control.ModifierKeys == Keys.Control && pure_key == Keys.Enter) { // 禁止插入回车换行 return true; } // Ctrl + M if (Control.ModifierKeys == Keys.Control && pure_key == Keys.M) { MarcEditor.EditControlTextToItem(); // 调模板 this.MarcEditor.GetValueFromTemplate(); return true; } // Ctrl + C if ((keyData & Keys.Control) == Keys.Control && pure_key == Keys.C) { this.Menu_Copy(null,null); return true; } // Ctrl + X if ((keyData & Keys.Control) == Keys.Control && pure_key == Keys.X) { this.Menu_Cut(null, null); return true; } // Ctrl + V if ((keyData & Keys.Control) == Keys.Control && pure_key == Keys.V) { this.Menu_Paste(null, null); return true; } /* // Ctrl + A 自动录入功能 if ((keyData & Keys.Control) == Keys.Control && (keyData & Keys.A) == Keys.A) { if (this.m_marcEditor != null) { GenerateDataEventArgs ea = new GenerateDataEventArgs(); this.m_marcEditor.OnGenerateData(ea); return true; } }*/ // Ctrl + A 自动录入功能 // && (keyData & (~Keys.Control)) == Keys.A) // 2007/5/15 修改,原来的行是CTRL+C和CTRL+A都起作用,CTRL+C是副作用。 if (keyData == (Keys.A | Keys.Control) // 这也是一个办法 || keyData == (Keys.A | Keys.Control | Keys.Alt)) { if (this.m_marcEditor != null) { GenerateDataEventArgs ea = new GenerateDataEventArgs(); this.m_marcEditor.OnGenerateData(ea); return true; } } if (keyData == (Keys.Y | Keys.Control)) // 这也是一个办法 { if (this.m_marcEditor != null) { GenerateDataEventArgs ea = new GenerateDataEventArgs(); this.m_marcEditor.OnVerifyData(ea); return true; } } /* // Ctrl + T 测试 if ((keyData & Keys.Control) == Keys.Control && (keyData & (~Keys.Control)) == Keys.T) // 2008/11/30 修改,原来的行是CTRL+C和CTRL+A都起作用,CTRL+C是副作用。 // && (keyData & Keys.T) == Keys.T) { if (this.m_marcEditor != null) { this.m_marcEditor.Test(); return true; } }*/ // 其余未处理的键 if ((keyData & Keys.Control) == Keys.Control) { bool bRet = this.MarcEditor.OnControlLetterKeyPress(pure_key); if (bRet == true) return true; } // 2008/11/30 changed return base.ProcessDialogKey(keyData); // return false }
public void CreateMenu(object sender, GenerateDataEventArgs e) { ScriptActionCollection actions = new ScriptActionCollection(); if (sender is MarcEditor || sender == null) { // 加拼音 actions.NewItem("加拼音", "给全部定义的子字段加拼音", "AddPinyin", false, 'P'); // 删除拼音 actions.NewItem("删除拼音", "删除全部拼音子字段", "RemovePinyin", false); // 清除拼音缓存 actions.NewItem("清除拼音缓存", "清除存储的以前选择过的汉字和拼音对照关系", "ClearPinyinCache", false); // 分割行 actions.NewSeperator(); // 规整ISBN为13 actions.NewItem("规整为ISBN-13", "对010$a中ISBN进行规整", "HyphenISBN_13", false); // 规整ISBN为10 actions.NewItem("规整为ISBN-10", "对010$a中ISBN进行规整", "HyphenISBN_10", false); // 分割行 actions.NewSeperator(); // 102国家代码 地区代码 actions.NewItem("102$a$b <-- 010$a", "根据010$a中ISBN出版社代码, 自动创建102字段$a国家代码$b地区代码", "Add102", false); // 410 <-- 225 actions.NewItem("410 <-- 225", "将225$a内容加入410 $1200 $a", "Copy225To410", false); // 7*1$a <-- 200$f actions.NewItem("7*1$a <-- 200$f", "将200$f内容加入701/711字段$a", "Copy200fTo7x1a", false); // 7*2$a <-- 200$g actions.NewItem("7*2$a <-- 200$g", "将200$g内容加入702/712字段$a", "Copy200gTo7x2a", false); // 905$d <-- 690$a actions.NewItem("905$d <-- 690$a", "将690$a内容加入905字段$d", "Copy690aTo905d", false); // 加入GCA著者号 actions.NewItem("加入GCAT著者号", "根据701/711/702/712$a内容, 创建905$e", "AddGcatAuthorNumber", false); // 加入四角号码著者号 actions.NewItem("加入四角号码著者号", "根据701/711/702/712$a内容, 创建905$e", "AddSjhmAuthorNumber", false); // 加入种次号 actions.NewItem("加入种次号", "根据905$d内容, 创建905$e", "AddZhongcihao", false); // 维护种次号 actions.NewItem("维护种次号", "根据905$d内容中的类号, 出现维护种次号的界面", "ManageZhongcihao", false); // 出版地 actions.NewItem("210$a$c <-- 010$a", "根据010$a中ISBN出版社代码, 自动创建出版社子字段210$a$c", "AddPublisher", false); // 分割行 actions.NewSeperator(); // 维护 102 国家代码 地区代码 actions.NewItem("维护102对照表", "ISBN出版社代码 和 102字段$a国家代码$b地区代码 的对照表", "Manage102", false); // 维护 210 出版地 出版社 actions.NewItem("维护210对照表", "ISBN出版社代码 和 210字段$a出版地$c出版社名 的对照表", "Manage210", false); // 分割行 actions.NewSeperator(); } this.ScriptActions = actions; }
// 自动加工数据 // parameters: // sender 从何处启动? MarcEditor EntityEditForm BindingForm public void AutoGenerate(object sender, GenerateDataEventArgs e, string strBiblioRecPath, bool bOnlyFillMenu = false) { int nRet = 0; string strError = ""; bool bAssemblyReloaded = false; // 防止重入 if (bOnlyFillMenu == true && this.m_nInFillMenu > 0) { return; } this.m_nInFillMenu++; try { // 初始化 dp2circulation_marc_autogen.cs 的 Assembly,并new DetailHost对象 // return: // -1 error // 0 没有重新初始化Assembly,而是直接用以前Cache的Assembly // 1 重新(或者首次)初始化了Assembly nRet = InitialAutogenAssembly(strBiblioRecPath, // null, out strError); if (nRet == -1) { goto ERROR1; } if (nRet == 0) { if (this.m_detailHostObj == null) { return; // 库名不具备,无法初始化 } } if (nRet == 1) { bAssemblyReloaded = true; } Debug.Assert(this.m_detailHostObj != null, ""); if (this.AutoGenNewStyle == true) { bool bDisplayWindow = Program.MainForm.PanelFixedVisible == false ? true : false; if (bDisplayWindow == true) { if (String.IsNullOrEmpty(e.ScriptEntry) != true && e.ScriptEntry != "Main") { bDisplayWindow = false; } } if (sender is EntityEditForm && (String.IsNullOrEmpty(e.ScriptEntry) == true || e.ScriptEntry == "Main")) { bDisplayWindow = true; } else if (sender is BindingForm && (String.IsNullOrEmpty(e.ScriptEntry) == true || e.ScriptEntry == "Main")) { bDisplayWindow = true; } DisplayAutoGenMenuWindow(bDisplayWindow); // 可能会改变 .ActionTable以及 .Count if (bOnlyFillMenu == false) { if (Program.MainForm.PanelFixedVisible == true && e.Parameter == null) // 2015/6/5 { Program.MainForm.ActivateGenerateDataPage(); } } if (this.m_genDataViewer != null) { this.m_genDataViewer.sender = sender; this.m_genDataViewer.e = e; } // 清除残留菜单事项 if (m_autogenSender != sender || bAssemblyReloaded == true) { if (this.m_genDataViewer != null && this.m_genDataViewer.Count > 0) { this.m_genDataViewer.Clear(); } } } else // 旧的风格 { #if NO if (this.m_genDataViewer != null) { this.m_genDataViewer.Close(); this.m_genDataViewer = null; } #endif CloseGenDataViewer(); if (this._myForm.Focused == true // || this.m_marcEditor.Focused TODO: 这里要研究一下如何实现 ) { Program.MainForm.CurrentGenerateDataControl = null; } // 如果意图仅仅为填充菜单 if (bOnlyFillMenu == true) { return; } } try { // 旧的风格 if (this.AutoGenNewStyle == false) { this.m_detailHostObj.Invoke(String.IsNullOrEmpty(e.ScriptEntry) == true ? "Main" : e.ScriptEntry, sender, e); // this.SetSaveAllButtonState(true); TODO: 应该没有必要。MARC 编辑器内容修改自然会引起保存按钮状态变化 return; } // 初始化菜单 try { if (this.m_genDataViewer != null) { // 出现菜单界面 if (this.m_genDataViewer.Count == 0) { dynamic o = this.m_detailHostObj; o.CreateMenu(sender, e); this.m_genDataViewer.Actions = this.m_detailHostObj.ScriptActions; } // 根据当前插入符位置刷新加亮事项 this.m_genDataViewer.RefreshState(); } if (String.IsNullOrEmpty(e.ScriptEntry) == false) { this.m_detailHostObj.Invoke(e.ScriptEntry, sender, e); } else { if (Program.MainForm.PanelFixedVisible == true && bOnlyFillMenu == false && Program.MainForm.CurrentGenerateDataControl != null) { TableLayoutPanel table = (TableLayoutPanel)Program.MainForm.CurrentGenerateDataControl; for (int i = 0; i < table.Controls.Count; i++) { Control control = table.Controls[i]; if (control is DpTable) { control.Focus(); break; } } } } } catch (Exception /*ex*/) { /* * // 被迫改用旧的风格 * this.m_detailHostObj.Invoke(String.IsNullOrEmpty(e.ScriptEntry) == true ? "Main" : e.ScriptEntry, * sender, * e); * this.SetSaveAllButtonState(true); * return; * */ throw; } } catch (Exception ex) { strError = "执行脚本文件 '" + m_strAutogenDataCfgFilename + "' 过程中发生异常: \r\n" + ExceptionUtil.GetDebugText(ex); goto ERROR1; } this.m_autogenSender = sender; // 记忆最近一次的调用发起者 if (bOnlyFillMenu == false && this.m_genDataViewer != null) { this.m_genDataViewer.TryAutoRun(); } return; ERROR1: // TODO: 报错是否要直接显示在 dpTable 中? // MessageBox.Show(this._myForm, strError); DisplayAutoGenMenuWindow(false); if (this.m_genDataViewer != null) { this.m_genDataViewer.DisplayError(strError); } } finally { this.m_nInFillMenu--; } }
public void OnGenerateData(GenerateDataEventArgs e) { if (this.GenerateData != null) this.GenerateData(this, e); }
// 创建索取号 void menu_manage856_Click(object sender, EventArgs e) { if (this.GenerateData != null) { GenerateDataEventArgs e1 = new GenerateDataEventArgs(); e1.FocusedControl = this.ListView; e1.ScriptEntry = "Manage856"; // 直接启动Manage856()函数 this.GenerateData(this, e1); } else { MessageBox.Show(this, "EntityControl没有挂接GenerateData事件"); } }
public void Invoke(string strFuncName, object sender, GenerateDataEventArgs e) { Type classType = this.GetType(); while (classType != null) { try { // 有两个参数的成员函数 classType.InvokeMember(strFuncName, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod , null, this, new object[] { sender, e }); return; } catch (System.MissingMethodException /*ex*/) { classType = classType.BaseType; if (classType == null) { break; } } } if (strFuncName == "Main") { classType = this.GetType(); // 老的HostEventArgs e 参数 while (classType != null) { try { // 有两个参数的成员函数 classType.InvokeMember(strFuncName, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod , null, this, new object[] { sender, new HostEventArgs() }); return; } catch (System.MissingMethodException /*ex*/) { classType = classType.BaseType; if (classType == null) { break; } } } } classType = this.GetType(); while (classType != null) { try { // 兼容以前的书写方法 -- 没有参数 classType.InvokeMember(strFuncName, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod , null, this, null); return; } catch (System.MissingMethodException /*ex*/) { classType = classType.BaseType; } } throw new Exception("函数 void " + strFuncName + "(object sender, GenerateDataEventArgs e) 或 void " + strFuncName + "() 没有找到"); }
public void CreateMenu(object sender, GenerateDataEventArgs e) { ScriptActionCollection actions = new ScriptActionCollection(); this.ScriptActions = actions; }