本文整理汇总了C#中Gtk.Menu.SelectFirst方法的典型用法代码示例。如果您正苦于以下问题:C# Gtk.Menu.SelectFirst方法的具体用法?C# Gtk.Menu.SelectFirst怎么用?C# Gtk.Menu.SelectFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Menu
的用法示例。
在下文中一共展示了Gtk.Menu.SelectFirst方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
protected override void Run (RefactoringOptions options)
{
Gtk.Menu menu = new Gtk.Menu ();
bool resolveDirect;
List<string> namespaces = GetResolveableNamespaces (options, out resolveDirect);
foreach (string ns in namespaces) {
// remove used namespaces for conflict resolving.
if (options.Document.CompilationUnit.IsNamespaceUsedAt (ns, options.ResolveResult.ResolvedExpression.Region.Start))
continue;
Gtk.MenuItem menuItem = new Gtk.MenuItem (string.Format (GettextCatalog.GetString ("Add using '{0}'"), ns));
CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation (options.Dom, options.Document, options.ResolveResult, ns);
menuItem.Activated += delegate {
resolveNameOperation.AddImport ();
};
menu.Add (menuItem);
}
if (resolveDirect) {
foreach (string ns in namespaces) {
Gtk.MenuItem menuItem = new Gtk.MenuItem (string.Format (GettextCatalog.GetString ("Add '{0}'"), ns));
CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation (options.Dom, options.Document, options.ResolveResult, ns);
menuItem.Activated += delegate {
resolveNameOperation.ResolveName ();
};
menu.Add (menuItem);
}
}
if (menu.Children != null && menu.Children.Length > 0) {
menu.ShowAll ();
ICompletionWidget widget = options.Document.GetContent<ICompletionWidget> ();
CodeCompletionContext codeCompletionContext = widget.CreateCodeCompletionContext (options.GetTextEditorData ().Caret.Offset);
menu.Popup (null, null, delegate (Gtk.Menu menu2, out int x, out int y, out bool pushIn) {
x = codeCompletionContext.TriggerXCoord;
y = codeCompletionContext.TriggerYCoord;
pushIn = false;
}, 0, Gtk.Global.CurrentEventTime);
menu.SelectFirst (true);
}
}
示例2: PopupQuickFixMenu
void PopupQuickFixMenu (Gdk.EventButton evt)
{
var menu = new Gtk.Menu ();
var caretOffset = document.Editor.Caret.Offset;
Gtk.Menu fixMenu = menu;
DomRegion region;
var resolveResult = document.GetLanguageItem (caretOffset, out region);
if (resolveResult != null) {
var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces (document, resolveResult);
bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
if (addUsing) {
foreach (string ns_ in possibleNamespaces) {
string ns = ns_;
var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Import Namespace {0}", ns));
menuItem.Activated += delegate {
new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true).Run ();
};
menu.Add (menuItem);
}
}
bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
if (resolveDirect) {
foreach (string ns in possibleNamespaces) {
var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Use {0}", ns + "." + document.Editor.GetTextBetween (region.Begin, region.End)));
menuItem.Activated += delegate {
new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, false).Run ();
};
menu.Add (menuItem);
}
}
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);
}
}
PopulateFixes (fixMenu);
menu.ShowAll ();
menu.SelectFirst (true);
menuPushed = true;
menu.Destroyed += delegate {
menuPushed = false;
};
var container = (TextEditorContainer)document.Editor.Parent.Parent;
var child = (TextEditorContainer.EditorContainerChild)container [this];
GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0));
}
示例3: PopupQuickFixMenu
void PopupQuickFixMenu (Gdk.EventButton evt)
{
var menu = new Gtk.Menu ();
Gtk.Menu fixMenu = menu;
ResolveResult resolveResult;
ICSharpCode.NRefactory.CSharp.AstNode node;
if (ResolveCommandHandler.ResolveAt (document, out resolveResult, out node)) {
var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces (
document,
node,
resolveResult
);
bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
if (addUsing) {
foreach (string ns_ in possibleNamespaces) {
string ns = ns_;
var menuItem = new Gtk.MenuItem (string.Format ("using {0};", ns));
menuItem.Activated += delegate {
new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true).Run ();
menu.Destroy ();
};
menu.Add (menuItem);
}
}
bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
if (resolveDirect) {
foreach (string ns in possibleNamespaces) {
var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("{0}", ns + "." + document.Editor.GetTextBetween (node.StartLocation, node.EndLocation)));
menuItem.Activated += delegate {
new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, false).Run ();
menu.Destroy ();
};
menu.Add (menuItem);
}
}
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);
}
}
PopulateFixes (fixMenu);
menu.ShowAll ();
menu.SelectFirst (true);
menuPushed = true;
menu.Destroyed += delegate {
menuPushed = false;
Hide ();
};
var container = (TextEditorContainer)document.Editor.Parent.Parent;
var child = (TextEditorContainer.EditorContainerChild)container [this];
GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0));
}
示例4: PopupQuickFixMenu
void PopupQuickFixMenu (Gdk.EventButton evt)
{
var menu = new Gtk.Menu ();
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
);
bool addUsing = !(resolveResult is AmbiguousTypeResolveResult);
if (addUsing) {
foreach (var t in possibleNamespaces.Where (tp => tp.Item2)) {
string ns = t.Item1;
var menuItem = new Gtk.MenuItem (string.Format ("using {0};", ns));
menuItem.Activated += delegate {
new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true, node).Run ();
menu.Destroy ();
};
menu.Add (menuItem);
items++;
}
}
bool resolveDirect = !(resolveResult is UnknownMemberResolveResult);
if (resolveDirect) {
foreach (var t in possibleNamespaces) {
string ns = t.Item1;
var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("{0}", ns + "." + document.Editor.GetTextBetween (node.StartLocation, node.EndLocation)));
menuItem.Activated += delegate {
new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, 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 ();
menu.ShowAll ();
menu.SelectFirst (true);
menuPushed = true;
menu.Hidden += delegate {
document.Editor.SuppressTooltips = false;
};
menu.Destroyed += delegate {
menuPushed = false;
Hide ();
};
var container = document.Editor.Parent;
var child = (TextEditor.EditorContainerChild)container [this];
Gdk.Rectangle rect;
/* if (child != null) {
rect = new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0);
} else {*/
var p = container.LocationToPoint (loc);
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);
}
示例5: PopupQuickFixMenu
public void PopupQuickFixMenu ()
{
Gtk.Menu menu = new Gtk.Menu ();
Dictionary<Gtk.MenuItem, ContextAction> fixTable = new Dictionary<Gtk.MenuItem, ContextAction> ();
int mnemonic = 1;
foreach (ContextAction fix in fixes) {
var escapedLabel = fix.GetMenuText (document, loc).Replace ("_", "__");
var label = (mnemonic <= 10)
? "_" + (mnemonic++ % 10).ToString () + " " + escapedLabel
: " " + escapedLabel;
Gtk.MenuItem menuItem = new Gtk.MenuItem (label);
fixTable [menuItem] = fix;
menuItem.Activated += delegate(object sender, EventArgs e) {
// ensure that the Ast is recent.
document.UpdateParseDocument ();
var runFix = fixTable [(Gtk.MenuItem)sender];
runFix.Run (document, loc);
document.Editor.Document.CommitUpdateAll ();
menu.Destroy ();
};
menu.Add (menuItem);
}
menu.ShowAll ();
int dx, dy;
this.ParentWindow.GetOrigin (out dx, out dy);
dx += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).X;
dy += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).Y - (int)document.Editor.VAdjustment.Value;
menu.Popup (null, null, delegate (Gtk.Menu menu2, out int x, out int y, out bool pushIn) {
x = dx;
y = dy + Allocation.Height;
pushIn = false;
menuPushed = true;
QueueDraw ();
}, 0, Gtk.Global.CurrentEventTime);
menu.SelectFirst (true);
menu.Destroyed += delegate {
menuPushed = false;
QueueDraw ();
};
}