public static KeyBoardForm GetKeyBoardForm(TextBox textBox, string content, BtnCallBack btnCallBack) { try { var form = new KeyBoardForm(); //获得textBox控件显示的真实宽和高 var window = Window.GetWindow(textBox); var windowWidth = SystemParameters.PrimaryScreenWidth; var txtWidth = textBox.ActualWidth; var design_Width = 1920; var width = windowWidth * txtWidth / design_Width; width = width < 500 ? 500 : width; var windowHeight = SystemParameters.PrimaryScreenHeight; var txtHeight = textBox.ActualHeight; var design_Height = 1080; var height = windowHeight * txtHeight / design_Height; var point = textBox.TransformToAncestor(window).Transform(new Point(0, 0)); SetPosition(form, point.X, point.Y + height, width, 180); form.Show(); form.Activate(); form.Bind(textBox, content, btnCallBack); form.okBtn.Focus(); var hwnd = new System.Windows.Interop.WindowInteropHelper(form).Handle; WindowPosMananger.Instance.SetKeyBoardIntptr(hwnd); WindowPosMananger.Instance.SetIntPrt(hwnd, 1); return(form); } catch (Exception ex) { // Logger.WriteError(Log.KeyBoardForm, "获取键盘发生异常", ex); } return(null); }
IEnumerator AgainMsg(string msgText, BtnCallBack CallBackFun) { while (IsOpening) { yield return(new WaitForEndOfFrame()); } OpenMsgBox(msgText, CallBackFun); }
public void OnClick_Cancel() { GameApp.Instance.SoundInstance.PlaySe("button"); if (CurBtnCB != null) { CurBtnCB(false); } base.Close(AppearType.Diffusion, () => { ToShow(false); }); CurBtnCB = null; }
private void Bind(TextBox textBox, string content, BtnCallBack btnCallBack) { try { //设置确认按钮的字符串 this.okBtn.Content = content; //设置绑定的输入框 this.textBox = textBox; //绑定点击确定按钮的回调函数 this.btnCallBack = btnCallBack; } catch (Exception e) { // Logger.WriteError(Log.KeyBoardForm, "键盘绑定失败", e); } }
public static KeyBoardForm GetKeyBoardForm(TextBox textBox, string content, BtnCallBack btnCallBack, double left, double top, double width, double height) { try { KeyBoardForm form = new KeyBoardForm(); SetPosition(form, left, top, width, height); form.Show(); form.Activate(); form.Bind(textBox, content, btnCallBack); form.okBtn.Focus(); IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(form).Handle; WindowPosMananger.Instance.SetKeyBoardIntptr(hwnd); return(form); } catch (Exception ex) { // Logger.WriteError(Log.KeyBoardForm, "获得键盘发生异常", ex); } return(null); }
internal void OpenSimpleMsgBox(string msgText, BtnCallBack CallBackFun = null) { if (BoxObj.activeSelf) { if (!MsgText.text.Contains(msgText)) { Debug.Log("消息排队: " + msgText); StartCoroutine(AgainMsg(msgText, CallBackFun)); } return; } base.Open(AppearType.Popup, BoxObj); MsgText.text = msgText; CurBtnCB += CallBackFun; IsOpening = true; OKBtnObj.transform.localPosition = new Vector3(0, -140, 0); CloseBtnObj.SetActive(false); }