mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Cleanup + Enforcing styling
This commit is contained in:
@ -26,6 +26,7 @@ namespace HeliosDisplayManagement.ShellExtension
|
||||
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Create_Shortcut,
|
||||
Properties.Resources.Shortcut_x16,
|
||||
(sender, args) => HeliosDisplayManagement.Open(HeliosStartupAction.CreateShortcut, profile)));
|
||||
|
||||
return profileMenu;
|
||||
}
|
||||
|
||||
@ -37,17 +38,25 @@ namespace HeliosDisplayManagement.ShellExtension
|
||||
protected override ContextMenuStrip CreateMenu()
|
||||
{
|
||||
var explorerMenu = new ContextMenuStrip();
|
||||
|
||||
if (Profile.GetAllProfiles().Any())
|
||||
{
|
||||
Profile.RefreshActiveStatus();
|
||||
var extensionMenu = new ToolStripMenuItem(Language.Display_Profiles,
|
||||
Properties.Resources.Icon_x16);
|
||||
|
||||
foreach (var profile in Profile.GetAllProfiles())
|
||||
{
|
||||
extensionMenu.DropDownItems.Add(CreateProfileMenu(profile));
|
||||
}
|
||||
|
||||
extensionMenu.DropDownItems.Add(new ToolStripSeparator());
|
||||
extensionMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Manage_Profiles,
|
||||
Properties.Resources.Icon_x16,
|
||||
(sender, args) => { HeliosDisplayManagement.Open(); }));
|
||||
(sender, args) =>
|
||||
{
|
||||
HeliosDisplayManagement.Open();
|
||||
}));
|
||||
explorerMenu.Items.Add(extensionMenu);
|
||||
explorerMenu.Items.Add(new ToolStripSeparator());
|
||||
}
|
||||
@ -55,10 +64,14 @@ namespace HeliosDisplayManagement.ShellExtension
|
||||
{
|
||||
var extensionMenu = new ToolStripMenuItem(Language.Manage_Profiles,
|
||||
Properties.Resources.Icon_x16,
|
||||
(sender, args) => { HeliosDisplayManagement.Open(); });
|
||||
(sender, args) =>
|
||||
{
|
||||
HeliosDisplayManagement.Open();
|
||||
});
|
||||
explorerMenu.Items.Add(extensionMenu);
|
||||
explorerMenu.Items.Add(new ToolStripSeparator());
|
||||
}
|
||||
|
||||
return explorerMenu;
|
||||
}
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ namespace HeliosDisplayManagement.ShellExtension
|
||||
protected override bool CanShowMenu()
|
||||
{
|
||||
return Helios.IsInstalled &&
|
||||
(SelectedItemPaths.Count() == 1) &&
|
||||
SelectedItemPaths.Count() == 1 &&
|
||||
Profile.GetAllProfiles().Any() &&
|
||||
(Path.GetExtension(SelectedItemPaths.First())?.ToLower() == @".exe");
|
||||
Path.GetExtension(SelectedItemPaths.First())?.ToLower() == @".exe";
|
||||
}
|
||||
|
||||
protected override ContextMenuStrip CreateMenu()
|
||||
@ -26,18 +26,28 @@ namespace HeliosDisplayManagement.ShellExtension
|
||||
var explorerMenu = new ContextMenuStrip();
|
||||
var extensionMenu = new ToolStripMenuItem(Language.Open_under_Display_Profile,
|
||||
Properties.Resources.Icon_x16);
|
||||
|
||||
if (Profile.GetAllProfiles().Any())
|
||||
{
|
||||
Profile.RefreshActiveStatus();
|
||||
|
||||
foreach (var profile in Profile.GetAllProfiles())
|
||||
{
|
||||
extensionMenu.DropDownItems.Add(CreateProfileMenu(profile));
|
||||
}
|
||||
|
||||
extensionMenu.DropDownItems.Add(new ToolStripSeparator());
|
||||
}
|
||||
|
||||
extensionMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Manage_Profiles,
|
||||
Properties.Resources.Icon_x16,
|
||||
(sender, args) => { HeliosDisplayManagement.Open(); }));
|
||||
(sender, args) =>
|
||||
{
|
||||
HeliosDisplayManagement.Open();
|
||||
}));
|
||||
explorerMenu.Items.Add(extensionMenu);
|
||||
explorerMenu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
return explorerMenu;
|
||||
}
|
||||
|
||||
@ -58,6 +68,7 @@ namespace HeliosDisplayManagement.ShellExtension
|
||||
(sender, args) =>
|
||||
HeliosDisplayManagement.Open(HeliosStartupAction.CreateShortcut, profile,
|
||||
SelectedItemPaths.FirstOrDefault())));
|
||||
|
||||
return profileMenu;
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ namespace HeliosDisplayManagement.ShellExtension
|
||||
protected override bool CanShowMenu()
|
||||
{
|
||||
return Helios.IsInstalled &&
|
||||
(SelectedItemPaths.Count() == 1) &&
|
||||
SelectedItemPaths.Count() == 1 &&
|
||||
Profile.GetAllProfiles().Any() &&
|
||||
(ParseSteamAppId() > 0);
|
||||
ParseSteamAppId() > 0;
|
||||
}
|
||||
|
||||
protected override ContextMenuStrip CreateMenu()
|
||||
@ -27,18 +27,28 @@ namespace HeliosDisplayManagement.ShellExtension
|
||||
var explorerMenu = new ContextMenuStrip();
|
||||
var extensionMenu = new ToolStripMenuItem(Language.Open_under_Display_Profile,
|
||||
Properties.Resources.Icon_x16);
|
||||
|
||||
if (Profile.GetAllProfiles().Any())
|
||||
{
|
||||
Profile.RefreshActiveStatus();
|
||||
|
||||
foreach (var profile in Profile.GetAllProfiles())
|
||||
{
|
||||
extensionMenu.DropDownItems.Add(CreateProfileMenu(profile));
|
||||
}
|
||||
|
||||
extensionMenu.DropDownItems.Add(new ToolStripSeparator());
|
||||
}
|
||||
|
||||
extensionMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Manage_Profiles,
|
||||
Properties.Resources.Icon_x16,
|
||||
(sender, args) => { HeliosDisplayManagement.Open(); }));
|
||||
(sender, args) =>
|
||||
{
|
||||
HeliosDisplayManagement.Open();
|
||||
}));
|
||||
explorerMenu.Items.Add(extensionMenu);
|
||||
explorerMenu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
return explorerMenu;
|
||||
}
|
||||
|
||||
@ -56,6 +66,7 @@ namespace HeliosDisplayManagement.ShellExtension
|
||||
(sender, args) =>
|
||||
HeliosDisplayManagement.OpenSteamGame(HeliosStartupAction.CreateShortcut, profile,
|
||||
appId)));
|
||||
|
||||
return profileMenu;
|
||||
}
|
||||
|
||||
@ -64,31 +75,49 @@ namespace HeliosDisplayManagement.ShellExtension
|
||||
try
|
||||
{
|
||||
var fileAddress = SelectedItemPaths.FirstOrDefault();
|
||||
if (!string.IsNullOrWhiteSpace(fileAddress) && File.Exists(fileAddress) &&
|
||||
(new FileInfo(fileAddress).Length < 1024))
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(fileAddress) &&
|
||||
File.Exists(fileAddress) &&
|
||||
new FileInfo(fileAddress).Length < 1024)
|
||||
{
|
||||
var fileContent = File.ReadAllText(fileAddress);
|
||||
|
||||
if (!fileContent.Contains(@"[InternetShortcut]"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var steamUrlPattern = @"steam://rungameid/";
|
||||
var urlIndex = fileContent.IndexOf(steamUrlPattern, StringComparison.InvariantCultureIgnoreCase);
|
||||
|
||||
if (urlIndex < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var nextLine = fileContent.IndexOf(@"\r", urlIndex + steamUrlPattern.Length,
|
||||
StringComparison.InvariantCultureIgnoreCase);
|
||||
|
||||
if (nextLine < 0)
|
||||
{
|
||||
nextLine = fileContent.Length - 1;
|
||||
}
|
||||
|
||||
var appIdString = fileContent.Substring(urlIndex + steamUrlPattern.Length,
|
||||
nextLine - urlIndex - steamUrlPattern.Length);
|
||||
uint appId;
|
||||
|
||||
if (uint.TryParse(appIdString, out appId))
|
||||
{
|
||||
return appId;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -12,13 +12,18 @@ namespace HeliosDisplayManagement.ShellExtension
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<packages>
|
||||
<package id="SharpShell" version="2.3.2" targetFramework="net45" />
|
||||
<package id="SharpShellTools" version="2.2.1" targetFramework="net45" />
|
||||
|
Reference in New Issue
Block a user