Monospace option for MessageForm

This commit is contained in:
n00mkrad
2025-11-09 16:07:03 +01:00
parent 08705f764e
commit cab30607d3
2 changed files with 11 additions and 10 deletions

View File

@@ -1,11 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Flowframes.Forms
@@ -15,14 +9,16 @@ namespace Flowframes.Forms
private string _text = "";
private string _title = "";
private MessageBoxButtons _btns;
private bool _monospace;
private bool _dialogResultSet = false;
public MessageForm(string text, string title, MessageBoxButtons buttons = MessageBoxButtons.OK)
public MessageForm(string text, string title, MessageBoxButtons buttons = MessageBoxButtons.OK, bool monospace = false)
{
_text = text;
_title = title;
_btns = buttons;
_monospace = monospace;
InitializeComponent();
}
@@ -32,6 +28,11 @@ namespace Flowframes.Forms
Text = _title;
textLabel.Text = _text;
if (_monospace)
{
textLabel.Font = new Font("Cascadia Code", textLabel.Font.Size, textLabel.Font.Style);
}
if(_btns == MessageBoxButtons.OK)
{
SetButtons(true, false, false);

View File

@@ -83,7 +83,7 @@ namespace Flowframes.Ui
public enum MessageType { Message, Warning, Error };
public static DialogResult ShowMessageBox(string text, MessageType type = MessageType.Message)
public static DialogResult ShowMessageBox(string text, MessageType type = MessageType.Message, bool monospace = false)
{
Logger.Log($"MessageBox: {text} ({type}){(BatchProcessing.busy ? "[Batch Mode - Will not display messagebox]" : "")}", true);
@@ -100,8 +100,8 @@ namespace Flowframes.Ui
if (type == MessageType.Warning) icon = MessageBoxIcon.Warning;
else if (type == MessageType.Error) icon = MessageBoxIcon.Error;
MessageForm form = new MessageForm(text, type.ToString()) { TopMost = true };
form.ShowDialog();
var msgForm = new MessageForm(text, type.ToString(), monospace: monospace) { TopMost = true };
Program.mainForm.Invoke(() => msgForm.ShowDialog());
return DialogResult.OK;
}