mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-07-05 01:50:26 +02:00
Compare commits
3 Commits
copilot/fi
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3f8d78e4b | ||
|
|
c27534331b | ||
|
|
aaadd5dd13 |
@@ -211,23 +211,15 @@ void Highlighter::AddDrawingPoint(MouseButton button)
|
||||
else
|
||||
{
|
||||
circleShape.FillBrush(m_compositor.CreateColorBrush(m_alwaysColor));
|
||||
// Remove the previous always-pointer shape from the collection before replacing it.
|
||||
// It has already been made transparent by ClearDrawingPoint(), so removing it
|
||||
// causes no visual glitch and prevents an unbounded accumulation of shape objects.
|
||||
if (m_alwaysPointer)
|
||||
{
|
||||
uint32_t index;
|
||||
if (m_shape.Shapes().IndexOf(m_alwaysPointer, index))
|
||||
{
|
||||
m_shape.Shapes().RemoveAt(index);
|
||||
}
|
||||
}
|
||||
m_alwaysPointer = circleShape;
|
||||
}
|
||||
}
|
||||
|
||||
m_shape.Shapes().Append(circleShape);
|
||||
|
||||
// TODO: We're leaking shapes for long drawing sessions.
|
||||
// Perhaps add a task to the Dispatcher every X circles to clean up.
|
||||
|
||||
// Get back on top in case other Window is now the topmost.
|
||||
// HACK: Draw with 1 pixel off. Otherwise, Windows glitches the task bar transparency when a transparent window fill the whole screen.
|
||||
SetWindowPos(m_hwnd, HWND_TOPMOST, GetSystemMetrics(SM_XVIRTUALSCREEN) + 1, GetSystemMetrics(SM_YVIRTUALSCREEN) + 1, GetSystemMetrics(SM_CXVIRTUALSCREEN) - 2, GetSystemMetrics(SM_CYVIRTUALSCREEN) - 2, 0);
|
||||
@@ -297,19 +289,7 @@ void Highlighter::StartDrawingPointFading(MouseButton button)
|
||||
animation.Duration(timeSpan(duration));
|
||||
animation.DelayTime(timeSpan(delay));
|
||||
|
||||
// Use a scoped batch to detect when the fade animation completes, then remove
|
||||
// the fully-transparent shape from the collection so it does not leak.
|
||||
auto batch = m_compositor.CreateScopedBatch(winrt::CompositionBatchTypes::Animation);
|
||||
circleShape.FillBrush().StartAnimation(L"Color", animation);
|
||||
batch.End();
|
||||
auto shapes = m_shape.Shapes();
|
||||
batch.Completed([shape = circleShape, shapes](winrt::IInspectable const&, winrt::CompositionBatchCompletedEventArgs const&) {
|
||||
uint32_t index;
|
||||
if (shapes.IndexOf(shape, index))
|
||||
{
|
||||
shapes.RemoveAt(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Highlighter::ClearDrawingPoint()
|
||||
|
||||
@@ -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