A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Fixed state propagation
Etienne Baudouxb6afe3edd3fd
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUINumberInput.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUINumberInput.csindex 23687df62..f8dbd9ce0 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUINumberInput.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUINumberInput.cs@@ -20,6 +20,11 @@ public interface IUINumberInput : IUISingleLineTextInput/// </summary>double Step { get; }+ /// <summary>+ /// Gets the value of the input.+ /// </summary>+ double Value { get; }+/// <summary>/// Raised when <see cref="Min"/> is changed./// </summary>@@ -66,6 +71,21 @@ internal class UINumberInput : UISingleLineTextInput, IUINumberInputinternal set => SetPropertyValue(ref _step, value, StepChanged);}+ public double Value+ {+ get+ {+ if (double.TryParse(Text, out double value))+ {+ return Math.Min(Math.Max(value, Min), Max);+ }+ else+ {+ return 0;+ }+ }+ }+public event EventHandler? MinChanged;public event EventHandler? MaxChanged;public event EventHandler? StepChanged;diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razorindex 1cb213797..a476fcbfb 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor@@ -6,7 +6,7 @@<Grid id="@ExtendedId"Class="ui-text-input-wrapper"IsVisible="@UIDiffTextInput.IsVisible"- IsEnabled="@UIDiffTextInput.IsEnabled"+ IsEnabled="@(UIDiffTextInput.IsEnabled && IsActuallyEnabled)"HorizontalAlignment="@(_isInFullScreenMode ? UIHorizontalAlignment.Stretch : UIDiffTextInput.HorizontalAlignment)"VerticalAlignment="@(_isInFullScreenMode ? UIVerticalAlignment.Stretch : UIDiffTextInput.VerticalAlignment)"RowSpacing="6"diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIFileSelectorPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UIFileSelectorPresenter.razorindex 4353000aa..95ec2075d 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIFileSelectorPresenter.razor+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIFileSelectorPresenter.razor@@ -5,7 +5,7 @@<!-- TODO: Localize --><Container id="@ExtendedId"IsVisible="@UIFileSelector.IsVisible"- IsEnabled="@UIFileSelector.IsEnabled"+ IsEnabled="@(UIFileSelector.IsEnabled && IsActuallyEnabled)"HorizontalAlignment="@UIFileSelector.HorizontalAlignment"VerticalAlignment="@UIFileSelector.VerticalAlignment"Class="ui-file-selector">diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIFileSelectorPresenter.razor.cs b/src/app/dev/DevToys.Blazor/Components/UIElements/UIFileSelectorPresenter.razor.csindex cd383c134..9227d4a91 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIFileSelectorPresenter.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIFileSelectorPresenter.razor.cs@@ -57,6 +57,11 @@ public partial class UIFileSelectorPresenter : MefComponentBaseprivate void OnFileDropped(InputFileChangeEventArgs args){+ if (!IsActuallyEnabled)+ {+ return;+ }+IReadOnlyList<IBrowserFile> droppedFiles = args.GetMultipleFiles(maximumFileCount: int.MaxValue);if (droppedFiles.Count == 0)diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIInfoBarPresenter.razor.cs b/src/app/dev/DevToys.Blazor/Components/UIElements/UIInfoBarPresenter.razor.csindex 99cc3a5a6..edcc4bf3d 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIInfoBarPresenter.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIInfoBarPresenter.razor.cs@@ -12,6 +12,8 @@ public partial class UIInfoBarPresenter : ComponentBase{await UIInfoBar.OnCloseAction.Invoke(); // TODO: Try Catch and log?}++ UIInfoBar.Close();}internal async Task OnActionButtonClickAsync()diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIMultiLineTextInputPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UIMultiLineTextInputPresenter.razorindex be34c652b..170f957f2 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIMultiLineTextInputPresenter.razor+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIMultiLineTextInputPresenter.razor@@ -7,7 +7,7 @@IsExtendableToFullScreen="@UIMultiLineTextInput.IsExtendableToFullScreen"><MonacoEditor @ref="_monacoEditor"IsVisible="@UIMultiLineTextInput.IsVisible"- IsEnabled="@UIMultiLineTextInput.IsEnabled"+ IsEnabled="@(UIMultiLineTextInput.IsEnabled && IsActuallyEnabled)"ConstructionOptions="@OnMonacoConstructionOptions"OnDidChangeModelContent="OnMonacoEditorTextChangedAsync"OnDidInit="OnMonacoEditorInitializedAsync"diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UINumberInputPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UINumberInputPresenter.razorindex ee8d5c533..a382987d4 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UINumberInputPresenter.razor+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UINumberInputPresenter.razor@@ -4,7 +4,7 @@<UITextInputWrapper @ref="_textInputWrapper" UITextInput="@UINumberInput"><TextBox IsVisible="@UINumberInput.IsVisible"- IsEnabled="@UINumberInput.IsEnabled"+ IsEnabled="@(UINumberInput.IsEnabled && IsActuallyEnabled)"Text="@UINumberInput.Text"IsReadOnly="@UINumberInput.IsReadOnly"TextChanged="@OnTextChanged"diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UISingleLineTextInputPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UISingleLineTextInputPresenter.razorindex c0c372692..d2ed866b6 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UISingleLineTextInputPresenter.razor+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UISingleLineTextInputPresenter.razor@@ -4,7 +4,7 @@<UITextInputWrapper @ref="_textInputWrapper" UITextInput="@UISingleLineTextInput"><TextBox IsVisible="@UISingleLineTextInput.IsVisible"- IsEnabled="@UISingleLineTextInput.IsEnabled"+ IsEnabled="@(UISingleLineTextInput.IsEnabled && IsActuallyEnabled)"Text="@UISingleLineTextInput.Text"IsReadOnly="@UISingleLineTextInput.IsReadOnly"TextChanged="@OnTextChanged"diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razorindex 15bfc9d86..0df52c646 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor@@ -3,140 +3,142 @@@inherits MefComponentBase<!-- TODO: Localize -->-<Grid id="@ExtendedId"- Class="ui-text-input-wrapper"- IsVisible="@UITextInput.IsVisible"- IsEnabled="@UITextInput.IsEnabled"- HorizontalAlignment="@(_isInFullScreenMode ? UIHorizontalAlignment.Stretch : UITextInput.HorizontalAlignment)"- VerticalAlignment="@(_isInFullScreenMode ? UIVerticalAlignment.Stretch : UITextInput.VerticalAlignment)"- RowSpacing="6"- Rows="@(new List<UIGridLength>- {- UIGridLength.Auto,- new UIGridLength(1, UIGridUnitType.Fraction)- })"- ColumnSpacing="6"- Columns="@(new List<UIGridLength>- {- new UIGridLength(1, UIGridUnitType.Fraction),- UIGridLength.Auto- })">- <GridCell Row="0" Column="0">- <Grid RowSpacing="0"- Rows="@(new List<UIGridLength>- {- new UIGridLength(1, UIGridUnitType.Fraction),- new UIGridLength(20, UIGridUnitType.Pixel)- })">- <GridCell Row="1">- <TextBlock id="@(ExtendedId + "-title")"- Text="@UITextInput.Title"- NoWrap="true"- CanTrim="true" />- </GridCell>- </Grid>- </GridCell>- <GridCell Row="0"- Column="1">- <StackPanel IsEnabled="@(!IsLoadingFile)" Wrap="false">- @if (UITextInput.CommandBarExtraContent is not null)+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">+ <Grid id="@ExtendedId"+ Class="ui-text-input-wrapper"+ IsVisible="@UITextInput.IsVisible"+ IsEnabled="@UITextInput.IsEnabled"+ HorizontalAlignment="@(_isInFullScreenMode ? UIHorizontalAlignment.Stretch : UITextInput.HorizontalAlignment)"+ VerticalAlignment="@(_isInFullScreenMode ? UIVerticalAlignment.Stretch : UITextInput.VerticalAlignment)"+ RowSpacing="6"+ Rows="@(new List<UIGridLength>{- <UIElementPresenter UIElement="@UITextInput.CommandBarExtraContent" />- <div class="ui-text-input-wrapper-separator"></div>- }-- @if (!_hideNonEssentialToolBar)+ UIGridLength.Auto,+ new UIGridLength(1, UIGridUnitType.Fraction)+ })"+ ColumnSpacing="6"+ Columns="@(new List<UIGridLength>{- @if (!UITextInput.IsReadOnly)+ new UIGridLength(1, UIGridUnitType.Fraction),+ UIGridLength.Auto+ })">+ <GridCell Row="0" Column="0">+ <Grid RowSpacing="0"+ Rows="@(new List<UIGridLength>+ {+ new UIGridLength(1, UIGridUnitType.Fraction),+ new UIGridLength(20, UIGridUnitType.Pixel)+ })">+ <GridCell Row="1">+ <TextBlock id="@(ExtendedId + "-title")"+ Text="@UITextInput.Title"+ NoWrap="true"+ CanTrim="true" />+ </GridCell>+ </Grid>+ </GridCell>+ <GridCell Row="0"+ Column="1">+ <StackPanel IsEnabled="@(!IsLoadingFile)" Wrap="false">+ @if (UITextInput.CommandBarExtraContent is not null){- <Button @onclick="@OnPasteButtonClickAsync">- <StackPanel>- <FontIcon Glyph="@('\uF2D5')" />- <TextBlock Text="Paste"- IsVisible="@(!_isToolBarShrink)" />- </StackPanel>- </Button>- <Button ToolTip="Load a file"- @onclick="@OnLoadFileButtonClickAsync">- <FontIcon Glyph="@('\uF378')" />- </Button>- <Button ToolTip="Clear"- @onclick="@OnClearButtonClickAsync">- <FontIcon Glyph="@('\uF369')" />- </Button>+ <UIElementPresenter UIElement="@UITextInput.CommandBarExtraContent" />+ <div class="ui-text-input-wrapper-separator"></div>}-- @if (!UITextInput.IsReadOnly && UITextInput.CanCopyWhenEditable)++ @if (!_hideNonEssentialToolBar){- <div class="ui-text-input-wrapper-separator"></div>+ @if (!UITextInput.IsReadOnly)+ {+ <Button @onclick="@OnPasteButtonClickAsync">+ <StackPanel>+ <FontIcon Glyph="@('\uF2D5')" />+ <TextBlock Text="Paste"+ IsVisible="@(!_isToolBarShrink)" />+ </StackPanel>+ </Button>+ <Button ToolTip="Load a file"+ @onclick="@OnLoadFileButtonClickAsync">+ <FontIcon Glyph="@('\uF378')" />+ </Button>+ <Button ToolTip="Clear"+ @onclick="@OnClearButtonClickAsync">+ <FontIcon Glyph="@('\uF369')" />+ </Button>+ }++ @if (!UITextInput.IsReadOnly && UITextInput.CanCopyWhenEditable)+ {+ <div class="ui-text-input-wrapper-separator"></div>+ }++ @if (UITextInput.IsReadOnly || UITextInput.CanCopyWhenEditable)+ {+ <Button ToolTip="Save as..."+ @onclick="@OnSaveAsButtonClickAsync">+ <FontIcon Glyph="@('\uF67F')" />+ </Button>+ <Button @onclick="@OnCopyButtonClick">+ <StackPanel>+ <FontIcon Glyph="@('\uF32B')" />+ <TextBlock Text="Copy"+ IsVisible="@(!_isToolBarShrink)" />+ </StackPanel>+ </Button>+ }}-- @if (UITextInput.IsReadOnly || UITextInput.CanCopyWhenEditable)+ else{- <Button ToolTip="Save as..."- @onclick="@OnSaveAsButtonClickAsync">- <FontIcon Glyph="@('\uF67F')" />- </Button>- <Button @onclick="@OnCopyButtonClick">- <StackPanel>- <FontIcon Glyph="@('\uF32B')" />- <TextBlock Text="Copy"- IsVisible="@(!_isToolBarShrink)" />- </StackPanel>+ <DropDownButton ToolTip="More..."+ Items="@CollapsedDropDownListItems"+ AnchorOrigin="Origin.BottomRight"+ TransformOrigin="Origin.TopRight"+ DisplayArrow="false">+ <FontIcon Glyph="@('\uE823')" 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 ? '\uF165' : '\uF15F')" /></Button>}- }- else- {- <DropDownButton ToolTip="More..."- Items="@CollapsedDropDownListItems"- AnchorOrigin="Origin.BottomRight"- TransformOrigin="Origin.TopRight"- DisplayArrow="false">- <FontIcon Glyph="@('\uE823')" 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 ? '\uF165' : '\uF15F')" />- </Button>- }-- @if (UITextInput.IsReadOnly)- {- <div class="ui-text-input-wrapper-separator"></div>- <DropDownButton ToolTip="Transfer to another tool"- Items="@SmartDetectionDropDownItems"- AnchorOrigin="Origin.BottomRight"- TransformOrigin="Origin.TopRight">- <img src="@(ToolsDetectedBySmartDetection ? "_content/DevToys.Blazor/img/idea.svg" : "_content/DevToys.Blazor/img/idea-disabled.svg")"- height="22"- width="22"- style="flex-basis: auto; align-self:center;" />- </DropDownButton>- }- </StackPanel>- </GridCell>- <GridCell Row="1" Column="0" ColumnSpan="2">- <Container IsEnabled="@(!IsLoadingFile)">- @ChildContent-- <!-- Progress bar to indicate when a file is being loaded -->- <div class="ui-text-input-wrapper-centered-progress-bar">- <ProgressBar IsIndeterminate="true"- IsVisible="@IsLoadingFile"- MarginLeft="24"- MarginRight="24"- HorizontalAlignment="UIHorizontalAlignment.Stretch"- VerticalAlignment="UIVerticalAlignment.Top" />- </div>-- <!-- Input form used for getting the dropped file when use drag and drop a file into the UI. -->- <InputFile style="display: none;" OnChange="OnFileDroppedAsync" />- </Container>- </GridCell>-</Grid>\ No newline at end of file++ @if (UITextInput.IsReadOnly)+ {+ <div class="ui-text-input-wrapper-separator"></div>+ <DropDownButton ToolTip="Transfer to another tool"+ Items="@SmartDetectionDropDownItems"+ AnchorOrigin="Origin.BottomRight"+ TransformOrigin="Origin.TopRight">+ <img src="@(ToolsDetectedBySmartDetection ? "_content/DevToys.Blazor/img/idea.svg" : "_content/DevToys.Blazor/img/idea-disabled.svg")"+ height="22"+ width="22"+ style="flex-basis: auto; align-self:center;" />+ </DropDownButton>+ }+ </StackPanel>+ </GridCell>+ <GridCell Row="1" Column="0" ColumnSpan="2">+ <Container IsEnabled="@(!IsLoadingFile)">+ @ChildContent++ <!-- Progress bar to indicate when a file is being loaded -->+ <div class="ui-text-input-wrapper-centered-progress-bar">+ <ProgressBar IsIndeterminate="true"+ IsVisible="@IsLoadingFile"+ MarginLeft="24"+ MarginRight="24"+ HorizontalAlignment="UIHorizontalAlignment.Stretch"+ VerticalAlignment="UIVerticalAlignment.Top" />+ </div>++ <!-- Input form used for getting the dropped file when use drag and drop a file into the UI. -->+ <InputFile style="display: none;" OnChange="OnFileDroppedAsync" />+ </Container>+ </GridCell>+ </Grid>+</CascadingValue>\ No newline at end of file