A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Added IUIGrid
Etienne Baudoux9952abafe2f1
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIGrid.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIGrid.csnew file mode 100644index 000000000..8bf6bbd30--- /dev/null+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIGrid.cs@@ -0,0 +1,276 @@+using System.Globalization;++namespace DevToys.Api;++/// <summary>+/// A component provides a flexible grid area that consists of columns and rows.+/// Child elements of the Grid are measured and arranged according to their row/column assignments and other logic.+/// </summary>+public interface IUIGrid : IUIElement+{+ /// <summary>+ /// Gets a value that indicates the space between rows.+ /// Default is <see cref="UISpacing.Small"/>.+ /// </summary>+ UISpacing RowSpacing { get; }++ /// <summary>+ /// Gets a value that indicates the space between columns.+ /// Default is <see cref="UISpacing.Small"/>.+ /// </summary>+ UISpacing ColumnSpacing { get; }++ /// <summary>+ /// Gets the definition of the rows in the grid.+ /// Default is a row that takes the whole height.+ /// </summary>+ UIGridLength[]? Rows { get; }++ /// <summary>+ /// Gets the definition of the columns in the grid.+ /// Default is a column that takes the whole width.+ /// </summary>+ UIGridLength[]? Columns { get; }++ /// <summary>+ /// Gets the cells in the grid.+ /// </summary>+ IUIGridCell[]? Cells { get; }++ /// <summary>+ /// Raised when <see cref="RowSpacing"/> is changed.+ /// </summary>+ event EventHandler? RowSpacingChanged;++ /// <summary>+ /// Raised when <see cref="ColumnSpacing"/> is changed.+ /// </summary>+ event EventHandler? ColumnSpacingChanged;++ /// <summary>+ /// Raised when <see cref="Rows"/> is changed.+ /// </summary>+ event EventHandler? RowsChanged;++ /// <summary>+ /// Raised when <see cref="Columns"/> is changed.+ /// </summary>+ event EventHandler? ColumnsChanged;++ /// <summary>+ /// Raised when <see cref="Cells"/> is changed.+ /// </summary>+ event EventHandler? CellsChanged;+}++[DebuggerDisplay($"Id = {{{nameof(Id)}}}")]+internal sealed class UIGrid : UIElement, IUIGrid+{+ private UISpacing _rowSpacing = UISpacing.Small;+ private UISpacing _columnSpacing = UISpacing.Small;+ private UIGridLength[]? _rows;+ private UIGridLength[]? _columns;+ private IUIGridCell[]? _cells;++ internal UIGrid(string? id)+ : base(id)+ {+ }++ public UISpacing RowSpacing+ {+ get => _rowSpacing;+ internal set => SetPropertyValue(ref _rowSpacing, value, RowSpacingChanged);+ }++ public UISpacing ColumnSpacing+ {+ get => _columnSpacing;+ internal set => SetPropertyValue(ref _columnSpacing, value, ColumnSpacingChanged);+ }++ public UIGridLength[]? Rows+ {+ get => _rows;+ internal set => SetPropertyValue(ref _rows, value, RowsChanged);+ }++ public UIGridLength[]? Columns+ {+ get => _columns;+ internal set => SetPropertyValue(ref _columns, value, ColumnsChanged);+ }++ public IUIGridCell[]? Cells+ {+ get => _cells;+ internal set => SetPropertyValue(ref _cells, value, CellsChanged);+ }++ public event EventHandler? RowSpacingChanged;+ public event EventHandler? ColumnSpacingChanged;+ public event EventHandler? RowsChanged;+ public event EventHandler? ColumnsChanged;+ public event EventHandler? CellsChanged;+}++public static partial class GUI+{+ /// <summary>+ /// A grid length definition that automatically fits to its content.+ /// </summary>+ public static UIGridLength Auto => UIGridLength.Auto;++ /// <summary>+ /// A grid length definition that is sized as a weighted proportion of available space.+ /// </summary>+ public static UIGridLength Fraction(int value)+ {+ return new(value, UIGridUnitType.Fraction);+ }++ /// <summary>+ /// A component provides a flexible grid area that consists of columns and rows.+ /// Child elements of the Grid are measured and arranged according to their row/column assignments and other logic.+ /// </summary>+ public static IUIGrid Grid()+ {+ return Grid(null);+ }++ /// <summary>+ /// A component provides a flexible grid area that consists of columns and rows.+ /// Child elements of the Grid are measured and arranged according to their row/column assignments and other logic.+ /// </summary>+ /// <param name="id">An optional unique identifier for this UI element.</param>+ public static IUIGrid Grid(string? id)+ {+ return new UIGrid(id);+ }++ /// <summary>+ /// Sets the rows.+ /// </summary>+ public static IUIGrid Rows(this IUIGrid element, params UIGridLength[] heights)+ {+ ((UIGrid)element).Rows = heights;+ return element;+ }++ /// <summary>+ /// Sets the rows.+ /// </summary>+ public static IUIGrid Rows<TEnum>(this IUIGrid element, params (TEnum name, UIGridLength height)[] rows) where TEnum : Enum+ {+ var heights = new UIGridLength[rows.Length];++ for (int i = 0; i < rows.Length; i++)+ {+ if (i != Convert.ToInt32(rows[i].name, CultureInfo.InvariantCulture))+ {+ // TODO: Credit https://github.com/VincentH-Net/CSharpForMarkup+ throw new ArgumentException(+ $"Value of row name {rows[i].name} is not {i}. " ++ "Rows must be defined with enum names whose values form the sequence 0,1,2,..."+ );+ }++ heights[i] = rows[i].height;+ }+ return Rows(element, heights);+ }++ /// <summary>+ /// Sets the columns.+ /// </summary>+ public static IUIGrid Columns(this IUIGrid element, params UIGridLength[] widths)+ {+ ((UIGrid)element).Columns = widths;+ return element;+ }++ /// <summary>+ /// Sets the columns.+ /// </summary>+ public static IUIGrid Columns<TEnum>(this IUIGrid element, params (TEnum name, UIGridLength width)[] columns) where TEnum : Enum+ {+ var widths = new UIGridLength[columns.Length];++ for (int i = 0; i < columns.Length; i++)+ {+ if (i != Convert.ToInt32(columns[i].name, CultureInfo.InvariantCulture))+ {+ throw new ArgumentException(+ $"Value of column name {columns[i].name} is not {i}. " ++ "Columns must be defined with enum names whose values form the sequence 0,1,2,..."+ );+ }++ widths[i] = columns[i].width;+ }+ return Columns(element, widths);+ }++ /// <summary>+ /// Sets the cells in the grid.+ /// </summary>+ public static IUIGrid Cells(this IUIGrid element, params IUIGridCell[] cells)+ {+ ((UIGrid)element).Cells = cells;+ return element;+ }++ /// <summary>+ /// Sets a small spacing between rows.+ /// </summary>+ public static IUIGrid RowSmallSpacing(this IUIGrid element)+ {+ ((UIGrid)element).RowSpacing = UISpacing.Small;+ return element;+ }++ /// <summary>+ /// Sets a medium spacing between rows.+ /// </summary>+ public static IUIGrid RowMediumSpacing(this IUIGrid element)+ {+ ((UIGrid)element).RowSpacing = UISpacing.Medium;+ return element;+ }++ /// <summary>+ /// Sets a large spacing between rows.+ /// </summary>+ public static IUIGrid RowLargeSpacing(this IUIGrid element)+ {+ ((UIGrid)element).RowSpacing = UISpacing.Large;+ return element;+ }++ /// <summary>+ /// Sets a small spacing between columns.+ /// </summary>+ public static IUIGrid ColumnSmallSpacing(this IUIGrid element)+ {+ ((UIGrid)element).ColumnSpacing = UISpacing.Small;+ return element;+ }++ /// <summary>+ /// Sets a medium spacing between columns.+ /// </summary>+ public static IUIGrid ColumnMediumSpacing(this IUIGrid element)+ {+ ((UIGrid)element).ColumnSpacing = UISpacing.Medium;+ return element;+ }++ /// <summary>+ /// Sets a large spacing between columns.+ /// </summary>+ public static IUIGrid ColumnLargeSpacing(this IUIGrid element)+ {+ ((UIGrid)element).ColumnSpacing = UISpacing.Large;+ return element;+ }+}diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIGridCell.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIGridCell.csnew file mode 100644index 000000000..517f21724--- /dev/null+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIGridCell.cs@@ -0,0 +1,249 @@+using System.Globalization;+using System.Runtime.CompilerServices;++namespace DevToys.Api;++/// <summary>+/// A component hosted by a <see cref="IUIGrid"/> that represents a cell in a flexible grid.+/// </summary>+public interface IUIGridCell+{+ /// <summary>+ /// Gets the row alignment of the cell.+ /// </summary>+ int Row { get; }++ /// <summary>+ /// Gets the column alignment of the cell.+ /// </summary>+ int Column { get; }++ /// <summary>+ /// Gets a value that indicates the total number of rows that the cell content spans within the parent grid.+ /// </summary>+ int RowSpan { get; }++ /// <summary>+ /// Gets a value that indicates the total number of columns that the cell content spans within the parent grid.+ /// </summary>+ int ColumnSpan { get; }++ /// <summary>+ /// Gets the child element to display in the cell.+ /// </summary>+ IUIElement? Child { get; }++ /// <summary>+ /// Raised when <see cref="Row"/> is changed.+ /// </summary>+ event EventHandler? RowChanged;++ /// <summary>+ /// Raised when <see cref="Column"/> is changed.+ /// </summary>+ event EventHandler? ColumnChanged;++ /// <summary>+ /// Raised when <see cref="RowSpan"/> is changed.+ /// </summary>+ event EventHandler? RowSpanChanged;++ /// <summary>+ /// Raised when <see cref="ColumnSpan"/> is changed.+ /// </summary>+ event EventHandler? ColumnSpanChanged;++ /// <summary>+ /// Raised when <see cref="Child"/> is changed.+ /// </summary>+ event EventHandler? ChildChanged;+}++[DebuggerDisplay($"Row = {{{nameof(Row)}}}, Column = {{{nameof(Column)}}}, RowSpan = {{{nameof(RowSpan)}}}, ColumnSpan = {{{nameof(ColumnSpan)}}}")]+internal sealed class UIGridCell : IUIGridCell, INotifyPropertyChanged+{+ private int _row;+ private int _column;+ private int _rowSpan;+ private int _columnSpan;+ private IUIElement? _child;++ public int Row+ {+ get => _row;+ internal set => SetPropertyValue(ref _row, value, RowChanged);+ }++ public int Column+ {+ get => _column;+ internal set => SetPropertyValue(ref _column, value, ColumnChanged);+ }++ public int RowSpan+ {+ get => _rowSpan;+ internal set => SetPropertyValue(ref _rowSpan, value, RowSpanChanged);+ }++ public int ColumnSpan+ {+ get => _columnSpan;+ internal set => SetPropertyValue(ref _columnSpan, value, ColumnSpanChanged);+ }++ public IUIElement? Child+ {+ get => _child;+ internal set => SetPropertyValue(ref _child, value, ChildChanged);+ }++ public event EventHandler? RowChanged;+ public event EventHandler? ColumnChanged;+ public event EventHandler? RowSpanChanged;+ public event EventHandler? ColumnSpanChanged;+ public event EventHandler? ChildChanged;++ public event PropertyChangedEventHandler? PropertyChanged;++ private 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);+ }+ }++ private void OnPropertyChanged([CallerMemberName] string? propertyName = null)+ {+ PropertyChanged?.Invoke(this, new(propertyName));+ }+}++public static partial class GUI+{+ /// <summary>+ /// Create a component hosted by a <see cref="IUIGrid"/> that represents a cell in a flexible grid.+ /// </summary>+ public static IUIGridCell Cell()+ {+ return new UIGridCell();+ }++ /// <summary>+ /// Create a component hosted by a <see cref="IUIGrid"/> that represents a cell in a flexible grid.+ /// </summary>+ /// <param name="row">The row alignment of the cell.</param>+ /// <param name="column">The column alignment of the cell.</param>+ /// <param name="rowSpan">A value that indicates the total number of rows that the cell content spans within the parent grid.</param>+ /// <param name="columnSpan">A value that indicates the total number of columns that the cell content spans within the parent grid.</param>+ public static IUIGridCell Cell(int row, int column, int rowSpan, int columnSpan, IUIElement? child = null)+ {+ return new UIGridCell()+ .Row(row)+ .Column(column)+ .RowSpan(rowSpan)+ .ColumnSpan(columnSpan)+ .WithChild(child);+ }++ /// <summary>+ /// Create a component hosted by a <see cref="IUIGrid"/> that represents a cell in a flexible grid.+ /// </summary>+ /// <param name="row">The row where the cell should be placed.</param>+ /// <param name="column">The column where the cell should be placed.</param>+ public static IUIGridCell Cell<TRow, TColumn>(TRow row, TColumn column, IUIElement? child = null)+ where TRow : Enum+ where TColumn : Enum+ {+ int rowIndex = row.ToInt();+ int columnIndex = column.ToInt();++ return new UIGridCell()+ .Row(rowIndex)+ .Column(columnIndex)+ .WithChild(child);+ }++ /// <summary>+ /// Create a component hosted by a <see cref="IUIGrid"/> that represents a cell in a flexible grid.+ /// </summary>+ /// <param name="firstRow">The first row where the cell should appear.</param>+ /// <param name="lastRow">The last row where the cell should appear.</param>+ /// <param name="firstColumn">The first column where the cell should appear.</param>+ /// <param name="lastColumn">The last column where the cell should appear.</param>+ public static IUIGridCell Cell<TRow, TColumn>(+ TRow firstRow,+ TRow lastRow,+ TColumn firstColumn,+ TColumn? lastColumn = default,+ IUIElement? child = null)+ where TRow : Enum+ where TColumn : Enum+ {+ int rowIndex = firstRow.ToInt();+ int rowSpan = lastRow.ToInt() - rowIndex + 1;+ int columnIndex = firstColumn.ToInt();+ int columnSpan = lastColumn is not null ? lastColumn.ToInt() + 1 - columnIndex : 1;++ return new UIGridCell()+ .Row(rowIndex)+ .RowSpan(rowSpan)+ .Column(columnIndex)+ .ColumnSpan(columnSpan)+ .WithChild(child);+ }++ /// <summary>+ /// Sets the row alignment of the cell.+ /// </summary>+ public static IUIGridCell Row(this IUIGridCell element, int row)+ {+ ((UIGridCell)element).Row = row;+ return element;+ }++ /// <summary>+ /// Sets the column alignment of the cell.+ /// </summary>+ public static IUIGridCell Column(this IUIGridCell element, int column)+ {+ ((UIGridCell)element).Column = column;+ return element;+ }++ /// <summary>+ /// Sets a value that indicates the total number of rows that the cell content spans within the parent grid.+ /// </summary>+ public static IUIGridCell RowSpan(this IUIGridCell element, int rows)+ {+ ((UIGridCell)element).RowSpan = rows;+ return element;+ }++ /// <summary>+ /// Sets a value that indicates the total number of columns that the cell content spans within the parent grid.+ /// </summary>+ public static IUIGridCell ColumnSpan(this IUIGridCell element, int columns)+ {+ ((UIGridCell)element).ColumnSpan = columns;+ return element;+ }++ /// <summary>+ /// Sets the child element to display in the cell.+ /// </summary>+ public static IUIGridCell WithChild(this IUIGridCell element, IUIElement? child)+ {+ ((UIGridCell)element).Child = child;+ return element;+ }++ private static int ToInt(this Enum enumValue) => Convert.ToInt32(enumValue, CultureInfo.InvariantCulture);+}diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIIcon.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIIcon.csindex 8aef559f1..30b274520 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIIcon.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIIcon.cs@@ -23,17 +23,17 @@ public interface IUIIcon : IUIElement/// <summary>/// Raised when <see cref="FontName"/> is changed./// </summary>- public event EventHandler? FontNameChanged;+ event EventHandler? FontNameChanged;/// <summary>/// Raised when <see cref="Glyph"/> is changed./// </summary>- public event EventHandler? GlyphChanged;+ event EventHandler? GlyphChanged;/// <summary>/// Raised when <see cref="Size"/> is changed./// </summary>- public event EventHandler? SizeChanged;+ event EventHandler? SizeChanged;}[DebuggerDisplay($"Id = {{{nameof(Id)}}}, Glyph = {{{nameof(Glyph)}}}")]diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISelectDropDownList.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISelectDropDownList.csindex fdd116581..68b6c376f 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISelectDropDownList.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISelectDropDownList.cs@@ -23,12 +23,12 @@ public interface IUISelectDropDownList : IUITitledElement/// <summary>/// Raised when <see cref="Items"/> is changed./// </summary>- public event EventHandler? ItemsChanged;+ event EventHandler? ItemsChanged;/// <summary>/// Raised when <see cref="SelectedItem"/> is changed./// </summary>- public event EventHandler? SelectedItemChanged;+ event EventHandler? SelectedItemChanged;}[DebuggerDisplay($"Id = {{{nameof(Id)}}}, Title = {{{nameof(Title)}}}")]diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.csindex 633b87cea..58c075acd 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs@@ -23,17 +23,17 @@ public interface IUISetting : IUITitledElement/// <summary>/// Raised when <see cref="Description"/> is changed./// </summary>- public event EventHandler? DescriptionChanged;+ event EventHandler? DescriptionChanged;/// <summary>/// Raised when <see cref="Icon"/> is changed./// </summary>- public event EventHandler? IconChanged;+ event EventHandler? IconChanged;/// <summary>/// Raised when <see cref="InteractiveElement"/> is changed./// </summary>- public event EventHandler? InteractiveElementChanged;+ event EventHandler? InteractiveElementChanged;}[DebuggerDisplay($"Id = {{{nameof(Id)}}}, Title = {{{nameof(Title)}}}")]diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.csindex b0254e662..57c2501ca 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISettingGroup.cs@@ -18,7 +18,7 @@ public interface IUISettingGroup : IUISetting/// <summary>/// Raised when <see cref="Children"/> is changed./// </summary>- public event EventHandler? ChildrenChanged;+ event EventHandler? ChildrenChanged;}[DebuggerDisplay($"Id = {{{nameof(Id)}}}, Title = {{{nameof(Title)}}}")]@@ -114,7 +114,7 @@ public static partial class GUI}/// <summary>- /// Set the children to be displayed in the group.+ /// Sets the children to be displayed in the group./// </summary>public static IUISettingGroup WithChildren(this IUISettingGroup element, params IUIElement[] children){@@ -125,7 +125,7 @@ public static partial class GUI}/// <summary>- /// Set the children to be displayed in the group.+ /// Sets the children to be displayed in the group./// </summary>public static IUISettingGroup WithSettings(this IUISettingGroup element, params IUISetting[] settings){diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIStack.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIStack.csindex 5bfc16688..46d50d694 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIStack.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIStack.cs@@ -25,17 +25,17 @@ public interface IUIStack : IUIElement/// <summary>/// Raised when <see cref="Orientation"/> is changed./// </summary>- public event EventHandler? OrientationChanged;+ event EventHandler? OrientationChanged;/// <summary>/// Raised when <see cref="Spacing"/> is changed./// </summary>- public event EventHandler? SpacingChanged;+ event EventHandler? SpacingChanged;/// <summary>/// Raised when <see cref="Children"/> is changed./// </summary>- public event EventHandler? ChildrenChanged;+ event EventHandler? ChildrenChanged;}[DebuggerDisplay($"Id = {{{nameof(Id)}}}, Orientation = {{{nameof(Orientation)}}}")]@@ -113,7 +113,7 @@ public static partial class GUI}/// <summary>- /// Set the children to be displayed in the stack.+ /// Sets the children to be displayed in the stack./// </summary>public static IUIStack WithChildren(this IUIStack element, params IUIElement[] children){@@ -122,7 +122,7 @@ public static partial class GUI}/// <summary>- /// Set a small spacing between children.+ /// Sets a small spacing between children./// </summary>public static IUIStack SmallSpacing(this IUIStack element){@@ -131,7 +131,7 @@ public static partial class GUI}/// <summary>- /// Set a medium spacing between children.+ /// Sets a medium spacing between children./// </summary>public static IUIStack MediumSpacing(this IUIStack element){@@ -140,7 +140,7 @@ public static partial class GUI}/// <summary>- /// Set a large spacing between children.+ /// Sets a large spacing between children./// </summary>public static IUIStack LargeSpacing(this IUIStack element){diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISwitch.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISwitch.csindex 909974010..80403b2a6 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISwitch.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISwitch.cs@@ -25,17 +25,17 @@ public interface IUISwitch : IUIElement/// <summary>/// Raised when <see cref="OnText"/> is changed./// </summary>- public event EventHandler? OnTextChanged;+ event EventHandler? OnTextChanged;/// <summary>/// Raised when <see cref="OffText"/> is changed./// </summary>- public event EventHandler? OffTextChanged;+ event EventHandler? OffTextChanged;/// <summary>/// Raised when <see cref="IsOn"/> is changed./// </summary>- public event EventHandler? IsOnChanged;+ event EventHandler? IsOnChanged;}[DebuggerDisplay($"Id = {{{nameof(Id)}}}, IsOn = {{{nameof(IsOn)}}}")]diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUITitledElement.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUITitledElement.csindex 32a7f51ca..35d7c4c00 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUITitledElement.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUITitledElement.cs@@ -38,7 +38,7 @@ internal abstract class UITitledElement : UIElement, IUITitledElementpublic static partial class GUI{/// <summary>- /// Set the title of the element.+ /// Sets the title of the element./// </summary>public static T Title<T>(this T element, string? title) where T : IUITitledElement{diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIWrap.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIWrap.csindex bf7374258..1a9a41389 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIWrap.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUIWrap.cs@@ -19,12 +19,12 @@ public interface IUIWrap : IUIElement/// <summary>/// Raised when <see cref="Spacing"/> is changed./// </summary>- public event EventHandler? SpacingChanged;+ event EventHandler? SpacingChanged;/// <summary>/// Raised when <see cref="Children"/> is changed./// </summary>- public event EventHandler? ChildrenChanged;+ event EventHandler? ChildrenChanged;}[DebuggerDisplay($"Id = {{{nameof(Id)}}}")]@@ -75,7 +75,7 @@ public static partial class GUI}/// <summary>- /// Set the children to be displayed in the stack.+ /// Sets the children to be displayed in the stack./// </summary>public static IUIWrap WithChildren(this IUIWrap element, params IUIElement[] children){@@ -84,7 +84,7 @@ public static partial class GUI}/// <summary>- /// Set a small spacing between children.+ /// Sets a small spacing between children./// </summary>public static IUIWrap SmallSpacing(this IUIWrap element){@@ -93,7 +93,7 @@ public static partial class GUI}/// <summary>- /// Set a medium spacing between children.+ /// Sets a medium spacing between children./// </summary>public static IUIWrap MediumSpacing(this IUIWrap element){@@ -102,7 +102,7 @@ public static partial class GUI}/// <summary>- /// Set a large spacing between children.+ /// Sets a large spacing between children./// </summary>public static IUIWrap LargeSpacing(this IUIWrap element){diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridLength.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridLength.csnew file mode 100644index 000000000..3bb4da9a2--- /dev/null+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridLength.cs@@ -0,0 +1,136 @@+namespace DevToys.Api;++public readonly struct UIGridLength : IEquatable<UIGridLength>+{+ private readonly UIGridUnitType _type;++ private readonly double _value;++ /// <summary>+ /// Initializes a new instance of the <see cref="UIGridLength"/> struct.+ /// </summary>+ /// <param name="value">The size of the UIGridLength in device independent pixels.</param>+ public UIGridLength(double value)+ : this(value, UIGridUnitType.Pixel)+ {+ }++ /// <summary>+ /// Initializes a new instance of the <see cref="UIGridLength"/> struct.+ /// </summary>+ /// <param name="value">The size of the <see cref="UIGridLength"/>.</param>+ /// <param name="type">The unit of the <see cref="UIGridLength"/>.</param>+ public UIGridLength(double value, UIGridUnitType type)+ {+ if (value < 0 || double.IsNaN(value) || double.IsInfinity(value))+ {+ throw new ArgumentException("Invalid value", nameof(value));+ }++ if (type < UIGridUnitType.Auto || type > UIGridUnitType.Fraction)+ {+ throw new ArgumentException("Invalid value", nameof(type));+ }++ _type = type;+ _value = value;+ }++ /// <summary>+ /// Gets an instance of <see cref="UIGridLength"/> that indicates that a row or column should+ /// auto-size to fit its content.+ /// </summary>+ public static UIGridLength Auto => new(0, UIGridUnitType.Auto);++ /// <summary>+ /// Gets the unit of the <see cref="UIGridLength"/>.+ /// </summary>+ public UIGridUnitType UIGridUnitType => _type;++ /// <summary>+ /// Gets a value that indicates whether the <see cref="UIGridLength"/> has a <see cref="UIGridUnitType"/> of Pixel.+ /// </summary>+ public bool IsAbsolute => _type == UIGridUnitType.Pixel;++ /// <summary>+ /// Gets a value that indicates whether the <see cref="UIGridLength"/> has a <see cref="UIGridUnitType"/> of Auto.+ /// </summary>+ public bool IsAuto => _type == UIGridUnitType.Auto;++ /// <summary>+ /// Gets a value that indicates whether the <see cref="UIGridLength"/> has a <see cref="UIGridUnitType"/> of Fraction.+ /// </summary>+ public bool IsFraction => _type == UIGridUnitType.Fraction;++ /// <summary>+ /// Gets the length.+ /// </summary>+ public double Value => _value;++ /// <summary>+ /// Creates a <see cref="UIGridLength"/> from an number interpreted as a pixels.+ /// </summary>+ public static implicit operator UIGridLength(double pixels)+ => new(pixels, UIGridUnitType.Pixel);++ /// <summary>+ /// Compares two <see cref="UIGridLength"/> structures for equality.+ /// </summary>+ /// <param name="a">The first <see cref="UIGridLength"/>.</param>+ /// <param name="b">The second <see cref="UIGridLength"/>.</param>+ /// <returns>True if the structures are equal, otherwise false.</returns>+ public static bool operator ==(UIGridLength a, UIGridLength b)+ {+ return (a.IsAuto && b.IsAuto) || (a._value == b._value && a._type == b._type);+ }++ /// <summary>+ /// Compares two <see cref="UIGridLength"/> structures for inequality.+ /// </summary>+ /// <param name="gl1">The first <see cref="UIGridLength"/>.</param>+ /// <param name="gl2">The first <see cref="UIGridLength"/>.</param>+ /// <returns>True if the structures are unequal, otherwise false.</returns>+ public static bool operator !=(UIGridLength gl1, UIGridLength gl2)+ {+ return !(gl1 == gl2);+ }++ /// <summary>+ /// Determines whether the <see cref="UIGridLength"/> is equal to the specified object.+ /// </summary>+ /// <param name="o">The object with which to test equality.</param>+ /// <returns>True if the objects are equal, otherwise false.</returns>+ public override bool Equals(object? o)+ {+ if (o == null)+ {+ return false;+ }++ if (o is not UIGridLength)+ {+ return false;+ }++ return this == (UIGridLength)o;+ }++ /// <summary>+ /// Compares two <see cref="UIGridLength"/> structures for equality.+ /// </summary>+ /// <param name="gridLength">The structure with which to test equality.</param>+ /// <returns>True if the structures are equal, otherwise false.</returns>+ public bool Equals(UIGridLength gridLength)+ {+ return this == gridLength;+ }++ /// <summary>+ /// Gets a hash code for the <see cref="UIGridLength"/>.+ /// </summary>+ /// <returns>The hash code.</returns>+ public override int GetHashCode()+ {+ return _value.GetHashCode() ^ _type.GetHashCode();+ }+}diff --git a/src/app/dev/DevToys.Blazor/Components/GridUnitType.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridUnitType.cssimilarity index 85%rename from src/app/dev/DevToys.Blazor/Components/GridUnitType.csrename to src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridUnitType.csindex d5278c1c4..38460d085 100644--- a/src/app/dev/DevToys.Blazor/Components/GridUnitType.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/UIGridUnitType.cs@@ -1,6 +1,6 @@-namespace DevToys.Blazor.Components;+namespace DevToys.Api;-public enum GridUnitType+public enum UIGridUnitType{/// <summary>/// The row or column is auto-sized to fit its content.diff --git a/src/app/dev/DevToys.Blazor/Components/GridLength.cs b/src/app/dev/DevToys.Blazor/Components/GridLength.csdeleted file mode 100644index d427503d5..000000000--- a/src/app/dev/DevToys.Blazor/Components/GridLength.cs+++ /dev/null@@ -1,130 +0,0 @@-namespace DevToys.Blazor.Components;--public readonly struct GridLength : IEquatable<GridLength>-{- private readonly GridUnitType _type;-- private readonly double _value;-- /// <summary>- /// Initializes a new instance of the <see cref="GridLength"/> struct.- /// </summary>- /// <param name="value">The size of the GridLength in device independent pixels.</param>- public GridLength(double value)- : this(value, GridUnitType.Pixel)- {- }-- /// <summary>- /// Initializes a new instance of the <see cref="GridLength"/> struct.- /// </summary>- /// <param name="value">The size of the <see cref="GridLength"/>.</param>- /// <param name="type">The unit of the <see cref="GridLength"/>.</param>- public GridLength(double value, GridUnitType type)- {- if (value < 0 || double.IsNaN(value) || double.IsInfinity(value))- {- throw new ArgumentException("Invalid value", nameof(value));- }-- if (type < GridUnitType.Auto || type > GridUnitType.Fraction)- {- throw new ArgumentException("Invalid value", nameof(type));- }-- _type = type;- _value = value;- }-- /// <summary>- /// Gets an instance of <see cref="GridLength"/> that indicates that a row or column should- /// auto-size to fit its content.- /// </summary>- public static GridLength Auto => new(0, GridUnitType.Auto);-- /// <summary>- /// Gets the unit of the <see cref="GridLength"/>.- /// </summary>- public GridUnitType GridUnitType => _type;-- /// <summary>- /// Gets a value that indicates whether the <see cref="GridLength"/> has a <see cref="GridUnitType"/> of Pixel.- /// </summary>- public bool IsAbsolute => _type == GridUnitType.Pixel;-- /// <summary>- /// Gets a value that indicates whether the <see cref="GridLength"/> has a <see cref="GridUnitType"/> of Auto.- /// </summary>- public bool IsAuto => _type == GridUnitType.Auto;-- /// <summary>- /// Gets a value that indicates whether the <see cref="GridLength"/> has a <see cref="GridUnitType"/> of Fraction.- /// </summary>- public bool IsFraction => _type == GridUnitType.Fraction;-- /// <summary>- /// Gets the length.- /// </summary>- public double Value => _value;-- /// <summary>- /// Compares two <see cref="GridLength"/> structures for equality.- /// </summary>- /// <param name="a">The first <see cref="GridLength"/>.</param>- /// <param name="b">The second <see cref="GridLength"/>.</param>- /// <returns>True if the structures are equal, otherwise false.</returns>- public static bool operator ==(GridLength a, GridLength b)- {- return (a.IsAuto && b.IsAuto) || (a._value == b._value && a._type == b._type);- }-- /// <summary>- /// Compares two <see cref="GridLength"/> structures for inequality.- /// </summary>- /// <param name="gl1">The first <see cref="GridLength"/>.</param>- /// <param name="gl2">The first <see cref="GridLength"/>.</param>- /// <returns>True if the structures are unequal, otherwise false.</returns>- public static bool operator !=(GridLength gl1, GridLength gl2)- {- return !(gl1 == gl2);- }-- /// <summary>- /// Determines whether the <see cref="GridLength"/> is equal to the specified object.- /// </summary>- /// <param name="o">The object with which to test equality.</param>- /// <returns>True if the objects are equal, otherwise false.</returns>- public override bool Equals(object? o)- {- if (o == null)- {- return false;- }-- if (o is not GridLength)- {- return false;- }-- return this == (GridLength)o;- }-- /// <summary>- /// Compares two <see cref="GridLength"/> structures for equality.- /// </summary>- /// <param name="gridLength">The structure with which to test equality.</param>- /// <returns>True if the structures are equal, otherwise false.</returns>- public bool Equals(GridLength gridLength)- {- return this == gridLength;- }-- /// <summary>- /// Gets a hash code for the <see cref="GridLength"/>.- /// </summary>- /// <returns>The hash code.</returns>- public override int GetHashCode()- {- return _value.GetHashCode() ^ _type.GetHashCode();- }-}diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Grid/Grid.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/Grid/Grid.razor.csindex 3987552ad..9f62d503a 100644--- a/src/app/dev/DevToys.Blazor/Components/Layout/Grid/Grid.razor.cs+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Grid/Grid.razor.cs@@ -19,13 +19,13 @@ public partial class Grid : StyledComponentBase/// Gets or sets the list of columns in the grid./// </summary>[Parameter]- public IEnumerable<GridLength>? Columns { get; set; }+ public IEnumerable<UIGridLength>? Columns { get; set; }/// <summary>/// Gets or sets the list of rows in the grid./// </summary>[Parameter]- public IEnumerable<GridLength>? Rows { get; set; }+ public IEnumerable<UIGridLength>? Rows { get; set; }/// <summary>/// Gets or sets the uniform distance (in pixels) between grid columns.@@ -47,7 +47,7 @@ public partial class Grid : StyledComponentBase[Parameter]public RenderFragment? ChildContent { get; set; }- private static string GetGridTemplate(IEnumerable<GridLength>? collection)+ private static string GetGridTemplate(IEnumerable<UIGridLength>? collection){if (collection is null || !collection.Any()){@@ -55,7 +55,7 @@ public partial class Grid : StyledComponentBase}var builder = new StringBuilder();- foreach (GridLength item in collection)+ foreach (UIGridLength item in collection){if (item.IsFraction){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.csindex 27ae3f652..03eed68d3 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@@ -28,13 +28,13 @@ public partial class SplitGrid : JSStyledComponentBase/// Gets or sets the length of the left or top cell./// </summary>[Parameter]- public GridLength LeftOrTopCellSize { get; set; } = new GridLength(1, GridUnitType.Fraction);+ public UIGridLength LeftOrTopCellSize { get; set; } = new UIGridLength(1, UIGridUnitType.Fraction);/// <summary>/// Gets or sets the length of the right or bottom cell./// </summary>[Parameter]- public GridLength RightOrBottomCellSize { get; set; } = new GridLength(1, GridUnitType.Fraction);+ public UIGridLength RightOrBottomCellSize { get; set; } = new UIGridLength(1, UIGridUnitType.Fraction);/// <summary>/// Gets or sets the content to be rendered inside the component.@@ -84,7 +84,7 @@ public partial class SplitGrid : JSStyledComponentBase}}- private static string GetCellLength(GridLength length)+ private static string GetCellLength(UIGridLength length){if (length.IsFraction){@@ -97,7 +97,7 @@ public partial class SplitGrid : JSStyledComponentBaseelse{Guard.IsTrue(length.IsAuto);- ThrowHelper.ThrowNotSupportedException($"{nameof(GridLength)}.{nameof(GridLength.Auto)} is not supported in {nameof(SplitGrid)}.");+ ThrowHelper.ThrowNotSupportedException($"{nameof(UIGridLength)}.{nameof(UIGridLength.Auto)} is not supported in {nameof(SplitGrid)}.");return string.Empty;}}diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razorindex 337a708da..8e8d6a98b 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIDiffTextInputPresenter.razor@@ -10,23 +10,23 @@HorizontalAlignment="@(_isInFullScreenMode ? UIHorizontalAlignment.Stretch : UIDiffTextInput.HorizontalAlignment)"VerticalAlignment="@(_isInFullScreenMode ? UIVerticalAlignment.Stretch : UIDiffTextInput.VerticalAlignment)"RowSpacing="6"- Rows="@(new List<GridLength>+ Rows="@(new List<UIGridLength>{- GridLength.Auto,- new GridLength(1, GridUnitType.Fraction)+ UIGridLength.Auto,+ new UIGridLength(1, UIGridUnitType.Fraction)})"ColumnSpacing="6"- Columns="@(new List<GridLength>+ Columns="@(new List<UIGridLength>{- new GridLength(1, GridUnitType.Fraction),- GridLength.Auto+ new UIGridLength(1, UIGridUnitType.Fraction),+ UIGridLength.Auto})"><GridCell Row="0" Column="0"><Grid RowSpacing="0"- Rows="@(new List<GridLength>+ Rows="@(new List<UIGridLength>{- new GridLength(1, GridUnitType.Fraction),- new GridLength(20, GridUnitType.Pixel)+ new UIGridLength(1, UIGridUnitType.Fraction),+ new UIGridLength(20, UIGridUnitType.Pixel)})"><GridCell Row="1"><TextBlock id="@(ExtendedId + "-title")"diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIElementPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UIElementPresenter.razorindex b27b10147..c47c25172 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UIElementPresenter.razor+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIElementPresenter.razor@@ -14,6 +14,10 @@<UIWrapPresenter UIWrap="@wrap" />break;+ case IUIGrid grid:+ <UIGridPresenter UIGrid="@grid" />+ break;+case IUIButton button:<UIButtonPresenter UIButton="@button" />break;diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIGridPresenter.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UIGridPresenter.razornew file mode 100644index 000000000..b3d40e9e6--- /dev/null+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIGridPresenter.razor@@ -0,0 +1,30 @@+@namespace DevToys.Blazor.Components.UIElements+@using DevToys.Api;+@inherits ComponentBase++<Grid id="@UIGrid.Id"+ IsVisible="@UIGrid.IsVisible"+ IsEnabled="@UIGrid.IsEnabled"+ HorizontalAlignment="@UIGrid.HorizontalAlignment"+ VerticalAlignment="@UIGrid.VerticalAlignment"+ RowSpacing="@(UIGrid.RowSpacing == UISpacing.Small ? 4 : (UIGrid.RowSpacing == UISpacing.Medium ? 8 : 12))"+ ColumnSpacing="@(UIGrid.ColumnSpacing == UISpacing.Small ? 4 : (UIGrid.ColumnSpacing == UISpacing.Medium ? 8 : 12))"+ Rows="@UIGrid.Rows"+ Columns="@UIGrid.Columns">+ @if (UIGrid.Cells is not null)+ {+ for (int i = 0; i < UIGrid.Cells.Length; i++)+ {+ IUIGridCell cell = UIGrid.Cells[i];+ <GridCell Row="@cell.Row"+ Column="@cell.Column"+ RowSpan="@cell.RowSpan"+ ColumnSpan="@cell.ColumnSpan">+ @if (cell.Child is not null)+ {+ <UIElementPresenter UIElement="@cell.Child" />+ }+ </GridCell>+ }+ }+</Grid>\ No newline at end of filediff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UIGridPresenter.razor.cs b/src/app/dev/DevToys.Blazor/Components/UIElements/UIGridPresenter.razor.csnew file mode 100644index 000000000..3a415cc7f--- /dev/null+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UIGridPresenter.razor.cs@@ -0,0 +1,7 @@+namespace DevToys.Blazor.Components.UIElements;++public partial class UIGridPresenter : ComponentBase+{+ [Parameter]+ public IUIGrid UIGrid { get; set; } = default!;+}diff --git a/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor b/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razorindex 24e1264a7..26b462c7a 100644--- a/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor+++ b/src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor@@ -10,23 +10,23 @@HorizontalAlignment="@(_isInFullScreenMode ? UIHorizontalAlignment.Stretch : UITextInput.HorizontalAlignment)"VerticalAlignment="@(_isInFullScreenMode ? UIVerticalAlignment.Stretch : UITextInput.VerticalAlignment)"RowSpacing="6"- Rows="@(new List<GridLength>+ Rows="@(new List<UIGridLength>{- GridLength.Auto,- new GridLength(1, GridUnitType.Fraction)+ UIGridLength.Auto,+ new UIGridLength(1, UIGridUnitType.Fraction)})"ColumnSpacing="6"- Columns="@(new List<GridLength>+ Columns="@(new List<UIGridLength>{- new GridLength(1, GridUnitType.Fraction),- GridLength.Auto+ new UIGridLength(1, UIGridUnitType.Fraction),+ UIGridLength.Auto})"><GridCell Row="0" Column="0"><Grid RowSpacing="0"- Rows="@(new List<GridLength>+ Rows="@(new List<UIGridLength>{- new GridLength(1, GridUnitType.Fraction),- new GridLength(20, GridUnitType.Pixel)+ new UIGridLength(1, UIGridUnitType.Fraction),+ new UIGridLength(20, UIGridUnitType.Pixel)})"><GridCell Row="1"><TextBlock id="@(ExtendedId + "-title")"diff --git a/src/app/dev/DevToys.Blazor/Pages/SubPages/TestPage.razor b/src/app/dev/DevToys.Blazor/Pages/SubPages/TestPage.razorindex c6b2ba6f8..6d4945289 100644--- a/src/app/dev/DevToys.Blazor/Pages/SubPages/TestPage.razor+++ b/src/app/dev/DevToys.Blazor/Pages/SubPages/TestPage.razor@@ -10,11 +10,11 @@PaddingTop="16"><Grid ColumnSpacing="12"RowSpacing="12"- Columns="@(new List<GridLength>+ Columns="@(new List<UIGridLength>{- GridLength.Auto,- new GridLength(1, GridUnitType.Fraction),- new GridLength(250)+ UIGridLength.Auto,+ new UIGridLength(1, UIGridUnitType.Fraction),+ new UIGridLength(250)})"><GridCell Column="0">diff --git a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razorindex 3fd427765..a929f01b6 100644--- a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor+++ b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolPage.razor@@ -24,16 +24,16 @@ elseRenderToolWithHeader = (bool isScrollable) => (__builder) =>{<Grid RowSpacing="12"- Rows="@(new List<GridLength>+ Rows="@(new List<UIGridLength>{- GridLength.Auto,- new GridLength(1, GridUnitType.Fraction)+ UIGridLength.Auto,+ new UIGridLength(1, UIGridUnitType.Fraction)})"ColumnSpacing="6"- Columns="@(new List<GridLength>+ Columns="@(new List<UIGridLength>{- new GridLength(1, GridUnitType.Fraction),- GridLength.Auto+ new UIGridLength(1, UIGridUnitType.Fraction),+ UIGridLength.Auto})"><GridCell Row="0" Column="0">diff --git a/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs b/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.csindex d25aa83bc..4b6a20b6d 100644--- a/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs+++ b/src/app/dev/DevToys.Tools/Tools/Settings/SettingsGuiTool.cs@@ -1,5 +1,17 @@namespace DevToys.Tools.Tools.Settings;+internal enum GridTestRow+{+ FileSelection,+ InputTextBox,+ Output+}++internal enum GridTestColumn+{+ UniqueColumn+}+[Export(typeof(IGuiTool))][Name("Settings")][ToolDisplayInformation(@@ -90,18 +102,32 @@ internal sealed class SettingsGuiTool : IGuiToolButton().Text("Bottom Center button").OnClick(OnBottomCenterButtonClickAsync),Button().Text("Bottom Right button")),NumberInput(),- FileSelector()- .CanSelectManyFiles()- .LimitFileTypesTo("*.bmp", "jpeg", "png", ".jpg")- .OnFilesSelected(OnFilesSelected),- SingleLineTextInput().Title("Read-write text input with copy").ReadOnly(),- MultilineTextInput()- .Title("Monaco editor")- .Extendable()- .CanCopyWhenEditable()- .Text("{\"hello\": \"there\"}")- .Language("json")- .CommandBarExtraContent(Button().Text("None")),+ Grid()+ .Rows(+ (GridTestRow.FileSelection, Fraction(1)),+ (GridTestRow.InputTextBox, 200),+ (GridTestRow.Output, Auto))+ .Columns(+ (GridTestColumn.UniqueColumn, Fraction(1)))+ .Cells(+ Cell(+ GridTestRow.FileSelection, GridTestColumn.UniqueColumn,+ FileSelector()+ .CanSelectManyFiles()+ .LimitFileTypesTo("*.bmp", "jpeg", "png", ".jpg")+ .OnFilesSelected(OnFilesSelected)),+ Cell(+ GridTestRow.InputTextBox, GridTestColumn.UniqueColumn,+ MultilineTextInput()+ .Title("Monaco editor")+ .Extendable()+ .CanCopyWhenEditable()+ .Text("{\"hello\": \"there\"}")+ .Language("json")+ .CommandBarExtraContent(Button().Text("None"))),+ Cell(+ GridTestRow.Output, GridTestColumn.UniqueColumn,+ SingleLineTextInput().Title("Read-write text input with copy").ReadOnly())),DiffTextInput().Title("Difference").OriginalText("hello")diff --git a/src/app/dev/platforms/desktop/DevToys.Windows/Controls/MicaWindowWithOverlay.xaml.cs b/src/app/dev/platforms/desktop/DevToys.Windows/Controls/MicaWindowWithOverlay.xaml.csindex ce75ecdbc..6c0b0a9fc 100644--- a/src/app/dev/platforms/desktop/DevToys.Windows/Controls/MicaWindowWithOverlay.xaml.cs+++ b/src/app/dev/platforms/desktop/DevToys.Windows/Controls/MicaWindowWithOverlay.xaml.cs@@ -52,24 +52,24 @@ public abstract partial class MicaWindowWithOverlay : Windowinternal static readonly DependencyProperty TitleBarMarginLeftProperty= DependencyProperty.Register(nameof(TitleBarMarginLeft),- typeof(GridLength),+ typeof(UIGridLength),typeof(MicaWindowWithOverlay));- internal GridLength TitleBarMarginLeft+ internal UIGridLength TitleBarMarginLeft{- get => (GridLength)GetValue(MarginMaximizedProperty);+ get => (UIGridLength)GetValue(MarginMaximizedProperty);set => SetValue(MarginMaximizedProperty, value);}internal static readonly DependencyProperty TitleBarMarginRightProperty= DependencyProperty.Register(nameof(TitleBarMarginRight),- typeof(GridLength),+ typeof(UIGridLength),typeof(MicaWindowWithOverlay));- internal GridLength TitleBarMarginRight+ internal UIGridLength TitleBarMarginRight{- get => (GridLength)GetValue(MarginMaximizedProperty);+ get => (UIGridLength)GetValue(MarginMaximizedProperty);set => SetValue(MarginMaximizedProperty, value);}