//コンテキストメニュー表示
public void ShowContextMenu(IPoderosaMenuGroup[] menus, ICommandTarget target, Point point_screen, ContextMenuFlags flags) {
//まずソート
ICollection sorted = PositionDesignationSorter.SortItems(menus);
ContextMenuStrip cm = new ContextMenuStrip();
MenuUtil.BuildContextMenu(cm, new ConvertingEnumerable<IPoderosaMenuGroup>(sorted), target);
if (cm.Items.Count == 0) {
cm.Dispose();
return;
}
//キーボード操作をトリガにメニューを出すときは、選択があったほうが何かと操作しやすい。
if ((flags & ContextMenuFlags.SelectFirstItem) != ContextMenuFlags.None)
cm.Items[0].Select();
// ContextMenuStrip is not disposed automatically and
// its instance sits in memory till application end.
// To release a document object related with some menu items,
// we need to dispose ContextMenuStrip explicitly soon after it disappeared.
cm.VisibleChanged += new EventHandler(ContextMenuStripVisibleChanged);
try {
cm.Show(this, this.PointToClient(point_screen));
}
catch (Exception ex) {
RuntimeUtil.ReportException(ex);
}
}