/// <summary> /// Loads a login dialog that forces the user to log into the application before using it. /// If the login is successful (meaning the DialogResult is set to OK) then the specified main /// form is loaded. /// </summary> /// <typeparam name="TLogin"> /// Type of the <see cref="FormPresenter"/> that represents the login dialog /// </typeparam> /// <typeparam name="TMain"> /// Type of the <see cref="FormPresenter"/> that represents the main dialog /// </typeparam> /// <param name="enableKioskMode"> /// Set to <c>true</c> to run the application in kiosk mode (full screen) /// </param> /// <param name="enableKioskMode">Set to <c>true</c> to run the application in kiosk mode, otherwise <c>false</c></param> public static void RunWithLogin <TLogin, TMain>(bool enableKioskMode) where TLogin : FormPresenter where TMain : FormPresenter { SplashScreen.Show(); var instance = Activator.CreateInstance <TLogin>(); var loginForm = (Form)instance.FormView; if (enableKioskMode) { loginForm.Load += (sender, e) => ForceKioskMode(loginForm); } var mainForm = Activator.CreateInstance <TMain>(); SplashScreen.Hide(); var loginHwnd = SystemWindow.FindWindow(loginForm.Name, loginForm.Text); var mainHwnd = SystemWindow.FindWindow(mainForm.FormView.Name, mainForm.FormView.Text); if (loginHwnd != IntPtr.Zero || mainHwnd != IntPtr.Zero) { return; } var dialogResult = loginForm.ShowDialog(); if (dialogResult == DialogResult.OK) { Application.Run((Form)mainForm.FormView); } }
/// <summary> /// Loads a login dialog that forces the user to log into the application before using it. /// If the login is successful (meaning the DialogResult is set to OK) then the smart menu /// form is loaded. /// </summary> /// <typeparam name="TLogin"> /// Type of the <see cref="FormPresenter"/> that represents the login dialog /// </typeparam> /// <param name="enableKioskMode">Set to <c>true</c> to run the application in kiosk mode, otherwise <c>false</c></param> public static void RunWithLogin <TLogin>(bool enableKioskMode) where TLogin : FormPresenter { SplashScreen.Show(); var instance = Activator.CreateInstance <TLogin>(); var loginForm = (Form)instance.FormView; if (enableKioskMode) { loginForm.Load += (sender, e) => ForceKioskMode(loginForm); } using (var presenter = new SmartMenuPresenter()) { var smartMenuView = (MobileForm)presenter.View; ForceKioskMode(smartMenuView); var loginHwnd = SystemWindow.FindWindow(loginForm.Name, loginForm.Text); var mainHwnd = SystemWindow.FindWindow(smartMenuView.Name, smartMenuView.Text); if (loginHwnd != IntPtr.Zero || mainHwnd != IntPtr.Zero) { return; } SplashScreen.Hide(); var dialogResult = loginForm.ShowDialog(); if (dialogResult == DialogResult.OK) { Application.Run(smartMenuView); } } }
/// <summary> /// Loads a login dialog that forces the user /// to log into the application before using it. If the login is /// successful (Meaning the DialogResult is set to /// OK) then the Main Form is loaded. /// </summary> /// <param name="loginForm">Login form</param> /// <param name="mainForm">Main form</param> /// <param name="enableKioskMode">Set to <c>true</c> to run the application in kiosk mode, otherwise <c>false</c></param> public static void RunWithLogin(MobileForm loginForm, MobileForm mainForm, bool enableKioskMode) { var loginHwnd = SystemWindow.FindWindow(loginForm.Name, loginForm.Text); var mainHwnd = SystemWindow.FindWindow(mainForm.Name, mainForm.Text); if (loginHwnd != IntPtr.Zero || mainHwnd != IntPtr.Zero) { return; } SplashScreen.Show(); if (enableKioskMode) { loginForm.Load += (sender, e) => ForceKioskMode(loginForm); } var dialogResult = loginForm.ShowDialog(); if (dialogResult != DialogResult.OK) { return; } SplashScreen.Hide(); Run(mainForm); }
/// <summary> /// Loads a login dialog that forces the user /// to log into the application before using it. If the login is /// successful (Meaning the DialogResult is set to /// OK) then the Main Form is loaded. /// </summary> /// <param name="loginForm">Login form</param> /// <param name="enableKioskMode">Set to <c>true</c> to run the application in kiosk mode, otherwise <c>false</c></param> public static void RunWithLogin(MobileForm loginForm, bool enableKioskMode) { SplashScreen.Show(); loginForm.Load += (sender, e) => ForceKioskMode(loginForm); using (var presenter = new SmartMenuPresenter()) { var hwnd = SystemWindow.FindWindow(presenter.View.Name, presenter.View.Text); if (hwnd != IntPtr.Zero) { return; } var smartMenuView = (MobileForm)presenter.View; if (enableKioskMode) { ForceKioskMode(smartMenuView); } SplashScreen.Hide(); var dialogResult = loginForm.ShowDialog(); if (dialogResult == DialogResult.OK) { Application.Run(smartMenuView); } } }
/// <summary> /// Begins running a standard application message loop on the current /// thread, and makes the specified form visible. /// </summary> public static void Run() { SplashScreen.Show(); using (var presenter = new SmartMenuPresenter()) { var hwnd = SystemWindow.FindWindow(presenter.View.Name, presenter.View.Text); if (hwnd != IntPtr.Zero) { return; } SplashScreen.Hide(); Run((MobileForm)presenter.View); } }
/// <summary> /// Begins running a standard application message loop on the current /// thread, and makes the specified form visible. /// </summary> /// <param name="form"> /// A <see cref="MobileForm"/> that represents the main form of the /// application to make visible. /// </param> /// <param name="enableKioskMode">Set to <c>true</c> to run the application in kiosk mode, otherwise <c>false</c></param> public static void Run(MobileForm form, bool enableKioskMode) { var hwnd = SystemWindow.FindWindow(form.Name, form.Text); if (hwnd != IntPtr.Zero) { return; } form.Load += delegate { if (enableKioskMode) { ForceKioskMode(form); } SplashScreen.Hide(); }; Application.Run(form); }