diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-10-19 07:21:41 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-10-19 07:21:41 +0200 |
commit | 063fb6f12aea3a5b71c05beea22e7f6482c2f1cf (patch) | |
tree | 064aa9edd5a27017f95ed0a6b19ac69499005778 /MatrixRoomUtils.Web/Pages/Dev/ModalTest.razor | |
parent | Add user management page (diff) | |
download | MatrixUtils-063fb6f12aea3a5b71c05beea22e7f6482c2f1cf.tar.xz |
Refactor, fix stuff
Diffstat (limited to 'MatrixRoomUtils.Web/Pages/Dev/ModalTest.razor')
-rw-r--r-- | MatrixRoomUtils.Web/Pages/Dev/ModalTest.razor | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/MatrixRoomUtils.Web/Pages/Dev/ModalTest.razor b/MatrixRoomUtils.Web/Pages/Dev/ModalTest.razor new file mode 100644 index 0000000..4a0487f --- /dev/null +++ b/MatrixRoomUtils.Web/Pages/Dev/ModalTest.razor @@ -0,0 +1,88 @@ +@page "/Dev/ModalTest" +@inject IJSRuntime JsRuntime +<h3>ModalTest</h3> + +@foreach (var (key, value) in _windowInfos) { + @* <ModalWindow X="@value.X" Y="@value.Y" Title="@value.Title">@value.Content</ModalWindow> *@ +} +@for (var i = 0; i < 5; i++) { + var i1 = i; + <ModalWindow X="@Random.Shared.Next(1400)" Y="@Random.Shared.Next(1000)" Title="@("Window " + i1)" OnCloseClicked="() => OnCloseClicked(i1)"> + @for (var j = 0; j < i1; j++) { + <h1>@j</h1> + } + </ModalWindow> +} + +@code { + + private Dictionary<int, WindowInfo> _windowInfos = new(); + + private class WindowInfo { + public double X; + public double Y; + public string Title; + public RenderFragment Content; + } + + protected override async Task OnInitializedAsync() { + double _x = 2; + double _xv = 20; + double _y = 0; + double multiplier = 1; + + for (var i = 0; i < 200; i++) { + var i1 = i; + _windowInfos.Add(_windowInfos.Count, new WindowInfo { + X = _x, + Y = _y, + Title = "Win" + i1, + Content = builder => { + builder.OpenComponent<ModalWindow>(0); + builder.AddAttribute(1, "X", _x); + builder.AddAttribute(2, "Y", _y); + builder.AddAttribute(3, "Title", "Win" + i1); + builder.AddAttribute(4, "ChildContent", (RenderFragment)(builder2 => { + builder2.OpenElement(0, "h1"); + builder2.AddContent(1, "Hello " + i1); + builder2.CloseElement(); + })); + builder.CloseComponent(); + } + }); + //_x += _xv /= 1000/System.Math.Sqrt((double)_windowInfos.Count)*_windowInfos.Count.ToString().Length*multiplier; + _y += 20; + _x += 20; + var dimension = await JsRuntime.InvokeAsync<WindowDimension>("getWindowDimensions"); + if (_x > dimension.Width - 100) _x %= dimension.Width - 100; + if (_y > dimension.Height - 50) { + _y %= dimension.Height - 50; + _xv = 20; + } + if ( + (_windowInfos.Count < 10 && _windowInfos.Count % 2 == 0) || + (_windowInfos.Count < 100 && _windowInfos.Count % 10 == 0) || + (_windowInfos.Count < 1000 && _windowInfos.Count % 50 == 0) || + (_windowInfos.Count < 10000 && _windowInfos.Count % 100 == 0) + ) { + StateHasChanged(); + await Task.Delay(25); + } + if(_windowInfos.Count > 750) multiplier = 2; + if(_windowInfos.Count > 1500) multiplier = 3; + + } + + await base.OnInitializedAsync(); + } + + private void OnCloseClicked(int i1) { + Console.WriteLine("Close clicked on " + i1); + } + + public class WindowDimension { + public int Width { get; set; } + public int Height { get; set; } + } + +} |