void DrawString_WhenPressEscape(object sender, KeyEventArgs e) { PopupTextBox s = sender as PopupTextBox; if (e.KeyCode == Keys.Escape) { s.Dispose(); _drawStatus = DrawStatus.Idle; } }
void DrawTextBox(string curText) { // Trường hợp thêm Text: chuẩn bị form Popup chứa RichtextBox để nhận vùng nhập Text Point location = PointToScreen(areaRect.Location); textRect = areaRect; textRect.Inflate(-1, -1); textBoxPopUp = new PopupTextBox(curText, textRect, location, () => { textRect.Size = textBoxPopUp.Size; this.Refresh(); }, () => TextToDraw = textBoxPopUp.TextToDraw); textBoxPopUp.Show(); textBoxPopUp.KeyDown += DrawString_WhenPressEscape; }