本文整理汇总了C#中Gtk.Menu.Destroy方法的典型用法代码示例。如果您正苦于以下问题:C# Gtk.Menu.Destroy方法的具体用法?C# Gtk.Menu.Destroy怎么用?C# Gtk.Menu.Destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Menu
的用法示例。
在下文中一共展示了Gtk.Menu.Destroy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDockPopupMenu
internal void ShowDockPopupMenu (uint time)
{
Gtk.Menu menu = new Gtk.Menu ();
// Hide menuitem
if ((Behavior & DockItemBehavior.CantClose) == 0) {
Gtk.MenuItem mitem = new Gtk.MenuItem (Catalog.GetString("Hide"));
mitem.Activated += delegate { Visible = false; };
menu.Append (mitem);
}
Gtk.MenuItem citem;
// Auto Hide menuitem
if ((Behavior & DockItemBehavior.CantAutoHide) == 0 && Status != DockItemStatus.AutoHide) {
citem = new Gtk.MenuItem (Catalog.GetString("Minimize"));
citem.Activated += delegate { Status = DockItemStatus.AutoHide; };
menu.Append (citem);
}
if (Status != DockItemStatus.Dockable) {
// Dockable menuitem
citem = new Gtk.MenuItem (Catalog.GetString("Dock"));
citem.Activated += delegate { Status = DockItemStatus.Dockable; };
menu.Append (citem);
}
// Floating menuitem
if ((Behavior & DockItemBehavior.NeverFloating) == 0 && Status != DockItemStatus.Floating) {
citem = new Gtk.MenuItem (Catalog.GetString("Undock"));
citem.Activated += delegate { Status = DockItemStatus.Floating; };
menu.Append (citem);
}
if (menu.Children.Length == 0) {
menu.Destroy ();
return;
}
ShowingContextMemu = true;
menu.ShowAll ();
menu.Hidden += (o,e) => {
ShowingContextMemu = false;
};
menu.Popup (null, null, null, 3, time);
}
示例2: 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));
}
示例3: 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);
}
示例4: 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 ();
};
}