Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/script without icon #8111

Merged
merged 3 commits into from
May 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public ScriptsSettingsPage()

propertyGrid1.SelectedGridItemChanged += (s, e) =>
{
if (WatchedProxyProperties.Contains(e.OldSelection?.PropertyDescriptor.Name ?? ""))
if (WatchedProxyProperties.Contains(e.OldSelection?.PropertyDescriptor?.Name ?? ""))
{
BindScripts(_scripts, SelectedScript);
propertyGrid1.Focus();
Expand Down Expand Up @@ -267,7 +267,7 @@ private void btnAdd_Click(object sender, EventArgs e)

private void btnArgumentsHelp_Click(object sender, EventArgs e)
{
if (_argumentsCheatSheet is object)
if (_argumentsCheatSheet?.Visible ?? false)
{
_argumentsCheatSheet.BringToFront();
return;
Expand Down
9 changes: 8 additions & 1 deletion GitUI/CommandsDialogs/UserScriptContextMenuExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using GitUI.Hotkey;
using GitUI.Script;
using ResourceManager;

namespace GitUI.CommandsDialogs
{
public static class UserScriptContextMenuExtensions
{
private static readonly Lazy<IEnumerable<HotkeyCommand>> Hotkeys = new Lazy<IEnumerable<HotkeyCommand>>(()
=> HotkeySettingsManager.LoadHotkeys(FormSettings.HotkeySettingsName));

/// <summary>
/// Appends user scripts to the <paramref name="contextMenu"/>, or under <paramref name="hostMenuItem"/>,
/// if scripts are marked as <see cref="ScriptInfo.AddToRevisionGridContextMenu"/>.
Expand Down Expand Up @@ -60,7 +66,8 @@ void AddOwnScripts()
{
Text = script.Name,
Name = script.Name + "_ownScript",
Image = script.GetIcon()
Image = script.GetIcon(),
ShortcutKeyDisplayString = Hotkeys.Value?.FirstOrDefault(h => h.Name == script.Name)?.KeyData.ToShortcutKeyDisplayString()
};

item.Click += (s, e) =>
Expand Down
5 changes: 5 additions & 0 deletions GitUI/Script/ScriptInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public ScriptInfo()
[CanBeNull]
public System.Drawing.Bitmap GetIcon()
{
if (string.IsNullOrWhiteSpace(Icon))
{
return null;
}

// Get all resources
System.Resources.ResourceManager rm
= new System.Resources.ResourceManager("GitUI.Properties.Images",
Expand Down