Files
Groupware/Project/Dialog/fTouchKeyFull.cs
2018-07-23 17:35:21 +09:00

94 lines
2.8 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Project.Dialog
{
public partial class fTouchKeyFull : Form
{
public fTouchKeyFull(string title,string value)
{
InitializeComponent();
this.lbTitle.Text = title;
this.tbInput.Text = value;
this.KeyDown += (s1, e1) =>
{
if (e1.KeyCode == Keys.Escape)
this.Close();
};
this.lbTitle.MouseMove += LbTitle_MouseMove;
this.lbTitle.MouseUp += LbTitle_MouseUp;
this.lbTitle.MouseDown += LbTitle_MouseDown;
}
private void fTouchKeyFull_Load(object sender, EventArgs e)
{
this.Show();
Application.DoEvents();
this.tbInput.SelectAll();
this.tbInput.Focus();
}
#region "Mouse Form Move"
private Boolean fMove = false;
private Point MDownPos;
private void LbTitle_MouseMove(object sender, MouseEventArgs e)
{
if (fMove)
{
Point offset = new Point(e.X - MDownPos.X, e.Y - MDownPos.Y);
this.Left += offset.X;
this.Top += offset.Y;
offset = new Point(0, 0);
}
}
private void LbTitle_MouseUp(object sender, MouseEventArgs e)
{
fMove = false;
}
private void LbTitle_MouseDown(object sender, MouseEventArgs e)
{
MDownPos = new Point(e.X, e.Y);
fMove = true;
}
#endregion
private void touchKeyFull1_keyClick(string key)
{
switch(key)
{
case "CLR":
this.tbInput.Text = string.Empty;
break;
case "BACK":
if (this.tbInput.TextLength < 2) this.tbInput.Text = string.Empty;
else this.tbInput.Text = this.tbInput.Text.Substring(0,tbInput.TextLength-1);
this.tbInput.SelectionStart = this.tbInput.TextLength;
break;
case "ENTER":
this.DialogResult = DialogResult.OK;
break;
default:
var seltext = tbInput.SelectedText;
if (seltext.Length == tbInput.TextLength) tbInput.Text = "";
this.tbInput.Text += key;
this.tbInput.SelectionStart = this.tbInput.TextLength;
break;
}
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}