mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-15 16:07:45 +01:00
Monospace option for MessageForm
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user