INT69DB_2A/INT69DB_2A/DialogForms/DialogFormUserEditorKeyboar...

111 lines
3.1 KiB
C#

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace INT69DB_2A.DialogForms
{
public partial class DialogFormUserEditorKeyboard : Form
{
#region Field
private string m_RetStringValue;
#endregion
#region Constructor
public DialogFormUserEditorKeyboard(string value, DataStore.LanguageID language)
{
InitializeComponent();
this.textBox.Text = value;
this.RetStringValue = value;
this.InitializeControl();
this.DefaultSetting();
switch (language)
{
case DataStore.LanguageID.Korean:
this.labelTitle.Text = "입력";
break;
case DataStore.LanguageID.English:
this.labelTitle.Text = "Type";
break;
case DataStore.LanguageID.Chinese:
this.labelTitle.Text = "输入";
break;
default:
this.labelTitle.Text = "Type";
break;
}
}
#endregion
#region Property
public string RetStringValue
{
get { return this.m_RetStringValue; }
private set { this.m_RetStringValue = value; }
}
#endregion
#region Method
private void InitializeControl()
{
int x = 0, y = 0;
x = Screen.PrimaryScreen.Bounds.Width / 2 - this.Size.Width / 2;
y = Screen.PrimaryScreen.Bounds.Height / 2 - this.Size.Height / 2;
this.Location = new Point(x, y);
this.Size = new Size(713, 473);
}
private void DefaultSetting()
{
this.smartKeyboard.TargetInputObject = this.textBox;
this.smartKeyboard.KeyboardType = SmartX.SmartKeyboard.KEYBOARDTYPES.NORMAL;
this.smartKeyboard.Show();
}
private void KeyActionEnter()
{
this.RetStringValue = this.textBox.Text;
this.DialogResult = DialogResult.OK;
this.Close();
this.Dispose();
}
private void KeyActionEsc()
{
this.DialogResult = DialogResult.Cancel;
this.Close();
this.Dispose();
}
#endregion
#region Event Handler
private void textBox_KeyPress(object sender, KeyPressEventArgs e)
{
//if (e.KeyChar == '\r')
// this.KeyActionEnter();
//else if (e.KeyChar == 27)
// this.KeyActionEsc();
}
private void smartKeyboard_OnXKeyClick(object sender, EventArgs e)
{
this.KeyActionEsc();
}
private void smartKeyboard_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
this.KeyActionEnter();
else if (e.KeyCode == Keys.Escape)
this.KeyActionEsc();
}
#endregion
}
}