コード例 #1
0
        /// <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);
                }
            }
        }
コード例 #2
0
        /// <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);
                }
            }
        }
コード例 #3
0
        /// <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);
            }
        }