public static void AddToolbarButton(PluginData pluginData, ToolBar toolBar, IGitRepository gitRepository) { Button button = new Button(); button.Width = 100; StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Vertical; BitmapImage bitmapImage = new BitmapImage(new Uri(pluginData.IconPath, UriKind.RelativeOrAbsolute)); Image image = new Image(); image.Source = bitmapImage; image.Width = 32; image.Height = 32; TextBlock textBlock = new TextBlock(); textBlock.HorizontalAlignment = HorizontalAlignment.Center; textBlock.Text = pluginData.Title; stackPanel.Children.Add(image); stackPanel.Children.Add(textBlock); button.Content = stackPanel; button.Command = new DelegateCommand(async(object parameter) => { string workingDirectory = gitRepository.GetRepositoryDirectory(); switch (pluginData.ExecutionType) { case ExecutionType.WithoutShellAndNoWaiting: { RunExternal runner = new RunExternal(pluginData.Command, workingDirectory); try { runner.RunWithoutWaiting(pluginData.Argument); } catch (System.Exception exception) { UIService.ShowMessage("Cannot execute. " + exception.Message); } return; } case ExecutionType.WimyGitInnerShellAndRefreshRepositoryStatus: { RunExternal runner = new RunExternal(pluginData.Command, workingDirectory); try { runner.RunInConsoleProgressWindow(pluginData.Argument); await gitRepository.Refresh(); } catch (System.Exception exception) { UIService.ShowMessage("Cannot execute. " + exception.Message); } return; } } }); toolBar.Items.Add(button); }