mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-21 07:17:56 +08:00
Merge remote-tracking branch 'origin/main' into dev/snickler/net8-upgrade
This commit is contained in:
commit
d6026b0ea1
1
.github/actions/spell-check/expect.txt
vendored
1
.github/actions/spell-check/expect.txt
vendored
@ -1983,6 +1983,7 @@ uipi
|
|||||||
UIs
|
UIs
|
||||||
ULARGE
|
ULARGE
|
||||||
ULONGLONG
|
ULONGLONG
|
||||||
|
ums
|
||||||
unapply
|
unapply
|
||||||
unassign
|
unassign
|
||||||
uncompilable
|
uncompilable
|
||||||
|
@ -204,6 +204,7 @@ steps:
|
|||||||
**\UnitTests-PdfThumbnailProvider.dll
|
**\UnitTests-PdfThumbnailProvider.dll
|
||||||
**\Settings.UI.UnitTests.dll
|
**\Settings.UI.UnitTests.dll
|
||||||
**\UnitTests-GcodePreviewHandler.dll
|
**\UnitTests-GcodePreviewHandler.dll
|
||||||
|
**\UnitTests-FancyZonesEditor.dll
|
||||||
**\UnitTests-PdfPreviewHandler.dll
|
**\UnitTests-PdfPreviewHandler.dll
|
||||||
**\UnitTests-PreviewHandlerCommon.dll
|
**\UnitTests-PreviewHandlerCommon.dll
|
||||||
**\Microsoft.PowerToys.Run.Plugin.Registry.UnitTests.dll
|
**\Microsoft.PowerToys.Run.Plugin.Registry.UnitTests.dll
|
||||||
|
@ -537,6 +537,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CropAndLock", "src\modules\
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CropAndLockModuleInterface", "src\modules\CropAndLock\CropAndLockModuleInterface\CropAndLockModuleInterface.vcxproj", "{3157FA75-86CF-4EE2-8F62-C43F776493C6}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CropAndLockModuleInterface", "src\modules\CropAndLock\CropAndLockModuleInterface\CropAndLockModuleInterface.vcxproj", "{3157FA75-86CF-4EE2-8F62-C43F776493C6}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-FancyZonesEditor", "src\modules\fancyzones\UnitTests-FancyZonesEditor\UnitTests-FancyZonesEditor.csproj", "{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|ARM64 = Debug|ARM64
|
Debug|ARM64 = Debug|ARM64
|
||||||
@ -2307,6 +2309,18 @@ Global
|
|||||||
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x64.Build.0 = Release|x64
|
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x64.Build.0 = Release|x64
|
||||||
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x86.ActiveCfg = Release|x64
|
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x86.ActiveCfg = Release|x64
|
||||||
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x86.Build.0 = Release|x64
|
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x86.Build.0 = Release|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|x86.ActiveCfg = Debug|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|x86.Build.0 = Debug|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Release|ARM64.Build.0 = Release|ARM64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Release|x64.Build.0 = Release|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Release|x86.ActiveCfg = Release|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Release|x86.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -2501,6 +2515,7 @@ Global
|
|||||||
{3B227528-4BA6-4CAF-B44A-A10C78A64849} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC}
|
{3B227528-4BA6-4CAF-B44A-A10C78A64849} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC}
|
||||||
{F5E1146E-B7B3-4E11-85FD-270A500BD78C} = {3B227528-4BA6-4CAF-B44A-A10C78A64849}
|
{F5E1146E-B7B3-4E11-85FD-270A500BD78C} = {3B227528-4BA6-4CAF-B44A-A10C78A64849}
|
||||||
{3157FA75-86CF-4EE2-8F62-C43F776493C6} = {3B227528-4BA6-4CAF-B44A-A10C78A64849}
|
{3157FA75-86CF-4EE2-8F62-C43F776493C6} = {3B227528-4BA6-4CAF-B44A-A10C78A64849}
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
||||||
|
@ -18,6 +18,7 @@ The 'Time and Date' plugin shows the date and time in different formats. For the
|
|||||||
**Remarks**
|
**Remarks**
|
||||||
- The following formats requires a prefix in the query:
|
- The following formats requires a prefix in the query:
|
||||||
- Unix Timestamp: `u`
|
- Unix Timestamp: `u`
|
||||||
|
- Unix Timestamp in milliseconds: `ums`
|
||||||
- Windows file time: `ft`
|
- Windows file time: `ft`
|
||||||
- On invalid number inputs we show a warning that tells the user which prefixes are allowed/required.
|
- On invalid number inputs we show a warning that tells the user which prefixes are allowed/required.
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ The following formats are currently available:
|
|||||||
| Time UTC | 4:10 PM | x | x |
|
| Time UTC | 4:10 PM | x | x |
|
||||||
| Now UTC | 3/5/2022 4:10 PM | x | x |
|
| Now UTC | 3/5/2022 4:10 PM | x | x |
|
||||||
| Unix Timestamp | 1646496622 | x | x |
|
| Unix Timestamp | 1646496622 | x | x |
|
||||||
|
| Unix Timestamp in milliseconds | 1646496622500 | x | x |
|
||||||
| Hour | 10 | x | |
|
| Hour | 10 | x | |
|
||||||
| Minute | 30 | x | |
|
| Minute | 30 | x | |
|
||||||
| Second | 45 | x | |
|
| Second | 45 | x | |
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
// 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 FancyZonesEditor.Models;
|
||||||
|
|
||||||
|
namespace UnitTestsFancyZonesEditor;
|
||||||
|
|
||||||
|
[TestClass]
|
||||||
|
public class DefaultLayoutsModelTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void OverridingLayoutClearsOldDefault()
|
||||||
|
{
|
||||||
|
var defaultLayoutsModel = new DefaultLayoutsModel();
|
||||||
|
GridLayoutModel firstLayout = new GridLayoutModel();
|
||||||
|
CanvasLayoutModel secondLayout = new CanvasLayoutModel("steve");
|
||||||
|
|
||||||
|
defaultLayoutsModel.Set(firstLayout, MonitorConfigurationType.Horizontal);
|
||||||
|
Assert.AreEqual(defaultLayoutsModel.Layouts[(int)MonitorConfigurationType.Horizontal], firstLayout);
|
||||||
|
|
||||||
|
defaultLayoutsModel.Set(secondLayout, MonitorConfigurationType.Horizontal);
|
||||||
|
Assert.AreNotEqual(defaultLayoutsModel.Layouts[(int)MonitorConfigurationType.Horizontal], firstLayout);
|
||||||
|
Assert.AreEqual(defaultLayoutsModel.Layouts[(int)MonitorConfigurationType.Horizontal], secondLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void SettingTheVerticalLayoutShouldBeTheDefault()
|
||||||
|
{
|
||||||
|
var defaultLayoutsModel = new DefaultLayoutsModel();
|
||||||
|
GridLayoutModel firstLayout = new GridLayoutModel();
|
||||||
|
defaultLayoutsModel.Set(firstLayout, MonitorConfigurationType.Horizontal);
|
||||||
|
defaultLayoutsModel.Set(firstLayout, MonitorConfigurationType.Vertical);
|
||||||
|
|
||||||
|
Assert.AreEqual(defaultLayoutsModel.Layouts[MonitorConfigurationType.Vertical], firstLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void RestoringLayoutShouldSetLayouts()
|
||||||
|
{
|
||||||
|
var defaultLayoutsModel = new DefaultLayoutsModel();
|
||||||
|
GridLayoutModel firstLayout = new GridLayoutModel();
|
||||||
|
CanvasLayoutModel secondLayout = new CanvasLayoutModel("steve");
|
||||||
|
var restoredLayouts = new Dictionary<MonitorConfigurationType, LayoutModel> { { MonitorConfigurationType.Horizontal, firstLayout }, { MonitorConfigurationType.Vertical, secondLayout } };
|
||||||
|
defaultLayoutsModel.Restore(restoredLayouts);
|
||||||
|
|
||||||
|
CollectionAssert.AreEqual(defaultLayoutsModel.Layouts, restoredLayouts);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
// 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 FancyZonesEditor.Models;
|
||||||
|
|
||||||
|
namespace UnitTestsFancyZonesEditor;
|
||||||
|
|
||||||
|
[TestClass]
|
||||||
|
public class GridLayoutModelTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void EmptyGridLayoutModelIsNotValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
Assert.IsFalse(gridLayoutModel.IsModelValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GridLayoutModelWithInvalidRowAndColumnCountsIsNotValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
gridLayoutModel.Rows = 0;
|
||||||
|
gridLayoutModel.Columns = 0;
|
||||||
|
Assert.IsFalse(gridLayoutModel.IsModelValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GridLayoutModelWithInvalidRowPercentsIsNotValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
gridLayoutModel.Rows = 1;
|
||||||
|
gridLayoutModel.Columns = 1;
|
||||||
|
gridLayoutModel.RowPercents = new List<int> { 0 }; // Invalid percentage
|
||||||
|
Assert.IsFalse(gridLayoutModel.IsModelValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GridLayoutModelWithInvalidColumnPercentsIsNotValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
gridLayoutModel.Rows = 1;
|
||||||
|
gridLayoutModel.Columns = 1;
|
||||||
|
gridLayoutModel.ColumnPercents = new List<int> { 0 }; // Invalid percentage
|
||||||
|
Assert.IsFalse(gridLayoutModel.IsModelValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GridLayoutModelWithInvalidCellChildMapLengthIsNotValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
gridLayoutModel.Rows = 2;
|
||||||
|
gridLayoutModel.Columns = 2;
|
||||||
|
gridLayoutModel.CellChildMap = new int[2, 1]; // Invalid length
|
||||||
|
Assert.IsFalse(gridLayoutModel.IsModelValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GridLayoutModelWithInvalidZoneCountIsNotValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
gridLayoutModel.Rows = 2;
|
||||||
|
gridLayoutModel.Columns = 2;
|
||||||
|
gridLayoutModel.CellChildMap = new int[,]
|
||||||
|
{
|
||||||
|
{ 1, 2 },
|
||||||
|
{ 3, 4 },
|
||||||
|
}; // Invalid zone count
|
||||||
|
Assert.IsFalse(gridLayoutModel.IsModelValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GridLayoutModelWithValidPropertiesIsValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
|
||||||
|
// Set valid row and column counts
|
||||||
|
gridLayoutModel.Rows = 2;
|
||||||
|
gridLayoutModel.Columns = 2;
|
||||||
|
|
||||||
|
// Set valid percentages for rows and columns
|
||||||
|
// Should add up to 10000
|
||||||
|
gridLayoutModel.RowPercents = new List<int> { 5000, 5000 };
|
||||||
|
gridLayoutModel.ColumnPercents = new List<int> { 5000, 5000 };
|
||||||
|
|
||||||
|
// Set a valid CellChildMap
|
||||||
|
gridLayoutModel.CellChildMap = new int[,]
|
||||||
|
{
|
||||||
|
{ 0, 1 },
|
||||||
|
{ 2, 3 },
|
||||||
|
}; // corresponds to 4 zones
|
||||||
|
|
||||||
|
Assert.IsTrue(gridLayoutModel.IsModelValid(), "GridLayoutModel with valid properties should be valid.");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0-windows10.0.20348.0</TargetFramework>
|
||||||
|
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
|
||||||
|
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<IsTestProject>true</IsTestProject>
|
||||||
|
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)\tests\UnitTest-FancyZonesEditor\</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||||
|
<PackageReference Include="MSTest.TestAdapter" />
|
||||||
|
<PackageReference Include="MSTest.TestFramework" />
|
||||||
|
<PackageReference Include="System.IO.Abstractions" />
|
||||||
|
<PackageReference Include="System.IO.Abstractions.TestingHelpers" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\editor\FancyZonesEditor\FancyZonesEditor.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,5 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
global using Microsoft.VisualStudio.TestTools.UnitTesting;
|
@ -12,7 +12,7 @@ namespace FancyZonesEditor
|
|||||||
{
|
{
|
||||||
private LayoutModel _backup;
|
private LayoutModel _backup;
|
||||||
private string _hotkeyBackup;
|
private string _hotkeyBackup;
|
||||||
private List<LayoutModel> _defaultLayoutsBackup;
|
private Dictionary<MonitorConfigurationType, LayoutModel> _defaultLayoutsBackup;
|
||||||
|
|
||||||
public LayoutBackup()
|
public LayoutBackup()
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@ namespace FancyZonesEditor
|
|||||||
}
|
}
|
||||||
|
|
||||||
_hotkeyBackup = MainWindowSettingsModel.LayoutHotkeys.Key(model.Uuid);
|
_hotkeyBackup = MainWindowSettingsModel.LayoutHotkeys.Key(model.Uuid);
|
||||||
_defaultLayoutsBackup = new List<LayoutModel>(MainWindowSettingsModel.DefaultLayouts.Layouts);
|
_defaultLayoutsBackup = new Dictionary<MonitorConfigurationType, LayoutModel>(MainWindowSettingsModel.DefaultLayouts.Layouts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restore(LayoutModel layoutToRestore)
|
public void Restore(LayoutModel layoutToRestore)
|
||||||
|
@ -13,7 +13,7 @@ namespace FancyZonesEditor.Models
|
|||||||
{
|
{
|
||||||
private static int Count { get; } = Enum.GetValues(typeof(MonitorConfigurationType)).Length;
|
private static int Count { get; } = Enum.GetValues(typeof(MonitorConfigurationType)).Length;
|
||||||
|
|
||||||
public List<LayoutModel> Layouts { get; } = new List<LayoutModel>(Count);
|
public Dictionary<MonitorConfigurationType, LayoutModel> Layouts { get; } = new Dictionary<MonitorConfigurationType, LayoutModel>(Count);
|
||||||
|
|
||||||
public DefaultLayoutsModel()
|
public DefaultLayoutsModel()
|
||||||
{
|
{
|
||||||
@ -36,12 +36,12 @@ namespace FancyZonesEditor.Models
|
|||||||
|
|
||||||
public void Reset(string uuid)
|
public void Reset(string uuid)
|
||||||
{
|
{
|
||||||
if (Layouts[(int)MonitorConfigurationType.Horizontal].Uuid == uuid)
|
if (Layouts[MonitorConfigurationType.Horizontal].Uuid == uuid)
|
||||||
{
|
{
|
||||||
Set(MainWindowSettingsModel.TemplateModels[(int)LayoutType.PriorityGrid], MonitorConfigurationType.Horizontal);
|
Set(MainWindowSettingsModel.TemplateModels[(int)LayoutType.PriorityGrid], MonitorConfigurationType.Horizontal);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Layouts[(int)MonitorConfigurationType.Vertical].Uuid == uuid)
|
if (Layouts[MonitorConfigurationType.Vertical].Uuid == uuid)
|
||||||
{
|
{
|
||||||
Set(MainWindowSettingsModel.TemplateModels[(int)LayoutType.Rows], MonitorConfigurationType.Vertical);
|
Set(MainWindowSettingsModel.TemplateModels[(int)LayoutType.Rows], MonitorConfigurationType.Vertical);
|
||||||
}
|
}
|
||||||
@ -49,23 +49,16 @@ namespace FancyZonesEditor.Models
|
|||||||
|
|
||||||
public void Set(LayoutModel layout, MonitorConfigurationType type)
|
public void Set(LayoutModel layout, MonitorConfigurationType type)
|
||||||
{
|
{
|
||||||
if (Layouts.Count <= (int)type)
|
Layouts[type] = layout;
|
||||||
{
|
|
||||||
Layouts.Insert((int)type, layout);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Layouts[(int)type] = layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
FirePropertyChanged();
|
FirePropertyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restore(List<LayoutModel> layouts)
|
public void Restore(Dictionary<MonitorConfigurationType, LayoutModel> layouts)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Count; i++)
|
foreach (var monitorConfigurationType in layouts.Keys)
|
||||||
{
|
{
|
||||||
Set(layouts[i], (MonitorConfigurationType)i);
|
Set(layouts[monitorConfigurationType], monitorConfigurationType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ namespace FancyZonesEditor.Models
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return MainWindowSettingsModel.DefaultLayouts.Layouts[(int)MonitorConfigurationType.Vertical].Uuid == this.Uuid;
|
return MainWindowSettingsModel.DefaultLayouts.Layouts[MonitorConfigurationType.Vertical].Uuid == this.Uuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ namespace FancyZonesEditor.Models
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return MainWindowSettingsModel.DefaultLayouts.Layouts[(int)MonitorConfigurationType.Vertical].Uuid != this.Uuid;
|
return MainWindowSettingsModel.DefaultLayouts.Layouts[MonitorConfigurationType.Vertical].Uuid != this.Uuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +80,8 @@ namespace FancyZonesEditor
|
|||||||
TemplateModels.Insert((int)LayoutType.PriorityGrid, priorityGridModel);
|
TemplateModels.Insert((int)LayoutType.PriorityGrid, priorityGridModel);
|
||||||
|
|
||||||
// set default layouts
|
// set default layouts
|
||||||
DefaultLayouts.Set(priorityGridModel, MonitorConfigurationType.Horizontal);
|
|
||||||
DefaultLayouts.Set(rowsModel, MonitorConfigurationType.Vertical);
|
DefaultLayouts.Set(rowsModel, MonitorConfigurationType.Vertical);
|
||||||
|
DefaultLayouts.Set(priorityGridModel, MonitorConfigurationType.Horizontal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsShiftKeyPressed - is the shift key currently being held down
|
// IsShiftKeyPressed - is the shift key currently being held down
|
||||||
|
@ -36,6 +36,7 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
|||||||
[DataRow("now", "Now -", "Images\\timeDate.dark.png")]
|
[DataRow("now", "Now -", "Images\\timeDate.dark.png")]
|
||||||
[DataRow("now u", "Now UTC -", "Images\\timeDate.dark.png")]
|
[DataRow("now u", "Now UTC -", "Images\\timeDate.dark.png")]
|
||||||
[DataRow("unix", "Unix epoch time -", "Images\\timeDate.dark.png")]
|
[DataRow("unix", "Unix epoch time -", "Images\\timeDate.dark.png")]
|
||||||
|
[DataRow("unix epoch time in", "Unix epoch time in milliseconds -", "Images\\timeDate.dark.png")]
|
||||||
[DataRow("hour", "Hour -", "Images\\time.dark.png")]
|
[DataRow("hour", "Hour -", "Images\\time.dark.png")]
|
||||||
[DataRow("minute", "Minute -", "Images\\time.dark.png")]
|
[DataRow("minute", "Minute -", "Images\\time.dark.png")]
|
||||||
[DataRow("second", "Second -", "Images\\time.dark.png")]
|
[DataRow("second", "Second -", "Images\\time.dark.png")]
|
||||||
@ -82,6 +83,7 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
|||||||
[DataRow("now", "Now -", "Images\\timeDate.light.png")]
|
[DataRow("now", "Now -", "Images\\timeDate.light.png")]
|
||||||
[DataRow("now u", "Now UTC -", "Images\\timeDate.light.png")]
|
[DataRow("now u", "Now UTC -", "Images\\timeDate.light.png")]
|
||||||
[DataRow("unix", "Unix epoch time -", "Images\\timeDate.light.png")]
|
[DataRow("unix", "Unix epoch time -", "Images\\timeDate.light.png")]
|
||||||
|
[DataRow("unix epoch time in", "Unix epoch time in milliseconds -", "Images\\timeDate.light.png")]
|
||||||
[DataRow("hour", "Hour -", "Images\\time.light.png")]
|
[DataRow("hour", "Hour -", "Images\\time.light.png")]
|
||||||
[DataRow("minute", "Minute -", "Images\\time.light.png")]
|
[DataRow("minute", "Minute -", "Images\\time.light.png")]
|
||||||
[DataRow("second", "Second -", "Images\\time.light.png")]
|
[DataRow("second", "Second -", "Images\\time.light.png")]
|
||||||
|
@ -31,13 +31,13 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
[DataRow("time", 2)]
|
[DataRow("time", 2)] // Setting 'Only Date, Time, Now on global results' is default on
|
||||||
[DataRow("date", 2)]
|
[DataRow("date", 2)] // Setting 'Only Date, Time, Now on global results' is default on
|
||||||
[DataRow("now", 3)]
|
[DataRow("now", 3)] // Setting 'Only Date, Time, Now on global results' is default on
|
||||||
[DataRow("current", 3)]
|
[DataRow("current", 3)] // Setting 'Only Date, Time, Now on global results' is default on
|
||||||
[DataRow("year", 0)]
|
[DataRow("year", 0)] // Setting 'Only Date, Time, Now on global results' is default on
|
||||||
[DataRow("time::10:10:10", 0)]
|
[DataRow("time::10:10:10", 0)] // Setting 'Only Date, Time, Now on global results' is default on
|
||||||
[DataRow("date::10/10/10", 0)]
|
[DataRow("date::10/10/10", 0)] // Setting 'Only Date, Time, Now on global results' is default on
|
||||||
public void CountWithoutPluginKeyword(string typedString, int expectedResultCount)
|
public void CountWithoutPluginKeyword(string typedString, int expectedResultCount)
|
||||||
{
|
{
|
||||||
// Setup
|
// Setup
|
||||||
@ -52,12 +52,12 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
[DataRow("(time", 17)]
|
[DataRow("(time", 18)]
|
||||||
[DataRow("(date", 25)]
|
[DataRow("(date", 26)]
|
||||||
[DataRow("(year", 7)]
|
[DataRow("(year", 7)]
|
||||||
[DataRow("(now", 31)]
|
[DataRow("(now", 32)]
|
||||||
[DataRow("(current", 31)]
|
[DataRow("(current", 32)]
|
||||||
[DataRow("(", 31)]
|
[DataRow("(", 32)]
|
||||||
[DataRow("(now::10:10:10", 1)] // Windows file time
|
[DataRow("(now::10:10:10", 1)] // Windows file time
|
||||||
[DataRow("(current::10:10:10", 0)]
|
[DataRow("(current::10:10:10", 0)]
|
||||||
public void CountWithPluginKeyword(string typedString, int expectedResultCount)
|
public void CountWithPluginKeyword(string typedString, int expectedResultCount)
|
||||||
@ -104,6 +104,7 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
|||||||
[DataRow("(now", "Now -")]
|
[DataRow("(now", "Now -")]
|
||||||
[DataRow("(now u", "Now UTC -")]
|
[DataRow("(now u", "Now UTC -")]
|
||||||
[DataRow("(unix", "Unix epoch time -")]
|
[DataRow("(unix", "Unix epoch time -")]
|
||||||
|
[DataRow("(unix epoch time in milli", "Unix epoch time in milliseconds -")]
|
||||||
[DataRow("(file", "Windows file time (Int64 number) ")]
|
[DataRow("(file", "Windows file time (Int64 number) ")]
|
||||||
[DataRow("(hour", "Hour -")]
|
[DataRow("(hour", "Hour -")]
|
||||||
[DataRow("(minute", "Minute -")]
|
[DataRow("(minute", "Minute -")]
|
||||||
@ -156,6 +157,11 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
|||||||
[DataRow("(12:30", "Time -")]
|
[DataRow("(12:30", "Time -")]
|
||||||
[DataRow("(10.10.2022", "Date -")]
|
[DataRow("(10.10.2022", "Date -")]
|
||||||
[DataRow("(u1646408119", "Date and time -")]
|
[DataRow("(u1646408119", "Date and time -")]
|
||||||
|
[DataRow("(u+1646408119", "Date and time -")]
|
||||||
|
[DataRow("(u-1646408119", "Date and time -")]
|
||||||
|
[DataRow("(ums1646408119", "Date and time -")]
|
||||||
|
[DataRow("(ums+1646408119", "Date and time -")]
|
||||||
|
[DataRow("(ums-1646408119", "Date and time -")]
|
||||||
[DataRow("(ft637820085517321977", "Date and time -")]
|
[DataRow("(ft637820085517321977", "Date and time -")]
|
||||||
public void DateTimeNumberOnlyInput(string typedString, string expectedResult)
|
public void DateTimeNumberOnlyInput(string typedString, string expectedResult)
|
||||||
{
|
{
|
||||||
@ -176,15 +182,10 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
|||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
[DataRow("(abcdefg")]
|
[DataRow("(abcdefg")]
|
||||||
[DataRow("(timmmmeeee")]
|
[DataRow("(timmmmeeee")]
|
||||||
[DataRow("(10.10.20.aa.22")]
|
|
||||||
[DataRow("(12::55")]
|
|
||||||
[DataRow("(12:aa:55")]
|
|
||||||
[DataRow("(timtaaaetetaae::u1646408119")]
|
[DataRow("(timtaaaetetaae::u1646408119")]
|
||||||
[DataRow("(time:eeee")]
|
[DataRow("(time:eeee")]
|
||||||
[DataRow("(time::eeee")]
|
[DataRow("(time::eeee")]
|
||||||
[DataRow("(time//eeee")]
|
[DataRow("(time//eeee")]
|
||||||
[DataRow("(date::12::55")]
|
|
||||||
[DataRow("(date::12:aa:55")]
|
|
||||||
public void InvalidInputNotShowsResults(string typedString)
|
public void InvalidInputNotShowsResults(string typedString)
|
||||||
{
|
{
|
||||||
// Setup
|
// Setup
|
||||||
@ -201,8 +202,23 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
|||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
[DataRow("(ug1646408119")] // Invalid prefix
|
[DataRow("(ug1646408119")] // Invalid prefix
|
||||||
[DataRow("(u9999999999999")] // Unix number + prefix is longer than 12 characters
|
[DataRow("(u9999999999999")] // Unix number + prefix is longer than 12 characters
|
||||||
|
[DataRow("(ums999999999999999")] // Unix number in milliseconds + prefix is longer than 17 characters
|
||||||
|
[DataRow("(-u99999999999")] // Unix number with wrong placement of - sign
|
||||||
|
[DataRow("(+ums9999999999")] // Unix number in milliseconds with wrong placement of + sign
|
||||||
[DataRow("(0123456")] // Missing prefix
|
[DataRow("(0123456")] // Missing prefix
|
||||||
[DataRow("(ft63782008ab55173dasdas21977")] // Number contains letters
|
[DataRow("(ft63782008ab55173dasdas21977")] // Number contains letters
|
||||||
|
[DataRow("(ft63782008ab55173dasdas")] // Number contains letters at the end
|
||||||
|
[DataRow("(ft12..548")] // Number contains wrong punctuation
|
||||||
|
[DataRow("(ft12..54//8")] // Number contains wrong punctuation and other characters
|
||||||
|
[DataRow("(time::ft12..54//8")] // Number contains wrong punctuation and other characters
|
||||||
|
[DataRow("(ut2ed.5555")] // Number contains letters
|
||||||
|
[DataRow("(12..54//8")] // Number contains punctuation and other characters, but no special prefix
|
||||||
|
[DataRow("(ft::1288gg8888")] // Number contains delimiter and letters, but no special prefix
|
||||||
|
[DataRow("(date::12::55")]
|
||||||
|
[DataRow("(date::12:aa:55")]
|
||||||
|
[DataRow("(10.aa.22")]
|
||||||
|
[DataRow("(12::55")]
|
||||||
|
[DataRow("(12:aa:55")]
|
||||||
public void InvalidNumberInputShowsErrorMessage(string typedString)
|
public void InvalidNumberInputShowsErrorMessage(string typedString)
|
||||||
{
|
{
|
||||||
// Setup
|
// Setup
|
||||||
@ -217,10 +233,12 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[DataTestMethod]
|
[DataTestMethod]
|
||||||
[DataRow("(ft12..548")] // Number contains punctuation
|
[DataRow("(ft1 2..548")] // Input contains space
|
||||||
[DataRow("(ft12..54//8")] // Number contains punctuation and other characters
|
[DataRow("(ft12..54 //8")] // Input contains space
|
||||||
[DataRow("(12..54//8")] // Number contains punctuation and other characters
|
[DataRow("(time::ft12..54 //8")] // Input contains space
|
||||||
[DataRow("(ft::1288gg8888")] // Number contains delimiter and other characters
|
[DataRow("(10.10aa")] // Input contains <Number>.<Number> (Can be part of a date.)
|
||||||
|
[DataRow("(10:10aa")] // Input contains <Number>:<Number> (Can be part of a time.)
|
||||||
|
[DataRow("(10/10aa")] // Input contains <Number>/<Number> (Can be part of a date.)
|
||||||
public void InvalidInputNotShowsErrorMessage(string typedString)
|
public void InvalidInputNotShowsErrorMessage(string typedString)
|
||||||
{
|
{
|
||||||
// Setup
|
// Setup
|
||||||
|
@ -34,6 +34,11 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
|||||||
[DataRow("5:05:10 PM", true, "T", "5:05:10 PM")]
|
[DataRow("5:05:10 PM", true, "T", "5:05:10 PM")]
|
||||||
[DataRow("10456", false, "", "")]
|
[DataRow("10456", false, "", "")]
|
||||||
[DataRow("u10456", true, "", "")] // Value is UTC and can be different based on system
|
[DataRow("u10456", true, "", "")] // Value is UTC and can be different based on system
|
||||||
|
[DataRow("u-10456", true, "", "")] // Value is UTC and can be different based on system
|
||||||
|
[DataRow("u+10456", true, "", "")] // Value is UTC and can be different based on system
|
||||||
|
[DataRow("ums10456", true, "", "")] // Value is UTC and can be different based on system
|
||||||
|
[DataRow("ums-10456", true, "", "")] // Value is UTC and can be different based on system
|
||||||
|
[DataRow("ums+10456", true, "", "")] // Value is UTC and can be different based on system
|
||||||
[DataRow("ft10456", true, "", "")] // Value is UTC and can be different based on system
|
[DataRow("ft10456", true, "", "")] // Value is UTC and can be different based on system
|
||||||
public void ConvertStringToDateTime(string typedString, bool expectedBool, string stringType, string expectedString)
|
public void ConvertStringToDateTime(string typedString, bool expectedBool, string stringType, string expectedString)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +61,7 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.Components
|
|||||||
{
|
{
|
||||||
// We use long instead of int for unix time stamp because int is too small after 03:14:07 UTC 2038-01-19
|
// We use long instead of int for unix time stamp because int is too small after 03:14:07 UTC 2038-01-19
|
||||||
long unixTimestamp = (long)dateTimeNowUtc.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
long unixTimestamp = (long)dateTimeNowUtc.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||||
|
long unixTimestampMilliseconds = (long)dateTimeNowUtc.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;
|
||||||
int weekOfYear = calendar.GetWeekOfYear(dateTimeNow, DateTimeFormatInfo.CurrentInfo.CalendarWeekRule, DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek);
|
int weekOfYear = calendar.GetWeekOfYear(dateTimeNow, DateTimeFormatInfo.CurrentInfo.CalendarWeekRule, DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek);
|
||||||
string era = DateTimeFormatInfo.CurrentInfo.GetEraName(calendar.GetEra(dateTimeNow));
|
string era = DateTimeFormatInfo.CurrentInfo.GetEraName(calendar.GetEra(dateTimeNow));
|
||||||
string eraShort = DateTimeFormatInfo.CurrentInfo.GetAbbreviatedEraName(calendar.GetEra(dateTimeNow));
|
string eraShort = DateTimeFormatInfo.CurrentInfo.GetAbbreviatedEraName(calendar.GetEra(dateTimeNow));
|
||||||
@ -89,6 +90,13 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.Components
|
|||||||
IconType = ResultIconType.DateTime,
|
IconType = ResultIconType.DateTime,
|
||||||
},
|
},
|
||||||
new AvailableResult()
|
new AvailableResult()
|
||||||
|
{
|
||||||
|
Value = unixTimestampMilliseconds.ToString(CultureInfo.CurrentCulture),
|
||||||
|
Label = Resources.Microsoft_plugin_timedate_Unix_Milliseconds,
|
||||||
|
AlternativeSearchTag = ResultHelper.SelectStringFromResources(isSystemDateTime, "Microsoft_plugin_timedate_SearchTagFormat"),
|
||||||
|
IconType = ResultIconType.DateTime,
|
||||||
|
},
|
||||||
|
new AvailableResult()
|
||||||
{
|
{
|
||||||
Value = dateTimeNow.Hour.ToString(CultureInfo.CurrentCulture),
|
Value = dateTimeNow.Hour.ToString(CultureInfo.CurrentCulture),
|
||||||
Label = Resources.Microsoft_plugin_timedate_Hour,
|
Label = Resources.Microsoft_plugin_timedate_Hour,
|
||||||
|
@ -86,6 +86,7 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.Components
|
|||||||
{
|
{
|
||||||
Title = Resources.Microsoft_plugin_timedate_ErrorResultTitle,
|
Title = Resources.Microsoft_plugin_timedate_ErrorResultTitle,
|
||||||
SubTitle = Resources.Microsoft_plugin_timedate_ErrorResultSubTitle,
|
SubTitle = Resources.Microsoft_plugin_timedate_ErrorResultSubTitle,
|
||||||
|
ToolTipData = new ToolTipData(Resources.Microsoft_plugin_timedate_ErrorResultTitle, Resources.Microsoft_plugin_timedate_ErrorResultSubTitle),
|
||||||
IcoPath = $"Images\\Warning.{theme}.png",
|
IcoPath = $"Images\\Warning.{theme}.png",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -121,8 +121,7 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If search term is only a number that can't be parsed return an error message
|
// If search term is only a number that can't be parsed return an error message
|
||||||
if (!isEmptySearchInput && results.Count == 0 && searchTerm.Any(char.IsNumber) && Regex.IsMatch(searchTerm, @"\w+\d+$") &&
|
if (!isEmptySearchInput && results.Count == 0 && Regex.IsMatch(searchTerm, @"\w+\d+.*$") && !searchTerm.Any(char.IsWhiteSpace) && (TimeAndDateHelper.IsSpecialInputParsing(searchTerm) || !Regex.IsMatch(searchTerm, @"\d+[\.:/]\d+")))
|
||||||
!searchTerm.Contains(InputDelimiter) && !searchTerm.Any(char.IsWhiteSpace) && !searchTerm.Any(char.IsPunctuation))
|
|
||||||
{
|
{
|
||||||
// Without plugin key word show only if message is not hidden by setting
|
// Without plugin key word show only if message is not hidden by setting
|
||||||
if (isKeywordSearch || !TimeDateSettings.Instance.HideNumberMessageOnGlobalQuery)
|
if (isKeywordSearch || !TimeDateSettings.Instance.HideNumberMessageOnGlobalQuery)
|
||||||
|
@ -96,17 +96,24 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.Components
|
|||||||
// Known date/time format
|
// Known date/time format
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(input, @"^u\d+") && input.Length <= 12 && long.TryParse(input.TrimStart('u'), out long secondsInt))
|
else if (Regex.IsMatch(input, @"^u[\+-]?\d{1,10}$") && long.TryParse(input.TrimStart('u'), out long secondsU))
|
||||||
{
|
{
|
||||||
// unix time stamp
|
// unix time stamp
|
||||||
// we use long instead of int because int is too small after 03:14:07 UTC 2038-01-19
|
// we use long instead of int because int is too small after 03:14:07 UTC 2038-01-19
|
||||||
timestamp = new DateTime(1970, 1, 1).AddSeconds(secondsInt).ToLocalTime();
|
timestamp = new DateTime(1970, 1, 1).AddSeconds(secondsU).ToLocalTime();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (Regex.IsMatch(input, @"^ft\d+") && long.TryParse(input.TrimStart("ft".ToCharArray()), out long secondsLong))
|
else if (Regex.IsMatch(input, @"^ums[\+-]?\d{1,13}$") && long.TryParse(input.TrimStart("ums".ToCharArray()), out long millisecondsUms))
|
||||||
|
{
|
||||||
|
// unix time stamp in milliseconds
|
||||||
|
// we use long instead of int because int is too small after 03:14:07 UTC 2038-01-19
|
||||||
|
timestamp = new DateTime(1970, 1, 1).AddMilliseconds(millisecondsUms).ToLocalTime();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (Regex.IsMatch(input, @"^ft\d+$") && long.TryParse(input.TrimStart("ft".ToCharArray()), out long secondsFt))
|
||||||
{
|
{
|
||||||
// windows file time
|
// windows file time
|
||||||
timestamp = new DateTime(secondsLong);
|
timestamp = new DateTime(secondsFt);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -115,6 +122,16 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.Components
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test if input is special parsing for Unix time, Unix time in milliseconds or File time.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">String with date/time</param>
|
||||||
|
/// <returns>True if yes, otherwise false</returns>
|
||||||
|
internal static bool IsSpecialInputParsing(string input)
|
||||||
|
{
|
||||||
|
return Regex.IsMatch(input, @"^.*(u|ums|ft)\d");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -160,7 +160,7 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Valid prefixes: 'u' for Unix Timestamp, 'ft' for Windows file time.
|
/// Looks up a localized string similar to Valid prefixes: 'u' for Unix Timestamp, 'ums' for Unix Timestamp in milliseconds, 'ft' for Windows file time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string Microsoft_plugin_timedate_ErrorResultSubTitle {
|
internal static string Microsoft_plugin_timedate_ErrorResultSubTitle {
|
||||||
get {
|
get {
|
||||||
@ -555,6 +555,15 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Unix epoch time in milliseconds.
|
||||||
|
/// </summary>
|
||||||
|
internal static string Microsoft_plugin_timedate_Unix_Milliseconds {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Microsoft_plugin_timedate_Unix_Milliseconds", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Week of the month.
|
/// Looks up a localized string similar to Week of the month.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -153,7 +153,7 @@
|
|||||||
<value>Era abbreviation</value>
|
<value>Era abbreviation</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Microsoft_plugin_timedate_ErrorResultSubTitle" xml:space="preserve">
|
<data name="Microsoft_plugin_timedate_ErrorResultSubTitle" xml:space="preserve">
|
||||||
<value>Valid prefixes: 'u' for Unix Timestamp, 'ft' for Windows file time</value>
|
<value>Valid prefixes: 'u' for Unix Timestamp, 'ums' for Unix Timestamp in milliseconds, 'ft' for Windows file time</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Microsoft_plugin_timedate_ErrorResultTitle" xml:space="preserve">
|
<data name="Microsoft_plugin_timedate_ErrorResultTitle" xml:space="preserve">
|
||||||
<value>Error: Invalid number input</value>
|
<value>Error: Invalid number input</value>
|
||||||
@ -312,4 +312,7 @@
|
|||||||
<data name="Microsoft_plugin_timedate_Year" xml:space="preserve">
|
<data name="Microsoft_plugin_timedate_Year" xml:space="preserve">
|
||||||
<value>Year</value>
|
<value>Year</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Microsoft_plugin_timedate_Unix_Milliseconds" xml:space="preserve">
|
||||||
|
<value>Unix epoch time in milliseconds</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@ -217,6 +217,7 @@ namespace Peek.FilePreviewer
|
|||||||
partial void OnPreviewerChanging(IPreviewer? value)
|
partial void OnPreviewerChanging(IPreviewer? value)
|
||||||
{
|
{
|
||||||
VideoPreview.MediaPlayer.Pause();
|
VideoPreview.MediaPlayer.Pause();
|
||||||
|
VideoPreview.MediaPlayer.Source = null;
|
||||||
VideoPreview.Source = null;
|
VideoPreview.Source = null;
|
||||||
|
|
||||||
ImagePreview.Source = null;
|
ImagePreview.Source = null;
|
||||||
|
@ -9,6 +9,7 @@ using Microsoft.UI.Xaml;
|
|||||||
using Peek.Common.Helpers;
|
using Peek.Common.Helpers;
|
||||||
using Peek.Common.Models;
|
using Peek.Common.Models;
|
||||||
using Peek.UI.Models;
|
using Peek.UI.Models;
|
||||||
|
using Windows.Win32.Foundation;
|
||||||
|
|
||||||
namespace Peek.UI
|
namespace Peek.UI
|
||||||
{
|
{
|
||||||
@ -40,11 +41,11 @@ namespace Peek.UI
|
|||||||
NavigationThrottleTimer.Interval = TimeSpan.FromMilliseconds(NavigationThrottleDelayMs);
|
NavigationThrottleTimer.Interval = TimeSpan.FromMilliseconds(NavigationThrottleDelayMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize(HWND foregroundWindowHandle)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Items = NeighboringItemsQuery.GetNeighboringItems();
|
Items = NeighboringItemsQuery.GetNeighboringItems(foregroundWindowHandle);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -85,20 +85,24 @@ namespace Peek.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnPeekHotkey()
|
private void OnPeekHotkey()
|
||||||
{
|
{
|
||||||
|
// Need to read the foreground HWND before activating Peek to avoid focus stealing
|
||||||
|
// Foreground HWND must always be Explorer or Desktop
|
||||||
|
var foregroundWindowHandle = Windows.Win32.PInvoke.GetForegroundWindow();
|
||||||
|
|
||||||
// First Peek activation
|
// First Peek activation
|
||||||
if (!activated)
|
if (!activated)
|
||||||
{
|
{
|
||||||
Activate();
|
Activate();
|
||||||
Initialize();
|
Initialize(foregroundWindowHandle);
|
||||||
activated = true;
|
activated = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AppWindow.IsVisible)
|
if (AppWindow.IsVisible)
|
||||||
{
|
{
|
||||||
if (IsNewSingleSelectedItem())
|
if (IsNewSingleSelectedItem(foregroundWindowHandle))
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize(foregroundWindowHandle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -107,7 +111,7 @@ namespace Peek.UI
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize(foregroundWindowHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,12 +130,12 @@ namespace Peek.UI
|
|||||||
Uninitialize();
|
Uninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Initialize()
|
private void Initialize(Windows.Win32.Foundation.HWND foregroundWindowHandle)
|
||||||
{
|
{
|
||||||
var bootTime = new System.Diagnostics.Stopwatch();
|
var bootTime = new System.Diagnostics.Stopwatch();
|
||||||
bootTime.Start();
|
bootTime.Start();
|
||||||
|
|
||||||
ViewModel.Initialize();
|
ViewModel.Initialize(foregroundWindowHandle);
|
||||||
ViewModel.ScalingFactor = this.GetMonitorScale();
|
ViewModel.ScalingFactor = this.GetMonitorScale();
|
||||||
|
|
||||||
bootTime.Stop();
|
bootTime.Stop();
|
||||||
@ -156,6 +160,7 @@ namespace Peek.UI
|
|||||||
private void FilePreviewer_PreviewSizeChanged(object sender, PreviewSizeChangedArgs e)
|
private void FilePreviewer_PreviewSizeChanged(object sender, PreviewSizeChangedArgs e)
|
||||||
{
|
{
|
||||||
var foregroundWindowHandle = Windows.Win32.PInvoke.GetForegroundWindow();
|
var foregroundWindowHandle = Windows.Win32.PInvoke.GetForegroundWindow();
|
||||||
|
|
||||||
var monitorSize = foregroundWindowHandle.GetMonitorSize();
|
var monitorSize = foregroundWindowHandle.GetMonitorSize();
|
||||||
var monitorScale = foregroundWindowHandle.GetMonitorScale();
|
var monitorScale = foregroundWindowHandle.GetMonitorScale();
|
||||||
|
|
||||||
@ -210,12 +215,10 @@ namespace Peek.UI
|
|||||||
Uninitialize();
|
Uninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsNewSingleSelectedItem()
|
private bool IsNewSingleSelectedItem(Windows.Win32.Foundation.HWND foregroundWindowHandle)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var foregroundWindowHandle = Windows.Win32.PInvoke.GetForegroundWindow();
|
|
||||||
|
|
||||||
var selectedItems = FileExplorerHelper.GetSelectedItems(foregroundWindowHandle);
|
var selectedItems = FileExplorerHelper.GetSelectedItems(foregroundWindowHandle);
|
||||||
var selectedItemsCount = selectedItems?.GetCount() ?? 0;
|
var selectedItemsCount = selectedItems?.GetCount() ?? 0;
|
||||||
if (selectedItems == null || selectedItemsCount == 0 || selectedItemsCount > 1)
|
if (selectedItems == null || selectedItemsCount == 0 || selectedItemsCount > 1)
|
||||||
|
@ -2,10 +2,7 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System.Diagnostics;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using Peek.Common.Models;
|
|
||||||
using Peek.UI.Extensions;
|
|
||||||
using Peek.UI.Helpers;
|
using Peek.UI.Helpers;
|
||||||
using Peek.UI.Models;
|
using Peek.UI.Models;
|
||||||
|
|
||||||
@ -16,10 +13,8 @@ namespace Peek.UI
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isMultipleFilesActivation;
|
private bool isMultipleFilesActivation;
|
||||||
|
|
||||||
public NeighboringItems? GetNeighboringItems()
|
public NeighboringItems? GetNeighboringItems(Windows.Win32.Foundation.HWND foregroundWindowHandle)
|
||||||
{
|
{
|
||||||
var foregroundWindowHandle = Windows.Win32.PInvoke.GetForegroundWindow();
|
|
||||||
|
|
||||||
var selectedItemsShellArray = FileExplorerHelper.GetSelectedItems(foregroundWindowHandle);
|
var selectedItemsShellArray = FileExplorerHelper.GetSelectedItems(foregroundWindowHandle);
|
||||||
var selectedItemsCount = selectedItemsShellArray?.GetCount() ?? 0;
|
var selectedItemsCount = selectedItemsShellArray?.GetCount() ?? 0;
|
||||||
|
|
||||||
|
@ -2,11 +2,9 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices.ComTypes;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Media3D;
|
using System.Windows.Media.Media3D;
|
||||||
using Common.Utilities;
|
|
||||||
using HelixToolkit.Wpf;
|
using HelixToolkit.Wpf;
|
||||||
using Microsoft.PowerToys.Settings.UI.Library;
|
using Microsoft.PowerToys.Settings.UI.Library;
|
||||||
using Bitmap = System.Drawing.Bitmap;
|
using Bitmap = System.Drawing.Bitmap;
|
||||||
@ -61,9 +59,11 @@ namespace Microsoft.PowerToys.ThumbnailHandler.Stl
|
|||||||
DefaultMaterial = new DiffuseMaterial(new SolidColorBrush(DefaultMaterialColor)),
|
DefaultMaterial = new DiffuseMaterial(new SolidColorBrush(DefaultMaterialColor)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
var model = stlReader.Read(stream);
|
var model = stlReader.Read(stream);
|
||||||
|
|
||||||
if (model.Bounds == Rect3D.Empty)
|
if (model == null || model.Children.Count == 0 || model.Bounds == Rect3D.Empty)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -108,6 +108,11 @@ namespace Microsoft.PowerToys.ThumbnailHandler.Stl
|
|||||||
bitmapStream.Position = 0;
|
bitmapStream.Position = 0;
|
||||||
|
|
||||||
thumbnail = new Bitmap(bitmapStream);
|
thumbnail = new Bitmap(bitmapStream);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return thumbnail;
|
return thumbnail;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,6 @@ void VideoConferenceModule::onMicrophoneConfigurationChanged()
|
|||||||
toolbar.setMicrophoneMute(muted);
|
toolbar.setMicrophoneMute(muted);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setMuteChangedCallback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoConferenceModule::VideoConferenceModule()
|
VideoConferenceModule::VideoConferenceModule()
|
||||||
@ -406,25 +405,6 @@ void VideoConferenceModule::set_config(const wchar_t* config)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoConferenceModule::setMuteChangedCallback()
|
|
||||||
{
|
|
||||||
// Keep all controlledMic mute state same _microphoneTrackedInUI
|
|
||||||
// Should not change manually in Control Panel
|
|
||||||
for (const auto& controlledMic : _controlledMicrophones)
|
|
||||||
{
|
|
||||||
if (controlledMic->id() != _microphoneTrackedInUI->id())
|
|
||||||
{
|
|
||||||
controlledMic->set_mute_changed_callback([&](const bool muted) {
|
|
||||||
auto muteState = getMicrophoneMuteState();
|
|
||||||
if (muted != muteState)
|
|
||||||
{
|
|
||||||
controlledMic->set_muted(muteState);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void VideoConferenceModule::init_settings()
|
void VideoConferenceModule::init_settings()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -552,7 +532,6 @@ void VideoConferenceModule::updateControlledMicrophones(const std::wstring_view
|
|||||||
controlledMic->set_muted(true);
|
controlledMic->set_muted(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setMuteChangedCallback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MicrophoneDevice* VideoConferenceModule::controlledDefaultMic()
|
MicrophoneDevice* VideoConferenceModule::controlledDefaultMic()
|
||||||
|
@ -73,7 +73,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void setMuteChangedCallback();
|
|
||||||
void init_settings();
|
void init_settings();
|
||||||
void updateControlledMicrophones(const std::wstring_view new_mic);
|
void updateControlledMicrophones(const std::wstring_view new_mic);
|
||||||
MicrophoneDevice* controlledDefaultMic();
|
MicrophoneDevice* controlledDefaultMic();
|
||||||
|
Loading…
Reference in New Issue
Block a user