public static string InputBox(string Prompt, string Title = "", string DefaultResponse = "", int XPos = -1, int YPos = -1)
        {
            IWin32Window parentWindow = null;
            IVbHost      vBHost       = HostServices.VBHost;

            if (vBHost != null)
            {
                parentWindow = vBHost.GetParentWindow();
            }
            if (Title.Length == 0)
            {
                if (vBHost == null)
                {
                    Title = GetTitleFromAssembly(Assembly.GetCallingAssembly());
                }
                else
                {
                    Title = vBHost.GetWindowTitle();
                }
            }
            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
            {
                return(InternalInputBox(Prompt, Title, DefaultResponse, XPos, YPos, parentWindow));
            }
            InputBoxHandler handler = new InputBoxHandler(Prompt, Title, DefaultResponse, XPos, YPos, parentWindow);
            Thread          thread  = new Thread(new ThreadStart(handler.StartHere));

            thread.Start();
            thread.Join();
            if (handler.Exception != null)
            {
                throw handler.Exception;
            }
            return(handler.Result);
        }
Exemple #2
0
        protected void DisplayInputBox(string prompt, InputBoxHandler handler)
        {
            InputBoxPrompt     = prompt;
            InputBoxValue      = string.Empty;
            InputBoxVisibility = Visibility.Visible;

            _inputBoxHandler = handler;

            OnPropertyChanged("InputBoxPrompt");
            OnPropertyChanged("InputBoxValue");
            OnPropertyChanged("InputBoxVisibility");
        }