From 57dedb5e9d4975322170c38b34cb18ba6545424c Mon Sep 17 00:00:00 2001 From: cyf Date: Sat, 15 Aug 2026 22:26:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E5=92=8CAlt=E6=8C=89=E9=92=AE=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FrmBaseAccraditation.Designer.cs | 6 +- .../FrmBaseAccraditation.cs | 22 +- 插件库/Lskj.Control/AuditPanel2.Designer.cs | 16 +- 插件库/Lskj.Control/AuditPanel2.cs | 28 +- 插件库/Lskj.Control/AuditPanelEx.Designer.cs | 342 +++++++++--------- 插件库/Lskj.Control/AuditPanelEx.cs | 19 + 插件库/Lskj.Control/BaseUserControl.cs | 6 +- 插件库/Lskj.Control/GridControlEx.cs | 23 ++ 插件库/Lskj.Control/LabelTimeEdit.cs | 252 +++++++++++++ 插件库/Lskj.Control/Lskj.Control.csproj | 4 + .../Model/AltButtonShortcutManager.cs | 122 +++++++ 插件库/Lskj.Control/Model/MyControl.cs | 25 +- 插件库/Lskj.Control/ModuleGridEx.Designer.cs | 25 +- 插件库/Lskj.Control/ModuleGridEx.cs | 23 ++ 插件库/Lskj.Control/ModulePanelEx.Designer.cs | 10 +- 插件库/Lskj.Control/ModulePanelEx.cs | 26 +- .../FrmAccraditation.Designer.cs | 10 +- .../Lskj.PubAccraditation/FrmAccraditation.cs | 24 +- 插件库/Lskj.PubBill/BillModule.Designer.cs | 13 +- 插件库/Lskj.PubSpec/FrmMain.Designer.cs | 14 +- 插件库/Lskj.PubSpec/FrmMain.cs | 20 + 插件库/Lskj.PubSpec2/FrmMain.Designer.cs | 4 +- 插件库/Lskj.PubSpec2/FrmMain.cs | 17 + 23 files changed, 818 insertions(+), 233 deletions(-) create mode 100644 插件库/Lskj.Control/LabelTimeEdit.cs create mode 100644 插件库/Lskj.Control/Model/AltButtonShortcutManager.cs diff --git a/插件库/Lskj.BaseAccraditation/FrmBaseAccraditation.Designer.cs b/插件库/Lskj.BaseAccraditation/FrmBaseAccraditation.Designer.cs index 4286383..3462636 100644 --- a/插件库/Lskj.BaseAccraditation/FrmBaseAccraditation.Designer.cs +++ b/插件库/Lskj.BaseAccraditation/FrmBaseAccraditation.Designer.cs @@ -107,7 +107,7 @@ this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(80, 28); this.btnCancel.TabIndex = 4; - this.btnCancel.Text = "退出(&C)"; + this.btnCancel.Text = "退出(C)"; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // // btnFileManger @@ -175,7 +175,7 @@ this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(80, 28); this.btnSave.TabIndex = 11; - this.btnSave.Text = "保存(&S)"; + this.btnSave.Text = "保存(S)"; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // // dpb_Tools @@ -458,7 +458,7 @@ this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(58, 23); this.btnClose.TabIndex = 12; - this.btnClose.Text = "关闭(&Q)"; + this.btnClose.Text = "关闭(Q)"; this.btnClose.Click += new System.EventHandler(this.btnClose_Click); // // labeltxt_managerAudit diff --git a/插件库/Lskj.BaseAccraditation/FrmBaseAccraditation.cs b/插件库/Lskj.BaseAccraditation/FrmBaseAccraditation.cs index 033580f..531738a 100644 --- a/插件库/Lskj.BaseAccraditation/FrmBaseAccraditation.cs +++ b/插件库/Lskj.BaseAccraditation/FrmBaseAccraditation.cs @@ -39,6 +39,9 @@ namespace Lskj.BaseAccraditation { public partial class FrmBaseAccraditation : BaseForm { + private readonly AltButtonShortcutManager mAltButtonShortcuts = + new AltButtonShortcutManager(); + #region 公用变量 /// /// 审批模型 @@ -190,6 +193,23 @@ namespace Lskj.BaseAccraditation public FrmBaseAccraditation() { InitializeComponent(); + InitializeAltButtonShortcuts(); + } + + private void InitializeAltButtonShortcuts() + { + mAltButtonShortcuts.Register(btnCancel, Keys.C); + mAltButtonShortcuts.Register(btnSave, Keys.S); + mAltButtonShortcuts.Register(btnAudit, Keys.Y); + mAltButtonShortcuts.Register(btnClose, Keys.Q); + mAltButtonShortcuts.Register(btnReturnd, Keys.N); + } + + protected override bool ProcessCmdKey( + ref System.Windows.Forms.Message msg, Keys keyData) + { + return mAltButtonShortcuts.ProcessKey(keyData) || + base.ProcessCmdKey(ref msg, keyData); } private void ReleaseResourcesForDispose() @@ -1480,7 +1500,7 @@ namespace Lskj.BaseAccraditation { this.btnAudit.Enabled = true; this.btnClose.Visible = this.btnRemindAccradit.Visible = this.btnRemindBack.Visible = this.btnSave.Visible = this.btnReturnd.Visible = false; - this.btnAudit.Text = "确认(&Y)"; + this.btnAudit.Text = "确认(Y)"; this.label_auditPerson.Text = "确认意见"; this.labeltxt_managerAudit.Text = "会签人"; this.txt_remark.Text = "确认"; diff --git a/插件库/Lskj.Control/AuditPanel2.Designer.cs b/插件库/Lskj.Control/AuditPanel2.Designer.cs index 4ff6a58..00797c4 100644 --- a/插件库/Lskj.Control/AuditPanel2.Designer.cs +++ b/插件库/Lskj.Control/AuditPanel2.Designer.cs @@ -175,7 +175,7 @@ this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(75, 26); this.btnClose.TabIndex = 22; - this.btnClose.Text = "关闭(&Q)"; + this.btnClose.Text = "关闭(Q)"; // // btnBack // @@ -187,7 +187,7 @@ this.btnBack.Name = "btnBack"; this.btnBack.Size = new System.Drawing.Size(75, 26); this.btnBack.TabIndex = 21; - this.btnBack.Text = "返退(&N)"; + this.btnBack.Text = "返退(N)"; this.btnBack.Click += new System.EventHandler(this.btnReturn_Click); // // btnSave @@ -200,7 +200,7 @@ this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(75, 26); this.btnSave.TabIndex = 25; - this.btnSave.Text = "保存(&S)"; + this.btnSave.Text = "保存(S)"; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // // btnAccradit @@ -213,7 +213,7 @@ this.btnAccradit.Name = "btnAccradit"; this.btnAccradit.Size = new System.Drawing.Size(75, 26); this.btnAccradit.TabIndex = 20; - this.btnAccradit.Text = "审核(&Y)"; + this.btnAccradit.Text = "审核(Y)"; this.btnAccradit.Click += new System.EventHandler(this.btnAccradit_Click); // // btnPrint @@ -256,7 +256,7 @@ this.btnSpare.Name = "btnSpare"; this.btnSpare.Size = new System.Drawing.Size(75, 26); this.btnSpare.TabIndex = 27; - this.btnSpare.Text = "分单(&P)"; + this.btnSpare.Text = "分单(P)"; this.btnSpare.Click += new System.EventHandler(this.btnSpare_Click); // // pcTool @@ -381,7 +381,7 @@ this.btnReflash.Name = "btnReflash"; this.btnReflash.Size = new System.Drawing.Size(75, 26); this.btnReflash.TabIndex = 27; - this.btnReflash.Text = "刷新(&R)"; + this.btnReflash.Text = "刷新(R)"; this.btnReflash.Click += new System.EventHandler(this.btnReflash_Click); // // panelControl1 @@ -523,7 +523,7 @@ this.btnSearch.Name = "btnSearch"; this.btnSearch.Size = new System.Drawing.Size(72, 26); this.btnSearch.TabIndex = 6; - this.btnSearch.Text = "搜索(&Q)"; + this.btnSearch.Text = "搜索(Q)"; this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click); // // labeldate_end @@ -571,7 +571,7 @@ this.btnBackTop.Name = "btnBackTop"; this.btnBackTop.Size = new System.Drawing.Size(72, 26); this.btnBackTop.TabIndex = 8; - this.btnBackTop.Text = "返审(&W)"; + this.btnBackTop.Text = "返审(W)"; this.btnBackTop.Click += new System.EventHandler(this.btnBack_Click); // // pcBillDetail diff --git a/插件库/Lskj.Control/AuditPanel2.cs b/插件库/Lskj.Control/AuditPanel2.cs index 0e5e264..d6e5360 100644 --- a/插件库/Lskj.Control/AuditPanel2.cs +++ b/插件库/Lskj.Control/AuditPanel2.cs @@ -29,11 +29,35 @@ namespace Lskj.Control { public partial class AuditPanel2 : UserControl { + private readonly AltButtonShortcutManager mAltButtonShortcuts = + new AltButtonShortcutManager(); + public AuditPanel2() { InitializeComponent(); + InitializeAltButtonShortcuts(); SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.Selectable | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true); } + + private void InitializeAltButtonShortcuts() + { + mAltButtonShortcuts.Register(btnClose, Keys.Q); + mAltButtonShortcuts.Register(btnBack, Keys.N); + mAltButtonShortcuts.Register(btnSave, Keys.S); + mAltButtonShortcuts.Register(btnAccradit, Keys.Y); + mAltButtonShortcuts.Register(btnSpare, Keys.P); + mAltButtonShortcuts.Register(btnReflash, Keys.R); + mAltButtonShortcuts.Register(btnSearch, Keys.Q); + mAltButtonShortcuts.Register(btnBackTop, Keys.W); + } + + protected override bool ProcessCmdKey( + ref System.Windows.Forms.Message msg, Keys keyData) + { + return mAltButtonShortcuts.ProcessKey(keyData) || + base.ProcessCmdKey(ref msg, keyData); + } + #region 公有变量 public string modelkeyName = ""; /// @@ -1601,7 +1625,7 @@ namespace Lskj.Control this.btnClose.Enabled = this.btnSave.Enabled = this.btnAccradit.Enabled = this.btnBack.Enabled = this.btnSpare.Enabled = false; this.btnSave.Visible = this.btnClose.Visible = this.btnBack.Visible = this.pcTool.Visible = true; - this.btnAccradit.Text = "确认(&Y)"; + this.btnAccradit.Text = "确认(Y)"; return; } @@ -3624,4 +3648,4 @@ namespace Lskj.Control } } -} \ No newline at end of file +} diff --git a/插件库/Lskj.Control/AuditPanelEx.Designer.cs b/插件库/Lskj.Control/AuditPanelEx.Designer.cs index ebaec54..cad81cb 100644 --- a/插件库/Lskj.Control/AuditPanelEx.Designer.cs +++ b/插件库/Lskj.Control/AuditPanelEx.Designer.cs @@ -48,34 +48,34 @@ this.btnBackAudit = new DevExpress.XtraEditors.SimpleButton(); this.btnRefresh = new DevExpress.XtraEditors.SimpleButton(); this.tabpage_finish = new DevExpress.XtraTab.XtraTabPage(); - this.pl_top = new DevExpress.XtraEditors.PanelControl(); - this.pl_top_right = new DevExpress.XtraEditors.PanelControl(); - this.btnBack = new DevExpress.XtraEditors.SimpleButton(); - this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton(); - this.pl_top_searchCond = new DevExpress.XtraEditors.PanelControl(); - this.labeldate_end = new Lskj.Control.LabelCheckDateEdit(); - this.btnSearch = new DevExpress.XtraEditors.SimpleButton(); - this.labeltxt_dataFlag = new Lskj.Control.LabelTextEdit(); - this.labelcheck_finalAuditor = new Lskj.Control.LabelCheckAutoTextEdit(); - this.labeldate_start = new Lskj.Control.LabelCheckDateEdit(); - this.splitBelow = new DevExpress.XtraEditors.SplitContainerControl(); - this.gridDetail = new Lskj.Control.GridControlEx(); - this.gridFlow = new Lskj.Control.GridControlEx(); this.gridFinish = new Lskj.Control.GridControlEx(); + this.splitBelow = new DevExpress.XtraEditors.SplitContainerControl(); + this.gridFlow = new Lskj.Control.GridControlEx(); + this.gridDetail = new Lskj.Control.GridControlEx(); + this.pl_top = new DevExpress.XtraEditors.PanelControl(); + this.pl_top_searchCond = new DevExpress.XtraEditors.PanelControl(); + this.labeldate_start = new Lskj.Control.LabelCheckDateEdit(); + this.labelcheck_finalAuditor = new Lskj.Control.LabelCheckAutoTextEdit(); + this.labeltxt_dataFlag = new Lskj.Control.LabelTextEdit(); + this.btnSearch = new DevExpress.XtraEditors.SimpleButton(); + this.labeldate_end = new Lskj.Control.LabelCheckDateEdit(); + this.pl_top_right = new DevExpress.XtraEditors.PanelControl(); + this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton(); + this.btnBack = new DevExpress.XtraEditors.SimpleButton(); this.tabMain = new DevExpress.XtraTab.XtraTabControl(); ((System.ComponentModel.ISupportInitialize)(this.pl_bottom)).BeginInit(); this.pl_bottom.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.p_menu)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.barManager1)).BeginInit(); this.tabpage_finish.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pl_top)).BeginInit(); - this.pl_top.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pl_top_right)).BeginInit(); - this.pl_top_right.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pl_top_searchCond)).BeginInit(); - this.pl_top_searchCond.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitBelow)).BeginInit(); this.splitBelow.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_top)).BeginInit(); + this.pl_top.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_top_searchCond)).BeginInit(); + this.pl_top_searchCond.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pl_top_right)).BeginInit(); + this.pl_top_right.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tabMain)).BeginInit(); this.tabMain.SuspendLayout(); this.SuspendLayout(); @@ -208,7 +208,7 @@ this.btnOkAudit.Name = "btnOkAudit"; this.btnOkAudit.Size = new System.Drawing.Size(82, 26); this.btnOkAudit.TabIndex = 7; - this.btnOkAudit.Text = "批量审核(&Y)"; + this.btnOkAudit.Text = "批量审核(Y)"; this.btnOkAudit.Visible = false; this.btnOkAudit.Click += new System.EventHandler(this.OnBtnOkAuditClick); // @@ -221,7 +221,7 @@ this.btnBackAudit.Name = "btnBackAudit"; this.btnBackAudit.Size = new System.Drawing.Size(86, 26); this.btnBackAudit.TabIndex = 6; - this.btnBackAudit.Text = "批量返审(&B)"; + this.btnBackAudit.Text = "批量返审(B)"; this.btnBackAudit.Visible = false; this.btnBackAudit.Click += new System.EventHandler(this.OnBtnBackAuditClick); // @@ -234,7 +234,7 @@ this.btnRefresh.Name = "btnRefresh"; this.btnRefresh.Size = new System.Drawing.Size(72, 26); this.btnRefresh.TabIndex = 5; - this.btnRefresh.Text = "刷新(&R)"; + this.btnRefresh.Text = "刷新(R)"; this.btnRefresh.Click += new System.EventHandler(this.BtnReflash_Click); // // tabpage_finish @@ -246,6 +246,57 @@ this.tabpage_finish.Size = new System.Drawing.Size(1570, 1007); this.tabpage_finish.Text = "已完成单据"; // + // gridFinish + // + this.gridFinish.AdapterObj = null; + this.gridFinish.AutoSize = true; + this.gridFinish.Dock = System.Windows.Forms.DockStyle.Fill; + this.gridFinish.Location = new System.Drawing.Point(0, 39); + this.gridFinish.Margin = new System.Windows.Forms.Padding(4); + this.gridFinish.Name = "gridFinish"; + this.gridFinish.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gridFinish.Size = new System.Drawing.Size(1570, 675); + this.gridFinish.SysModel = null; + this.gridFinish.TabIndex = 29; + // + // splitBelow + // + this.splitBelow.Dock = System.Windows.Forms.DockStyle.Bottom; + this.splitBelow.Location = new System.Drawing.Point(0, 714); + this.splitBelow.Name = "splitBelow"; + this.splitBelow.Panel1.Controls.Add(this.gridFlow); + this.splitBelow.Panel1.Text = "Panel1"; + this.splitBelow.Panel2.Controls.Add(this.gridDetail); + this.splitBelow.Panel2.Text = "Panel2"; + this.splitBelow.Size = new System.Drawing.Size(1570, 293); + this.splitBelow.SplitterPosition = 453; + this.splitBelow.TabIndex = 28; + this.splitBelow.Text = "splitContainerControl1"; + // + // gridFlow + // + this.gridFlow.AdapterObj = null; + this.gridFlow.Dock = System.Windows.Forms.DockStyle.Fill; + this.gridFlow.Location = new System.Drawing.Point(0, 0); + this.gridFlow.Margin = new System.Windows.Forms.Padding(4); + this.gridFlow.Name = "gridFlow"; + this.gridFlow.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gridFlow.Size = new System.Drawing.Size(453, 293); + this.gridFlow.SysModel = null; + this.gridFlow.TabIndex = 19; + // + // gridDetail + // + this.gridDetail.AdapterObj = null; + this.gridDetail.Dock = System.Windows.Forms.DockStyle.Fill; + this.gridDetail.Location = new System.Drawing.Point(0, 0); + this.gridDetail.Margin = new System.Windows.Forms.Padding(4); + this.gridDetail.Name = "gridDetail"; + this.gridDetail.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; + this.gridDetail.Size = new System.Drawing.Size(1112, 293); + this.gridDetail.SysModel = null; + this.gridDetail.TabIndex = 20; + // // pl_top // this.pl_top.Controls.Add(this.pl_top_searchCond); @@ -256,41 +307,6 @@ this.pl_top.Size = new System.Drawing.Size(1570, 39); this.pl_top.TabIndex = 25; // - // pl_top_right - // - this.pl_top_right.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; - this.pl_top_right.Controls.Add(this.simpleButton1); - this.pl_top_right.Controls.Add(this.btnBack); - this.pl_top_right.Dock = System.Windows.Forms.DockStyle.Right; - this.pl_top_right.Location = new System.Drawing.Point(1305, 2); - this.pl_top_right.Name = "pl_top_right"; - this.pl_top_right.Size = new System.Drawing.Size(263, 35); - this.pl_top_right.TabIndex = 24; - // - // btnBack - // - this.btnBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnBack.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnBack.Appearance.Options.UseFont = true; - this.btnBack.Location = new System.Drawing.Point(100, 5); - this.btnBack.Name = "btnBack"; - this.btnBack.Size = new System.Drawing.Size(82, 26); - this.btnBack.TabIndex = 8; - this.btnBack.Text = "返审(&W)"; - this.btnBack.Click += new System.EventHandler(this.btnBack_Click); - // - // simpleButton1 - // - this.simpleButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.simpleButton1.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.simpleButton1.Appearance.Options.UseFont = true; - this.simpleButton1.Location = new System.Drawing.Point(188, 5); - this.simpleButton1.Name = "simpleButton1"; - this.simpleButton1.Size = new System.Drawing.Size(72, 26); - this.simpleButton1.TabIndex = 9; - this.simpleButton1.Text = "帮助文档"; - this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click); - // // pl_top_searchCond // this.pl_top_searchCond.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; @@ -305,71 +321,6 @@ this.pl_top_searchCond.Size = new System.Drawing.Size(1303, 35); this.pl_top_searchCond.TabIndex = 23; // - // labeldate_end - // - this.labeldate_end.BackColor = System.Drawing.Color.Transparent; - this.labeldate_end.BackgroundColor = System.Drawing.Color.Empty; - this.labeldate_end.ContentBold = false; - this.labeldate_end.EditText = null; - this.labeldate_end.FontSize = 0F; - this.labeldate_end.LabelText = "终审时间止"; - this.labeldate_end.Location = new System.Drawing.Point(216, 8); - this.labeldate_end.Margin = new System.Windows.Forms.Padding(4); - this.labeldate_end.Model = null; - this.labeldate_end.Name = "labeldate_end"; - this.labeldate_end.NullText = null; - this.labeldate_end.ReadOnly = false; - this.labeldate_end.Required = false; - this.labeldate_end.Size = new System.Drawing.Size(196, 21); - this.labeldate_end.TabIndex = 12; - // - // btnSearch - // - this.btnSearch.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnSearch.Appearance.Options.UseFont = true; - this.btnSearch.Location = new System.Drawing.Point(774, 5); - this.btnSearch.Name = "btnSearch"; - this.btnSearch.Size = new System.Drawing.Size(72, 26); - this.btnSearch.TabIndex = 6; - this.btnSearch.Text = "搜索(&Q)"; - this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click); - // - // labeltxt_dataFlag - // - this.labeltxt_dataFlag.BackColor = System.Drawing.Color.Transparent; - this.labeltxt_dataFlag.BackgroundColor = System.Drawing.Color.Empty; - this.labeltxt_dataFlag.ContentBold = false; - this.labeltxt_dataFlag.EditText = ""; - this.labeltxt_dataFlag.FontSize = 0F; - this.labeltxt_dataFlag.LabelText = "数据标识号"; - this.labeltxt_dataFlag.Location = new System.Drawing.Point(605, 8); - this.labeltxt_dataFlag.Margin = new System.Windows.Forms.Padding(4); - this.labeltxt_dataFlag.Model = null; - this.labeltxt_dataFlag.Name = "labeltxt_dataFlag"; - this.labeltxt_dataFlag.NullText = ""; - this.labeltxt_dataFlag.ReadOnly = false; - this.labeltxt_dataFlag.Required = false; - this.labeltxt_dataFlag.Size = new System.Drawing.Size(164, 21); - this.labeltxt_dataFlag.TabIndex = 10; - // - // labelcheck_finalAuditor - // - this.labelcheck_finalAuditor.BackColor = System.Drawing.Color.Transparent; - this.labelcheck_finalAuditor.BackgroundColor = System.Drawing.Color.Empty; - this.labelcheck_finalAuditor.ContentBold = false; - this.labelcheck_finalAuditor.EditText = null; - this.labelcheck_finalAuditor.FontSize = 0F; - this.labelcheck_finalAuditor.LabelText = "终审人"; - this.labelcheck_finalAuditor.Location = new System.Drawing.Point(419, 8); - this.labelcheck_finalAuditor.Margin = new System.Windows.Forms.Padding(4); - this.labelcheck_finalAuditor.Model = null; - this.labelcheck_finalAuditor.Name = "labelcheck_finalAuditor"; - this.labelcheck_finalAuditor.NullText = null; - this.labelcheck_finalAuditor.ReadOnly = false; - this.labelcheck_finalAuditor.Required = false; - this.labelcheck_finalAuditor.Size = new System.Drawing.Size(180, 21); - this.labelcheck_finalAuditor.TabIndex = 13; - // // labeldate_start // this.labeldate_start.BackColor = System.Drawing.Color.Transparent; @@ -388,56 +339,105 @@ this.labeldate_start.Size = new System.Drawing.Size(196, 21); this.labeldate_start.TabIndex = 11; // - // splitBelow + // labelcheck_finalAuditor // - this.splitBelow.Dock = System.Windows.Forms.DockStyle.Bottom; - this.splitBelow.Location = new System.Drawing.Point(0, 714); - this.splitBelow.Name = "splitBelow"; - this.splitBelow.Panel1.Controls.Add(this.gridFlow); - this.splitBelow.Panel1.Text = "Panel1"; - this.splitBelow.Panel2.Controls.Add(this.gridDetail); - this.splitBelow.Panel2.Text = "Panel2"; - this.splitBelow.Size = new System.Drawing.Size(1570, 293); - this.splitBelow.SplitterPosition = 453; - this.splitBelow.TabIndex = 28; - this.splitBelow.Text = "splitContainerControl1"; + this.labelcheck_finalAuditor.BackColor = System.Drawing.Color.Transparent; + this.labelcheck_finalAuditor.BackgroundColor = System.Drawing.Color.Empty; + this.labelcheck_finalAuditor.ContentBold = false; + this.labelcheck_finalAuditor.EditText = null; + this.labelcheck_finalAuditor.FontSize = 0F; + this.labelcheck_finalAuditor.LabelText = "终审人"; + this.labelcheck_finalAuditor.Location = new System.Drawing.Point(419, 8); + this.labelcheck_finalAuditor.Margin = new System.Windows.Forms.Padding(4); + this.labelcheck_finalAuditor.Model = null; + this.labelcheck_finalAuditor.Name = "labelcheck_finalAuditor"; + this.labelcheck_finalAuditor.NullText = null; + this.labelcheck_finalAuditor.ReadOnly = false; + this.labelcheck_finalAuditor.Required = false; + this.labelcheck_finalAuditor.Size = new System.Drawing.Size(180, 21); + this.labelcheck_finalAuditor.TabIndex = 13; // - // gridDetail + // labeltxt_dataFlag // - this.gridDetail.AdapterObj = null; - this.gridDetail.Dock = System.Windows.Forms.DockStyle.Fill; - this.gridDetail.Location = new System.Drawing.Point(0, 0); - this.gridDetail.Margin = new System.Windows.Forms.Padding(4); - this.gridDetail.Name = "gridDetail"; - this.gridDetail.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; - this.gridDetail.Size = new System.Drawing.Size(1112, 293); - this.gridDetail.SysModel = null; - this.gridDetail.TabIndex = 20; + this.labeltxt_dataFlag.BackColor = System.Drawing.Color.Transparent; + this.labeltxt_dataFlag.BackgroundColor = System.Drawing.Color.Empty; + this.labeltxt_dataFlag.ContentBold = false; + this.labeltxt_dataFlag.EditText = ""; + this.labeltxt_dataFlag.FontSize = 0F; + this.labeltxt_dataFlag.LabelText = "数据标识号"; + this.labeltxt_dataFlag.Location = new System.Drawing.Point(605, 8); + this.labeltxt_dataFlag.Margin = new System.Windows.Forms.Padding(4); + this.labeltxt_dataFlag.Model = null; + this.labeltxt_dataFlag.Name = "labeltxt_dataFlag"; + this.labeltxt_dataFlag.NullText = ""; + this.labeltxt_dataFlag.ReadOnly = false; + this.labeltxt_dataFlag.Required = false; + this.labeltxt_dataFlag.Size = new System.Drawing.Size(164, 21); + this.labeltxt_dataFlag.TabIndex = 10; // - // gridFlow + // btnSearch // - this.gridFlow.AdapterObj = null; - this.gridFlow.Dock = System.Windows.Forms.DockStyle.Fill; - this.gridFlow.Location = new System.Drawing.Point(0, 0); - this.gridFlow.Margin = new System.Windows.Forms.Padding(4); - this.gridFlow.Name = "gridFlow"; - this.gridFlow.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; - this.gridFlow.Size = new System.Drawing.Size(453, 293); - this.gridFlow.SysModel = null; - this.gridFlow.TabIndex = 19; + this.btnSearch.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnSearch.Appearance.Options.UseFont = true; + this.btnSearch.Location = new System.Drawing.Point(774, 5); + this.btnSearch.Name = "btnSearch"; + this.btnSearch.Size = new System.Drawing.Size(72, 26); + this.btnSearch.TabIndex = 6; + this.btnSearch.Text = "搜索(Q)"; + this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click); // - // gridFinish + // labeldate_end // - this.gridFinish.AdapterObj = null; - this.gridFinish.AutoSize = true; - this.gridFinish.Dock = System.Windows.Forms.DockStyle.Fill; - this.gridFinish.Location = new System.Drawing.Point(0, 39); - this.gridFinish.Margin = new System.Windows.Forms.Padding(4); - this.gridFinish.Name = "gridFinish"; - this.gridFinish.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; - this.gridFinish.Size = new System.Drawing.Size(1570, 675); - this.gridFinish.SysModel = null; - this.gridFinish.TabIndex = 29; + this.labeldate_end.BackColor = System.Drawing.Color.Transparent; + this.labeldate_end.BackgroundColor = System.Drawing.Color.Empty; + this.labeldate_end.ContentBold = false; + this.labeldate_end.EditText = null; + this.labeldate_end.FontSize = 0F; + this.labeldate_end.LabelText = "终审时间止"; + this.labeldate_end.Location = new System.Drawing.Point(216, 8); + this.labeldate_end.Margin = new System.Windows.Forms.Padding(4); + this.labeldate_end.Model = null; + this.labeldate_end.Name = "labeldate_end"; + this.labeldate_end.NullText = null; + this.labeldate_end.ReadOnly = false; + this.labeldate_end.Required = false; + this.labeldate_end.Size = new System.Drawing.Size(196, 21); + this.labeldate_end.TabIndex = 12; + // + // pl_top_right + // + this.pl_top_right.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.pl_top_right.Controls.Add(this.simpleButton1); + this.pl_top_right.Controls.Add(this.btnBack); + this.pl_top_right.Dock = System.Windows.Forms.DockStyle.Right; + this.pl_top_right.Location = new System.Drawing.Point(1305, 2); + this.pl_top_right.Name = "pl_top_right"; + this.pl_top_right.Size = new System.Drawing.Size(263, 35); + this.pl_top_right.TabIndex = 24; + // + // simpleButton1 + // + this.simpleButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.simpleButton1.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.simpleButton1.Appearance.Options.UseFont = true; + this.simpleButton1.Location = new System.Drawing.Point(188, 5); + this.simpleButton1.Name = "simpleButton1"; + this.simpleButton1.Size = new System.Drawing.Size(72, 26); + this.simpleButton1.TabIndex = 9; + this.simpleButton1.Text = "帮助文档"; + this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click); + // + // btnBack + // + this.btnBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnBack.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnBack.Appearance.Options.UseFont = true; + this.btnBack.Location = new System.Drawing.Point(100, 5); + this.btnBack.Name = "btnBack"; + this.btnBack.Size = new System.Drawing.Size(82, 26); + this.btnBack.TabIndex = 8; + this.btnBack.Text = "返审(W)"; + this.btnBack.Click += new System.EventHandler(this.btnBack_Click); // // tabMain // @@ -470,14 +470,14 @@ ((System.ComponentModel.ISupportInitialize)(this.barManager1)).EndInit(); this.tabpage_finish.ResumeLayout(false); this.tabpage_finish.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pl_top)).EndInit(); - this.pl_top.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.pl_top_right)).EndInit(); - this.pl_top_right.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.pl_top_searchCond)).EndInit(); - this.pl_top_searchCond.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitBelow)).EndInit(); this.splitBelow.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_top)).EndInit(); + this.pl_top.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_top_searchCond)).EndInit(); + this.pl_top_searchCond.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pl_top_right)).EndInit(); + this.pl_top_right.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.tabMain)).EndInit(); this.tabMain.ResumeLayout(false); this.ResumeLayout(false); diff --git a/插件库/Lskj.Control/AuditPanelEx.cs b/插件库/Lskj.Control/AuditPanelEx.cs index ca344fc..5b47744 100644 --- a/插件库/Lskj.Control/AuditPanelEx.cs +++ b/插件库/Lskj.Control/AuditPanelEx.cs @@ -42,10 +42,29 @@ namespace Lskj.Control public partial class AuditPanelEx : UserControl { private bool mResourcesReleased; + private readonly AltButtonShortcutManager mAltButtonShortcuts = + new AltButtonShortcutManager(); public AuditPanelEx() { InitializeComponent(); + InitializeAltButtonShortcuts(); + } + + private void InitializeAltButtonShortcuts() + { + mAltButtonShortcuts.Register(btnOkAudit, Keys.Y); + mAltButtonShortcuts.Register(btnBackAudit, Keys.B); + mAltButtonShortcuts.Register(btnRefresh, Keys.R); + mAltButtonShortcuts.Register(btnBack, Keys.W); + mAltButtonShortcuts.Register(btnSearch, Keys.Q); + } + + protected override bool ProcessCmdKey( + ref System.Windows.Forms.Message msg, Keys keyData) + { + return mAltButtonShortcuts.ProcessKey(keyData) || + base.ProcessCmdKey(ref msg, keyData); } internal void ReleaseResourcesForDispose() diff --git a/插件库/Lskj.Control/BaseUserControl.cs b/插件库/Lskj.Control/BaseUserControl.cs index 48ee740..2ce8a1e 100644 --- a/插件库/Lskj.Control/BaseUserControl.cs +++ b/插件库/Lskj.Control/BaseUserControl.cs @@ -75,12 +75,14 @@ namespace Lskj.Control case ControlType.LabDate: case ControlType.LabDateTime: case ControlType.LabDateTimeShort: - case ControlType.LabTime: - case ControlType.LabShortTime: // 日期控件 LabelDateEdit dateEdit = this as LabelDateEdit; UpdContrast = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.EditValue.ToString(); break; + case ControlType.LabTime: + case ControlType.LabShortTime: + LabelTimeEdit timeEdit = this as LabelTimeEdit; + return timeEdit != null && !timeEdit.IsSameTime(this.Model.Text); } return this.Model == null || this.Model.Text == null || !this.Model.Text.Equals(UpdContrast, StringComparison.OrdinalIgnoreCase); } diff --git a/插件库/Lskj.Control/GridControlEx.cs b/插件库/Lskj.Control/GridControlEx.cs index 7dd9959..0a263c8 100644 --- a/插件库/Lskj.Control/GridControlEx.cs +++ b/插件库/Lskj.Control/GridControlEx.cs @@ -4244,6 +4244,29 @@ namespace Lskj.Control RepositoryItemTimeEdit timeEdit = new RepositoryItemTimeEdit(); timeEdit.DisplayFormat.FormatString = timeEdit.EditFormat.FormatString = timeEdit.Mask.EditMask = DateFormat.Format(fieldType); timeEdit.DisplayFormat.FormatType = timeEdit.EditFormat.FormatType = DevExpress.Utils.FormatType.Custom; + timeEdit.ParseEditValue += delegate(object sender, ConvertEditValueEventArgs e) + { + // SQL Server 的 time 字段在 DataTable 中是 TimeSpan,TimeEdit 输入后返回 DateTime。 + // 只转换 TimeSpan 绑定列,不改变原有 DateTime 类型列的行为。 + if (gridColumn.ColumnType != typeof(TimeSpan) || e.Value == null || e.Value == DBNull.Value) + { + return; + } + + if (e.Value is DateTime) + { + e.Value = ((DateTime)e.Value).TimeOfDay; + e.Handled = true; + return; + } + + TimeSpan timeValue; + if (!(e.Value is TimeSpan) && TimeSpan.TryParse(e.Value.ToString(), out timeValue)) + { + e.Value = timeValue; + e.Handled = true; + } + }; diff --git a/插件库/Lskj.Control/LabelTimeEdit.cs b/插件库/Lskj.Control/LabelTimeEdit.cs new file mode 100644 index 0000000..97448c8 --- /dev/null +++ b/插件库/Lskj.Control/LabelTimeEdit.cs @@ -0,0 +1,252 @@ +using System; +using System.Drawing; +using System.Windows.Forms; +using DevExpress.XtraEditors; + +namespace Lskj.Control +{ + /// + /// 带标题的时间输入控件,使用上下按钮调整时间。 + /// + public class LabelTimeEdit : BaseUserControl + { + private readonly Panel plLeft; + private readonly Panel plRight; + private readonly Label lblText; + private readonly TimeEdit txtEdit; + private string formatString = "HH:mm:ss"; + + public LabelTimeEdit() + { + plLeft = new Panel(); + plRight = new Panel(); + lblText = new Label(); + txtEdit = new TimeEdit(); + + SuspendLayout(); + plLeft.SuspendLayout(); + plRight.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)txtEdit.Properties).BeginInit(); + + plLeft.BackColor = Color.Transparent; + plLeft.Controls.Add(lblText); + plLeft.Dock = DockStyle.Left; + plLeft.Size = new Size(40, 21); + + lblText.AutoSize = true; + lblText.Location = new Point(5, 4); + lblText.Text = "名称"; + + plRight.Controls.Add(txtEdit); + plRight.Dock = DockStyle.Fill; + plRight.Location = new Point(40, 0); + + txtEdit.Dock = DockStyle.Fill; + txtEdit.EditValue = null; + txtEdit.Properties.Buttons.Clear(); + txtEdit.Properties.Buttons.Add(new DevExpress.XtraEditors.Controls.EditorButton( + DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)); + txtEdit.Properties.TimeEditStyle = DevExpress.XtraEditors.Repository.TimeEditStyle.SpinButtons; + + AutoScaleMode = AutoScaleMode.None; + BackColor = Color.Transparent; + Controls.Add(plRight); + Controls.Add(plLeft); + Size = new Size(162, 21); + + ((System.ComponentModel.ISupportInitialize)txtEdit.Properties).EndInit(); + plRight.ResumeLayout(false); + plLeft.ResumeLayout(false); + plLeft.PerformLayout(); + ResumeLayout(false); + } + + /// + /// 时间编辑器。 + /// + public TimeEdit TextEdit + { + get { return txtEdit; } + } + + public override string LabelText + { + get { return lblText.Text; } + set + { + lblText.Text = value; + if (FontSize > 0) + { + plLeft.AutoSize = false; + lblText.AutoSize = false; + lblText.Dock = DockStyle.Fill; + lblText.Location = new Point(0, 0); + lblText.TextAlign = ContentAlignment.MiddleLeft; + txtEdit.Properties.AutoHeight = false; + plLeft.Width = value.Length * GetCharWidth(); + GetCharWidthMultilingual(lblText, lblText.Text, plLeft); + } + else + { + plLeft.Width = lblText.Width + PaddingLeft; + } + } + } + + public override float FontSize + { + get { return base.FontSize; } + set + { + base.FontSize = value; + if (value > 0) + { + lblText.Font = new Font(lblText.Font.FontFamily, value); + txtEdit.Font = new Font(txtEdit.Font.FontFamily, value); + } + } + } + + public override string EditText + { + get { return txtEdit.EditValue == null ? string.Empty : txtEdit.Text; } + set + { + TimeSpan timeValue; + txtEdit.EditValue = TryGetTime(value, out timeValue) + ? (object)DateTime.Today.Add(timeValue) + : null; + } + } + + public override string NullText + { + get { return txtEdit.Properties.NullValuePrompt; } + set + { + if (!string.IsNullOrEmpty(value)) + { + txtEdit.Properties.NullValuePromptShowForEmptyValue = true; + txtEdit.Properties.NullValuePrompt = value; + } + base.NullText = value; + } + } + + public override bool ReadOnly + { + get { return base.ReadOnly; } + set + { + base.ReadOnly = value; + txtEdit.Properties.ReadOnly = value; + txtEdit.Enabled = !value; + lblText.ForeColor = value ? ReadOnlyLabelForceColor : Required ? RequiredLabelForceColor : DefaultLabelForceColor; + } + } + + public override bool Required + { + get { return base.Required; } + set + { + base.Required = value; + if (value) + { + lblText.ForeColor = RequiredLabelForceColor; + } + } + } + + public override Color BackgroundColor + { + get { return txtEdit.Properties.Appearance.BackColor; } + set { txtEdit.Properties.Appearance.BackColor = value; } + } + + public override Color ForeColor + { + get { return txtEdit.Properties.Appearance.ForeColor; } + set { txtEdit.Properties.Appearance.ForeColor = value; } + } + + public override bool ContentBold + { + get { return txtEdit.Properties.Appearance.Font.Bold; } + set + { + Font oldFont = txtEdit.Properties.Appearance.Font; + txtEdit.Properties.Appearance.Font = new Font(oldFont.FontFamily, oldFont.Size, value ? FontStyle.Bold : FontStyle.Regular); + } + } + + /// + /// 设置时间的显示和输入格式。 + /// + public void TimeFormat(string value) + { + if (string.IsNullOrWhiteSpace(value)) + { + return; + } + + formatString = value; + txtEdit.Properties.DisplayFormat.FormatString = value; + txtEdit.Properties.EditFormat.FormatString = value; + txtEdit.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom; + txtEdit.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Custom; + txtEdit.Properties.Mask.EditMask = value; + txtEdit.Properties.Mask.UseMaskAsDisplayFormat = true; + txtEdit.Properties.TimeFormat = value.IndexOf("ss", StringComparison.OrdinalIgnoreCase) >= 0 + ? DevExpress.XtraEditors.Controls.TimeFormat.HourMinSec + : DevExpress.XtraEditors.Controls.TimeFormat.HourMin; + } + + /// + /// 按控件显示精度比较当前值和原值,避免 DateTime/TimeSpan 字符串格式差异造成误判。 + /// + public bool IsSameTime(string value) + { + TimeSpan oldTime; + TimeSpan currentTime; + bool hasOldTime = TryGetTime(value, out oldTime); + bool hasCurrentTime = TryGetTime(EditText, out currentTime); + if (!hasOldTime || !hasCurrentTime) + { + return !hasOldTime && !hasCurrentTime; + } + + if (formatString.IndexOf("ss", StringComparison.OrdinalIgnoreCase) >= 0) + { + return oldTime.Hours == currentTime.Hours && + oldTime.Minutes == currentTime.Minutes && + oldTime.Seconds == currentTime.Seconds; + } + + return oldTime.Hours == currentTime.Hours && oldTime.Minutes == currentTime.Minutes; + } + + private static bool TryGetTime(string value, out TimeSpan timeValue) + { + timeValue = TimeSpan.Zero; + if (string.IsNullOrWhiteSpace(value)) + { + return false; + } + + if (TimeSpan.TryParse(value, out timeValue)) + { + return true; + } + + DateTime dateValue; + if (DateTime.TryParse(value, out dateValue)) + { + timeValue = dateValue.TimeOfDay; + return true; + } + + return false; + } + } +} diff --git a/插件库/Lskj.Control/Lskj.Control.csproj b/插件库/Lskj.Control/Lskj.Control.csproj index d949ae9..fcc4469 100644 --- a/插件库/Lskj.Control/Lskj.Control.csproj +++ b/插件库/Lskj.Control/Lskj.Control.csproj @@ -928,6 +928,7 @@ LabelWeigh.cs + UserControl @@ -1219,6 +1220,9 @@ LabelDateEdit.cs + + UserControl + UserControl diff --git a/插件库/Lskj.Control/Model/AltButtonShortcutManager.cs b/插件库/Lskj.Control/Model/AltButtonShortcutManager.cs new file mode 100644 index 0000000..d9284e1 --- /dev/null +++ b/插件库/Lskj.Control/Model/AltButtonShortcutManager.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using DevExpress.XtraEditors; + +namespace Lskj.Control.Model +{ + /// + /// 将按钮原有的 & 助记键改为必须按 Alt 才能触发的快捷键。 + /// + public sealed class AltButtonShortcutManager + { + private sealed class ShortcutItem + { + public SimpleButton Button; + public Keys Key; + } + + private readonly List mShortcutItems = + new List(); + private bool mUpdatingText; + + /// + /// 注册按钮快捷键,并移除标题中的 &,保持界面显示为“按钮名(X)”。 + /// + public void Register(SimpleButton button, Keys defaultKey) + { + if (button == null) + { + return; + } + + ShortcutItem item = mShortcutItems.Find( + shortcut => ReferenceEquals(shortcut.Button, button)); + if (item == null) + { + item = new ShortcutItem { Button = button, Key = defaultKey }; + mShortcutItems.Add(item); + button.TextChanged += OnButtonTextChanged; + } + + UpdateShortcut(item, defaultKey); + } + + /// + /// 只响应 Alt+原助记键;未按 Alt、同时按下其他修饰键时均不处理。 + /// + public bool ProcessKey(Keys keyData) + { + if ((keyData & Keys.Modifiers) != Keys.Alt) + { + return false; + } + + Keys keyCode = keyData & Keys.KeyCode; + foreach (ShortcutItem item in mShortcutItems) + { + SimpleButton button = item.Button; + if (item.Key == keyCode && button != null && + !button.IsDisposed && button.Visible && button.Enabled) + { + button.PerformClick(); + return true; + } + } + + return false; + } + + private void OnButtonTextChanged(object sender, EventArgs e) + { + if (mUpdatingText) + { + return; + } + + SimpleButton button = sender as SimpleButton; + ShortcutItem item = mShortcutItems.Find( + shortcut => ReferenceEquals(shortcut.Button, button)); + if (item != null) + { + UpdateShortcut(item, item.Key); + } + } + + private void UpdateShortcut(ShortcutItem item, Keys defaultKey) + { + string text = item.Button.Text ?? string.Empty; + int mnemonicIndex = FindMnemonicIndex(text); + if (mnemonicIndex >= 0) + { + item.Key = (Keys)char.ToUpperInvariant(text[mnemonicIndex + 1]); + mUpdatingText = true; + try + { + item.Button.Text = text.Remove(mnemonicIndex, 1); + } + finally + { + mUpdatingText = false; + } + } + else + { + item.Key = defaultKey; + } + } + + private static int FindMnemonicIndex(string text) + { + for (int index = 0; index < text.Length - 1; index++) + { + if (text[index] == '&' && char.IsLetterOrDigit(text[index + 1])) + { + return index; + } + } + + return -1; + } + } +} diff --git a/插件库/Lskj.Control/Model/MyControl.cs b/插件库/Lskj.Control/Model/MyControl.cs index fb0416b..bb34219 100644 --- a/插件库/Lskj.Control/Model/MyControl.cs +++ b/插件库/Lskj.Control/Model/MyControl.cs @@ -2095,8 +2095,6 @@ namespace Lskj.Control.Model case ControlType.LabDate: case ControlType.LabDateTime: case ControlType.LabDateTimeShort: - case ControlType.LabTime: - case ControlType.LabShortTime: // 日期控件 LabelDateEdit dateEdit = ctr as LabelDateEdit; if (string.IsNullOrWhiteSpace(dateEdit.FormatType)) @@ -2109,6 +2107,12 @@ namespace Lskj.Control.Model } //value = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.EditValue.ToString(); break; + case ControlType.LabTime: + case ControlType.LabShortTime: + // 时间控件只返回时分秒部分,不附带日期。 + LabelTimeEdit timeEdit = ctr as LabelTimeEdit; + value = timeEdit == null ? string.Empty : timeEdit.EditText; + break; case ControlType.LabDateHalfDay: // 日期半天控件 LabelDateHalfDayEdit dateHalfDayEdit = ctr as LabelDateHalfDayEdit; @@ -4519,11 +4523,20 @@ namespace Lskj.Control.Model Font mRowFont = new Font("Microsoft YaHei UI", 12); switch (model.FieldType) { + case ControlType.LabTime: + case ControlType.LabShortTime: + // 时间控件使用 TimeEdit,避免 DateEdit 显示日期日历。 + LabelTimeEdit timeEdit = new LabelTimeEdit(); + timeEdit.TextEdit.KeyDown += new KeyEventHandler(OnTextEditKeyDown); + timeEdit.TextEdit.TextChanged += new EventHandler(OnTextEditTextChanged); + // 时间类型固定使用时分或时分秒,避免旧的日期格式配置覆盖为年月日。 + timeEdit.TimeFormat(DateFormat.Format(model.FieldType)); + if (!isLoadBorder) timeEdit.TextEdit.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + baseControl = timeEdit; + break; case ControlType.LabDate: case ControlType.LabDateTime: case ControlType.LabDateTimeShort: - case ControlType.LabTime: - case ControlType.LabShortTime: case ControlType.LabShortDate: // 日期控件 LabelDateEdit dateEdit = new LabelDateEdit(); @@ -6699,6 +6712,10 @@ namespace Lskj.Control.Model LabelDateEdit dateEdit = controlObj as LabelDateEdit; value = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.DateTime.ToString("yyyy-MM-dd"); } + else if (controlObj is LabelTimeEdit) + { + value = ((LabelTimeEdit)controlObj).EditText; + } else if (controlObj is LabelCheckEdit) { LabelCheckEdit checkEdit = controlObj as LabelCheckEdit; diff --git a/插件库/Lskj.Control/ModuleGridEx.Designer.cs b/插件库/Lskj.Control/ModuleGridEx.Designer.cs index 9410207..91ec22d 100644 --- a/插件库/Lskj.Control/ModuleGridEx.Designer.cs +++ b/插件库/Lskj.Control/ModuleGridEx.Designer.cs @@ -34,15 +34,14 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.pm_print = new DevExpress.XtraBars.PopupMenu(this.components); - this.barManager1 = new DevExpress.XtraBars.BarManager(this.components); + this.pm_print = new DevExpress.XtraBars.PopupMenu(); + this.barManager1 = new DevExpress.XtraBars.BarManager(); this.barDockControlTop = new DevExpress.XtraBars.BarDockControl(); this.barDockControlBottom = new DevExpress.XtraBars.BarDockControl(); this.barDockControlLeft = new DevExpress.XtraBars.BarDockControl(); this.barDockControlRight = new DevExpress.XtraBars.BarDockControl(); - this.pm_oper = new DevExpress.XtraBars.PopupMenu(this.components); - this.pm_common = new DevExpress.XtraBars.PopupMenu(this.components); + this.pm_oper = new DevExpress.XtraBars.PopupMenu(); + this.pm_common = new DevExpress.XtraBars.PopupMenu(); this.grouptip = new System.Windows.Forms.GroupBox(); this.TipsPanel = new System.Windows.Forms.Panel(); this.scc_container = new DevExpress.XtraEditors.SplitContainerControl(); @@ -343,7 +342,7 @@ this.btnFixSearch.Name = "btnFixSearch"; this.btnFixSearch.Size = new System.Drawing.Size(63, 24); this.btnFixSearch.TabIndex = 33; - this.btnFixSearch.Text = "查询(&Q)"; + this.btnFixSearch.Text = "查询(Q)"; // // txtFixKey // @@ -439,7 +438,7 @@ this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(72, 26); this.btnSave.TabIndex = 37; - this.btnSave.Text = "保存(&S)"; + this.btnSave.Text = "保存(S)"; this.btnSave.Click += new System.EventHandler(this.OnSaveClick); // // btnUpdate @@ -451,7 +450,7 @@ this.btnUpdate.Name = "btnUpdate"; this.btnUpdate.Size = new System.Drawing.Size(72, 26); this.btnUpdate.TabIndex = 38; - this.btnUpdate.Text = "修改(&U)"; + this.btnUpdate.Text = "修改(U)"; this.btnUpdate.Visible = false; this.btnUpdate.Click += new System.EventHandler(this.OnUpdateClick); // @@ -464,7 +463,7 @@ this.btnPrint.Name = "btnPrint"; this.btnPrint.Size = new System.Drawing.Size(72, 26); this.btnPrint.TabIndex = 37; - this.btnPrint.Text = "打印(&P)"; + this.btnPrint.Text = "打印(P)"; this.btnPrint.Visible = false; this.btnPrint.Click += new System.EventHandler(this.OnPrintClick); // @@ -477,7 +476,7 @@ this.btnExport.Name = "btnExport"; this.btnExport.Size = new System.Drawing.Size(72, 26); this.btnExport.TabIndex = 37; - this.btnExport.Text = "导出(&E)"; + this.btnExport.Text = "导出(E)"; this.btnExport.Visible = false; this.btnExport.Click += new System.EventHandler(this.OnExportClick); // @@ -490,7 +489,7 @@ this.btnImport.Name = "btnImport"; this.btnImport.Size = new System.Drawing.Size(72, 26); this.btnImport.TabIndex = 37; - this.btnImport.Text = "导入(&I)"; + this.btnImport.Text = "导入(I)"; this.btnImport.Visible = false; this.btnImport.Click += new System.EventHandler(this.OnImportClick); // @@ -503,7 +502,7 @@ this.btnDel.Name = "btnDel"; this.btnDel.Size = new System.Drawing.Size(72, 26); this.btnDel.TabIndex = 36; - this.btnDel.Text = "删除(&D)"; + this.btnDel.Text = "删除(D)"; this.btnDel.Click += new System.EventHandler(this.OnDelClick); // // btnAdd @@ -515,7 +514,7 @@ this.btnAdd.Name = "btnAdd"; this.btnAdd.Size = new System.Drawing.Size(72, 26); this.btnAdd.TabIndex = 35; - this.btnAdd.Text = "增加(&A)"; + this.btnAdd.Text = "增加(A)"; this.btnAdd.Click += new System.EventHandler(this.OnAddClick); // // ModuleGridEx diff --git a/插件库/Lskj.Control/ModuleGridEx.cs b/插件库/Lskj.Control/ModuleGridEx.cs index 17a3460..91584ad 100644 --- a/插件库/Lskj.Control/ModuleGridEx.cs +++ b/插件库/Lskj.Control/ModuleGridEx.cs @@ -53,6 +53,9 @@ namespace Lskj.Control /// public partial class ModuleGridEx : UserControl { + private readonly AltButtonShortcutManager mAltButtonShortcuts = + new AltButtonShortcutManager(); + #region private property /// @@ -3702,10 +3705,30 @@ namespace Lskj.Control public ModuleGridEx() { InitializeComponent(); + InitializeAltButtonShortcuts(); this.OperShortMode = true; this.Disposed += OnModuleGridExDisposed; } + private void InitializeAltButtonShortcuts() + { + mAltButtonShortcuts.Register(btnFixSearch, Keys.Q); + mAltButtonShortcuts.Register(btnSave, Keys.S); + mAltButtonShortcuts.Register(btnUpdate, Keys.U); + mAltButtonShortcuts.Register(btnPrint, Keys.P); + mAltButtonShortcuts.Register(btnExport, Keys.E); + mAltButtonShortcuts.Register(btnImport, Keys.I); + mAltButtonShortcuts.Register(btnDel, Keys.D); + mAltButtonShortcuts.Register(btnAdd, Keys.A); + } + + protected override bool ProcessCmdKey( + ref System.Windows.Forms.Message msg, Keys keyData) + { + return mAltButtonShortcuts.ProcessKey(keyData) || + base.ProcessCmdKey(ref msg, keyData); + } + /// /// 清理公共事件和全局右键引用,避免模块关闭后仍保留当前表格。 /// diff --git a/插件库/Lskj.Control/ModulePanelEx.Designer.cs b/插件库/Lskj.Control/ModulePanelEx.Designer.cs index 8c0c538..18e07ad 100644 --- a/插件库/Lskj.Control/ModulePanelEx.Designer.cs +++ b/插件库/Lskj.Control/ModulePanelEx.Designer.cs @@ -310,7 +310,7 @@ namespace Lskj.Control this.btnAttach.Size = new System.Drawing.Size(80, 28); this.btnAttach.TabIndex = 6; this.btnAttach.TabStop = false; - this.btnAttach.Text = "附件管理(&F)"; + this.btnAttach.Text = "附件管理(F)"; // // btnUpdate // @@ -321,7 +321,7 @@ namespace Lskj.Control this.btnUpdate.Size = new System.Drawing.Size(80, 28); this.btnUpdate.TabIndex = 4; this.btnUpdate.TabStop = false; - this.btnUpdate.Text = "修改保存(&E)"; + this.btnUpdate.Text = "修改保存(E)"; // // ddb_common // @@ -342,7 +342,7 @@ namespace Lskj.Control this.btnApply.Name = "btnApply"; this.btnApply.Size = new System.Drawing.Size(80, 28); this.btnApply.TabIndex = 5; - this.btnApply.Text = "提交审核(&R)"; + this.btnApply.Text = "提交审核(R)"; // // btnAdd // @@ -353,7 +353,7 @@ namespace Lskj.Control this.btnAdd.Size = new System.Drawing.Size(80, 28); this.btnAdd.TabIndex = 3; this.btnAdd.TabStop = false; - this.btnAdd.Text = "添加保存(&A)"; + this.btnAdd.Text = "添加保存(A)"; // // btnClose // @@ -364,7 +364,7 @@ namespace Lskj.Control this.btnClose.Size = new System.Drawing.Size(80, 28); this.btnClose.TabIndex = 10; this.btnClose.TabStop = false; - this.btnClose.Text = "退出(&C)"; + this.btnClose.Text = "退出(C)"; // // simpleButton1 // diff --git a/插件库/Lskj.Control/ModulePanelEx.cs b/插件库/Lskj.Control/ModulePanelEx.cs index ee4f880..a5929d9 100644 --- a/插件库/Lskj.Control/ModulePanelEx.cs +++ b/插件库/Lskj.Control/ModulePanelEx.cs @@ -47,6 +47,9 @@ namespace Lskj.Control /// public partial class ModulePanelEx : UserControl { + private readonly AltButtonShortcutManager mAltButtonShortcuts = + new AltButtonShortcutManager(); + public LabelTextEdit ScanEdit { get { return this._scanEdit; } } #region private property @@ -228,6 +231,7 @@ namespace Lskj.Control { SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.Selectable | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true); InitializeComponent(); + InitializeAltButtonShortcuts(); this.scc_container.PanelVisibility = SplitPanelVisibility.Panel1; this.simpleButton1.Click += simpleButton1_Click; this.btnClear.Click += OnBtnClearClick; @@ -241,6 +245,22 @@ namespace Lskj.Control this.BtnMesClose.Click += OnBtnMesCloseClick; } + private void InitializeAltButtonShortcuts() + { + mAltButtonShortcuts.Register(btnAttach, Keys.F); + mAltButtonShortcuts.Register(btnUpdate, Keys.E); + mAltButtonShortcuts.Register(btnApply, Keys.R); + mAltButtonShortcuts.Register(btnAdd, Keys.A); + mAltButtonShortcuts.Register(btnClose, Keys.C); + } + + protected override bool ProcessCmdKey( + ref System.Windows.Forms.Message msg, Keys keyData) + { + return mAltButtonShortcuts.ProcessKey(keyData) || + base.ProcessCmdKey(ref msg, keyData); + } + #region private method /// /// 说明:控制滚动条是否存在横向的 @@ -360,9 +380,9 @@ namespace Lskj.Control this.btnUpdate.Location = this.btnApply.Location; } // 设置文本 - btnAdd.Text = !string.IsNullOrWhiteSpace(this.SysModel.AddCaption) ? this.SysModel.AddCaption : "添加保存(&A)"; - btnUpdate.Text = !string.IsNullOrWhiteSpace(this.SysModel.ModifyCaption) ? this.SysModel.ModifyCaption : "修改保存(&E)"; - btnApply.Text = !string.IsNullOrWhiteSpace(this.SysModel.ApplyCaption) ? this.SysModel.ApplyCaption : "提交审核(&R)"; + btnAdd.Text = !string.IsNullOrWhiteSpace(this.SysModel.AddCaption) ? this.SysModel.AddCaption : "添加保存(A)"; + btnUpdate.Text = !string.IsNullOrWhiteSpace(this.SysModel.ModifyCaption) ? this.SysModel.ModifyCaption : "修改保存(E)"; + btnApply.Text = !string.IsNullOrWhiteSpace(this.SysModel.ApplyCaption) ? this.SysModel.ApplyCaption : "提交审核(R)"; //隐藏帮助文档按钮 if (SystemInfo.Instance.HideHelpDocument) this.simpleButton1.Visible = false; diff --git a/插件库/Lskj.PubAccraditation/FrmAccraditation.Designer.cs b/插件库/Lskj.PubAccraditation/FrmAccraditation.Designer.cs index c75c055..2eb5e06 100644 --- a/插件库/Lskj.PubAccraditation/FrmAccraditation.Designer.cs +++ b/插件库/Lskj.PubAccraditation/FrmAccraditation.Designer.cs @@ -432,7 +432,7 @@ this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(67, 23); this.btnSave.TabIndex = 17; - this.btnSave.Text = "保存(&S)"; + this.btnSave.Text = "保存(S)"; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // // dpb_Tools @@ -481,7 +481,7 @@ this.btnSpare.Name = "btnSpare"; this.btnSpare.Size = new System.Drawing.Size(67, 23); this.btnSpare.TabIndex = 19; - this.btnSpare.Text = "分单(&P)"; + this.btnSpare.Text = "分单(P)"; this.btnSpare.Click += new System.EventHandler(this.btnSpare_Click); // // btnPrint @@ -508,7 +508,7 @@ this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(75, 23); this.btnClose.TabIndex = 5; - this.btnClose.Text = "关闭(&Q)"; + this.btnClose.Text = "关闭(Q)"; this.btnClose.Click += new System.EventHandler(this.btnClose_Click); // // btnRemindBack @@ -533,7 +533,7 @@ this.btnBack.Name = "btnBack"; this.btnBack.Size = new System.Drawing.Size(75, 23); this.btnBack.TabIndex = 4; - this.btnBack.Text = "返退(&N)"; + this.btnBack.Text = "返退(N)"; this.btnBack.Click += new System.EventHandler(this.btnReturn_Click); // // btnRemindAccradit @@ -558,7 +558,7 @@ this.btnAccradit.Name = "btnAccradit"; this.btnAccradit.Size = new System.Drawing.Size(75, 23); this.btnAccradit.TabIndex = 3; - this.btnAccradit.Text = "审核(&Y)"; + this.btnAccradit.Text = "审核(Y)"; this.btnAccradit.Click += new System.EventHandler(this.btnAccradit_Click); // // label_date diff --git a/插件库/Lskj.PubAccraditation/FrmAccraditation.cs b/插件库/Lskj.PubAccraditation/FrmAccraditation.cs index 6c5eb88..b05b321 100644 --- a/插件库/Lskj.PubAccraditation/FrmAccraditation.cs +++ b/插件库/Lskj.PubAccraditation/FrmAccraditation.cs @@ -44,9 +44,29 @@ namespace Lskj.PubAccraditation /// public partial class FrmAccraditation : BaseForm { + private readonly AltButtonShortcutManager mAltButtonShortcuts = + new AltButtonShortcutManager(); + public FrmAccraditation() { InitializeComponent(); + InitializeAltButtonShortcuts(); + } + + private void InitializeAltButtonShortcuts() + { + mAltButtonShortcuts.Register(btnSave, Keys.S); + mAltButtonShortcuts.Register(btnSpare, Keys.P); + mAltButtonShortcuts.Register(btnClose, Keys.Q); + mAltButtonShortcuts.Register(btnBack, Keys.N); + mAltButtonShortcuts.Register(btnAccradit, Keys.Y); + } + + protected override bool ProcessCmdKey( + ref System.Windows.Forms.Message msg, Keys keyData) + { + return mAltButtonShortcuts.ProcessKey(keyData) || + base.ProcessCmdKey(ref msg, keyData); } private void ReleaseResourcesForDispose() @@ -2203,8 +2223,8 @@ namespace Lskj.PubAccraditation { this.btnAccradit.Enabled = true; this.btnRemindAccradit.Visible = this.btnRemindBack.Visible = this.btnSave.Visible = this.btnClose.Visible = this.btnSpare.Visible = this.btnBack.Visible = false; - this.btnAccradit.Text = "确认(&Y)"; - this.btnAccradit.Text = "确认(&Y)"; + this.btnAccradit.Text = "确认(Y)"; + this.btnAccradit.Text = "确认(Y)"; this.label_auditPerson.Text = "确认意见"; this.label_date.EditText = "会签人"; this.txtRemark.Text = "确认"; diff --git a/插件库/Lskj.PubBill/BillModule.Designer.cs b/插件库/Lskj.PubBill/BillModule.Designer.cs index 813f0e6..f39f27b 100644 --- a/插件库/Lskj.PubBill/BillModule.Designer.cs +++ b/插件库/Lskj.PubBill/BillModule.Designer.cs @@ -28,16 +28,17 @@ /// private void InitializeComponent() { - this.barManager1 = new DevExpress.XtraBars.BarManager(); + this.components = new System.ComponentModel.Container(); + this.barManager1 = new DevExpress.XtraBars.BarManager(this.components); this.barDockControl1 = new DevExpress.XtraBars.BarDockControl(); this.barDockControl2 = new DevExpress.XtraBars.BarDockControl(); this.barDockControl3 = new DevExpress.XtraBars.BarDockControl(); this.barDockControl5 = new DevExpress.XtraBars.BarDockControl(); - this.pmFP = new DevExpress.XtraBars.PopupMenu(); - this.pmBillExp = new DevExpress.XtraBars.PopupMenu(); - this.pmBill = new DevExpress.XtraBars.PopupMenu(); - this.pMprint = new DevExpress.XtraBars.PopupMenu(); - this.pMenu = new DevExpress.XtraBars.PopupMenu(); + this.pmFP = new DevExpress.XtraBars.PopupMenu(this.components); + this.pmBillExp = new DevExpress.XtraBars.PopupMenu(this.components); + this.pmBill = new DevExpress.XtraBars.PopupMenu(this.components); + this.pMprint = new DevExpress.XtraBars.PopupMenu(this.components); + this.pMenu = new DevExpress.XtraBars.PopupMenu(this.components); this.tb_buttom = new Lskj.Control.TabControlEx(); this.ssc_main_top = new DevExpress.XtraEditors.SplitContainerControl(); this.pl_left = new DevExpress.XtraEditors.PanelControl(); diff --git a/插件库/Lskj.PubSpec/FrmMain.Designer.cs b/插件库/Lskj.PubSpec/FrmMain.Designer.cs index 4fe236b..e17f5ad 100644 --- a/插件库/Lskj.PubSpec/FrmMain.Designer.cs +++ b/插件库/Lskj.PubSpec/FrmMain.Designer.cs @@ -133,9 +133,11 @@ this.gcMain.AdapterObj = null; this.gcMain.Dock = System.Windows.Forms.DockStyle.Fill; this.gcMain.Location = new System.Drawing.Point(0, 0); + this.gcMain.Margin = new System.Windows.Forms.Padding(4); this.gcMain.Name = "gcMain"; this.gcMain.SiftEnumObj = Lskj.Control.GridControlEx.HeaderSiftEnum.Sum; this.gcMain.Size = new System.Drawing.Size(597, 548); + this.gcMain.SysModel = null; this.gcMain.TabIndex = 2; // // panelControl4 @@ -173,7 +175,7 @@ this.btnExport.Name = "btnExport"; this.btnExport.Size = new System.Drawing.Size(72, 26); this.btnExport.TabIndex = 15; - this.btnExport.Text = "导出(&E)"; + this.btnExport.Text = "导出(E)"; this.btnExport.Click += new System.EventHandler(this.OnExportClick); // // btnShowAll @@ -193,7 +195,7 @@ this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(72, 26); this.btnSave.TabIndex = 13; - this.btnSave.Text = "保存(&S)"; + this.btnSave.Text = "保存(S)"; this.btnSave.Click += new System.EventHandler(this.OnSaveButtonClick); // // btnDelete @@ -203,7 +205,7 @@ this.btnDelete.Name = "btnDelete"; this.btnDelete.Size = new System.Drawing.Size(72, 26); this.btnDelete.TabIndex = 12; - this.btnDelete.Text = "删除(&D)"; + this.btnDelete.Text = "删除(D)"; this.btnDelete.Click += new System.EventHandler(this.OnDeleteButtonClick); // // btnAdd @@ -213,7 +215,7 @@ this.btnAdd.Name = "btnAdd"; this.btnAdd.Size = new System.Drawing.Size(72, 26); this.btnAdd.TabIndex = 11; - this.btnAdd.Text = "增加(&A)"; + this.btnAdd.Text = "增加(A)"; this.btnAdd.Click += new System.EventHandler(this.OnAddButtonClick); // // btnRefresh @@ -223,7 +225,7 @@ this.btnRefresh.Name = "btnRefresh"; this.btnRefresh.Size = new System.Drawing.Size(72, 26); this.btnRefresh.TabIndex = 10; - this.btnRefresh.Text = "刷新(&R)"; + this.btnRefresh.Text = "刷新(R)"; this.btnRefresh.Click += new System.EventHandler(this.OnRefreshButtonClick); // // panelControl3 @@ -306,4 +308,4 @@ private DevExpress.XtraEditors.SimpleButton btnExport; private DevExpress.XtraEditors.SimpleButton simpleButton1; } -} \ No newline at end of file +} diff --git a/插件库/Lskj.PubSpec/FrmMain.cs b/插件库/Lskj.PubSpec/FrmMain.cs index 397805f..9aab3d8 100644 --- a/插件库/Lskj.PubSpec/FrmMain.cs +++ b/插件库/Lskj.PubSpec/FrmMain.cs @@ -30,6 +30,9 @@ namespace Lskj.PubSpec { public partial class FrmMain : BaseForm { + private readonly AltButtonShortcutManager mAltButtonShortcuts = + new AltButtonShortcutManager(); + private bool _existsPid = false; /// /// 主键 @@ -59,6 +62,23 @@ namespace Lskj.PubSpec public FrmMain() { InitializeComponent(); + InitializeAltButtonShortcuts(); + } + + private void InitializeAltButtonShortcuts() + { + mAltButtonShortcuts.Register(btnExport, Keys.E); + mAltButtonShortcuts.Register(btnSave, Keys.S); + mAltButtonShortcuts.Register(btnDelete, Keys.D); + mAltButtonShortcuts.Register(btnAdd, Keys.A); + mAltButtonShortcuts.Register(btnRefresh, Keys.R); + } + + protected override bool ProcessCmdKey( + ref System.Windows.Forms.Message msg, Keys keyData) + { + return mAltButtonShortcuts.ProcessKey(keyData) || + base.ProcessCmdKey(ref msg, keyData); } /// diff --git a/插件库/Lskj.PubSpec2/FrmMain.Designer.cs b/插件库/Lskj.PubSpec2/FrmMain.Designer.cs index 13b86d9..cf27a1e 100644 --- a/插件库/Lskj.PubSpec2/FrmMain.Designer.cs +++ b/插件库/Lskj.PubSpec2/FrmMain.Designer.cs @@ -213,7 +213,7 @@ this.btnExport.Name = "btnExport"; this.btnExport.Size = new System.Drawing.Size(72, 26); this.btnExport.TabIndex = 19; - this.btnExport.Text = "导出(&E)"; + this.btnExport.Text = "导出(E)"; this.btnExport.Click += new System.EventHandler(this.OnExportClick); // // btnShowAll @@ -233,7 +233,7 @@ this.btnRefresh.Name = "btnRefresh"; this.btnRefresh.Size = new System.Drawing.Size(72, 26); this.btnRefresh.TabIndex = 17; - this.btnRefresh.Text = "刷新(&R)"; + this.btnRefresh.Text = "刷新(R)"; this.btnRefresh.Click += new System.EventHandler(this.OnRefreshButtonClick); // // FrmMain diff --git a/插件库/Lskj.PubSpec2/FrmMain.cs b/插件库/Lskj.PubSpec2/FrmMain.cs index cbd2b00..0eccc15 100644 --- a/插件库/Lskj.PubSpec2/FrmMain.cs +++ b/插件库/Lskj.PubSpec2/FrmMain.cs @@ -28,6 +28,9 @@ namespace Lskj.PubSpec2 { public partial class FrmMain : BaseForm { + private readonly AltButtonShortcutManager mAltButtonShortcuts = + new AltButtonShortcutManager(); + private bool _existsPid = false; /// /// 主键 @@ -55,6 +58,20 @@ namespace Lskj.PubSpec2 public FrmMain() { InitializeComponent(); + InitializeAltButtonShortcuts(); + } + + private void InitializeAltButtonShortcuts() + { + mAltButtonShortcuts.Register(btnExport, Keys.E); + mAltButtonShortcuts.Register(btnRefresh, Keys.R); + } + + protected override bool ProcessCmdKey( + ref System.Windows.Forms.Message msg, Keys keyData) + { + return mAltButtonShortcuts.ProcessKey(keyData) || + base.ProcessCmdKey(ref msg, keyData); } private void ReleaseResourcesForDispose()