Dreamine.UI.WinForms 1.0.1
Dreamine.UI.WinForms 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
DreamineVirtualKeyboardAssist.cs
이 파일의 문서화 페이지로 가기
1using System.Windows.Forms;
3
5
15{
24 private static readonly Dictionary<DreamineTextBox, DreamineVirtualKeyboardForm> _open = new();
25
58 public static void Attach(DreamineTextBox textBox, VkLayout layout = VkLayout.Text)
59 {
60 textBox.Enter += (_, _) => Show(textBox, layout);
61 }
62
79 public static void Detach(DreamineTextBox textBox)
80 {
81 if (_open.TryGetValue(textBox, out var form))
82 {
83 form.Close();
84 _open.Remove(textBox);
85 }
86 }
87
112 private static void Show(DreamineTextBox textBox, VkLayout layout)
113 {
114 if (_open.ContainsKey(textBox))
115 return;
116
117 var screenLocation = textBox.Parent?.PointToScreen(textBox.Location) ?? Cursor.Position;
118 var form = new DreamineVirtualKeyboardForm(textBox, layout);
119 var workingArea = Screen.FromControl(textBox).WorkingArea;
120 var x = Math.Clamp(screenLocation.X, workingArea.Left, Math.Max(workingArea.Left, workingArea.Right - form.Width));
121 var y = screenLocation.Y + textBox.Height + 4;
122 if (y + form.Height > workingArea.Bottom)
123 y = Math.Max(workingArea.Top, screenLocation.Y - form.Height - 4);
124
125 form.Location = new System.Drawing.Point(x, y);
126 form.FormClosed += (_, _) => _open.Remove(textBox);
127
128 _open[textBox] = form;
129 form.Show();
130 }
131}
static readonly Dictionary< DreamineTextBox, DreamineVirtualKeyboardForm > _open
static void Attach(DreamineTextBox textBox, VkLayout layout=VkLayout.Text)