Add support for context menu keyboard key to uploads listview

This commit is contained in:
STDray 2016-05-18 18:39:59 +03:00
parent df60c24b0e
commit e9dbcdafe7
2 changed files with 33 additions and 0 deletions

View file

@ -907,6 +907,8 @@ private void InitializeComponent()
this.tsmiImagePreview});
this.cmsTaskInfo.Name = "cmsHistory";
resources.ApplyResources(this.cmsTaskInfo, "cmsTaskInfo");
this.cmsTaskInfo.Closing += new System.Windows.Forms.ToolStripDropDownClosingEventHandler(this.cmsTaskInfo_Closing);
this.cmsTaskInfo.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.cmsTaskInfo_PreviewKeyDown);
//
// tsmiShowErrors
//

View file

@ -1319,11 +1319,42 @@ private void lvUploads_KeyDown(object sender, KeyEventArgs e)
uim.DeleteFiles();
RemoveSelectedItems();
break;
case Keys.Apps:
if (lvUploads.SelectedItems.Count > 0)
{
UpdateContextMenu();
cmsTaskInfo.Show(lvUploads, lvUploads.SelectedItems[0].Position);
}
break;
}
e.Handled = e.SuppressKeyPress = true;
}
private void cmsTaskInfo_Closing(object sender, ToolStripDropDownClosingEventArgs e)
{
switch (e.CloseReason)
{
default:
return;
case ToolStripDropDownCloseReason.Keyboard:
e.Cancel = !(NativeMethods.GetKeyState((int)Keys.Apps) < 0 || NativeMethods.GetKeyState((int)Keys.F10) < 0 || NativeMethods.GetKeyState((int)Keys.Escape) < 0);
break;
}
}
private void cmsTaskInfo_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
switch (e.KeyData)
{
default:
return;
case Keys.Apps:
cmsTaskInfo.Close();
break;
}
}
private void lvUploads_ItemDrag(object sender, ItemDragEventArgs e)
{
TaskInfo[] taskInfos = GetCurrentTasks().Select(x => x.Info).Where(x => x != null).ToArray();