feat: add modal dialog, paged results, scan status, and trend value table components
- Introduced ModalDialog component for displaying modal dialogs with accessibility features. - Added PagedResults component to handle pagination of items with customizable rendering. - Created ScanStatus component to display the status of a scan with elapsed time. - Implemented TrendValueTable component for displaying trend data in a paginated table format. - Added measurement utility functions for formatting and validating measurement values. - Included tests for measurement functions and trend series fetching logic to ensure correctness.
This commit is contained in:
1 parent
c19c77334f
commit
a8b6cd4061
23 files changed
+1479
-2157
No files matched your search
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -15,6 +16,13 @@ namespace SeLtd.Setup
|
||||
private readonly FlowLayoutPanel body = new FlowLayoutPanel();
|
||||
private readonly Button back = new Button { Text = "Zurück", AutoSize = true };
|
||||
private readonly Button next = new Button { Text = "Weiter", AutoSize = true };
|
||||
private readonly Button pause = new Button { Text = "Nach Schritt anhalten", AutoSize = true, Visible = false };
|
||||
private readonly System.Windows.Forms.Timer progressTimer = new System.Windows.Forms.Timer { Interval = 1000 };
|
||||
private readonly Stopwatch elapsed = new Stopwatch();
|
||||
private CancellationTokenSource cancellation;
|
||||
private Label activeStep;
|
||||
private Label elapsedLabel;
|
||||
private ProgressBar progressBar;
|
||||
private TextBox input;
|
||||
private TextBox log;
|
||||
private CheckBox choice;
|
||||
@@ -66,7 +74,7 @@ namespace SeLtd.Setup
|
||||
body.Margin = new Padding(0);
|
||||
body.ClientSizeChanged += delegate { FitBody(); };
|
||||
var buttons = new FlowLayoutPanel { Dock = DockStyle.Fill, AutoSize = true, FlowDirection = FlowDirection.RightToLeft };
|
||||
buttons.Controls.AddRange(new Control[] { next, back });
|
||||
buttons.Controls.AddRange(new Control[] { next, back, pause });
|
||||
layout.Controls.Add(section, 0, 0);
|
||||
layout.Controls.Add(headline, 0, 1);
|
||||
layout.Controls.Add(body, 0, 2);
|
||||
@@ -75,7 +83,15 @@ namespace SeLtd.Setup
|
||||
AcceptButton = next;
|
||||
back.Click += OnBack;
|
||||
next.Click += OnNext;
|
||||
FormClosing += delegate(object sender, FormClosingEventArgs e) { if (busy) e.Cancel = true; };
|
||||
pause.Click += delegate { RequestPause(); };
|
||||
progressTimer.Tick += delegate { UpdateElapsed(); };
|
||||
Disposed += delegate { progressTimer.Dispose(); };
|
||||
FormClosing += delegate(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (!busy) return;
|
||||
e.Cancel = true;
|
||||
RequestPause();
|
||||
};
|
||||
ShowChecks();
|
||||
}
|
||||
|
||||
@@ -88,6 +104,7 @@ namespace SeLtd.Setup
|
||||
next.Text = nextText;
|
||||
back.Visible = canGoBack;
|
||||
next.Enabled = true;
|
||||
pause.Visible = false;
|
||||
validation = null;
|
||||
input = null;
|
||||
choice = null;
|
||||
@@ -239,22 +256,72 @@ namespace SeLtd.Setup
|
||||
{
|
||||
page = 4;
|
||||
Screen("SE-LTD SETUP / LÄUFT", title, "Erneut versuchen", false);
|
||||
cancellation = new CancellationTokenSource();
|
||||
activeStep = Note("Wird vorbereitet …");
|
||||
elapsedLabel = Note("");
|
||||
progressBar = new ProgressBar { Style = ProgressBarStyle.Marquee, Height = 12, Width = 320, AccessibleName = "Arbeitsschritt läuft" };
|
||||
Add(progressBar);
|
||||
log = new TextBox { ReadOnly = true, Multiline = true, ScrollBars = ScrollBars.Vertical, Height = 200, AccessibleName = "Installationsfortschritt" };
|
||||
Add(log);
|
||||
elapsed.Restart();
|
||||
UpdateElapsed();
|
||||
progressTimer.Start();
|
||||
pause.Enabled = true;
|
||||
pause.Visible = true;
|
||||
SetBusy(true);
|
||||
}
|
||||
|
||||
private void UpdateElapsed()
|
||||
{
|
||||
if (elapsedLabel == null || elapsedLabel.IsDisposed) return;
|
||||
var state = cancellation != null && cancellation.IsCancellationRequested
|
||||
? "Aktueller Schritt wird abgeschlossen. Danach hält das Setup an."
|
||||
: "Setup läuft.";
|
||||
elapsedLabel.Text = state + " Laufzeit " + elapsed.Elapsed.ToString(@"hh\:mm\:ss");
|
||||
}
|
||||
|
||||
private void RequestPause()
|
||||
{
|
||||
if (!busy || cancellation == null || cancellation.IsCancellationRequested) return;
|
||||
cancellation.Cancel();
|
||||
pause.Enabled = false;
|
||||
UpdateElapsed();
|
||||
}
|
||||
|
||||
private void SetBusy(bool value)
|
||||
{
|
||||
busy = value;
|
||||
back.Enabled = !value;
|
||||
next.Enabled = !value;
|
||||
UseWaitCursor = value;
|
||||
if (!value)
|
||||
{
|
||||
progressTimer.Stop();
|
||||
elapsed.Stop();
|
||||
if (progressBar != null && !progressBar.IsDisposed)
|
||||
{
|
||||
progressBar.Style = ProgressBarStyle.Blocks;
|
||||
progressBar.Visible = false;
|
||||
}
|
||||
pause.Visible = false;
|
||||
if (cancellation != null)
|
||||
{
|
||||
cancellation.Dispose();
|
||||
cancellation = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Progress(string line)
|
||||
{
|
||||
BeginInvoke(new Action(() => log.AppendText(line + Environment.NewLine)));
|
||||
var output = log;
|
||||
var label = activeStep;
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
if (output.IsDisposed) return;
|
||||
label.Text = line;
|
||||
output.AppendText(line + Environment.NewLine);
|
||||
}));
|
||||
}
|
||||
|
||||
private void ShowSuccess()
|
||||
@@ -304,10 +371,12 @@ namespace SeLtd.Setup
|
||||
ShowProgress("Projekt wird vorbereitet");
|
||||
try
|
||||
{
|
||||
await Task.Run(() => setup.Prepare(folder, Progress));
|
||||
var stop = cancellation.Token;
|
||||
await Task.Run(() => setup.Prepare(folder, Progress, stop));
|
||||
if (setup.ExistingEnvironment) ShowExisting();
|
||||
else { variableIndex = 0; ShowVariable(); }
|
||||
}
|
||||
catch (OperationCanceledException) { ShowFolder(); }
|
||||
catch (Exception error) { ShowError(error); ShowFolder(); }
|
||||
finally { SetBusy(false); }
|
||||
}
|
||||
@@ -332,12 +401,19 @@ namespace SeLtd.Setup
|
||||
ShowProgress("SE-LTD wird installiert");
|
||||
try
|
||||
{
|
||||
await Task.Run(() => setup.Install(Progress));
|
||||
var stop = cancellation.Token;
|
||||
await Task.Run(() => setup.Install(Progress, stop));
|
||||
ShowSuccess();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
headline.Text = "Setup angehalten";
|
||||
elapsedLabel.Text = "Bereits gestartete Dienste bleiben unverändert. Du kannst das Setup erneut starten.";
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
log.AppendText(Environment.NewLine + error.Message);
|
||||
elapsedLabel.Text = "Setup fehlgeschlagen. Details stehen im Fortschrittsprotokoll.";
|
||||
ShowError(error);
|
||||
}
|
||||
finally { SetBusy(false); }
|
||||
|
||||
Reference in new issue
Block a user