A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Added expand button to text input
Etienne Baudoux6cc21bf6dead
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDiffTextInput.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDiffTextInput.csindex d5642a561..58fa57b9f 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDiffTextInput.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDiffTextInput.cs@@ -23,6 +23,11 @@ public interface IUIDiffTextInput : IUISingleLineTextInput/// </summary>bool InlineMode { get; }+ /// <summary>+ /// Gets whether the element can be expanded to take the size of the whole tool boundaries.+ /// </summary>+ bool IsExtendableToFullScreen { get; }+/// <summary>/// Raised when <see cref="ModifiedText"/> is changed./// </summary>@@ -32,6 +37,11 @@ public interface IUIDiffTextInput : IUISingleLineTextInput/// Raised when <see cref="InlineMode"/> is changed./// </summary>event EventHandler? InlineModeChanged;++ /// <summary>+ /// Raised when <see cref="IsExtendableToFullScreen"/> is changed.+ /// </summary>+ event EventHandler? IsExtendableToFullScreenChanged;}[DebuggerDisplay($"Id = {{{nameof(Id)}}}, Text = {{{nameof(Text)}}}")]@@ -39,6 +49,7 @@ internal class UIDiffTextInput : UISingleLineTextInput, IUIDiffTextInput{private bool _inline;private string? _modifiedText;+ private bool _isExtendableToFullScreen;internal UIDiffTextInput(string? id): base(id)@@ -63,8 +74,15 @@ internal class UIDiffTextInput : UISingleLineTextInput, IUIDiffTextInputinternal set => SetPropertyValue(ref _inline, value, InlineModeChanged);}+ public bool IsExtendableToFullScreen+ {+ get => _isExtendableToFullScreen;+ internal set => SetPropertyValue(ref _isExtendableToFullScreen, value, IsExtendableToFullScreenChanged);+ }+public event EventHandler? ModifiedTextChanged;public event EventHandler? InlineModeChanged;+ public event EventHandler? IsExtendableToFullScreenChanged;}public static partial class GUI@@ -127,4 +145,22 @@ public static partial class GUI((UIDiffTextInput)element).InlineMode = false;return element;}++ /// <summary>+ /// Indicates that the control can be extended to take the size of the whole tool boundaries.+ /// </summary>+ public static IUIDiffTextInput Extendable(this IUIDiffTextInput element)+ {+ ((UIDiffTextInput)element).IsExtendableToFullScreen = true;+ return element;+ }++ /// <summary>+ /// Indicates that the control can not be extended to take the size of the whole tool boundaries.+ /// </summary>+ public static IUIDiffTextInput NotExtendable(this IUIDiffTextInput element)+ {+ ((UIDiffTextInput)element).IsExtendableToFullScreen = false;+ return element;+ }}diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIMultiLineTextInput.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIMultiLineTextInput.csindex 53fa1ba01..2378b83b3 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIMultiLineTextInput.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIMultiLineTextInput.cs@@ -15,6 +15,11 @@ public interface IUIMultiLineTextInput : IUISingleLineTextInput/// </summary>string SyntaxColorizationLanguageName { get; }+ /// <summary>+ /// Gets whether the element can be expanded to take the size of the whole tool boundaries.+ /// </summary>+ bool IsExtendableToFullScreen { get; }+/// <summary>/// Raised when <see cref="HighlightedSpans"/> is changed./// </summary>@@ -24,13 +29,19 @@ public interface IUIMultiLineTextInput : IUISingleLineTextInput/// Raised when <see cref="SyntaxColorizationLanguageName"/> is changed./// </summary>event EventHandler? SyntaxColorizationLanguageNameChanged;++ /// <summary>+ /// Raised when <see cref="IsExtendableToFullScreen"/> is changed.+ /// </summary>+ event EventHandler? IsExtendableToFullScreenChanged;}-[DebuggerDisplay($"Id = {{{nameof(Id)}}}, Text = {{{nameof(Text)}}}")]+[DebuggerDisplay($"Id = {{{nameof(Id)}}}, Text = {{{nameof(Text)}}}, SyntaxColorizationLanguageName = {{{nameof(SyntaxColorizationLanguageName)}}}")]internal class UIMultilineTextInput : UISingleLineTextInput, IUIMultiLineTextInput{private IReadOnlyList<TextSpan>? _highlightedSpans;private string? _syntaxColorizationLanguageName;+ private bool _isExtendableToFullScreen;internal UIMultilineTextInput(string? id): base(id)@@ -49,8 +60,15 @@ internal class UIMultilineTextInput : UISingleLineTextInput, IUIMultiLineTextInpinternal set => SetPropertyValue(ref _syntaxColorizationLanguageName, value, SyntaxColorizationLanguageNameChanged);}+ public bool IsExtendableToFullScreen+ {+ get => _isExtendableToFullScreen;+ internal set => SetPropertyValue(ref _isExtendableToFullScreen, value, IsExtendableToFullScreenChanged);+ }+public event EventHandler? HighlightedSpansChanged;public event EventHandler? SyntaxColorizationLanguageNameChanged;+ public event EventHandler? IsExtendableToFullScreenChanged;}public static partial class GUI@@ -108,4 +126,22 @@ public static partial class GUI((UIMultilineTextInput)element).SyntaxColorizationLanguageName = programmingLanguageName;return element;}++ /// <summary>+ /// Indicates that the control can be extended to take the size of the whole tool boundaries.+ /// </summary>+ public static IUIMultiLineTextInput Extendable(this IUIMultiLineTextInput element)+ {+ ((UIMultilineTextInput)element).IsExtendableToFullScreen = true;+ return element;+ }++ /// <summary>+ /// Indicates that the control can not be extended to take the size of the whole tool boundaries.+ /// </summary>+ public static IUIMultiLineTextInput NotExtendable(this IUIMultiLineTextInput element)+ {+ ((UIMultilineTextInput)element).IsExtendableToFullScreen = false;+ return element;+ }}diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIToolView.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIToolView.csnew file mode 100644index 000000000..e2bbf8c16--- /dev/null+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIToolView.cs@@ -0,0 +1,61 @@+using System.Runtime.CompilerServices;++namespace DevToys.Api;++/// <summary>+/// Represents the root ui definition of a <see cref="IGuiTool"/>.+/// </summary>+[DebuggerDisplay($"IsScrollable = {{{nameof(IsScrollable)}}}")]+public class UIToolView : INotifyPropertyChanged+{+ private bool _isScrollable;++ /// <summary>+ /// Creates a new instance of the <see cref="UIToolView"/> class.+ /// </summary>+ /// <param name="rootElement">The root element of the tool's UI.</param>+ /// <param name="isScrollable">Indicates whether the UI of the tool is scrollable or should fits to the window boundaries.</param>+ public UIToolView(IUIElement rootElement, bool isScrollable = false)+ {+ Guard.IsNotNull(rootElement);+ IsScrollable = isScrollable;+ RootElement = rootElement;+ }++ /// <summary>+ /// Gets whether the UI of the tool is scrollable or should fits to the window boundaries.+ /// </summary>+ public bool IsScrollable+ {+ get => _isScrollable;+ internal set => SetPropertyValue(ref _isScrollable, value, IsScrollableChanged);+ }++ /// <summary>+ /// Gets the root element of the tool's UI.+ /// </summary>+ public IUIElement RootElement { get; }++ public event EventHandler? IsScrollableChanged;++ public event PropertyChangedEventHandler? PropertyChanged;++ protected void SetPropertyValue<T>(+ ref T field,+ T value,+ EventHandler? propertyChangedEventHandler,+ [CallerMemberName] string? propertyName = null)+ {+ if (!EqualityComparer<T>.Default.Equals(field, value))+ {+ field = value;+ propertyChangedEventHandler?.Invoke(this, EventArgs.Empty);+ OnPropertyChanged(propertyName);+ }+ }++ protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)+ {+ PropertyChanged?.Invoke(this, new(propertyName));+ }+}diff --git a/src/app/dev/DevToys.Api/Tool/GUI/IGuiTool.cs b/src/app/dev/DevToys.Api/Tool/GUI/IGuiTool.csindex a2e912faf..beef9539c 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/IGuiTool.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/IGuiTool.cs@@ -48,7 +48,7 @@ public interface IGuiTool/// <summary>/// Gets the view for the tool./// </summary>- IUIElement View { get; }+ UIToolView View { get; }/// <summary>/// Invoked when the app detected a data compatible with the tool and that the user navigates to this tool in question.diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor b/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razornew file mode 100644index 000000000..f4aeaa6fd--- /dev/null+++ b/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor@@ -0,0 +1,15 @@+@namespace DevToys.Blazor.Components+@inherits JSStyledComponentBase++<CascadingValue Value="this" IsFixed="true">+ <Container HorizontalAlignment="UIHorizontalAlignment.Stretch"+ VerticalAlignment="UIVerticalAlignment.Stretch">+ <div id="@FullScreenId"+ class="full-screen-container @(FinalCssClasses)"+ style="@(IsInFullScreenMode ? string.Empty : "display: none !important;")">+ </div>+ <Container IsVisible=@(!IsInFullScreenMode)>+ @ChildContent+ </Container>+ </Container>+</CascadingValue>\ No newline at end of filediff --git a/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.csnew file mode 100644index 000000000..451705765--- /dev/null+++ b/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.cs@@ -0,0 +1,37 @@+namespace DevToys.Blazor.Components;++public partial class FullScreenContainer : JSStyledComponentBase+{+ protected string FullScreenId => Id + "-full-screen";++ protected override string JavaScriptFile => "./_content/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.js";++ [Parameter]+ public RenderFragment? ChildContent { get; set; }++ [Parameter]+ public EventCallback<bool> IsInFullScreenModeChanged { get; set; }++ public bool IsInFullScreenMode { get; private set; }++ internal async Task<bool> ToggleFullScreenModeAsync(string elementId)+ {+ if (!IsInFullScreenMode)+ {+ await (await JSModule).InvokeVoidWithErrorHandlingAsync("setToFullScreen", FullScreenId, elementId);+ IsInFullScreenMode = true;+ }+ else+ {+ await (await JSModule).InvokeVoidWithErrorHandlingAsync("restoreFromFullScreen", elementId);+ IsInFullScreenMode = false;+ }++ if (IsInFullScreenModeChanged.HasDelegate)+ {+ await IsInFullScreenModeChanged.InvokeAsync(IsInFullScreenMode);+ }+ StateHasChanged();+ return IsInFullScreenMode;+ }+}diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.js b/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.jsnew file mode 100644index 000000000..fbae564ff--- /dev/null+++ b/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.js@@ -0,0 +1,19 @@+let parentOfElementToFullScreen = null;+export function setToFullScreen(fullScreenHostId, elementToFullScreenId) {+ if (parentOfElementToFullScreen !== null) {+ throw "ERROR: Looks like FullScreenContainer is already in full screen mode.";+ }+ const fullScreenHost = document.getElementById(fullScreenHostId);+ const elementToFullScreen = document.getElementById(elementToFullScreenId);+ parentOfElementToFullScreen = elementToFullScreen.parentElement;+ fullScreenHost.appendChild(elementToFullScreen);+}+export function restoreFromFullScreen(elementToRestoreFromFullScreenId) {+ if (parentOfElementToFullScreen === null) {+ throw "ERROR: Looks like FullScreenContainer is not in full screen mode.";+ }+ const elementToRestoreFromFullScreen = document.getElementById(elementToRestoreFromFullScreenId);+ parentOfElementToFullScreen.appendChild(elementToRestoreFromFullScreen);+ parentOfElementToFullScreen = null;+}+//# sourceMappingURL=FullScreenContainer.razor.js.map\ No newline at end of filediff --git a/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.scss b/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.scssnew file mode 100644index 000000000..83c13a5eb--- /dev/null+++ b/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.scss@@ -0,0 +1,4 @@+.full-screen-container {+ height: 100%;+ width: 100%;+}diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.ts b/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.tsnew file mode 100644index 000000000..df576dcc2--- /dev/null+++ b/src/app/dev/DevToys.Blazor/Components/Layout/FullScreenContainer/FullScreenContainer.razor.ts@@ -0,0 +1,25 @@+let parentOfElementToFullScreen: HTMLElement = null;++export function setToFullScreen(fullScreenHostId: string, elementToFullScreenId: string): void {+ if (parentOfElementToFullScreen !== null) {+ throw "ERROR: Looks like FullScreenContainer is already in full screen mode.";+ }++ const fullScreenHost: HTMLElement = document.getElementById(fullScreenHostId);+ const elementToFullScreen: HTMLElement = document.getElementById(elementToFullScreenId);++ parentOfElementToFullScreen = elementToFullScreen.parentElement;++ fullScreenHost.appendChild(elementToFullScreen);+}++export function restoreFromFullScreen(elementToRestoreFromFullScreenId: string): void {+ if (parentOfElementToFullScreen === null) {+ throw "ERROR: Looks like FullScreenContainer is not in full screen mode.";+ }++ const elementToRestoreFromFullScreen: HTMLElement = document.getElementById(elementToRestoreFromFullScreenId);++ parentOfElementToFullScreen.appendChild(elementToRestoreFromFullScreen);+ parentOfElementToFullScreen = null;+}\ No newline at end of filediff --git a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.csindex 7c51b3ece..1aa047e11 100644--- a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.cs@@ -26,6 +26,12 @@ public partial class ScrollViewer : StyledComponentBase[Parameter]public bool UseNativeScrollBar { get; set; }+ /// <summary>+ /// Gets or sets whether the scroll viewer is allowed to have its content scrolled.+ /// </summary>+ [Parameter]+ public bool IsScrollable { get; set; } = true;+protected override async Task OnAfterRenderAsync(bool firstRender){await base.OnAfterRenderAsync(firstRender);@@ -34,7 +40,7 @@ public partial class ScrollViewer : StyledComponentBaseprotected override void OnParametersSet(){AdditionalAttributes ??= new Dictionary<string, object>();- if (IsActuallyEnabled && !UseNativeScrollBar)+ if (IsActuallyEnabled && !UseNativeScrollBar && IsScrollable){// This will trigger simplebar to start.AdditionalAttributes.TryAdd("data-simplebar", true);@@ -44,8 +50,17 @@ public partial class ScrollViewer : StyledComponentBaseAdditionalAttributes.Remove("data-simplebar");}- if ((Orientation & UIOrientation.Vertical) != 0- && (Orientation & UIOrientation.Horizontal) != 0)+ if (IsScrollable)+ {+ AdditionalAttributes.Remove("data-simplebar-not-scrollable");+ }+ else+ {+ AdditionalAttributes.TryAdd("data-simplebar-not-scrollable", true);+ }++ if (((Orientation & UIOrientation.Vertical) != 0 && (Orientation & UIOrientation.Horizontal) != 0)+ || !IsScrollable){CSS.Clear();}@@ -70,7 +85,7 @@ public partial class ScrollViewer : StyledComponentBase}}- if (UseNativeScrollBar)+ if (UseNativeScrollBar && IsScrollable){CSS.Add("use-native-scroll");}diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.scss b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.scssindex 0727d70f3..279e1c12a 100644--- a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.scss+++ b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.scss@@ -324,3 +324,7 @@scrollbar-width: none;-ms-overflow-style: none;}++[data-simplebar-not-scrollable] .simplebar-content{+ height: 100% !important;+}diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razorindex ea8774e24..337a708da 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor@@ -2,11 +2,55 @@@using DevToys.Api;@inherits JSStyledComponentBase-<MonacoEditorDiff @ref="_monacoEditor"- IsVisible="@UIDiffTextInput.IsVisible"- IsEnabled="@UIDiffTextInput.IsEnabled"- HorizontalAlignment="@UIDiffTextInput.HorizontalAlignment"- VerticalAlignment="@UIDiffTextInput.VerticalAlignment"- Header="@UIDiffTextInput.Title"- ConstructionOptions="@OnMonacoConstructionOptions"- OnDidInit="@OnMonacoEditorInitializedAsync" />\ No newline at end of file+<!-- TODO: Localize -->+<Grid id="@ExtendedId"+ Class="ui-text-input-wrapper"+ IsVisible="@UIDiffTextInput.IsVisible"+ IsEnabled="@UIDiffTextInput.IsEnabled"+ HorizontalAlignment="@(_isInFullScreenMode ? UIHorizontalAlignment.Stretch : UIDiffTextInput.HorizontalAlignment)"+ VerticalAlignment="@(_isInFullScreenMode ? UIVerticalAlignment.Stretch : UIDiffTextInput.VerticalAlignment)"+ RowSpacing="6"+ Rows="@(new List<GridLength>+ {+ GridLength.Auto,+ new GridLength(1, GridUnitType.Fraction)+ })"+ ColumnSpacing="6"+ Columns="@(new List<GridLength>+ {+ new GridLength(1, GridUnitType.Fraction),+ GridLength.Auto+ })">+ <GridCell Row="0" Column="0">+ <Grid RowSpacing="0"+ Rows="@(new List<GridLength>+ {+ new GridLength(1, GridUnitType.Fraction),+ new GridLength(20, GridUnitType.Pixel)+ })">+ <GridCell Row="1">+ <TextBlock id="@(ExtendedId + "-title")"+ Text="@UIDiffTextInput.Title"+ NoWrap="true"+ CanTrim="true" />+ </GridCell>+ </Grid>+ </GridCell>+ <GridCell Row="0"+ Column="1">+ <StackPanel Wrap="false">+ @if (@UIDiffTextInput.IsExtendableToFullScreen)+ {+ <Button ToolTip="@(_isInFullScreenMode ? "Shrink" : "Extend")"+ @onclick="@OnToggleFullScreenButtonClickAsync">+ <FontIcon Glyph="@(_isInFullScreenMode ? '\uE0DC' : '\uE0C5')" />+ </Button>+ }+ </StackPanel>+ </GridCell>+ <GridCell Row="1" Column="0" ColumnSpan="2">+ <MonacoEditorDiff @ref="_monacoEditor"+ ConstructionOptions="@OnMonacoConstructionOptions"+ OnDidInit="@OnMonacoEditorInitializedAsync" />+ </GridCell>+</Grid>\ No newline at end of filediff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor.cs b/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor.csindex 6fc693616..165953e57 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor.cs@@ -6,11 +6,16 @@ namespace DevToys.Blazor.Components.UIElements;public partial class UIDiffTextInputPresenter : JSStyledComponentBase, IDisposable{private MonacoEditorDiff _monacoEditor = default!;- private UITextInputWrapper _textInputWrapper = default!;+ private bool _isInFullScreenMode;[Parameter]public IUIDiffTextInput UIDiffTextInput { get; set; } = default!;+ [CascadingParameter]+ protected FullScreenContainer? FullScreenContainer { get; set; }++ protected string ExtendedId => UIDiffTextInput.Id + "-" + Id;+protected override void OnInitialized(){base.OnInitialized();@@ -81,6 +86,13 @@ public partial class UIDiffTextInputPresenter : JSStyledComponentBase, IDisposab});}+ private async Task OnToggleFullScreenButtonClickAsync()+ {+ Guard.IsNotNull(FullScreenContainer);+ _isInFullScreenMode = await FullScreenContainer.ToggleFullScreenModeAsync(ExtendedId);+ StateHasChanged();+ }+private StandaloneDiffEditorConstructionOptions OnMonacoConstructionOptions(MonacoEditorDiff monacoEditor){return new StandaloneDiffEditorConstructionOptionsdiff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIMultiLineTextInputPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UIMultiLineTextInputPresenter.razorindex 702eba090..df28ee7a8 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIMultiLineTextInputPresenter.razor+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIMultiLineTextInputPresenter.razor@@ -2,7 +2,9 @@@using DevToys.Api;@inherits StyledComponentBase-<UITextInputWrapper @ref="_textInputWrapper" UITextInput="@UIMultiLineTextInput">+<UITextInputWrapper @ref="_textInputWrapper"+ UITextInput="@UIMultiLineTextInput"+ IsExtendableToFullScreen="@UIMultiLineTextInput.IsExtendableToFullScreen"><MonacoEditor @ref="_monacoEditor"IsVisible="@UIMultiLineTextInput.IsVisible"IsEnabled="@UIMultiLineTextInput.IsEnabled"diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razorindex 9cb1fde74..b77de5425 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor@@ -7,8 +7,8 @@Class="ui-text-input-wrapper"IsVisible="@UITextInput.IsVisible"IsEnabled="@UITextInput.IsEnabled"- HorizontalAlignment="@UITextInput.HorizontalAlignment"- VerticalAlignment="@UITextInput.VerticalAlignment"+ HorizontalAlignment="@(_isInFullScreenMode ? UIHorizontalAlignment.Stretch : UITextInput.HorizontalAlignment)"+ VerticalAlignment="@(_isInFullScreenMode ? UIVerticalAlignment.Stretch : UITextInput.VerticalAlignment)"RowSpacing="6"Rows="@(new List<GridLength>{@@ -90,6 +90,16 @@<FontIcon Glyph="@('\uE824')" Height="22" Width="22" /></DropDownButton>}++ @if (IsExtendableToFullScreen)+ {+ <div class="ui-text-input-wrapper-separator"></div>+ <Button ToolTip="@(_isInFullScreenMode ? "Shrink" : "Extend")"+ @onclick="@OnToggleFullScreenButtonClickAsync">+ <FontIcon Glyph="@(_isInFullScreenMode ? '\uE0DC' : '\uE0C5')" />+ </Button>+ }+<div class="ui-text-input-wrapper-separator"></div><DropDownButton ToolTip="Transfer to another tool"Items="@SmartDetectionDropDownItems"diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.cs b/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.csindex a9daaa067..19bb1ba49 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.cs@@ -34,10 +34,10 @@ public partial class UITextInputWrapper : MefComponentBaseprivate readonly ILogger _logger;private readonly DisposableSemaphore _disposableSemaphore = new();- private Grid _rootGrid = default!;private CancellationTokenSource? _cancellationTokenSource;private bool _isToolBarShrink;private bool _hideNonEssentialToolBar;+ private bool _isInFullScreenMode;protected override string? JavaScriptFile => "./_content/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor.js";@@ -59,6 +59,9 @@ public partial class UITextInputWrapper : MefComponentBase[Parameter]public RenderFragment? ChildContent { get; set; }+ [Parameter]+ public bool IsExtendableToFullScreen { get; set; }+protected bool IsLoadingFile { get; set; }protected bool ToolsDetectedBySmartDetection { get; set; }@@ -69,6 +72,9 @@ public partial class UITextInputWrapper : MefComponentBaseprotected string ExtendedId => UITextInput.Id + "-" + Id;+ [CascadingParameter]+ protected FullScreenContainer? FullScreenContainer { get; set; }+public UITextInputWrapper(){_logger = this.Log();@@ -282,7 +288,7 @@ public partial class UITextInputWrapper : MefComponentBase{LogErrorOpeningFile(ex);- await InvokeAsync(async () =>+ await InvokeAsync(() =>{IsLoadingFile = false;// TODO: Display ContentDialog@@ -301,6 +307,13 @@ public partial class UITextInputWrapper : MefComponentBase}}+ private async Task OnToggleFullScreenButtonClickAsync()+ {+ Guard.IsNotNull(FullScreenContainer);+ _isInFullScreenMode = await FullScreenContainer.ToggleFullScreenModeAsync(ExtendedId);+ StateHasChanged();+ }+private async Task FocusOnTextEditorAsync(){Guard.IsEqualTo(_childrenComponents.Count, 1);diff --git a/src/app/dev/DevToys.Blazor/DevToys.Blazor.csproj b/src/app/dev/DevToys.Blazor/DevToys.Blazor.csprojindex 93cc87078..f677d9048 100644--- a/src/app/dev/DevToys.Blazor/DevToys.Blazor.csproj+++ b/src/app/dev/DevToys.Blazor/DevToys.Blazor.csproj@@ -31,11 +31,15 @@<ConfigFiles Include="tsconfig.json" /><Content Update="tsconfig.json" PublishFolderType="None" /><Content Update="package.json" PublishFolderType="None" ExcludeFromBundleResources="true" />+ <Compile Remove="%2a%2a\**" />+ <Content Remove="%2a%2a\**" />+ <EmbeddedResource Remove="%2a%2a\**" />+ <TypeScriptCompile Remove="%2a%2a\**" /><TypeScriptCompile Remove="**\*.ts" />- <None Include="**\*.ts" /></ItemGroup><ItemGroup>+ <None Remove="%2a%2a\**" /><None Remove="node_modules\**" /><TypeScriptCompile Remove="node_modules\**" /><TypeScriptCompile Remove="wwwroot\lib\monaco-editor\**\*.*" />diff --git a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razor b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razorindex dbcae5f06..ea16dc8a7 100644--- a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razor+++ b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razor@@ -1,40 +1,38 @@@namespace DevToys.Blazor.Pages.SubPages@inherits MefComponentBase-<CascadingValue Value="this" IsFixed="true">- <GridView Class="entrance-theme-transition tool-group-grid-view"- ItemsSource="@ViewModel.Tools"- ItemMinWidth="330"- OnItemClick=@OnToolSelected>- <Header>- <TextBlock Appearance="@TextBlockAppearance.Title" Style="font-size: 24px !important" Text="@ViewModel.HeaderText" />- </Header>- <GroupHeaderTemplate Context="item">- <TextBlock Appearance="@TextBlockAppearance.Subtitle" Text="@item" />- </GroupHeaderTemplate>- <ItemTemplate Context="item">- <div class="tool-group-grid-view-item">- <div class="icon">- <FontIcon Height="64"- Width="64"- FontFamily="@item.IconFontName"- Glyph="@item.IconGlyph" />- </div>- <div class="title">- <TextBlock Appearance="@TextBlockAppearance.BodyStrong" Text="@item.LongOrShortDisplayTitle" />- </div>- <div class="description">- <TextBlock Appearance="@TextBlockAppearance.Caption" Text="@item.Description" />- </div>- <div class="buttons" @onclick:stopPropagation="true">- <Button HorizontalAlignment="UIHorizontalAlignment.Right"- Class="button"- Appearance="@ButtonAppearance.Neutral"- @onclick="() => OnOpenInNewWindow(item)">- <FontIcon Class="fonticon" Glyph="@('\uEE7A')" />- </Button>- </div>+<GridView Class="entrance-theme-transition tool-group-grid-view"+ ItemsSource="@ViewModel.Tools"+ ItemMinWidth="330"+ OnItemClick=@OnToolSelected>+ <Header>+ <TextBlock Appearance="@TextBlockAppearance.Title" Style="font-size: 24px !important" Text="@ViewModel.HeaderText" />+ </Header>+ <GroupHeaderTemplate Context="item">+ <TextBlock Appearance="@TextBlockAppearance.Subtitle" Text="@item" />+ </GroupHeaderTemplate>+ <ItemTemplate Context="item">+ <div class="tool-group-grid-view-item">+ <div class="icon">+ <FontIcon Height="64"+ Width="64"+ FontFamily="@item.IconFontName"+ Glyph="@item.IconGlyph" /></div>- </ItemTemplate>- </GridView>-</CascadingValue>\ No newline at end of file+ <div class="title">+ <TextBlock Appearance="@TextBlockAppearance.BodyStrong" Text="@item.LongOrShortDisplayTitle" />+ </div>+ <div class="description">+ <TextBlock Appearance="@TextBlockAppearance.Caption" Text="@item.Description" />+ </div>+ <div class="buttons" @onclick:stopPropagation="true">+ <Button HorizontalAlignment="UIHorizontalAlignment.Right"+ Class="button"+ Appearance="@ButtonAppearance.Neutral"+ @onclick="() => OnOpenInNewWindow(item)">+ <FontIcon Class="fonticon" Glyph="@('\uEE7A')" />+ </Button>+ </div>+ </div>+ </ItemTemplate>+</GridView>\ No newline at end of filediff --git a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razorindex 590875608..47bb3a92e 100644--- a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor+++ b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor@@ -2,18 +2,26 @@@using DevToys.Blazor.Components.UIElements@inherits MefComponentBase-<CascadingValue Value="this" IsFixed="true">- <ScrollViewer Class="entrance-theme-transition tool-page">- @RenderTool+@if (ViewModel.ToolView.IsScrollable)+{+ <ScrollViewer Class="entrance-theme-transition tool-page-content"+ IsScrollable="@(!IsInFullScreenMode)">+ @RenderToolWithHeader(true)</ScrollViewer>-</CascadingValue>+}+else+{+ <div class="entrance-theme-transition tool-page-content">+ @RenderToolWithHeader(false)+ </div>+}@code {- private RenderFragment RenderTool { get; set; } = default!;+ private RenderFragment<bool> RenderToolWithHeader { get; set; } = default!;protected override Task OnInitializedAsync(){- RenderTool = (__builder) =>+ RenderToolWithHeader = (bool isScrollable) => (__builder) =>{<Grid RowSpacing="12"Rows="@(new List<GridLength>@@ -29,7 +37,19 @@</GridCell><GridCell Row="1">- <UIElementPresenter UIElement="@ViewModel.ToolView" />+ @*@if (isScrollable)+ {+ <UIElementPresenter UIElement="@ViewModel.ToolView.RootElement" />+ }+ else+ {+ <FullScreenContainer>+ <UIElementPresenter UIElement="@ViewModel.ToolView.RootElement" />+ </FullScreenContainer>+ }*@+ <FullScreenContainer IsInFullScreenModeChanged="@OnIsInFullScreenModeChanged">+ <UIElementPresenter UIElement="@ViewModel.ToolView.RootElement" />+ </FullScreenContainer></GridCell></Grid>};diff --git a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor.cs b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor.csindex 8cd875559..39a5b8d1a 100644--- a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor.cs+++ b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor.cs@@ -4,7 +4,7 @@ using DevToys.Core.Tools.ViewItems;namespace DevToys.Blazor.Pages.SubPages;-public partial class ToolPage : MefComponentBase+public partial class ToolPage : MefComponentBase, IDisposable{[Import]internal ToolPageViewModel ViewModel { get; set; } = default!;@@ -12,6 +12,9 @@ public partial class ToolPage : MefComponentBase[Parameter]public GuiToolViewItem? GuiToolViewItem { get; set; }+ [Parameter]+ public bool IsInFullScreenMode { get; set; }+protected override void OnInitialized(){base.OnInitialized();@@ -24,6 +27,24 @@ public partial class ToolPage : MefComponentBaseif (GuiToolViewItem is not null){ViewModel.Load(GuiToolViewItem);+ ViewModel.ToolView.PropertyChanged -= ToolView_PropertyChanged;+ ViewModel.ToolView.PropertyChanged += ToolView_PropertyChanged;}}++ public void Dispose()+ {+ ViewModel.ToolView.PropertyChanged -= ToolView_PropertyChanged;+ GC.SuppressFinalize(this);+ }++ private void ToolView_PropertyChanged(object? sender, PropertyChangedEventArgs e)+ {+ StateHasChanged();+ }++ private void OnIsInFullScreenModeChanged(bool isInFullScreenMode)+ {+ IsInFullScreenMode = isInFullScreenMode;+ }}diff --git a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor.scss b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor.scssindex 1e03066af..dbef8a2b2 100644--- a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor.scss+++ b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor.scss@@ -1,10 +1,14 @@.tool-page {- padding: 40px;+ &-content {+ padding: 40px;+ }}// Compact modediv[data-compactmode] {.tool-page {- padding: 32px 16px;+ &-content {+ padding: 32px 16px;+ }}}diff --git a/src/app/dev/DevToys.Business/ViewModels/ToolPageViewModel.cs b/src/app/dev/DevToys.Business/ViewModels/ToolPageViewModel.csindex 169657655..0395725a5 100644--- a/src/app/dev/DevToys.Business/ViewModels/ToolPageViewModel.cs+++ b/src/app/dev/DevToys.Business/ViewModels/ToolPageViewModel.cs@@ -34,7 +34,14 @@ internal sealed partial class ToolPageViewModel : ObservableRecipient/// <summary>/// Gets the UI of the tool./// </summary>- internal IUIElement? ToolView => _guiToolViewItem?.ToolInstance.View;+ internal UIToolView ToolView+ {+ get+ {+ Guard.IsNotNull(_guiToolViewItem);+ return _guiToolViewItem.ToolInstance.View;+ }+ }internal void Load(GuiToolViewItem guiToolViewItem){diff --git a/src/app/dev/DevToys.Core/Tools/GuiToolInstance.cs b/src/app/dev/DevToys.Core/Tools/GuiToolInstance.csindex 96a0eed09..6c3d5cdd8 100644--- a/src/app/dev/DevToys.Core/Tools/GuiToolInstance.cs+++ b/src/app/dev/DevToys.Core/Tools/GuiToolInstance.cs@@ -14,7 +14,7 @@ public sealed partial class GuiToolInstance : ObservableObjectprivate readonly ILogger _logger;private readonly Lazy<IGuiTool, GuiToolMetadata> _guiToolDefinition;private readonly Lazy<IGuiTool> _instance;- private readonly Lazy<IUIElement> _view;+ private readonly Lazy<UIToolView> _view;private readonly Lazy<ResourceManager?> _resourceManager;private readonly Lazy<string> _shortDisplayTitle;private readonly Lazy<string> _longDisplayTitle;@@ -84,7 +84,7 @@ public sealed partial class GuiToolInstance : ObservableObject/// Gets the view of the tool./// Calling this property is expensive the first time as it will create the instance of the tool and the instance of the view./// </summary>- public IUIElement View => _view.Value;+ public UIToolView View => _view.Value;/// <summary>/// Send data coming from Smart Detection to the tool.diff --git a/src/app/dev/DevToys.Tools/Tools/Sample/SampleToolFactory.cs b/src/app/dev/DevToys.Tools/Tools/Sample/SampleToolFactory.csindex 7aa187a90..fa33f06c9 100644--- a/src/app/dev/DevToys.Tools/Tools/Sample/SampleToolFactory.cs+++ b/src/app/dev/DevToys.Tools/Tools/Sample/SampleToolFactory.cs@@ -68,27 +68,26 @@ internal sealed class SampleGuiTool : IGuiToolprivate readonly IUIStack _mainStack = Stack();private readonly IUIStack _subStack = Stack();- public IUIElement View =>- _mainStack- .Vertical()- .WithChildren(- _button.Text("I'm in a StackPanel. Click me to disable the parent StackPanel and all its children").OnClick(OnClick),- _subStack- .Vertical()- .WithChildren(- _button2.Text("Hello !"),- _button3.Text("Hello !"),- _button4.Text("Hello !"),- _button5.Text("Hello !"),- _button6.Text("Hello !"),- _button7.Text("Hello !"),- _button8.Text("Hello !"),- _button9.Text("Hello !"),- _button10.Text("Hello !"),- _button11.Text("Hello !"),- _button12.Text("Hello !")));- //Button().Text("Hello !");- // => _editor;+ public UIToolView View =>+ new(+ _mainStack+ .Vertical()+ .WithChildren(+ _button.Text("I'm in a StackPanel. Click me to disable the parent StackPanel and all its children").OnClick(OnClick),+ _subStack+ .Vertical()+ .WithChildren(+ _button2.Text("Hello !"),+ _button3.Text("Hello !"),+ _button4.Text("Hello !"),+ _button5.Text("Hello !"),+ _button6.Text("Hello !"),+ _button7.Text("Hello !"),+ _button8.Text("Hello !"),+ _button9.Text("Hello !"),+ _button10.Text("Hello !"),+ _button11.Text("Hello !"),+ _button12.Text("Hello !"))));private ValueTask OnClick(){@@ -128,10 +127,7 @@ internal sealed class SampleGuiTool : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool2 : IGuiTool{- private readonly IUIMultiLineTextInput _editor = MultilineTextInput().CanCopyWhenEditable();-- public IUIElement View- => _editor;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData){@@ -157,7 +153,7 @@ internal sealed class SampleGuiTool2 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool3 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -181,7 +177,7 @@ internal sealed class SampleGuiTool3 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool4 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -205,7 +201,7 @@ internal sealed class SampleGuiTool4 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool5 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -229,7 +225,7 @@ internal sealed class SampleGuiTool5 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool6 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -253,7 +249,7 @@ internal sealed class SampleGuiTool6 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool7 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -277,7 +273,7 @@ internal sealed class SampleGuiTool7 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool8 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -301,7 +297,7 @@ internal sealed class SampleGuiTool8 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool9 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -325,7 +321,7 @@ internal sealed class SampleGuiTool9 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool10 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -349,7 +345,7 @@ internal sealed class SampleGuiTool10 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool11 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -373,7 +369,7 @@ internal sealed class SampleGuiTool11 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool12 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -397,7 +393,7 @@ internal sealed class SampleGuiTool12 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool13 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -421,7 +417,7 @@ internal sealed class SampleGuiTool13 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool14 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -445,7 +441,7 @@ internal sealed class SampleGuiTool14 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool15 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -469,7 +465,7 @@ internal sealed class SampleGuiTool15 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool16 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}@@ -493,7 +489,7 @@ internal sealed class SampleGuiTool16 : IGuiTool[TargetPlatform(Platform.WASM)]internal sealed class SampleGuiTool17 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object? parsedData) { }}diff --git a/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs b/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.csindex 298451f30..83c96a12c 100644--- a/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs+++ b/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs@@ -45,52 +45,62 @@ internal sealed class SettingsGuiTool : IGuiTool.OnClick(OnMyButtonClickAsync);}- public IUIElement View- => Stack()- .Vertical()- .WithChildren(- SettingGroup()- .Icon("FluentSystemIcons", '\uF6A9')- .Title("Title")- .Description("Description")- .Handle(- _settingsProvider,- DummySetting2,- OnDummySetting2ChangedAsync,- Item("Use system settings", AvailableApplicationTheme.Default),- Item("Light", AvailableApplicationTheme.Light),- Item("Dark", AvailableApplicationTheme.Dark))- .WithSettings(- Setting()- .Title("Compact mode")- .Handle(_settingsProvider, PredefinedSettings.CompactMode),- Setting()- .Title("Line numbers")- .Handle(_settingsProvider, PredefinedSettings.TextEditorLineNumbers),- Setting()- .Title("Title")- .Description("Description")- .InteractiveElement(- Switch()),- Setting()- .Title("Title")- .Description("Description")- .InteractiveElement(- Switch())),- Wrap()- .WithChildren(- _topLeftButton,- Button().Text("Top Center button"),- Button().Text("Top Right button")),- Wrap()- .Disable()- .WithChildren(- Button().Text("Bottom Left button"),- Button().Text("Bottom Center button").OnClick(OnBottomCenterButtonClickAsync),- Button().Text("Bottom Right button")),- SingleLineTextInput().Title("Read-write text input with copy").ReadOnly(),- MultilineTextInput().Title("Monaco editor").Text("{\"hello\": \"there\"}").Language("json"),- DiffTextInput().Title("Difference").OriginalText("hello").ModifiedText("hello world"));+ public UIToolView View+ => new(+ Stack()+ .Vertical()+ .WithChildren(+ SettingGroup()+ .Icon("FluentSystemIcons", '\uF6A9')+ .Title("Title")+ .Description("Description")+ .Handle(+ _settingsProvider,+ DummySetting2,+ OnDummySetting2ChangedAsync,+ Item("Use system settings", AvailableApplicationTheme.Default),+ Item("Light", AvailableApplicationTheme.Light),+ Item("Dark", AvailableApplicationTheme.Dark))+ .WithSettings(+ Setting()+ .Title("Compact mode")+ .Handle(_settingsProvider, PredefinedSettings.CompactMode),+ Setting()+ .Title("Line numbers")+ .Handle(_settingsProvider, PredefinedSettings.TextEditorLineNumbers),+ Setting()+ .Title("Title")+ .Description("Description")+ .InteractiveElement(+ Switch()),+ Setting()+ .Title("Title")+ .Description("Description")+ .InteractiveElement(+ Switch())),+ Wrap()+ .WithChildren(+ _topLeftButton,+ Button().Text("Top Center button"),+ Button().Text("Top Right button")),+ Wrap()+ .Disable()+ .WithChildren(+ Button().Text("Bottom Left button"),+ Button().Text("Bottom Center button").OnClick(OnBottomCenterButtonClickAsync),+ Button().Text("Bottom Right button")),+ SingleLineTextInput().Title("Read-write text input with copy").ReadOnly(),+ MultilineTextInput()+ .Title("Monaco editor")+ .Extendable()+ .Text("{\"hello\": \"there\"}")+ .Language("json"),+ DiffTextInput()+ .Title("Difference")+ .OriginalText("hello")+ .Extendable()+ .ModifiedText("hello world")),+ isScrollable: true);public void OnDataReceived(string dataTypeName, object? parsedData){diff --git a/src/app/tests/DevToys.UnitTests/Mocks/MockIFileStorage.cs b/src/app/tests/DevToys.UnitTests/Mocks/MockIFileStorage.csindex 5f61bb1d0..bdedde99c 100644--- a/src/app/tests/DevToys.UnitTests/Mocks/MockIFileStorage.cs+++ b/src/app/tests/DevToys.UnitTests/Mocks/MockIFileStorage.cs@@ -24,13 +24,13 @@ internal class MockIFileStorage : IFileStoragethrow new NotImplementedException();}- public ValueTask<Stream?> PickSaveFileAsync(string[] fileTypes)+ public ValueTask<Stream> PickSaveFileAsync(string[] fileTypes){// TODO: prompt the user to type in the console a relative or absolute file path that has one of the file types indicated.throw new NotImplementedException();}- public ValueTask<Stream?> PickOpenFileAsync(string[] fileTypes)+ public ValueTask<Stream> PickOpenFileAsync(string[] fileTypes){// TODO: prompt the user to type in the console a relative or absolute file path that has one of the file types indicated.throw new NotImplementedException();diff --git a/src/app/tests/DevToys.UnitTests/Mocks/Tools/MockDataTypeDetector.cs b/src/app/tests/DevToys.UnitTests/Mocks/Tools/MockDataTypeDetector.csindex d7cf49ffc..0ba3e0e6b 100644--- a/src/app/tests/DevToys.UnitTests/Mocks/Tools/MockDataTypeDetector.cs+++ b/src/app/tests/DevToys.UnitTests/Mocks/Tools/MockDataTypeDetector.cs@@ -9,7 +9,7 @@ namespace DevToys.UnitTests.Mocks.Tools;[DataTypeName("JSON", baseName: "text")]internal class MockJsonDataTypeDetector : IDataTypeDetector{- public ValueTask<DataDetectionResult> TryDetectDataAsync(object data, DataDetectionResult? resultFromBaseDetector, CancellationToken cancellationToken)+ public ValueTask<DataDetectionResult> TryDetectDataAsync(object data, DataDetectionResult resultFromBaseDetector, CancellationToken cancellationToken){if (resultFromBaseDetector is not null&& resultFromBaseDetector.Data is string dataString@@ -36,7 +36,7 @@ internal class MockJsonDataTypeDetector : IDataTypeDetector[DataTypeName("text")]internal class MockTextDataTypeDetector : IDataTypeDetector{- public ValueTask<DataDetectionResult> TryDetectDataAsync(object data, DataDetectionResult? resultFromBaseDetector, CancellationToken cancellationToken)+ public ValueTask<DataDetectionResult> TryDetectDataAsync(object data, DataDetectionResult resultFromBaseDetector, CancellationToken cancellationToken){if (data is string dataString && !string.IsNullOrEmpty(dataString)){diff --git a/src/app/tests/DevToys.UnitTests/Mocks/Tools/MockIGuiTool.cs b/src/app/tests/DevToys.UnitTests/Mocks/Tools/MockIGuiTool.csindex d2e4fe92a..40deb369d 100644--- a/src/app/tests/DevToys.UnitTests/Mocks/Tools/MockIGuiTool.cs+++ b/src/app/tests/DevToys.UnitTests/Mocks/Tools/MockIGuiTool.cs@@ -19,7 +19,7 @@ namespace DevToys.UnitTests.Mocks.Tools;[AcceptedDataTypeName("text")]internal sealed class MockIGuiTool2 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object parsedData) { }}@@ -40,7 +40,7 @@ internal sealed class MockIGuiTool2 : IGuiTool[AcceptedDataTypeName("JSON")]internal sealed class MockIGuiTool : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object parsedData) { }}@@ -60,7 +60,7 @@ internal sealed class MockIGuiTool : IGuiToolSearchKeywordsResourceName = nameof(MockToolResource.TitleXmlFormatter))]internal sealed class MockIGuiTool3 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object parsedData) { }}@@ -80,7 +80,7 @@ internal sealed class MockIGuiTool3 : IGuiToolSearchKeywordsResourceName = nameof(MockToolResource.TitleXmlValidator))]internal sealed class MockIGuiTool4 : IGuiTool{- public IUIElement View => null!;+ public UIToolView View => null!;public void OnDataReceived(string dataTypeName, object parsedData) { }}