Ejemplo n.º 1
0
        public static string ShowFileDialogForExecutable(string fileName)
        {
            // Switch to default desktop
            if (SebWindowsClientMain.sessionCreateNewDesktop) SEBDesktopController.Show(SEBClientInfo.OriginalDesktop.DesktopName);

            // Create the thread object. This does not start the thread.
            Worker workerObject = new Worker();
            Thread workerThread = new Thread(workerObject.ShowFileDialogInThread);
            workerThread.SetApartmentState(ApartmentState.STA);
            workerObject.fileNameExecutable = fileName;

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

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

            // 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.fileNameFullPath;
        }
Ejemplo n.º 2
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 (SebInstance.Settings.Get<bool>(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);

                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;
            }
        }