本文整理汇总了C#中MonoDevelop.Components.Commands.CommandManager.GetCommand方法的典型用法代码示例。如果您正苦于以下问题:C# CommandManager.GetCommand方法的具体用法?C# CommandManager.GetCommand怎么用?C# CommandManager.GetCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.Components.Commands.CommandManager
的用法示例。
在下文中一共展示了CommandManager.GetCommand方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCommand
public virtual Command GetCommand (CommandManager manager)
{
if (localCmd != null) {
if (manager.GetCommand (localCmd.Id) == null)
manager.RegisterCommand (localCmd);
localCmd = null;
}
return manager.GetCommand (cmdId);
}
示例2: CommandMenuItem
public CommandMenuItem (object commandId, CommandManager commandManager, string overrideLabel, bool disabledVisible): base ("")
{
this.commandId = commandId;
this.commandManager = commandManager;
this.overrideLabel = overrideLabel;
this.disabledVisible = disabledVisible;
ActionCommand cmd = commandManager.GetCommand (commandId) as ActionCommand;
if (cmd != null)
isArray = cmd.CommandArray;
}
示例3: CommandCheckMenuItem
public CommandCheckMenuItem (object commandId, CommandManager commandManager, string overrideLabel, bool disabledVisible): base ("")
{
this.commandId = commandId;
this.commandManager = commandManager;
this.overrideLabel = overrideLabel;
this.disabledVisible = disabledVisible;
ActionCommand cmd = commandManager.GetCommand (commandId) as ActionCommand;
if (cmd != null && cmd.ActionType == ActionType.Radio)
this.DrawAsRadio = true;
}
示例4: MDMenu
public MDMenu (CommandManager manager, CommandEntrySet ces, CommandSource commandSource, object initialCommandTarget)
{
this.WeakDelegate = this;
AutoEnablesItems = false;
Title = (ces.Name ?? "").Replace ("_", "");
foreach (CommandEntry ce in ces) {
if (ce.CommandId == Command.Separator) {
AddItem (NSMenuItem.SeparatorItem);
if (!string.IsNullOrEmpty (ce.OverrideLabel))
AddItem (new MDMenuHeaderItem (ce.OverrideLabel));
continue;
}
if (string.Equals (ce.CommandId as string, servicesID, StringComparison.Ordinal)) {
AddItem (new MDServicesMenuItem ());
continue;
}
var subset = ce as CommandEntrySet;
if (subset != null) {
AddItem (new MDSubMenuItem (manager, subset, commandSource, initialCommandTarget));
continue;
}
var lce = ce as LinkCommandEntry;
if (lce != null) {
AddItem (new MDLinkMenuItem (lce));
continue;
}
Command cmd = manager.GetCommand (ce.CommandId);
if (cmd == null) {
LoggingService.LogError ("MacMenu: '{0}' maps to null command", ce.CommandId);
continue;
}
if (cmd is CustomCommand) {
LoggingService.LogWarning ("MacMenu: '{0}' is unsupported custom-rendered command' '", ce.CommandId);
continue;
}
var acmd = cmd as ActionCommand;
if (acmd == null) {
LoggingService.LogWarning ("MacMenu: '{0}' has unknown command type '{1}'", cmd.GetType (), ce.CommandId);
continue;
}
AddItem (new MDMenuItem (manager, ce, acmd, commandSource, initialCommandTarget));
}
}
示例5: CreateMenuItem
static Gtk.MenuItem CreateMenuItem (CommandManager manager, Command cmd, object cmdId, bool isArrayMaster, string overrideLabel, bool disabledVisible)
{
cmdId = CommandManager.ToCommandId (cmdId);
if (cmdId == CommandManager.ToCommandId (Command.Separator))
return new Gtk.SeparatorMenuItem ();
if (cmd == null)
cmd = manager.GetCommand (cmdId);
if (cmd == null) {
MonoDevelop.Core.LoggingService.LogWarning ("Unknown command '{0}'", cmdId);
return new Gtk.MenuItem ("<Unknown Command>");
}
if (cmd is CustomCommand) {
Gtk.Widget child = (Gtk.Widget) Activator.CreateInstance (((CustomCommand)cmd).WidgetType);
CustomMenuItem ti = new CustomMenuItem ();
ti.Child = child;
return ti;
}
ActionCommand acmd = cmd as ActionCommand;
if (acmd.ActionType == ActionType.Normal || (isArrayMaster && acmd.CommandArray))
return new CommandMenuItem (cmdId, manager, overrideLabel, disabledVisible);
else
return new CommandCheckMenuItem (cmdId, manager, overrideLabel, disabledVisible);
}
示例6: InitApp
void InitApp (CommandManager commandManager)
{
if (initedApp)
return;
commandManager.CommandActivating += OnCommandActivating;
//mac-ify these command names
commandManager.GetCommand (EditCommands.MonodevelopPreferences).Text = GettextCatalog.GetString ("Preferences...");
commandManager.GetCommand (EditCommands.DefaultPolicies).Text = GettextCatalog.GetString ("Custom Policies...");
commandManager.GetCommand (HelpCommands.About).Text = GettextCatalog.GetString ("About {0}", BrandingService.ApplicationName);
commandManager.GetCommand (MacIntegrationCommands.HideWindow).Text = GettextCatalog.GetString ("Hide {0}", BrandingService.ApplicationName);
commandManager.GetCommand (ToolCommands.AddinManager).Text = GettextCatalog.GetString ("Add-in Manager...");
initedApp = true;
IdeApp.Workbench.RootWindow.DeleteEvent += HandleDeleteEvent;
if (MacSystemInformation.OsVersion >= MacSystemInformation.Lion) {
IdeApp.Workbench.RootWindow.Realized += (sender, args) => {
var win = GtkQuartz.GetWindow ((Gtk.Window) sender);
win.CollectionBehavior |= NSWindowCollectionBehavior.FullScreenPrimary;
};
}
}
示例7: InitApp
void InitApp (CommandManager commandManager)
{
if (initedApp)
return;
commandManager.CommandActivating += OnCommandActivating;
//mac-ify these command names
commandManager.GetCommand (EditCommands.MonodevelopPreferences).Text = GettextCatalog.GetString ("Preferences...");
commandManager.GetCommand (EditCommands.DefaultPolicies).Text = GettextCatalog.GetString ("Custom Policies...");
commandManager.GetCommand (HelpCommands.About).Text = GettextCatalog.GetString ("About {0}", BrandingService.ApplicationName);
commandManager.GetCommand (MacIntegrationCommands.HideWindow).Text = GettextCatalog.GetString ("Hide {0}", BrandingService.ApplicationName);
commandManager.GetCommand (ToolCommands.AddinManager).Text = GettextCatalog.GetString ("Add-in Manager...");
initedApp = true;
IdeApp.Workbench.RootWindow.DeleteEvent += HandleDeleteEvent;
if (MacSystemInformation.OsVersion >= MacSystemInformation.Lion) {
IdeApp.Workbench.RootWindow.Realized += (sender, args) => {
var win = GtkQuartz.GetWindow ((Gtk.Window) sender);
win.CollectionBehavior |= NSWindowCollectionBehavior.FullScreenPrimary;
};
}
PatchGtkTheme ();
NSNotificationCenter.DefaultCenter.AddObserver (NSCell.ControlTintChangedNotification, notif => Runtime.RunInMainThread (
delegate {
Styles.LoadStyle();
PatchGtkTheme();
}));
// FIXME: Immediate theme switching disabled, until NSAppearance issues are fixed
//IdeApp.Preferences.UserInterfaceTheme.Changed += (s,a) => PatchGtkTheme ();
}
示例8: InitApp
void InitApp (CommandManager commandManager)
{
if (initedApp)
return;
MacMainMenu.SetAppQuitCommand (CommandManager.ToCommandId (FileCommands.Exit));
MacMainMenu.AddCommandIDMappings (new Dictionary<object, CarbonCommandID> ()
{
{ CommandManager.ToCommandId (EditCommands.Copy), CarbonCommandID.Copy },
{ CommandManager.ToCommandId (EditCommands.Cut), CarbonCommandID.Cut },
{ CommandManager.ToCommandId (EditCommands.MonodevelopPreferences), CarbonCommandID.Preferences },
{ CommandManager.ToCommandId (EditCommands.Redo), CarbonCommandID.Redo },
{ CommandManager.ToCommandId (EditCommands.Undo), CarbonCommandID.Undo },
{ CommandManager.ToCommandId (EditCommands.SelectAll), CarbonCommandID.SelectAll },
{ CommandManager.ToCommandId (FileCommands.NewFile), CarbonCommandID.New },
{ CommandManager.ToCommandId (FileCommands.OpenFile), CarbonCommandID.Open },
{ CommandManager.ToCommandId (FileCommands.Save), CarbonCommandID.Save },
{ CommandManager.ToCommandId (FileCommands.SaveAs), CarbonCommandID.SaveAs },
{ CommandManager.ToCommandId (FileCommands.CloseFile), CarbonCommandID.Close },
{ CommandManager.ToCommandId (FileCommands.Exit), CarbonCommandID.Quit },
{ CommandManager.ToCommandId (FileCommands.ReloadFile), CarbonCommandID.Revert },
{ CommandManager.ToCommandId (HelpCommands.About), CarbonCommandID.About },
{ CommandManager.ToCommandId (HelpCommands.Help), CarbonCommandID.AppHelp },
{ CommandManager.ToCommandId (MacIntegrationCommands.HideWindow), CarbonCommandID.Hide },
{ CommandManager.ToCommandId (MacIntegrationCommands.HideOthers), CarbonCommandID.HideOthers },
});
//mac-ify these command names
commandManager.GetCommand (EditCommands.MonodevelopPreferences).Text = GettextCatalog.GetString ("Preferences...");
commandManager.GetCommand (EditCommands.DefaultPolicies).Text = GettextCatalog.GetString ("Custom Policies...");
commandManager.GetCommand (HelpCommands.About).Text = GettextCatalog.GetString ("About {0}", BrandingService.ApplicationName);
commandManager.GetCommand (MacIntegrationCommands.HideWindow).Text = GettextCatalog.GetString ("Hide {0}", BrandingService.ApplicationName);
commandManager.GetCommand (ToolCommands.AddinManager).Text = GettextCatalog.GetString ("Add-in Manager...");
initedApp = true;
IdeApp.Workbench.RootWindow.DeleteEvent += HandleDeleteEvent;
if (MacSystemInformation.OsVersion >= MacSystemInformation.Lion) {
IdeApp.Workbench.RootWindow.Realized += (sender, args) => {
var win = GtkQuartz.GetWindow ((Gtk.Window) sender);
win.CollectionBehavior |= NSWindowCollectionBehavior.FullScreenPrimary;
};
}
}
示例9: InitApp
static void InitApp (CommandManager commandManager)
{
if (initedApp)
return;
MacMainMenu.AddCommandIDMappings (new Dictionary<object, CarbonCommandID> ()
{
{ CommandManager.ToCommandId (EditCommands.Copy), CarbonCommandID.Copy },
{ CommandManager.ToCommandId (EditCommands.Cut), CarbonCommandID.Cut },
//FIXME: for some reason mapping this causes two menu items to be created
// { EditCommands.MonodevelopPreferences, CarbonCommandID.Preferences },
{ CommandManager.ToCommandId (EditCommands.Redo), CarbonCommandID.Redo },
{ CommandManager.ToCommandId (EditCommands.Undo), CarbonCommandID.Undo },
{ CommandManager.ToCommandId (EditCommands.SelectAll), CarbonCommandID.SelectAll },
{ CommandManager.ToCommandId (FileCommands.NewFile), CarbonCommandID.New },
{ CommandManager.ToCommandId (FileCommands.OpenFile), CarbonCommandID.Open },
{ CommandManager.ToCommandId (FileCommands.Save), CarbonCommandID.Save },
{ CommandManager.ToCommandId (FileCommands.SaveAs), CarbonCommandID.SaveAs },
{ CommandManager.ToCommandId (FileCommands.CloseFile), CarbonCommandID.Close },
{ CommandManager.ToCommandId (FileCommands.Exit), CarbonCommandID.Quit },
{ CommandManager.ToCommandId (FileCommands.ReloadFile), CarbonCommandID.Revert },
{ CommandManager.ToCommandId (HelpCommands.About), CarbonCommandID.About },
{ CommandManager.ToCommandId (HelpCommands.Help), CarbonCommandID.AppHelp },
});
//mac-ify these command names
commandManager.GetCommand (EditCommands.MonodevelopPreferences).Text = GettextCatalog.GetString ("Preferences...");
commandManager.GetCommand (EditCommands.DefaultPolicies).Text = GettextCatalog.GetString ("Custom Policies...");
commandManager.GetCommand (HelpCommands.About).Text = string.Format (GettextCatalog.GetString ("About {0}"), BrandingService.ApplicationName);
commandManager.GetCommand (ToolCommands.AddinManager).Text = GettextCatalog.GetString ("Add-in Manager...");
initedApp = true;
MacMainMenu.SetAppQuitCommand (CommandManager.ToCommandId (FileCommands.Exit));
MacMainMenu.AddAppMenuItems (
commandManager,
CommandManager.ToCommandId (HelpCommands.About),
CommandManager.ToCommandId (MonoDevelop.Ide.Updater.UpdateCommands.CheckForUpdates),
CommandManager.ToCommandId (Command.Separator),
CommandManager.ToCommandId (EditCommands.MonodevelopPreferences),
CommandManager.ToCommandId (EditCommands.DefaultPolicies),
CommandManager.ToCommandId (ToolCommands.AddinManager));
IdeApp.Workbench.RootWindow.DeleteEvent += HandleDeleteEvent;
}
示例10: AddAppMenuItems
public static void AddAppMenuItems (CommandManager manager, params object [] cmdIds)
{
//FIXME: we assume we get first pick of cmdIDs
HIMenuItem mnu = HIToolbox.GetMenuItem ((uint)CarbonCommandID.Hide);
appMenu = mnu.MenuRef;
var appMenuId = HIToolbox.GetMenuID (appMenu);
for (int i = cmdIds.Length - 1; i >= 0; i--) {
var cmdId = cmdIds[i];
if (cmdId == Command.Separator) {
HIToolbox.InsertMenuSeparator (mnu.MenuRef, 0);
continue;
}
Command cmd = manager.GetCommand (cmdId);
if (cmd == null){
MonoDevelop.Core.LoggingService.LogError ("Null command in Mac app menu for ID {0}", cmdId);
continue;
}
uint macCmdId = GetNewMenuItemId (cmd);
ushort pos = HIToolbox.InsertMenuItem (mnu.MenuRef, (cmd.Text ?? "").Replace ("_", ""), 0, 0, macCmdId);
SetMenuAccelerator (new HIMenuItem (mnu.MenuRef, pos), cmd.AccelKey);
menuIdMap[cmdId] = appMenuId;
}
}