本文整理汇总了C#中Gtk.Menu.SelectFirst方法的典型用法代码示例。如果您正苦于以下问题:C# Menu.SelectFirst方法的具体用法?C# Menu.SelectFirst怎么用?C# Menu.SelectFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Menu
的用法示例。
在下文中一共展示了Menu.SelectFirst方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopupQuickFixMenu
void PopupQuickFixMenu (Gdk.EventButton evt, Action<Gtk.Menu> menuAction)
{
var menu = new Gtk.Menu ();
menu.Events |= Gdk.EventMask.AllEventsMask;
Gtk.Menu fixMenu = menu;
ResolveResult resolveResult;
ICSharpCode.NRefactory.CSharp.AstNode node;
int items = 0;
if (ResolveCommandHandler.ResolveAt (document, out resolveResult, out node)) {
var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces (
document,
node,
ref resolveResult
);
foreach (var t in possibleNamespaces.Where (tp => tp.OnlyAddReference)) {
var menuItem = new Gtk.MenuItem (t.GetImportText ());
menuItem.Activated += delegate {
new ResolveCommandHandler.AddImport (document, resolveResult, null, t.Reference, true, node).Run ();
menu.Destroy ();
};
menu.Add (menuItem);
items++;
}
bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
if (addUsing) {
foreach (var t in possibleNamespaces.Where (tp => tp.IsAccessibleWithGlobalUsing)) {
string ns = t.Namespace;
var reference = t.Reference;
var menuItem = new Gtk.MenuItem (t.GetImportText ());
menuItem.Activated += delegate {
new ResolveCommandHandler.AddImport (document, resolveResult, ns, reference, true, node).Run ();
menu.Destroy ();
};
menu.Add (menuItem);
items++;
}
}
bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
if (resolveDirect) {
foreach (var t in possibleNamespaces) {
string ns = t.Namespace;
var reference = t.Reference;
var menuItem = new Gtk.MenuItem (t.GetInsertNamespaceText (document.Editor.GetTextBetween (node.StartLocation, node.EndLocation)));
menuItem.Activated += delegate {
new ResolveCommandHandler.AddImport (document, resolveResult, ns, reference, false, node).Run ();
menu.Destroy ();
};
menu.Add (menuItem);
items++;
}
}
if (menu.Children.Any () && Fixes.Any ()) {
fixMenu = new Gtk.Menu ();
var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Quick Fixes"));
menuItem.Submenu = fixMenu;
menu.Add (menuItem);
items++;
}
}
PopulateFixes (fixMenu, ref items);
if (items == 0) {
menu.Destroy ();
return;
}
document.Editor.SuppressTooltips = true;
document.Editor.Parent.HideTooltip ();
if (menuAction != null)
menuAction (menu);
menu.ShowAll ();
menu.SelectFirst (true);
menu.Hidden += delegate {
document.Editor.SuppressTooltips = false;
};
var container = document.Editor.Parent;
var p = container.LocationToPoint (currentSmartTagBegin);
var rect = new Gdk.Rectangle (
p.X + container.Allocation.X ,
p.Y + (int)document.Editor.LineHeight + container.Allocation.Y, 0, 0);
GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, rect);
}