private void PasteToSelectedActionMenuItem_Click(object sender, RoutedEventArgs e) { if (_commandClipboard.Count == 0) { return; } var targetApplication = lstAvailableApplication.SelectedItem as IApplication; if (targetApplication == null) { return; } var selectedCommand = lstAvailableActions.SelectedItem as CommandInfo; if (selectedCommand == null || selectedCommand.Action == null) { return; } lstAvailableActions.SelectedItem = null; IAction currentAction = selectedCommand.Action; foreach (var actionGroup in _commandClipboard.GroupBy(ci => ci.Action)) { foreach (var info in actionGroup) { if (_cutActionSource != null) { info.Action.RemoveCommand(info.Command); } var newCommand = ((Command)info.Command).Clone() as Command; newCommand.Name = ApplicationManager.GetNextCommandName(newCommand.Name, info.Action); currentAction.AddCommand(newCommand); } } if (_cutActionSource != null) { _cutActionSource = null; _commandClipboard.Clear(); } ApplicationManager.Instance.SaveApplications(); }