Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 private void GetKeyBoardForm(TextBox textbox)
 {
     try
     {
         _form = KeyBoardForm.GetKeyBoardForm(textbox, "确定", OkBtnClickCallBack);
     }
     catch (Exception ex)
     {
         Log.Logger.Error($"加载键盘发生异常 exception:{ex}");
     }
 }
Exemplo n.º 3
0
 private static void SetPosition(KeyBoardForm form, double left, double top, double width, double height)
 {
     try
     {
         form.Left   = left;
         form.Top    = top;
         form.Width  = width;
         form.Height = height;
     }
     catch (Exception e)
     {
         // Logger.WriteError(Log.KeyBoardForm, "设置键盘位置发生异常", e);
     }
 }
Exemplo n.º 4
0
 public static void CloseFrom(KeyBoardForm form)
 {
     try
     {
         if (form != null)
         {
             form.Close();
             WindowPosMananger.Instance.SetKeyBoardIntptr(IntPtr.Zero);
         }
     }
     catch (Exception e)
     {
         // Logger.WriteError(Log.KeyBoardForm, "设置关闭键盘窗口发生异常", e);
     }
 }
Exemplo n.º 5
0
 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);
 }