From 2644728a4edca027f2113c0fbe1fa9d924a475b8 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Mon, 25 Nov 2024 13:27:48 +0100 Subject: [PATCH] Docs: add Max example for Progress component --- .../Models/Snippets.generated.cs | 40 +++++++++++++++++ .../Code/ProgressWithMaxExampleCode.html | 44 +++++++++++++++++++ .../Examples/ProgressWithMaxExample.razor | 40 +++++++++++++++++ .../Components/Progresses/ProgressPage.razor | 10 +++++ 4 files changed, 134 insertions(+) create mode 100644 Documentation/Blazorise.Docs/Pages/Docs/Components/Progresses/Code/ProgressWithMaxExampleCode.html create mode 100644 Documentation/Blazorise.Docs/Pages/Docs/Components/Progresses/Examples/ProgressWithMaxExample.razor diff --git a/Documentation/Blazorise.Docs/Models/Snippets.generated.cs b/Documentation/Blazorise.Docs/Models/Snippets.generated.cs index fbe2cab561..4af4f29a83 100644 --- a/Documentation/Blazorise.Docs/Models/Snippets.generated.cs +++ b/Documentation/Blazorise.Docs/Models/Snippets.generated.cs @@ -3639,6 +3639,46 @@ private void SetActive(string page) "; + public const string ProgressWithMaxExample = @"@using System.Timers +@implements IDisposable + + + + + + + There have been @Value files downloaded + + + +@code { + private int Value = 0; + private Timer timer; + + private const int IntervalDelay = 100; // milliseconds + private const int IntervalIncrement = 1; + + protected override void OnInitialized() + { + timer = new Timer(IntervalDelay); + timer.Elapsed += OnTimerElapsed; + timer.AutoReset = true; + timer.Start(); + } + + private void OnTimerElapsed(object sender, ElapsedEventArgs e) + { + Value = Value < 42 ? Value + IntervalIncrement : 0; + InvokeAsync(StateHasChanged); + } + + public void Dispose() + { + timer?.Stop(); + timer?.Dispose(); + } +}"; + public const string BasicRadioGroupExample = @" Red Green diff --git a/Documentation/Blazorise.Docs/Pages/Docs/Components/Progresses/Code/ProgressWithMaxExampleCode.html b/Documentation/Blazorise.Docs/Pages/Docs/Components/Progresses/Code/ProgressWithMaxExampleCode.html new file mode 100644 index 0000000000..ed61e2644b --- /dev/null +++ b/Documentation/Blazorise.Docs/Pages/Docs/Components/Progresses/Code/ProgressWithMaxExampleCode.html @@ -0,0 +1,44 @@ +
+
+@using System.Timers
+@implements IDisposable
+
+<Field>
+    <FieldBody>
+        <Progress Max="42" Value="@Value" />
+    </FieldBody>
+    <FieldHelp>
+        There have been @Value files downloaded
+    </FieldHelp>
+</Field>
+
+
+@code {
+    private int Value = 0;
+    private Timer timer;
+
+    private const int IntervalDelay = 100; // milliseconds
+    private const int IntervalIncrement = 1;
+
+    protected override void OnInitialized()
+    {
+        timer = new Timer(IntervalDelay);
+        timer.Elapsed += OnTimerElapsed;
+        timer.AutoReset = true;
+        timer.Start();
+    }
+
+    private void OnTimerElapsed(object sender, ElapsedEventArgs e)
+    {
+        Value = Value < 42 ? Value + IntervalIncrement : 0;
+        InvokeAsync(StateHasChanged);
+    }
+
+    public void Dispose()
+    {
+        timer?.Stop();
+        timer?.Dispose();
+    }
+}
+
+
diff --git a/Documentation/Blazorise.Docs/Pages/Docs/Components/Progresses/Examples/ProgressWithMaxExample.razor b/Documentation/Blazorise.Docs/Pages/Docs/Components/Progresses/Examples/ProgressWithMaxExample.razor new file mode 100644 index 0000000000..fb3f1e7c11 --- /dev/null +++ b/Documentation/Blazorise.Docs/Pages/Docs/Components/Progresses/Examples/ProgressWithMaxExample.razor @@ -0,0 +1,40 @@ +@namespace Blazorise.Docs.Docs.Examples +@using System.Timers +@implements IDisposable + + + + + + + There have been @Value files downloaded + + + +@code { + private int Value = 0; + private Timer timer; + + private const int IntervalDelay = 100; // milliseconds + private const int IntervalIncrement = 1; + + protected override void OnInitialized() + { + timer = new Timer(IntervalDelay); + timer.Elapsed += OnTimerElapsed; + timer.AutoReset = true; + timer.Start(); + } + + private void OnTimerElapsed(object sender, ElapsedEventArgs e) + { + Value = Value < 42 ? Value + IntervalIncrement : 0; + InvokeAsync(StateHasChanged); + } + + public void Dispose() + { + timer?.Stop(); + timer?.Dispose(); + } +} \ No newline at end of file diff --git a/Documentation/Blazorise.Docs/Pages/Docs/Components/Progresses/ProgressPage.razor b/Documentation/Blazorise.Docs/Pages/Docs/Components/Progresses/ProgressPage.razor index eb3d777252..b6499e1443 100644 --- a/Documentation/Blazorise.Docs/Pages/Docs/Components/Progresses/ProgressPage.razor +++ b/Documentation/Blazorise.Docs/Pages/Docs/Components/Progresses/ProgressPage.razor @@ -90,6 +90,16 @@ + + + You can specify the maximum value of the determinate Progress. This is useful for instances where you want to show capacity, or how much of a total has been uploaded/downloaded. + + + + + + + Page progress