本文整理汇总了C#中Gtk.Action.CreateAcceleratedMenuItem方法的典型用法代码示例。如果您正苦于以下问题:C# Action.CreateAcceleratedMenuItem方法的具体用法?C# Action.CreateAcceleratedMenuItem怎么用?C# Action.CreateAcceleratedMenuItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.Action
的用法示例。
在下文中一共展示了Action.CreateAcceleratedMenuItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterAdjustment
/// <summary>
/// Register a new adjustment with Pinta, causing it to be added to the Adjustments menu.
/// </summary>
/// <param name="adjustment">The adjustment to register</param>
/// <returns>The action created for this adjustment</returns>
public Gtk.Action RegisterAdjustment (BaseEffect adjustment)
{
// Add icon to IconFactory
Gtk.IconFactory fact = new Gtk.IconFactory ();
fact.Add (adjustment.Icon, new Gtk.IconSet (PintaCore.Resources.GetIcon (adjustment.Icon)));
fact.AddDefault ();
// Create a gtk action for each adjustment
Gtk.Action act = new Gtk.Action (adjustment.GetType ().Name, adjustment.Name + (adjustment.IsConfigurable ? Catalog.GetString ("...") : ""), string.Empty, adjustment.Icon);
act.Activated += delegate (object sender, EventArgs e) { PintaCore.LivePreview.Start (adjustment); };
PintaCore.Actions.Adjustments.Actions.Add (act);
// Create a menu item for each adjustment
MenuItem menu_item;
// If no key is specified, don't use an accelerated menu item
if (adjustment.AdjustmentMenuKey == (Gdk.Key)0)
menu_item = (MenuItem)act.CreateMenuItem ();
else
menu_item = act.CreateAcceleratedMenuItem (adjustment.AdjustmentMenuKey, adjustment.AdjustmentMenuKeyModifiers);
((Menu)((ImageMenuItem)PintaCore.Chrome.MainMenu.Children[5]).Submenu).AppendMenuItemSorted (menu_item);
adjustments.Add (adjustment, act);
adjustment_menuitems.Add (adjustment, menu_item);
return act;
}
示例2: LoadEffects
private void LoadEffects()
{
// Load our adjustments
foreach (BaseEffect effect in extensions.Effects.Where (t => t.EffectOrAdjustment == EffectAdjustment.Adjustment).OrderBy (t => t.Text)) {
// Add icon to IconFactory
Gtk.IconFactory fact = new Gtk.IconFactory ();
fact.Add (effect.Icon, new Gtk.IconSet (PintaCore.Resources.GetIcon (effect.Icon)));
fact.AddDefault ();
// Create a gtk action for each adjustment
Gtk.Action act = new Gtk.Action (effect.GetType ().Name, effect.Text, string.Empty, effect.Icon);
PintaCore.Actions.Adjustments.Actions.Add (act);
act.Activated += delegate (object sender, EventArgs e) { PintaCore.LivePreview.Start (extensions.Effects.Where (t => t.GetType ().Name == (sender as Gtk.Action).Name).First ()); };
// Create a menu item for each adjustment
((Menu)((ImageMenuItem)main_menu.Children[5]).Submenu).Append (act.CreateAcceleratedMenuItem (effect.AdjustmentMenuKey, effect.AdjustmentMenuKeyModifiers));
}
// Load our effects
foreach (BaseEffect effect in extensions.Effects.Where (t => t.EffectOrAdjustment == EffectAdjustment.Effect).OrderBy (t => string.Format ("{0}|{1}", t.EffectMenuCategory, t.Text))) {
// Add icon to IconFactory
Gtk.IconFactory fact = new Gtk.IconFactory ();
fact.Add (effect.Icon, new Gtk.IconSet (PintaCore.Resources.GetIcon (effect.Icon)));
fact.AddDefault ();
// Create a gtk action and menu item for each effect
Gtk.Action act = new Gtk.Action (effect.GetType ().Name, effect.Text, string.Empty, effect.Icon);
PintaCore.Actions.Effects.AddEffect (effect.EffectMenuCategory, act);
act.Activated += delegate (object sender, EventArgs e) { PintaCore.LivePreview.Start (extensions.Effects.Where (t => t.GetType ().Name == (sender as Gtk.Action).Name).First ()); };
}
}