mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
[WIP] Sort out the ShortcutForm controls
The logic I chose for the ShortcutForm controls is really not suited towards distributed logic. I am going to have to centralise the logic into a single function that will evaulate when to enable the save button.
This commit is contained in:
parent
4412a75bd9
commit
9dab00bdb4
@ -57,6 +57,8 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<StartupObject>HeliosPlus.Program</StartupObject>
|
<StartupObject>HeliosPlus.Program</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup />
|
||||||
|
<PropertyGroup />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
@ -76,7 +78,7 @@
|
|||||||
<Compile Include="GameLibraries\SteamAppInfoParser\PackageInfo.cs" />
|
<Compile Include="GameLibraries\SteamAppInfoParser\PackageInfo.cs" />
|
||||||
<Compile Include="GameLibraries\SteamAppInfoParser\App.cs" />
|
<Compile Include="GameLibraries\SteamAppInfoParser\App.cs" />
|
||||||
<Compile Include="Shortcut.cs" />
|
<Compile Include="Shortcut.cs" />
|
||||||
<Compile Include="UIForms\ProfileAdaptor - Copy.cs" />
|
<Compile Include="UIForms\ShortcutAdaptor.cs" />
|
||||||
<Compile Include="UIForms\ProfileAdaptor.cs" />
|
<Compile Include="UIForms\ProfileAdaptor.cs" />
|
||||||
<Compile Include="UIForms\MainForm.cs">
|
<Compile Include="UIForms\MainForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
@ -226,6 +228,7 @@
|
|||||||
<None Include="Resources\HeliosPlus.ico" />
|
<None Include="Resources\HeliosPlus.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="HeliosPlus.ico" />
|
||||||
<Content Include="Resources\redarrows.png" />
|
<Content Include="Resources\redarrows.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -17,6 +17,7 @@ using HeliosPlus.GameLibraries;
|
|||||||
using HeliosPlus.Shared;
|
using HeliosPlus.Shared;
|
||||||
using HeliosPlus.UIForms;
|
using HeliosPlus.UIForms;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace HeliosPlus {
|
namespace HeliosPlus {
|
||||||
public enum SupportedGameLibrary
|
public enum SupportedGameLibrary
|
||||||
@ -91,46 +92,6 @@ namespace HeliosPlus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CreateShortcutToExecutable(Profile profile, string executableToRun, string processToMonitor, uint timeout, string executableArguments)
|
|
||||||
{
|
|
||||||
|
|
||||||
IPCService.GetInstance().Status = InstanceStatus.User;
|
|
||||||
new ShortcutForm(profile)
|
|
||||||
{
|
|
||||||
ExecutableNameAndPath = executableToRun,
|
|
||||||
ExecutableArguments = executableArguments,
|
|
||||||
ProcessNameToMonitor = processToMonitor,
|
|
||||||
ExecutableTimeout = timeout
|
|
||||||
}.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void CreateShortcutToSteamGame(Profile profile, string steamGameIdToRun, uint timeout, string executableArguments)
|
|
||||||
{
|
|
||||||
|
|
||||||
IPCService.GetInstance().Status = InstanceStatus.User;
|
|
||||||
new ShortcutForm(profile)
|
|
||||||
{
|
|
||||||
GameLibrary = SupportedGameLibrary.Steam,
|
|
||||||
GameAppId = Convert.ToUInt32(steamGameIdToRun),
|
|
||||||
GameTimeout = timeout,
|
|
||||||
GameArguments = executableArguments,
|
|
||||||
}.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void CreateShortcutToUplayGame(Profile profile, string uplayGameIdToRun, uint timeout, string executableArguments)
|
|
||||||
{
|
|
||||||
|
|
||||||
IPCService.GetInstance().Status = InstanceStatus.User;
|
|
||||||
new ShortcutForm(profile)
|
|
||||||
{
|
|
||||||
GameLibrary = SupportedGameLibrary.Uplay,
|
|
||||||
GameAppId = Convert.ToUInt32(uplayGameIdToRun),
|
|
||||||
GameTimeout = timeout,
|
|
||||||
GameArguments = executableArguments,
|
|
||||||
}.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static void EditProfile(Profile profile)
|
private static void EditProfile(Profile profile)
|
||||||
{
|
{
|
||||||
// Get the status of the thing
|
// Get the status of the thing
|
||||||
@ -205,200 +166,25 @@ namespace HeliosPlus {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// This is the SwitchProfile command
|
// This is the SwitchProfile command
|
||||||
app.Command("SwitchProfile", (switchProfileCmd) =>
|
app.Command("RunShortcut", (switchProfileCmd) =>
|
||||||
{
|
{
|
||||||
|
var argumentShortcut = switchProfileCmd.Argument("\"SHORTCUT_NAME\"", "(required) The name 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.
|
//description and help text of the command.
|
||||||
switchProfileCmd.Description = "Use this command to temporarily change profiles, and load your favourite game or application.";
|
switchProfileCmd.Description = "Use this command to temporarily change profiles, and load your favourite game or application.";
|
||||||
|
|
||||||
switchProfileCmd.OnExecute(() =>
|
switchProfileCmd.OnExecute(() =>
|
||||||
{
|
{
|
||||||
switchProfileCmd.ShowHelp();
|
Console.WriteLine($"Editing profile {argumentShortcut.Value}");
|
||||||
return 1;
|
|
||||||
|
SwitchToProfile(GetProfile(argumentShortcut.Value));
|
||||||
|
|
||||||
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
switchProfileCmd.Command("permanent", (switchProfilePermanentSubCmd) =>
|
|
||||||
{
|
|
||||||
switchProfilePermanentSubCmd.Description = "Change to a different display profile permanently (until you manually switch back).";
|
|
||||||
var optionProfile = switchProfilePermanentSubCmd.Option("-p|--profile <PROFILENAME>", "(required) The Profile Name or Profile ID of the display profile to you want to use.", CommandOptionType.SingleValue).IsRequired();
|
|
||||||
optionProfile.Validators.Add(new ProfileMustExistValidator());
|
|
||||||
switchProfilePermanentSubCmd.OnExecute(() =>
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Changing to display profile {optionProfile.Value()}.");
|
|
||||||
|
|
||||||
SwitchToProfile(GetProfile(optionProfile.Value()));
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
switchProfileCmd.Command("exe", (switchProfileExecuteSubCmd) =>
|
|
||||||
{
|
|
||||||
switchProfileExecuteSubCmd.Description = "Temporarily change to a different display profile, run an application or game executable, then change back.";
|
|
||||||
var argumentExecutable = switchProfileExecuteSubCmd.Argument("PATH_TO_EXE", "(required) The game exectuable file to run.").IsRequired();
|
|
||||||
argumentExecutable.Validators.Add(new FileArgumentMustExistValidator());
|
|
||||||
var optionProfile = switchProfileExecuteSubCmd.Option("-p|--profile <PROFILENAME>", "(required) The Profile Name or Profile ID of the display profile to you want to use.", CommandOptionType.SingleValue).IsRequired();
|
|
||||||
optionProfile.Validators.Add(new ProfileMustExistValidator());
|
|
||||||
var optionWaitFor = switchProfileExecuteSubCmd.Option("-w|--waitfor <PROCESSNAME>", "(optional) The application/game to start when we're temporarily switching profile and running the application/game. Also can be used when creating a shortcut. Cannot be used with --steam or --uplay options.", CommandOptionType.SingleValue);
|
|
||||||
optionWaitFor.Validators.Add(new FileOptionMustExistValidator());
|
|
||||||
var optionTimeout = switchProfileExecuteSubCmd.Option<uint>("-t|--timeout", "(optional) The time in seconds we should delay starting the application/game when we're temporarily switching profile and running the application/game.", CommandOptionType.SingleValue);
|
|
||||||
var optionArguments = switchProfileExecuteSubCmd.Option("-a|--arguments", "(optional) Extra arguments to pass to the application/game when we're temporarily switching profile and running the application/game.", CommandOptionType.SingleValue);
|
|
||||||
switchProfileExecuteSubCmd.OnExecute(() =>
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Changing to display profile {optionProfile.Value()}, running executable {argumentExecutable.Value} then reverting back to this display profile when finished.");
|
|
||||||
|
|
||||||
SwitchToExecutable(
|
|
||||||
GetProfile(optionProfile.Value()),
|
|
||||||
//GetProfile(argProfile.Value),
|
|
||||||
argumentExecutable.Value,
|
|
||||||
optionWaitFor.Value(),
|
|
||||||
Convert.ToUInt32(optionTimeout.Value()),
|
|
||||||
optionArguments.Value()
|
|
||||||
);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
switchProfileCmd.Command("steam", (switchProfileSteamSubCmd) =>
|
|
||||||
{
|
|
||||||
switchProfileSteamSubCmd.Description = "Change to a display profile and run a Steam game, then swap back.";
|
|
||||||
var argumentSteam = switchProfileSteamSubCmd.Argument("STEAM_GAME_ID", "(required) The Steam Game ID.").IsRequired();
|
|
||||||
argumentSteam.Validators.Add(new SteamArgumentMustExistValidator());
|
|
||||||
var optionProfile = switchProfileSteamSubCmd.Option("-p|--profile <PROFILENAME>", "(required) The Profile Name or Profile ID of the display profile to you want to use.", CommandOptionType.SingleValue).IsRequired();
|
|
||||||
optionProfile.Validators.Add(new ProfileMustExistValidator());
|
|
||||||
var optionTimeout = switchProfileSteamSubCmd.Option<uint>("-t|--timeout", "(optional) The time in seconds we should delay starting the application/game when we're temporarily switching profile and running the application/game. ", CommandOptionType.SingleValue);
|
|
||||||
var optionArguments = switchProfileSteamSubCmd.Option("-a|--arguments", "(optional) Extra arguments to pass to the application/game when we're temporarily switching profile and running the application/game.", CommandOptionType.SingleValue);
|
|
||||||
switchProfileSteamSubCmd.OnExecute(() =>
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Changing to display profile {optionProfile.Value()}, running Steam Game ID:{argumentSteam.Value} then reverting back to this display profile when finished.");
|
|
||||||
|
|
||||||
SwitchToSteamGame(
|
|
||||||
GetProfile(optionProfile.Value()),
|
|
||||||
//GetProfile(argProfile.Value),
|
|
||||||
argumentSteam.Value,
|
|
||||||
Convert.ToUInt32(optionTimeout.Value()),
|
|
||||||
optionArguments.Value()
|
|
||||||
);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
switchProfileCmd.Command("uplay", (switchProfileUplaySubCmd) =>
|
|
||||||
{
|
|
||||||
switchProfileUplaySubCmd.Description = "Change to a display profile and run a Uplay game.";
|
|
||||||
var argumentUplay = switchProfileUplaySubCmd.Argument("UPLAY_GAME_ID", "(required) The Uplay Game ID to run for when we're temporarily switching profile and running the Uplay application/game.").IsRequired();
|
|
||||||
argumentUplay.Validators.Add(new UplayArgumentMustExistValidator());
|
|
||||||
var optionProfile = switchProfileUplaySubCmd.Option("-p|--profile <PROFILENAME>", "(required) The Profile Name or Profile ID of the display profile to you want to use.", CommandOptionType.SingleValue).IsRequired();
|
|
||||||
optionProfile.Validators.Add(new ProfileMustExistValidator());
|
|
||||||
var optionTimeout = switchProfileUplaySubCmd.Option<uint>("-t|--timeout", "(optional) The time in seconds we should delay starting the application/game when we're temporarily switching profile and running the application/game.", CommandOptionType.SingleValue);
|
|
||||||
var optionArguments = switchProfileUplaySubCmd.Option("-a|--arguments", "(optional) Extra arguments to pass to the application/game when we're temporarily switching profile and running the application/game.", CommandOptionType.SingleValue);
|
|
||||||
switchProfileUplaySubCmd.OnExecute(() =>
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Changing to display profile {optionProfile.Value()}, running Uplay Game ID:{argumentUplay.Value} then reverting back to this display profile when finished.");
|
|
||||||
|
|
||||||
SwitchToUplayGame(
|
|
||||||
GetProfile(optionProfile.Value()),
|
|
||||||
//GetProfile(argProfile.Value),
|
|
||||||
argumentUplay.Value,
|
|
||||||
Convert.ToUInt32(optionTimeout.Value()),
|
|
||||||
optionArguments.Value()
|
|
||||||
);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/*// This is the CreateShortcut command
|
|
||||||
app.Command("CreateShortcut", (createShortcutCmd) =>
|
|
||||||
{
|
|
||||||
//description and help text of the command.
|
|
||||||
createShortcutCmd.Description = "Use this command to create a new shortcut to your favourite game.";
|
|
||||||
//createShortcutCmd.ExtendedHelpText = "Use this command to create a new shortcut to your favourite game.";
|
|
||||||
|
|
||||||
var optionProfile = createShortcutCmd.Option("-p|--profile", "The Profile Name or Profile ID of the profile to you want to use.", CommandOptionType.SingleValue).IsRequired();
|
|
||||||
optionProfile.Validators.Add(new ProfileMustExistValidator());
|
|
||||||
|
|
||||||
createShortcutCmd.OnExecute(() =>
|
|
||||||
{
|
|
||||||
createShortcutCmd.ShowHelp();
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
createShortcutCmd.Command("exe", (createShortcutExecutableSubCmd) =>
|
|
||||||
{
|
|
||||||
createShortcutExecutableSubCmd.Description = "Create a shortcut to run a Game executable.";
|
|
||||||
var argumentExecutable = createShortcutExecutableSubCmd.Argument("executabletorun", "The game exectuable file to run.").IsRequired();
|
|
||||||
argumentExecutable.Validators.Add(new FileArgumentMustExistValidator());
|
|
||||||
var optionWaitFor = createShortcutExecutableSubCmd.Option("-w|--waitfor <PROCESSNAME>", "(optional) The application/game to start when we're temporarily switching profile and running the application/game. Also can be used when creating a shortcut. Cannot be used with --steam or --uplay options.", CommandOptionType.SingleValue);
|
|
||||||
optionWaitFor.Validators.Add(new FileOptionMustExistValidator());
|
|
||||||
var optionTimeout = createShortcutExecutableSubCmd.Option<uint>("-t|--timeout", "(optional) The time in seconds we should delay starting the application/game when we're temporarily switching profile and running the application/game. Also can be used when creating a shortcut.", CommandOptionType.SingleValue);
|
|
||||||
var optionArguments = createShortcutExecutableSubCmd.Option("-a|--arguments", "(optional) Extra arguments to pass to the application/game when we're temporarily switching profile and running the application/game. Also can be used when creating a shortcut.", CommandOptionType.SingleValue);
|
|
||||||
createShortcutExecutableSubCmd.OnExecute(() =>
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Creating a Desktop Shortcut to the application or game {argumentExecutable.Value}");
|
|
||||||
|
|
||||||
CreateShortcutToExecutable(
|
|
||||||
GetProfile(optionProfile.Value()),
|
|
||||||
argumentExecutable.Value,
|
|
||||||
optionWaitFor.Value(),
|
|
||||||
Convert.ToUInt32(optionTimeout.Value()),
|
|
||||||
optionArguments.Value()
|
|
||||||
);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
createShortcutCmd.Command("steam", (createShortcutSteamSubCmd) =>
|
|
||||||
{
|
|
||||||
createShortcutSteamSubCmd.Description = "Create a Steam Game shortcut.";
|
|
||||||
var argumentSteam = createShortcutSteamSubCmd.Argument("steamgameid", "The Steam Game ID.").IsRequired();
|
|
||||||
argumentSteam.Validators.Add(new SteamArgumentMustExistValidator());
|
|
||||||
var optionTimeout = createShortcutSteamSubCmd.Option<uint>("-t|--timeout", "(optional) The time in seconds we should delay starting the application/game when we're temporarily switching profile and running the application/game. Also can be used when creating a shortcut.", CommandOptionType.SingleValue);
|
|
||||||
var optionArguments = createShortcutSteamSubCmd.Option("-a|--arguments", "(optional) Extra arguments to pass to the application/game when we're temporarily switching profile and running the application/game. Also can be used when creating a shortcut.", CommandOptionType.SingleValue);
|
|
||||||
createShortcutSteamSubCmd.OnExecute(() =>
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Creating a Desktop Shortcut to the Steam Game {argumentSteam.Value}");
|
|
||||||
|
|
||||||
CreateShortcutToSteamGame(
|
|
||||||
GetProfile(optionProfile.Value()),
|
|
||||||
argumentSteam.Value,
|
|
||||||
Convert.ToUInt32(optionTimeout.Value()),
|
|
||||||
optionArguments.Value()
|
|
||||||
);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
createShortcutCmd.Command("uplay", (createShortcutUplaySubCmd) =>
|
|
||||||
{
|
|
||||||
createShortcutUplaySubCmd.Description = "Create a Uplay Game shortcut.";
|
|
||||||
var argumentUplay = createShortcutUplaySubCmd.Argument("uplaygameid", "The Uplay Game ID to run for when we're temporarily switching profile and running the Uplay application/game.").IsRequired();
|
|
||||||
argumentUplay.Validators.Add(new UplayArgumentMustExistValidator());
|
|
||||||
var optionTimeout = createShortcutUplaySubCmd.Option<uint>("-t|--timeout", "(optional) The time in seconds we should delay starting the application/game when we're temporarily switching profile and running the application/game. Also can be used when creating a shortcut.", CommandOptionType.SingleValue);
|
|
||||||
var optionArguments = createShortcutUplaySubCmd.Option("-a|--arguments", "(optional) Extra arguments to pass to the application/game when we're temporarily switching profile and running the application/game. Also can be used when creating a shortcut.", CommandOptionType.SingleValue);
|
|
||||||
createShortcutUplaySubCmd.OnExecute(() =>
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Creating a Desktop Shortcut to the Uplay Game {argumentUplay.Value}");
|
|
||||||
|
|
||||||
CreateShortcutToUplayGame(
|
|
||||||
GetProfile(optionProfile.Value()),
|
|
||||||
argumentUplay.Value,
|
|
||||||
Convert.ToUInt32(optionTimeout.Value()),
|
|
||||||
optionArguments.Value()
|
|
||||||
);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});*/
|
|
||||||
|
|
||||||
// This is the EditProfile command
|
// This is the EditProfile command
|
||||||
app.Command("EditProfile", (editProfileCmd) =>
|
app.Command("EditProfile", (editProfileCmd) =>
|
||||||
{
|
{
|
||||||
@ -876,5 +662,25 @@ namespace HeliosPlus {
|
|||||||
throw new Exception(Language.Can_not_change_active_profile);
|
throw new Exception(Language.Can_not_change_active_profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsValidFilename(string testName)
|
||||||
|
{
|
||||||
|
string strTheseAreInvalidFileNameChars = new string(Path.GetInvalidFileNameChars());
|
||||||
|
Regex regInvalidFileName = new Regex("[" + Regex.Escape(strTheseAreInvalidFileNameChars) + "]");
|
||||||
|
|
||||||
|
if (regInvalidFileName.IsMatch(testName)) { return false; };
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetValidFilename(string uncheckedFilename)
|
||||||
|
{
|
||||||
|
string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
|
||||||
|
foreach (char c in invalid)
|
||||||
|
{
|
||||||
|
uncheckedFilename = uncheckedFilename.Replace(c.ToString(), "");
|
||||||
|
}
|
||||||
|
return uncheckedFilename;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using HeliosPlus.GameLibraries;
|
using HeliosPlus.GameLibraries;
|
||||||
|
using HeliosPlus.Resources;
|
||||||
using HeliosPlus.Shared;
|
using HeliosPlus.Shared;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
@ -9,19 +10,38 @@ using System.Drawing.Imaging;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.ServiceModel.Dispatcher;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace HeliosPlus
|
namespace HeliosPlus
|
||||||
{
|
{
|
||||||
class Shortcut
|
public enum ShortcutPermanence
|
||||||
|
{
|
||||||
|
Permanent,
|
||||||
|
Temporary,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ShortcutCategory
|
||||||
|
{
|
||||||
|
Application,
|
||||||
|
Game,
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Shortcut
|
||||||
{
|
{
|
||||||
|
|
||||||
private static List<Shortcut> _allSavedShortcuts = new List<Shortcut>();
|
private static List<Shortcut> _allSavedShortcuts = new List<Shortcut>();
|
||||||
private MultiIcon _shortcutIcon, _originalIcon = null;
|
private MultiIcon _shortcutIcon, _originalIcon = null;
|
||||||
private Bitmap _shortcutBitmap, _originalBitmap = null;
|
private Bitmap _shortcutBitmap, _originalBitmap = null;
|
||||||
|
|
||||||
public Shortcut( Profile profile)
|
public Shortcut()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shortcut(Profile profile) : this()
|
||||||
{
|
{
|
||||||
ProfileToUse = profile;
|
ProfileToUse = profile;
|
||||||
}
|
}
|
||||||
@ -30,8 +50,23 @@ namespace HeliosPlus
|
|||||||
|
|
||||||
public string Name { get; set; } = "Current Display Profile";
|
public string Name { get; set; } = "Current Display Profile";
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public Profile ProfileToUse { get; set; } = null;
|
public Profile ProfileToUse { get; set; } = null;
|
||||||
|
|
||||||
|
public string ProfileName {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ProfileToUse is Profile)
|
||||||
|
return ProfileToUse.Name;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShortcutPermanence Permanence { get; set; } = ShortcutPermanence.Temporary;
|
||||||
|
|
||||||
|
public ShortcutCategory Category { get; set; } = ShortcutCategory.Game;
|
||||||
|
|
||||||
public string ProcessNameToMonitor { get; set; } = "";
|
public string ProcessNameToMonitor { get; set; } = "";
|
||||||
|
|
||||||
public string ExecutableNameAndPath { get; set; } = "";
|
public string ExecutableNameAndPath { get; set; } = "";
|
||||||
@ -40,6 +75,10 @@ namespace HeliosPlus
|
|||||||
|
|
||||||
public string ExecutableArguments { get; set; } = "";
|
public string ExecutableArguments { get; set; } = "";
|
||||||
|
|
||||||
|
public bool ExecutableArgumentsRequired { get; set; } = false;
|
||||||
|
|
||||||
|
public bool ProcessNameToMonitorUsesExecutable { get; set; } = true;
|
||||||
|
|
||||||
public uint GameAppId { get; set; } = 0;
|
public uint GameAppId { get; set; } = 0;
|
||||||
|
|
||||||
public string GameName { get; set; } = "";
|
public string GameName { get; set; } = "";
|
||||||
@ -50,6 +89,8 @@ namespace HeliosPlus
|
|||||||
|
|
||||||
public string GameArguments { get; set; } = "";
|
public string GameArguments { get; set; } = "";
|
||||||
|
|
||||||
|
public bool GameArgumentsRequired { get; set; } = false;
|
||||||
|
|
||||||
public string OriginalIconPath { get; set; } = "";
|
public string OriginalIconPath { get; set; } = "";
|
||||||
|
|
||||||
[JsonConverter(typeof(CustomBitmapConverter))]
|
[JsonConverter(typeof(CustomBitmapConverter))]
|
||||||
@ -101,11 +142,13 @@ namespace HeliosPlus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public static string SavedShortcutsFilePath
|
public static string SavedShortcutsFilePath
|
||||||
{
|
{
|
||||||
get => Path.Combine(Program.AppDataPath, $"Shortcuts\\Shortcuts_{Version.ToString(2)}.json");
|
get => Path.Combine(Program.AppDataPath, $"Shortcuts\\Shortcuts_{Version.ToString(2)}.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public static string SavedShortcutsPath
|
public static string SavedShortcutsPath
|
||||||
{
|
{
|
||||||
get => Path.Combine(Program.AppDataPath, $"Shortcuts");
|
get => Path.Combine(Program.AppDataPath, $"Shortcuts");
|
||||||
@ -113,6 +156,7 @@ namespace HeliosPlus
|
|||||||
|
|
||||||
public string SavedShortcutIconCacheFilename { get; set; }
|
public string SavedShortcutIconCacheFilename { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public static List<Shortcut> AllSavedShortcuts
|
public static List<Shortcut> AllSavedShortcuts
|
||||||
{
|
{
|
||||||
@ -122,13 +166,8 @@ namespace HeliosPlus
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public bool IsPossible
|
public bool IsPossible
|
||||||
{
|
{
|
||||||
get
|
get;
|
||||||
{
|
set;
|
||||||
if (ProfileToUse != null)
|
|
||||||
return ProfileToUse.IsPossible;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap ExtractVistaIcon(Icon icoIcon)
|
public static Bitmap ExtractVistaIcon(Icon icoIcon)
|
||||||
@ -168,8 +207,43 @@ namespace HeliosPlus
|
|||||||
{
|
{
|
||||||
if (_shortcutIcon == null)
|
if (_shortcutIcon == null)
|
||||||
{
|
{
|
||||||
// Work out the name of the shortcut we'll save.
|
// Only add the rest of the options if the permanence is temporary
|
||||||
SavedShortcutIconCacheFilename = Path.Combine(Program.ShortcutIconCachePath, String.Concat(GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), @".ico"));
|
if (Permanence == ShortcutPermanence.Temporary)
|
||||||
|
{
|
||||||
|
// Only add this set of options if the shortcut is to an standalone application
|
||||||
|
if (Category == ShortcutCategory.Application)
|
||||||
|
{
|
||||||
|
// Work out the name of the shortcut we'll save.
|
||||||
|
SavedShortcutIconCacheFilename = Path.Combine(Program.ShortcutIconCachePath, String.Concat(@"executable-", Program.GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), "-", Path.GetFileNameWithoutExtension(ExecutableNameAndPath), @".ico"));
|
||||||
|
|
||||||
|
}
|
||||||
|
// Only add the rest of the options if the temporary switch radio button is set
|
||||||
|
// and if the game launching radio button is set
|
||||||
|
else if (Permanence == ShortcutPermanence.Temporary)
|
||||||
|
{
|
||||||
|
// TODO need to make this work so at least one game library is installed
|
||||||
|
// i.e. if (!SteamGame.SteamInstalled && !UplayGame.UplayInstalled )
|
||||||
|
if (GameLibrary == SupportedGameLibrary.Steam)
|
||||||
|
{
|
||||||
|
// Work out the name of the shortcut we'll save.
|
||||||
|
SavedShortcutIconCacheFilename = Path.Combine(Program.ShortcutIconCachePath, String.Concat(@"steam-", Program.GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), "-", GameAppId.ToString(), @".ico"));
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (GameLibrary == SupportedGameLibrary.Uplay)
|
||||||
|
{
|
||||||
|
// Work out the name of the shortcut we'll save.
|
||||||
|
SavedShortcutIconCacheFilename = Path.Combine(Program.ShortcutIconCachePath, String.Concat(@"uplay-", Program.GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), "-", GameAppId.ToString(), @".ico"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// Only add the rest of the options if the shortcut is permanent
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Work out the name of the shortcut we'll save.
|
||||||
|
SavedShortcutIconCacheFilename = Path.Combine(Program.ShortcutIconCachePath, String.Concat(@"permanent-", Program.GetValidFilename(Name).ToLower(CultureInfo.InvariantCulture), @".ico"));
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -212,6 +286,20 @@ namespace HeliosPlus
|
|||||||
Console.WriteLine("Unable to deserialize shortcut: " + ex.Message);
|
Console.WriteLine("Unable to deserialize shortcut: " + ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lookup all the Profile Names in the Saved Profiles
|
||||||
|
List<Profile> allProfiles = Profile.AllSavedProfiles;
|
||||||
|
foreach (Shortcut updatedShortcut in shortcuts)
|
||||||
|
{
|
||||||
|
IEnumerable<Profile> matchingProfile = (from profile in allProfiles where profile.Name == updatedShortcut.ProfileName select profile);
|
||||||
|
if (matchingProfile.Count() > 0)
|
||||||
|
{
|
||||||
|
updatedShortcut.ProfileToUse = matchingProfile.First();
|
||||||
|
updatedShortcut.IsPossible = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
updatedShortcut.IsPossible = false;
|
||||||
|
}
|
||||||
|
|
||||||
_allSavedShortcuts = shortcuts;
|
_allSavedShortcuts = shortcuts;
|
||||||
|
|
||||||
return _allSavedShortcuts;
|
return _allSavedShortcuts;
|
||||||
@ -288,16 +376,106 @@ namespace HeliosPlus
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReSharper disable once FunctionComplexityOverflow
|
||||||
private static string GetValidFilename(string uncheckedFilename)
|
// ReSharper disable once CyclomaticComplexity
|
||||||
|
public bool CreateShortcut(string shortcutFileName)
|
||||||
{
|
{
|
||||||
string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
|
string programName = Path.GetFileNameWithoutExtension(ExecutableNameAndPath);
|
||||||
foreach (char c in invalid)
|
string shortcutDescription = string.Empty;
|
||||||
|
string shortcutIconFileName = string.Empty;
|
||||||
|
|
||||||
|
var shortcutArgs = new List<string>
|
||||||
{
|
{
|
||||||
uncheckedFilename = uncheckedFilename.Replace(c.ToString(), "");
|
// Add the SwitchProfile command as the first argument to start to switch to another profile
|
||||||
|
$"{HeliosStartupAction.SwitchProfile}",
|
||||||
|
$"\"{Name}\""
|
||||||
|
};
|
||||||
|
|
||||||
|
// Only add the rest of the options if the permanence is temporary
|
||||||
|
if (Permanence == ShortcutPermanence.Temporary)
|
||||||
|
{
|
||||||
|
// Only add this set of options if the shortcut is to an standalone application
|
||||||
|
if (Category == ShortcutCategory.Application)
|
||||||
|
{
|
||||||
|
// Prepare text for the shortcut description field
|
||||||
|
shortcutDescription = string.Format(Language.Executing_application_with_profile, programName, Name);
|
||||||
|
|
||||||
|
}
|
||||||
|
// Only add the rest of the options if the temporary switch radio button is set
|
||||||
|
// and if the game launching radio button is set
|
||||||
|
else if (Permanence == ShortcutPermanence.Temporary)
|
||||||
|
{
|
||||||
|
// Prepare text for the shortcut description field
|
||||||
|
shortcutDescription = string.Format(Language.Executing_application_with_profile, GameName, Name);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return uncheckedFilename;
|
// Only add the rest of the options if the permanent switch radio button is set
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Prepare text for the shortcut description field
|
||||||
|
shortcutDescription = string.Format(Language.Switching_display_profile_to_profile, Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we are ready to create a shortcut based on the filename the user gave us
|
||||||
|
shortcutFileName = Path.ChangeExtension(shortcutFileName, @"lnk");
|
||||||
|
|
||||||
|
// If the user supplied a file
|
||||||
|
if (shortcutFileName != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Remove the old file to replace it
|
||||||
|
if (File.Exists(shortcutFileName))
|
||||||
|
{
|
||||||
|
File.Delete(shortcutFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actually create the shortcut!
|
||||||
|
var wshShellType = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8"));
|
||||||
|
dynamic wshShell = Activator.CreateInstance(wshShellType);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var shortcut = wshShell.CreateShortcut(shortcutFileName);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
shortcut.TargetPath = Application.ExecutablePath;
|
||||||
|
shortcut.Arguments = string.Join(" ", shortcutArgs);
|
||||||
|
shortcut.Description = shortcutDescription;
|
||||||
|
shortcut.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath) ??
|
||||||
|
string.Empty;
|
||||||
|
|
||||||
|
shortcut.IconLocation = shortcutIconFileName;
|
||||||
|
|
||||||
|
shortcut.Save();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Marshal.FinalReleaseComObject(shortcut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Marshal.FinalReleaseComObject(wshShell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Clean up a failed attempt
|
||||||
|
if (File.Exists(shortcutFileName))
|
||||||
|
{
|
||||||
|
File.Delete(shortcutFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return a status on how it went
|
||||||
|
// true if it was a success or false if it was not
|
||||||
|
return shortcutFileName != null && File.Exists(shortcutFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region JsonConverterBitmap
|
#region JsonConverterBitmap
|
||||||
|
@ -74,6 +74,7 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
private void Exit_Click(object sender, EventArgs e)
|
private void Exit_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,21 +293,11 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsValidFilename(string testName)
|
|
||||||
{
|
|
||||||
string strTheseAreInvalidFileNameChars = new string(Path.GetInvalidFileNameChars());
|
|
||||||
Regex regInvalidFileName = new Regex("[" + Regex.Escape(strTheseAreInvalidFileNameChars) + "]");
|
|
||||||
|
|
||||||
if (regInvalidFileName.IsMatch(testName)) { return false; };
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btn_save_as_Click(object sender, EventArgs e)
|
private void btn_save_as_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Check the name is valid
|
// Check the name is valid
|
||||||
if (!IsValidFilename(txt_profile_save_name.Text))
|
if (!Program.IsValidFilename(txt_profile_save_name.Text))
|
||||||
{
|
{
|
||||||
MessageBox.Show("The profile name cannot contain the following characters:" + Path.GetInvalidFileNameChars(), "Invalid characters in profile name", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("The profile name cannot contain the following characters:" + Path.GetInvalidFileNameChars(), "Invalid characters in profile name", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
|
||||||
|
19
HeliosPlus/UIForms/MainForm.Designer.cs
generated
19
HeliosPlus/UIForms/MainForm.Designer.cs
generated
@ -32,10 +32,10 @@
|
|||||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||||
this.btn_setup_display_profiles = new System.Windows.Forms.Button();
|
this.btn_setup_display_profiles = new System.Windows.Forms.Button();
|
||||||
this.pb_display_profile = new System.Windows.Forms.PictureBox();
|
this.pb_display_profile = new System.Windows.Forms.PictureBox();
|
||||||
|
this.lbl_version = new System.Windows.Forms.Label();
|
||||||
this.btn_setup_game_shortcuts = new System.Windows.Forms.Button();
|
this.btn_setup_game_shortcuts = new System.Windows.Forms.Button();
|
||||||
this.btn_exit = new System.Windows.Forms.Button();
|
this.btn_exit = new System.Windows.Forms.Button();
|
||||||
this.pb_game_shortcut = new System.Windows.Forms.PictureBox();
|
this.pb_game_shortcut = new System.Windows.Forms.PictureBox();
|
||||||
this.lbl_version = new System.Windows.Forms.Label();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||||
this.splitContainer1.Panel1.SuspendLayout();
|
this.splitContainer1.Panel1.SuspendLayout();
|
||||||
this.splitContainer1.Panel2.SuspendLayout();
|
this.splitContainer1.Panel2.SuspendLayout();
|
||||||
@ -80,6 +80,14 @@
|
|||||||
this.pb_display_profile.TabStop = false;
|
this.pb_display_profile.TabStop = false;
|
||||||
this.pb_display_profile.Click += new System.EventHandler(this.pb_display_profile_Click);
|
this.pb_display_profile.Click += new System.EventHandler(this.pb_display_profile_Click);
|
||||||
//
|
//
|
||||||
|
// lbl_version
|
||||||
|
//
|
||||||
|
resources.ApplyResources(this.lbl_version, "lbl_version");
|
||||||
|
this.lbl_version.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
this.lbl_version.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.lbl_version.ForeColor = System.Drawing.Color.White;
|
||||||
|
this.lbl_version.Name = "lbl_version";
|
||||||
|
//
|
||||||
// btn_setup_game_shortcuts
|
// btn_setup_game_shortcuts
|
||||||
//
|
//
|
||||||
resources.ApplyResources(this.btn_setup_game_shortcuts, "btn_setup_game_shortcuts");
|
resources.ApplyResources(this.btn_setup_game_shortcuts, "btn_setup_game_shortcuts");
|
||||||
@ -107,14 +115,6 @@
|
|||||||
this.pb_game_shortcut.TabStop = false;
|
this.pb_game_shortcut.TabStop = false;
|
||||||
this.pb_game_shortcut.Click += new System.EventHandler(this.pb_game_shortcut_Click);
|
this.pb_game_shortcut.Click += new System.EventHandler(this.pb_game_shortcut_Click);
|
||||||
//
|
//
|
||||||
// lbl_version
|
|
||||||
//
|
|
||||||
resources.ApplyResources(this.lbl_version, "lbl_version");
|
|
||||||
this.lbl_version.BackColor = System.Drawing.Color.Transparent;
|
|
||||||
this.lbl_version.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
|
||||||
this.lbl_version.ForeColor = System.Drawing.Color.White;
|
|
||||||
this.lbl_version.Name = "lbl_version";
|
|
||||||
//
|
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
resources.ApplyResources(this, "$this");
|
resources.ApplyResources(this, "$this");
|
||||||
@ -122,7 +122,6 @@
|
|||||||
this.Controls.Add(this.splitContainer1);
|
this.Controls.Add(this.splitContainer1);
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.Name = "MainForm";
|
this.Name = "MainForm";
|
||||||
this.ShowIcon = false;
|
|
||||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||||
this.Load += new System.EventHandler(this.MainForm_Load);
|
this.Load += new System.EventHandler(this.MainForm_Load);
|
||||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||||
|
@ -10768,7 +10768,7 @@
|
|||||||
<value>Microsoft Sans Serif, 21.75pt</value>
|
<value>Microsoft Sans Serif, 21.75pt</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="btn_setup_game_shortcuts.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="btn_setup_game_shortcuts.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>212, 176</value>
|
<value>212, 178</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="btn_setup_game_shortcuts.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="btn_setup_game_shortcuts.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>360, 50</value>
|
<value>360, 50</value>
|
||||||
@ -10798,7 +10798,7 @@
|
|||||||
<value>Flat</value>
|
<value>Flat</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="btn_exit.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="btn_exit.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>697, 345</value>
|
<value>697, 348</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="btn_exit.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="btn_exit.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>75, 23</value>
|
<value>75, 23</value>
|
||||||
|
90
HeliosPlus/UIForms/ShortcutForm.Designer.cs
generated
90
HeliosPlus/UIForms/ShortcutForm.Designer.cs
generated
@ -68,7 +68,6 @@ namespace HeliosPlus.UIForms
|
|||||||
this.nud_timeout_executable = new System.Windows.Forms.NumericUpDown();
|
this.nud_timeout_executable = new System.Windows.Forms.NumericUpDown();
|
||||||
this.rb_launcher = new System.Windows.Forms.RadioButton();
|
this.rb_launcher = new System.Windows.Forms.RadioButton();
|
||||||
this.rb_standalone = new System.Windows.Forms.RadioButton();
|
this.rb_standalone = new System.Windows.Forms.RadioButton();
|
||||||
this.dv_profile = new HeliosPlus.Shared.UserControls.DisplayView();
|
|
||||||
this.dialog_open = new System.Windows.Forms.OpenFileDialog();
|
this.dialog_open = new System.Windows.Forms.OpenFileDialog();
|
||||||
this.dialog_save = new System.Windows.Forms.SaveFileDialog();
|
this.dialog_save = new System.Windows.Forms.SaveFileDialog();
|
||||||
this.rb_switch_perm = new System.Windows.Forms.RadioButton();
|
this.rb_switch_perm = new System.Windows.Forms.RadioButton();
|
||||||
@ -77,6 +76,9 @@ namespace HeliosPlus.UIForms
|
|||||||
this.ilv_saved_profiles = new Manina.Windows.Forms.ImageListView();
|
this.ilv_saved_profiles = new Manina.Windows.Forms.ImageListView();
|
||||||
this.lbl_profile_shown_subtitle = new System.Windows.Forms.Label();
|
this.lbl_profile_shown_subtitle = new System.Windows.Forms.Label();
|
||||||
this.lbl_profile_shown = new System.Windows.Forms.Label();
|
this.lbl_profile_shown = new System.Windows.Forms.Label();
|
||||||
|
this.txt_shortcut_save_name = new System.Windows.Forms.TextBox();
|
||||||
|
this.btn_save_or_rename = new System.Windows.Forms.Button();
|
||||||
|
this.dv_profile = new HeliosPlus.Shared.UserControls.DisplayView();
|
||||||
this.g_temporary.SuspendLayout();
|
this.g_temporary.SuspendLayout();
|
||||||
this.p_game.SuspendLayout();
|
this.p_game.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nud_timeout_game)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.nud_timeout_game)).BeginInit();
|
||||||
@ -90,13 +92,15 @@ namespace HeliosPlus.UIForms
|
|||||||
this.btn_save.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
|
this.btn_save.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
|
||||||
this.btn_save.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
|
this.btn_save.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
|
||||||
this.btn_save.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
this.btn_save.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.btn_save.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.btn_save.ForeColor = System.Drawing.Color.White;
|
this.btn_save.ForeColor = System.Drawing.Color.White;
|
||||||
this.btn_save.Location = new System.Drawing.Point(602, 985);
|
this.btn_save.Location = new System.Drawing.Point(743, 689);
|
||||||
this.btn_save.Name = "btn_save";
|
this.btn_save.Name = "btn_save";
|
||||||
this.btn_save.Size = new System.Drawing.Size(94, 25);
|
this.btn_save.Size = new System.Drawing.Size(120, 40);
|
||||||
this.btn_save.TabIndex = 6;
|
this.btn_save.TabIndex = 6;
|
||||||
this.btn_save.Text = "&Create Shortcut";
|
this.btn_save.Text = "&Create Shortcut";
|
||||||
this.btn_save.UseVisualStyleBackColor = true;
|
this.btn_save.UseVisualStyleBackColor = true;
|
||||||
|
this.btn_save.Visible = false;
|
||||||
this.btn_save.Click += new System.EventHandler(this.btn_save_Click);
|
this.btn_save.Click += new System.EventHandler(this.btn_save_Click);
|
||||||
//
|
//
|
||||||
// btn_cancel
|
// btn_cancel
|
||||||
@ -106,7 +110,7 @@ namespace HeliosPlus.UIForms
|
|||||||
this.btn_cancel.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
|
this.btn_cancel.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
|
||||||
this.btn_cancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
this.btn_cancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
this.btn_cancel.ForeColor = System.Drawing.Color.White;
|
this.btn_cancel.ForeColor = System.Drawing.Color.White;
|
||||||
this.btn_cancel.Location = new System.Drawing.Point(869, 984);
|
this.btn_cancel.Location = new System.Drawing.Point(1498, 725);
|
||||||
this.btn_cancel.Name = "btn_cancel";
|
this.btn_cancel.Name = "btn_cancel";
|
||||||
this.btn_cancel.Size = new System.Drawing.Size(94, 25);
|
this.btn_cancel.Size = new System.Drawing.Size(94, 25);
|
||||||
this.btn_cancel.TabIndex = 5;
|
this.btn_cancel.TabIndex = 5;
|
||||||
@ -120,9 +124,9 @@ namespace HeliosPlus.UIForms
|
|||||||
this.g_temporary.Controls.Add(this.p_standalone);
|
this.g_temporary.Controls.Add(this.p_standalone);
|
||||||
this.g_temporary.Controls.Add(this.rb_launcher);
|
this.g_temporary.Controls.Add(this.rb_launcher);
|
||||||
this.g_temporary.Controls.Add(this.rb_standalone);
|
this.g_temporary.Controls.Add(this.rb_standalone);
|
||||||
this.g_temporary.Location = new System.Drawing.Point(12, 514);
|
this.g_temporary.Location = new System.Drawing.Point(812, 137);
|
||||||
this.g_temporary.Name = "g_temporary";
|
this.g_temporary.Name = "g_temporary";
|
||||||
this.g_temporary.Size = new System.Drawing.Size(1161, 467);
|
this.g_temporary.Size = new System.Drawing.Size(780, 467);
|
||||||
this.g_temporary.TabIndex = 4;
|
this.g_temporary.TabIndex = 4;
|
||||||
this.g_temporary.TabStop = false;
|
this.g_temporary.TabStop = false;
|
||||||
this.g_temporary.Text = "Application or Game Information";
|
this.g_temporary.Text = "Application or Game Information";
|
||||||
@ -500,23 +504,6 @@ namespace HeliosPlus.UIForms
|
|||||||
this.rb_standalone.CheckedChanged += new System.EventHandler(this.rb_standalone_CheckedChanged);
|
this.rb_standalone.CheckedChanged += new System.EventHandler(this.rb_standalone_CheckedChanged);
|
||||||
this.rb_standalone.Paint += new System.Windows.Forms.PaintEventHandler(this.radiobutton_Paint);
|
this.rb_standalone.Paint += new System.Windows.Forms.PaintEventHandler(this.radiobutton_Paint);
|
||||||
//
|
//
|
||||||
// dv_profile
|
|
||||||
//
|
|
||||||
this.dv_profile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.dv_profile.BackColor = System.Drawing.Color.DimGray;
|
|
||||||
this.dv_profile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
|
||||||
this.dv_profile.Font = new System.Drawing.Font("Consolas", 50F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
|
||||||
this.dv_profile.ForeColor = System.Drawing.Color.MidnightBlue;
|
|
||||||
this.dv_profile.Location = new System.Drawing.Point(0, -1);
|
|
||||||
this.dv_profile.Margin = new System.Windows.Forms.Padding(18);
|
|
||||||
this.dv_profile.Name = "dv_profile";
|
|
||||||
this.dv_profile.PaddingX = 100;
|
|
||||||
this.dv_profile.PaddingY = 100;
|
|
||||||
this.dv_profile.Profile = null;
|
|
||||||
this.dv_profile.Size = new System.Drawing.Size(975, 311);
|
|
||||||
this.dv_profile.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// dialog_open
|
// dialog_open
|
||||||
//
|
//
|
||||||
this.dialog_open.DefaultExt = "exe";
|
this.dialog_open.DefaultExt = "exe";
|
||||||
@ -536,7 +523,7 @@ namespace HeliosPlus.UIForms
|
|||||||
//
|
//
|
||||||
this.rb_switch_perm.AutoSize = true;
|
this.rb_switch_perm.AutoSize = true;
|
||||||
this.rb_switch_perm.ForeColor = System.Drawing.Color.White;
|
this.rb_switch_perm.ForeColor = System.Drawing.Color.White;
|
||||||
this.rb_switch_perm.Location = new System.Drawing.Point(16, 456);
|
this.rb_switch_perm.Location = new System.Drawing.Point(815, 75);
|
||||||
this.rb_switch_perm.Name = "rb_switch_perm";
|
this.rb_switch_perm.Name = "rb_switch_perm";
|
||||||
this.rb_switch_perm.Size = new System.Drawing.Size(216, 17);
|
this.rb_switch_perm.Size = new System.Drawing.Size(216, 17);
|
||||||
this.rb_switch_perm.TabIndex = 7;
|
this.rb_switch_perm.TabIndex = 7;
|
||||||
@ -550,7 +537,7 @@ namespace HeliosPlus.UIForms
|
|||||||
this.rb_switch_temp.AutoSize = true;
|
this.rb_switch_temp.AutoSize = true;
|
||||||
this.rb_switch_temp.Checked = true;
|
this.rb_switch_temp.Checked = true;
|
||||||
this.rb_switch_temp.ForeColor = System.Drawing.Color.White;
|
this.rb_switch_temp.ForeColor = System.Drawing.Color.White;
|
||||||
this.rb_switch_temp.Location = new System.Drawing.Point(16, 479);
|
this.rb_switch_temp.Location = new System.Drawing.Point(815, 98);
|
||||||
this.rb_switch_temp.Name = "rb_switch_temp";
|
this.rb_switch_temp.Name = "rb_switch_temp";
|
||||||
this.rb_switch_temp.Size = new System.Drawing.Size(381, 17);
|
this.rb_switch_temp.Size = new System.Drawing.Size(381, 17);
|
||||||
this.rb_switch_temp.TabIndex = 8;
|
this.rb_switch_temp.TabIndex = 8;
|
||||||
@ -572,12 +559,12 @@ namespace HeliosPlus.UIForms
|
|||||||
this.ilv_saved_profiles.AllowColumnResize = false;
|
this.ilv_saved_profiles.AllowColumnResize = false;
|
||||||
this.ilv_saved_profiles.AllowItemReorder = false;
|
this.ilv_saved_profiles.AllowItemReorder = false;
|
||||||
this.ilv_saved_profiles.AllowPaneResize = false;
|
this.ilv_saved_profiles.AllowPaneResize = false;
|
||||||
this.ilv_saved_profiles.Location = new System.Drawing.Point(1, 322);
|
this.ilv_saved_profiles.Location = new System.Drawing.Point(1, 476);
|
||||||
this.ilv_saved_profiles.MultiSelect = false;
|
this.ilv_saved_profiles.MultiSelect = false;
|
||||||
this.ilv_saved_profiles.Name = "ilv_saved_profiles";
|
this.ilv_saved_profiles.Name = "ilv_saved_profiles";
|
||||||
this.ilv_saved_profiles.PersistentCacheDirectory = "";
|
this.ilv_saved_profiles.PersistentCacheDirectory = "";
|
||||||
this.ilv_saved_profiles.PersistentCacheSize = ((long)(100));
|
this.ilv_saved_profiles.PersistentCacheSize = ((long)(100));
|
||||||
this.ilv_saved_profiles.Size = new System.Drawing.Size(974, 128);
|
this.ilv_saved_profiles.Size = new System.Drawing.Size(799, 128);
|
||||||
this.ilv_saved_profiles.TabIndex = 22;
|
this.ilv_saved_profiles.TabIndex = 22;
|
||||||
this.ilv_saved_profiles.UseWIC = true;
|
this.ilv_saved_profiles.UseWIC = true;
|
||||||
this.ilv_saved_profiles.View = Manina.Windows.Forms.View.HorizontalStrip;
|
this.ilv_saved_profiles.View = Manina.Windows.Forms.View.HorizontalStrip;
|
||||||
@ -589,7 +576,7 @@ namespace HeliosPlus.UIForms
|
|||||||
this.lbl_profile_shown_subtitle.BackColor = System.Drawing.Color.DimGray;
|
this.lbl_profile_shown_subtitle.BackColor = System.Drawing.Color.DimGray;
|
||||||
this.lbl_profile_shown_subtitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.lbl_profile_shown_subtitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.lbl_profile_shown_subtitle.ForeColor = System.Drawing.Color.White;
|
this.lbl_profile_shown_subtitle.ForeColor = System.Drawing.Color.White;
|
||||||
this.lbl_profile_shown_subtitle.Location = new System.Drawing.Point(12, 42);
|
this.lbl_profile_shown_subtitle.Location = new System.Drawing.Point(12, 104);
|
||||||
this.lbl_profile_shown_subtitle.Name = "lbl_profile_shown_subtitle";
|
this.lbl_profile_shown_subtitle.Name = "lbl_profile_shown_subtitle";
|
||||||
this.lbl_profile_shown_subtitle.Size = new System.Drawing.Size(132, 20);
|
this.lbl_profile_shown_subtitle.Size = new System.Drawing.Size(132, 20);
|
||||||
this.lbl_profile_shown_subtitle.TabIndex = 24;
|
this.lbl_profile_shown_subtitle.TabIndex = 24;
|
||||||
@ -601,12 +588,51 @@ namespace HeliosPlus.UIForms
|
|||||||
this.lbl_profile_shown.BackColor = System.Drawing.Color.DimGray;
|
this.lbl_profile_shown.BackColor = System.Drawing.Color.DimGray;
|
||||||
this.lbl_profile_shown.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.lbl_profile_shown.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.lbl_profile_shown.ForeColor = System.Drawing.Color.White;
|
this.lbl_profile_shown.ForeColor = System.Drawing.Color.White;
|
||||||
this.lbl_profile_shown.Location = new System.Drawing.Point(12, 13);
|
this.lbl_profile_shown.Location = new System.Drawing.Point(12, 75);
|
||||||
this.lbl_profile_shown.Name = "lbl_profile_shown";
|
this.lbl_profile_shown.Name = "lbl_profile_shown";
|
||||||
this.lbl_profile_shown.Size = new System.Drawing.Size(205, 29);
|
this.lbl_profile_shown.Size = new System.Drawing.Size(205, 29);
|
||||||
this.lbl_profile_shown.TabIndex = 23;
|
this.lbl_profile_shown.TabIndex = 23;
|
||||||
this.lbl_profile_shown.Text = "My Display Profile";
|
this.lbl_profile_shown.Text = "My Display Profile";
|
||||||
//
|
//
|
||||||
|
// txt_shortcut_save_name
|
||||||
|
//
|
||||||
|
this.txt_shortcut_save_name.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.txt_shortcut_save_name.Location = new System.Drawing.Point(687, 630);
|
||||||
|
this.txt_shortcut_save_name.MaxLength = 200;
|
||||||
|
this.txt_shortcut_save_name.Name = "txt_shortcut_save_name";
|
||||||
|
this.txt_shortcut_save_name.Size = new System.Drawing.Size(384, 35);
|
||||||
|
this.txt_shortcut_save_name.TabIndex = 27;
|
||||||
|
//
|
||||||
|
// btn_save_or_rename
|
||||||
|
//
|
||||||
|
this.btn_save_or_rename.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.btn_save_or_rename.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
|
||||||
|
this.btn_save_or_rename.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
|
||||||
|
this.btn_save_or_rename.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.btn_save_or_rename.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.btn_save_or_rename.ForeColor = System.Drawing.Color.White;
|
||||||
|
this.btn_save_or_rename.Location = new System.Drawing.Point(537, 630);
|
||||||
|
this.btn_save_or_rename.Name = "btn_save_or_rename";
|
||||||
|
this.btn_save_or_rename.Size = new System.Drawing.Size(151, 33);
|
||||||
|
this.btn_save_or_rename.TabIndex = 25;
|
||||||
|
this.btn_save_or_rename.Text = "&Save As";
|
||||||
|
this.btn_save_or_rename.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// dv_profile
|
||||||
|
//
|
||||||
|
this.dv_profile.BackColor = System.Drawing.Color.DimGray;
|
||||||
|
this.dv_profile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.dv_profile.Font = new System.Drawing.Font("Consolas", 50F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.dv_profile.ForeColor = System.Drawing.Color.MidnightBlue;
|
||||||
|
this.dv_profile.Location = new System.Drawing.Point(0, 61);
|
||||||
|
this.dv_profile.Margin = new System.Windows.Forms.Padding(18);
|
||||||
|
this.dv_profile.Name = "dv_profile";
|
||||||
|
this.dv_profile.PaddingX = 100;
|
||||||
|
this.dv_profile.PaddingY = 100;
|
||||||
|
this.dv_profile.Profile = null;
|
||||||
|
this.dv_profile.Size = new System.Drawing.Size(800, 410);
|
||||||
|
this.dv_profile.TabIndex = 2;
|
||||||
|
//
|
||||||
// ShortcutForm
|
// ShortcutForm
|
||||||
//
|
//
|
||||||
this.AcceptButton = this.btn_save;
|
this.AcceptButton = this.btn_save;
|
||||||
@ -614,7 +640,9 @@ namespace HeliosPlus.UIForms
|
|||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.BackColor = System.Drawing.Color.Black;
|
this.BackColor = System.Drawing.Color.Black;
|
||||||
this.CancelButton = this.btn_cancel;
|
this.CancelButton = this.btn_cancel;
|
||||||
this.ClientSize = new System.Drawing.Size(975, 1021);
|
this.ClientSize = new System.Drawing.Size(1607, 762);
|
||||||
|
this.Controls.Add(this.txt_shortcut_save_name);
|
||||||
|
this.Controls.Add(this.btn_save_or_rename);
|
||||||
this.Controls.Add(this.lbl_profile_shown_subtitle);
|
this.Controls.Add(this.lbl_profile_shown_subtitle);
|
||||||
this.Controls.Add(this.lbl_profile_shown);
|
this.Controls.Add(this.lbl_profile_shown);
|
||||||
this.Controls.Add(this.ilv_saved_profiles);
|
this.Controls.Add(this.ilv_saved_profiles);
|
||||||
@ -692,5 +720,7 @@ namespace HeliosPlus.UIForms
|
|||||||
private Manina.Windows.Forms.ImageListView ilv_saved_profiles;
|
private Manina.Windows.Forms.ImageListView ilv_saved_profiles;
|
||||||
private System.Windows.Forms.Label lbl_profile_shown_subtitle;
|
private System.Windows.Forms.Label lbl_profile_shown_subtitle;
|
||||||
private System.Windows.Forms.Label lbl_profile_shown;
|
private System.Windows.Forms.Label lbl_profile_shown;
|
||||||
|
private System.Windows.Forms.TextBox txt_shortcut_save_name;
|
||||||
|
private System.Windows.Forms.Button btn_save_or_rename;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,22 +20,27 @@ namespace HeliosPlus.UIForms
|
|||||||
{
|
{
|
||||||
|
|
||||||
List<SteamGame> _allSteamGames;
|
List<SteamGame> _allSteamGames;
|
||||||
internal Profile[] _allProfiles;
|
|
||||||
private Profile _selectedProfile;
|
|
||||||
private ProfileAdaptor _profileAdaptor;
|
private ProfileAdaptor _profileAdaptor;
|
||||||
private static bool _inDialog = false;
|
private static bool _inDialog = false;
|
||||||
private List<Profile> _loadedProfiles = new List<Profile>();
|
private List<Profile> _loadedProfiles = new List<Profile>();
|
||||||
private static Profile _profileToLoad = null;
|
private Profile _profileToUse= null;
|
||||||
|
private Shortcut _shortcutToEdit = null;
|
||||||
|
private string _saveOrRenameMode = "save";
|
||||||
|
private bool _isNewShortcut = true;
|
||||||
|
|
||||||
public ShortcutForm()
|
public ShortcutForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
// Set the profileAdaptor we need to load images from Profiles
|
||||||
|
// into the Profiles ImageListView
|
||||||
_profileAdaptor = new ProfileAdaptor();
|
_profileAdaptor = new ProfileAdaptor();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShortcutForm(Profile profile) : this()
|
public ShortcutForm(Shortcut shortcutToEdit) : this()
|
||||||
{
|
{
|
||||||
_profileToLoad = profile;
|
_shortcutToEdit = shortcutToEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ProcessNameToMonitor
|
public string ProcessNameToMonitor
|
||||||
@ -58,36 +63,6 @@ namespace HeliosPlus.UIForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Profile SelectedProfile
|
|
||||||
{
|
|
||||||
get => dv_profile.Profile;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
// Check the profile is valid
|
|
||||||
// Create an array of display profiles we have
|
|
||||||
var profiles = Profile.LoadAllProfiles().ToArray();
|
|
||||||
_allProfiles = profiles;
|
|
||||||
// Check if the user supplied a --profile option using the profiles' ID
|
|
||||||
var profileIndex = profiles.Length > 0 ? Array.FindIndex(profiles, p => p.Id.Equals(value.Id, StringComparison.InvariantCultureIgnoreCase)) : -1;
|
|
||||||
// If the profileID wasn't there, maybe they used the profile name?
|
|
||||||
if (profileIndex == -1)
|
|
||||||
{
|
|
||||||
// Try and lookup the profile in the profiles' Name fields
|
|
||||||
profileIndex = profiles.Length > 0 ? Array.FindIndex(profiles, p => p.Name.StartsWith(value.Name, StringComparison.InvariantCultureIgnoreCase)) : -1;
|
|
||||||
}
|
|
||||||
// If the profileID still isn't there, then raise the alarm
|
|
||||||
if (profileIndex == -1)
|
|
||||||
{
|
|
||||||
MessageBox.Show(
|
|
||||||
$"ShortcutForm: Setting SelectProfile: Couldn't find either Profile Name '{SelectedProfile.Name}'or ID '{SelectedProfile.Id}' supplied to Profile property.",
|
|
||||||
Language.Executable,
|
|
||||||
MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Exclamation);
|
|
||||||
}
|
|
||||||
dv_profile.Profile = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ExecutableNameAndPath
|
public string ExecutableNameAndPath
|
||||||
{
|
{
|
||||||
get => rb_switch_temp.Checked && rb_launcher.Checked ? txt_executable.Text : string.Empty;
|
get => rb_switch_temp.Checked && rb_launcher.Checked ? txt_executable.Text : string.Empty;
|
||||||
@ -153,6 +128,12 @@ namespace HeliosPlus.UIForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Shortcut Shortcut
|
||||||
|
{
|
||||||
|
get => _shortcutToEdit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public SupportedGameLibrary GameLibrary
|
public SupportedGameLibrary GameLibrary
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -225,18 +206,6 @@ namespace HeliosPlus.UIForms
|
|||||||
iconImage.PixelFormat == System.Drawing.Imaging.PixelFormat.Format8bppIndexed;
|
iconImage.PixelFormat == System.Drawing.Imaging.PixelFormat.Format8bppIndexed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetValidFilename(string uncheckedFilename)
|
|
||||||
{
|
|
||||||
string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
|
|
||||||
foreach (char c in invalid)
|
|
||||||
{
|
|
||||||
uncheckedFilename = uncheckedFilename.Replace(c.ToString(), "");
|
|
||||||
}
|
|
||||||
return uncheckedFilename;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void btn_app_executable_Click(object sender, EventArgs e)
|
private void btn_app_executable_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dialog_open.ShowDialog(this) == DialogResult.OK)
|
if (dialog_open.ShowDialog(this) == DialogResult.OK)
|
||||||
@ -259,319 +228,194 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
private void btn_save_Click(object sender, EventArgs e)
|
private void btn_save_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult = DialogResult.None;
|
// Store all of the information in the Shortcut object based on what's been selected in this form
|
||||||
|
|
||||||
try
|
// Validate the fields are filled as they should be!
|
||||||
|
// Check the name is valid
|
||||||
|
if (String.IsNullOrWhiteSpace(txt_shortcut_save_name.Text) && Program.IsValidFilename(txt_shortcut_save_name.Text))
|
||||||
{
|
{
|
||||||
// Set the Shortcut save folder to the Desktop as that's where people will want it most likely
|
MessageBox.Show(
|
||||||
dialog_save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
@"You need to specify a name for this Shortcut before it can be saved.",
|
||||||
// Try to set up some sensible suggestions for the Shortcut name
|
@"Please name this Shortcut.",
|
||||||
if (rb_switch_perm.Checked)
|
MessageBoxButtons.OK,
|
||||||
{
|
MessageBoxIcon.Exclamation);
|
||||||
|
return;
|
||||||
dialog_save.FileName = SelectedProfile.Name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (rb_standalone.Checked)
|
|
||||||
{
|
|
||||||
dialog_save.FileName = String.Concat(Path.GetFileNameWithoutExtension(ExecutableNameAndPath),@" (", SelectedProfile.Name.ToLower(), @")");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dialog_save.FileName = String.Concat(GameName, @" (", SelectedProfile.Name, @")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show the Save Shortcut window
|
|
||||||
if (dialog_save.ShowDialog(this) == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (CreateShortcut(dialog_save.FileName))
|
|
||||||
{
|
|
||||||
MessageBox.Show(
|
|
||||||
Language.Shortcut_placed_successfully,
|
|
||||||
Language.Shortcut,
|
|
||||||
MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show(
|
|
||||||
Language.Failed_to_create_the_shortcut_Unexpected_exception_occurred,
|
|
||||||
Language.Shortcut,
|
|
||||||
MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Exclamation);
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog_save.FileName = string.Empty;
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
|
||||||
|
// Check the profile is set and that it's still valid
|
||||||
|
if (!(_profileToUse is Profile))
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message, Language.Shortcut, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show(
|
||||||
|
@"You need to select a Display Profile to use with this shortcut. Please select one from the list of Display Profiles on the left of the screen.",
|
||||||
|
@"Please choose a Display Profile.",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Exclamation);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// ReSharper disable once FunctionComplexityOverflow
|
// Check the permanence requirements
|
||||||
// ReSharper disable once CyclomaticComplexity
|
if (rb_switch_perm.Checked)
|
||||||
private bool CreateShortcut(string fileName)
|
|
||||||
{
|
|
||||||
string programName = Path.GetFileNameWithoutExtension(txt_executable.Text);
|
|
||||||
string shortcutDescription = string.Empty;
|
|
||||||
MultiIcon shortcutIcon;
|
|
||||||
string shortcutIconFileName = string.Empty;
|
|
||||||
|
|
||||||
var args = new List<string>
|
|
||||||
{
|
{
|
||||||
// Add the SwitchProfile command as the first argument to start to switch to another profile
|
// Check the Shortcut Category to see if it's application
|
||||||
$"{HeliosStartupAction.SwitchProfile}"
|
|
||||||
};
|
|
||||||
|
|
||||||
// Only add the rest of the options if the temporary switch radio button is set
|
|
||||||
if (rb_switch_temp.Checked)
|
|
||||||
{
|
|
||||||
// Only add this set of options if the standalone programme radio button is set
|
|
||||||
if (rb_standalone.Checked)
|
if (rb_standalone.Checked)
|
||||||
{
|
{
|
||||||
// Doublecheck the Executable text field is filled in
|
if (cb_args_executable.Checked && String.IsNullOrWhiteSpace(txt_args_executable.Text))
|
||||||
if (string.IsNullOrWhiteSpace(ExecutableNameAndPath))
|
|
||||||
{
|
{
|
||||||
throw new Exception(Language.Executable_address_can_not_be_empty);
|
MessageBox.Show(
|
||||||
|
@"If you have chosen to pass extra arguments to the executable when it is run, then you need to enter them in the 'Pass arguments to Executable' field. If you didn't want to pass extra arguments then please uncheck the 'Pass arguments to Executable' checkbox.",
|
||||||
|
@"Please add Executable arguments.",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Exclamation);
|
||||||
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doublecheck the Executable text field is a path to a real file
|
if (!File.Exists(txt_executable.Text))
|
||||||
if (!File.Exists(ExecutableNameAndPath))
|
|
||||||
{
|
{
|
||||||
throw new Exception(Language.Executable_file_not_found);
|
MessageBox.Show(
|
||||||
|
@"The executable you have chosen does not exist! Please reselect the executable, or check you have persmissions to view it.",
|
||||||
|
@"Executable doesn't exist",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Exclamation);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the executable command and the executable name to the shortcut arguments
|
if (String.IsNullOrWhiteSpace(txt_process_name.Text))
|
||||||
args.Add($"execute \"{ExecutableNameAndPath}\"");
|
|
||||||
|
|
||||||
// Add the Profile Name as the first option (use that rather than ID - though ID still will work!)
|
|
||||||
args.Add($"--profile \"{SelectedProfile.Name}\"");
|
|
||||||
|
|
||||||
// Check that the wait for executable radiobutton is on
|
|
||||||
if (rb_wait_executable.Checked)
|
|
||||||
{
|
{
|
||||||
// Doublecheck the process name has text in it
|
string message = "";
|
||||||
if (!string.IsNullOrWhiteSpace(ProcessNameToMonitor))
|
|
||||||
{
|
|
||||||
// Add the waitfor argument and the process name to the shortcut arguments
|
|
||||||
args.Add($"--waitfor \"{ProcessNameToMonitor}\"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the timeout argument and the timeout duration in seconds to the shortcut arguments
|
// figure out the message we want to give the user
|
||||||
args.Add($"--timeout {ExecutableTimeout}");
|
if (_shortcutToEdit.ProcessNameToMonitorUsesExecutable)
|
||||||
|
message = @"Cannot work out the process to monitor from the executable. Please reselect the executable (and we'll try again), and if that doesn't work then manually enter the process name into the 'Process to monitor' field.";
|
||||||
|
else
|
||||||
|
message = @"Please manually enter the process name into the 'Process to monitor' field.";
|
||||||
|
|
||||||
if (cb_args_executable.Checked)
|
// show the error message
|
||||||
{
|
MessageBox.Show(
|
||||||
args.Add($"--arguments \"{ExecutableArguments}\"");
|
message,
|
||||||
}
|
@"Empty process monitor",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
// Prepare text for the shortcut description field
|
MessageBoxIcon.Exclamation);
|
||||||
shortcutDescription = string.Format(Language.Executing_application_with_profile, programName, SelectedProfile.Name);
|
return;
|
||||||
|
|
||||||
// Work out the name of the shortcut we'll save.
|
|
||||||
shortcutIconFileName = Path.Combine(Program.ShortcutIconCachePath, String.Concat(@"executable-", GetValidFilename(SelectedProfile.Name).ToLower(CultureInfo.InvariantCulture), "-", Path.GetFileNameWithoutExtension(ExecutableNameAndPath), @".ico"));
|
|
||||||
|
|
||||||
// Grab an icon for the selected executable
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// We'll first try to extract the Icon from the executable the user provided
|
|
||||||
//shortcutIcon.Load(ExecutableNameAndPath);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// but if that doesn't work, then we use our own one.
|
|
||||||
//shortcutIcon.Load(Assembly.GetExecutingAssembly().Location);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Only add the rest of the options if the temporary switch radio button is set
|
else if (rb_switch_temp.Checked)
|
||||||
// and if the game launching radio button is set
|
|
||||||
else if (rb_launcher.Checked)
|
|
||||||
{
|
{
|
||||||
// TODO need to make this work so at least one game library is installed
|
|
||||||
// i.e. if (!SteamGame.SteamInstalled && !UplayGame.UplayInstalled )
|
if (cb_args_game.Checked && String.IsNullOrWhiteSpace(txt_args_game.Text))
|
||||||
if (GameLibrary == SupportedGameLibrary.Steam)
|
|
||||||
{
|
{
|
||||||
if (!SteamGame.SteamInstalled)
|
MessageBox.Show(
|
||||||
{
|
@"If you have chosen to pass extra arguments to the Game when it is run, then you need to enter them in the 'Pass arguments to Game' field. If you didn't want to pass extra arguments then please uncheck the 'Pass arguments to Game' checkbox.",
|
||||||
throw new Exception(Language.Steam_is_not_installed);
|
@"Please add Game arguments.",
|
||||||
}
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Exclamation);
|
||||||
List<SteamGame> allSteamGames = SteamGame.GetAllInstalledGames();
|
return;
|
||||||
|
|
||||||
SteamGame steamGameToRun = null;
|
|
||||||
foreach (SteamGame steamGameToCheck in allSteamGames)
|
|
||||||
{
|
|
||||||
if (steamGameToCheck.GameId == GameAppId)
|
|
||||||
{
|
|
||||||
steamGameToRun = steamGameToCheck;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Work out the name of the shortcut we'll save.
|
|
||||||
shortcutIconFileName = Path.Combine(Program.ShortcutIconCachePath, String.Concat(@"steam-", GetValidFilename(SelectedProfile.Name).ToLower(CultureInfo.InvariantCulture), "-", GameAppId.ToString(), @".ico"));
|
|
||||||
|
|
||||||
shortcutIcon = new ProfileIcon(SelectedProfile).ToIconOverly(steamGameToRun.GameIconPath);
|
|
||||||
shortcutIcon.Save(shortcutIconFileName, MultiIconFormat.ICO);
|
|
||||||
|
|
||||||
args.Add($"steam {GameAppId}");
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (GameLibrary == SupportedGameLibrary.Uplay)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!UplayGame.UplayInstalled)
|
|
||||||
{
|
|
||||||
throw new Exception(Language.Steam_is_not_installed);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<UplayGame> allUplayGames = UplayGame.GetAllInstalledGames();
|
|
||||||
|
|
||||||
UplayGame uplayGameToRun = null;
|
|
||||||
foreach (UplayGame uplayGameToCheck in allUplayGames)
|
|
||||||
{
|
|
||||||
if (uplayGameToCheck.GameId == GameAppId)
|
|
||||||
{
|
|
||||||
uplayGameToRun = uplayGameToCheck;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//shortcutIcon = uplayGameToRun.GameIcon;
|
|
||||||
|
|
||||||
// Work out the name of the shortcut we'll save.
|
|
||||||
shortcutIconFileName = Path.Combine(Program.ShortcutIconCachePath, String.Concat(@"uplay-", GetValidFilename(SelectedProfile.Name).ToLower(CultureInfo.InvariantCulture), "-" , GameAppId.ToString(), @".ico"));
|
|
||||||
|
|
||||||
shortcutIcon = new ProfileIcon(SelectedProfile).ToIconOverly(uplayGameToRun.GameIconPath);
|
|
||||||
shortcutIcon.Save(shortcutIconFileName, MultiIconFormat.ICO);
|
|
||||||
|
|
||||||
args.Add($"uplay {GameAppId}");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the Profile Name as the first option (use that rather than ID - though ID still will work!)
|
if (Convert.ToUInt32(txt_game_id.Text) == 0)
|
||||||
args.Add($"--profile \"{SelectedProfile.Name}\"");
|
|
||||||
|
|
||||||
// Add the game timeout argument and the timeout duration in seconds to the shortcut arguments
|
|
||||||
args.Add($"--timeout {GameTimeout}");
|
|
||||||
|
|
||||||
if (cb_args_game.Checked)
|
|
||||||
{
|
{
|
||||||
args.Add($"--arguments \"{GameArguments}\"");
|
MessageBox.Show(
|
||||||
|
@"Please choose a Game by scrolling through the list, selecting the Game that you want, and then clicking the '>>' button to fill the Game fields.",
|
||||||
|
@"Please choose a Game.",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Exclamation);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare text for the shortcut description field
|
|
||||||
shortcutDescription = string.Format(Language.Executing_application_with_profile, GameName, SelectedProfile.Name);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Only add the rest of the options if the permanent switch radio button is set
|
|
||||||
|
// Fill the Shortcut object with the bits we care about saving
|
||||||
|
|
||||||
|
// Update the Executable args
|
||||||
|
_shortcutToEdit.ExecutableArguments = txt_args_executable.Text;
|
||||||
|
|
||||||
|
// Update if the executable args are needed
|
||||||
|
_shortcutToEdit.ExecutableArgumentsRequired = cb_args_executable.Checked;
|
||||||
|
|
||||||
|
// Update the Executable name and path
|
||||||
|
_shortcutToEdit.ExecutableNameAndPath = txt_executable.Text;
|
||||||
|
|
||||||
|
// Update the executable timeout
|
||||||
|
_shortcutToEdit.ExecutableTimeout = Convert.ToUInt32(nud_timeout_executable.Value);
|
||||||
|
|
||||||
|
// Update the game app id
|
||||||
|
_shortcutToEdit.GameAppId = Convert.ToUInt32(txt_game_id.Text);
|
||||||
|
|
||||||
|
// Update the game args
|
||||||
|
_shortcutToEdit.GameArguments = txt_args_game.Text;
|
||||||
|
|
||||||
|
// Update if the game args are needed
|
||||||
|
_shortcutToEdit.GameArgumentsRequired = cb_args_game.Checked;
|
||||||
|
|
||||||
|
// Update what game library it's from
|
||||||
|
//_shortcutToEdit.GameLibrary = SupportedGameLibrary.Steam;
|
||||||
|
|
||||||
|
// Update the Game Name
|
||||||
|
_shortcutToEdit.GameName = txt_game_name.Text;
|
||||||
|
|
||||||
|
// Update the Game Timeout
|
||||||
|
_shortcutToEdit.GameTimeout = Convert.ToUInt32(nud_timeout_game.Value);
|
||||||
|
|
||||||
|
// Update the Shortcut name
|
||||||
|
_shortcutToEdit.Name = txt_shortcut_save_name.Text;
|
||||||
|
|
||||||
|
// Check the permanence requirements
|
||||||
|
if (rb_switch_temp.Checked)
|
||||||
|
_shortcutToEdit.Permanence = ShortcutPermanence.Temporary;
|
||||||
|
|
||||||
|
if (rb_switch_perm.Checked)
|
||||||
|
_shortcutToEdit.Permanence = ShortcutPermanence.Permanent;
|
||||||
|
|
||||||
|
// Update the process name to monitor
|
||||||
|
if (!String.IsNullOrWhiteSpace(txt_process_name.Text)) {
|
||||||
|
_shortcutToEdit.ProcessNameToMonitor = txt_process_name.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rb_wait_process.Checked && !String.IsNullOrWhiteSpace(txt_process_name.Text))
|
||||||
|
{
|
||||||
|
_shortcutToEdit.ProcessNameToMonitorUsesExecutable = true;
|
||||||
|
_shortcutToEdit.ProcessNameToMonitor = txt_process_name.Text;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Add the action switch to make the permanent switch to a different profile
|
_shortcutToEdit.ProcessNameToMonitorUsesExecutable = false;
|
||||||
args.Add($"permanent");
|
|
||||||
|
|
||||||
// Add the Profile Name as the first option (use that rather than ID - though ID still will work!)
|
|
||||||
args.Add($"--profile \"{SelectedProfile.Name}\"");
|
|
||||||
|
|
||||||
// Prepare text for the shortcut description field
|
|
||||||
shortcutDescription = string.Format(Language.Switching_display_profile_to_profile, SelectedProfile.Name);
|
|
||||||
|
|
||||||
// Work out the name of the shortcut we'll save.
|
|
||||||
shortcutIconFileName = Path.Combine(Program.ShortcutIconCachePath, String.Concat(@"permanent-", GetValidFilename(SelectedProfile.Name).ToLower(CultureInfo.InvariantCulture), @".ico"));
|
|
||||||
|
|
||||||
// Grab an icon for the selected profile
|
|
||||||
try
|
|
||||||
{
|
|
||||||
shortcutIcon = new ProfileIcon(SelectedProfile).ToIcon();
|
|
||||||
shortcutIcon.Save(shortcutIconFileName, MultiIconFormat.ICO);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// but if that doesn't work, then we use our own one.
|
|
||||||
shortcutIcon = new ProfileIcon(SelectedProfile).ToIconOverly(Assembly.GetExecutingAssembly().Location);
|
|
||||||
shortcutIcon.Save(shortcutIconFileName, MultiIconFormat.ICO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we are ready to create a shortcut based on the filename the user gave us
|
// Update the profile to use
|
||||||
fileName = Path.ChangeExtension(fileName, @"lnk");
|
_shortcutToEdit.ProfileToUse = _profileToUse;
|
||||||
|
|
||||||
// If the user supplied a file
|
// Update the Category as well as the OriginalIconPath
|
||||||
if (fileName != null)
|
// (as we need the OriginalIconPath to run the SaveShortcutIconToCache method)
|
||||||
{
|
if (rb_launcher.Checked)
|
||||||
try
|
_shortcutToEdit.Category = ShortcutCategory.Game;
|
||||||
{
|
if (txt_game_launcher.Text == SupportedGameLibrary.Steam.ToString())
|
||||||
// Remove the old file to replace it
|
_shortcutToEdit.OriginalIconPath = (from steamGame in SteamGame.AllGames where steamGame.GameId == _shortcutToEdit.GameAppId select steamGame.GameIconPath).First();
|
||||||
if (File.Exists(fileName))
|
else if (txt_game_launcher.Text == SupportedGameLibrary.Uplay.ToString())
|
||||||
{
|
_shortcutToEdit.OriginalIconPath = (from uplayGame in UplayGame.AllGames where uplayGame.GameId == _shortcutToEdit.GameAppId select uplayGame.GameIconPath).First();
|
||||||
File.Delete(fileName);
|
else if (rb_standalone.Checked)
|
||||||
}
|
_shortcutToEdit.Category = ShortcutCategory.Application;
|
||||||
|
|
||||||
// Actually create the shortcut!
|
// Save the shortcut icon
|
||||||
var wshShellType = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8"));
|
_shortcutToEdit.SaveShortcutIconToCache();
|
||||||
dynamic wshShell = Activator.CreateInstance(wshShellType);
|
|
||||||
|
|
||||||
try
|
// Add the Shortcut to the list of saved Shortcuts so it gets saved for later
|
||||||
{
|
// but only if it's new... if it is an edit then it will already be in the list.
|
||||||
var shortcut = wshShell.CreateShortcut(fileName);
|
if (_isNewShortcut)
|
||||||
|
Shortcut.AllSavedShortcuts.Add(_shortcutToEdit);
|
||||||
|
|
||||||
try
|
// Save everything is golden and close the form.
|
||||||
{
|
DialogResult = DialogResult.OK;
|
||||||
shortcut.TargetPath = Application.ExecutablePath;
|
this.Close();
|
||||||
shortcut.Arguments = string.Join(" ", args);
|
|
||||||
shortcut.Description = shortcutDescription;
|
|
||||||
shortcut.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath) ??
|
|
||||||
string.Empty;
|
|
||||||
|
|
||||||
shortcut.IconLocation = shortcutIconFileName;
|
|
||||||
|
|
||||||
shortcut.Save();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Marshal.FinalReleaseComObject(shortcut);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Marshal.FinalReleaseComObject(wshShell);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// Clean up a failed attempt
|
|
||||||
if (File.Exists(fileName))
|
|
||||||
{
|
|
||||||
File.Delete(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return a status on how it went
|
|
||||||
// true if it was a success or false if it was not
|
|
||||||
return fileName != null && File.Exists(fileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void txt_executable_TextChanged(object sender, EventArgs e)
|
private void txt_executable_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (File.Exists(txt_executable.Text))
|
if (File.Exists(txt_executable.Text))
|
||||||
{
|
{
|
||||||
|
|
||||||
// Turn on the CreateShortcut Button
|
|
||||||
btn_save.Enabled = true;
|
|
||||||
|
|
||||||
// Try and discern the process name for this
|
// Try and discern the process name for this
|
||||||
// if the user hasn't entered anything already
|
// if the user hasn't entered anything already
|
||||||
if (txt_process_name.Text == String.Empty)
|
if (txt_process_name.Text == String.Empty)
|
||||||
@ -587,10 +431,24 @@ namespace HeliosPlus.UIForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else
|
if (txt_shortcut_save_name.Text.Length > 0)
|
||||||
|
{
|
||||||
|
// Turn on the CreateShortcut Button
|
||||||
|
btn_save.Enabled = true;
|
||||||
|
btn_save.Visible = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btn_save.Enabled = false;
|
||||||
|
btn_save.Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Turn off the CreateShortcut Button
|
// Turn off the CreateShortcut Button
|
||||||
btn_save.Enabled = false;
|
btn_save.Enabled = false;
|
||||||
|
btn_save.Visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,8 +459,17 @@ namespace HeliosPlus.UIForms
|
|||||||
// Disable the Temporary Group
|
// Disable the Temporary Group
|
||||||
g_temporary.Enabled = false;
|
g_temporary.Enabled = false;
|
||||||
}
|
}
|
||||||
// Turn on the CreateShortcut Button
|
if (txt_shortcut_save_name.Text.Length > 0)
|
||||||
btn_save.Enabled = true;
|
{
|
||||||
|
// Turn on the CreateShortcut Button
|
||||||
|
btn_save.Enabled = true;
|
||||||
|
btn_save.Visible = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btn_save.Enabled = false;
|
||||||
|
btn_save.Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void rb_switch_temp_CheckedChanged(object sender, EventArgs e)
|
private void rb_switch_temp_CheckedChanged(object sender, EventArgs e)
|
||||||
@ -617,17 +484,20 @@ namespace HeliosPlus.UIForms
|
|||||||
{
|
{
|
||||||
// Turn on the CreateShortcut Button
|
// Turn on the CreateShortcut Button
|
||||||
btn_save.Enabled = true;
|
btn_save.Enabled = true;
|
||||||
|
btn_save.Visible = true;
|
||||||
}
|
}
|
||||||
// else if it's a valid executable
|
// else if it's a valid executable
|
||||||
else if (txt_executable.Text.Length > 0 && File.Exists(txt_executable.Text))
|
else if (txt_executable.Text.Length > 0 && File.Exists(txt_executable.Text) && txt_shortcut_save_name.Text.Length > 0)
|
||||||
{
|
{
|
||||||
// Turn on the CreateShortcut Button
|
// Turn on the CreateShortcut Button
|
||||||
btn_save.Enabled = true;
|
btn_save.Enabled = true;
|
||||||
|
btn_save.Visible = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Turn on the CreateShortcut Button
|
// Turn on the CreateShortcut Button
|
||||||
btn_save.Enabled = false;
|
btn_save.Enabled = false;
|
||||||
|
btn_save.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -643,15 +513,17 @@ namespace HeliosPlus.UIForms
|
|||||||
// Disable the Game Panel
|
// Disable the Game Panel
|
||||||
p_game.Enabled = false;
|
p_game.Enabled = false;
|
||||||
|
|
||||||
if (txt_executable.Text.Length > 0 && File.Exists(txt_executable.Text))
|
if (txt_executable.Text.Length > 0 && File.Exists(txt_executable.Text) && txt_shortcut_save_name.Text.Length > 0)
|
||||||
{
|
{
|
||||||
// Turn on the CreateShortcut Button
|
// Turn on the CreateShortcut Button
|
||||||
btn_save.Enabled = true;
|
btn_save.Enabled = true;
|
||||||
|
btn_save.Visible = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Turn on the CreateShortcut Button
|
// Turn on the CreateShortcut Button
|
||||||
btn_save.Enabled = false;
|
btn_save.Enabled = false;
|
||||||
|
btn_save.Visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,15 +539,17 @@ namespace HeliosPlus.UIForms
|
|||||||
p_standalone.Enabled = false;
|
p_standalone.Enabled = false;
|
||||||
|
|
||||||
// If it's been set already to a valid gamelauncher, then enable the button
|
// If it's been set already to a valid gamelauncher, then enable the button
|
||||||
if (txt_game_launcher.Text.Length > 0 && txt_game_id.Text.Length > 0 && txt_game_name.Text.Length > 0)
|
if (txt_game_launcher.Text.Length > 0 && txt_game_id.Text.Length > 0 && txt_game_name.Text.Length > 0 && txt_shortcut_save_name.Text.Length > 0)
|
||||||
{
|
{
|
||||||
// Turn on the CreateShortcut Button
|
// Turn on the CreateShortcut Button
|
||||||
btn_save.Enabled = true;
|
btn_save.Enabled = true;
|
||||||
|
btn_save.Visible = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Turn on the CreateShortcut Button
|
// Turn on the CreateShortcut Button
|
||||||
btn_save.Enabled = false;
|
btn_save.Enabled = false;
|
||||||
|
btn_save.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -713,6 +587,22 @@ namespace HeliosPlus.UIForms
|
|||||||
private async void ShortcutForm_Load(object sender, EventArgs e)
|
private async void ShortcutForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Create a new SHortcut if we are creating a new one
|
||||||
|
// And set up the page.
|
||||||
|
if (_shortcutToEdit == null)
|
||||||
|
{
|
||||||
|
_shortcutToEdit = new Shortcut();
|
||||||
|
_isNewShortcut = true;
|
||||||
|
_saveOrRenameMode = "save";
|
||||||
|
btn_save_or_rename.Text = "Save As";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_isNewShortcut = false;
|
||||||
|
_saveOrRenameMode = "rename";
|
||||||
|
btn_save_or_rename.Text = "Rename To";
|
||||||
|
}
|
||||||
|
|
||||||
// Load all the profiles to prepare things
|
// Load all the profiles to prepare things
|
||||||
_loadedProfiles = (List<Profile>)Profile.LoadAllProfiles();
|
_loadedProfiles = (List<Profile>)Profile.LoadAllProfiles();
|
||||||
|
|
||||||
@ -735,8 +625,8 @@ namespace HeliosPlus.UIForms
|
|||||||
if (!foundCurrentProfileInLoadedProfiles)
|
if (!foundCurrentProfileInLoadedProfiles)
|
||||||
ChangeSelectedProfile(Profile.CurrentProfile);
|
ChangeSelectedProfile(Profile.CurrentProfile);
|
||||||
|
|
||||||
// Refresh the Profile UI
|
// Refresh the Shortcut UI
|
||||||
RefreshDisplayProfileUI();
|
RefreshShortcutUI();
|
||||||
|
|
||||||
// Start finding the games and loading the Games ListView
|
// Start finding the games and loading the Games ListView
|
||||||
List<SteamGame> allSteamGames = SteamGame.GetAllInstalledGames();
|
List<SteamGame> allSteamGames = SteamGame.GetAllInstalledGames();
|
||||||
@ -861,8 +751,12 @@ namespace HeliosPlus.UIForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn on the CreateShortcut Button
|
if (txt_shortcut_save_name.Text.Length > 0)
|
||||||
btn_save.Enabled = true;
|
{
|
||||||
|
// Turn on the CreateShortcut Button
|
||||||
|
btn_save.Enabled = true;
|
||||||
|
btn_save.Visible = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -881,21 +775,25 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
private void ChangeSelectedProfile(Profile profile)
|
private void ChangeSelectedProfile(Profile profile)
|
||||||
{
|
{
|
||||||
|
// If the profile is null then return
|
||||||
|
// (this happens when a new blank shortcut is created
|
||||||
|
if (profile == null)
|
||||||
|
return;
|
||||||
|
|
||||||
// And we need to update the actual selected profile too!
|
// And we need to update the actual selected profile too!
|
||||||
_selectedProfile = profile;
|
_profileToUse = profile;
|
||||||
|
|
||||||
// We also need to load the saved profile name to show the user
|
// We also need to load the saved profile name to show the user
|
||||||
lbl_profile_shown.Text = _selectedProfile.Name;
|
lbl_profile_shown.Text = _profileToUse.Name;
|
||||||
|
|
||||||
if (_selectedProfile.Equals(Profile.CurrentProfile))
|
if (_profileToUse.Equals(Profile.CurrentProfile))
|
||||||
{
|
{
|
||||||
lbl_profile_shown_subtitle.Text = "(Current Display Profile in use)";
|
lbl_profile_shown_subtitle.Text = "(Current Display Profile in use)";
|
||||||
btn_save.Visible = false;
|
btn_save.Visible = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!_selectedProfile.IsPossible)
|
if (!_profileToUse.IsPossible)
|
||||||
{
|
{
|
||||||
lbl_profile_shown_subtitle.Text = "(Display Profile is not valid so cannot be used)";
|
lbl_profile_shown_subtitle.Text = "(Display Profile is not valid so cannot be used)";
|
||||||
btn_save.Visible = false;
|
btn_save.Visible = false;
|
||||||
@ -915,7 +813,7 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshDisplayProfileUI()
|
private void RefreshShortcutUI()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!_inDialog)
|
if (!_inDialog)
|
||||||
@ -942,13 +840,6 @@ namespace HeliosPlus.UIForms
|
|||||||
ilv_saved_profiles.Items.Add(newItem, _profileAdaptor);
|
ilv_saved_profiles.Items.Add(newItem, _profileAdaptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Profile.CurrentProfile.Equals(loadedProfile))
|
|
||||||
{
|
|
||||||
// We have already saved the selected profile!
|
|
||||||
// so we need to show the selected profile
|
|
||||||
ChangeSelectedProfile(loadedProfile);
|
|
||||||
foundCurrentProfileInLoadedProfiles = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we get to the end of the loaded profiles and haven't
|
// If we get to the end of the loaded profiles and haven't
|
||||||
@ -959,8 +850,8 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
// Check if we were loading a profile to edit
|
// Check if we were loading a profile to edit
|
||||||
// If so, select that instead of all that other stuff above!
|
// If so, select that instead of all that other stuff above!
|
||||||
if (_profileToLoad != null)
|
if (_shortcutToEdit != null)
|
||||||
ChangeSelectedProfile(_profileToLoad);
|
ChangeSelectedProfile(_shortcutToEdit.ProfileToUse);
|
||||||
|
|
||||||
// Restart updating the saved_profiles listview
|
// Restart updating the saved_profiles listview
|
||||||
ilv_saved_profiles.ResumeLayout();
|
ilv_saved_profiles.ResumeLayout();
|
||||||
@ -974,6 +865,7 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
private void btn_back_Click(object sender, EventArgs e)
|
private void btn_back_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1036,23 +928,5 @@ namespace HeliosPlus.UIForms
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void black_button_Paint(object sender, PaintEventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
base.OnPaint(e);
|
|
||||||
|
|
||||||
Button button = sender as Button;
|
|
||||||
|
|
||||||
if (!button.Enabled)
|
|
||||||
{
|
|
||||||
int x = ClientRectangle.X + 3 ;
|
|
||||||
int y = ClientRectangle.Y + 8 ;
|
|
||||||
|
|
||||||
TextRenderer.DrawText(e.Graphics, button.Text,
|
|
||||||
button.Font, new Point(x, y), Color.Gray,
|
|
||||||
TextFormatFlags.LeftAndRightPadding);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -130,7 +130,7 @@
|
|||||||
<value>373, 24</value>
|
<value>373, 24</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>36</value>
|
<value>67</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
46
HeliosPlus/UIForms/ShortcutLibraryForm.Designer.cs
generated
46
HeliosPlus/UIForms/ShortcutLibraryForm.Designer.cs
generated
@ -29,34 +29,34 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShortcutLibraryForm));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShortcutLibraryForm));
|
||||||
this.ilv_saved_profiles = new Manina.Windows.Forms.ImageListView();
|
this.ilv_saved_shortcuts = new Manina.Windows.Forms.ImageListView();
|
||||||
this.btn_delete = new System.Windows.Forms.Button();
|
this.btn_delete = new System.Windows.Forms.Button();
|
||||||
this.btn_back = new System.Windows.Forms.Button();
|
this.btn_back = new System.Windows.Forms.Button();
|
||||||
this.btn_run = new System.Windows.Forms.Button();
|
this.btn_run = new System.Windows.Forms.Button();
|
||||||
this.btn_edit = new System.Windows.Forms.Button();
|
this.btn_edit = new System.Windows.Forms.Button();
|
||||||
this.btn_new = new System.Windows.Forms.Button();
|
this.btn_new = new System.Windows.Forms.Button();
|
||||||
this.btn_save = new System.Windows.Forms.Button();
|
this.btn_save = new System.Windows.Forms.Button();
|
||||||
|
this.dialog_save = new System.Windows.Forms.SaveFileDialog();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// ilv_saved_profiles
|
// ilv_saved_shortcuts
|
||||||
//
|
//
|
||||||
this.ilv_saved_profiles.AllowCheckBoxClick = false;
|
this.ilv_saved_shortcuts.AllowCheckBoxClick = false;
|
||||||
this.ilv_saved_profiles.AllowColumnClick = false;
|
this.ilv_saved_shortcuts.AllowColumnClick = false;
|
||||||
this.ilv_saved_profiles.AllowColumnResize = false;
|
this.ilv_saved_shortcuts.AllowColumnResize = false;
|
||||||
this.ilv_saved_profiles.AllowItemReorder = false;
|
this.ilv_saved_shortcuts.AllowItemReorder = false;
|
||||||
this.ilv_saved_profiles.AllowPaneResize = false;
|
this.ilv_saved_shortcuts.AllowPaneResize = false;
|
||||||
this.ilv_saved_profiles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
this.ilv_saved_shortcuts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.ilv_saved_profiles.Location = new System.Drawing.Point(0, 0);
|
this.ilv_saved_shortcuts.Location = new System.Drawing.Point(0, 0);
|
||||||
this.ilv_saved_profiles.MultiSelect = false;
|
this.ilv_saved_shortcuts.MultiSelect = false;
|
||||||
this.ilv_saved_profiles.Name = "ilv_saved_profiles";
|
this.ilv_saved_shortcuts.Name = "ilv_saved_shortcuts";
|
||||||
this.ilv_saved_profiles.PersistentCacheDirectory = "";
|
this.ilv_saved_shortcuts.PersistentCacheDirectory = "";
|
||||||
this.ilv_saved_profiles.PersistentCacheSize = ((long)(100));
|
this.ilv_saved_shortcuts.PersistentCacheSize = ((long)(100));
|
||||||
this.ilv_saved_profiles.Size = new System.Drawing.Size(1122, 743);
|
this.ilv_saved_shortcuts.Size = new System.Drawing.Size(1122, 743);
|
||||||
this.ilv_saved_profiles.TabIndex = 22;
|
this.ilv_saved_shortcuts.TabIndex = 22;
|
||||||
this.ilv_saved_profiles.UseWIC = true;
|
this.ilv_saved_shortcuts.UseWIC = true;
|
||||||
this.ilv_saved_profiles.View = Manina.Windows.Forms.View.HorizontalStrip;
|
|
||||||
//
|
//
|
||||||
// btn_delete
|
// btn_delete
|
||||||
//
|
//
|
||||||
@ -158,6 +158,13 @@
|
|||||||
this.btn_save.UseVisualStyleBackColor = false;
|
this.btn_save.UseVisualStyleBackColor = false;
|
||||||
this.btn_save.Visible = false;
|
this.btn_save.Visible = false;
|
||||||
//
|
//
|
||||||
|
// dialog_save
|
||||||
|
//
|
||||||
|
this.dialog_save.DefaultExt = "lnk";
|
||||||
|
this.dialog_save.DereferenceLinks = false;
|
||||||
|
this.dialog_save.Filter = global::HeliosPlus.Resources.Language.Shortcuts_Filter;
|
||||||
|
this.dialog_save.RestoreDirectory = true;
|
||||||
|
//
|
||||||
// ShortcutLibraryForm
|
// ShortcutLibraryForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
@ -170,7 +177,7 @@
|
|||||||
this.Controls.Add(this.btn_delete);
|
this.Controls.Add(this.btn_delete);
|
||||||
this.Controls.Add(this.btn_back);
|
this.Controls.Add(this.btn_back);
|
||||||
this.Controls.Add(this.btn_run);
|
this.Controls.Add(this.btn_run);
|
||||||
this.Controls.Add(this.ilv_saved_profiles);
|
this.Controls.Add(this.ilv_saved_shortcuts);
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.Name = "ShortcutLibraryForm";
|
this.Name = "ShortcutLibraryForm";
|
||||||
@ -183,12 +190,13 @@
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Manina.Windows.Forms.ImageListView ilv_saved_profiles;
|
private Manina.Windows.Forms.ImageListView ilv_saved_shortcuts;
|
||||||
private System.Windows.Forms.Button btn_delete;
|
private System.Windows.Forms.Button btn_delete;
|
||||||
private System.Windows.Forms.Button btn_back;
|
private System.Windows.Forms.Button btn_back;
|
||||||
private System.Windows.Forms.Button btn_run;
|
private System.Windows.Forms.Button btn_run;
|
||||||
private System.Windows.Forms.Button btn_edit;
|
private System.Windows.Forms.Button btn_edit;
|
||||||
private System.Windows.Forms.Button btn_new;
|
private System.Windows.Forms.Button btn_new;
|
||||||
private System.Windows.Forms.Button btn_save;
|
private System.Windows.Forms.Button btn_save;
|
||||||
|
private System.Windows.Forms.SaveFileDialog dialog_save;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,15 @@
|
|||||||
using Manina.Windows.Forms;
|
using HeliosPlus.GameLibraries;
|
||||||
|
using HeliosPlus.Resources;
|
||||||
|
using HeliosPlus.Shared;
|
||||||
|
using Manina.Windows.Forms;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Drawing.IconLib;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -14,8 +20,9 @@ namespace HeliosPlus.UIForms
|
|||||||
public partial class ShortcutLibraryForm : Form
|
public partial class ShortcutLibraryForm : Form
|
||||||
{
|
{
|
||||||
|
|
||||||
List<Shortcut> _savedShortcuts = new List<Shortcut>();
|
|
||||||
private ShortcutAdaptor _shortcutAdaptor;
|
private ShortcutAdaptor _shortcutAdaptor;
|
||||||
|
private ImageListViewItem _selectedShortcutILVItem = null;
|
||||||
|
private Shortcut _selectedShortcut = null;
|
||||||
|
|
||||||
public ShortcutLibraryForm()
|
public ShortcutLibraryForm()
|
||||||
{
|
{
|
||||||
@ -27,6 +34,10 @@ namespace HeliosPlus.UIForms
|
|||||||
{
|
{
|
||||||
var shortcutForm = new ShortcutForm();
|
var shortcutForm = new ShortcutForm();
|
||||||
shortcutForm.ShowDialog(this);
|
shortcutForm.ShowDialog(this);
|
||||||
|
if (shortcutForm.DialogResult == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_selectedShortcut = shortcutForm.Shortcut;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btn_back_Click(object sender, EventArgs e)
|
private void btn_back_Click(object sender, EventArgs e)
|
||||||
@ -38,35 +49,98 @@ namespace HeliosPlus.UIForms
|
|||||||
{
|
{
|
||||||
// Load all the shortcuts we have saved earlier
|
// Load all the shortcuts we have saved earlier
|
||||||
List<Shortcut> _savedShortcuts = Shortcut.LoadAllShortcuts();
|
List<Shortcut> _savedShortcuts = Shortcut.LoadAllShortcuts();
|
||||||
// Refresh the Profile UI
|
// Refresh the Shortcut Library UI
|
||||||
RefreshDisplayProfileUI();
|
RefreshShortcutLibraryUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshDisplayProfileUI()
|
private void RefreshShortcutLibraryUI()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (_savedShortcuts.Count > 0)
|
if (Shortcut.AllSavedShortcuts.Count > 0)
|
||||||
{
|
{
|
||||||
// Temporarily stop updating the saved_profiles listview
|
// Temporarily stop updating the saved_profiles listview
|
||||||
ilv_saved_profiles.SuspendLayout();
|
ilv_saved_shortcuts.SuspendLayout();
|
||||||
|
|
||||||
ImageListViewItem newItem = null;
|
ImageListViewItem newItem = null;
|
||||||
foreach (Shortcut loadedShortcut in _savedShortcuts)
|
foreach (Shortcut loadedShortcut in Shortcut.AllSavedShortcuts)
|
||||||
{
|
{
|
||||||
bool thisLoadedProfileIsAlreadyHere = (from item in ilv_saved_profiles.Items where item.Text == loadedShortcut.Name select item.Text).Any();
|
bool thisLoadedProfileIsAlreadyHere = (from item in ilv_saved_shortcuts.Items where item.Text == loadedShortcut.Name select item.Text).Any();
|
||||||
if (!thisLoadedProfileIsAlreadyHere)
|
if (!thisLoadedProfileIsAlreadyHere)
|
||||||
{
|
{
|
||||||
newItem = new ImageListViewItem(loadedShortcut, loadedShortcut.Name);
|
newItem = new ImageListViewItem(loadedShortcut, loadedShortcut.Name);
|
||||||
//ilv_saved_profiles.Items.Add(newItem);
|
//ilv_saved_profiles.Items.Add(newItem);
|
||||||
ilv_saved_profiles.Items.Add(newItem, _shortcutAdaptor);
|
ilv_saved_shortcuts.Items.Add(newItem, _shortcutAdaptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restart updating the saved_profiles listview
|
// Restart updating the saved_profiles listview
|
||||||
ilv_saved_profiles.ResumeLayout();
|
ilv_saved_shortcuts.ResumeLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btn_save_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.None;
|
||||||
|
|
||||||
|
// Only do something if there is a shortcut selected
|
||||||
|
if (_selectedShortcut != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Set the Shortcut save folder to the Desktop as that's where people will want it most likely
|
||||||
|
dialog_save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
||||||
|
// Try to set up some sensible suggestions for the Shortcut name
|
||||||
|
if (_selectedShortcut.Permanence == ShortcutPermanence.Permanent)
|
||||||
|
{
|
||||||
|
|
||||||
|
dialog_save.FileName = _selectedShortcut.Name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_selectedShortcut.Category == ShortcutCategory.Application)
|
||||||
|
{
|
||||||
|
dialog_save.FileName = String.Concat(Path.GetFileNameWithoutExtension(_selectedShortcut.ExecutableNameAndPath), @" (", _selectedShortcut.Name.ToLower(CultureInfo.InvariantCulture), @")");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dialog_save.FileName = String.Concat(_selectedShortcut, @" (", _selectedShortcut.Name, @")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the Save Shortcut window
|
||||||
|
if (dialog_save.ShowDialog(this) == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_selectedShortcut.CreateShortcut(dialog_save.FileName))
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
Language.Shortcut_placed_successfully,
|
||||||
|
Language.Shortcut,
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
Language.Failed_to_create_the_shortcut_Unexpected_exception_occurred,
|
||||||
|
Language.Shortcut,
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Exclamation);
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog_save.FileName = string.Empty;
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, Language.Shortcut, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,9 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<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>
|
||||||
|
<metadata name="dialog_save.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
|
@ -9,6 +9,8 @@ using McMaster.Extensions.CommandLineUtils.Validation;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using HeliosPlus.Shared;
|
using HeliosPlus.Shared;
|
||||||
using HeliosPlus.GameLibraries;
|
using HeliosPlus.GameLibraries;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.ServiceModel.Dispatcher;
|
||||||
|
|
||||||
namespace HeliosPlus
|
namespace HeliosPlus
|
||||||
{
|
{
|
||||||
@ -41,6 +43,45 @@ namespace HeliosPlus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ShortcutMustExistValidator : IArgumentValidator
|
||||||
|
{
|
||||||
|
public ValidationResult GetValidationResult(CommandArgument argumentShortcutName, ValidationContext context)
|
||||||
|
{
|
||||||
|
// This validator only runs if there is a string provided
|
||||||
|
if (argumentShortcutName.Value == "") return ValidationResult.Success;
|
||||||
|
string shortcutNameProvided = (string) argumentShortcutName.Value;
|
||||||
|
string shortcutName = "";
|
||||||
|
|
||||||
|
// check if the shortcut name is surrounded by speech marks
|
||||||
|
int shortcutNameIndexLeft = shortcutNameProvided.IndexOf('"');
|
||||||
|
int shortcutNameIndexRight = shortcutNameProvided.LastIndexOf('"');
|
||||||
|
if (shortcutNameIndexLeft != -1 && shortcutNameIndexRight != -1 && shortcutNameIndexLeft != shortcutNameIndexRight)
|
||||||
|
{
|
||||||
|
MatchCollection matches = Regex.Matches(shortcutNameProvided, @"'(.*?)'");
|
||||||
|
shortcutName = matches[0].Groups[1].Value; // (Index 1 is the first group)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shortcutName = shortcutNameProvided;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create an array of shortcuts we have
|
||||||
|
var shortcuts = Shortcut.LoadAllShortcuts().ToArray();
|
||||||
|
// Check if the user supplied a valid shortcut name
|
||||||
|
int profileIndex = shortcuts.Length > 0 ? Array.FindIndex(shortcuts, p => p.Name.Contains(shortcutName)) : -1;
|
||||||
|
|
||||||
|
// If the profileID still isn't there, then raise the alarm
|
||||||
|
if (profileIndex == -1)
|
||||||
|
{
|
||||||
|
return new ValidationResult($"Couldn't find Shortcut Name supplied via command line: '{shortcutName}'. Please check the Shortcut Name you supplied on the command line is correct.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Using Shortcut: '{shortcuts[profileIndex].Name}'");
|
||||||
|
return ValidationResult.Success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class FileOptionMustExistValidator : IOptionValidator
|
class FileOptionMustExistValidator : IOptionValidator
|
||||||
{
|
{
|
||||||
public ValidationResult GetValidationResult(CommandOption optionFullFileName, ValidationContext context)
|
public ValidationResult GetValidationResult(CommandOption optionFullFileName, ValidationContext context)
|
||||||
@ -77,42 +118,4 @@ namespace HeliosPlus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SteamArgumentMustExistValidator : IArgumentValidator
|
|
||||||
{
|
|
||||||
public ValidationResult GetValidationResult(CommandArgument argumentSteamGameId, ValidationContext context)
|
|
||||||
{
|
|
||||||
// This validator only runs if there is a string provided
|
|
||||||
if (argumentSteamGameId.Value == "") return ValidationResult.Success;
|
|
||||||
var steamGameId = argumentSteamGameId.Value;
|
|
||||||
|
|
||||||
// Check that the Steam Game exists
|
|
||||||
/*if (!Steam.IsInstalled(steamGameId))
|
|
||||||
{
|
|
||||||
return new ValidationResult($"Couldn't find a Steam Game with ID '{argumentSteamGameId.Value}' within Steam. Please check you specified the correct Steam Game ID you supplied in the --steam '{argumentSteamGameId.Name}' command line argument.");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return ValidationResult.Success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class UplayArgumentMustExistValidator : IArgumentValidator
|
|
||||||
{
|
|
||||||
public ValidationResult GetValidationResult(CommandArgument argumentUplayGameId, ValidationContext context)
|
|
||||||
{
|
|
||||||
// This validator only runs if there is a string provided
|
|
||||||
if (argumentUplayGameId.Value == "") return ValidationResult.Success;
|
|
||||||
var steamGameId = argumentUplayGameId.Value;
|
|
||||||
|
|
||||||
// Check that the Uplay Game exists
|
|
||||||
/*if (!Steam.IsInstalled(uplayGameId))
|
|
||||||
{
|
|
||||||
return new ValidationResult($"Couldn't find a Uplay Game with ID '{argumentUplayGameId.Value}' within Uplay. Please check you specified the correct Uplay Game ID you supplied in the --steam '{argumentUplayGameId.Name}' command line argument.");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return ValidationResult.Success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user