Icons added for the shell extension context menu

This commit is contained in:
s_falahati 2017-08-10 18:39:41 +04:30
parent fc896f9692
commit 6e704ca74d
10 changed files with 79 additions and 8 deletions

View File

@ -15,15 +15,15 @@ namespace HeliosDisplayManagement.ShellExtension
private static ToolStripMenuItem CreateProfileMenu(Profile profile) private static ToolStripMenuItem CreateProfileMenu(Profile profile)
{ {
var profileMenu = new ToolStripMenuItem(profile.Name, new ProfileIcon(profile).ToBitmap(16, 16)); var profileMenu = new ToolStripMenuItem(profile.Name, new ProfileIcon(profile).ToBitmap(16, 16));
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Apply, null, profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Apply, Properties.Resources.Run_x16,
(sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.SwitchProfile, profile)) (sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.SwitchProfile, profile))
{ {
Enabled = profile.IsPossible && !profile.IsActive Enabled = profile.IsPossible && !profile.IsActive
}); });
profileMenu.DropDownItems.Add(new ToolStripSeparator()); profileMenu.DropDownItems.Add(new ToolStripSeparator());
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Edit, null, profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Edit, Properties.Resources.Edit_x16,
(sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.EditProfile, profile))); (sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.EditProfile, profile)));
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Create_Shortcut, null, profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Create_Shortcut, Properties.Resources.Shortcut_x16,
(sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.CreateShortcut, profile))); (sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.CreateShortcut, profile)));
return profileMenu; return profileMenu;
} }

View File

@ -80,8 +80,14 @@
<Link>srm.exe</Link> <Link>srm.exe</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<None Include="Resources\Run_x16.png" />
<None Include="Resources\Shortcut_x16.png" />
<None Include="Resources\Edit_x16.png" />
<None Include="Resources\Icon_x16.png" /> <None Include="Resources\Icon_x16.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Include="Shield.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -40,18 +40,18 @@ namespace HeliosDisplayManagement.ShellExtension
private ToolStripMenuItem CreateProfileMenu(Profile profile) private ToolStripMenuItem CreateProfileMenu(Profile profile)
{ {
var profileMenu = new ToolStripMenuItem(profile.Name, new ProfileIcon(profile).ToBitmap(16, 16)); var profileMenu = new ToolStripMenuItem(profile.Name, new ProfileIcon(profile).ToBitmap(16, 16));
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Run, null, profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Run, Properties.Resources.Run_x16,
(sender, args) => (sender, args) =>
HeliosDisplayManagement.Open(HeliosStartupAction.SwitchProfile, profile, HeliosDisplayManagement.Open(HeliosStartupAction.SwitchProfile, profile,
SelectedItemPaths.FirstOrDefault()))); SelectedItemPaths.FirstOrDefault())));
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Run_as_administrator, null, profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Run_as_administrator, Shield.SmallIcon,
(sender, args) => (sender, args) =>
HeliosDisplayManagement.Open(HeliosStartupAction.SwitchProfile, profile, HeliosDisplayManagement.Open(HeliosStartupAction.SwitchProfile, profile,
SelectedItemPaths.FirstOrDefault(), true))); SelectedItemPaths.FirstOrDefault(), true)));
profileMenu.DropDownItems.Add(new ToolStripSeparator()); profileMenu.DropDownItems.Add(new ToolStripSeparator());
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Edit, null, profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Edit, null,
(sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.EditProfile, profile))); (sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.EditProfile, profile)));
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Create_Shortcut, null, profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Create_Shortcut, Properties.Resources.Shortcut_x16,
(sender, args) => (sender, args) =>
HeliosDisplayManagement.Open(HeliosStartupAction.CreateShortcut, profile, HeliosDisplayManagement.Open(HeliosStartupAction.CreateShortcut, profile,
SelectedItemPaths.FirstOrDefault()))); SelectedItemPaths.FirstOrDefault())));

View File

@ -42,14 +42,14 @@ namespace HeliosDisplayManagement.ShellExtension
{ {
var appId = ParseSteamAppId(); var appId = ParseSteamAppId();
var profileMenu = new ToolStripMenuItem(profile.Name, new ProfileIcon(profile).ToBitmap(16, 16)); var profileMenu = new ToolStripMenuItem(profile.Name, new ProfileIcon(profile).ToBitmap(16, 16));
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Run, null, profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Run, Properties.Resources.Run_x16,
(sender, args) => (sender, args) =>
HeliosDisplayManagement.OpenSteamGame(HeliosStartupAction.SwitchProfile, profile, HeliosDisplayManagement.OpenSteamGame(HeliosStartupAction.SwitchProfile, profile,
appId))); appId)));
profileMenu.DropDownItems.Add(new ToolStripSeparator()); profileMenu.DropDownItems.Add(new ToolStripSeparator());
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Edit, null, profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Edit, null,
(sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.EditProfile, profile))); (sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.EditProfile, profile)));
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Create_Shortcut, null, profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Create_Shortcut, Properties.Resources.Shortcut_x16,
(sender, args) => (sender, args) =>
HeliosDisplayManagement.OpenSteamGame(HeliosStartupAction.CreateShortcut, profile, HeliosDisplayManagement.OpenSteamGame(HeliosStartupAction.CreateShortcut, profile,
appId))); appId)));

View File

@ -60,6 +60,16 @@ namespace HeliosDisplayManagement.ShellExtension.Properties {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Edit_x16 {
get {
object obj = ResourceManager.GetObject("Edit_x16", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
@ -69,5 +79,25 @@ namespace HeliosDisplayManagement.ShellExtension.Properties {
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Run_x16 {
get {
object obj = ResourceManager.GetObject("Run_x16", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Shortcut_x16 {
get {
object obj = ResourceManager.GetObject("Shortcut_x16", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
} }
} }

View File

@ -118,7 +118,16 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Edit_x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Edit_x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Icon_x16" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Icon_x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Icon_x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\Icon_x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="Run_x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Run_x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Shortcut_x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Shortcut_x16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,26 @@
using System.Drawing;
using System.Windows.Forms;
namespace HeliosDisplayManagement.ShellExtension
{
public static class Shield
{
private static Bitmap _smallIcon;
public static Bitmap SmallIcon
{
get
{
if (_smallIcon != null)
return _smallIcon;
var iconSize = SystemInformation.SmallIconSize;
_smallIcon = new Bitmap(iconSize.Width, iconSize.Height);
using (var g = Graphics.FromImage(_smallIcon))
{
g.DrawIcon(SystemIcons.Shield, new Rectangle(Point.Empty, iconSize));
}
return _smallIcon;
}
}
}
}