Skip to content

A Swiss Army knife for developers.

Added regex tool

Etienne Baudoux68bccad3511c
diff --git a/src/dev/def/DevTools.Core/Threading/IThread.cs b/src/dev/def/DevTools.Core/Threading/IThread.cs
index 3b16205dc..3e42d389e 100644
--- a/src/dev/def/DevTools.Core/Threading/IThread.cs
+++ b/src/dev/def/DevTools.Core/Threading/IThread.cs
@@ -25,6 +25,13 @@ namespace DevTools.Core.Threading
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
Task RunOnUIThreadAsync(Action action);
+ /// <summary>
+ /// Runs a given action on the UI thread and wait for its result asynchronously.
+ /// </summary>
+ /// <param name="action">Action to run on the UI thread.</param>
+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
+ Task RunOnUIThreadAsync(ThreadPriority priority, Action action);
+
/// <summary>
/// Runs a given action on the UI thread and wait for its result asynchronously.
/// </summary>
@@ -32,11 +39,25 @@ namespace DevTools.Core.Threading
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
Task RunOnUIThreadAsync(Func<Task> action);
+ /// <summary>
+ /// Runs a given action on the UI thread and wait for its result asynchronously.
+ /// </summary>
+ /// <param name="action">Action to run on the UI thread.</param>
+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
+ Task RunOnUIThreadAsync(ThreadPriority priority, Func<Task> action);
+
/// <summary>
/// Runs a given action on the UI thread and wait for its result asynchronously.
/// </summary>
/// <param name="action">Action to run on the UI thread.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
Task<T> RunOnUIThreadAsync<T>(Func<Task<T>> action);
+
+ /// <summary>
+ /// Runs a given action on the UI thread and wait for its result asynchronously.
+ /// </summary>
+ /// <param name="action">Action to run on the UI thread.</param>
+ /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
+ Task<T> RunOnUIThreadAsync<T>(ThreadPriority priority, Func<Task<T>> action);
}
}
diff --git a/src/dev/def/DevTools.Core/Threading/ThreadPriority.cs b/src/dev/def/DevTools.Core/Threading/ThreadPriority.cs
new file mode 100644
index 000000000..e816124f7
--- /dev/null
+++ b/src/dev/def/DevTools.Core/Threading/ThreadPriority.cs
@@ -0,0 +1,9 @@
+namespace DevTools.Core.Threading
+{
+ public enum ThreadPriority
+ {
+ Low,
+ Normal,
+ High
+ }
+}
diff --git a/src/dev/impl/DevTools.Common/DevTools.Common.csproj b/src/dev/impl/DevTools.Common/DevTools.Common.csproj
index c5280222b..dc6df636e 100644
--- a/src/dev/impl/DevTools.Common/DevTools.Common.csproj
+++ b/src/dev/impl/DevTools.Common/DevTools.Common.csproj
@@ -89,6 +89,8 @@
<DependentUpon>FormattedTextBlock.xaml</DependentUpon>
</Compile>
<Compile Include="UI\Controls\FormattedTextBlock\IFormattedTextBlock.cs" />
+ <Compile Include="UI\Controls\HighlightSpan.cs" />
+ <Compile Include="UI\Controls\ICustomTextBox.cs" />
<Compile Include="UI\Controls\TextEditor\CommandHandlerResult.cs" />
<Compile Include="UI\Controls\TextEditor\ICommandHandler.cs" />
<Compile Include="UI\Controls\TextEditor\IKeyboardCommand.cs" />
@@ -199,6 +201,9 @@
<ItemGroup>
<PRIResource Include="Strings\en\HashGenerator.resw" />
</ItemGroup>
+ <ItemGroup>
+ <PRIResource Include="Strings\en\RegEx.resw" />
+ </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/src/dev/impl/DevTools.Common/LanguageManager.cs b/src/dev/impl/DevTools.Common/LanguageManager.cs
index 4c3d1612c..7946c9a4f 100644
--- a/src/dev/impl/DevTools.Common/LanguageManager.cs
+++ b/src/dev/impl/DevTools.Common/LanguageManager.cs
@@ -26,6 +26,7 @@ namespace DevTools.Common
private readonly HashGeneratorStrings _hashgenerator = new HashGeneratorStrings();
private readonly JsonFormatterStrings _jsonformatter = new JsonFormatterStrings();
private readonly MainPageStrings _mainpage = new MainPageStrings();
+ private readonly RegExStrings _regex = new RegExStrings();
private readonly SettingsStrings _settings = new SettingsStrings();
private readonly TextDiffStrings _textdiff = new TextDiffStrings();
@@ -64,6 +65,11 @@ namespace DevTools.Common
/// </summary>
public MainPageStrings MainPage => _mainpage;
+ /// <summary>
+ /// Gets the <see cref="RegExStrings"/>.
+ /// </summary>
+ public RegExStrings RegEx => _regex;
+
/// <summary>
/// Gets the <see cref="SettingsStrings"/>.
/// </summary>
@@ -174,10 +180,45 @@ namespace DevTools.Common
{
private readonly ResourceLoader _resources = ResourceLoader.GetForViewIndependentUse("DevTools.Common/HashGenerator");
+ /// <summary>
+ /// Gets the resource Configuration.
+ /// </summary>
+ public string Configuration => _resources.GetString("Configuration");
+
/// <summary>
/// Gets the resource DisplayName.
/// </summary>
public string DisplayName => _resources.GetString("DisplayName");
+
+ /// <summary>
+ /// Gets the resource Input.
+ /// </summary>
+ public string Input => _resources.GetString("Input");
+
+ /// <summary>
+ /// Gets the resource MD5.
+ /// </summary>
+ public string MD5 => _resources.GetString("MD5");
+
+ /// <summary>
+ /// Gets the resource SHA1.
+ /// </summary>
+ public string SHA1 => _resources.GetString("SHA1");
+
+ /// <summary>
+ /// Gets the resource SHA256.
+ /// </summary>
+ public string SHA256 => _resources.GetString("SHA256");
+
+ /// <summary>
+ /// Gets the resource SHA512.
+ /// </summary>
+ public string SHA512 => _resources.GetString("SHA512");
+
+ /// <summary>
+ /// Gets the resource Uppercase.
+ /// </summary>
+ public string Uppercase => _resources.GetString("Uppercase");
}
public class JsonFormatterStrings : ObservableObject
@@ -215,6 +256,16 @@ namespace DevTools.Common
public string Search => _resources.GetString("Search");
}
+ public class RegExStrings : ObservableObject
+ {
+ private readonly ResourceLoader _resources = ResourceLoader.GetForViewIndependentUse("DevTools.Common/RegEx");
+
+ /// <summary>
+ /// Gets the resource DisplayName.
+ /// </summary>
+ public string DisplayName => _resources.GetString("DisplayName");
+ }
+
public class SettingsStrings : ObservableObject
{
private readonly ResourceLoader _resources = ResourceLoader.GetForViewIndependentUse("DevTools.Common/Settings");
@@ -314,9 +365,29 @@ namespace DevTools.Common
{
private readonly ResourceLoader _resources = ResourceLoader.GetForViewIndependentUse("DevTools.Common/TextDiff");
+ /// <summary>
+ /// Gets the resource Difference.
+ /// </summary>
+ public string Difference => _resources.GetString("Difference");
+
/// <summary>
/// Gets the resource DisplayName.
/// </summary>
public string DisplayName => _resources.GetString("DisplayName");
+
+ /// <summary>
+ /// Gets the resource Inputs.
+ /// </summary>
+ public string Inputs => _resources.GetString("Inputs");
+
+ /// <summary>
+ /// Gets the resource LeftText.
+ /// </summary>
+ public string LeftText => _resources.GetString("LeftText");
+
+ /// <summary>
+ /// Gets the resource RightText.
+ /// </summary>
+ public string RightText => _resources.GetString("RightText");
}
}
\ No newline at end of file
diff --git a/src/dev/impl/DevTools.Common/Strings/en/HashGenerator.resw b/src/dev/impl/DevTools.Common/Strings/en/HashGenerator.resw
index bb3ec8af8..63834adfc 100644
--- a/src/dev/impl/DevTools.Common/Strings/en/HashGenerator.resw
+++ b/src/dev/impl/DevTools.Common/Strings/en/HashGenerator.resw
@@ -117,7 +117,28 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <data name="Configuration" xml:space="preserve">
+ <value>Configuration</value>
+ </data>
<data name="DisplayName" xml:space="preserve">
<value>Hash Generator</value>
</data>
+ <data name="Input" xml:space="preserve">
+ <value>Input</value>
+ </data>
+ <data name="MD5" xml:space="preserve">
+ <value>MD5</value>
+ </data>
+ <data name="SHA1" xml:space="preserve">
+ <value>SHA1</value>
+ </data>
+ <data name="SHA256" xml:space="preserve">
+ <value>SHA256</value>
+ </data>
+ <data name="SHA512" xml:space="preserve">
+ <value>SHA512</value>
+ </data>
+ <data name="Uppercase" xml:space="preserve">
+ <value>Uppercase</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevTools.Common/Strings/en/RegEx.resw b/src/dev/impl/DevTools.Common/Strings/en/RegEx.resw
new file mode 100644
index 000000000..1ce2d7718
--- /dev/null
+++ b/src/dev/impl/DevTools.Common/Strings/en/RegEx.resw
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="DisplayName" xml:space="preserve">
+ <value>Regex Tester</value>
+ </data>
+</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevTools.Common/Strings/en/TextDiff.resw b/src/dev/impl/DevTools.Common/Strings/en/TextDiff.resw
index 8c7dcced1..39d7a1b17 100644
--- a/src/dev/impl/DevTools.Common/Strings/en/TextDiff.resw
+++ b/src/dev/impl/DevTools.Common/Strings/en/TextDiff.resw
@@ -117,7 +117,19 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <data name="Difference" xml:space="preserve">
+ <value>Difference</value>
+ </data>
<data name="DisplayName" xml:space="preserve">
<value>Text Diff</value>
</data>
+ <data name="Inputs" xml:space="preserve">
+ <value>Inputs</value>
+ </data>
+ <data name="LeftText" xml:space="preserve">
+ <value>Old text</value>
+ </data>
+ <data name="RightText" xml:space="preserve">
+ <value>New text</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/src/dev/impl/DevTools.Common/Themes/Custom.xaml b/src/dev/impl/DevTools.Common/Themes/Custom.xaml
index 6395846c6..5f3fc7a99 100644
--- a/src/dev/impl/DevTools.Common/Themes/Custom.xaml
+++ b/src/dev/impl/DevTools.Common/Themes/Custom.xaml
@@ -15,6 +15,7 @@
<x:String x:Key="Base64EncoderDecoderToolProvider">M 0.008 0.008 L 0.008 31.992 L 31.992 31.992 L 31.992 0.008 Z M 2.916 2.916 L 29.084 2.916 L 29.084 29.084 L 2.916 29.084 Z M 11.957 10.094 L 8.777 13.774 C 7.823 14.87 7.276 16.273 7.276 17.727 L 7.276 18.18 C 7.276 20.169 8.924 21.816 10.912 21.816 L 12.366 21.816 C 14.353 21.816 16 20.169 16 18.18 C 16 16.193 14.353 14.546 12.366 14.546 L 11.957 14.546 L 14.137 12.002 Z M 21.816 10.184 L 21.816 14.546 L 20.362 14.546 L 20.362 10.231 L 17.454 10.231 L 17.454 17.454 L 21.816 17.454 L 21.816 21.816 L 24.722 21.816 L 24.722 10.184 Z M 10.276 17.454 L 12.366 17.454 C 12.781 17.454 13.092 17.766 13.092 18.18 C 13.092 18.595 12.781 18.908 12.366 18.908 L 10.912 18.908 C 10.497 18.908 10.184 18.595 10.184 18.18 L 10.184 17.727 C 10.184 17.629 10.264 17.55 10.276 17.454 Z</x:String>
<x:String x:Key="JsonFormatterToolProvider">M 9.5703125 4 C 5.9553125 4 4.4385 5.3040312 4.4375 8.4570312 L 4.4375 10.648438 C 4.4375 12.498437 3.9412656 13.115234 2.4472656 13.115234 L 2.4472656 16.398438 C 3.9402656 16.398437 4.4375 17.014563 4.4375 18.851562 L 4.4375 21.435547 C 4.4375 24.660547 5.9673125 26 9.5703125 26 L 10.816406 26 L 10.816406 23.404297 L 10.283203 23.404297 C 8.3622031 23.404297 7.7460938 22.835328 7.7460938 20.986328 L 7.7460938 17.904297 C 7.7460938 16.091297 6.8912969 15.024141 5.2792969 14.869141 L 5.2792969 14.65625 C 6.9632969 14.50225 7.7460938 13.578656 7.7460938 11.847656 L 7.7460938 9.0371094 C 7.7460938 7.1761094 8.3512031 6.6074219 10.283203 6.6074219 L 10.816406 6.6074219 L 10.816406 4 L 9.5703125 4 z M 19.183594 4 L 19.183594 6.6074219 L 19.716797 6.6074219 C 21.648797 6.6074219 22.253906 7.1761094 22.253906 9.0371094 L 22.253906 11.847656 C 22.253906 13.577656 23.037703 14.50225 24.720703 14.65625 L 24.720703 14.871094 C 23.107703 15.025094 22.253906 16.090297 22.253906 17.904297 L 22.253906 20.986328 C 22.253906 22.835328 21.636797 23.404297 19.716797 23.404297 L 19.183594 23.404297 L 19.183594 26.001953 L 20.429688 26.001953 C 24.033688 26.001953 25.5625 24.6615 25.5625 21.4375 L 25.5625 18.853516 C 25.5625 17.015516 26.058734 16.398438 27.552734 16.398438 L 27.552734 13.115234 C 26.059734 13.115234 25.5625 12.499391 25.5625 10.650391 L 25.5625 8.4570312 C 25.5625 5.3040312 24.044687 4 20.429688 4 L 19.183594 4 z</x:String>
<x:String x:Key="TextDiffToolProvider">M 6 3 L 6 29 L 13 29 L 13 27 L 8 27 L 8 5 L 13 5 L 13 3 L 6 3 z M 15 3 L 15 5 L 17 5 L 17 3 L 15 3 z M 19 3 L 19 5 L 24 5 L 24 27 L 19 27 L 19 29 L 26 29 L 26 3 L 19 3 z M 15 7 L 15 9 L 17 9 L 17 7 L 15 7 z M 15 11 L 15 13 L 17 13 L 17 11 L 15 11 z M 15 15 L 15 17 L 17 17 L 17 15 L 15 15 z M 15 19 L 15 21 L 17 21 L 17 19 L 15 19 z M 15 23 L 15 25 L 17 25 L 17 23 L 15 23 z M 15 27 L 15 29 L 17 29 L 17 27 L 15 27 z</x:String>
+ <x:String x:Key="RegExToolProvider">M1.62 10a13.63 13.63 0 0 0 .45 3.51A13.39 13.39 0 0 0 3.4 16.7a.91.91 0 0 1 .1.27.41.41 0 0 1 0 .21.38.38 0 0 1-.1.15l-.14.11-.83.5a14.89 14.89 0 0 1-1.11-2 13.62 13.62 0 0 1-.74-2 13.22 13.22 0 0 1-.42-2 16.4 16.4 0 0 1 0-4.14 13.22 13.22 0 0 1 .42-2 13.84 13.84 0 0 1 .74-2A14.94 14.94 0 0 1 2.4 2l.83.51.14.11a.4.4 0 0 1 .1.15.41.41 0 0 1 0 .21.93.93 0 0 1-.1.27A13.6 13.6 0 0 0 1.62 10zM5 13.51a1.53 1.53 0 0 1 .11-.59 1.5 1.5 0 0 1 .31-.48 1.5 1.5 0 0 1 1.65-.32 1.51 1.51 0 0 1 .8.8 1.47 1.47 0 0 1 .12.59 1.46 1.46 0 0 1-.12.59 1.56 1.56 0 0 1-.32.48 1.46 1.46 0 0 1-.48.32 1.57 1.57 0 0 1-1.18 0 1.4 1.4 0 0 1-.47-.32A1.5 1.5 0 0 1 5 13.51zm10.8-4.72l-.54.94-1.75-1-.34-.23a1.38 1.38 0 0 1-.27-.26A1.84 1.84 0 0 1 13 9v2h-1V9a2.16 2.16 0 0 1 .12-.76 1.82 1.82 0 0 1-.58.48l-1.74 1-.54-.94 1.73-1a2.25 2.25 0 0 1 .75-.29 1.77 1.77 0 0 1-.75-.28L9.2 6.2l.54-.94 1.75 1 .33.24a1.64 1.64 0 0 1 .27.27A2 2 0 0 1 12 6V4h1v2a2.93 2.93 0 0 1 0 .4 1.36 1.36 0 0 1-.1.36 2.24 2.24 0 0 1 .59-.49l1.74-1 .54.94-1.73 1-.36.18a1.29 1.29 0 0 1-.36.1 2.11 2.11 0 0 1 .36.1 2 2 0 0 1 .36.19zM18.37 10a13.65 13.65 0 0 0-.45-3.51 13.81 13.81 0 0 0-1.32-3.27.93.93 0 0 1-.1-.27.45.45 0 0 1 0-.21.36.36 0 0 1 .1-.15l.14-.11.86-.48a15.54 15.54 0 0 1 1.1 2 13.79 13.79 0 0 1 .74 2 13.18 13.18 0 0 1 .42 2 16.16 16.16 0 0 1 .14 2 16.21 16.21 0 0 1-.13 2 13.18 13.18 0 0 1-.42 2 13.57 13.57 0 0 1-.74 2 15.49 15.49 0 0 1-1.1 2l-.84-.5-.14-.11a.35.35 0 0 1-.1-.15.44.44 0 0 1 0-.21.91.91 0 0 1 .1-.27 13.62 13.62 0 0 0 1.31-3.23 13.69 13.69 0 0 0 .43-3.53z</x:String>
<!-- From https://github.com/morning4coffe-dev/storylines -->
<Style x:Key="RightAlignedToggleSwitchStyle" TargetType="ToggleSwitch">
@@ -607,7 +608,6 @@
</VisualStateManager.VisualStateGroups>
</Grid>
-
</ControlTemplate>
</Setter.Value>
</Setter>
diff --git a/src/dev/impl/DevTools.Common/UI/Controls/CustomTextBox.xaml b/src/dev/impl/DevTools.Common/UI/Controls/CustomTextBox.xaml
index a9401f4e0..03b20a38c 100644
--- a/src/dev/impl/DevTools.Common/UI/Controls/CustomTextBox.xaml
+++ b/src/dev/impl/DevTools.Common/UI/Controls/CustomTextBox.xaml
@@ -38,6 +38,19 @@
Visibility="Collapsed"/>
<TextBox
x:Name="TextBox"
+ x:DeferLoadStrategy="Lazy"
+ Grid.Row="1"
+ Grid.Column="0"
+ TabIndex="1"
+ IsSpellCheckEnabled="False"
+ TextWrapping="{x:Bind AcceptsReturn, Mode=OneWay, Converter={StaticResource BooleanToTextWrappingConverter}}"
+ IsReadOnly="{x:Bind IsReadOnly, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ AcceptsReturn="{x:Bind AcceptsReturn, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ Text="{x:Bind Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ Visibility="Collapsed"/>
+ <RichEditBox
+ x:Name="RichEditBox"
+ x:DeferLoadStrategy="Lazy"
Grid.Row="1"
Grid.Column="0"
TabIndex="1"
@@ -45,7 +58,81 @@
TextWrapping="{x:Bind AcceptsReturn, Mode=OneWay, Converter={StaticResource BooleanToTextWrappingConverter}}"
IsReadOnly="{x:Bind IsReadOnly, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
AcceptsReturn="{x:Bind AcceptsReturn, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
- Text="{x:Bind Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
+ Visibility="Collapsed">
+ <RichEditBox.ContextFlyout>
+ <MenuFlyout>
+ <MenuFlyoutItem
+ Text="{Binding Instance.Common.Cut, Source={StaticResource LanguageManager}}"
+ Command="{Binding CutCommand}">
+ <MenuFlyoutItem.Icon>
+ <FontIcon Glyph="&#xF33A;" />
+ </MenuFlyoutItem.Icon>
+ <MenuFlyoutItem.KeyboardAccelerators>
+ <KeyboardAccelerator Key="X" Modifiers="Control" IsEnabled="False"/>
+ </MenuFlyoutItem.KeyboardAccelerators>
+ </MenuFlyoutItem>
+ <MenuFlyoutItem
+ Text="{Binding Instance.Common.Copy, Source={StaticResource LanguageManager}}"
+ Command="{Binding CopyCommand}">
+ <MenuFlyoutItem.Icon>
+ <FontIcon Glyph="&#xF32B;" />
+ </MenuFlyoutItem.Icon>
+ <MenuFlyoutItem.KeyboardAccelerators>
+ <KeyboardAccelerator Key="C" Modifiers="Control" IsEnabled="False"/>
+ </MenuFlyoutItem.KeyboardAccelerators>
+ </MenuFlyoutItem>
+ <MenuFlyoutItem
+ Text="{Binding Instance.Common.Paste, Source={StaticResource LanguageManager}}"
+ Command="{Binding PasteCommand}">
+ <MenuFlyoutItem.Icon>
+ <FontIcon Glyph="&#xF2D5;" />
+ </MenuFlyoutItem.Icon>
+ <MenuFlyoutItem.KeyboardAccelerators>
+ <KeyboardAccelerator Key="V" Modifiers="Control" IsEnabled="False"/>
+ </MenuFlyoutItem.KeyboardAccelerators>
+ </MenuFlyoutItem>
+ <MenuFlyoutItem
+ Text="{Binding Instance.Common.Delete, Source={StaticResource LanguageManager}}"
+ Command="{Binding DeleteCommand}">
+ <MenuFlyoutItem.Icon>
+ <FontIcon Glyph="&#xF34C;" />
+ </MenuFlyoutItem.Icon>
+ <MenuFlyoutItem.KeyboardAccelerators>
+ <KeyboardAccelerator Key="Delete" IsEnabled="False" />
+ </MenuFlyoutItem.KeyboardAccelerators>
+ </MenuFlyoutItem>
+ <MenuFlyoutSeparator/>
+ <MenuFlyoutItem
+ Text="{Binding Instance.Common.Undo, Source={StaticResource LanguageManager}}"
+ Command="{Binding UndoCommand}">
+ <MenuFlyoutItem.Icon>
+ <FontIcon Glyph="&#xF199;" />
+ </MenuFlyoutItem.Icon>
+ <MenuFlyoutItem.KeyboardAccelerators>
+ <KeyboardAccelerator Key="Z" Modifiers="Control" IsEnabled="False" />
+ </MenuFlyoutItem.KeyboardAccelerators>
+ </MenuFlyoutItem>
+ <MenuFlyoutItem
+ Text="{Binding Instance.Common.Redo, Source={StaticResource LanguageManager}}"
+ Command="{Binding RedoCommand}">
+ <MenuFlyoutItem.Icon>
+ <FontIcon Glyph="&#xF16E;" />
+ </MenuFlyoutItem.Icon>
+ <MenuFlyoutItem.KeyboardAccelerators>
+ <KeyboardAccelerator Key="Y" Modifiers="Control" IsEnabled="False" />
+ </MenuFlyoutItem.KeyboardAccelerators>
+ </MenuFlyoutItem>
+ <MenuFlyoutSeparator/>
+ <MenuFlyoutItem
+ Text="{Binding Instance.Common.SelectAll, Source={StaticResource LanguageManager}}"
+ Command="{Binding SelectAllCommand}">
+ <MenuFlyoutItem.KeyboardAccelerators>
+ <KeyboardAccelerator Key="A" Modifiers="Control" IsEnabled="False" />
+ </MenuFlyoutItem.KeyboardAccelerators>
+ </MenuFlyoutItem>
+ </MenuFlyout>
+ </RichEditBox.ContextFlyout>
+ </RichEditBox>
<StackPanel
Grid.Row="0"
Grid.Column="0"
diff --git a/src/dev/impl/DevTools.Common/UI/Controls/CustomTextBox.xaml.cs b/src/dev/impl/DevTools.Common/UI/Controls/CustomTextBox.xaml.cs
index 95507d7d7..c417951a9 100644
--- a/src/dev/impl/DevTools.Common/UI/Controls/CustomTextBox.xaml.cs
+++ b/src/dev/impl/DevTools.Common/UI/Controls/CustomTextBox.xaml.cs
@@ -1,16 +1,24 @@
#nullable enable
+using Microsoft.Toolkit.Mvvm.Input;
using System;
+using System.Collections.Generic;
+using System.Linq;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage;
using Windows.Storage.Pickers;
+using Windows.UI;
+using Windows.UI.Text;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace DevTools.Common.UI.Controls
{
- public sealed partial class CustomTextBox : UserControl
+ public sealed partial class CustomTextBox : UserControl, ICustomTextBox
{
+ private bool _isTextPendingUpdate;
+ private IEnumerable<HighlightSpan>? _highlightedSpans;
+
public static readonly DependencyProperty HeaderProperty
= DependencyProperty.Register(
nameof(Header),
@@ -24,6 +32,19 @@ namespace DevTools.Common.UI.Controls
set => SetValue(HeaderProperty, value);
}
+ public static readonly DependencyProperty IsRichTextEditProperty
+ = DependencyProperty.Register(
+ nameof(IsRichTextEdit),
+ typeof(bool),
+ typeof(CustomTextBox),
+ new PropertyMetadata(false, OnIsRichTextEditPropertyChangedCalled));
+
+ public bool IsRichTextEdit
+ {
+ get => (bool)GetValue(IsRichTextEditProperty);
+ set => SetValue(IsRichTextEditProperty, value);
+ }
+
public static readonly DependencyProperty IsReadOnlyProperty
= DependencyProperty.Register(
nameof(IsReadOnly),
@@ -55,7 +76,7 @@ namespace DevTools.Common.UI.Controls
nameof(Text),
typeof(string),
typeof(CustomTextBox),
- new PropertyMetadata(string.Empty));
+ new PropertyMetadata(string.Empty, OnTextPropertyChangedCalled));
public string Text
{
@@ -68,18 +89,221 @@ namespace DevTools.Common.UI.Controls
InitializeComponent();
Loaded += OnLoaded;
+ ActualThemeChanged += OnActualThemeChanged;
+
+ CutCommand = new RelayCommand(ExecuteCutCommand, CanExecuteCutCommand);
+ CopyCommand = new RelayCommand(ExecuteCopyCommand, CanExecuteCopyCommand);
+ PasteCommand = new RelayCommand(ExecutePasteCommand, CanExecutePasteCommand);
+ DeleteCommand = new RelayCommand(ExecuteDeleteCommand, CanExecuteDeleteCommand);
+ UndoCommand = new RelayCommand(ExecuteUndoCommand, CanExecuteUndoCommand);
+ RedoCommand = new RelayCommand(ExecuteRedoCommand, CanExecuteRedoCommand);
+ SelectAllCommand = new RelayCommand(ExecuteSelectAllCommand, CanExecuteSelectAllCommand);
+
+ DataContext = this;
+ }
+
+ #region CutCommand
+
+ public IRelayCommand CutCommand { get; }
+
+ private bool CanExecuteCutCommand()
+ {
+ return RichEditBox != null && RichEditBox.TextDocument.Selection.Length != 0 && IsEnabled && RichEditBox.TextDocument.CanCopy();
+ }
+
+ private void ExecuteCutCommand()
+ {
+ RichEditBox.TextDocument.Selection.Cut();
+ }
+
+ #endregion
+
+ #region CopyCommand
+
+ public IRelayCommand CopyCommand { get; }
+
+ private bool CanExecuteCopyCommand()
+ {
+ return RichEditBox != null && RichEditBox.TextDocument.Selection.Length != 0 && IsEnabled && RichEditBox.TextDocument.CanCopy();
+ }
+
+ private void ExecuteCopyCommand()
+ {
+ RichEditBox.TextDocument.Selection.Copy();
+ }
+
+ #endregion
+
+ #region PasteCommand
+
+ public IRelayCommand PasteCommand { get; }
+
+ private bool CanExecutePasteCommand()
+ {
+ return RichEditBox != null && RichEditBox.TextDocument.CanPaste() && IsEnabled;
+ }
+
+ private void ExecutePasteCommand()
+ {
+ PasteButton_Click(this, null!);
+ }
+
+ #endregion
+
+ #region DeleteCommand
+
+ public IRelayCommand DeleteCommand { get; }
+
+ private bool CanExecuteDeleteCommand()
+ {
+ return RichEditBox != null && RichEditBox.TextDocument.Selection.Length != 0 && IsEnabled && !IsReadOnly;
+ }
+
+ private void ExecuteDeleteCommand()
+ {
+ RichEditBox.TextDocument.BeginUndoGroup();
+ RichEditBox.TextDocument.Selection.SetText(TextSetOptions.None, string.Empty);
+ RichEditBox.TextDocument.EndUndoGroup();
+ }
+
+ #endregion
+
+ #region UndoCommand
+
+ public IRelayCommand UndoCommand { get; }
+
+ private bool CanExecuteUndoCommand()
+ {
+ return RichEditBox != null && RichEditBox.TextDocument.CanUndo() && IsEnabled && !IsReadOnly;
+ }
+
+ private void ExecuteUndoCommand()
+ {
+ RichEditBox.TextDocument.Undo();
+ }
+
+ #endregion
+
+ #region RedoCommand
+
+ public IRelayCommand RedoCommand { get; }
+
+ private bool CanExecuteRedoCommand()
+ {
+ return RichEditBox != null && RichEditBox.TextDocument.CanRedo() && IsEnabled && !IsReadOnly;
+ }
+
+ private void ExecuteRedoCommand()
+ {
+ RichEditBox.TextDocument.Redo();
+ }
+
+ #endregion
+
+ #region SelectAllCommand
+
+ public IRelayCommand SelectAllCommand { get; }
+
+ private bool CanExecuteSelectAllCommand()
+ {
+ return IsEnabled;
+ }
+
+ private void ExecuteSelectAllCommand()
+ {
+ RichEditBox.TextDocument.Selection.SetRange(0, int.MaxValue);
+ }
+
+ #endregion
+
+ public void SetHighlights(IEnumerable<HighlightSpan>? spans)
+ {
+ IEnumerable<HighlightSpan>? highlightsToRemove = _highlightedSpans?.Except(spans ?? Array.Empty<HighlightSpan>());
+ IEnumerable<HighlightSpan>? highlightsToAdd = spans?.Except(_highlightedSpans ?? Array.Empty<HighlightSpan>());
+
+ _highlightedSpans = spans;
+
+ if (!IsRichTextEdit)
+ {
+ return;
+ }
+
+ var richEditBox = GetRichEditBox();
+ richEditBox.TextDocument.BatchDisplayUpdates();
+
+ if (highlightsToRemove is not null)
+ {
+ foreach (HighlightSpan span in highlightsToRemove)
+ {
+ ITextRange range
+ = richEditBox.TextDocument.GetRange(
+ span.StartIndex,
+ span.StartIndex + span.Length);
+ range.CharacterFormat.BackgroundColor = Colors.Transparent;
+ range.CharacterFormat.ForegroundColor = ActualTheme == ElementTheme.Dark ? Colors.White : Colors.Black;
+ }
+ }
+
+ if (highlightsToAdd is not null)
+ {
+ foreach (HighlightSpan span in highlightsToAdd)
+ {
+ ITextRange range
+ = richEditBox.TextDocument.GetRange(
+ span.StartIndex,
+ span.StartIndex + span.Length);
+ range.CharacterFormat.BackgroundColor = span.BackgroundColor;
+ range.CharacterFormat.ForegroundColor = span.ForegroundColor;
+ }
+ }
+
+ richEditBox.TextDocument.ApplyDisplayUpdates();
}
- private void UpdateCopyButtons()
+ private void UpdateUI()
{
+ if (Header is not null)
+ {
+ GetHeaderContentPresenter().Visibility = Visibility.Visible;
+ }
+
+ if (IsRichTextEdit)
+ {
+ var richEditBox = GetRichEditBox();
+ richEditBox.Visibility = Visibility.Visible;
+ richEditBox.TextChanging += RichEditBox_TextChanging;
+ richEditBox.SelectionFlyout = null;
+
+ if (TextBox is not null)
+ {
+ GetTextBox().Visibility = Visibility.Collapsed;
+ }
+ }
+ else
+ {
+ if (RichEditBox is not null)
+ {
+ GetRichEditBox().Visibility = Visibility.Collapsed;
+ }
+ GetTextBox().Visibility = Visibility.Visible;
+ }
+
if (IsReadOnly)
{
if (!AcceptsReturn)
{
GetInlinedCopyButton().Visibility = Visibility.Visible;
+ if (CopyButton is not null)
+ {
+ GetCopyButton().Visibility = Visibility.Collapsed;
+ }
}
else
{
+ if (InlinedCopyButton is not null)
+ {
+ GetInlinedCopyButton().Visibility = Visibility.Collapsed;
+ }
GetCopyButton().Visibility = Visibility.Visible;
}
@@ -91,9 +315,9 @@ namespace DevTools.Common.UI.Controls
}
else
{
+ GetPasteButton().Visibility = Visibility.Visible;
if (AcceptsReturn)
{
- GetPasteButton().Visibility = Visibility.Visible;
GetOpenFileButton().Visibility = Visibility.Visible;
}
@@ -134,17 +358,60 @@ namespace DevTools.Common.UI.Controls
return (ContentPresenter)(HeaderContentPresenter ?? FindName(nameof(HeaderContentPresenter)));
}
+ private TextBox GetTextBox()
+ {
+ return (TextBox)(TextBox ?? FindName(nameof(TextBox)));
+ }
+
+ private RichEditBox GetRichEditBox()
+ {
+ return (RichEditBox)(RichEditBox ?? FindName(nameof(RichEditBox)));
+ }
+
private void OnLoaded(object sender, RoutedEventArgs e)
{
- if (Header is not null)
- {
- GetHeaderContentPresenter().Visibility = Visibility.Visible;
- }
+ UpdateUI();
+ }
+
+ private void OnActualThemeChanged(FrameworkElement sender, object args)
+ {
+ SetHighlights(_highlightedSpans);
}
- private void PasteButton_Click(object sender, RoutedEventArgs e)
+ private async void PasteButton_Click(object sender, RoutedEventArgs e)
{
- TextBox.PasteFromClipboard();
+ if (IsRichTextEdit)
+ {
+ var richEditBox = GetRichEditBox();
+ if (!richEditBox.TextDocument.CanPaste())
+ {
+ return;
+ }
+
+ try
+ {
+ DataPackageView? dataPackageView = Clipboard.GetContent();
+ if (!dataPackageView.Contains(StandardDataFormats.Text))
+ {
+ return;
+ }
+
+ string? text = await dataPackageView.GetTextAsync();
+
+ richEditBox.TextDocument.BeginUndoGroup();
+ richEditBox.TextDocument.Selection.SetText(TextSetOptions.None, text);
+ richEditBox.TextDocument.Selection.StartPosition = richEditBox.TextDocument.Selection.EndPosition;
+ richEditBox.TextDocument.EndUndoGroup();
+ }
+ catch (Exception ex)
+ {
+ // TODO: Log this.
+ }
+ }
+ else
+ {
+ TextBox.PasteFromClipboard();
+ }
}
private void CopyButton_Click(object sender, RoutedEventArgs e)
@@ -188,14 +455,54 @@ namespace DevTools.Common.UI.Controls
}
}
+ private void RichEditBox_TextChanging(RichEditBox sender, RichEditBoxTextChangingEventArgs args)
+ {
+ if (args.IsContentChanging)
+ {
+ if (!_isTextPendingUpdate)
+ {
+ RichEditBox.TextDocument.GetText(TextGetOptions.UseCrlf, out var document);
+ _isTextPendingUpdate = true;
+ Text = document;
+ SetHighlights(_highlightedSpans);
+ _isTextPendingUpdate = false;
+ }
+ }
+ }
+
private static void OnIsReadOnlyPropertyChangedCalled(DependencyObject sender, DependencyPropertyChangedEventArgs eventArgs)
{
- ((CustomTextBox)sender).UpdateCopyButtons();
+ ((CustomTextBox)sender).UpdateUI();
}
private static void OnAcceptsReturnPropertyChangedCalled(DependencyObject sender, DependencyPropertyChangedEventArgs eventArgs)
{
- ((CustomTextBox)sender).UpdateCopyButtons();
+ ((CustomTextBox)sender).UpdateUI();
+ }
+
+ private static void OnIsRichTextEditPropertyChangedCalled(DependencyObject sender, DependencyPropertyChangedEventArgs eventArgs)
+ {
+ ((CustomTextBox)sender).UpdateUI();
+ }
+
+ private static void OnTextPropertyChangedCalled(DependencyObject sender, DependencyPropertyChangedEventArgs eventArgs)
+ {
+ var customTextBox = (CustomTextBox)sender;
+ if (customTextBox.IsRichTextEdit)
+ {
+ if (!customTextBox._isTextPendingUpdate)
+ {
+ string? text = eventArgs.NewValue as string;
+
+ customTextBox._isTextPendingUpdate = true;
+ bool isReadOnly = customTextBox.IsReadOnly;
+ customTextBox.IsReadOnly = false;
+ customTextBox.RichEditBox.Document.SetText(TextSetOptions.None, text ?? string.Empty);
+ customTextBox.SetHighlights(customTextBox._highlightedSpans);
+ customTextBox.IsReadOnly = isReadOnly;
+ customTextBox._isTextPendingUpdate = false;
+ }
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/dev/impl/DevTools.Common/UI/Controls/FormattedTextBlock/FormattedTextBlock.xaml b/src/dev/impl/DevTools.Common/UI/Controls/FormattedTextBlock/FormattedTextBlock.xaml
index 775a179a1..f6146861a 100644
--- a/src/dev/impl/DevTools.Common/UI/Controls/FormattedTextBlock/FormattedTextBlock.xaml
+++ b/src/dev/impl/DevTools.Common/UI/Controls/FormattedTextBlock/FormattedTextBlock.xaml
@@ -10,6 +10,10 @@
d:DesignWidth="400">
<Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="*"/>
+ </Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Disabled">
@@ -54,8 +58,20 @@
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
+ <ContentPresenter
+ x:Name="HeaderContentPresenter"
+ x:DeferLoadStrategy="Lazy"
+ Grid.Row="0"
+ Content="{x:Bind Header}"
+ Foreground="{ThemeResource TextControlHeaderForeground}"
+ Margin="{ThemeResource TextBoxTopHeaderMargin}"
+ FontWeight="Normal"
+ TextWrapping="Wrap"
+ VerticalAlignment="Bottom"
+ Visibility="Collapsed"/>
<Border
x:Name="BorderElement"
+ Grid.Row="1"
Background="{ThemeResource TextControlBackground}"
BorderThickness="{ThemeResource TextControlBorderThemeThickness}"
BorderBrush="{ThemeResource TextControlBorderBrush}"
@@ -64,6 +80,7 @@
MinWidth="{ThemeResource TextControlThemeMinWidth}"/>
<ScrollViewer
x:Name="ContentElement"
+ Grid.Row="1"
AutomationProperties.AccessibilityView="Raw"
HorizontalScrollBarVisibility="Auto"
HorizontalScrollMode="Enabled"
diff --git a/src/dev/impl/DevTools.Common/UI/Controls/FormattedTextBlock/FormattedTextBlock.xaml.cs b/src/dev/impl/DevTools.Common/UI/Controls/FormattedTextBlock/FormattedTextBlock.xaml.cs
index f27453170..886697f36 100644
--- a/src/dev/impl/DevTools.Common/UI/Controls/FormattedTextBlock/FormattedTextBlock.xaml.cs
+++ b/src/dev/impl/DevTools.Common/UI/Controls/FormattedTextBlock/FormattedTextBlock.xaml.cs
@@ -45,6 +45,19 @@ namespace DevTools.Common.UI.Controls.FormattedTextBlock
set => SetValue(SettingsProviderProperty, value);
}
+ public static readonly DependencyProperty HeaderProperty
+ = DependencyProperty.Register(
+ nameof(Header),
+ typeof(object),
+ typeof(FormattedTextBlock),
+ new PropertyMetadata(null));
+
+ public object Header
+ {
+ get => (object)GetValue(HeaderProperty);
+ set => SetValue(HeaderProperty, value);
+ }
+
public FormattedTextBlock()
{
InitializeComponent();
@@ -431,10 +444,20 @@ namespace DevTools.Common.UI.Controls.FormattedTextBlock
return minRequisiteWidth;
}
+ private ContentPresenter GetHeaderContentPresenter()
+ {
+ return (ContentPresenter)(HeaderContentPresenter ?? FindName(nameof(HeaderContentPresenter)));
+ }
+
private void OnLoaded(object sender, RoutedEventArgs e)
{
_loaded = true;
+ if (Header is not null)
+ {
+ GetHeaderContentPresenter().Visibility = Visibility.Visible;
+ }
+
ResetRootGridClipping();
UpdateLineHighlighterAndIndicator();
diff --git a/src/dev/impl/DevTools.Common/UI/Controls/HighlightSpan.cs b/src/dev/impl/DevTools.Common/UI/Controls/HighlightSpan.cs
new file mode 100644
index 000000000..f1f7fe9c5
--- /dev/null
+++ b/src/dev/impl/DevTools.Common/UI/Controls/HighlightSpan.cs
@@ -0,0 +1,35 @@
+using System.Collections.Generic;
+using Windows.UI;
+
+namespace DevTools.Common.UI.Controls
+{
+ public struct HighlightSpan
+ {
+ public int StartIndex { get; set; }
+
+ public int Length { get; set; }
+
+ public Color ForegroundColor { get; set; }
+
+ public Color BackgroundColor { get; set; }
+
+ public override bool Equals(object obj)
+ {
+ return obj is HighlightSpan span &&
+ StartIndex == span.StartIndex &&
+ Length == span.Length &&
+ EqualityComparer<Color>.Default.Equals(ForegroundColor, span.ForegroundColor) &&
+ EqualityComparer<Color>.Default.Equals(BackgroundColor, span.BackgroundColor);
+ }
+
+ public override int GetHashCode()
+ {
+ int hashCode = -1153736223;
+ hashCode = (hashCode * -1521134295) + StartIndex.GetHashCode();
+ hashCode = (hashCode * -1521134295) + Length.GetHashCode();
+ hashCode = (hashCode * -1521134295) + ForegroundColor.GetHashCode();
+ hashCode = (hashCode * -1521134295) + BackgroundColor.GetHashCode();
+ return hashCode;
+ }
+ }
+}
diff --git a/src/dev/impl/DevTools.Common/UI/Controls/ICustomTextBox.cs b/src/dev/impl/DevTools.Common/UI/Controls/ICustomTextBox.cs
new file mode 100644
index 000000000..5b4347405
--- /dev/null
+++ b/src/dev/impl/DevTools.Common/UI/Controls/ICustomTextBox.cs
@@ -0,0 +1,11 @@
+#nullable enable
+
+using System.Collections.Generic;
+
+namespace DevTools.Common.UI.Controls
+{
+ public interface ICustomTextBox
+ {
+ void SetHighlights(IEnumerable<HighlightSpan> spans);
+ }
+}
diff --git a/src/dev/impl/DevTools.Core.Impl/Threading/Thread.cs b/src/dev/impl/DevTools.Core.Impl/Threading/Thread.cs
index 279499849..065628885 100644
--- a/src/dev/impl/DevTools.Core.Impl/Threading/Thread.cs
+++ b/src/dev/impl/DevTools.Core.Impl/Threading/Thread.cs
@@ -32,6 +32,11 @@ namespace DevTools.Core.Impl.Threading
}
public Task RunOnUIThreadAsync(Action action)
+ {
+ return RunOnUIThreadAsync(ThreadPriority.Normal, action);
+ }
+
+ public Task RunOnUIThreadAsync(ThreadPriority priority, Action action)
{
if (action is null)
{
@@ -45,11 +50,16 @@ namespace DevTools.Core.Impl.Threading
}
else
{
- return _uiDispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action()).AsTask();
+ return _uiDispatcher.RunAsync(GetDispatcherPriority(priority), () => action()).AsTask();
}
}
- public async Task RunOnUIThreadAsync(Func<Task> action)
+ public Task RunOnUIThreadAsync(Func<Task> action)
+ {
+ return RunOnUIThreadAsync(ThreadPriority.Normal, action);
+ }
+
+ public async Task RunOnUIThreadAsync(ThreadPriority priority, Func<Task> action)
{
if (action is null)
{
@@ -64,8 +74,8 @@ namespace DevTools.Core.Impl.Threading
{
var tcs = new TaskCompletionSource<object>();
await _uiDispatcher.RunAsync(
- CoreDispatcherPriority.Normal,
- async() =>
+ GetDispatcherPriority(priority),
+ async () =>
{
try
{
@@ -78,9 +88,9 @@ namespace DevTools.Core.Impl.Threading
}
finally
{
- #pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
+#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
tcs.TrySetResult(null);
- #pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
+#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
}
});
@@ -88,7 +98,12 @@ namespace DevTools.Core.Impl.Threading
}
}
- public async Task<T> RunOnUIThreadAsync<T>(Func<Task<T>> action)
+ public Task<T> RunOnUIThreadAsync<T>(Func<Task<T>> action)
+ {
+ return RunOnUIThreadAsync(ThreadPriority.Normal, action);
+ }
+
+ public async Task<T> RunOnUIThreadAsync<T>(ThreadPriority priority, Func<Task<T>> action)
{
Arguments.NotNull(action, nameof(action));
@@ -101,7 +116,7 @@ namespace DevTools.Core.Impl.Threading
T result = default!;
var tcs = new TaskCompletionSource<object>();
_uiDispatcher.RunAsync(
- CoreDispatcherPriority.Normal, async () =>
+ GetDispatcherPriority(priority), async () =>
{
try
{
@@ -114,9 +129,9 @@ namespace DevTools.Core.Impl.Threading
}
finally
{
- #pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
+#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
tcs.TrySetResult(null);
- #pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
+#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
}
}).AsTask().ForgetSafely();
@@ -124,5 +139,20 @@ namespace DevTools.Core.Impl.Threading
return result!;
}
}
+
+ private CoreDispatcherPriority GetDispatcherPriority(ThreadPriority priority)
+ {
+ switch (priority)
+ {
+ case ThreadPriority.Low:
+ return CoreDispatcherPriority.Low;
+ case ThreadPriority.Normal:
+ return CoreDispatcherPriority.Normal;
+ case ThreadPriority.High:
+ return CoreDispatcherPriority.High;
+ default:
+ throw new NotSupportedException();
+ }
+ }
}
}
diff --git a/src/dev/impl/DevTools.Impl/Views/Settings/SettingsToolPage.xaml b/src/dev/impl/DevTools.Impl/Views/Settings/SettingsToolPage.xaml
index b31ccf245..1a448b134 100644
--- a/src/dev/impl/DevTools.Impl/Views/Settings/SettingsToolPage.xaml
+++ b/src/dev/impl/DevTools.Impl/Views/Settings/SettingsToolPage.xaml
@@ -13,7 +13,7 @@
<converters:EnumToBooleanConverter x:Key="EnumToBooleanConverter"/>
</Page.Resources>
- <StackPanel Spacing="4">
+ <StackPanel Margin="0,0,0,16" Spacing="4">
<StackPanel.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition IsStaggeringEnabled="True" FromVerticalOffset="50"/>
diff --git a/src/dev/impl/DevTools.Providers.Impl/DevTools.Providers.Impl.csproj b/src/dev/impl/DevTools.Providers.Impl/DevTools.Providers.Impl.csproj
index 2e25b7313..7df93f373 100644
--- a/src/dev/impl/DevTools.Providers.Impl/DevTools.Providers.Impl.csproj
+++ b/src/dev/impl/DevTools.Providers.Impl/DevTools.Providers.Impl.csproj
@@ -90,6 +90,11 @@
<DependentUpon>JsonFormatterToolPage.xaml</DependentUpon>
</Compile>
<Compile Include="Tools\JsonFormatter\JsonFormatterToolViewModel.cs" />
+ <Compile Include="Tools\RegEx\RegExToolPage.xaml.cs">
+ <DependentUpon>RegExToolPage.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="Tools\RegEx\RegExToolProvider.cs" />
+ <Compile Include="Tools\RegEx\RegExToolViewModel.cs" />
<Compile Include="Tools\TextDiff\TextDiffToolPage.xaml.cs">
<DependentUpon>TextDiffToolPage.xaml</DependentUpon>
</Compile>
@@ -130,6 +135,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Tools\RegEx\RegExToolPage.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="Tools\TextDiff\TextDiffToolPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
diff --git a/src/dev/impl/DevTools.Providers.Impl/Tools/HashGenerator/HashGeneratorToolPage.xaml b/src/dev/impl/DevTools.Providers.Impl/Tools/HashGenerator/HashGeneratorToolPage.xaml
index 269a281ab..3035f7505 100644
--- a/src/dev/impl/DevTools.Providers.Impl/Tools/HashGenerator/HashGeneratorToolPage.xaml
+++ b/src/dev/impl/DevTools.Providers.Impl/Tools/HashGenerator/HashGeneratorToolPage.xaml
@@ -16,39 +16,41 @@
</TransitionCollection>
</StackPanel.ChildrenTransitions>
- <TextBlock Style="{StaticResource SubTitleTextBlock}" Text="Configuration" />
+ <TextBlock Style="{StaticResource SubTitleTextBlock}" Text="{x:Bind ViewModel.Strings.Configuration}" />
<controls:ExpandableSettingControl
- Title="Uppercase">
+ Title="{x:Bind ViewModel.Strings.Uppercase}">
<controls:ExpandableSettingControl.Icon>
<FontIcon Glyph="&#xF7B2;" />
</controls:ExpandableSettingControl.Icon>
- <ToggleSwitch Style="{StaticResource RightAlignedToggleSwitchStyle}" IsOn="{x:Bind ViewModel.IsUppercase, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
+ <ToggleSwitch
+ Style="{StaticResource RightAlignedToggleSwitchStyle}"
+ IsOn="{x:Bind ViewModel.IsUppercase, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</controls:ExpandableSettingControl>
<controls:CustomTextBox
- Header="Input"
+ Header="{x:Bind ViewModel.Strings.Input}"
Height="150"
AcceptsReturn="True"
Text="{x:Bind ViewModel.Input, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<controls:CustomTextBox
- Header="MD5"
+ Header="{x:Bind ViewModel.Strings.MD5}"
IsReadOnly="True"
Text="{x:Bind ViewModel.MD5, Mode=OneWay}"/>
<controls:CustomTextBox
- Header="SHA1"
+ Header="{x:Bind ViewModel.Strings.SHA1}"
IsReadOnly="True"
Text="{x:Bind ViewModel.SHA1, Mode=OneWay}"/>
<controls:CustomTextBox
- Header="SHA256"
+ Header="{x:Bind ViewModel.Strings.SHA256}"
IsReadOnly="True"
Text="{x:Bind ViewModel.SHA256, Mode=OneWay}"/>
<controls:CustomTextBox
- Header="SHA512"
+ Header="{x:Bind ViewModel.Strings.SHA512}"
IsReadOnly="True"
Text="{x:Bind ViewModel.SHA512, Mode=OneWay}"/>
</StackPanel>
diff --git a/src/dev/impl/DevTools.Providers.Impl/Tools/HashGenerator/HashGeneratorToolViewModel.cs b/src/dev/impl/DevTools.Providers.Impl/Tools/HashGenerator/HashGeneratorToolViewModel.cs
index 38db35b9a..97caeed41 100644
--- a/src/dev/impl/DevTools.Providers.Impl/Tools/HashGenerator/HashGeneratorToolViewModel.cs
+++ b/src/dev/impl/DevTools.Providers.Impl/Tools/HashGenerator/HashGeneratorToolViewModel.cs
@@ -1,5 +1,6 @@
#nullable enable
+using DevTools.Common;
using DevTools.Core.Threading;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
@@ -28,6 +29,8 @@ namespace DevTools.Providers.Impl.Tools.HashGenerator
public Type View { get; } = typeof(HashGeneratorToolPage);
+ internal HashGeneratorStrings Strings => LanguageManager.Instance.HashGenerator;
+
internal bool IsUppercase
{
get => _isUppercase;
diff --git a/src/dev/impl/DevTools.Providers.Impl/Tools/RegEx/RegExToolPage.xaml b/src/dev/impl/DevTools.Providers.Impl/Tools/RegEx/RegExToolPage.xaml
new file mode 100644
index 000000000..1f464771e
--- /dev/null
+++ b/src/dev/impl/DevTools.Providers.Impl/Tools/RegEx/RegExToolPage.xaml
@@ -0,0 +1,37 @@
+<Page
+ x:Class="DevTools.Providers.Impl.Tools.RegEx.RegExToolPage"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:local="using:DevTools.Providers.Impl.Tools.RegEx"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:controls="using:DevTools.Common.UI.Controls"
+ mc:Ignorable="d"
+ NavigationCacheMode="Required">
+
+ <Grid Margin="0,0,0,16" RowSpacing="12">
+ <Grid.ChildrenTransitions>
+ <TransitionCollection>
+ <EntranceThemeTransition IsStaggeringEnabled="True" FromVerticalOffset="50"/>
+ </TransitionCollection>
+ </Grid.ChildrenTransitions>
+
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto"/>
+ <RowDefinition Height="*"/>
+ </Grid.RowDefinitions>
+
+ <controls:CustomTextBox
+ Grid.Row="0"
+ Header="Regular expression"
+ Text="{x:Bind ViewModel.RegularExpression, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
+
+ <controls:CustomTextBox
+ x:Name="MatchTextBox"
+ Grid.Row="1"
+ Header="Text"
+ AcceptsReturn="True"
+ IsRichTextEdit="True"
+ Text="{x:Bind ViewModel.Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
+ </Grid>
+</Page>
diff --git a/src/dev/impl/DevTools.Providers.Impl/Tools/RegEx/RegExToolPage.xaml.cs b/src/dev/impl/DevTools.Providers.Impl/Tools/RegEx/RegExToolPage.xaml.cs
new file mode 100644
index 000000000..83108655e
--- /dev/null
+++ b/src/dev/impl/DevTools.Providers.Impl/Tools/RegEx/RegExToolPage.xaml.cs
@@ -0,0 +1,46 @@
+#nullable enable
+
+using DevTools.Core.Navigation;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Navigation;
+
+namespace DevTools.Providers.Impl.Tools.RegEx
+{
+ public sealed partial class RegExToolPage : Page
+ {
+ public static readonly DependencyProperty ViewModelProperty
+ = DependencyProperty.Register(
+ nameof(ViewModel),
+ typeof(RegExToolViewModel),
+ typeof(RegExToolPage),
+ new PropertyMetadata(null));
+
+ /// <summary>
+ /// Gets the page's view model.
+ /// </summary>
+ public RegExToolViewModel ViewModel
+ {
+ get => (RegExToolViewModel)GetValue(ViewModelProperty);
+ set => SetValue(ViewModelProperty, value);
+ }
+
+ public RegExToolPage()
+ {
+ InitializeComponent();
+ }
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ var parameters = (NavigationParameter)e.Parameter;
+
+ // Set the view model
+ ViewModel = (RegExToolViewModel)parameters.Parameter!;
+ DataContext = ViewModel;
+
+ ViewModel.MatchTextBox = MatchTextBox;
+
+ base.OnNavigatedTo(e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/dev/impl/DevTools.Providers.Impl/Tools/RegEx/RegExToolProvider.cs b/src/dev/impl/DevTools.Providers.Impl/Tools/RegEx/RegExToolProvider.cs
new file mode 100644
index 000000000..9c9cc112d
--- /dev/null
+++ b/src/dev/impl/DevTools.Providers.Impl/Tools/RegEx/RegExToolProvider.cs
@@ -0,0 +1,42 @@
+#nullable enable
+
+using DevTools.Common;
+using DevTools.Core.Injection;
+using DevTools.Core.Threading;
+using System.Composition;
+
+namespace DevTools.Providers.Impl.Tools.RegEx
+{
+ [Export(typeof(IToolProvider))]
+ [Name("Regular Expression Tester")]
+ [ProtocolName("regex")]
+ [Order(0)]
+ [NotScrollable]
+ internal sealed class RegExToolProvider : ToolProviderBase, IToolProvider
+ {
+ private readonly IThread _thread;
+ private readonly IMefProvider _mefProvider;
+
+ public string? DisplayName => LanguageManager.Instance.RegEx.DisplayName;
+
+ public object IconSource => CreatePathIconFromPath(nameof(RegExToolProvider));
+
+ [ImportingConstructor]
+ public RegExToolProvider(IThread thread, IMefProvider mefProvider)
+ : base(thread)
+ {
+ _thread = thread;
+ _mefProvider = mefProvider;
+ }
+
+ public bool CanBeTreatedByTool(string data)
+ {
+ return false;
+ }
+
+ public IToolViewModel CreateTool()
+ {
+ return _mefProvider.Import<RegExToolViewModel>();
+ }
+ }
+}
diff --git a/src/dev/impl/DevTools.Providers.Impl/Tools/RegEx/RegExToolViewModel.cs b/src/dev/impl/DevTools.Providers.Impl/Tools/RegEx/RegExToolViewModel.cs
new file mode 100644
index 000000000..a31d1a6b4
--- /dev/null
+++ b/src/dev/impl/DevTools.Providers.Impl/Tools/RegEx/RegExToolViewModel.cs
@@ -0,0 +1,114 @@
+#nullable enable
+
+using DevTools.Common;
+using DevTools.Common.UI.Controls;
+using DevTools.Core.Threading;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using System;
+using System.Collections.Generic;
+using System.Composition;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using Windows.UI;
+
+namespace DevTools.Providers.Impl.Tools.RegEx
+{
+ [Export(typeof(RegExToolViewModel))]
+ public sealed class RegExToolViewModel : ObservableRecipient, IToolViewModel
+ {
+ private readonly IThread _thread;
+ private readonly Queue<(string pattern, string text)> _regExMatchingQueue = new();
+
+ private bool _calculationInProgress;
+ private string? _regularExpression;
+ private string? _text;
+
+ public Type View { get; } = typeof(RegExToolPage);
+
+ internal RegExStrings Strings => LanguageManager.Instance.RegEx;
+
+ internal string? RegularExpression
+ {
+ get => _regularExpression;
+ set
+ {
+ SetProperty(ref _regularExpression, value);
+ QueueRegExMatch();
+ }
+ }
+
+ internal string? Text
+ {
+ get => _text;
+ set
+ {
+ SetProperty(ref _text, value);
+ QueueRegExMatch();
+ }
+ }
+
+ internal ICustomTextBox? MatchTextBox { private get; set; }
+
+ [ImportingConstructor]
+ public RegExToolViewModel(IThread thread)
+ {
+ _thread = thread;
+ }
+
+ private void QueueRegExMatch()
+ {
+ _regExMatchingQueue.Enqueue(new(RegularExpression ?? string.Empty, Text ?? string.Empty));
+ TreatQueueAsync().Forget();
+ }
+
+ private async Task TreatQueueAsync()
+ {
+ if (_calculationInProgress)
+ {
+ return;
+ }
+
+ _calculationInProgress = true;
+
+ await TaskScheduler.Default;
+
+ while (_regExMatchingQueue.TryDequeue(out (string pattern, string text) data))
+ {
+ var spans = new List<HighlightSpan>();
+
+ try
+ {
+ string pattern = data.pattern.Trim('/');
+
+ var regex = new Regex(data.pattern, RegexOptions.Multiline);
+ MatchCollection matches = regex.Matches(data.text.Replace("\r\n", "\r"));
+
+ foreach (Match match in matches)
+ {
+ spans.Add(
+ new HighlightSpan()
+ {
+ StartIndex = match.Index,
+ Length = match.Length,
+ BackgroundColor = Colors.Yellow,
+ ForegroundColor = Colors.Black
+ });
+ }
+ }
+ catch
+ {
+ // TODO: indicate the user that the regex is wrong.
+ }
+
+ _thread.RunOnUIThreadAsync(
+ ThreadPriority.Low,
+ () =>
+ {
+ MatchTextBox?.SetHighlights(spans);
+ }).ForgetSafely();
+ }
+
+ _calculationInProgress = false;
+ }
+ }
+}
diff --git a/src/dev/impl/DevTools.Providers.Impl/Tools/TextDiff/TextDiffToolPage.xaml b/src/dev/impl/DevTools.Providers.Impl/Tools/TextDiff/TextDiffToolPage.xaml
index 14f938d84..711110c15 100644
--- a/src/dev/impl/DevTools.Providers.Impl/Tools/TextDiff/TextDiffToolPage.xaml
+++ b/src/dev/impl/DevTools.Providers.Impl/Tools/TextDiff/TextDiffToolPage.xaml
@@ -24,7 +24,6 @@
<Grid.RowDefinitions>
<RowDefinition Height="{x:Bind ExandableInput.IsExpanded, Mode=OneWay, Converter={StaticResource BooleanToGridLengthConverter}}"/>
- <RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
@@ -34,58 +33,35 @@
VerticalAlignment="Stretch"
VerticalContentAlignment="Stretch"
IsExpanded="True"
- Title="Inputs">
+ Title="{x:Bind ViewModel.Strings.Inputs}">
<controls:ExpandableSettingControl.ExpandableContent>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
-
- <Grid
- Grid.Column="0"
- Grid.Row="0"
- Margin="0,0,6,8">
- <TextBlock Text="Old text"/>
- </Grid>
-
- <Grid
- Grid.Column="1"
- Grid.Row="0"
- Margin="6,0,0,8">
- <TextBlock Text="New text"/>
- </Grid>
<texteditor:TextEditor
Grid.Column="0"
- Grid.Row="1"
Margin="0,0,6,0"
SettingsProvider="{x:Bind ViewModel.SettingsProvider}"
+ Header="{x:Bind ViewModel.Strings.LeftText}"
Text="{x:Bind ViewModel.OldText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<texteditor:TextEditor
Grid.Column="1"
- Grid.Row="1"
Margin="6,0,0,0"
SettingsProvider="{x:Bind ViewModel.SettingsProvider}"
+ Header="{x:Bind ViewModel.Strings.RightText}"
Text="{x:Bind ViewModel.NewText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</controls:ExpandableSettingControl.ExpandableContent>
</controls:ExpandableSettingControl>
- <Grid
- Grid.Row="1"
- Margin="0,0,0,8">
- <TextBlock Text="Difference"/>
- </Grid>
-
<formattedtextblock:FormattedTextBlock
x:Name="OuputTextEditor"
- Grid.Row="2"
+ Grid.Row="1"
+ Header="{x:Bind ViewModel.Strings.Difference}"
SettingsProvider="{x:Bind ViewModel.SettingsProvider}"/>
</Grid>
</Page>
diff --git a/src/dev/impl/DevTools.Providers.Impl/Tools/TextDiff/TextDiffToolViewModel.cs b/src/dev/impl/DevTools.Providers.Impl/Tools/TextDiff/TextDiffToolViewModel.cs
index 5dfec7d0b..d411329a5 100644
--- a/src/dev/impl/DevTools.Providers.Impl/Tools/TextDiff/TextDiffToolViewModel.cs
+++ b/src/dev/impl/DevTools.Providers.Impl/Tools/TextDiff/TextDiffToolViewModel.cs
@@ -1,5 +1,6 @@
#nullable enable
+using DevTools.Common;
using DevTools.Common.UI.Controls.FormattedTextBlock;
using DevTools.Core;
using DevTools.Core.Settings;
@@ -26,6 +27,8 @@ namespace DevTools.Providers.Impl.Tools.TextDiff
internal ISettingsProvider SettingsProvider { get; }
+ internal TextDiffStrings Strings => LanguageManager.Instance.TextDiff;
+
internal string? OldText
{
get => _oldText;
@@ -78,7 +81,7 @@ namespace DevTools.Providers.Impl.Tools.TextDiff
while (_comparisonQueue.TryDequeue(out (string? oldText, string? newText) item))
{
- // await TextEditor!.ShowTextDiffAsync(item.oldText, item.newText);
+ // await TextEditor!.ShowTextDiffAsync(item.oldText, item.newText);
}
_comparisonInProgress = false;