Last active
June 25, 2019 10:45
-
-
Save Nyconing/c2a69c7f40eae8e044f24f11d9ce8df3 to your computer and use it in GitHub Desktop.
AutoPOS Script: POSMemberEditForm (Forcefully bypassing Enter key)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BCE.AutoCount.POS.Maintenance.Member; | |
using System.Windows.Forms; | |
using System.Reflection; | |
using System.ComponentModel; | |
public void OnFormInitialize(FormAddMember.FormInitializeEventArgs args){ | |
var eventStaticNameProp = typeof(Control).GetField("EventKeyDown", BindingFlags.Static | BindingFlags.NonPublic); | |
var eventStaticName = eventStaticNameProp.GetValue(args.Form); | |
var eventsProp = args.Form.GetType().GetProperty("Events", BindingFlags.NonPublic | BindingFlags.Instance); | |
EventHandlerList list = (EventHandlerList)eventsProp.GetValue(args.Form, null); | |
list.RemoveHandler(eventStaticName, list[eventStaticName]); | |
args.Form.KeyDown += new KeyEventHandler(FormAddMember_KeyDown); | |
} | |
private void FormAddMember_KeyDown(object sender, KeyEventArgs e) { | |
Func<Type, string, FieldInfo> ReflectionGetPrivateField = (obj, name) => obj.GetField(name, BindingFlags.NonPublic | BindingFlags.Instance); | |
var form = sender as FormAddMember; | |
var btnKeyboard = (DevExpress.XtraEditors.BaseButton) ReflectionGetPrivateField(typeof(FormAddMember), "btnKeyboard").GetValue(form); | |
var btnKeyboard2 = (DevExpress.XtraEditors.BaseButton) ReflectionGetPrivateField(typeof(FormAddMember), "btnKeyboard2").GetValue(form); | |
var btnKeyboard3 = (DevExpress.XtraEditors.BaseButton) ReflectionGetPrivateField(typeof(FormAddMember), "btnKeyboard3").GetValue(form); | |
var btnKeyboard4 = (DevExpress.XtraEditors.BaseButton) ReflectionGetPrivateField(typeof(FormAddMember), "btnKeyboard4").GetValue(form); | |
var btnKeyboard5 = (DevExpress.XtraEditors.BaseButton) ReflectionGetPrivateField(typeof(FormAddMember), "btnKeyboard5").GetValue(form); | |
var btnOpeningPoints = (DevExpress.XtraEditors.BaseButton) ReflectionGetPrivateField(typeof(FormAddMember), "btnOpeningPoints").GetValue(form); | |
if (e.KeyCode == Keys.F1) | |
btnKeyboard.PerformClick(); | |
else if (e.KeyCode == Keys.F2) | |
btnKeyboard2.PerformClick(); | |
else if (e.KeyCode == Keys.F3) | |
btnKeyboard3.PerformClick(); | |
else if (e.KeyCode == Keys.F4) | |
btnKeyboard4.PerformClick(); | |
else if (e.KeyCode == Keys.F5) { | |
btnKeyboard5.PerformClick(); | |
} | |
else { | |
if (e.KeyCode != Keys.F6) | |
return; | |
btnOpeningPoints.PerformClick(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment