private void ConditionMenuItem_Click(object sender, RoutedEventArgs e) { var selectedItem = TreeViewCommands.SelectedItem; if (selectedItem == null) { return; } var condition = ((MenuItem)sender).Header as ICondition; var properties = condition.GetType().GetProperties(); if (properties.Length > (condition is IOrderBy ? 1 : 0)) { var commandWindow = new CommandWindow(condition) { Owner = this }; if (commandWindow.ShowDialog() != true) { return; } } var node = new BatchNode() { Condition = condition }; if (selectedItem is TreeViewItem) { rootNode.Children.Add(node); } else { (selectedItem as BatchNode)?.Children.Add(node); } }
private void CommandMenuItem_Click(object sender, RoutedEventArgs e) { var selectedItem = TreeViewCommands.SelectedItem; if (selectedItem == null) { return; } ICommand command; if ((sender as MenuItem)?.Header is ICommand asCommandFromMenuItem) { command = asCommandFromMenuItem; } else if (sender is Button button) { command = PluginManager.Instance.FindCommand(button.Tag as string); } else if (sender is ICommand asCommand) { command = asCommand; } else { return; } if (command == null) { return; } command = Activator.CreateInstance(command.GetType()) as ICommand; var properties = command?.GetType().GetProperties(); if (properties?.Length > (command is IOrderBy ? 3 : 2)) { var commandWindow = new CommandWindow(command) { Owner = this }; if (commandWindow.ShowDialog() != true) { return; } } var node = new BatchNode() { Command = command }; if (selectedItem is TreeViewItem) { rootNode.Children.Add(node); } else { (selectedItem as BatchNode)?.Children.Add(node); } }