Updated shell ext to createprofile

This commit is contained in:
Terry MacDonald 2020-12-06 21:19:03 +13:00
parent 7e43cd99ef
commit 45e2c32c30
6 changed files with 107 additions and 72 deletions

View File

@ -226,13 +226,13 @@
"Entry" "Entry"
{ {
"MsmKey" = "8:_7E279826AED3D503C2B7F7DB69F2C6E7" "MsmKey" = "8:_7E279826AED3D503C2B7F7DB69F2C6E7"
"OwnerKey" = "8:_60AA7260CBB14B2DA5A5237FEBBA6E3B" "OwnerKey" = "8:_3427114400C346E681DEA717B5D9A237"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry" "Entry"
{ {
"MsmKey" = "8:_7E279826AED3D503C2B7F7DB69F2C6E7" "MsmKey" = "8:_7E279826AED3D503C2B7F7DB69F2C6E7"
"OwnerKey" = "8:_3427114400C346E681DEA717B5D9A237" "OwnerKey" = "8:_60AA7260CBB14B2DA5A5237FEBBA6E3B"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry" "Entry"
@ -394,7 +394,13 @@
"Entry" "Entry"
{ {
"MsmKey" = "8:_UNDEFINED" "MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_3427114400C346E681DEA717B5D9A237" "OwnerKey" = "8:_65F5D368273B99C7FE49B20D33031A7B"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_6F55062F4B8FDA7C720DAA94953D9E90"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry" "Entry"
@ -406,6 +412,12 @@
"Entry" "Entry"
{ {
"MsmKey" = "8:_UNDEFINED" "MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_3427114400C346E681DEA717B5D9A237"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_7E279826AED3D503C2B7F7DB69F2C6E7" "OwnerKey" = "8:_7E279826AED3D503C2B7F7DB69F2C6E7"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
@ -583,18 +595,6 @@
"OwnerKey" = "8:_90FC8214331F53FD9474FAE9E83D2C2C" "OwnerKey" = "8:_90FC8214331F53FD9474FAE9E83D2C2C"
"MsmSig" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED"
} }
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_65F5D368273B99C7FE49B20D33031A7B"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_6F55062F4B8FDA7C720DAA94953D9E90"
"MsmSig" = "8:_UNDEFINED"
}
} }
"Configurations" "Configurations"
{ {
@ -678,7 +678,7 @@
"EntryPoint" = "8:" "EntryPoint" = "8:"
"Sequence" = "3:1" "Sequence" = "3:1"
"Identifier" = "8:_703939FB_1800_4C54_9228_AE37F541938E" "Identifier" = "8:_703939FB_1800_4C54_9228_AE37F541938E"
"InstallerClass" = "11:TRUE" "InstallerClass" = "11:FALSE"
"CustomActionData" = "8:" "CustomActionData" = "8:"
"Run64Bit" = "11:TRUE" "Run64Bit" = "11:TRUE"
} }
@ -693,7 +693,7 @@
"EntryPoint" = "8:" "EntryPoint" = "8:"
"Sequence" = "3:1" "Sequence" = "3:1"
"Identifier" = "8:_4CB63466_63BE_413E_AFD3_98040D42F4F1" "Identifier" = "8:_4CB63466_63BE_413E_AFD3_98040D42F4F1"
"InstallerClass" = "11:TRUE" "InstallerClass" = "11:FALSE"
"CustomActionData" = "8:" "CustomActionData" = "8:"
"Run64Bit" = "11:TRUE" "Run64Bit" = "11:TRUE"
} }
@ -1034,7 +1034,7 @@
{ {
"AssemblyRegister" = "3:1" "AssemblyRegister" = "3:1"
"AssemblyIsInGAC" = "11:FALSE" "AssemblyIsInGAC" = "11:FALSE"
"AssemblyAsmDisplayName" = "8:DisplayMagician.ShellExtension, Version=0.1.0.41963, Culture=neutral, PublicKeyToken=23a864d3136391eb, processorArchitecture=MSIL" "AssemblyAsmDisplayName" = "8:DisplayMagician.ShellExtension, Version=0.1.0.37800, Culture=neutral, PublicKeyToken=23a864d3136391eb, processorArchitecture=MSIL"
"ScatterAssemblies" "ScatterAssemblies"
{ {
"_3427114400C346E681DEA717B5D9A237" "_3427114400C346E681DEA717B5D9A237"
@ -1542,7 +1542,7 @@
"SharedLegacy" = "11:FALSE" "SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1" "PackageAs" = "3:1"
"Register" = "3:1" "Register" = "3:1"
"Exclude" = "11:TRUE" "Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE" "IsDependency" = "11:TRUE"
"IsolateTo" = "8:" "IsolateTo" = "8:"
} }
@ -1581,7 +1581,7 @@
{ {
"AssemblyRegister" = "3:1" "AssemblyRegister" = "3:1"
"AssemblyIsInGAC" = "11:FALSE" "AssemblyIsInGAC" = "11:FALSE"
"AssemblyAsmDisplayName" = "8:DisplayMagician.Shared, Version=0.9.5.40335, Culture=neutral, processorArchitecture=MSIL" "AssemblyAsmDisplayName" = "8:DisplayMagician.Shared, Version=0.9.5.36656, Culture=neutral, processorArchitecture=MSIL"
"ScatterAssemblies" "ScatterAssemblies"
{ {
"_CF2B5512697D3444DA5C7C187AE26988" "_CF2B5512697D3444DA5C7C187AE26988"
@ -1892,15 +1892,15 @@
{ {
"Name" = "8:Microsoft Visual Studio" "Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:DisplayMagician" "ProductName" = "8:DisplayMagician"
"ProductCode" = "8:{78BBD2D7-BE5D-4C74-B612-091C756EF26B}" "ProductCode" = "8:{65098CF0-9B4F-4078-9DCA-3EB25C8497B7}"
"PackageCode" = "8:{2712909A-C2E7-4E3C-907A-CEF66D9B7438}" "PackageCode" = "8:{7C3CC1F3-8872-45A6-A688-90E6938B88DC}"
"UpgradeCode" = "8:{48CB9401-ADED-4D62-B779-8317C7D069E1}" "UpgradeCode" = "8:{48CB9401-ADED-4D62-B779-8317C7D069E1}"
"AspNetVersion" = "8:2.0.50727.0" "AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE" "RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:FALSE" "RemovePreviousVersions" = "11:FALSE"
"DetectNewerInstalledVersion" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE" "InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:0.9.0" "ProductVersion" = "8:0.1.0"
"Manufacturer" = "8:Terry MacDonald" "Manufacturer" = "8:Terry MacDonald"
"ARPHELPTELEPHONE" = "8:" "ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:" "ARPHELPLINK" = "8:"

View File

@ -4,6 +4,7 @@
{ {
RunShortcut, RunShortcut,
ChangeProfile, ChangeProfile,
CreateProfile,
StartUpNormally StartUpNormally
} }
} }

View File

@ -15,22 +15,23 @@ using Microsoft.Win32;
namespace DisplayMagician.ShellExtension namespace DisplayMagician.ShellExtension
{ {
[ComVisible(true)] [ComVisible(true)]
[Guid("de271cd7-fa82-439f-b128-202d473bb51e")]
[RegistrationName("DisplayMagician.ShellExtension")]
[COMServerAssociation(AssociationType.DesktopBackground)] [COMServerAssociation(AssociationType.DesktopBackground)]
[Guid("592dcbe6-3052-47bb-b962-101abb5e0ce8")] public class DisplayMagicianDesktopMenuExtension : SharpContextMenu
public class HeliosDesktopMenuExtension : SharpContextMenu
{ {
// Other constants that are useful // Other constants that are useful
internal static Version _version = new Version(1, 0, 0); internal static Version _version = new Version(0, 1, 0);
internal static string AlternateAppHomePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "DisplayMagician"); internal static string AlternateAppHomePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "DisplayMagician");
internal static string AppDataPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "DisplayMagician"); internal static string AppDataPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "DisplayMagician");
private static string AppProfileStoragePath = System.IO.Path.Combine(AppDataPath, $"Profiles"); 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_1.0.json");
internal static string registryDisplayMagician = @"SOFTWARE\DisplayMagician"; internal static string registryDisplayMagician = @"SOFTWARE\DisplayMagician";
string DisplayMagicianFullname = ""; string DisplayMagicianFullname = "";
string DisplayMagicianInstallDir = ""; string DisplayMagicianInstallDir = "";
Process DisplayMagicianProcess = null; Process DisplayMagicianProcess = null;
public HeliosDesktopMenuExtension() public DisplayMagicianDesktopMenuExtension()
{ } { }
protected override bool CanShowMenu() protected override bool CanShowMenu()
@ -70,30 +71,28 @@ namespace DisplayMagician.ShellExtension
//Logging.Log($"Starting CreateMenu"); //Logging.Log($"Starting CreateMenu");
var explorerMenuStrip = new ContextMenuStrip(); var explorerMenuStrip = new ContextMenuStrip();
if (File.Exists(DisplayMagicianFullname))
{
var extensionMenu = new ToolStripMenuItem("DisplayMagician: Change display profiles...", Properties.Resources.DisplayMagicianMenuImage);
explorerMenuStrip.Items.Add(extensionMenu);
Dictionary<string, string> profiles = new Dictionary<string, string>(); Dictionary<string, string> profiles = new Dictionary<string, string>();
if (File.Exists(_profileStorageJsonFileName)) if (File.Exists(_profileStorageJsonFileName))
{ {
//Logging.Log($"{_profileStorageJsonFileName} file exists");
MatchCollection mc; MatchCollection mc;
string uuid = ""; string uuid = "";
string profileName = ""; string profileName = "";
foreach (string aLine in File.ReadLines(_profileStorageJsonFileName, Encoding.Unicode)) foreach (string aLine in File.ReadLines(_profileStorageJsonFileName, Encoding.Unicode))
{ {
//Logging.Log($"Processing line: {_profileStorageJsonFileName}");
string lineToProcess = aLine; string lineToProcess = aLine;
if (lineToProcess.StartsWith(" \"UUID\"")) if (lineToProcess.StartsWith(" \"UUID\""))
{ {
//Logging.Log($"Line starts with 4 spaces and UUID");
mc = Regex.Matches(lineToProcess, " \"UUID\": \"(.*)\""); mc = Regex.Matches(lineToProcess, " \"UUID\": \"(.*)\"");
uuid = mc[0].Groups[1].ToString(); uuid = mc[0].Groups[1].ToString();
} }
else if (lineToProcess.StartsWith(" \"Name\"")) else if (lineToProcess.StartsWith(" \"Name\""))
{ {
//Logging.Log($"Line starts with 4 spaces and Name");
mc = Regex.Matches(lineToProcess, " \"Name\": \"(.*)\""); mc = Regex.Matches(lineToProcess, " \"Name\": \"(.*)\"");
profileName = mc[0].Groups[1].ToString(); profileName = mc[0].Groups[1].ToString();
if (!uuid.Equals("")) if (!uuid.Equals(""))
@ -104,22 +103,35 @@ namespace DisplayMagician.ShellExtension
} }
var extensionMenu = new ToolStripMenuItem("DisplayMagician: Change display profiles...", Properties.Resources.DisplayMagicianMenuImage);
explorerMenuStrip.Items.Add(extensionMenu);
// Add the first menu to create a new Displaay Profile
extensionMenu.DropDownItems.Add(new ToolStripMenuItem("Create a new display profile", null,
(sender, args) =>
{
//Logging.Log(DisplayMagicianFullname + $" CreateProfile");
DisplayMagicianProcess = Process.Start(DisplayMagicianFullname, $"CreateProfile");
//Logging.Log(DisplayMagicianProcess.ToString());
}
));
if (profiles.Count > 0) if (profiles.Count > 0)
{ {
extensionMenu.DropDownItems.Add(new ToolStripSeparator());
foreach (KeyValuePair<string, string> pair in profiles.OrderBy(key => key.Key)) foreach (KeyValuePair<string, string> pair in profiles.OrderBy(key => key.Key))
{ {
extensionMenu.DropDownItems.Add(new ToolStripMenuItem(pair.Key, null, extensionMenu.DropDownItems.Add(new ToolStripMenuItem(pair.Key, null,
(sender, args) => (sender, args) =>
{ {
Logging.Log(DisplayMagicianFullname + $" ChangeProfile \"{pair.Value}\""); //Logging.Log(DisplayMagicianFullname + $" ChangeProfile \"{pair.Value}\"");
DisplayMagicianProcess = Process.Start(DisplayMagicianFullname,$"ChangeProfile \"{pair.Value}\""); DisplayMagicianProcess = Process.Start(DisplayMagicianFullname,$"ChangeProfile \"{pair.Value}\"");
Logging.Log(DisplayMagicianProcess.ToString()); //Logging.Log(DisplayMagicianProcess.ToString());
} }
)); ));
} }
} }
}
return explorerMenuStrip; return explorerMenuStrip;
} }

View File

@ -22,7 +22,7 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM // The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("592dcbe6-3052-47bb-b962-101abb5e0ce8")] [assembly: Guid("592ecbe6-3052-47bb-b962-101abb5e0ce9")]
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //

View File

@ -129,6 +129,32 @@ namespace DisplayMagician {
}); });
}); });
// This is the CreateProfile command
app.Command(DisplayMagicianStartupAction.CreateProfile.ToString(), (createProfileCmd) =>
{
var argumentProfile = runProfileCmd.Argument("\"Profile_UUID\"", "(required) The UUID of the profile to run from those stored in the profile file.").IsRequired();
argumentProfile.Validators.Add(new ProfileMustExistValidator());
//description and help text of the command.
createProfileCmd.Description = "Use this command to go directly to the create display profile screen.";
createProfileCmd.OnExecute(() =>
{
try
{
// Lookup the profile
ProfileItem profileToUse = ProfileRepository.AllProfiles.Where(p => p.UUID.Equals(argumentProfile.Value)).First();
ApplyProfile(profileToUse);
return 0;
}
catch (Exception)
{
return 1;
}
});
});
app.OnExecute(() => app.OnExecute(() =>
{ {

View File

@ -1,16 +1,12 @@
using AudioSwitcher.AudioApi.CoreAudio; using AudioSwitcher.AudioApi.CoreAudio;
using DisplayMagician.GameLibraries; using DisplayMagician.GameLibraries;
using DisplayMagician.InterProcess; using DisplayMagician.InterProcess;
using DisplayMagician.Resources;
using DisplayMagician.Shared; using DisplayMagician.Shared;
using Newtonsoft.Json; using Newtonsoft.Json;
using NvAPIWrapper.Mosaic;
using NvAPIWrapper.Native.Mosaic;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing.IconLib;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;