I have a Login form and the user logs in by swiping their RFID Tag.
I also have a section in the application (win Forms) where an Admin user can add aditional users to the system and assign them a tag(for login)
My TagRead event is triggered in Login, and I see no point in closing the connection to the reader after login just to open one again on another form in the same application.
Problem is on my AddUser form when I scan the tag to assing to the user the TagRead Event is triggered on the login form (where the connection was established)
So what do I do?
Try to listen to the event finishing on the login form and then read tag data on AddUser? can I trigger the read event to happen in AddUser form?
What I have tried:
I have read up on Delegates and tried creating a delegate on the login form for the TagRead event and then assign that event to a method in the AddUser form
LOGIN_Frm
public delegate void EventHandler(object sender, TagReadEventArgs e);
EventHandler EventHandlerDelegate;
public event EventHandler Read
{
add
{
this.EventHandlerDelegate += value;
}
remove
{
this.EventHandlerDelegate -= value;
}
}
private void Reader_OnTagRead(object sender, TagReadEventArgs e)
{
tags.Add(e.RrfidTag);
BindList();
if (this.EventHandlerDelegate != null)
{
EventArgs e2 = new EventArgs();
object[] args = new object[] { sender, e };
foreach (Delegate handler in this.EventHandlerDelegate.GetInvocationList())
{
handler.DynamicInvoke(args);
if (e.Handled)
break;
}
}
}
AddUser frm
Login frmLogin = new Login();
this.frmLogin.Read += new ControlTestApp.Login.EventHandler(this.Reader_OnTagRead);
private void Reader_OnTagRead(object sender, TagReadEventArgs e)
{
}
but this still does not trigger the event/method in the Add User form
I dont have an event on AddUser that can trigger the event on Login I kind of either need Login to say "hey I just read a tag" or I need AddUser to say "have you read a tag yet? how about now?"