Skip to content

Commit

Permalink
Merge pull request #544 from emoacht/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
emoacht authored Dec 8, 2023
2 parents a226d09 + 1c16a7c commit 262a5c0
Show file tree
Hide file tree
Showing 40 changed files with 280 additions and 64 deletions.
3 changes: 2 additions & 1 deletion Source/IconImage/DarkAppIcon.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
</UserControl.Resources>

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

<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.5.0.0")]
[assembly: AssemblyFileVersion("4.5.0.0")]
[assembly: AssemblyVersion("4.6.0.0")]
[assembly: AssemblyFileVersion("4.6.0.0")]
9 changes: 8 additions & 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.5.1"
<Product Id="*" Name="Monitorian" Manufacturer="emoacht" Version="4.6.0"
Language="1033" Codepage="1252" UpgradeCode="{81A4D148-75D3-462E-938D-8C208FB48E3C}">
<Package Id="*" InstallerVersion="500" Compressed="yes"
InstallScope="perMachine" InstallPrivileges="elevated"
Expand Down Expand Up @@ -101,6 +101,12 @@
<File Id="CoreResourcesLibrary_de" Name="$(var.Monitorian.TargetName).Core.resources.dll" KeyPath="yes"/>
</Component>
</Directory>
<Directory Id="ResourcesFolder_elGR" Name="el-GR"
FileSource="$(var.Monitorian.TargetDir)el-GR">
<Component Id="CoreResourcesLibrary_elGR" Guid="{D8FA6F67-57B7-45AA-8C81-C323A50787DE}">
<File Id="CoreResourcesLibrary_elGR" Name="$(var.Monitorian.TargetName).Core.resources.dll" KeyPath="yes"/>
</Component>
</Directory>
<Directory Id="ResourcesFolder_es" Name="es"
FileSource="$(var.Monitorian.TargetDir)es">
<Component Id="CoreResourcesLibrary_es" Guid="{4329EAB1-6FC9-41F4-8A6E-77FA6C67B15C}">
Expand Down Expand Up @@ -224,6 +230,7 @@
<ComponentRef Id="CoreResourcesLibrary_ar"/>
<ComponentRef Id="CoreResourcesLibrary_ca"/>
<ComponentRef Id="CoreResourcesLibrary_de"/>
<ComponentRef Id="CoreResourcesLibrary_elGR"/>
<ComponentRef Id="CoreResourcesLibrary_es"/>
<ComponentRef Id="CoreResourcesLibrary_fr"/>
<ComponentRef Id="CoreResourcesLibrary_it"/>
Expand Down
1 change: 0 additions & 1 deletion Source/Monitorian.Core/AppControllerCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ protected virtual void Update(string instanceName, int brightness)
protected virtual async Task UpdateMessageAsync(string deviceInstanceId, string message)
{
var monitor = Monitors.FirstOrDefault(x => string.Equals(x.DeviceInstanceId, deviceInstanceId, StringComparison.OrdinalIgnoreCase));
System.Diagnostics.Debug.WriteLine(message);
if (monitor is not null)
{
await monitor.ShowNormalMessageAsync(message, TimeSpan.FromSeconds(30));
Expand Down
8 changes: 4 additions & 4 deletions Source/Monitorian.Core/AppKeeper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public AppKeeper()
StartupAgent = new StartupAgent();
}

public Task<bool> StartAsync(StartupEventArgs e) => StartAsync(e, Enumerable.Empty<string>());
public Task<bool> StartAsync(StartupEventArgs e) => StartAsync(e, []);

public async Task<bool> StartAsync(StartupEventArgs e, IEnumerable<string> additionalOptions)
{
Expand Down Expand Up @@ -60,10 +60,10 @@ public void Write(string content)

#region Arguments

public static IReadOnlyList<string> StandardArguments => _standardArguments?.ToArray() ?? Array.Empty<string>();
public static IReadOnlyList<string> StandardArguments => _standardArguments?.ToArray() ?? [];
private static string[] _standardArguments;

public static IReadOnlyList<string> OtherArguments => _otherArguments?.ToArray() ?? Array.Empty<string>();
public static IReadOnlyList<string> OtherArguments => _otherArguments?.ToArray() ?? [];
private static string[] _otherArguments;

public static IEnumerable<string> EnumerateStandardOptions() =>
Expand All @@ -79,7 +79,7 @@ public static IEnumerable<string> EnumerateStandardOptions() =>
private async Task ParseArgumentsAsync(StartupEventArgs e, string[] standardOptions)
{
// Load persistent arguments.
var args = (await LoadArgumentsAsync())?.Split() ?? Array.Empty<string>();
var args = (await LoadArgumentsAsync())?.Split() ?? [];

// Concatenate current and persistent arguments.
// The first element of StartupEventArgs.Args is not executing assembly's path unlike
Expand Down
6 changes: 3 additions & 3 deletions Source/Monitorian.Core/Helper/ExceptionExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static string ToDetailedString(this Exception ex)
{
innerExceptions = (ex.InnerException is not null)
? new Exception[] { ex.InnerException }
: Array.Empty<Exception>();
: [];

foreach (var property in EnumerateAddedProperties(ex))
{
Expand Down Expand Up @@ -61,12 +61,12 @@ private static IEnumerable<PropertyInfo> EnumerateAddedProperties(Exception ex)

private static string GetEnvironmentString(string key)
{
var method = typeof(Environment).GetMethod("GetResourceString", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(string) }, null);
var method = typeof(Environment).GetMethod("GetResourceString", BindingFlags.NonPublic | BindingFlags.Static, null, [typeof(string)], null);

string buffer = null;
try
{
buffer = method?.Invoke(null, new object[] { key }) as string;
buffer = method?.Invoke(null, [key]) as string;
}
catch
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Monitorian.Core/Helper/OsVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ internal static class OsVersion

#region Cache

private static readonly Dictionary<string, bool> _cache = new();
private static readonly Dictionary<string, bool> _cache = [];
private static readonly object _lock = new();

private static bool IsEqualToOrGreaterThan(in int major, in int minor = 0, in int build = 0, [CallerMemberName] string propertyName = null)
Expand Down
6 changes: 2 additions & 4 deletions Source/Monitorian.Core/Helper/SimpleSerialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ public static string ConvertCollectionValue(string value) =>
IsPrettified ? Indent + ConvertValue(value) : value;
}

public class StringWrapper
public class StringWrapper(string value)
{
private readonly string _value;

public StringWrapper(string value) => this._value = value;
private readonly string _value = value;

public override string ToString() => _value;
}
2 changes: 1 addition & 1 deletion Source/Monitorian.Core/Helper/Throttle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class Throttle<T>
{
protected readonly SemaphoreSlim _semaphore = new(1, 1);
protected readonly DispatcherTimer _timer;
protected readonly Queue<T> _queue = new();
protected readonly Queue<T> _queue = [];
protected readonly Action<T[]> _action;

public Throttle(TimeSpan dueTime, Action<T[]> action)
Expand Down
2 changes: 1 addition & 1 deletion Source/Monitorian.Core/Models/DocumentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static string BuildHtml(string fileName, string title, string body)
title = Path.GetFileNameWithoutExtension(fileName);

body = body?
.Split(new[] { "\r\n\r\n", "\n\n" /* two consecutive line breaks */ }, StringSplitOptions.RemoveEmptyEntries)
.Split(["\r\n\r\n", "\n\n" /* two consecutive line breaks */ ], StringSplitOptions.RemoveEmptyEntries)
.Select(x =>
{
var array = x.Split(Array.Empty<char>(), 2, StringSplitOptions.RemoveEmptyEntries);
Expand Down
2 changes: 1 addition & 1 deletion Source/Monitorian.Core/Models/LanguageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Monitorian.Core.Models;

public class LanguageService
{
public static IReadOnlyCollection<string> Options => new[] { Option };
public static IReadOnlyCollection<string> Options => [Option];

private const string Option = "/lang";

Expand Down
2 changes: 1 addition & 1 deletion Source/Monitorian.Core/Models/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ private static void UpdateContent(string filePath, string newContent, int capaci

static string TruncateSections(string content, string sectionHeader, int sectionCount)
{
var firstIndex = content.StartsWith(sectionHeader, StringComparison.Ordinal) ? new[] { 0 } : Enumerable.Empty<int>();
var firstIndex = content.StartsWith(sectionHeader, StringComparison.Ordinal) ? new[] { 0 } : [];
var secondIndices = content.IndicesOf('\n' /* either CR+Lf or Lf */ + sectionHeader, StringComparison.Ordinal).Select(x => x + 1);
var indices = firstIndex.Concat(secondIndices).ToArray();

Expand Down
2 changes: 1 addition & 1 deletion Source/Monitorian.Core/Models/Monitor/DeviceConversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static bool TryParseToDeviceInstanceId(string source, out string deviceIn
{
if (buffer.StartsWith("DISPLAY", StringComparison.Ordinal))
{
var fields = buffer.Split(new[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
var fields = buffer.Split([@"\"], StringSplitOptions.RemoveEmptyEntries);
if (fields is { Length: 3 })
{
deviceInstanceId = string.Join(@"\", fields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void Close()

public static event EventHandler<string> AdvancedColorInfoChanged;

private static readonly List<Holder> _holders = new();
private static readonly List<Holder> _holders = [];
private static readonly object _registerLock = new();

public static Action RegisterMonitor(string deviceInstanceId, IntPtr monitorHandle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static async Task<DisplayItem[]> GetDisplayMonitorsAsync()

try
{
var devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Display.DisplayMonitor.GetDeviceSelector(), new[] { deviceInstanceIdKey });
var devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Display.DisplayMonitor.GetDeviceSelector(), [deviceInstanceIdKey]);
if (devices is { Count: > 0 })
{
var items = new List<DisplayItem>(devices.Count);
Expand Down
6 changes: 5 additions & 1 deletion Source/Monitorian.Core/Models/Monitor/IMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public class ValueData
public ValueData(byte value, IEnumerable<byte> values)
{
this.Value = value;
this.Values = Array.AsReadOnly(values.ToArray());

if (values is not null)
{
this.Values = Array.AsReadOnly(values.ToArray());
}
}
}
2 changes: 1 addition & 1 deletion Source/Monitorian.Core/Models/Monitor/MSMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class DesktopItem
[OnSerializing]
private void OnSerializing(StreamingContext context)
{
_brightnessLevelsString = string.Join(" ", BrightnessLevels ?? Enumerable.Empty<byte>());
_brightnessLevelsString = string.Join(" ", BrightnessLevels ?? []);
}

public DesktopItem(
Expand Down
2 changes: 1 addition & 1 deletion Source/Monitorian.Core/Models/Monitor/PowerManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private struct SYSTEM_POWER_STATUS
/// <summary>
/// Options
/// </summary>
public static IReadOnlyCollection<string> Options => new[] { PowerBindOption };
public static IReadOnlyCollection<string> Options => [PowerBindOption];

private const string PowerBindOption = "/powerbind";

Expand Down
2 changes: 1 addition & 1 deletion Source/Monitorian.Core/Models/OperationRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Task RecordAsync(string content)
public void StartLineRecord(string key, string actionName)
{
if (IsEnabled)
_actionLines.Value[key] = new List<string>(new[] { actionName });
_actionLines.Value[key] = new List<string>([actionName]);
}

public void AddLineRecord(string key, string lineString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private static string FindFamilyName(string identityName)
/// <summary>
/// Options
/// </summary>
public static IReadOnlyCollection<string> Options => new[] { ConnectOption };
public static IReadOnlyCollection<string> Options => [ConnectOption];

private const string ConnectOption = "/connect";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal class DisplayInformationWatcher : IDisposable
/// <summary>
/// Options
/// </summary>
public static IReadOnlyCollection<string> Options => new[] { AdvancedColorOption };
public static IReadOnlyCollection<string> Options => [AdvancedColorOption];

private const string AdvancedColorOption = "/advancedcolor";

Expand All @@ -39,10 +39,10 @@ public void Subscribe(Action<string, string> onDisplayInformationChanged)
return;

this._onDisplayInformationChanged = onDisplayInformationChanged ?? throw new ArgumentNullException(nameof(onDisplayInformationChanged));
DisplayInformationProvider.AdvancedColorInfoChanged += OnAdvanctedColorInfoChanged;
DisplayInformationProvider.AdvancedColorInfoChanged += OnAdvancedColorInfoChanged;
}

private void OnAdvanctedColorInfoChanged(object sender, string e)
private void OnAdvancedColorInfoChanged(object sender, string e)
{
var colorInfo = ((Windows.Graphics.Display.DisplayInformation)sender).GetAdvancedColorInfo();
_onDisplayInformationChanged?.Invoke(e, $"SDR WL: {colorInfo.SdrWhiteLevelInNits} Min: {colorInfo.MinLuminanceInNits:f1} Max: {colorInfo.MaxLuminanceInNits:f1} [{colorInfo.CurrentAdvancedColorKind}]");
Expand Down Expand Up @@ -74,7 +74,7 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
// Free any other managed objects here.
DisplayInformationProvider.AdvancedColorInfoChanged -= OnAdvanctedColorInfoChanged;
DisplayInformationProvider.AdvancedColorInfoChanged -= OnAdvancedColorInfoChanged;
DisplayInformationProvider.ClearMonitors();
}

Expand Down
8 changes: 6 additions & 2 deletions Source/Monitorian.Core/Monitorian.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@
<DependentUpon>Resources.resx</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.el-GR.resx">
<DependentUpon>Resources.resx</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.es.resx">
<DependentUpon>Resources.resx</DependentUpon>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -275,10 +279,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.Contracts">
<Version>10.0.22621.755</Version>
<Version>10.0.22621.2428</Version>
</PackageReference>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf">
<Version>1.1.39</Version>
<Version>1.1.77</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
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.5.1.0")]
[assembly: AssemblyFileVersion("4.5.1.0")]
[assembly: AssemblyVersion("4.6.0.0")]
[assembly: AssemblyFileVersion("4.6.0.0")]
[assembly: NeutralResourcesLanguage("en-US")]

// For unit test
Expand Down
Loading

0 comments on commit 262a5c0

Please sign in to comment.