本文整理汇总了C#中System.Windows.Controls.ContextMenu.AddAction方法的典型用法代码示例。如果您正苦于以下问题:C# ContextMenu.AddAction方法的具体用法?C# ContextMenu.AddAction怎么用?C# ContextMenu.AddAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ContextMenu
的用法示例。
在下文中一共展示了ContextMenu.AddAction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: region_Loaded
private void region_Loaded(object sender, RoutedEventArgs e)
{
var border = (Border)e.Source;
var region = (Region)border.DataContext;
var menu = new ContextMenu();
menu.AddAction("New Region", CreateNewRegion);
menu.AddAction("Rename", () => RenameRegion(region));
menu.AddAction("Delete", () => DeleteRegion(region));
border.ContextMenu = menu;
}
示例2: trigger_Loaded
void trigger_Loaded(object sender, RoutedEventArgs e)
{
var border = (Border)e.Source;
var trigger = (Trigger)border.DataContext;
var menu = new ContextMenu();
menu.AddAction("New Trigger", CreateNewTrigger);
menu.AddAction("New Trigger (Repeating)", CreateNewRepeatingTrigger);
menu.AddAction("Copy Trigger", () => Mission.CopyTrigger(trigger));
menu.Items.Add(GetNewActionMenu(trigger));
menu.Items.Add(GetNewConditionMenu(trigger));
menu.Items.Add(new Separator());
menu.AddAction("Move Up", () => MoveTrigger(MoveDirection.Up, trigger));
menu.AddAction("Move Up 5 Spaces", () => MoveTrigger(MoveDirection.Up, trigger, 5));
menu.AddAction("Move to Top", () => MoveTrigger(MoveDirection.Up, trigger, true));
menu.AddAction("Move Down", () => MoveTrigger(MoveDirection.Down, trigger));
menu.AddAction("Move Down 5 Spaces", () => MoveTrigger(MoveDirection.Down, trigger, 5));
menu.AddAction("Move to Bottom", () => MoveTrigger(MoveDirection.Down, trigger, true));
menu.AddAction("Rename", () => RenameTrigger(trigger));
menu.AddAction("Delete", () => DeleteTrigger(trigger));
menu.Items.Add(new Separator());
menu.AddAction("Expand All Triggers", ExpandAllTriggers);
menu.AddAction("Collapse All Triggers", CollapseAllTriggers);
menu.AddAction("Collapse All But This", () => CollapseAllButThisTrigger(trigger));
border.ContextMenu = menu;
}
示例3: window_Loaded
void window_Loaded(object sender, RoutedEventArgs e)
{
var project = MainMenu.AddContainer("Project");
project.AddAction("New", NewMission);
project.AddAction("Open", LoadMission);
project.AddAction("Save", QuickSave);
project.AddAction("Save As", SaveMission);
var welcomeScreen = new WelcomeDialog { ShowInTaskbar = true, Owner = this };
welcomeScreen.ShowDialog();
if (Mission == null)
{
MessageBox.Show("A mission needs to be selected");
Environment.Exit(0);
}
var mission = MainMenu.AddContainer("Mission");
mission.AddAction("Create Mutator", () => BuildMission());
mission.AddAction("Create Invisible Mutator", () => BuildMission(true));
mission.AddAction("Test Mission", TestMission);
mission.AddAction("Export Localization File", ExportLocalizationFile);
mission.AddAction("Publish", ShowMissionManagement);
mission.AddAction("Settings", ShowMissionSettings);
var newMenu = MainMenu.AddContainer("New");
newMenu.AddAction("New Trigger", CreateNewTrigger);
newMenu.AddAction("New Trigger (Repeating)", CreateNewRepeatingTrigger);
newMenu.AddAction("New Region", CreateNewRegion);
newMenu.AddAction("Copy Trigger", () => Mission.CopyTrigger(CurrentTrigger));
newMenu.Items.Add(GetNewConditionMenu(delegate
{
if (logicGrid.SelectedItem is Trigger) return CurrentTrigger;
if (logicGrid.SelectedItem is ActionsFolder) return CurrentActionsFolder.Trigger;
if (logicGrid.SelectedItem is ConditionsFolder) return CurrentConditionsFolder.Trigger;
if (logicGrid.SelectedItem is TriggerLogic) return Mission.FindLogicOwner(CurrentLogic);
return null;
}));
newMenu.Items.Add(GetNewActionMenu(() => CurrentTrigger));
var editMenu = MainMenu.AddContainer("Edit");
editMenu.AddAction("Rename", RenameCurrentItem);
editMenu.AddAction("Delete", DeleteCurrentItem);
editMenu.AddAction("Move Up", () => MoveCurrentItem(MoveDirection.Up));
editMenu.AddAction("Move Up 5 Spaces", () => MoveCurrentItem(MoveDirection.Up, 5));
editMenu.AddAction("Move To Top", () => MoveCurrentItem(MoveDirection.Up, true));
editMenu.AddAction("Move Down", () => MoveCurrentItem(MoveDirection.Down));
editMenu.AddAction("Move Down 5 Spaces", () => MoveCurrentItem(MoveDirection.Down, 5));
editMenu.AddAction("Move To Bottom", () => MoveCurrentItem(MoveDirection.Down, true));
editMenu.AddAction("Expand All Triggers", ExpandAllTriggers);
editMenu.AddAction("Collapse All Triggers", CollapseAllTriggers);
var menu = new ContextMenu();
menu.AddAction("New Trigger", CreateNewTrigger);
menu.AddAction("New Trigger (Repeating)", CreateNewRepeatingTrigger);
menu.AddAction("New Region", CreateNewRegion);
logicGrid.ContextMenu = menu;
Assembly assembly = Assembly.GetExecutingAssembly();
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
string version = fileVersionInfo.FileVersion;
var aboutString = String.Format("Mission Editor {0}\n\nby Quantum and KingRaptor\n\nFor help with the program, visit {1}", version, GlobalConst.BaseSiteUrl + "/Wiki/MissionEditorStartPage");
var help = MainMenu.AddContainer("Help");
help.AddAction("About", () => MessageBox.Show(aboutString, "About Mission Editor", MessageBoxButton.OK, MessageBoxImage.Information));
autosaveTimer.Start();
}
示例4: logic_Loaded
void logic_Loaded(object sender, RoutedEventArgs e)
{
var border = (Border)e.Source;
var item = (TriggerLogic)border.DataContext;
var menu = new ContextMenu();
border.ContextMenu = menu;
menu.AddAction("Rename", () => RenameLogicItem(item));
menu.AddAction("Move Up", () => MoveItem(MoveDirection.Up, item));
menu.AddAction("Move Up 5 Spaces", () => MoveItem(MoveDirection.Up, item, 5));
menu.AddAction("Move to Top", () => MoveItem(MoveDirection.Up, item, true));
menu.AddAction("Move Down", () => MoveItem(MoveDirection.Down, item));
menu.AddAction("Move Down 5 Spaces", () => MoveItem(MoveDirection.Down, item, 5));
menu.AddAction("Move to Bottom", () => MoveItem(MoveDirection.Down, item, true));
menu.AddAction("Delete", () => DeleteTriggerLogic(item));
border.ContextMenu = menu;
}