Fix Java 8 resolution for MfApi restart, refresh targets after settings, and copy errors to clipboard.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
namespace ZA.CoreService.ESBCertificateManager.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Fehlerdialog mit Text und Button „In Zwischenablage kopieren“.
|
||||
/// Kopiert den Fehlertext beim Öffnen automatisch.
|
||||
/// </summary>
|
||||
public static class CopyableErrorDialog
|
||||
{
|
||||
public static void Show(
|
||||
IWin32Window? owner,
|
||||
string title,
|
||||
string details)
|
||||
{
|
||||
string text = string.IsNullOrWhiteSpace(details)
|
||||
? "(keine Fehlerdetails)"
|
||||
: details.Trim();
|
||||
|
||||
TryCopy(text);
|
||||
|
||||
using Form dialog = new()
|
||||
{
|
||||
Text = title,
|
||||
StartPosition = FormStartPosition.CenterParent,
|
||||
FormBorderStyle = FormBorderStyle.FixedDialog,
|
||||
MaximizeBox = false,
|
||||
MinimizeBox = false,
|
||||
ShowInTaskbar = false,
|
||||
ClientSize = new Size(640, 420),
|
||||
BackColor = Color.FromArgb(16, 28, 48),
|
||||
ForeColor = Color.FromArgb(241, 245, 249),
|
||||
Font = new Font("Segoe UI", 9.5f)
|
||||
};
|
||||
|
||||
Label hint = new()
|
||||
{
|
||||
Text =
|
||||
"Fehlertext ist in der Zwischenablage — "
|
||||
+ "einfach hier einfügen (Strg+V).",
|
||||
Location = new Point(16, 12),
|
||||
AutoSize = false,
|
||||
Size = new Size(608, 28),
|
||||
ForeColor = Color.FromArgb(208, 171, 57)
|
||||
};
|
||||
|
||||
TextBox box = new()
|
||||
{
|
||||
Location = new Point(16, 44),
|
||||
Size = new Size(608, 310),
|
||||
Multiline = true,
|
||||
ReadOnly = true,
|
||||
ScrollBars = ScrollBars.Both,
|
||||
WordWrap = false,
|
||||
Text = text,
|
||||
BackColor = Color.FromArgb(12, 22, 38),
|
||||
ForeColor = Color.FromArgb(241, 245, 249),
|
||||
BorderStyle = BorderStyle.FixedSingle,
|
||||
Font = new Font("Consolas", 9f)
|
||||
};
|
||||
|
||||
Label copyStatus = new()
|
||||
{
|
||||
Text = "✓ In Zwischenablage kopiert",
|
||||
Location = new Point(16, 368),
|
||||
AutoSize = true,
|
||||
ForeColor = Color.FromArgb(90, 200, 140)
|
||||
};
|
||||
|
||||
Button btnCopy = new()
|
||||
{
|
||||
Text = "Nochmal kopieren",
|
||||
Location = new Point(280, 362),
|
||||
Size = new Size(160, 36),
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
BackColor = Color.FromArgb(39, 52, 73),
|
||||
ForeColor = Color.FromArgb(241, 245, 249),
|
||||
Cursor = Cursors.Hand
|
||||
};
|
||||
|
||||
btnCopy.FlatAppearance.BorderColor =
|
||||
Color.FromArgb(36, 74, 117);
|
||||
|
||||
btnCopy.Click += (_, _) =>
|
||||
{
|
||||
if (TryCopy(text))
|
||||
{
|
||||
copyStatus.Text = "✓ Erneut kopiert";
|
||||
copyStatus.ForeColor =
|
||||
Color.FromArgb(90, 200, 140);
|
||||
}
|
||||
else
|
||||
{
|
||||
copyStatus.Text = "Kopieren fehlgeschlagen";
|
||||
copyStatus.ForeColor =
|
||||
Color.FromArgb(220, 100, 100);
|
||||
}
|
||||
};
|
||||
|
||||
Button btnClose = new()
|
||||
{
|
||||
Text = "Schließen",
|
||||
Location = new Point(456, 362),
|
||||
Size = new Size(168, 36),
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
BackColor = Color.FromArgb(0, 110, 182),
|
||||
ForeColor = Color.White,
|
||||
Cursor = Cursors.Hand,
|
||||
DialogResult = DialogResult.OK
|
||||
};
|
||||
|
||||
btnClose.FlatAppearance.BorderSize = 0;
|
||||
|
||||
dialog.Controls.Add(hint);
|
||||
dialog.Controls.Add(box);
|
||||
dialog.Controls.Add(copyStatus);
|
||||
dialog.Controls.Add(btnCopy);
|
||||
dialog.Controls.Add(btnClose);
|
||||
dialog.AcceptButton = btnClose;
|
||||
dialog.CancelButton = btnClose;
|
||||
|
||||
dialog.ShowDialog(owner);
|
||||
}
|
||||
|
||||
private static bool TryCopy(string text)
|
||||
{
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(text);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user