mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-07-02 00:19:16 +02:00
Compare commits
3 Commits
copilot/fi
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3f8d78e4b | ||
|
|
c27534331b | ||
|
|
aaadd5dd13 |
@@ -129,8 +129,8 @@ public partial class ContentPageViewModel : PageViewModel, ICommandBarContext
|
||||
|
||||
UpdateDetails();
|
||||
|
||||
model.ItemsChanged += Model_ItemsChanged;
|
||||
FetchContent();
|
||||
model.ItemsChanged += Model_ItemsChanged;
|
||||
|
||||
DoOnUiThread(
|
||||
() =>
|
||||
|
||||
@@ -44,9 +44,9 @@ public partial class ContentTreeViewModel(ITreeContent _tree, WeakReference<IPag
|
||||
UpdateProperty(nameof(Root));
|
||||
}
|
||||
|
||||
FetchContent();
|
||||
model.PropChanged += Model_PropChanged;
|
||||
model.ItemsChanged += Model_ItemsChanged;
|
||||
FetchContent();
|
||||
}
|
||||
|
||||
// Theoretically, we should unify this with the one in CommandPalettePageViewModelFactory
|
||||
|
||||
@@ -209,8 +209,8 @@ public sealed partial class DockBandViewModel : ExtensionObjectViewModel
|
||||
var list = command.Model.Unsafe as IListPage;
|
||||
if (list is not null)
|
||||
{
|
||||
list.ItemsChanged += HandleItemsChanged;
|
||||
InitializeFromList(list);
|
||||
list.ItemsChanged += HandleItemsChanged;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -957,8 +957,8 @@ public partial class ListViewModel : PageViewModel, IDisposable
|
||||
Filters?.InitializeProperties();
|
||||
UpdateProperty(nameof(Filters));
|
||||
|
||||
model.ItemsChanged += Model_ItemsChanged;
|
||||
FetchItems(true);
|
||||
model.ItemsChanged += Model_ItemsChanged;
|
||||
}
|
||||
|
||||
private static IGridPropertiesViewModel? LoadGridPropertiesViewModel(IGridProperties? gridProperties)
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// 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 System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace ViewModelTests
|
||||
{
|
||||
[TestClass]
|
||||
public class NewPlus
|
||||
{
|
||||
[TestMethod]
|
||||
public void CreateExplorerProcessStartInfoShouldQuoteTemplatePathAndUseFullExplorerPath()
|
||||
{
|
||||
// Arrange
|
||||
const string templatePath = @"C:\Users\Test User\Documents\My Templates";
|
||||
var createExplorerProcessStartInfoMethod = typeof(NewPlusViewModel).GetMethod("CreateExplorerProcessStartInfo", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
|
||||
// Act
|
||||
var processStartInfo = (ProcessStartInfo)createExplorerProcessStartInfoMethod.Invoke(null, new object[] { templatePath });
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(processStartInfo);
|
||||
Assert.AreEqual(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "explorer.exe"), processStartInfo.FileName);
|
||||
Assert.AreEqual($"\"{templatePath}\"", processStartInfo.Arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,6 +330,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly string ExplorerExePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "explorer.exe");
|
||||
|
||||
private bool _isNewPlusEnabled;
|
||||
private string _templateLocation;
|
||||
private bool _hideFileExtension;
|
||||
@@ -356,12 +358,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
CopyTemplateExamples(_templateLocation);
|
||||
|
||||
var process = new ProcessStartInfo()
|
||||
{
|
||||
FileName = _templateLocation,
|
||||
UseShellExecute = true,
|
||||
};
|
||||
Process.Start(process);
|
||||
Process.Start(CreateExplorerProcessStartInfo(_templateLocation));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -369,6 +366,15 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private static ProcessStartInfo CreateExplorerProcessStartInfo(string templateLocation)
|
||||
{
|
||||
return new ProcessStartInfo
|
||||
{
|
||||
FileName = ExplorerExePath,
|
||||
Arguments = $"\"{templateLocation}\"",
|
||||
};
|
||||
}
|
||||
|
||||
private async void PickNewTemplateFolder()
|
||||
{
|
||||
var newPath = await PickFolderDialog();
|
||||
|
||||
Reference in New Issue
Block a user