本文整理汇总了C#中Gtk.Menu.Destroy方法的典型用法代码示例。如果您正苦于以下问题:C# Menu.Destroy方法的具体用法?C# Menu.Destroy怎么用?C# Menu.Destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Menu
的用法示例。
在下文中一共展示了Menu.Destroy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDockPopupMenu
internal void ShowDockPopupMenu (uint time)
{
Menu menu = new Menu ();
// Hide menuitem
if ((Behavior & DockItemBehavior.CantClose) == 0) {
MenuItem mitem = new MenuItem (Catalog.GetString("Hide"));
mitem.Activated += delegate { Visible = false; };
menu.Append (mitem);
}
MenuItem citem;
// Auto Hide menuitem
if ((Behavior & DockItemBehavior.CantAutoHide) == 0 && Status != DockItemStatus.AutoHide) {
citem = new MenuItem (Catalog.GetString("Minimize"));
citem.Activated += delegate { Status = DockItemStatus.AutoHide; };
menu.Append (citem);
}
if (Status != DockItemStatus.Dockable) {
// Dockable menuitem
citem = new 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 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: CreateOptionsMenu
public Menu CreateOptionsMenu ()
{
Menu menu = new Menu ();
MenuItem searchInMenu = new MenuItem (GettextCatalog.GetString ("_Search in"));
Menu sub = new Menu ();
searchInMenu.Submenu = sub;
Gtk.RadioMenuItem original = null, translated = null, both = null;
GLib.SList group = new GLib.SList (IntPtr.Zero);
original = new Gtk.RadioMenuItem (group, GettextCatalog.GetString ("_Original"));
group = original.Group;
original.ButtonPressEvent += delegate { original.Activate (); };
sub.Append (original);
translated = new Gtk.RadioMenuItem (group, GettextCatalog.GetString ("_Translated"));
translated.ButtonPressEvent += delegate { translated.Activate (); };
group = translated.Group;
sub.Append (translated);
both = new Gtk.RadioMenuItem (group, GettextCatalog.GetString ("_Both"));
both.ButtonPressEvent += delegate { both.Activate (); };
sub.Append (both);
switch (DoSearchIn) {
case SearchIn.Both:
both.Activate ();
break;
case SearchIn.Original:
original.Activate ();
break;
case SearchIn.Translated:
translated.Activate ();
break;
}
menu.Append (searchInMenu);
both.Activated += delegate {
if (DoSearchIn != SearchIn.Both) {
DoSearchIn = SearchIn.Both;
UpdateFromCatalog ();
menu.Destroy ();
}
};
original.Activated += delegate {
if (DoSearchIn != SearchIn.Original) {
DoSearchIn = SearchIn.Original;
UpdateFromCatalog ();
menu.Destroy ();
}
};
translated.Activated += delegate {
if (DoSearchIn != SearchIn.Translated) {
DoSearchIn = SearchIn.Translated;
UpdateFromCatalog ();
menu.Destroy ();
}
};
Gtk.CheckMenuItem regexSearch = new Gtk.CheckMenuItem (MonoDevelop.Core.GettextCatalog.GetString ("_Regex search"));
regexSearch.Active = RegexSearch;
regexSearch.ButtonPressEvent += delegate {
RegexSearch = !RegexSearch;
UpdateFromCatalog ();
};
menu.Append (regexSearch);
Gtk.CheckMenuItem caseSensitive = new Gtk.CheckMenuItem (MonoDevelop.Core.GettextCatalog.GetString ("_Case sensitive"));
caseSensitive.Active = IsCaseSensitive;
caseSensitive.ButtonPressEvent += delegate {
IsCaseSensitive = !IsCaseSensitive;
UpdateFromCatalog ();
};
menu.Append (caseSensitive);
Gtk.CheckMenuItem wholeWordsOnly = new Gtk.CheckMenuItem (MonoDevelop.Core.GettextCatalog.GetString ("_Whole words only"));
wholeWordsOnly.Active = IsWholeWordOnly;
wholeWordsOnly.Sensitive = !RegexSearch;
wholeWordsOnly.ButtonPressEvent += delegate {
IsWholeWordOnly = !IsWholeWordOnly;
UpdateFromCatalog ();
};
menu.Append (wholeWordsOnly);
menu.ShowAll ();
return menu;
}
示例3: CreateOptionsMenu
// options menu for filterSearchEntry
public Menu CreateOptionsMenu()
{
Menu menu = new Menu ();
MenuItem searchInMenu = new MenuItem (GettextCatalog.GetString ("_Search in"));
Menu sub = new Menu ();
searchInMenu.Submenu = sub;
Gtk.RadioMenuItem name = null, baseValue = null, value =null, comment = null, all = null;
GLib.SList group = new GLib.SList (IntPtr.Zero);
name = new Gtk.RadioMenuItem (group, GettextCatalog.GetString ("_Name"));
group = name.Group;
name.ButtonPressEvent += delegate { name.Activate (); };
sub.Append (name);
baseValue = new Gtk.RadioMenuItem (group, GettextCatalog.GetString ("_Base Value"));
baseValue.ButtonPressEvent += delegate { baseValue.Activate (); };
group = baseValue.Group;
sub.Append (baseValue);
value = new Gtk.RadioMenuItem (group, GettextCatalog.GetString ("_Value"));
value.ButtonPressEvent += delegate { value.Activate (); };
group = value.Group;
sub.Append (value);
comment = new Gtk.RadioMenuItem (group, GettextCatalog.GetString ("_Comment"));
comment.ButtonPressEvent += delegate { comment.Activate (); };
group = comment.Group;
sub.Append (comment);
all = new Gtk.RadioMenuItem (group, GettextCatalog.GetString ("_All"));
all.ButtonPressEvent += delegate { all.Activate (); };
sub.Append (all);
switch (DoSearchIn) {
case SearchIn.All:
all.Activate ();
break;
case SearchIn.BaseValue:
baseValue.Activate ();
break;
case SearchIn.Value:
value.Activate ();
break;
case SearchIn.Name:
name.Activate ();
break;
case SearchIn.Comment:
comment.Activate ();
break;
}
menu.Append (searchInMenu);
all.Activated += delegate {
if (DoSearchIn != SearchIn.All) {
DoSearchIn = SearchIn.All;
Refresh ();
menu.Destroy ();
}
};
baseValue.Activated += delegate {
if (DoSearchIn != SearchIn.BaseValue) {
DoSearchIn = SearchIn.BaseValue;
Refresh ();
menu.Destroy ();
}
};
value.Activated += delegate {
if (DoSearchIn != SearchIn.Value) {
DoSearchIn = SearchIn.Value;
Refresh ();
menu.Destroy ();
}
};
name.Activated += delegate {
if (DoSearchIn != SearchIn.Name) {
DoSearchIn = SearchIn.Name;
Refresh ();
menu.Destroy ();
}
};
comment.Activated += delegate {
if (DoSearchIn != SearchIn.Comment) {
DoSearchIn = SearchIn.Comment;
Refresh ();
menu.Destroy ();
}
};
Gtk.CheckMenuItem regexSearch = new Gtk.CheckMenuItem (MonoDevelop.Core.GettextCatalog.GetString ("_Regex search"));
regexSearch.Active = RegexSearch;
regexSearch.ButtonPressEvent += delegate {
RegexSearch = !RegexSearch;
Refresh ();
};
menu.Append (regexSearch);
Gtk.CheckMenuItem caseSensitive = new Gtk.CheckMenuItem (MonoDevelop.Core.GettextCatalog.GetString ("_Case sensitive"));
caseSensitive.Active = IsCaseSensitive;
//.........这里部分代码省略.........
示例4: 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);
}
示例5: ShowDockPopupMenu
internal void ShowDockPopupMenu(uint time, TabStrip tabstrip = null)
{
Menu menu = new Menu();
MenuItem citem;
// Close menuitem
if ((Behavior & DockItemBehavior.CantClose) == 0)
{
citem = new MenuItem(Catalog.GetString("Close"));
citem.Activated += delegate { Close(); };
menu.Append(citem);
}
{
citem = new MenuItem(this.Status==DockItemStatus.AutoHide
? Catalog.GetString("Restore" )
: Catalog.GetString("Minimize"));
citem.Activated += (o, e) =>
{
TitleTab.OnClickDock(o, e);
if(this.Status==DockItemStatus.AutoHide)
(o as MenuItem).Name = this.Status==DockItemStatus.AutoHide
? Catalog.GetString("Restore" )
: Catalog.GetString("Minimize");
};
menu.Append(citem);
}
#if false
// Hide menuitem
if ((Behavior & DockItemBehavior.CantClose) == 0
&& (Behavior & DockItemBehavior.CloseOnHide) == 0)
{
citem = new MenuItem (Catalog.GetString("Hide"));
citem.Activated += delegate { Visible = false; };
menu.Append (citem);
}
// Auto Hide menuitem
if ((Behavior & DockItemBehavior.CantAutoHide) == 0 && Status != DockItemStatus.AutoHide) {
citem = new MenuItem (Catalog.GetString("Minimize"));
citem.Activated += delegate { Status = DockItemStatus.AutoHide; };
menu.Append (citem);
}
#endif
if (Status != DockItemStatus.Dockable)
{
// Dockable menuitem
citem = new 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 MenuItem(Catalog.GetString("Undock"));
citem.Activated += delegate { Status = DockItemStatus.Floating; };
menu.Append(citem);
}
// flip tab menuitem
if (tabstrip != null && (Behavior & DockItemBehavior.NeverFloating) == 0 && Status != DockItemStatus.Floating
&& (Status == DockItemStatus.Dockable || Status == DockItemStatus.AutoHide))
{
citem = new MenuItem(Catalog.GetString("Toggle Horizontal/Vertical Tab Layout"));
citem.Activated += (o, e) =>
{
tabstrip.Flip();
};
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);
}