Skip to content

Commit

Permalink
Merge pull request #557 from emoacht/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
emoacht authored Jan 8, 2024
2 parents afd60aa + 991ee1d commit 482c039
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 27 deletions.
3 changes: 1 addition & 2 deletions Source/IconImage/DarkAppIcon.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
</UserControl.Resources>

<Grid Background="{x:Null}">
<!--<Rectangle Fill="{StaticResource BackBrush}"/>-->
<Rectangle Fill="{StaticResource BackBrush}" RadiusX="20" RadiusY="20"/>
<Rectangle Fill="{StaticResource BackBrush}" RadiusX="28" RadiusY="28"/>

<Grid>
<Border BorderBrush="{StaticResource EdgeBrush}"
Expand Down
4 changes: 2 additions & 2 deletions Source/IconImage/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.6.0.0")]
[assembly: AssemblyFileVersion("4.6.0.0")]
[assembly: AssemblyVersion("4.6.2.0")]
[assembly: AssemblyFileVersion("4.6.2.0")]
2 changes: 1 addition & 1 deletion Source/Installer/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Monitorian" Manufacturer="emoacht" Version="4.6.1"
<Product Id="*" Name="Monitorian" Manufacturer="emoacht" Version="4.6.2"
Language="1033" Codepage="1252" UpgradeCode="{81A4D148-75D3-462E-938D-8C208FB48E3C}">
<Package Id="*" InstallerVersion="500" Compressed="yes"
InstallScope="perMachine" InstallPrivileges="elevated"
Expand Down
41 changes: 25 additions & 16 deletions Source/Monitorian.Core/AppKeeper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task<bool> StartAsync(StartupEventArgs e, IEnumerable<string> addit

SubscribeExceptions();

var (success, response) = StartupAgent.Start(ProductInfo.Product, ProductInfo.StartupTaskId, OtherArguments);
var (success, response) = StartupAgent.Start(ProductInfo.Product, ProductInfo.StartupTaskId, ForwardingArguments);
if (!success && (response is not null))
{
ConsoleService.WriteLine(response);
Expand Down Expand Up @@ -66,6 +66,9 @@ public void Write(string content)
public static IReadOnlyList<string> OtherArguments => _otherArguments?.ToArray() ?? [];
private static string[] _otherArguments;

public static IReadOnlyList<string> ForwardingArguments => _forwardingArguments?.ToArray() ?? [];
private static string[] _forwardingArguments;

public static IEnumerable<string> EnumerateStandardOptions() =>
new[]
{
Expand All @@ -78,26 +81,32 @@ public static IEnumerable<string> EnumerateStandardOptions() =>

private async Task ParseArgumentsAsync(StartupEventArgs e, string[] standardOptions)
{
// Load persistent arguments.
var args = (await LoadArgumentsAsync())?.Split() ?? [];

// Concatenate current and persistent arguments.
// Divide current arguments.
// The first element of StartupEventArgs.Args is not executing assembly's path unlike
// that of arguments provided by Environment.GetCommandLineArgs method.
args = e.Args.Concat(args.Select(x => x.Trim('"'))).ToArray();
if (args is not { Length: > 0 })
return;
var (currentStandard, currentOther) = Divide(e.Args);

const char optionMark = '/';
var isStandard = false;
// Divide persistent arguments.
var persistentArgs = (await LoadArgumentsAsync())?.Split().Select(x => x.Trim('"'));
var (persistentStandard, persistentOther) = Divide(persistentArgs);

var buffer = args
.Where(x => !string.IsNullOrWhiteSpace(x))
.GroupBy(x => (x[0] == optionMark) ? (isStandard = standardOptions.Contains(x.ToLower())) : isStandard)
.ToArray();
_standardArguments = persistentStandard.Concat(currentStandard).ToArray();
_forwardingArguments = currentOther.ToArray();
_otherArguments = persistentOther.Concat(_forwardingArguments).ToArray();

_standardArguments = buffer.SingleOrDefault(x => x.Key)?.ToArray();
_otherArguments = buffer.SingleOrDefault(x => !x.Key)?.ToArray();
(IEnumerable<string> standard, IEnumerable<string> other) Divide(IEnumerable<string> args)
{
const char optionMark = '/';
var isStandard = false;

var buffer = args
.Where(x => !string.IsNullOrWhiteSpace(x))
.GroupBy(x => (x[0] == optionMark) ? (isStandard = standardOptions.Contains(x.ToLower())) : isStandard)
.ToArray() ?? [];

return (standard: buffer.SingleOrDefault(x => x.Key) ?? Enumerable.Empty<string>(),
other: buffer.SingleOrDefault(x => !x.Key) ?? Enumerable.Empty<string>());
}
}

private const string ArgumentsFileName = "arguments.txt";
Expand Down
4 changes: 2 additions & 2 deletions Source/Monitorian.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.6.1.0")]
[assembly: AssemblyFileVersion("4.6.1.0")]
[assembly: AssemblyVersion("4.6.2.0")]
[assembly: AssemblyFileVersion("4.6.2.0")]
[assembly: NeutralResourcesLanguage("en-US")]

// For unit test
Expand Down
4 changes: 2 additions & 2 deletions Source/Monitorian/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.6.1.0")]
[assembly: AssemblyFileVersion("4.6.1.0")]
[assembly: AssemblyVersion("4.6.2.0")]
[assembly: AssemblyFileVersion("4.6.2.0")]
[assembly: Guid("a4cc5362-9b08-465b-ad64-5cfabc72a4c7")]
[assembly: NeutralResourcesLanguage("en-US")]
Binary file modified Source/Monitorian/Resources/Icons/AppIcon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion Source/StartupAgency/PipeHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public PipeHolder(string name, Func<string[], Task<string>> handleRequestAsync)
/// <summary>
/// Creates <see cref="System.Threading.Semaphore"/> to start named pipes.
/// </summary>
/// <param name="args">Arguments to another instance</param>
/// <param name="args">Arguments being forwarded to another instance</param>
/// <returns>
/// <para>success: True if no other instance exists and this instance successfully creates</para>
/// <para>response: Response from another instance if that instance exists and returns an response</para>
Expand Down
2 changes: 1 addition & 1 deletion Source/StartupAgency/StartupAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class StartupAgent : IDisposable
/// </summary>
/// <param name="name">Name</param>
/// <param name="startupTaskId">Startup task ID</param>
/// <param name="args">Arguments to another instance</param>
/// <param name="args">Arguments being forwarded to another instance</param>
/// <returns>
/// <para>success: True if no other instance exists and this instance successfully starts</para>
/// <para>response: Response from another instance if that instance exists and returns an response</para>
Expand Down

0 comments on commit 482c039

Please sign in to comment.