Ejemplo n.º 1
0
        public static EditStringResult EditStringWithDropdown(string prompt, string defaultResult, string listCaption, IEnumerable <string> listItems, string defaultListSelection, IEnumerable <string> autoCompleteList = null, bool allowEmptyString = false)
        {
            EditStringResult result = new EditStringResult();

            InputWindow inputWindow = new InputWindow();

            inputWindow.lblPrompt.Text = prompt + ":";
            if (autoCompleteList != null)
            {
                inputWindow.SetAutoComplete(autoCompleteList);
            }
            inputWindow.ActiveInputControl.Text = defaultResult;
            inputWindow.ActiveInputControl.Focus();
            inputWindow.txtInput.SelectAll();

            if (listItems != null)
            {
                inputWindow.SetDropdown(listCaption, listItems, defaultListSelection);
            }

            inputWindow.ShowDialog();

            string inputResult = inputWindow.ActiveInputControl.Text;

            result.Cancelled = (inputWindow.Cancelled || (!allowEmptyString && inputResult.Length == 0));
            result.Result    = inputResult;

            if (listItems != null)
            {
                result.ListResult = inputWindow.lstDropdown.Text;
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static EditStringResult EditStringWithDropdown(string prompt, string defaultResult, string listCaption, IEnumerable<string> listItems, string defaultListSelection, IEnumerable<string> autoCompleteList = null, bool allowEmptyString = false)
        {
            EditStringResult result = new EditStringResult();

            InputWindow inputWindow = new InputWindow();
            inputWindow.lblPrompt.Text = prompt + ":";
            if (autoCompleteList != null)
            {
                inputWindow.SetAutoComplete(autoCompleteList);
            }
            inputWindow.ActiveInputControl.Text = defaultResult;
            inputWindow.ActiveInputControl.Focus();
            inputWindow.txtInput.SelectAll();

            if (listItems != null)
            {
                inputWindow.SetDropdown(listCaption, listItems, defaultListSelection);
            }

            inputWindow.ShowDialog();

            string inputResult = inputWindow.ActiveInputControl.Text;
            result.Cancelled = (inputWindow.Cancelled || (!allowEmptyString && inputResult.Length == 0));
            result.Result = inputResult;

            if (listItems != null)
            {
                result.ListResult = inputWindow.lstDropdown.Text;
            }

            return result;
        }