Skip to content

A Swiss Army knife for developers.

Fixed UI update propagation in UIElement

Etienne Baudouxaf9960b640ca
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIButton.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIButton.cs
index 42c3f4fe4..2defb027d 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIButton.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIButton.cs
@@ -5,6 +5,11 @@
/// </summary>
public interface IUIButton : IUIElement
{
+ /// <summary>
+ /// Gets whether the button appearance should be accented.
+ /// </summary>
+ bool IsAccent { get; }
+
/// <summary>
/// Gets the text to display in the button.
/// </summary>
@@ -18,12 +23,18 @@ public interface IUIButton : IUIElement
/// <summary>
/// Raised when <see cref="Text"/> is changed.
/// </summary>
- public event EventHandler? TextChanged;
+ event EventHandler? TextChanged;
+
+ /// <summary>
+ /// Raised when <see cref="IsAccent"/> is changed.
+ /// </summary>
+ event EventHandler? IsAccentChanged;
}
[DebuggerDisplay($"Id = {{{nameof(Id)}}}, Text = {{{nameof(Text)}}}")]
internal sealed class UIButton : UIElement, IUIButton
{
+ private bool _isAccent;
private string? _text;
internal UIButton(string? id)
@@ -31,19 +42,23 @@ internal sealed class UIButton : UIElement, IUIButton
{
}
+ public bool IsAccent
+ {
+ get => _isAccent;
+ internal set => SetPropertyValue(ref _isAccent, value, IsAccentChanged);
+ }
+
public string? Text
{
get => _text;
- internal set
- {
- _text = value;
- TextChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _text, value, TextChanged);
}
public Func<ValueTask>? OnClickAction { get; internal set; }
public event EventHandler? TextChanged;
+
+ public event EventHandler? IsAccentChanged;
}
public static partial class GUI
@@ -92,4 +107,22 @@ public static partial class GUI
((UIButton)element).OnClickAction = actionOnClick;
return element;
}
+
+ /// <summary>
+ /// Sets the button to appear as accented.
+ /// </summary>
+ public static IUIButton AccentAppearance(this IUIButton element)
+ {
+ ((UIButton)element).IsAccent = true;
+ return element;
+ }
+
+ /// <summary>
+ /// Sets the button to appear as neutral.
+ /// </summary>
+ public static IUIButton NeutralAppearance(this IUIButton element)
+ {
+ ((UIButton)element).IsAccent = false;
+ return element;
+ }
}
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDropDownList.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDropDownList.cs
index e19cc2767..b07a3dcb1 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDropDownList.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIDropDownList.cs
@@ -45,11 +45,7 @@ internal sealed class UIDropDownList : UITitledElement, IUIDropDownList
public IUIDropDownListItem[]? Items
{
get => _items;
- internal set
- {
- _items = value;
- ItemsChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _items, value, ItemsChanged);
}
public IUIDropDownListItem? SelectedItem
@@ -57,9 +53,13 @@ internal sealed class UIDropDownList : UITitledElement, IUIDropDownList
get => _selectedItem;
internal set
{
- _selectedItem = value;
- OnItemSelectedAction?.Invoke(_selectedItem);
- SelectedItemChanged?.Invoke(this, EventArgs.Empty);
+ if (_selectedItem != value)
+ {
+ _selectedItem = value;
+ OnItemSelectedAction?.Invoke(_selectedItem);
+ SelectedItemChanged?.Invoke(this, EventArgs.Empty);
+ OnPropertyChanged();
+ }
}
}
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIElement.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIElement.cs
index 654eddea9..d77c02411 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIElement.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIElement.cs
@@ -1,4 +1,6 @@
-namespace DevToys.Api;
+using System.Runtime.CompilerServices;
+
+namespace DevToys.Api;
/// <summary>
/// A base interface for all UI elements.
@@ -21,6 +23,16 @@ public interface IUIElement
/// </summary>
bool IsEnabled { get; }
+ /// <summary>
+ /// Gets how the element should align horizontally.
+ /// </summary>
+ UIHorizontalAlignment HorizontalAlignment { get; }
+
+ /// <summary>
+ /// Gets how the element should align vertically.
+ /// </summary>
+ UIVerticalAlignment VerticalAlignment { get; }
+
/// <summary>
/// Raised when <see cref="IsVisible"/> is changed.
/// </summary>
@@ -30,13 +42,25 @@ public interface IUIElement
/// Raised when <see cref="IsEnabled"/> is changed.
/// </summary>
event EventHandler? IsEnabledChanged;
+
+ /// <summary>
+ /// Raised when <see cref="HorizontalAlignment"/> is changed.
+ /// </summary>
+ event EventHandler? HorizontalAlignmentChanged;
+
+ /// <summary>
+ /// Raised when <see cref="VerticalAlignment"/> is changed.
+ /// </summary>
+ event EventHandler? VerticalAlignmentChanged;
}
[DebuggerDisplay($"Id = {{{nameof(Id)}}}, IsVisible = {{{nameof(IsVisible)}}}, IsEnabled = {{{nameof(IsEnabled)}}}")]
-internal abstract class UIElement : IUIElement
+internal abstract class UIElement : IUIElement, INotifyPropertyChanged
{
private bool _isVisible = true;
private bool _isEnabled = true;
+ private UIHorizontalAlignment _horizontalAlignment = UIHorizontalAlignment.Stretch;
+ private UIVerticalAlignment _verticalAlignment = UIVerticalAlignment.Stretch;
protected UIElement(string? id)
{
@@ -48,26 +72,55 @@ internal abstract class UIElement : IUIElement
public bool IsVisible
{
get => _isVisible;
- internal set
- {
- _isVisible = value;
- IsVisibleChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _isVisible, value, IsVisibleChanged);
}
public bool IsEnabled
{
get => _isEnabled;
- internal set
- {
- _isEnabled = value;
- IsEnabledChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _isEnabled, value, IsEnabledChanged);
+ }
+
+ public UIHorizontalAlignment HorizontalAlignment
+ {
+ get => _horizontalAlignment;
+ internal set => SetPropertyValue(ref _horizontalAlignment, value, HorizontalAlignmentChanged);
+ }
+
+ public UIVerticalAlignment VerticalAlignment
+ {
+ get => _verticalAlignment;
+ internal set => SetPropertyValue(ref _verticalAlignment, value, VerticalAlignmentChanged);
}
public event EventHandler? IsVisibleChanged;
public event EventHandler? IsEnabledChanged;
+
+ public event EventHandler? HorizontalAlignmentChanged;
+
+ public event EventHandler? VerticalAlignmentChanged;
+
+ 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));
+ }
}
public static partial class GUI
@@ -119,4 +172,28 @@ public static partial class GUI
}
return element;
}
+
+ /// <summary>
+ /// Align the element horizontally.
+ /// </summary>
+ public static T AlignHorizontally<T>(this T element, UIHorizontalAlignment alignment) where T : IUIElement
+ {
+ if (element is UIElement strongElement)
+ {
+ strongElement.HorizontalAlignment = alignment;
+ }
+ return element;
+ }
+
+ /// <summary>
+ /// Align the element vertically.
+ /// </summary>
+ public static T AlignVertically<T>(this T element, UIVerticalAlignment alignment) where T : IUIElement
+ {
+ if (element is UIElement strongElement)
+ {
+ strongElement.VerticalAlignment = alignment;
+ }
+ return element;
+ }
}
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIIcon.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIIcon.cs
index eb80d0129..abdf12e35 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIIcon.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIIcon.cs
@@ -57,9 +57,8 @@ internal sealed class UIIcon : UIElement, IUIIcon
get => _fontName;
internal set
{
- _fontName = value;
- Guard.IsNotNullOrWhiteSpace(FontName);
- FontNameChanged?.Invoke(this, EventArgs.Empty);
+ Guard.IsNotNullOrWhiteSpace(value);
+ SetPropertyValue(ref _fontName, value, FontNameChanged);
}
}
@@ -68,20 +67,15 @@ internal sealed class UIIcon : UIElement, IUIIcon
get => _glyph;
internal set
{
- _glyph = value;
- Guard.IsNotNullOrWhiteSpace(Glyph);
- GlyphChanged?.Invoke(this, EventArgs.Empty);
+ Guard.IsNotNullOrWhiteSpace(value);
+ SetPropertyValue(ref _glyph, value, GlyphChanged);
}
}
public int Size
{
get => _size;
- internal set
- {
- _size = value;
- SizeChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _size, value, SizeChanged);
}
public event EventHandler? FontNameChanged;
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIMultilineLineTextInput.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIMultilineLineTextInput.cs
index d182a9f35..6764de64b 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIMultilineLineTextInput.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIMultilineLineTextInput.cs
@@ -43,21 +43,13 @@ internal class UIMultilineTextInput : UISingleLineTextInput, IUIMultilineLineTex
public IReadOnlyList<TextSpan> HighlightedSpans
{
get => _highlightedSpans ?? Array.Empty<TextSpan>();
- internal set
- {
- _highlightedSpans = value;
- HighlightedSpansChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _highlightedSpans, value, HighlightedSpansChanged);
}
public string SyntaxColorizationLanguageName
{
get => _syntaxColorizationLanguageName ?? string.Empty;
- internal set
- {
- _syntaxColorizationLanguageName = value;
- SyntaxColorizationLanguageNameChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _syntaxColorizationLanguageName, value, SyntaxColorizationLanguageNameChanged);
}
public event EventHandler? HighlightedSpansChanged;
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs
index 12524b123..5fc30a7d5 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs
@@ -51,31 +51,19 @@ internal class UISetting : UITitledElement, IUISetting
public string? Description
{
get => _description;
- internal set
- {
- _description = value;
- DescriptionChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _description, value, DescriptionChanged);
}
public IUIIcon? Icon
{
get => _icon;
- internal set
- {
- _icon = value;
- IconChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _icon, value, IconChanged);
}
public IUIElement? InteractiveElement
{
get => _interactiveElement;
- internal set
- {
- _interactiveElement = value;
- InteractiveElementChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _interactiveElement, value, InteractiveElementChanged);
}
public event EventHandler? DescriptionChanged;
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs
index 57f8778fc..684a948ab 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs
@@ -34,11 +34,7 @@ internal sealed class UISettingGroup : UISetting, IUISettingGroup
public IUIElement[]? Children
{
get => _children;
- internal set
- {
- _children = value;
- ChildrenChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _children, value, ChildrenChanged);
}
public bool ChildrenAreAllSettings { get; internal set; }
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISinglelineTextInput.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISinglelineTextInput.cs
index 3a92af71b..30bfd311d 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISinglelineTextInput.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISinglelineTextInput.cs
@@ -62,31 +62,19 @@ internal class UISingleLineTextInput : UITitledElement, IUISingleLineTextInput
public string Text
{
get => _text ?? string.Empty;
- internal set
- {
- _text = value;
- TextChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _text, value, TextChanged);
}
public bool IsReadOnly
{
get => _isReadOnly;
- internal set
- {
- _isReadOnly = value;
- IsReadOnlyChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _isReadOnly, value, IsReadOnlyChanged);
}
public bool CanCopyWhenEditable
{
get => _canCopyWhenEditable;
- internal set
- {
- _canCopyWhenEditable = value;
- CanCopyWhenEditableChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _canCopyWhenEditable, value, CanCopyWhenEditableChanged);
}
public TextSpan Selection
@@ -111,6 +99,7 @@ internal class UISingleLineTextInput : UITitledElement, IUISingleLineTextInput
}
}
SelectionChanged?.Invoke(this, EventArgs.Empty);
+ OnPropertyChanged();
}
}
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIStack.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIStack.cs
index c73272230..bd1071346 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIStack.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIStack.cs
@@ -41,21 +41,13 @@ internal sealed class UIStack : UIElement, IUIStack
public UIOrientation Orientation
{
get => _orientation;
- internal set
- {
- _orientation = value;
- OrientationChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _orientation, value, OrientationChanged);
}
public IUIElement[]? Children
{
get => _children;
- internal set
- {
- _children = value;
- ChildrenChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _children, value, ChildrenChanged);
}
public event EventHandler? OrientationChanged;
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISwitch.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISwitch.cs
index c4a09b651..909974010 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISwitch.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISwitch.cs
@@ -55,8 +55,7 @@ internal sealed class UISwitch : UITitledElement, IUISwitch
get => _state;
internal set
{
- _state = value;
- IsOnChanged?.Invoke(this, EventArgs.Empty);
+ SetPropertyValue(ref _state, value, IsOnChanged);
ActionOnToggle?.Invoke(_state);
}
}
@@ -64,21 +63,13 @@ internal sealed class UISwitch : UITitledElement, IUISwitch
public string? OnText
{
get => _onText;
- internal set
- {
- _onText = value;
- OnTextChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _onText, value, OnTextChanged);
}
public string? OffText
{
get => _offText;
- internal set
- {
- _offText = value;
- OffTextChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _offText, value, OffTextChanged);
}
internal Func<bool, ValueTask>? ActionOnToggle { get; set; }
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUITitledElement.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUITitledElement.cs
index 50e641ee4..32a7f51ca 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUITitledElement.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUITitledElement.cs
@@ -29,11 +29,7 @@ internal abstract class UITitledElement : UIElement, IUITitledElement
public string? Title
{
get => _title;
- internal set
- {
- _title = value;
- TitleChanged?.Invoke(this, EventArgs.Empty);
- }
+ internal set => SetPropertyValue(ref _title, value, TitleChanged);
}
public event EventHandler? TitleChanged;
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIHorizontalAlignment.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIHorizontalAlignment.cs
new file mode 100644
index 000000000..465de44de
--- /dev/null
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIHorizontalAlignment.cs
@@ -0,0 +1,27 @@
+namespace DevToys.Api;
+
+/// <summary>
+/// Indicates where an element should be displayed on the horizontal axis relative to the allocated layout slot of the parent element.
+/// </summary>
+public enum UIHorizontalAlignment
+{
+ /// <summary>
+ /// An element aligned to the left of the layout slot for the parent element.
+ /// </summary>
+ Left,
+
+ /// <summary>
+ /// An element aligned to the center of the layout slot for the parent element.
+ /// </summary>
+ Center,
+
+ /// <summary>
+ /// An element aligned to the right of the layout slot for the parent element.
+ /// </summary>
+ Right,
+
+ /// <summary>
+ /// An element stretched to fill the entire layout slot of the parent element.
+ /// </summary>
+ Stretch,
+}
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIOrientation.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIOrientation.cs
index 9eb0eadc7..d3cd90ef5 100644
--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIOrientation.cs
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIOrientation.cs
@@ -1,17 +1,17 @@
namespace DevToys.Api;
/// <summary>
-/// Defines the different orientations that a control or layout can have.
+/// Defines the different orientations that an element or layout can have.
/// </summary>
public enum UIOrientation
{
/// <summary>
- /// Control or layout should be horizontally oriented.
+ /// Element or layout should be horizontally oriented.
/// </summary>
Horizontal,
/// <summary>
- /// Control or layout should be vertically oriented.
+ /// Element or layout should be vertically oriented.
/// </summary>
Vertical
}
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIVerticalAlignment.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIVerticalAlignment.cs
new file mode 100644
index 000000000..e604f8b14
--- /dev/null
+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIVerticalAlignment.cs
@@ -0,0 +1,27 @@
+namespace DevToys.Api;
+
+/// <summary>
+/// Describes how a child element is vertically positioned or stretched within a parent's layout slot.
+/// </summary>
+public enum UIVerticalAlignment
+{
+ /// <summary>
+ /// The child element is aligned to the top of the parent's layout slot.
+ /// </summary>
+ Top,
+
+ /// <summary>
+ /// The child element is aligned to the center of the parent's layout slot.
+ /// </summary>
+ Center,
+
+ /// <summary>
+ /// The child element is aligned to the bottom of the parent's layout slot.
+ /// </summary>
+ Bottom,
+
+ /// <summary>
+ /// The child element stretches to fill the parent's layout slot.
+ /// </summary>
+ Stretch
+}
diff --git a/src/app/dev/DevToys.Blazor/Assets/sass/_typography.scss b/src/app/dev/DevToys.Blazor/Assets/sass/_typography.scss
index c045fb6c1..246665ad2 100644
--- a/src/app/dev/DevToys.Blazor/Assets/sass/_typography.scss
+++ b/src/app/dev/DevToys.Blazor/Assets/sass/_typography.scss
@@ -27,8 +27,9 @@ i[class^="FluentSystemIcons"]:before, i[class*=" FluentSystemIcons"]:before {
family: var(--font-family-text);
size: var(--font-size-body);
optical-sizing: none;
- weight: normal;
+ weight: 300;
}
line-height: 20px;
+ letter-spacing: 0.3px;
}
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor b/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor
index e572ccea0..0e3521736 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor
@@ -2,7 +2,7 @@
@inherits JSStyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -15,6 +15,7 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
<button id=@Id
role="button"
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor.cs b/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor.cs
index 17efceddd..3f0c46948 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor.cs
@@ -16,12 +16,12 @@ public partial class Button : JSStyledComponentBase
CSS.Clear();
CSS.Add($"type-{Appearance.Class}");
- if (IsEnabled && AdditionalAttributes is not null)
+ if (IsActuallyEnabled && AdditionalAttributes is not null)
{
AdditionalAttributes.Remove("disabled");
}
- if (!IsEnabled)
+ if (!IsActuallyEnabled)
{
CSS.Add("disabled");
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/CheckBox/CheckBox.razor b/src/app/dev/DevToys.Blazor/Components/BasicInput/CheckBox/CheckBox.razor
index 23d3cedb0..6d95ceb3e 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/CheckBox/CheckBox.razor
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/CheckBox/CheckBox.razor
@@ -2,7 +2,7 @@
@inherits JSStyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -15,13 +15,14 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
<label
id=@Id
role="button"
- class="checkbox-container @(IsEnabled ? string.Empty : "disabled")"
+ class="checkbox-container @(IsActuallyEnabled ? string.Empty : "disabled")"
style="@(Style)"
- @onclick:stopPropagation="@IsEnabled"
+ @onclick:stopPropagation="@IsActuallyEnabled"
@ref=Element>
<span class="checkbox-inner">
<input
@@ -29,8 +30,8 @@
tabindex="0"
class="checkbox @(FinalCssClasses)"
checked="@IsChecked"
- disabled="@(!IsEnabled)"
- @onclick:preventDefault="@(!IsEnabled)"
+ disabled="@(!IsActuallyEnabled)"
+ @onclick:preventDefault="@(!IsActuallyEnabled)"
@onchange="OnChange"
@attributes="AdditionalAttributes" />
<svg
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor b/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor
index 3004bc824..2daf03f39 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor
@@ -2,88 +2,91 @@
@typeparam TElement
@inherits SelectBase<TElement>
-<CascadingValue Value="this" IsFixed="false">
- <Container HorizontalAlignment="@HorizontalAlignment"
- VerticalAlignment="@VerticalAlignment"
- Width="@Width"
- Height="@Height"
- MarginLeft="@MarginLeft"
- MarginRight="@MarginRight"
- MarginTop="@MarginTop"
- MarginBottom="@MarginBottom"
- PaddingLeft="@PaddingLeft"
- PaddingRight="@PaddingRight"
- PaddingTop="@PaddingTop"
- PaddingBottom="@PaddingBottom"
- IsVisible="@IsVisible">
- <div id=@Id
- class="combo-box-with-header @(FinalCssClasses)"
- style="@(Style)"
- @attributes="AdditionalAttributes">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
+ <CascadingValue Value="this" IsFixed="false">
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ MarginLeft="@MarginLeft"
+ MarginRight="@MarginRight"
+ MarginTop="@MarginTop"
+ MarginBottom="@MarginBottom"
+ PaddingLeft="@PaddingLeft"
+ PaddingRight="@PaddingRight"
+ PaddingTop="@PaddingTop"
+ PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
+ IsVisible="@IsVisible">
+ <div id=@Id
+ class="combo-box-with-header @(FinalCssClasses)"
+ style="@(Style)"
+ @attributes="AdditionalAttributes">
- @if (!string.IsNullOrWhiteSpace(Header))
- {
- <TextBlock Appearance="TextBlockAppearance.Body" Class="combo-box-header" Text="@Header" />
- }
-
- <Button @ref="_button"
- Class="@($"combo-box-button {FinalCssClasses}")"
- HorizontalAlignment="@HorizontalAlignment"
- Width="@Width"
- Appearance="ButtonAppearance.Neutral"
- IsEnabled="@IsEnabled"
- @onclick="@ToggleDropDown">
- @if (SelectedItem is not null)
+ @if (!string.IsNullOrWhiteSpace(Header))
{
- @ItemTemplate(SelectedItem)
+ <TextBlock Appearance="TextBlockAppearance.Body" Class="combo-box-header" Text="@Header" />
}
- <div class="arrow-down-icon">
- <FontIcon Glyph="@('\uf2a6')" Height="12" Width="12" />
- </div>
- <Popover Open="_isOpen"
- AnchorOrigin="Origin.CenterCenter"
- TransformOrigin="Origin.CenterCenter"
- RelativeWidth="false"
- @ontouchend:stopPropagation>
- <CascadingValue Value="@this" IsFixed="true">
- <FocusTrapper Style="display: contents;"
- OnEscapeKeyPressed="OnEscapeKeyPressed"
- @onfocusout="OnEscapeKeyPressed">
- <ScrollViewer Orientation="Orientation.Vertical"
- IsEnabled="@IsEnabled"
- Class="@FinalCssClasses"
- Style="@Style"
- UseNativeScrollBar="true"
- AdditionalAttributes="@AdditionalAttributes">
- <ul @ref="_listBox"
- role="menu"
- class="combo-box-list-box"
- tabindex="0"
- @onkeydown="OnKeyDown">
+ <Button @ref="_button"
+ Class="@($"combo-box-button {FinalCssClasses}")"
+ HorizontalAlignment="@HorizontalAlignment"
+ Width="@Width"
+ Appearance="ButtonAppearance.Neutral"
+ IsEnabled="@IsActuallyEnabled"
+ @onclick="@ToggleDropDown">
+ @if (SelectedItem is not null)
+ {
+ @ItemTemplate(SelectedItem)
+ }
+ <div class="arrow-down-icon">
+ <FontIcon Glyph="@('\uf2a6')" Height="12" Width="12" />
+ </div>
- @if (Virtualize)
- {
- <Virtualize Items="@Items" Context="item">
- @RenderItem(item)
- </Virtualize>
- }
- else if (Items is not null)
- {
- foreach (var item in Items)
+ <Popover Open="_isOpen"
+ AnchorOrigin="Origin.CenterCenter"
+ TransformOrigin="Origin.CenterCenter"
+ RelativeWidth="false"
+ @ontouchend:stopPropagation>
+ <CascadingValue Value="@this" IsFixed="true">
+ <FocusTrapper Style="display: contents;"
+ OnEscapeKeyPressed="OnEscapeKeyPressed"
+ @onfocusout="OnEscapeKeyPressed">
+ <ScrollViewer Orientation="UIOrientation.Vertical"
+ IsEnabled="@IsActuallyEnabled"
+ Class="@FinalCssClasses"
+ Style="@Style"
+ UseNativeScrollBar="true"
+ AdditionalAttributes="@AdditionalAttributes">
+ <ul @ref="_listBox"
+ role="menu"
+ class="combo-box-list-box"
+ tabindex="0"
+ @onkeydown="OnKeyDown">
+
+ @if (Virtualize)
+ {
+ <Virtualize Items="@Items" Context="item">
+ @RenderItem(item)
+ </Virtualize>
+ }
+ else if (Items is not null)
{
- @RenderItem(item)
+ foreach (var item in Items)
+ {
+ @RenderItem(item)
+ }
}
- }
- </ul>
- </ScrollViewer>
- </FocusTrapper>
- </CascadingValue>
- </Popover>
- </Button>
- </div>
- </Container>
+ </ul>
+ </ScrollViewer>
+ </FocusTrapper>
+ </CascadingValue>
+ </Popover>
+ </Button>
+ </div>
+ </Container>
+ </CascadingValue>
</CascadingValue>
@code {
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor.cs b/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor.cs
index b580f235b..eae89c2a8 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor.cs
@@ -49,7 +49,7 @@ public partial class ComboBox<TElement> : SelectBase<TElement> where TElement :
private void OpenDropDown(MouseEventArgs ev)
{
- if (IsEnabled && ContextMenuService.TryOpenContextMenu())
+ if (IsActuallyEnabled && ContextMenuService.TryOpenContextMenu())
{
ContextMenuService.CloseContextMenuRequested += ContextMenuService_CloseContextMenuRequested;
_isOpen = true;
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor b/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor
index bee08cbe2..e206ca3d4 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor
@@ -1,80 +1,83 @@
@namespace DevToys.Blazor.Components
@inherits StyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
- <Container HorizontalAlignment="@HorizontalAlignment"
- VerticalAlignment="@VerticalAlignment"
- Width="@Width"
- Height="@Height"
- MarginLeft="@MarginLeft"
- MarginRight="@MarginRight"
- MarginTop="@MarginTop"
- MarginBottom="@MarginBottom"
- PaddingLeft="@PaddingLeft"
- PaddingRight="@PaddingRight"
- PaddingTop="@PaddingTop"
- PaddingBottom="@PaddingBottom"
- IsVisible="@IsVisible">
- <div id=@Id
- class="drop-down-list-with-header @(FinalCssClasses)"
- style="@(Style)"
- @attributes="AdditionalAttributes">
-
- @if (!string.IsNullOrWhiteSpace(Header))
- {
- <TextBlock Appearance="TextBlockAppearance.Body" Class="drop-down-list-header" Text="@Header" />
- }
-
- <Button Class="@($"drop-down-list-button {FinalCssClasses}")"
- HorizontalAlignment="@HorizontalAlignment"
- Width="@Width"
- Appearance="ButtonAppearance.Neutral"
- IsEnabled="@IsEnabled"
- @onclick="@ToggleDropDown">
- @ChildContent
- <div class="arrow-down-icon">
- <FontIcon Glyph="@('\uf2a6')" Height="12" Width="12" />
- </div>
-
- <Popover Open="_isOpen"
- AnchorOrigin="Origin.BottomCenter"
- TransformOrigin="Origin.TopCenter"
- RelativeWidth="false"
- Class="drop-down-list-drop-down"
- @ontouchend:stopPropagation>
- <CascadingValue Value="@this" IsFixed="true">
- <FocusTrapper Style="display: contents;"
- OnEscapeKeyPressed="OnEscapeKeyPressed"
- @onfocusout="OnEscapeKeyPressed">
- <ListBox @ref="_listBox"
- Items="Items"
- Context="item"
- Role="menu"
- OverrideDefaultItemTemplate="true"
- Virtualize="true"
- RaiseSelectionEventOnKeyboardNavigation="false"
- SelectedIndexChanged="OnDropDowlListItemSelected"
- UseNativeScrollBar="true"
- Class="context-menu-list-box"
- Style="max-height: 400px">
- <ItemTemplate>
- <li role="menuitem"
- class="@($"context-menu-item {(_listBox!.SelectedItem == item ? "selected" : string.Empty)} {(item.IsEnabled ? string.Empty : "disabled")}")"
- aria-disabled="@(item.IsEnabled ? string.Empty : "true")">
- <div class="icon-container">
- <FontIcon Glyph="@item.IconGlyph" FontFamily="@item.IconFontFamily" />
- </div>
- <TextBlock Class="text"
- NoWrap="true"
- Text="@item.Text" />
- </li>
- </ItemTemplate>
- </ListBox>
- </FocusTrapper>
- </CascadingValue>
- </Popover>
- </Button>
-
- </div>
- </Container>
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
+ <CascadingValue Value="this" IsFixed="true">
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ MarginLeft="@MarginLeft"
+ MarginRight="@MarginRight"
+ MarginTop="@MarginTop"
+ MarginBottom="@MarginBottom"
+ PaddingLeft="@PaddingLeft"
+ PaddingRight="@PaddingRight"
+ PaddingTop="@PaddingTop"
+ PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
+ IsVisible="@IsVisible">
+ <div id=@Id
+ class="drop-down-list-with-header @(FinalCssClasses)"
+ style="@(Style)"
+ @attributes="AdditionalAttributes">
+
+ @if (!string.IsNullOrWhiteSpace(Header))
+ {
+ <TextBlock Appearance="TextBlockAppearance.Body" Class="drop-down-list-header" Text="@Header" />
+ }
+
+ <Button Class="@($"drop-down-list-button {FinalCssClasses}")"
+ HorizontalAlignment="@HorizontalAlignment"
+ Width="@Width"
+ Appearance="ButtonAppearance.Neutral"
+ IsEnabled="@IsActuallyEnabled"
+ @onclick="@ToggleDropDown">
+ @ChildContent
+ <div class="arrow-down-icon">
+ <FontIcon Glyph="@('\uf2a6')" Height="12" Width="12" />
+ </div>
+
+ <Popover Open="_isOpen"
+ AnchorOrigin="Origin.BottomCenter"
+ TransformOrigin="Origin.TopCenter"
+ RelativeWidth="false"
+ Class="drop-down-list-drop-down"
+ @ontouchend:stopPropagation>
+ <CascadingValue Value="@this" IsFixed="true">
+ <FocusTrapper Style="display: contents;"
+ OnEscapeKeyPressed="OnEscapeKeyPressed"
+ @onfocusout="OnEscapeKeyPressed">
+ <ListBox @ref="_listBox"
+ Items="Items"
+ Context="item"
+ Role="menu"
+ OverrideDefaultItemTemplate="true"
+ Virtualize="true"
+ RaiseSelectionEventOnKeyboardNavigation="false"
+ SelectedIndexChanged="OnDropDowlListItemSelected"
+ UseNativeScrollBar="true"
+ Class="context-menu-list-box"
+ Style="max-height: 400px">
+ <ItemTemplate>
+ <li role="menuitem"
+ class="@($"context-menu-item {(_listBox!.SelectedItem == item ? "selected" : string.Empty)} {(item.IsEnabled ? string.Empty : "disabled")}")"
+ aria-disabled="@(item.IsEnabled ? string.Empty : "true")">
+ <div class="icon-container">
+ <FontIcon Glyph="@item.IconGlyph" FontFamily="@item.IconFontFamily" />
+ </div>
+ <TextBlock Class="text"
+ NoWrap="true"
+ Text="@item.Text" />
+ </li>
+ </ItemTemplate>
+ </ListBox>
+ </FocusTrapper>
+ </CascadingValue>
+ </Popover>
+ </Button>
+
+ </div>
+ </Container>
+ </CascadingValue>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor.cs b/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor.cs
index dc6398358..66ee7eb96 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor.cs
@@ -1,5 +1,4 @@
-using DevToys.Api;
-using DevToys.Blazor.Core.Services;
+using DevToys.Blazor.Core.Services;
using Microsoft.AspNetCore.Components.Web;
namespace DevToys.Blazor.Components;
@@ -56,7 +55,7 @@ public partial class DropDownList : StyledComponentBase
private void OpenDropDown(MouseEventArgs ev)
{
- if (IsEnabled && ContextMenuService.TryOpenContextMenu())
+ if (IsActuallyEnabled && ContextMenuService.TryOpenContextMenu())
{
ContextMenuService.CloseContextMenuRequested += ContextMenuService_CloseContextMenuRequested;
_isOpen = true;
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/RadioButton/RadioButton.razor b/src/app/dev/DevToys.Blazor/Components/BasicInput/RadioButton/RadioButton.razor
index b18f98b4a..8a5ff4e87 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/RadioButton/RadioButton.razor
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/RadioButton/RadioButton.razor
@@ -2,7 +2,7 @@
@inherits JSStyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -15,19 +15,20 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
<label id=@Id
- class="radio-button-container @(IsEnabled ? string.Empty : "disabled")"
+ class="radio-button-container @(IsActuallyEnabled ? string.Empty : "disabled")"
style="@(Style)"
- @onclick:stopPropagation="@IsEnabled"
+ @onclick:stopPropagation="@IsActuallyEnabled"
@ref=Element>
<input type="radio"
tabindex="0"
class="radio-button @(FinalCssClasses)"
checked="@IsChecked"
- disabled="@(!IsEnabled)"
+ disabled="@(!IsActuallyEnabled)"
name="@Group"
- @onclick:preventDefault="@(!IsEnabled)"
+ @onclick:preventDefault="@(!IsActuallyEnabled)"
@onchange="OnChange"
@attributes="AdditionalAttributes" />
<TextBlock Text="@Text" />
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/ToggleSwitch/ToggleSwitch.razor b/src/app/dev/DevToys.Blazor/Components/BasicInput/ToggleSwitch/ToggleSwitch.razor
index f2e2fc8d6..64bf40f59 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/ToggleSwitch/ToggleSwitch.razor
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/ToggleSwitch/ToggleSwitch.razor
@@ -2,7 +2,7 @@
@inherits JSStyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -15,13 +15,14 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
<label
id=@Id
role="button"
- class="toggle-switch-container @(IsEnabled ? string.Empty : "disabled")"
+ class="toggle-switch-container @(IsActuallyEnabled ? string.Empty : "disabled")"
style="@(Style)"
- @onclick:stopPropagation="@IsEnabled"
+ @onclick:stopPropagation="@IsActuallyEnabled"
@ref=Element>
<TextBlock Text="@Text" NoWrap="true" />
<input
@@ -29,8 +30,8 @@
tabindex="0"
class="toggle-switch @(FinalCssClasses)"
checked="@IsOn"
- disabled="@(!IsEnabled)"
- @onclick:preventDefault="@(!IsEnabled)"
+ disabled="@(!IsActuallyEnabled)"
+ @onclick:preventDefault="@(!IsActuallyEnabled)"
@onchange="OnChange"
@attributes="AdditionalAttributes" />
</label>
diff --git a/src/app/dev/DevToys.Blazor/Components/Collections/GridView/GridView.razor b/src/app/dev/DevToys.Blazor/Components/Collections/GridView/GridView.razor
index d6489674a..9694a8e8f 100644
--- a/src/app/dev/DevToys.Blazor/Components/Collections/GridView/GridView.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Collections/GridView/GridView.razor
@@ -3,7 +3,7 @@
@typeparam TKey
@typeparam TElement
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -16,9 +16,10 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
<ScrollViewer @ref=_scrollViewer
- Orientation="Orientation.Vertical"
+ Orientation="UIOrientation.Vertical"
Class="@(FinalCssClasses)"
style="@(Style)"
@attributes="AdditionalAttributes">
diff --git a/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBox.razor b/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBox.razor
index a9a8d44b4..b2697cb09 100644
--- a/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBox.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBox.razor
@@ -2,7 +2,7 @@
@typeparam TElement
@inherits SelectBase<TElement>
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -15,9 +15,10 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
- <ScrollViewer Orientation="Orientation.Vertical"
- IsEnabled="@IsEnabled"
+ <ScrollViewer Orientation="UIOrientation.Vertical"
+ IsEnabled="@IsActuallyEnabled"
Class="@FinalCssClasses"
Style="@Style"
UseNativeScrollBar="@UseNativeScrollBar"
diff --git a/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBoxItem.razor b/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBoxItem.razor
index 9c9ad33ff..c48731d2d 100644
--- a/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBoxItem.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBoxItem.razor
@@ -1,7 +1,7 @@
@namespace DevToys.Blazor.Components
@inherits StyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<li class="list-box-item @(FinalCssClasses)"
style="@(Style)"
role="listitem"
diff --git a/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBoxItem.razor.cs b/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBoxItem.razor.cs
index a5ea031a7..07b0b4302 100644
--- a/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBoxItem.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBoxItem.razor.cs
@@ -28,7 +28,7 @@ public partial class ListBoxItem : StyledComponentBase
CSS.Remove("selected");
}
- if (IsEnabled)
+ if (IsActuallyEnabled)
{
CSS.Remove("disabled");
}
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/FontIcon/FontIcon.razor b/src/app/dev/DevToys.Blazor/Components/Feedback/FontIcon/FontIcon.razor
index 49cd61e9c..f20159b8f 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/FontIcon/FontIcon.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/FontIcon/FontIcon.razor
@@ -1,7 +1,7 @@
@namespace DevToys.Blazor.Components
@inherits StyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="null"
@@ -14,6 +14,7 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
<i id=@Id
class="font-icon @(FinalCssClasses)"
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/FontIcon/FontIcon.razor.cs b/src/app/dev/DevToys.Blazor/Components/Feedback/FontIcon/FontIcon.razor.cs
index 0812d6663..34a407d94 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/FontIcon/FontIcon.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/FontIcon/FontIcon.razor.cs
@@ -12,8 +12,8 @@ public partial class FontIcon : StyledComponentBase
public FontIcon()
{
- VerticalAlignment = VerticalAlignment.Center;
- HorizontalAlignment = HorizontalAlignment.Center;
+ VerticalAlignment = UIVerticalAlignment.Center;
+ HorizontalAlignment = UIHorizontalAlignment.Center;
Height = 16;
Width = 16;
}
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/InfoBar/InfoBar.razor b/src/app/dev/DevToys.Blazor/Components/Feedback/InfoBar/InfoBar.razor
index 17f5c6f57..d1581fd5f 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/InfoBar/InfoBar.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/InfoBar/InfoBar.razor
@@ -1,7 +1,7 @@
@namespace DevToys.Blazor.Components
@inherits StyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -14,6 +14,7 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
@if (IsOpen)
{
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/InfoBar/InfoBar.razor.cs b/src/app/dev/DevToys.Blazor/Components/Feedback/InfoBar/InfoBar.razor.cs
index 3bf0d0608..7c3aa0d36 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/InfoBar/InfoBar.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/InfoBar/InfoBar.razor.cs
@@ -4,7 +4,7 @@ public partial class InfoBar : StyledComponentBase
{
public InfoBar()
{
- VerticalAlignment = VerticalAlignment.Center;
+ VerticalAlignment = UIVerticalAlignment.Center;
}
[Parameter]
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor
index c96654aaa..334c8c956 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor
@@ -1,7 +1,7 @@
@namespace DevToys.Blazor.Components
@inherits StyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -14,6 +14,7 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
<svg @ref="Element"
tabindex="-1"
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor.cs b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor.cs
index 3cbbcf508..565a93497 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor.cs
@@ -6,7 +6,7 @@ public partial class ProgressBar : StyledComponentBase
{
public ProgressBar()
{
- VerticalAlignment = VerticalAlignment.Top;
+ VerticalAlignment = UIVerticalAlignment.Top;
}
[Parameter]
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor
index f7fdd44f9..fff5d85ba 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor
@@ -1,7 +1,7 @@
@namespace DevToys.Blazor.Components
@inherits StyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -14,6 +14,7 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
<svg @ref="Element"
tabindex="-1"
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor.cs b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor.cs
index 23766159b..1a31cf613 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor.cs
@@ -9,8 +9,8 @@ public partial class ProgressRing : StyledComponentBase
public ProgressRing()
{
- VerticalAlignment = VerticalAlignment.Center;
- HorizontalAlignment = HorizontalAlignment.Center;
+ VerticalAlignment = UIVerticalAlignment.Center;
+ HorizontalAlignment = UIHorizontalAlignment.Center;
Height = 48;
Width = 48;
}
diff --git a/src/app/dev/DevToys.Blazor/Components/HorizontalAlignment.cs b/src/app/dev/DevToys.Blazor/Components/HorizontalAlignment.cs
deleted file mode 100644
index db1a6e15e..000000000
--- a/src/app/dev/DevToys.Blazor/Components/HorizontalAlignment.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace DevToys.Blazor.Components;
-
-public enum HorizontalAlignment
-{
- Stretch,
- Left,
- Right,
- Center
-}
diff --git a/src/app/dev/DevToys.Blazor/Components/JSStyledComponentBase.cs b/src/app/dev/DevToys.Blazor/Components/JSStyledComponentBase.cs
index 9c575424b..de6bf59b4 100644
--- a/src/app/dev/DevToys.Blazor/Components/JSStyledComponentBase.cs
+++ b/src/app/dev/DevToys.Blazor/Components/JSStyledComponentBase.cs
@@ -1,6 +1,4 @@
-using DevToys.Api;
-
-namespace DevToys.Blazor.Components;
+namespace DevToys.Blazor.Components;
public abstract class JSStyledComponentBase : StyledComponentBase, IAsyncDisposable
{
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Card/Card.razor b/src/app/dev/DevToys.Blazor/Components/Layout/Card/Card.razor
index 48730bf69..01db3cbe2 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/Card/Card.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Card/Card.razor
@@ -1,7 +1,7 @@
@namespace DevToys.Blazor.Components
@inherits StyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -14,6 +14,7 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
<div class="card @(FinalCssClasses)"
style="@(Style)"
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor b/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor
index 883449896..df0c947df 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor
@@ -1,7 +1,7 @@
@namespace DevToys.Blazor.Components
@inherits StyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<div class="@(FinalCssClasses)"
style="@(FinalStyles)"
@attributes="AdditionalAttributes">
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor.cs
index 86b1b5e83..ede8159f7 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor.cs
@@ -44,27 +44,27 @@ public partial class Container : StyledComponentBase
switch (HorizontalAlignment)
{
- case HorizontalAlignment.Stretch:
+ case UIHorizontalAlignment.Stretch:
innerStyleBuilder.AddImportantStyle("width", "100%", !Width.HasValue);
styleBuilder.AddImportantStyle("justify-content", "center", Width.HasValue);
break;
- case HorizontalAlignment.Left:
+ case UIHorizontalAlignment.Left:
styleBuilder.AddImportantStyle("justify-content", "flex-start");
break;
- case HorizontalAlignment.Right:
+ case UIHorizontalAlignment.Right:
styleBuilder.AddImportantStyle("justify-content", "flex-end");
break;
- case HorizontalAlignment.Center:
+ case UIHorizontalAlignment.Center:
styleBuilder.AddImportantStyle("justify-content", "center");
break;
}
switch (VerticalAlignment)
{
- case VerticalAlignment.Stretch:
+ case UIVerticalAlignment.Stretch:
styleBuilder.AddImportantStyle("align-items", "stretch");
styleBuilder.AddImportantStyle("height", "100%", !Height.HasValue);
styleBuilder.AddImportantStyle("max-height", "100%", !Height.HasValue);
@@ -72,15 +72,15 @@ public partial class Container : StyledComponentBase
innerStyleBuilder.AddImportantStyle("height", "100%", !Height.HasValue);
break;
- case VerticalAlignment.Top:
+ case UIVerticalAlignment.Top:
styleBuilder.AddImportantStyle("align-items", "flex-start");
break;
- case VerticalAlignment.Bottom:
+ case UIVerticalAlignment.Bottom:
styleBuilder.AddImportantStyle("align-items", "flex-end");
break;
- case VerticalAlignment.Center:
+ case UIVerticalAlignment.Center:
styleBuilder.AddImportantStyle("align-items", "center");
break;
}
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Expander/Expander.razor b/src/app/dev/DevToys.Blazor/Components/Layout/Expander/Expander.razor
index 41b1e8cfa..5a35fc683 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/Expander/Expander.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Expander/Expander.razor
@@ -1,7 +1,7 @@
@namespace DevToys.Blazor.Components
@inherits StyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -14,6 +14,7 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible"
Class="expander">
<Card data-expanded="@IsExpanded.ToString().ToLower()"
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Expander/Expander.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/Expander/Expander.razor.cs
index c6a800cca..5d9c5b5d6 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/Expander/Expander.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Expander/Expander.razor.cs
@@ -1,5 +1,4 @@
-using DevToys.Core;
-using Microsoft.AspNetCore.Components.Web;
+using Microsoft.AspNetCore.Components.Web;
namespace DevToys.Blazor.Components;
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Grid/Grid.razor b/src/app/dev/DevToys.Blazor/Components/Layout/Grid/Grid.razor
index b771d988c..b8fe77f12 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/Grid/Grid.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Grid/Grid.razor
@@ -1,20 +1,23 @@
@namespace DevToys.Blazor.Components
@inherits StyledComponentBase
-<Container HorizontalAlignment="@HorizontalAlignment"
- VerticalAlignment="@VerticalAlignment"
- Width="@Width"
- Height="@Height"
- MarginLeft="@MarginLeft"
- MarginRight="@MarginRight"
- MarginTop="@MarginTop"
- MarginBottom="@MarginBottom"
- PaddingLeft="@PaddingLeft"
- PaddingRight="@PaddingRight"
- PaddingTop="@PaddingTop"
- PaddingBottom="@PaddingBottom"
- IsVisible="@IsVisible">
- <div id="@Id" @ref="@Element" class="@FinalCssClasses" style="@StyleValue" @attributes="AdditionalAttributes">
- @ChildContent
- </div>
-</Container>
\ No newline at end of file
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ MarginLeft="@MarginLeft"
+ MarginRight="@MarginRight"
+ MarginTop="@MarginTop"
+ MarginBottom="@MarginBottom"
+ PaddingLeft="@PaddingLeft"
+ PaddingRight="@PaddingRight"
+ PaddingTop="@PaddingTop"
+ PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
+ IsVisible="@IsVisible">
+ <div id="@Id" @ref="@Element" class="@FinalCssClasses" style="@StyleValue" @attributes="AdditionalAttributes">
+ @ChildContent
+ </div>
+ </Container>
+</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Grid/GridCell.razor b/src/app/dev/DevToys.Blazor/Components/Layout/Grid/GridCell.razor
index ef01fa704..dfa2d1409 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/Grid/GridCell.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Grid/GridCell.razor
@@ -1,8 +1,8 @@
@namespace DevToys.Blazor.Components
@inherits ComponentBase
-<Container HorizontalAlignment="@HorizontalAlignment.Stretch"
- VerticalAlignment="@VerticalAlignment.Stretch"
+<Container HorizontalAlignment="@UIHorizontalAlignment.Stretch"
+ VerticalAlignment="@UIVerticalAlignment.Stretch"
Style="@GridCellStyleValue">
@ChildContent
</Container>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor
index 3c5fea398..9b068dbe9 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor
@@ -1,7 +1,7 @@
@namespace DevToys.Blazor.Components
@inherits StyledComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -14,6 +14,7 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
<div id=@Id
class="scroll-viewer @(FinalCssClasses)"
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor.cs
index 1ae6c3361..7c51b3ece 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
@@ -6,7 +6,7 @@ public partial class ScrollViewer : StyledComponentBase
/// Gets or set the orientation in which the content can be scrolled.
/// </summary>
[Parameter]
- public Orientation Orientation { get; set; } = Orientation.Vertical;
+ public UIOrientation Orientation { get; set; } = UIOrientation.Vertical;
/// <summary>
/// Gets or sets the content to be rendered inside the component.
@@ -34,7 +34,7 @@ public partial class ScrollViewer : StyledComponentBase
protected override void OnParametersSet()
{
AdditionalAttributes ??= new Dictionary<string, object>();
- if (IsEnabled && !UseNativeScrollBar)
+ if (IsActuallyEnabled && !UseNativeScrollBar)
{
// This will trigger simplebar to start.
AdditionalAttributes.TryAdd("data-simplebar", true);
@@ -44,14 +44,14 @@ public partial class ScrollViewer : StyledComponentBase
AdditionalAttributes.Remove("data-simplebar");
}
- if ((Orientation & Orientation.Vertical) != 0
- && (Orientation & Orientation.Horizontal) != 0)
+ if ((Orientation & UIOrientation.Vertical) != 0
+ && (Orientation & UIOrientation.Horizontal) != 0)
{
CSS.Clear();
}
else
{
- if ((Orientation & Orientation.Vertical) != 0)
+ if ((Orientation & UIOrientation.Vertical) != 0)
{
CSS.Add("vertical");
}
@@ -60,7 +60,7 @@ public partial class ScrollViewer : StyledComponentBase
CSS.Remove("vertical");
}
- if ((Orientation & Orientation.Horizontal) != 0)
+ if ((Orientation & UIOrientation.Horizontal) != 0)
{
CSS.Add("horizontal");
}
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/SplitGrid/SplitGrid.razor b/src/app/dev/DevToys.Blazor/Components/Layout/SplitGrid/SplitGrid.razor
index 1ddb3f8c8..7b7ebaf13 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/SplitGrid/SplitGrid.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/SplitGrid/SplitGrid.razor
@@ -1,32 +1,35 @@
@namespace DevToys.Blazor.Components
@inherits JSStyledComponentBase
-<Container HorizontalAlignment="@HorizontalAlignment"
- VerticalAlignment="@VerticalAlignment"
- Width="@Width"
- Height="@Height"
- MarginLeft="@MarginLeft"
- MarginRight="@MarginRight"
- MarginTop="@MarginTop"
- MarginBottom="@MarginBottom"
- PaddingLeft="@PaddingLeft"
- PaddingRight="@PaddingRight"
- PaddingTop="@PaddingTop"
- PaddingBottom="@PaddingBottom"
- IsVisible="@IsVisible">
- <div id="@Id"
- @ref="@Element"
- class="@FinalCssClasses"
- style="@StyleValue"
- @attributes="AdditionalAttributes">
- <Container>
- @LeftOrTopCellContent
- </Container>
- <div @ref="@_gutterElement" class="grid-split-gripper" style="@GutterStyle">
- <FontIcon Glyph="@GripperGlyph" />
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ MarginLeft="@MarginLeft"
+ MarginRight="@MarginRight"
+ MarginTop="@MarginTop"
+ MarginBottom="@MarginBottom"
+ PaddingLeft="@PaddingLeft"
+ PaddingRight="@PaddingRight"
+ PaddingTop="@PaddingTop"
+ PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
+ IsVisible="@IsVisible">
+ <div id="@Id"
+ @ref="@Element"
+ class="@FinalCssClasses"
+ style="@StyleValue"
+ @attributes="AdditionalAttributes">
+ <Container IsEnabled="@IsActuallyEnabled">
+ @LeftOrTopCellContent
+ </Container>
+ <div @ref="@_gutterElement" class="grid-split-gripper" style="@GutterStyle">
+ <FontIcon Glyph="@GripperGlyph" />
+ </div>
+ <Container IsEnabled="@IsActuallyEnabled">
+ @RightOrBottomCellContent
+ </Container>
</div>
- <Container>
- @RightOrBottomCellContent
- </Container>
- </div>
-</Container>
\ No newline at end of file
+ </Container>
+</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/SplitGrid/SplitGrid.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/SplitGrid/SplitGrid.razor.cs
index c50a2e695..27ae3f652 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/SplitGrid/SplitGrid.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/SplitGrid/SplitGrid.razor.cs
@@ -8,21 +8,21 @@ public partial class SplitGrid : JSStyledComponentBase
protected string? StyleValue => new StyleBuilder()
.AddStyle("display", "grid")
- .AddStyle("grid-template-columns", $"{GetCellLength(LeftOrTopCellSize)} 16px {GetCellLength(RightOrBottomCellSize)}", GutterOrientation == Orientation.Vertical)
- .AddStyle("grid-template-rows", $"{GetCellLength(LeftOrTopCellSize)} 16px {GetCellLength(RightOrBottomCellSize)}", GutterOrientation == Orientation.Horizontal)
+ .AddStyle("grid-template-columns", $"{GetCellLength(LeftOrTopCellSize)} 16px {GetCellLength(RightOrBottomCellSize)}", GutterOrientation == UIOrientation.Vertical)
+ .AddStyle("grid-template-rows", $"{GetCellLength(LeftOrTopCellSize)} 16px {GetCellLength(RightOrBottomCellSize)}", GutterOrientation == UIOrientation.Horizontal)
.AddStyle(Style)
.Build();
protected string? GutterStyle => new StyleBuilder()
- .AddStyle("cursor", "col-resize", GutterOrientation == Orientation.Vertical)
- .AddStyle("cursor", "row-resize", GutterOrientation == Orientation.Horizontal)
- .AddStyle("grid-column", "2", GutterOrientation == Orientation.Vertical)
- .AddStyle("grid-column", "1/-1", GutterOrientation == Orientation.Horizontal)
- .AddStyle("grid-row", "1/-1", GutterOrientation == Orientation.Vertical)
- .AddStyle("grid-row", "2", GutterOrientation == Orientation.Horizontal)
+ .AddStyle("cursor", "col-resize", GutterOrientation == UIOrientation.Vertical)
+ .AddStyle("cursor", "row-resize", GutterOrientation == UIOrientation.Horizontal)
+ .AddStyle("grid-column", "2", GutterOrientation == UIOrientation.Vertical)
+ .AddStyle("grid-column", "1/-1", GutterOrientation == UIOrientation.Horizontal)
+ .AddStyle("grid-row", "1/-1", GutterOrientation == UIOrientation.Vertical)
+ .AddStyle("grid-row", "2", GutterOrientation == UIOrientation.Horizontal)
.Build();
- protected char GripperGlyph => GutterOrientation == Orientation.Vertical ? '\uE9F8' : '\uE9F5';
+ protected char GripperGlyph => GutterOrientation == UIOrientation.Vertical ? '\uE9F8' : '\uE9F5';
/// <summary>
/// Gets or sets the length of the left or top cell.
@@ -52,7 +52,7 @@ public partial class SplitGrid : JSStyledComponentBase
/// Gets or set the orientation of the grid gutter.
/// </summary>
[Parameter]
- public Orientation GutterOrientation { get; set; } = Orientation.Vertical;
+ public UIOrientation GutterOrientation { get; set; } = UIOrientation.Vertical;
/// <summary>
/// Gets or set the minimum size of the cells.
@@ -78,7 +78,7 @@ public partial class SplitGrid : JSStyledComponentBase
"initializeSplitGrid",
Element,
_gutterElement,
- GutterOrientation == Orientation.Vertical,
+ GutterOrientation == UIOrientation.Vertical,
MinimumCellSize);
}
}
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor b/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor
index e9dc7c868..284b9aaa6 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor
@@ -2,20 +2,23 @@
@inherits StyledComponentBase
-<Container HorizontalAlignment="@HorizontalAlignment"
- VerticalAlignment="@VerticalAlignment"
- Width="@Width"
- Height="@Height"
- MarginLeft="@MarginLeft"
- MarginRight="@MarginRight"
- MarginTop="@MarginTop"
- MarginBottom="@MarginBottom"
- PaddingLeft="@PaddingLeft"
- PaddingRight="@PaddingRight"
- PaddingTop="@PaddingTop"
- PaddingBottom="@PaddingBottom"
- IsVisible="@IsVisible">
- <div id="@Id" @ref="@Element" class="@ClassValue" style="@StyleValue" @attributes="AdditionalAttributes">
- @ChildContent
- </div>
-</Container>
\ No newline at end of file
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ MarginLeft="@MarginLeft"
+ MarginRight="@MarginRight"
+ MarginTop="@MarginTop"
+ MarginBottom="@MarginBottom"
+ PaddingLeft="@PaddingLeft"
+ PaddingRight="@PaddingRight"
+ PaddingTop="@PaddingTop"
+ PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
+ IsVisible="@IsVisible">
+ <div id="@Id" @ref="@Element" class="@ClassValue" style="@StyleValue" @attributes="AdditionalAttributes">
+ @ChildContent
+ </div>
+ </Container>
+</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor.cs
index 356d7c6f8..45a46d630 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor.cs
@@ -3,8 +3,8 @@
public partial class StackPanel : StyledComponentBase
{
protected string? ClassValue => new CssBuilder(FinalCssClasses)
- .AddClass("stack-horizontal", () => Orientation == Orientation.Horizontal)
- .AddClass("stack-vertical", () => Orientation == Orientation.Vertical)
+ .AddClass("stack-horizontal", () => Orientation == UIOrientation.Horizontal)
+ .AddClass("stack-vertical", () => Orientation == UIOrientation.Vertical)
.Build();
protected string? StyleValue => new StyleBuilder()
@@ -18,7 +18,7 @@ public partial class StackPanel : StyledComponentBase
/// Gets or set the orientation of the stacked components.
/// </summary>
[Parameter]
- public Orientation Orientation { get; set; } = Orientation.Horizontal;
+ public UIOrientation Orientation { get; set; } = UIOrientation.Horizontal;
/// <summary>
/// Gets or sets if the stack wraps.
diff --git a/src/app/dev/DevToys.Blazor/Components/MefComponentBase.cs b/src/app/dev/DevToys.Blazor/Components/MefComponentBase.cs
index fe7c83549..d1891325b 100644
--- a/src/app/dev/DevToys.Blazor/Components/MefComponentBase.cs
+++ b/src/app/dev/DevToys.Blazor/Components/MefComponentBase.cs
@@ -1,6 +1,4 @@
-using DevToys.Api;
-
-namespace DevToys.Blazor.Components;
+namespace DevToys.Blazor.Components;
public abstract class MefComponentBase : JSStyledComponentBase
{
diff --git a/src/app/dev/DevToys.Blazor/Components/Menu/ContextMenu/ContextMenu.razor b/src/app/dev/DevToys.Blazor/Components/Menu/ContextMenu/ContextMenu.razor
index e9b58aeba..506365812 100644
--- a/src/app/dev/DevToys.Blazor/Components/Menu/ContextMenu/ContextMenu.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Menu/ContextMenu/ContextMenu.razor
@@ -5,11 +5,11 @@
<div id="@Id"
Class="context-menu @(FinalCssClasses)"
Style="@Style"
-@attributes="AdditionalAttributes"
-@oncontextmenu:preventDefault="true">
+ @attributes="AdditionalAttributes"
+ @oncontextmenu:preventDefault="true">
<CascadingValue Value="this" IsFixed="true">
<div @oncontextmenu="@ToggleMenuAsync"
- disabled="@(!IsEnabled)"
+ disabled="@(!IsActuallyEnabled)"
class="context-menu-activator">
@ChildContent
</div>
diff --git a/src/app/dev/DevToys.Blazor/Components/Menu/ContextMenu/ContextMenu.razor.cs b/src/app/dev/DevToys.Blazor/Components/Menu/ContextMenu/ContextMenu.razor.cs
index 1af5c535c..d8be2df31 100644
--- a/src/app/dev/DevToys.Blazor/Components/Menu/ContextMenu/ContextMenu.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Menu/ContextMenu/ContextMenu.razor.cs
@@ -1,5 +1,4 @@
-using DevToys.Api;
-using DevToys.Blazor.Core.Services;
+using DevToys.Blazor.Core.Services;
using Microsoft.AspNetCore.Components.Web;
namespace DevToys.Blazor.Components;
@@ -64,7 +63,7 @@ public partial class ContextMenu : StyledComponentBase
private async Task OpenMenuAsync(MouseEventArgs ev)
{
- if (IsEnabled)
+ if (IsActuallyEnabled)
{
// This may update the item list.
await OnContextMenuOpening.InvokeAsync();
diff --git a/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBar.razor b/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBar.razor
index ba060b05b..cd91a2d6f 100644
--- a/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBar.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBar.razor
@@ -6,7 +6,7 @@
@typeparam TElement
@typeparam TSearchElement
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<div id=@Id
class="nav-bar-root @(_sidebarState.NavBarClassNames) @(FinalCssClasses)"
style="@(Style)"
@@ -15,8 +15,8 @@
<!-- Header -->
<div class="nav-bar-header">
- <StackPanel Orientation="Orientation.Horizontal"
- HorizontalAlignment="HorizontalAlignment.Left">
+ <StackPanel Orientation="UIOrientation.Horizontal"
+ HorizontalAlignment="UIHorizontalAlignment.Left">
<Button Appearance="ButtonAppearance.Stealth"
Class="nav-bar-button-icon"
Height="36"
@@ -57,11 +57,11 @@
<!-- Sidebar -->
<nav id="@NavId" class="@(_sidebarState.NavBarClassNames)">
<StackPanel Class="sidebar-header"
- Orientation="Orientation.Vertical">
+ Orientation="UIOrientation.Vertical">
@* TODO: Localize *@
<Button Appearance="ButtonAppearance.Stealth"
Class="nav-bar-button-icon"
- HorizontalAlignment="HorizontalAlignment.Left"
+ HorizontalAlignment="UIHorizontalAlignment.Left"
Height="36"
Width="40"
MarginTop="0"
@@ -79,7 +79,7 @@
<Button Appearance="ButtonAppearance.Stealth"
Class="nav-bar-button-icon"
- HorizontalAlignment="HorizontalAlignment.Left"
+ HorizontalAlignment="UIHorizontalAlignment.Left"
Height="36"
Width="40"
MarginTop="6"
@@ -106,7 +106,7 @@
</AutoSuggestBox>
</StackPanel>
<div class="sidebar-body">
- <ScrollViewer Orientation="Orientation.Vertical">
+ <ScrollViewer Orientation="UIOrientation.Vertical">
<ul class="sidebar-items" role="listbox">
@if (MenuItemsSource is not null)
{
diff --git a/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBarItem.razor b/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBarItem.razor
index f7371e9dd..7b6ccb12c 100644
--- a/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBarItem.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBarItem.razor
@@ -5,7 +5,7 @@
@typeparam TElement
@typeparam TSearchElement
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
@if (Item is ISeparator)
{
<li id="@Id" class="sidebar-item-separator"></li>
@@ -32,7 +32,7 @@
<div @onclick:stopPropagation="true">
<Button Appearance="ButtonAppearance.Stealth"
Class="sidebar-expand-group-button"
- HorizontalAlignment="HorizontalAlignment.Right"
+ HorizontalAlignment="UIHorizontalAlignment.Right"
Width="32"
aria-expanded="@(IsExpanded.ToString().ToLowerInvariant())"
data-expanded="@(IsExpanded.ToString().ToLowerInvariant())"
diff --git a/src/app/dev/DevToys.Blazor/Components/Orientation.cs b/src/app/dev/DevToys.Blazor/Components/Orientation.cs
deleted file mode 100644
index eb57c10ae..000000000
--- a/src/app/dev/DevToys.Blazor/Components/Orientation.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace DevToys.Blazor.Components;
-
-[Flags]
-public enum Orientation
-{
- Horizontal,
- Vertical
-}
diff --git a/src/app/dev/DevToys.Blazor/Components/StyledComponentBase.cs b/src/app/dev/DevToys.Blazor/Components/StyledComponentBase.cs
index d243c3432..e4060e863 100644
--- a/src/app/dev/DevToys.Blazor/Components/StyledComponentBase.cs
+++ b/src/app/dev/DevToys.Blazor/Components/StyledComponentBase.cs
@@ -1,12 +1,12 @@
-using DevToys.Api;
-
-namespace DevToys.Blazor.Components;
+namespace DevToys.Blazor.Components;
public abstract class StyledComponentBase : ComponentBase
{
private static readonly Random random = new();
private readonly Lazy<ObservableHashSet<string>> _css;
+ private bool _isEnabled = true;
+ private bool _parentIsEnabled = true;
/// <summary>
/// Gets a reference to the HTML element rendered by the component.
@@ -43,17 +43,28 @@ public abstract class StyledComponentBase : ComponentBase
[Parameter]
public bool IsEnabled { get; set; } = true;
+ /// <summary>
+ /// Gets or sets whether the parent component is enabled or not.
+ /// </summary>
+ [CascadingParameter(Name = nameof(ParentIsEnabled))]
+ protected bool ParentIsEnabled { get; set; } = true;
+
+ /// <summary>
+ /// Gets whether the component is actually enabled or not, based on <see cref="IsEnabled"/> and <see cref="ParentIsEnabled"/>.
+ /// </summary>
+ public bool IsActuallyEnabled => IsEnabled && ParentIsEnabled;
+
/// <summary>
/// Gets or sets how the component should horizontally align.
/// </summary>
[Parameter]
- public HorizontalAlignment HorizontalAlignment { get; set; } = HorizontalAlignment.Stretch;
+ public UIHorizontalAlignment HorizontalAlignment { get; set; } = UIHorizontalAlignment.Stretch;
/// <summary>
/// Gets or sets how the component should vertically align.
/// </summary>
[Parameter]
- public VerticalAlignment VerticalAlignment { get; set; } = VerticalAlignment.Stretch;
+ public UIVerticalAlignment VerticalAlignment { get; set; } = UIVerticalAlignment.Stretch;
/// <summary>
/// Gets or sets the width the component should have.
diff --git a/src/app/dev/DevToys.Blazor/Components/Text/AutoSuggestBox/AutoSuggestBox.razor b/src/app/dev/DevToys.Blazor/Components/Text/AutoSuggestBox/AutoSuggestBox.razor
index 314e019aa..437aa374c 100644
--- a/src/app/dev/DevToys.Blazor/Components/Text/AutoSuggestBox/AutoSuggestBox.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Text/AutoSuggestBox/AutoSuggestBox.razor
@@ -2,58 +2,61 @@
@inherits StyledComponentBase
@typeparam TElement
-<CascadingValue Value="this" IsFixed="true">
- <Container HorizontalAlignment="@HorizontalAlignment"
- VerticalAlignment="@VerticalAlignment"
- Width="@Width"
- Height="@Height"
- MarginLeft="@MarginLeft"
- MarginRight="@MarginRight"
- MarginTop="@MarginTop"
- MarginBottom="@MarginBottom"
- PaddingLeft="@PaddingLeft"
- PaddingRight="@PaddingRight"
- PaddingTop="@PaddingTop"
- PaddingBottom="@PaddingBottom"
- IsVisible="@IsVisible">
- <div id="@Id" style="@Style">
- <TextBox @ref="_textBox"
- Class="@(FinalCssClasses)"
- @attributes="AdditionalAttributes"
- Type="TextBoxTypes.Search"
- Header="@Header"
- Placeholder="@Placeholder"
- IsEnabled="@IsEnabled"
- IsReadOnly="@IsReadOnly"
- TextChanged="@OnTextBoxTextChangedAsync"
- @onkeydown="@OnTextBoxKeyPress"
- @onfocusout="@OnTextBoxFocusLost">
- <Buttons>
- <FontIcon Glyph="@('\uF68F')"
- HorizontalAlignment="HorizontalAlignment.Right"
- Style="margin-right: 12px; margin-left: 6px;" />
- </Buttons>
- </TextBox>
-
- <Popover Open="_showDropDown"
- AnchorOrigin="Origin.BottomLeft"
- TransformOrigin="Origin.TopLeft"
- RelativeWidth="true"
- Class="auto-suggest-box-drop-down"
- @ontouchend:stopPropagation>
- <CascadingValue Value="@this" IsFixed="true">
- <ListBox @ref="_resultListBox"
- Items="@Items"
- Context="item"
- RaiseSelectionEventOnKeyboardNavigation="false"
- UseNativeScrollBar="true"
- SelectedIndexChanged="OnSelectedIndexChanged">
- <ItemTemplate>
- @ItemTemplate(item)
- </ItemTemplate>
- </ListBox>
- </CascadingValue>
- </Popover>
- </div>
- </Container>
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
+ <CascadingValue Value="this" IsFixed="true">
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ MarginLeft="@MarginLeft"
+ MarginRight="@MarginRight"
+ MarginTop="@MarginTop"
+ MarginBottom="@MarginBottom"
+ PaddingLeft="@PaddingLeft"
+ PaddingRight="@PaddingRight"
+ PaddingTop="@PaddingTop"
+ PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
+ IsVisible="@IsVisible">
+ <div id="@Id" style="@Style">
+ <TextBox @ref="_textBox"
+ Class="@(FinalCssClasses)"
+ @attributes="AdditionalAttributes"
+ Type="TextBoxTypes.Search"
+ Header="@Header"
+ Placeholder="@Placeholder"
+ IsEnabled="@IsActuallyEnabled"
+ IsReadOnly="@IsReadOnly"
+ TextChanged="@OnTextBoxTextChangedAsync"
+ @onkeydown="@OnTextBoxKeyPress"
+ @onfocusout="@OnTextBoxFocusLost">
+ <Buttons>
+ <FontIcon Glyph="@('\uF68F')"
+ HorizontalAlignment="UIHorizontalAlignment.Right"
+ Style="margin-right: 12px; margin-left: 6px;" />
+ </Buttons>
+ </TextBox>
+
+ <Popover Open="_showDropDown"
+ AnchorOrigin="Origin.BottomLeft"
+ TransformOrigin="Origin.TopLeft"
+ RelativeWidth="true"
+ Class="auto-suggest-box-drop-down"
+ @ontouchend:stopPropagation>
+ <CascadingValue Value="@this" IsFixed="true">
+ <ListBox @ref="_resultListBox"
+ Items="@Items"
+ Context="item"
+ RaiseSelectionEventOnKeyboardNavigation="false"
+ UseNativeScrollBar="true"
+ SelectedIndexChanged="OnSelectedIndexChanged">
+ <ItemTemplate>
+ @ItemTemplate(item)
+ </ItemTemplate>
+ </ListBox>
+ </CascadingValue>
+ </Popover>
+ </div>
+ </Container>
+ </CascadingValue>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Text/AutoSuggestBox/AutoSuggestBox.razor.cs b/src/app/dev/DevToys.Blazor/Components/Text/AutoSuggestBox/AutoSuggestBox.razor.cs
index 090884d7b..2ee3bfafc 100644
--- a/src/app/dev/DevToys.Blazor/Components/Text/AutoSuggestBox/AutoSuggestBox.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Text/AutoSuggestBox/AutoSuggestBox.razor.cs
@@ -54,7 +54,7 @@ public partial class AutoSuggestBox<TElement> : StyledComponentBase, IDisposable
private void OnItemsChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
Guard.IsNotNull(Items);
- _showDropDown = IsEnabled && !IsReadOnly && Items.Count > 0;
+ _showDropDown = IsActuallyEnabled && !IsReadOnly && Items.Count > 0;
}
private Task OnTextBoxTextChangedAsync(string text)
diff --git a/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor b/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor
index 8747080c7..62a44608b 100644
--- a/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor
@@ -1,7 +1,7 @@
@namespace DevToys.Blazor.Components
@inherits RicherMonacoEditorBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -14,6 +14,7 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
<div id="@(Id)-monaco-container"
class="monaco-editor-standalone-with-header @(FinalCssClasses)"
@@ -25,7 +26,7 @@
<TextBlock Appearance="TextBlockAppearance.Body" Class="monaco-editor-standalone-header" Text="@Header" />
}
- <div class="monaco-editor-standalone-container @(IsEnabled ? string.Empty : "disabled")"
+ <div class="monaco-editor-standalone-container @(IsActuallyEnabled ? string.Empty : "disabled")"
@ref=Element>
<ProgressRing id="@($"{Id}-loading")"
diff --git a/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor.cs b/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor.cs
index e114409d9..21e97060f 100644
--- a/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor.cs
@@ -1,6 +1,5 @@
using System.Text.Json;
using System.Text.Json.Serialization;
-using DevToys.Api;
using DevToys.Blazor.Components.Monaco.Editor;
namespace DevToys.Blazor.Components;
diff --git a/src/app/dev/DevToys.Blazor/Components/Text/TextBlock/TextBlock.razor.cs b/src/app/dev/DevToys.Blazor/Components/Text/TextBlock/TextBlock.razor.cs
index 9329270d7..d4938a91e 100644
--- a/src/app/dev/DevToys.Blazor/Components/Text/TextBlock/TextBlock.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Text/TextBlock/TextBlock.razor.cs
@@ -1,5 +1,4 @@
-using DevToys.Api;
-using Microsoft.AspNetCore.Components.Rendering;
+using Microsoft.AspNetCore.Components.Rendering;
namespace DevToys.Blazor.Components;
diff --git a/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor b/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor
index 5b95cbe03..c329bf199 100644
--- a/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor
@@ -1,7 +1,7 @@
@namespace DevToys.Blazor.Components
@inherits MefComponentBase
-<CascadingValue Value="this" IsFixed="true">
+<CascadingValue Name="ParentIsEnabled" Value="@IsActuallyEnabled">
<Container HorizontalAlignment="@HorizontalAlignment"
VerticalAlignment="@VerticalAlignment"
Width="@Width"
@@ -14,6 +14,7 @@
PaddingRight="@PaddingRight"
PaddingTop="@PaddingTop"
PaddingBottom="@PaddingBottom"
+ IsEnabled="@IsActuallyEnabled"
IsVisible="@IsVisible">
<div id=@Id
class="text-box-with-header @(FinalCssClasses)"
@@ -25,18 +26,18 @@
<TextBlock Appearance="TextBlockAppearance.Body" Class="text-box-header" Text="@Header" />
}
- <div class="text-box-container @(IsEnabled ? string.Empty : "disabled") @(_isContextMenuOpened ? "is-context-menu-opened" : string.Empty)"
+ <div class="text-box-container @(IsActuallyEnabled ? string.Empty : "disabled") @(_isContextMenuOpened ? "is-context-menu-opened" : string.Empty)"
@ref=Element>
- <ContextMenu IsEnabled="IsEnabled"
+ <ContextMenu IsEnabled="IsActuallyEnabled"
OnContextMenuOpening="OnContextMenuOpening"
OnContextMenuOpened="OnContextMenuOpened"
OnContextMenuClosed="OnContextMenuClosedAsync"
Items="_contextMenuItems">
<InputText @ref="_input"
- class="@($"text-box {(IsEnabled ? string.Empty : "disabled")})")"
+ class="@($"text-box {(IsActuallyEnabled ? string.Empty : "disabled")})")"
placeholder="@Placeholder"
- disabled="@(!IsEnabled)"
+ disabled="@(!IsActuallyEnabled)"
readonly="@(IsReadOnly)"
type="@(Type.ToString().ToLowerInvariant())"
min="@Min"
@@ -48,13 +49,13 @@
<div class="text-box-underline" />
<div class="text-box-buttons">
- @if (IsEnabled && !IsReadOnly)
+ @if (IsActuallyEnabled && !IsReadOnly)
{
if (!string.IsNullOrEmpty(Text))
{
<Button Appearance="ButtonAppearance.Stealth"
Class="text-box-clear-button"
- HorizontalAlignment="HorizontalAlignment.Right"
+ HorizontalAlignment="UIHorizontalAlignment.Right"
title="Clear"
aria-label="Clear"
@onclick="OnClearClick">
@@ -65,14 +66,14 @@
if (Type == TextBoxTypes.Number)
{
<Button Appearance="ButtonAppearance.Stealth"
- HorizontalAlignment="HorizontalAlignment.Right"
+ HorizontalAlignment="UIHorizontalAlignment.Right"
title="Increase"
aria-label="Increase"
@onclick="OnIncreaseClickAsync">
<FontIcon Glyph="@('\uF2B6')" />
</Button>
<Button Appearance="ButtonAppearance.Stealth"
- HorizontalAlignment="HorizontalAlignment.Right"
+ HorizontalAlignment="UIHorizontalAlignment.Right"
title="Decrease"
aria-label="Decrease"
@onclick="OnDecreaseClickAsync">
diff --git a/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor.cs b/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor.cs
index 714a2c93b..ce48a64ee 100644
--- a/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor.cs
@@ -1,5 +1,4 @@
using System.Collections.ObjectModel;
-using DevToys.Api;
using Microsoft.AspNetCore.Components.Forms;
namespace DevToys.Blazor.Components;
diff --git a/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor.scss b/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor.scss
index a3835586f..cce13455b 100644
--- a/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor.scss
@@ -16,6 +16,7 @@
background-color: transparent;
&::placeholder {
+ @include typography-body;
user-select: none;
-webkit-user-select: none;
color: var(--text-box-placeholder-foreground);
diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIButtonPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UIButtonPresenter.razor
index d84862c47..83713af41 100644
--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIButtonPresenter.razor
+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIButtonPresenter.razor
@@ -2,14 +2,12 @@
@using DevToys.Api;
@inherits ComponentBase
-<CascadingValue Value="this" IsFixed="true">
- @if (UIButton is not null)
- {
- <Button IsVisible="@UIButton.IsVisible"
- IsEnabled="@UIButton.IsEnabled"
- Appearance="ButtonAppearance.Neutral"
- @onclick=OnButtonClickAsync>
- <TextBlock Text="@UIButton?.Text" />
- </Button>
- }
-</CascadingValue>
\ No newline at end of file
+<Button id="@UIButton.Id"
+ IsVisible="@UIButton.IsVisible"
+ IsEnabled="@UIButton.IsEnabled"
+ HorizontalAlignment="@UIButton.HorizontalAlignment"
+ VerticalAlignment="@UIButton.VerticalAlignment"
+ Appearance="@((UIButton.IsAccent ? ButtonAppearance.Accent : ButtonAppearance.Neutral))"
+ @onclick=OnButtonClickAsync>
+ <TextBlock Text="@UIButton?.Text" />
+</Button>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIButtonPresenter.razor.cs b/src/app/dev/DevToys.Blazor/Components/UIElements/UIButtonPresenter.razor.cs
index d9b84a79b..4db2ac76d 100644
--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIButtonPresenter.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIButtonPresenter.razor.cs
@@ -1,11 +1,9 @@
-using DevToys.Api;
-
-namespace DevToys.Blazor.Components.UIElements;
+namespace DevToys.Blazor.Components.UIElements;
public partial class UIButtonPresenter : ComponentBase
{
[Parameter]
- public IUIButton? UIButton { get; set; }
+ public IUIButton UIButton { get; set; } = default!;
internal async Task OnButtonClickAsync()
{
diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIElementPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UIElementPresenter.razor
index d088e697f..70420667d 100644
--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIElementPresenter.razor
+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIElementPresenter.razor
@@ -2,21 +2,19 @@
@using DevToys.Api;
@inherits ComponentBase
-<CascadingValue Value="this" IsFixed="true">
- @if (UIElement is not null)
+@if (UIElement is not null)
+{
+ switch (UIElement)
{
- switch (UIElement)
- {
- @*case IUIStack stack:
- <UIStackPresenter UIStack="@stack" />
- break;*@
+ case IUIStack stack:
+ <UIStackPresenter UIStack="@stack" />
+ break;
- case IUIButton button:
- <UIButtonPresenter UIButton="@button" />
- break;
+ case IUIButton button:
+ <UIButtonPresenter UIButton="@button" />
+ break;
- default:
- throw new NotSupportedException($"Gui Tool component of type '{UIElement.GetType().FullName}' isn't supported.");
- }
+ default:
+ throw new NotSupportedException($"Gui Tool component of type '{UIElement.GetType().FullName}' isn't supported.");
}
-</CascadingValue>
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIElementPresenter.razor.cs b/src/app/dev/DevToys.Blazor/Components/UIElements/UIElementPresenter.razor.cs
index 3ab8c3395..514448a25 100644
--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIElementPresenter.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIElementPresenter.razor.cs
@@ -1,9 +1,30 @@
-using DevToys.Api;
+namespace DevToys.Blazor.Components.UIElements;
-namespace DevToys.Blazor.Components.UIElements;
-
-public partial class UIElementPresenter : ComponentBase
+public partial class UIElementPresenter : ComponentBase, IDisposable
{
[Parameter]
- public IUIElement? UIElement { get; set; }
+ public IUIElement UIElement { get; set; } = default!;
+
+ protected override void OnInitialized()
+ {
+ base.OnInitialized();
+ Guard.IsAssignableToType<INotifyPropertyChanged>(UIElement);
+ ((INotifyPropertyChanged)UIElement).PropertyChanged += UIElementPresenter_PropertyChanged;
+ }
+
+ private void UIElementPresenter_PropertyChanged(object? sender, PropertyChangedEventArgs e)
+ {
+ // When a IUIElement such as a Button handles a click, the action may change properties of the Button in question, or other
+ // element around (Stack, List, other Buttons...etc). When it does so, Blazor is smart enough to re-evaluate bindings
+ // of the current Button being clicked, but due to optimization, it doesn't re-evaluate other elements that may have changed.
+ // As a workaround, we here listen to UIElement.PropertyChanged to be notified when a property of the IUIElement has changed so
+ // we can let Blazor know that we should re-render this element.
+ StateHasChanged();
+ }
+
+ public void Dispose()
+ {
+ Guard.IsAssignableToType<INotifyPropertyChanged>(UIElement);
+ ((INotifyPropertyChanged)UIElement).PropertyChanged -= UIElementPresenter_PropertyChanged;
+ }
}
diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIStackPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UIStackPresenter.razor
new file mode 100644
index 000000000..a6119eff4
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIStackPresenter.razor
@@ -0,0 +1,18 @@
+@namespace DevToys.Blazor.Components.UIElements
+@using DevToys.Api;
+@inherits ComponentBase
+
+<StackPanel id="@UIStack.Id"
+ IsVisible="@UIStack.IsVisible"
+ IsEnabled="@UIStack.IsEnabled"
+ HorizontalAlignment="@UIStack.HorizontalAlignment"
+ VerticalAlignment="@UIStack.VerticalAlignment"
+ Orientation="@UIStack.Orientation">
+ @if (UIStack.Children is not null)
+ {
+ for (int i = 0; i < UIStack.Children.Length; i++)
+ {
+ <UIElementPresenter UIElement="@UIStack.Children[i]"/>
+ }
+ }
+</StackPanel>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIStackPresenter.razor.cs b/src/app/dev/DevToys.Blazor/Components/UIElements/UIStackPresenter.razor.cs
new file mode 100644
index 000000000..8baeba945
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIStackPresenter.razor.cs
@@ -0,0 +1,7 @@
+namespace DevToys.Blazor.Components.UIElements;
+
+public partial class UIStackPresenter : ComponentBase
+{
+ [Parameter]
+ public IUIStack UIStack { get; set; } = default!;
+}
diff --git a/src/app/dev/DevToys.Blazor/Components/VerticalAlignment.cs b/src/app/dev/DevToys.Blazor/Components/VerticalAlignment.cs
deleted file mode 100644
index a279687f4..000000000
--- a/src/app/dev/DevToys.Blazor/Components/VerticalAlignment.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace DevToys.Blazor.Components;
-
-public enum VerticalAlignment
-{
- Stretch,
- Top,
- Bottom,
- Center
-}
diff --git a/src/app/dev/DevToys.Blazor/Core/Services/PopoverHandler.cs b/src/app/dev/DevToys.Blazor/Core/Services/PopoverHandler.cs
index 43c4ad7d2..865e55758 100644
--- a/src/app/dev/DevToys.Blazor/Core/Services/PopoverHandler.cs
+++ b/src/app/dev/DevToys.Blazor/Core/Services/PopoverHandler.cs
@@ -1,5 +1,4 @@
-using DevToys.Api;
-using DevToys.Blazor.Components;
+using DevToys.Blazor.Components;
namespace DevToys.Blazor.Core.Services;
diff --git a/src/app/dev/DevToys.Blazor/Core/Services/PopoverService.cs b/src/app/dev/DevToys.Blazor/Core/Services/PopoverService.cs
index 952dd9342..d11063128 100644
--- a/src/app/dev/DevToys.Blazor/Core/Services/PopoverService.cs
+++ b/src/app/dev/DevToys.Blazor/Core/Services/PopoverService.cs
@@ -1,6 +1,4 @@
-using DevToys.Api;
-
-namespace DevToys.Blazor.Core.Services;
+namespace DevToys.Blazor.Core.Services;
public sealed class PopoverService : IAsyncDisposable
{
diff --git a/src/app/dev/DevToys.Blazor/Pages/Index.razor.cs b/src/app/dev/DevToys.Blazor/Pages/Index.razor.cs
index 5f07735cc..e8ddbaca5 100644
--- a/src/app/dev/DevToys.Blazor/Pages/Index.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Pages/Index.razor.cs
@@ -1,5 +1,4 @@
-using DevToys.Api;
-using DevToys.Blazor.Components;
+using DevToys.Blazor.Components;
using DevToys.Blazor.Core.Services;
using DevToys.Business.ViewModels;
using DevToys.Core;
diff --git a/src/app/dev/DevToys.Blazor/Pages/MainLayout.razor.cs b/src/app/dev/DevToys.Blazor/Pages/MainLayout.razor.cs
index 538f3e9d5..a28fd63f1 100644
--- a/src/app/dev/DevToys.Blazor/Pages/MainLayout.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Pages/MainLayout.razor.cs
@@ -1,6 +1,4 @@
-using DevToys.Api;
-
-namespace DevToys.Blazor.Pages;
+namespace DevToys.Blazor.Pages;
public partial class MainLayout : LayoutComponentBase
{
diff --git a/src/app/dev/DevToys.Blazor/Pages/SubPages/TestPage.razor b/src/app/dev/DevToys.Blazor/Pages/SubPages/TestPage.razor
index 0c17b3f6a..222465b92 100644
--- a/src/app/dev/DevToys.Blazor/Pages/SubPages/TestPage.razor
+++ b/src/app/dev/DevToys.Blazor/Pages/SubPages/TestPage.razor
@@ -3,7 +3,7 @@
<CascadingValue Value="this" IsFixed="true">
<ScrollViewer>
<StackPanel Class="entrance-theme-transition"
- Orientation="Orientation.Vertical"
+ Orientation="UIOrientation.Vertical"
PaddingLeft="16"
PaddingBottom="16"
PaddingRight="16"
@@ -18,7 +18,7 @@
})">
<GridCell Column="0">
- <StackPanel Orientation="Orientation.Vertical">
+ <StackPanel Orientation="UIOrientation.Vertical">
<ProgressRing IsIndeterminate="true" />
<ProgressRing Value="75" Size="32" />
<CheckBox IsChecked="true" Text="An option" />
@@ -39,26 +39,26 @@
<GridCell Column="1" ColumnSpan="2">
<SplitGrid>
<LeftOrTopCellContent>
- <StackPanel Orientation="Orientation.Vertical">
+ <StackPanel Orientation="UIOrientation.Vertical">
<TextBlock Appearance="TextBlockAppearance.TitleLarge" Text="Test" />
<MonacoEditor />
- <Button VerticalAlignment="VerticalAlignment.Center" IsEnabled="true">Set favorite</Button>
- <Button HorizontalAlignment="HorizontalAlignment.Left" IsEnabled="false">Set favorite</Button>
- <Button HorizontalAlignment="HorizontalAlignment.Center" IsEnabled="true" Appearance="ButtonAppearance.Accent">Set favorite</Button>
- <Button HorizontalAlignment="HorizontalAlignment.Right" Height="100" Width="200" IsEnabled="false" Appearance="ButtonAppearance.Accent">Set favorite</Button>
+ <Button VerticalAlignment="UIVerticalAlignment.Center" IsEnabled="true">Set favorite</Button>
+ <Button HorizontalAlignment="UIHorizontalAlignment.Left" IsEnabled="false">Set favorite</Button>
+ <Button HorizontalAlignment="UIHorizontalAlignment.Center" IsEnabled="true" Appearance="ButtonAppearance.Accent">Set favorite</Button>
+ <Button HorizontalAlignment="UIHorizontalAlignment.Right" Height="100" Width="200" IsEnabled="false" Appearance="ButtonAppearance.Accent">Set favorite</Button>
<Button IsEnabled="true" Appearance="ButtonAppearance.Stealth">Set favorite</Button>
- <Button VerticalAlignment="VerticalAlignment.Bottom" IsEnabled="false" Appearance="ButtonAppearance.Stealth">Set favorite</Button>
+ <Button VerticalAlignment="UIVerticalAlignment.Bottom" IsEnabled="false" Appearance="ButtonAppearance.Stealth">Set favorite</Button>
<TextBox Header="First name" Placeholder="Normal" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
<TextBox Header="Middle name" Placeholder="Read only" IsReadOnly="true" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
<TextBox Header="Last name" Placeholder="Disabled" IsEnabled="false" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
<TextBox Header="Number input" Type="TextBoxTypes.Number" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
<TextBox Header="Password input" Type="TextBoxTypes.Password" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
- <ProgressBar IsIndeterminate="true" Width="150" HorizontalAlignment="HorizontalAlignment.Left" />
+ <ProgressBar IsIndeterminate="true" Width="150" HorizontalAlignment="UIHorizontalAlignment.Left" />
<ProgressBar Value="75" />
</StackPanel>
</LeftOrTopCellContent>
<RightOrBottomCellContent>
- <StackPanel Orientation="Orientation.Vertical">
+ <StackPanel Orientation="UIOrientation.Vertical">
<DropDownList Header="Drop down list header"
Items="@(new List<DropDownListItem>
{
diff --git a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razor b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razor
index a450e80d3..dbcae5f06 100644
--- a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razor
+++ b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razor
@@ -27,7 +27,7 @@
<TextBlock Appearance="@TextBlockAppearance.Caption" Text="@item.Description" />
</div>
<div class="buttons" @onclick:stopPropagation="true">
- <Button HorizontalAlignment="HorizontalAlignment.Right"
+ <Button HorizontalAlignment="UIHorizontalAlignment.Right"
Class="button"
Appearance="@ButtonAppearance.Neutral"
@onclick="() => OnOpenInNewWindow(item)">
diff --git a/src/app/dev/DevToys.Blazor/Properties/AdditionGlobalUsings.cs b/src/app/dev/DevToys.Blazor/Properties/AdditionGlobalUsings.cs
index 2e3736b5f..8f1d1079b 100644
--- a/src/app/dev/DevToys.Blazor/Properties/AdditionGlobalUsings.cs
+++ b/src/app/dev/DevToys.Blazor/Properties/AdditionGlobalUsings.cs
@@ -3,5 +3,6 @@
global using Microsoft.AspNetCore.Components;
global using Microsoft.JSInterop;
+global using DevToys.Api;
global using DevToys.Blazor.Core.Helpers;
global using DevToys.Blazor.Core.Extensions;
diff --git a/src/app/dev/DevToys.Business/ViewModels/MainWindowViewModel.cs b/src/app/dev/DevToys.Business/ViewModels/MainWindowViewModel.cs
index c8c422447..3e9a0523a 100644
--- a/src/app/dev/DevToys.Business/ViewModels/MainWindowViewModel.cs
+++ b/src/app/dev/DevToys.Business/ViewModels/MainWindowViewModel.cs
@@ -3,7 +3,6 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using DevToys.Api;
-using DevToys.Business.Models;
using DevToys.Core.Models;
using DevToys.Core.Tools;
using DevToys.Core.Tools.ViewItems;
diff --git a/src/app/dev/DevToys.Core/Tools/GuiToolProvider.cs b/src/app/dev/DevToys.Core/Tools/GuiToolProvider.cs
index 005776477..33e863df5 100644
--- a/src/app/dev/DevToys.Core/Tools/GuiToolProvider.cs
+++ b/src/app/dev/DevToys.Core/Tools/GuiToolProvider.cs
@@ -1,6 +1,5 @@
using System.Collections.ObjectModel;
using System.Reflection;
-using System.Text.RegularExpressions;
using DevToys.Api;
using DevToys.Core.Tools.Metadata;
using DevToys.Core.Tools.ViewItems;
diff --git a/src/app/dev/DevToys.Tools/Tools/Sample/SampleToolFactory.cs b/src/app/dev/DevToys.Tools/Tools/Sample/SampleToolFactory.cs
index 604911f9e..15f8b0c82 100644
--- a/src/app/dev/DevToys.Tools/Tools/Sample/SampleToolFactory.cs
+++ b/src/app/dev/DevToys.Tools/Tools/Sample/SampleToolFactory.cs
@@ -1,4 +1,5 @@
-using Microsoft.Extensions.Logging;
+using DevToys.Api;
+using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
namespace DevToys.Tools.Tools.Sample;
@@ -52,10 +53,52 @@ internal sealed class SampleCommandLineTool : ICommandLineTool
internal sealed class SampleGuiTool : IGuiTool
{
//private readonly IUIMultilineLineTextInput _editor = MultilineTextInput().Language("json").CanCopyWhenEditable();
-
- public IUIElement View => Button().Text("Hello !");
+ private readonly IUIButton _button = Button();
+ private readonly IUIButton _button2 = Button();
+ private readonly IUIButton _button3 = Button();
+ private readonly IUIButton _button4 = Button();
+ private readonly IUIButton _button5 = Button();
+ private readonly IUIButton _button6 = Button();
+ private readonly IUIButton _button7 = Button();
+ private readonly IUIButton _button8 = Button();
+ private readonly IUIButton _button9 = Button();
+ private readonly IUIButton _button10 = Button();
+ private readonly IUIButton _button11 = Button();
+ private readonly IUIButton _button12 = Button();
+ private 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;
+ private ValueTask OnClick()
+ {
+ _button.Text("Done !");
+ //_button.AccentAppearance();
+ _mainStack.Disable();
+ //_button.Hide();
+ return ValueTask.CompletedTask;
+ }
+
public void OnDataReceived(string dataTypeName, object? parsedData)
{
if (dataTypeName == PredefinedCommonDataTypeNames.Json && parsedData is Tuple<JToken, string> strongTypedParsedData)
diff --git a/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs b/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs
index e66692674..7a17951fb 100644
--- a/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs
+++ b/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs
@@ -47,50 +47,50 @@ internal sealed class SettingsGuiTool : IGuiTool
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())),
- Stack()
- .Horizontal()
- .WithChildren(
- _topLeftButton,
- Button().Text("Top Center button"),
- Button().Text("Top Right button")),
- Stack()
- .Horizontal()
- .Disable()
- .WithChildren(
- Button().Text("Bottom Left button"),
- Button().Text("Bottom Center button").OnClick(OnBottomCenterButtonClickAsync),
- Button().Text("Bottom Right button")),
- SingleLineTextInput().CanCopyWhenEditable());
+ .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())),
+ Stack()
+ .Horizontal()
+ .WithChildren(
+ _topLeftButton,
+ Button().Text("Top Center button"),
+ Button().Text("Top Right button")),
+ Stack()
+ .Horizontal()
+ .Disable()
+ .WithChildren(
+ Button().Text("Bottom Left button"),
+ Button().Text("Bottom Center button").OnClick(OnBottomCenterButtonClickAsync),
+ Button().Text("Bottom Right button")),
+ SingleLineTextInput().CanCopyWhenEditable());
public void OnDataReceived(string dataTypeName, object? parsedData)
{
diff --git a/src/app/dev/platforms/desktop/DevToys.Windows/MainWindow.xaml.cs b/src/app/dev/platforms/desktop/DevToys.Windows/MainWindow.xaml.cs
index 73e74d193..74fdc8637 100644
--- a/src/app/dev/platforms/desktop/DevToys.Windows/MainWindow.xaml.cs
+++ b/src/app/dev/platforms/desktop/DevToys.Windows/MainWindow.xaml.cs
@@ -8,7 +8,6 @@ using DevToys.Core.Mef;
using DevToys.Windows.Controls;
using DevToys.Windows.Core;
using Microsoft.AspNetCore.Components.WebView;
-using Microsoft.AspNetCore.Components.WebView.Wpf;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using PredefinedSettings = DevToys.Core.Settings.PredefinedSettings;