First working ShellContextMenu extension
Can now apply saved display profiles by right-clicking on the Desktop Background and selecting the display profile that you want to use. It will run <HeliosPlus> ChangeProfile <uuid> where <HeliosPlus> is the HeliosPlus binary and <uuid> is the UUID of the relevant display profile.
@ -54,11 +54,18 @@
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>HeliosPlus2.ico</ApplicationIcon>
|
||||
<ApplicationIcon>HeliosPlus.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignManifests>true</SignManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>
|
||||
</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@ -72,7 +79,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="FodyWeavers.xml" />
|
||||
<Content Include="HeliosPlus2.ico" />
|
||||
<Content Include="HeliosPlus.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Costura.Fody">
|
||||
|
Before Width: | Height: | Size: 457 KiB After Width: | Height: | Size: 457 KiB |
@ -33,7 +33,15 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>HeliosPlus2.ico</ApplicationIcon>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>
|
||||
</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
@ -116,7 +124,7 @@
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="HeliosPlus2.ico" />
|
||||
<None Include="Resources\HeliosPlus.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -38,7 +38,7 @@ namespace HeliosPlus.Shared
|
||||
// Common items to the class
|
||||
private static List<ProfileItem> _allProfiles = new List<ProfileItem>();
|
||||
private static bool _profilesLoaded = false;
|
||||
public static Version Version = new Version(1, 0, 0);
|
||||
public static Version _version = new Version(1, 0, 0);
|
||||
private static ProfileItem _currentProfile;
|
||||
|
||||
// Other constants that are useful
|
||||
@ -46,7 +46,7 @@ namespace HeliosPlus.Shared
|
||||
public static string AppIconPath = System.IO.Path.Combine(AppDataPath, $"Icons");
|
||||
public static string AppHeliosPlusIconFilename = System.IO.Path.Combine(AppIconPath, @"HeliosPlus.ico");
|
||||
private static string AppProfileStoragePath = System.IO.Path.Combine(AppDataPath, $"Profiles");
|
||||
private static string _profileStorageJsonFileName = System.IO.Path.Combine(AppProfileStoragePath, $"DisplayProfiles_{Version.ToString(2)}.json");
|
||||
private static string _profileStorageJsonFileName = System.IO.Path.Combine(AppProfileStoragePath, $"DisplayProfiles_{_version.ToString(2)}.json");
|
||||
|
||||
|
||||
#endregion
|
||||
|
10
HeliosPlus.Shared/Properties/Resources.Designer.cs
generated
@ -59,5 +59,15 @@ namespace HeliosPlus.Shared.Properties {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon HeliosPlus {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("HeliosPlus", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,4 +117,8 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="HeliosPlus" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\HeliosPlus.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
Before Width: | Height: | Size: 457 KiB After Width: | Height: | Size: 457 KiB |
Before Width: | Height: | Size: 108 KiB |
@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using HeliosPlus.Shared;
|
||||
using HeliosPlus.ShellExtension.Resources;
|
||||
|
||||
namespace HeliosPlus.ShellExtension
|
||||
{
|
||||
internal class HeliosPlus
|
||||
{
|
||||
internal static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus");
|
||||
|
||||
public static void Open(
|
||||
HeliosStartupAction action = HeliosStartupAction.StartUpNormally,
|
||||
ProfileItem profile = null,
|
||||
string programAddress = null,
|
||||
bool asAdmin = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
Helios.Open(action, profile, programAddress, asAdmin);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.ToString(), string.Format(Language.Failed_to_execute_action_Error_Message, e.Message),
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public static void OpenSteamGame(
|
||||
HeliosStartupAction action = HeliosStartupAction.StartUpNormally,
|
||||
ProfileItem profile = null,
|
||||
uint steamAppId = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
Helios.OpenSteamGame(action, profile, steamAppId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.ToString(), string.Format(Language.Failed_to_execute_action_Error_Message, e.Message),
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,75 +1,119 @@
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using HeliosPlus.Shared;
|
||||
using System.IO;
|
||||
using System;
|
||||
using HeliosPlus.ShellExtension.Resources;
|
||||
using HeliosPlus;
|
||||
using SharpShell.Attributes;
|
||||
using SharpShell.SharpContextMenu;
|
||||
using SharpShell.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace HeliosPlus.ShellExtension
|
||||
{
|
||||
[ComVisible(true)]
|
||||
[COMServerAssociation(AssociationType.Class, @"DesktopBackground")]
|
||||
[Guid("2EC0C798-715B-458E-8C86-5D846F67FBA1")]
|
||||
internal class HeliosDesktopMenuExtension : SharpContextMenu
|
||||
[COMServerAssociation(AssociationType.DesktopBackground)]
|
||||
[Guid("346e3285-43ca-45bc-8b33-1d4cdfe32e00")]
|
||||
public class HeliosDesktopMenuExtension : SharpContextMenu
|
||||
{
|
||||
private static ToolStripMenuItem CreateProfileMenu(ProfileItem profile)
|
||||
{
|
||||
var profileMenu = new ToolStripMenuItem(profile.Name, new ProfileIcon(profile).ToBitmap(16, 16));
|
||||
profileMenu.DropDownItems.Add(new ToolStripMenuItem("Change Profile", null,
|
||||
(sender, args) => HeliosPlus.Open(HeliosStartupAction.ChangeProfile, profile))
|
||||
{
|
||||
Enabled = profile.IsPossible && !profile.IsActive
|
||||
}) ;
|
||||
profileMenu.DropDownItems.Add(new ToolStripSeparator());
|
||||
profileMenu.DropDownItems.Add(new ToolStripMenuItem("Run Shortcut", null,
|
||||
(sender, args) => HeliosPlus.Open(HeliosStartupAction.RunShortcut, profile)));
|
||||
// Other constants that are useful
|
||||
internal static Version _version = new Version(1, 0, 0);
|
||||
internal static string AlternateAppHomePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "HeliosPlus");
|
||||
internal static string AppDataPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus");
|
||||
private static string AppProfileStoragePath = System.IO.Path.Combine(AppDataPath, $"Profiles");
|
||||
private static string _profileStorageJsonFileName = System.IO.Path.Combine(AppProfileStoragePath, $"DisplayProfiles_{_version.ToString(2)}.json");
|
||||
internal static string registryHeliosPlus = @"SOFTWARE\HeliosPlus";
|
||||
string heliosPlusFullname = "";
|
||||
string heliosPlusInstallDir = "";
|
||||
|
||||
return profileMenu;
|
||||
}
|
||||
public HeliosDesktopMenuExtension()
|
||||
{ }
|
||||
|
||||
protected override bool CanShowMenu()
|
||||
{
|
||||
return Helios.IsInstalled;
|
||||
// Only show this menu if HeliosPlus is installed
|
||||
heliosPlusInstallDir = "";
|
||||
try
|
||||
{
|
||||
RegistryKey heliosPlusKey = Registry.LocalMachine.OpenSubKey(registryHeliosPlus, RegistryKeyPermissionCheck.ReadSubTree);
|
||||
heliosPlusInstallDir = heliosPlusKey.GetValue("InstallDir", AlternateAppHomePath).ToString();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
heliosPlusInstallDir = AlternateAppHomePath;
|
||||
}
|
||||
|
||||
heliosPlusFullname = Path.Combine(heliosPlusInstallDir, "HeliosPlus.exe");
|
||||
|
||||
|
||||
if (File.Exists(heliosPlusFullname))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override ContextMenuStrip CreateMenu()
|
||||
{
|
||||
var explorerMenu = new ContextMenuStrip();
|
||||
|
||||
if (ProfileRepository.AllProfiles.Any())
|
||||
{
|
||||
var extensionMenu = new ToolStripMenuItem(Language.Display_Profiles,
|
||||
Properties.Resources.HeliosPlus.ToBitmap());
|
||||
var explorerMenuStrip = new ContextMenuStrip();
|
||||
|
||||
foreach (var profile in ProfileRepository.AllProfiles)
|
||||
if (File.Exists(heliosPlusFullname))
|
||||
{
|
||||
extensionMenu.DropDownItems.Add(CreateProfileMenu(profile));
|
||||
|
||||
var extensionMenu = new ToolStripMenuItem("HeliosPlus: Change display profiles...", Properties.Resources.HeliosPlusMenuImage);
|
||||
explorerMenuStrip.Items.Add(extensionMenu);
|
||||
|
||||
Dictionary<string, string> profiles = new Dictionary<string, string>();
|
||||
|
||||
if (File.Exists(_profileStorageJsonFileName))
|
||||
{
|
||||
MatchCollection mc;
|
||||
string uuid = "";
|
||||
string profileName = "";
|
||||
|
||||
foreach (string aLine in File.ReadLines(_profileStorageJsonFileName, Encoding.Unicode))
|
||||
{
|
||||
string lineToProcess = aLine;
|
||||
if (lineToProcess.StartsWith(" \"UUID\""))
|
||||
{
|
||||
mc = Regex.Matches(lineToProcess, " \"UUID\": \"(.*)\"");
|
||||
uuid = mc[0].Groups[1].ToString();
|
||||
}
|
||||
else if (lineToProcess.StartsWith(" \"Name\""))
|
||||
{
|
||||
mc = Regex.Matches(lineToProcess, " \"Name\": \"(.*)\"");
|
||||
profileName = mc[0].Groups[1].ToString();
|
||||
if (!uuid.Equals(""))
|
||||
profiles.Add(profileName, uuid);
|
||||
}
|
||||
|
||||
extensionMenu.DropDownItems.Add(new ToolStripSeparator());
|
||||
extensionMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Manage_Profiles,
|
||||
Properties.Resources.HeliosPlus.ToBitmap(),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (profiles.Count > 0)
|
||||
{
|
||||
|
||||
foreach (KeyValuePair<string, string> pair in profiles.OrderBy(key => key.Key))
|
||||
{
|
||||
extensionMenu.DropDownItems.Add(new ToolStripMenuItem(pair.Key, null,
|
||||
(sender, args) =>
|
||||
{
|
||||
HeliosPlus.Open();
|
||||
}));
|
||||
explorerMenu.Items.Add(extensionMenu);
|
||||
explorerMenu.Items.Add(new ToolStripSeparator());
|
||||
Logging.Log(heliosPlusFullname + $" ChangeProfile {pair.Value}");
|
||||
Process.Start(heliosPlusFullname + $" ChangeProfile {pair.Value}");
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var extensionMenu = new ToolStripMenuItem(Language.Manage_Profiles,
|
||||
Properties.Resources.HeliosPlus.ToBitmap(),
|
||||
(sender, args) =>
|
||||
{
|
||||
HeliosPlus.Open();
|
||||
});
|
||||
explorerMenu.Items.Add(extensionMenu);
|
||||
explorerMenu.Items.Add(new ToolStripSeparator());
|
||||
}
|
||||
|
||||
return explorerMenu;
|
||||
return explorerMenuStrip;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using HeliosPlus.Shared;
|
||||
using HeliosPlus.ShellExtension.Resources;
|
||||
using SharpShell.Attributes;
|
||||
using SharpShell.SharpContextMenu;
|
||||
|
||||
namespace HeliosPlus.ShellExtension
|
||||
{
|
||||
[ComVisible(true)]
|
||||
[COMServerAssociation(AssociationType.ClassOfExtension, @".exe")]
|
||||
[Guid("48B49131-2258-4694-879F-A3F96310A220")]
|
||||
internal class HeliosExecutableMenuExtension : SharpContextMenu
|
||||
{
|
||||
protected override bool CanShowMenu()
|
||||
{
|
||||
return Helios.IsInstalled &&
|
||||
SelectedItemPaths.Count() == 1 &&
|
||||
ProfileRepository.AllProfiles.Any() &&
|
||||
Path.GetExtension(SelectedItemPaths.First())?.ToLower() == @".exe";
|
||||
}
|
||||
|
||||
protected override ContextMenuStrip CreateMenu()
|
||||
{
|
||||
var explorerMenu = new ContextMenuStrip();
|
||||
var extensionMenu = new ToolStripMenuItem(Language.Open_under_Display_Profile,
|
||||
Properties.Resources.HeliosPlus.ToBitmap());
|
||||
|
||||
if (ProfileRepository.AllProfiles.Any())
|
||||
{
|
||||
foreach (var profile in ProfileRepository.AllProfiles)
|
||||
{
|
||||
extensionMenu.DropDownItems.Add(CreateProfileMenu(profile));
|
||||
}
|
||||
|
||||
extensionMenu.DropDownItems.Add(new ToolStripSeparator());
|
||||
}
|
||||
|
||||
extensionMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Manage_Profiles,
|
||||
Properties.Resources.HeliosPlus.ToBitmap(),
|
||||
(sender, args) =>
|
||||
{
|
||||
HeliosPlus.Open();
|
||||
}));
|
||||
explorerMenu.Items.Add(extensionMenu);
|
||||
explorerMenu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
return explorerMenu;
|
||||
}
|
||||
|
||||
private ToolStripMenuItem CreateProfileMenu(ProfileItem profile)
|
||||
{
|
||||
var profileMenu = new ToolStripMenuItem(profile.Name, new ProfileIcon(profile).ToBitmap(16, 16));
|
||||
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Run, null,
|
||||
(sender, args) =>
|
||||
HeliosPlus.Open(HeliosStartupAction.ChangeProfile, profile,
|
||||
SelectedItemPaths.FirstOrDefault())));
|
||||
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Run_as_administrator, Shield.SmallIcon,
|
||||
(sender, args) =>
|
||||
HeliosPlus.Open(HeliosStartupAction.ChangeProfile, profile,
|
||||
SelectedItemPaths.FirstOrDefault(), true)));
|
||||
profileMenu.DropDownItems.Add(new ToolStripSeparator());
|
||||
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Create_Shortcut, null,
|
||||
(sender, args) =>
|
||||
HeliosPlus.Open(HeliosStartupAction.ChangeProfile, profile,
|
||||
SelectedItemPaths.FirstOrDefault())));
|
||||
|
||||
return profileMenu;
|
||||
}
|
||||
}
|
||||
}
|
@ -32,13 +32,13 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>HeliosPlus2.ico</ApplicationIcon>
|
||||
<ApplicationIcon>Resources\HeliosPlus.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
|
||||
<AssemblyOriginatorKeyFile>HeliosPlusSigningKey.pfx</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
@ -47,10 +47,7 @@
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Helios.cs" />
|
||||
<Compile Include="HeliosDesktopMenuExtension.cs" />
|
||||
<Compile Include="HeliosExecutableMenuExtension.cs" />
|
||||
<Compile Include="HeliosSteamUrlMenuExtension.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
@ -66,6 +63,7 @@
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\Language.resx">
|
||||
@ -88,8 +86,7 @@
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Key.snk" />
|
||||
<None Include="Resources\HeliosPlus.ico" />
|
||||
<None Include="HeliosPlusSigningKey.pfx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HeliosPlus.Shared\HeliosPlus.Shared.csproj">
|
||||
@ -98,7 +95,8 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="HeliosPlus2.ico" />
|
||||
<Content Include="Resources\HeliosPlus.ico" />
|
||||
<None Include="Resources\HeliosPlusMenuImage.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@ -1,118 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using HeliosPlus.Shared;
|
||||
using HeliosPlus.ShellExtension.Resources;
|
||||
using SharpShell.Attributes;
|
||||
using SharpShell.SharpContextMenu;
|
||||
|
||||
namespace HeliosPlus.ShellExtension
|
||||
{
|
||||
[ComVisible(true)]
|
||||
[COMServerAssociation(AssociationType.ClassOfExtension, @".url")]
|
||||
[Guid("E41ECFB2-3E7D-4A47-8A51-8627F1B21AE5")]
|
||||
internal class HeliosSteamUrlMenuExtension : SharpContextMenu
|
||||
{
|
||||
protected override bool CanShowMenu()
|
||||
{
|
||||
return Helios.IsInstalled &&
|
||||
SelectedItemPaths.Count() == 1 &&
|
||||
ProfileRepository.AllProfiles.Any() &&
|
||||
ParseSteamAppId() > 0;
|
||||
}
|
||||
|
||||
protected override ContextMenuStrip CreateMenu()
|
||||
{
|
||||
var explorerMenu = new ContextMenuStrip();
|
||||
var extensionMenu = new ToolStripMenuItem(Language.Open_under_Display_Profile,
|
||||
Properties.Resources.HeliosPlus.ToBitmap());
|
||||
|
||||
if (ProfileRepository.AllProfiles.Any())
|
||||
{
|
||||
foreach (var profile in ProfileRepository.AllProfiles)
|
||||
{
|
||||
extensionMenu.DropDownItems.Add(CreateProfileMenu(profile));
|
||||
}
|
||||
|
||||
extensionMenu.DropDownItems.Add(new ToolStripSeparator());
|
||||
}
|
||||
|
||||
extensionMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Manage_Profiles,
|
||||
Properties.Resources.HeliosPlus.ToBitmap(),
|
||||
(sender, args) =>
|
||||
{
|
||||
HeliosPlus.Open();
|
||||
}));
|
||||
explorerMenu.Items.Add(extensionMenu);
|
||||
explorerMenu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
return explorerMenu;
|
||||
}
|
||||
|
||||
private ToolStripMenuItem CreateProfileMenu(ProfileItem profile)
|
||||
{
|
||||
var appId = ParseSteamAppId();
|
||||
var profileMenu = new ToolStripMenuItem(profile.Name, new ProfileIcon(profile).ToBitmap(16, 16));
|
||||
profileMenu.DropDownItems.Add(new ToolStripMenuItem(Language.Run, null,
|
||||
(sender, args) =>
|
||||
HeliosPlus.OpenSteamGame(HeliosStartupAction.ChangeProfile, profile,
|
||||
appId)));
|
||||
|
||||
|
||||
return profileMenu;
|
||||
}
|
||||
|
||||
private uint ParseSteamAppId()
|
||||
{
|
||||
try
|
||||
{
|
||||
var fileAddress = SelectedItemPaths.FirstOrDefault();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -69,5 +69,15 @@ namespace HeliosPlus.ShellExtension.Properties {
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap HeliosPlusMenuImage {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("HeliosPlusMenuImage", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,4 +121,7 @@
|
||||
<data name="HeliosPlus" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\HeliosPlus.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="HeliosPlusMenuImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\HeliosPlusMenuImage.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
Before Width: | Height: | Size: 457 KiB After Width: | Height: | Size: 457 KiB |
BIN
HeliosPlus.ShellExtension/Resources/HeliosPlusMenuImage.png
Normal file
After Width: | Height: | Size: 758 B |
@ -27,6 +27,7 @@
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
@ -53,8 +54,7 @@
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
<ApplicationIcon>Resources\HeliosPlus.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>HeliosPlus.Program</StartupObject>
|
||||
@ -64,6 +64,13 @@
|
||||
<PropertyGroup>
|
||||
<SignManifests>false</SignManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>
|
||||
</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="PresentationCore" />
|
||||
@ -107,12 +114,6 @@
|
||||
<Compile Include="UIForms\MaskedDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UIForms\WaitingForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UIForms\WaitingForm.Designer.cs">
|
||||
<DependentUpon>WaitingForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UIForms\ShortcutAdaptor.cs" />
|
||||
<Compile Include="UIForms\ProfileAdaptor.cs" />
|
||||
<Compile Include="UIForms\MainForm.cs">
|
||||
@ -170,9 +171,6 @@
|
||||
<EmbeddedResource Include="UIForms\MaskedForm.resx">
|
||||
<DependentUpon>MaskedForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UIForms\WaitingForm.resx">
|
||||
<DependentUpon>WaitingForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UIForms\MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
@ -274,6 +272,7 @@
|
||||
<None Include="Resources\Epic.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\HeliosPlus.ico" />
|
||||
<Content Include="Resources\redarrows.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -103,6 +103,23 @@ namespace HeliosPlus {
|
||||
});
|
||||
});
|
||||
|
||||
// This is the ApplyProfile command
|
||||
app.Command(HeliosStartupAction.ChangeProfile.ToString(), (runShortcutCmd) =>
|
||||
{
|
||||
var argumentShortcut = runShortcutCmd.Argument("\"SHORTCUT_UUID\"", "(required) The UUID of the shortcut to run from those stored in the shortcut library.").IsRequired();
|
||||
argumentShortcut.Validators.Add(new ShortcutMustExistValidator());
|
||||
|
||||
//description and help text of the command.
|
||||
runShortcutCmd.Description = "Use this command to run favourite game or application with a display profile of your choosing.";
|
||||
|
||||
runShortcutCmd.OnExecute(() =>
|
||||
{
|
||||
//
|
||||
RunShortcut(argumentShortcut.Value);
|
||||
return 0;
|
||||
});
|
||||
});
|
||||
|
||||
app.OnExecute(() =>
|
||||
{
|
||||
|
||||
|
@ -122,7 +122,7 @@
|
||||
<value>..\Resources\Epic.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="HeliosPlus" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\HeliosPlus2.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<value>..\Resources\HeliosPlus.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Origin" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Origin.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
|
Before Width: | Height: | Size: 457 KiB After Width: | Height: | Size: 457 KiB |
Before Width: | Height: | Size: 457 KiB |
99
HeliosPlus/UIForms/WaitingForm.Designer.cs
generated
@ -1,99 +0,0 @@
|
||||
|
||||
namespace HeliosPlus.UIForms
|
||||
{
|
||||
partial class WaitingForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WaitingForm));
|
||||
this.btn_stop_waiting = new System.Windows.Forms.Button();
|
||||
this.lbl_title = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btn_stop_waiting
|
||||
//
|
||||
this.btn_stop_waiting.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btn_stop_waiting.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
|
||||
this.btn_stop_waiting.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
|
||||
this.btn_stop_waiting.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btn_stop_waiting.ForeColor = System.Drawing.Color.White;
|
||||
this.btn_stop_waiting.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.btn_stop_waiting.Location = new System.Drawing.Point(534, 183);
|
||||
this.btn_stop_waiting.Name = "btn_stop_waiting";
|
||||
this.btn_stop_waiting.Size = new System.Drawing.Size(99, 23);
|
||||
this.btn_stop_waiting.TabIndex = 4;
|
||||
this.btn_stop_waiting.Text = "&Stop Waiting";
|
||||
this.btn_stop_waiting.UseVisualStyleBackColor = true;
|
||||
this.btn_stop_waiting.Click += new System.EventHandler(this.btn_stop_waiting_Click);
|
||||
//
|
||||
// lbl_title
|
||||
//
|
||||
this.lbl_title.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lbl_title.AutoSize = true;
|
||||
this.lbl_title.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lbl_title.ForeColor = System.Drawing.Color.White;
|
||||
this.lbl_title.Location = new System.Drawing.Point(202, 84);
|
||||
this.lbl_title.Name = "lbl_title";
|
||||
this.lbl_title.Size = new System.Drawing.Size(259, 26);
|
||||
this.lbl_title.TabIndex = 5;
|
||||
this.lbl_title.Text = "Waiting for game to exit...";
|
||||
this.lbl_title.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.lbl_title.UseWaitCursor = true;
|
||||
//
|
||||
// WaitingForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.DimGray;
|
||||
this.ClientSize = new System.Drawing.Size(645, 218);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.lbl_title);
|
||||
this.Controls.Add(this.btn_stop_waiting);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "WaitingForm";
|
||||
this.Opacity = 0.8D;
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Waiting...";
|
||||
this.TopMost = true;
|
||||
this.UseWaitCursor = true;
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btn_stop_waiting;
|
||||
private System.Windows.Forms.Label lbl_title;
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HeliosPlus.UIForms
|
||||
{
|
||||
public partial class WaitingForm : Form
|
||||
{
|
||||
public WaitingForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void btn_stop_waiting_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|