mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-07-07 19:09:43 +02:00
Compare commits
2 Commits
copilot/fi
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
412d60fbe4 | ||
|
|
01d31cb62e |
@@ -211,15 +211,23 @@ 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);
|
||||
@@ -289,7 +297,19 @@ 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()
|
||||
|
||||
@@ -39,7 +39,6 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
|
||||
[DataTestMethod]
|
||||
[DataRow("test")]
|
||||
[DataRow("[10,10]")] // '[10,10]' is interpreted as array by mages engine
|
||||
[DataRow("sqrt(-1)")] // sqrt(-1) returns a complex number which is not supported
|
||||
public void Interpret_NoResult_WhenCalled(string input)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests
|
||||
[DataRow("10+(8*9)/0*7", "Expression contains division by zero")]
|
||||
[DataRow("10+(8*9)/0x00", "Expression contains division by zero")]
|
||||
[DataRow("10+(8*9)/0b0", "Expression contains division by zero")]
|
||||
[DataRow("=sqrt(-1)", "Result is a complex number")]
|
||||
public void ErrorResultOnInvalidKeywordQuery(string typedString, string expectedResult)
|
||||
{
|
||||
Query expectedQuery = new(typedString, "=");
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using Mages.Core;
|
||||
@@ -123,12 +122,6 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
||||
return Properties.Resources.wox_plugin_calculator_double_array_returned;
|
||||
}
|
||||
|
||||
if (result is Complex)
|
||||
{
|
||||
// Result is a complex number (e.g. sqrt(-1))
|
||||
return Properties.Resources.wox_plugin_calculator_complex_number_result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,15 +69,6 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Result is a complex number.
|
||||
/// </summary>
|
||||
public static string wox_plugin_calculator_complex_number_result {
|
||||
get {
|
||||
return ResourceManager.GetString("wox_plugin_calculator_complex_number_result", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Copy failed, please try later.
|
||||
/// </summary>
|
||||
|
||||
@@ -158,9 +158,6 @@
|
||||
<value>Ignores your system setting and returns numbers in the format '{0}'.</value>
|
||||
<comment>{0} is a placeholder and will be replaced in code.</comment>
|
||||
</data>
|
||||
<data name="wox_plugin_calculator_complex_number_result" xml:space="preserve">
|
||||
<value>Result is a complex number</value>
|
||||
</data>
|
||||
<data name="wox_plugin_calculator_division_by_zero" xml:space="preserve">
|
||||
<value>Expression contains division by zero</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user