当前位置: 首页>>代码示例>>C#>>正文


C# Action.CreateAcceleratedMenuItem方法代码示例

本文整理汇总了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;
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:34,代码来源:EffectsManager.cs

示例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 ()); };
            }
        }
开发者ID:linuxmhall,项目名称:Pinta,代码行数:31,代码来源:MainWindow.cs


注:本文中的Gtk.Action.CreateAcceleratedMenuItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。