Merge pull request #183 from ivandrofly/patch-10

Refact & more keys allowed
This commit is contained in:
Nikolaj Olsson 2014-06-23 20:13:40 +02:00
commit cac2d68aac
3 changed files with 38 additions and 22 deletions

View File

@ -560,6 +560,7 @@ namespace Nikse.SubtitleEdit.Forms
Paragraph p = _subtitle.Paragraphs[i];
if (p.Text.Trim().Length == 0)
{
continue;
}
else
{

View File

@ -86,7 +86,8 @@ namespace Nikse.SubtitleEdit.Forms
(e.KeyValue >= 96 && e.KeyValue <= 105))
{
}
else if (e.KeyData == (Keys.Shift | Keys.Home) || e.KeyData == (Keys.Shift | Keys.End))
else if (e.KeyData == (Keys.Shift | Keys.Home) || e.KeyData == (Keys.Shift | Keys.End) ||
e.KeyCode == (Keys.MButton | Keys.Space) || e.KeyCode == (Keys.LButton | Keys.RButton | Keys.Space))
{
}
else if (e.KeyCode == Keys.Enter)
@ -104,7 +105,6 @@ namespace Nikse.SubtitleEdit.Forms
}
else if (e.Modifiers != Keys.Control && e.Modifiers != Keys.Alt)
{
e.Handled = true;
e.SuppressKeyPress = true;
}
}

View File

@ -37,31 +37,46 @@ namespace Nikse.SubtitleEdit.Forms
private void TextBox1KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.D0 ||
e.KeyCode == Keys.D1 ||
e.KeyCode == Keys.D2 ||
e.KeyCode == Keys.D3 ||
e.KeyCode == Keys.D4 ||
e.KeyCode == Keys.D5 ||
e.KeyCode == Keys.D6 ||
e.KeyCode == Keys.D7 ||
e.KeyCode == Keys.D8 ||
e.KeyCode == Keys.D9 ||
e.KeyCode == Keys.Delete ||
e.KeyCode == Keys.Left ||
e.KeyCode == Keys.Right ||
e.KeyCode == Keys.Back ||
(e.KeyValue >= 96 && e.KeyValue <= 105))
{
}
else if (e.KeyCode == Keys.Enter)
if (e.KeyCode == Keys.Enter)
{
ButtonOkClick(null, null);
}
else
{
e.Handled = true;
e.SuppressKeyPress = true;
if (e.KeyCode == Keys.D0 ||
e.KeyCode == Keys.D1 ||
e.KeyCode == Keys.D2 ||
e.KeyCode == Keys.D3 ||
e.KeyCode == Keys.D4 ||
e.KeyCode == Keys.D5 ||
e.KeyCode == Keys.D6 ||
e.KeyCode == Keys.D7 ||
e.KeyCode == Keys.D8 ||
e.KeyCode == Keys.D9 ||
e.KeyCode == Keys.Delete ||
e.KeyCode == Keys.Left ||
e.KeyCode == Keys.Right ||
e.KeyCode == Keys.Back ||
(e.KeyValue >= 96 && e.KeyValue <= 105))
{
}
else if (e.KeyData == (Keys.Shift | Keys.Home) || e.KeyData == (Keys.Shift | Keys.End) ||
e.KeyCode == (Keys.MButton | Keys.Space) || e.KeyCode == (Keys.LButton | Keys.RButton | Keys.Space))
{
}
else if (e.KeyData == (Keys.Control | Keys.V) && Clipboard.GetText(TextDataFormat.UnicodeText).Length > 0)
{
var p = Clipboard.GetText(TextDataFormat.UnicodeText);
int num;
if (!int.TryParse(p, out num))
{
e.SuppressKeyPress = true;
}
}
else if (e.Modifiers != Keys.Control && e.Modifiers != Keys.Alt)
{
e.SuppressKeyPress = true;
}
}
}