mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 08:27:44 +01:00
Monospace option for MessageForm
This commit is contained in:
@@ -1,11 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Flowframes.Forms
|
namespace Flowframes.Forms
|
||||||
@@ -15,14 +9,16 @@ namespace Flowframes.Forms
|
|||||||
private string _text = "";
|
private string _text = "";
|
||||||
private string _title = "";
|
private string _title = "";
|
||||||
private MessageBoxButtons _btns;
|
private MessageBoxButtons _btns;
|
||||||
|
private bool _monospace;
|
||||||
|
|
||||||
private bool _dialogResultSet = false;
|
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;
|
_text = text;
|
||||||
_title = title;
|
_title = title;
|
||||||
_btns = buttons;
|
_btns = buttons;
|
||||||
|
_monospace = monospace;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
@@ -32,6 +28,11 @@ namespace Flowframes.Forms
|
|||||||
Text = _title;
|
Text = _title;
|
||||||
textLabel.Text = _text;
|
textLabel.Text = _text;
|
||||||
|
|
||||||
|
if (_monospace)
|
||||||
|
{
|
||||||
|
textLabel.Font = new Font("Cascadia Code", textLabel.Font.Size, textLabel.Font.Style);
|
||||||
|
}
|
||||||
|
|
||||||
if(_btns == MessageBoxButtons.OK)
|
if(_btns == MessageBoxButtons.OK)
|
||||||
{
|
{
|
||||||
SetButtons(true, false, false);
|
SetButtons(true, false, false);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace Flowframes.Ui
|
|||||||
|
|
||||||
public enum MessageType { Message, Warning, Error };
|
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);
|
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;
|
if (type == MessageType.Warning) icon = MessageBoxIcon.Warning;
|
||||||
else if (type == MessageType.Error) icon = MessageBoxIcon.Error;
|
else if (type == MessageType.Error) icon = MessageBoxIcon.Error;
|
||||||
|
|
||||||
MessageForm form = new MessageForm(text, type.ToString()) { TopMost = true };
|
var msgForm = new MessageForm(text, type.ToString(), monospace: monospace) { TopMost = true };
|
||||||
form.ShowDialog();
|
Program.mainForm.Invoke(() => msgForm.ShowDialog());
|
||||||
return DialogResult.OK;
|
return DialogResult.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user