mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-10 06:17:01 +01:00
Compare commits
3 Commits
copilot/fi
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d541e52d8 | ||
|
|
26e250b6f4 | ||
|
|
eb35b3a249 |
@@ -49,7 +49,9 @@ namespace Awake.Core
|
||||
|
||||
private static DateTimeOffset ExpireAt { get; set; }
|
||||
|
||||
private static readonly CompositeFormat AwakeMinute = CompositeFormat.Parse(Resources.AWAKE_MINUTE);
|
||||
private static readonly CompositeFormat AwakeMinutes = CompositeFormat.Parse(Resources.AWAKE_MINUTES);
|
||||
private static readonly CompositeFormat AwakeHour = CompositeFormat.Parse(Resources.AWAKE_HOUR);
|
||||
private static readonly CompositeFormat AwakeHours = CompositeFormat.Parse(Resources.AWAKE_HOURS);
|
||||
private static readonly BlockingCollection<ExecutionState> _stateQueue;
|
||||
private static CancellationTokenSource _tokenSource;
|
||||
@@ -451,7 +453,7 @@ namespace Awake.Core
|
||||
Dictionary<string, uint> optionsList = new()
|
||||
{
|
||||
{ string.Format(CultureInfo.InvariantCulture, AwakeMinutes, 30), 1800 },
|
||||
{ string.Format(CultureInfo.InvariantCulture, AwakeHours, 1), 3600 },
|
||||
{ string.Format(CultureInfo.InvariantCulture, AwakeHour, 1), 3600 },
|
||||
{ string.Format(CultureInfo.InvariantCulture, AwakeHours, 2), 7200 },
|
||||
};
|
||||
return optionsList;
|
||||
|
||||
@@ -159,6 +159,15 @@ namespace Awake.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} hour.
|
||||
/// </summary>
|
||||
internal static string AWAKE_HOUR {
|
||||
get {
|
||||
return ResourceManager.GetString("AWAKE_HOUR", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} hours.
|
||||
/// </summary>
|
||||
@@ -240,6 +249,15 @@ namespace Awake.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} minute.
|
||||
/// </summary>
|
||||
internal static string AWAKE_MINUTE {
|
||||
get {
|
||||
return ResourceManager.GetString("AWAKE_MINUTE", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} minutes.
|
||||
/// </summary>
|
||||
|
||||
@@ -123,6 +123,10 @@
|
||||
<data name="AWAKE_EXIT" xml:space="preserve">
|
||||
<value>Exit</value>
|
||||
</data>
|
||||
<data name="AWAKE_HOUR" xml:space="preserve">
|
||||
<value>{0} hour</value>
|
||||
<comment>{0} shouldn't be removed. It will be replaced by the number 1 at runtime by the application. Used for defining a period to keep the PC awake.</comment>
|
||||
</data>
|
||||
<data name="AWAKE_HOURS" xml:space="preserve">
|
||||
<value>{0} hours</value>
|
||||
<comment>{0} shouldn't be removed. It will be replaced by a number greater than 1 at runtime by the application. Used for defining a period to keep the PC awake.</comment>
|
||||
@@ -142,6 +146,10 @@
|
||||
<value>Keep awake until expiration date and time</value>
|
||||
<comment>Keep the system awake until expiration date and time</comment>
|
||||
</data>
|
||||
<data name="AWAKE_MINUTE" xml:space="preserve">
|
||||
<value>{0} minute</value>
|
||||
<comment>{0} shouldn't be removed. It will be replaced by the number 1 at runtime by the application. Used for defining a period to keep the PC awake.</comment>
|
||||
</data>
|
||||
<data name="AWAKE_MINUTES" xml:space="preserve">
|
||||
<value>{0} minutes</value>
|
||||
<comment>{0} shouldn't be removed. It will be replaced by a number greater than 1 at runtime by the application. Used for defining a period to keep the PC awake.</comment>
|
||||
|
||||
@@ -32,12 +32,12 @@ public partial class ImageSize : INotifyPropertyChanged, IHasId
|
||||
|
||||
public ImageSize(int id = 0, string name = "", ResizeFit fit = ResizeFit.Fit, double width = 0, double height = 0, ResizeUnit unit = ResizeUnit.Pixel)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
Fit = fit;
|
||||
Width = width;
|
||||
Height = height;
|
||||
Unit = unit;
|
||||
_id = id;
|
||||
_name = name;
|
||||
_fit = fit;
|
||||
_width = width < 0 || double.IsNaN(width) ? 0 : width;
|
||||
_height = height < 0 || double.IsNaN(height) ? 0 : height;
|
||||
_unit = unit;
|
||||
}
|
||||
|
||||
private int _id;
|
||||
@@ -105,8 +105,16 @@ public partial class ImageSize : INotifyPropertyChanged, IHasId
|
||||
get => _unit;
|
||||
set
|
||||
{
|
||||
var previousUnit = _unit;
|
||||
if (SetProperty(ref _unit, value))
|
||||
{
|
||||
// When switching to Percent unit, set width and height to 100 (representing 100%)
|
||||
if (value == ResizeUnit.Percent && previousUnit != ResizeUnit.Percent)
|
||||
{
|
||||
Width = 100.0;
|
||||
Height = 100.0;
|
||||
}
|
||||
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsHeightUsed)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.UnitTests.ModelsTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ImageSizeTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void WhenUnitChangesToPercent_WidthShouldBeSetTo100()
|
||||
{
|
||||
// Arrange
|
||||
var imageSize = new ImageSize(1, "Test", ResizeFit.Fit, 854, 480, ResizeUnit.Pixel);
|
||||
|
||||
// Act
|
||||
imageSize.Unit = ResizeUnit.Percent;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(100.0, imageSize.Width, "Width should be set to 100 when switching to Percent unit");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WhenUnitChangesToPercent_HeightShouldBeSetTo100()
|
||||
{
|
||||
// Arrange
|
||||
var imageSize = new ImageSize(1, "Test", ResizeFit.Stretch, 854, 480, ResizeUnit.Pixel);
|
||||
|
||||
// Act
|
||||
imageSize.Unit = ResizeUnit.Percent;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(100.0, imageSize.Height, "Height should be set to 100 when switching to Percent unit");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WhenUnitChangesFromPercentToPixel_ValuesShouldNotChange()
|
||||
{
|
||||
// Arrange
|
||||
var imageSize = new ImageSize(1, "Test", ResizeFit.Fit, 50, 75, ResizeUnit.Percent);
|
||||
|
||||
// Act
|
||||
imageSize.Unit = ResizeUnit.Pixel;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(50.0, imageSize.Width, "Width should remain unchanged when switching from Percent to other units");
|
||||
Assert.AreEqual(75.0, imageSize.Height, "Height should remain unchanged when switching from Percent to other units");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WhenUnitRemainsPercent_ValuesShouldNotChange()
|
||||
{
|
||||
// Arrange
|
||||
var imageSize = new ImageSize(1, "Test", ResizeFit.Fit, 75, 60, ResizeUnit.Percent);
|
||||
|
||||
// Act
|
||||
imageSize.Unit = ResizeUnit.Percent;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(75.0, imageSize.Width, "Width should remain unchanged when unit stays as Percent");
|
||||
Assert.AreEqual(60.0, imageSize.Height, "Height should remain unchanged when unit stays as Percent");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user