/// ----------------------------------------------------------------------------------------
 /// <summary>
 /// Show SEB Password Dialog Form.
 /// </summary>
 /// ----------------------------------------------------------------------------------------
 public static string ShowPasswordDialogForm(string title, string passwordRequestText)
 {
     using (SebPasswordDialogForm sebPasswordDialogForm = new SebPasswordDialogForm())
     {
         SetForegroundWindow(sebPasswordDialogForm.Handle);
         sebPasswordDialogForm.TopMost = true;
         // Set the title of the dialog window
         sebPasswordDialogForm.Text = title;
         // Set the text of the dialog
         sebPasswordDialogForm.LabelText = passwordRequestText;
         sebPasswordDialogForm.txtSEBPassword.Focus();
         // If we are running in SebWindowsClient we need to activate it before showing the password dialog
         // Don't do this; it will fail when the password dialog is running in a separate thread
         //if (SEBClientInfo.SebWindowsClientForm != null) SEBClientInfo.SebWindowsClientForm.Activate();
         // Show password dialog as a modal dialog and determine if DialogResult = OK.
         if (sebPasswordDialogForm.ShowDialog() == DialogResult.OK)
         {
             // Read the contents of testDialog's TextBox.
             string password = sebPasswordDialogForm.txtSEBPassword.Text;
             sebPasswordDialogForm.txtSEBPassword.Text = "";
             //sebPasswordDialogForm.txtSEBPassword.Focus();
             return password;
         }
         else
         {
             return null;
         }
     }
 }
Example #2
0
 /// ----------------------------------------------------------------------------------------
 /// <summary>
 /// Show SEB Password Dialog Form.
 /// </summary>
 /// ----------------------------------------------------------------------------------------
 public static string ShowPasswordDialogForm(string title, string passwordRequestText)
 {
     using (SebPasswordDialogForm sebPasswordDialogForm = new SebPasswordDialogForm())
     {
         SetForegroundWindow(sebPasswordDialogForm.Handle);
         sebPasswordDialogForm.TopMost = true;
         // Set the title of the dialog window
         sebPasswordDialogForm.Text = title;
         // Set the text of the dialog
         sebPasswordDialogForm.LabelText = passwordRequestText;
         sebPasswordDialogForm.txtSEBPassword.Focus();
         // If we are running in SebWindowsClient we need to activate it before showing the password dialog
         // Don't do this; it will fail when the password dialog is running in a separate thread
         //if (SEBClientInfo.SebWindowsClientForm != null) SEBClientInfo.SebWindowsClientForm.Activate();
         // Show password dialog as a modal dialog and determine if DialogResult = OK.
         if (sebPasswordDialogForm.ShowDialog() == DialogResult.OK)
         {
             // Read the contents of testDialog's TextBox.
             string password = sebPasswordDialogForm.txtSEBPassword.Text;
             sebPasswordDialogForm.txtSEBPassword.Text = "";
             //sebPasswordDialogForm.txtSEBPassword.Focus();
             return(password);
         }
         else
         {
             return(null);
         }
     }
 }
        public static string ShowPasswordDialogForm(string title, string passwordRequestText)
        {
            if (SEBClientInfo.SebWindowsClientForm != null)
            {
                SebWindowsClientMain.SEBToForeground();
            }
            if (SebWindowsClientMain.sessionCreateNewDesktop || SEBSettings.settingsCurrent.Count > 0 && (bool)SEBClientInfo.getSebSetting("touchOptimized")["touchOptimized"])
            {
                return(SebPasswordDialogForm.ShowPasswordDialogForm(title, passwordRequestText));
            }
            Worker worker = new Worker();
            Thread thread = new Thread(new ThreadStart(worker.ShowPasswordDialogInThread));

            worker.dialogTitle = title;
            worker.dialogText  = passwordRequestText;
            thread.Start();
            do
            {
                ;
            }while (!thread.IsAlive);
            thread.Join();
            if (SebWindowsClientMain.sessionCreateNewDesktop)
            {
                SEBDesktopController.Show(SEBClientInfo.SEBNewlDesktop.DesktopName);
            }
            return(worker.dialogResultText);
        }
Example #4
0
        public static string ShowPasswordDialogForm(string title, string passwordRequestText)
        {
            // If we are running in SebWindowsClient we need to activate it before showing the password dialog
            if (SEBClientInfo.SebWindowsClientForm != null)
            {
                SebWindowsClientMain.SEBToForeground();
            }

            //No longer necessary as you cannot switch from not-create-new-desktop to create-new-desktop and the other way around
            // Check if SEB is running on a separate desktop
            if (SebWindowsClientMain.sessionCreateNewDesktop)              //Switch to default desktop: SEBDesktopController.Show(SEBClientInfo.OriginalDesktop.DesktopName);
            {
                // SEB is already running on a separate desktop: we can show the password entry dialog without a separate thread
                return(SebPasswordDialogForm.ShowPasswordDialogForm(title, passwordRequestText));
            }
            //In Touch Mode, do not use the threaded Dialog because we know we can't use it
            else if (SEBSettings.settingsCurrent.Count > 0 && (Boolean)SEBClientInfo.getSebSetting(SEBSettings.KeyTouchOptimized)[SEBSettings.KeyTouchOptimized])
            {
                return(SebPasswordDialogForm.ShowPasswordDialogForm(title, passwordRequestText));
            }
            else
            {
                // SEB isn't running on a separate desktop (or not yet):
                // We need to show the password dialog in a separate thread to avoid hooks/references for the current main thread
                // (this makes switching desktops impossible in case it would be necessary later)

                // Create the thread object. This does not start the thread.
                Worker workerObject = new Worker();
                Thread workerThread = new Thread(workerObject.ShowPasswordDialogInThread);

                workerThread.SetApartmentState(ApartmentState.STA);
                workerObject.dialogTitle = title;
                workerObject.dialogText  = passwordRequestText;

                // Start the worker thread.
                workerThread.Start();

                // Loop until worker thread activates.
                while (!workerThread.IsAlive)
                {
                    ;
                }

                // Request that the worker thread stop itself:
                //workerObject.RequestStop();

                // Use the Join method to block the current thread
                // until the object's thread terminates.
                workerThread.Join();

                // Switch to new desktop
                if (SebWindowsClientMain.sessionCreateNewDesktop)
                {
                    SEBDesktopController.Show(SEBClientInfo.SEBNewlDesktop.DesktopName);
                }

                return(workerObject.dialogResultText);
            }
        }
 public static string ShowPasswordDialogForm(string title, string passwordRequestText)
 {
     using (SebPasswordDialogForm passwordDialogForm = new SebPasswordDialogForm())
     {
         SebPasswordDialogForm.SetForegroundWindow(passwordDialogForm.Handle);
         passwordDialogForm.TopMost   = true;
         passwordDialogForm.Text      = title;
         passwordDialogForm.LabelText = passwordRequestText;
         passwordDialogForm.txtSEBPassword.Focus();
         if (passwordDialogForm.ShowDialog() != DialogResult.OK)
         {
             return((string)null);
         }
         string text = passwordDialogForm.txtSEBPassword.Text;
         passwordDialogForm.txtSEBPassword.Text = "";
         return(text);
     }
 }
 public void ShowPasswordDialogInThread()
 {
     this.dialogResultText = SebPasswordDialogForm.ShowPasswordDialogForm(this.dialogTitle, this.dialogText);
 }