Skip to content

Commit

Permalink
add Shortcut for Up and Down Key
Browse files Browse the repository at this point in the history
  • Loading branch information
luvletter2333 committed Jun 13, 2021
1 parent d4ff06e commit 09a92ab
Showing 1 changed file with 22 additions and 31 deletions.
53 changes: 22 additions & 31 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,62 +108,53 @@ private void Form1_Load(object sender, EventArgs e)
}
}

private void Form1_KeyDown(object sender, KeyEventArgs e)
private bool handleShortCut(Keys keyData)
{
var keyData = e.KeyData;
if (keyData == (Keys.Control | Keys.ProcessKey))
if (keyData == (Keys.Control | Keys.ProcessKey) || keyData == (Keys.Control | Keys.Space))
{ //Fade to Blank
Console.WriteLine("ShortCut: Ctrl + Space");
btn_Clear_Fade_Click();
e.Handled = true;
return true;
}
else if (keyData == (Keys.Control | Keys.Enter))
{ //Cut to Blank
Console.WriteLine("ShortCut: Ctrl + Enter");
btn_Clear_Click();
e.Handled = true;
return true;
}
else if (keyData == Keys.Space)
{ // Fade
Console.WriteLine("ShortCut: Space");
btn_fade_Click();
e.Handled = true;
return true;
}
else if (keyData == Keys.Enter)
{ //fade to blank
Console.WriteLine("ShortCut: Enter");
btn_Hard_Click();
e.Handled = true;
}
}

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.Space))
{ //Fade to Blank
Console.WriteLine("ShortCut: Ctrl + Space");
btn_Clear_Fade_Click();
return true;
}
else if (keyData == (Keys.Control | Keys.Enter))
{ //Cut to Blank
Console.WriteLine("ShortCut: Ctrl + Enter");
btn_Clear_Click();
return true;
}
else if (keyData == Keys.Space)
{ // Fade
Console.WriteLine("ShortCut: Space");
btn_fade_Click();
else if (keyData == Keys.Up)
{
if (lst_SubTitle.SelectedIndex - 1 >= 0)
lst_SubTitle.SelectedIndex--;
return true;
}
else if (keyData == Keys.Enter)
{ //fade to blank
Console.WriteLine("ShortCut: Enter");
btn_Hard_Click();
else if (keyData == Keys.Down)
{
if (lst_SubTitle.SelectedIndex + 1 < lst_SubTitle.Items.Count)
lst_SubTitle.SelectedIndex++;
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
return false;
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
e.Handled = handleShortCut(e.KeyData);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
return handleShortCut(keyData) || base.ProcessCmdKey(ref msg, keyData);
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Expand Down

0 comments on commit 09a92ab

Please sign in to comment.