Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Text;
- using System.Windows.Forms;
- using Authorization;
- public partial class frmMain : Form
- {
- public frmMain()
- {
- InitializeComponent();
- }
- #region "Authorization"
- private void btnAuthorize_Click(object sender, EventArgs e)
- {
- //Validate that user has entered correct information in textboxes.
- //Use NFAuth's constructor to your full advantage
- NFAuth auth = new NFAuth(txtUsername.Text, txtPassword.Text, PROGRAM_ID, PROGRAM_NAME, this, UpdateSub: Auth_UpdateHandler, AuthorizedSub: Auth_AuthorizedHandler, UnAuthorizedSub: Auth_UnauthorizedHandler, ExceptionSub: Auth_ExceptionHandler);
- //Settings can also be set like this:
- auth.StatusLabel = lblStatus;
- //Authorize asynchronously so it doesn't freeze the GUI
- auth.AuthorizeASync();
- //Disable your authorize button
- btnAuthorize.Enabled = false;
- }
- private void Auth_ExceptionHandler(Exception ex)
- {
- //Handle the exception (stuff like Debug.Print() might help with debugging)
- }
- private void Auth_AuthorizedHandler()
- {
- //Do something when they are authorized
- }
- private void Auth_UnauthorizedHandler()
- {
- btnAuthorize.Enabled = true;
- //Do something for handling unauthorized.
- }
- private void Auth_UpdateHandler()
- {
- //You can either require the user to update before using or just use the outdated version.
- }
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement