private void CreateErrorWindow(Canvas canvas, string error, string header, GameContentManager.UI stage) { var window = new InputBox( header, error, false, InputBox.InputType.OkayOnly, OkayClicked, null, -1, 0, canvas, stage ); mErrorWindows.Add(window); }
public InputBox( string title, string prompt, bool modal, InputType inputtype, EventHandler okayYesSubmitClicked, EventHandler cancelClicked, object userData, int quantity = 0, Base parent = null, GameContentManager.UI stage = GameContentManager.UI.InGame ) : base(parent) { if (parent == null) { parent = Interface.GameUi.GameCanvas; } OkayEventHandler = okayYesSubmitClicked; CancelEventHandler = cancelClicked; this.UserData = userData; mInputType = inputtype; _uiStage = stage; mPrompt = prompt; mMyWindow = new WindowControl(parent, title, modal, "InputBox"); mMyWindow.BeforeDraw += _myWindow_BeforeDraw; mMyWindow.DisableResizing(); mNumericTextboxBg = new ImagePanel(mMyWindow, "Textbox"); mNumericTextbox = new TextBoxNumeric(mNumericTextboxBg, "TextboxText"); mNumericTextbox.SubmitPressed += TextBox_SubmitPressed; mNumericTextbox.Text = quantity.ToString(); if (inputtype == InputType.NumericInput) { mNumericTextbox.Focus(); } mTextboxBg = new ImagePanel(mMyWindow, "Textbox"); mTextbox = new TextBox(mTextboxBg, "TextboxText"); mTextbox.SubmitPressed += TextBox_SubmitPressed; if (inputtype == InputType.TextInput) { mTextbox.Focus(); } if (inputtype != InputType.NumericInput) { mNumericTextboxBg.IsHidden = true; } if (inputtype != InputType.TextInput) { mTextboxBg.IsHidden = true; } mYesButton = new Button(mMyWindow, "YesButton"); mYesButton.SetText(Strings.InputBox.okay); mYesButton.Clicked += okayBtn_Clicked; mNoButton = new Button(mMyWindow, "NoButton"); mNoButton.SetText(Strings.InputBox.cancel); mNoButton.Clicked += cancelBtn_Clicked; mOkayButton = new Button(mMyWindow, "OkayButton"); mOkayButton.SetText(Strings.InputBox.okay); mOkayButton.Clicked += okayBtn_Clicked; mPromptLabel = new Label(mMyWindow, "PromptLabel"); Interface.InputBlockingElements.Add(this); }