Do not show save message with text box - thx Pasco :)

This commit is contained in:
Nikolaj Olsson 2024-09-19 07:51:24 +02:00
parent 9ae93c4d49
commit dbe07ab735
4 changed files with 38 additions and 9 deletions

View File

@ -106,7 +106,8 @@ namespace Nikse.SubtitleEdit.Forms
{
System.Diagnostics.Debug.WriteLine("EbuOptions unable to read existing file: " + fileName + " - " + ex.Message);
}
string title = Path.GetFileNameWithoutExtension(fileName);
var title = Path.GetFileNameWithoutExtension(fileName);
if (title.Length > 32)
{
title = title.Substring(0, 32).Trim();

View File

@ -2508,7 +2508,7 @@ namespace Nikse.SubtitleEdit.Forms
promptText = string.Format(_language.SaveChangesToX, _fileName);
}
var dr = MessageBox.Show(this, promptText, Title, MessageBoxButtons.YesNoCancel);
var dr = MessageBox.Show(this, promptText, Title, MessageBoxButtons.YesNoCancel, true);
if (dr == DialogResult.Cancel)
{

View File

@ -52,6 +52,14 @@ namespace Nikse.SubtitleEdit.Forms.SeMsgBox
}
}
public static DialogResult Show(Form form, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, bool noTextBox)
{
using (var msgBox = new MessageBoxForm(text, caption, buttons, icon))
{
return msgBox.ShowDialog(form);
}
}
internal static DialogResult Show(Form form, string text, string title, MessageBoxButtons buttons)
{
using (var msgBox = new MessageBoxForm(text, title, buttons))
@ -60,6 +68,15 @@ namespace Nikse.SubtitleEdit.Forms.SeMsgBox
}
}
internal static DialogResult Show(Form form, string text, string title, MessageBoxButtons buttons, bool noTextBox)
{
using (var msgBox = new MessageBoxForm(text, title, buttons, noTextBox))
{
return msgBox.ShowDialog(form);
}
}
internal static DialogResult Show(string text, string caption)
{
using (var msgBox = new MessageBoxForm(text, caption, MessageBoxButtons.OK))

View File

@ -17,7 +17,13 @@ namespace Nikse.SubtitleEdit.Forms.SeMsgBox
public MessageBoxForm(string text, string caption, MessageBoxButtons buttons)
{
var icon = AutoGuessIcon(text, buttons);
Init(text, caption, buttons, icon);
Init(text, caption, buttons, icon, false);
}
public MessageBoxForm(string text, string caption, MessageBoxButtons buttons, bool noTextBox)
{
var icon = AutoGuessIcon(text, buttons);
Init(text, caption, buttons, icon, noTextBox);
}
private static MessageBoxIcon AutoGuessIcon(string text, MessageBoxButtons buttons)
@ -37,10 +43,15 @@ namespace Nikse.SubtitleEdit.Forms.SeMsgBox
public MessageBoxForm(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
{
Init(text, caption, buttons, icon);
Init(text, caption, buttons, icon, false);
}
private void Init(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
public MessageBoxForm(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, bool noTextBox)
{
Init(text, caption, buttons, icon, noTextBox);
}
private void Init(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, bool noTextBox)
{
UiUtil.PreInitialize(this);
InitializeComponent();
@ -59,7 +70,7 @@ namespace Nikse.SubtitleEdit.Forms.SeMsgBox
buttonAbort.Text = LanguageSettings.Current.DvdSubRip.Abort;
InitializeIcon(icon);
InitializeText(text);
InitializeText(text, noTextBox);
InitializeButtons(buttons);
UiUtil.FixLargeFonts(this, buttonOK);
@ -121,14 +132,14 @@ namespace Nikse.SubtitleEdit.Forms.SeMsgBox
}
}
private void InitializeText(string text)
private void InitializeText(string text, bool noTextBox)
{
if (text == null)
{
text = string.Empty;
}
if (ShouldSwitchToTextBox(text))
if (!noTextBox && ShouldSwitchToTextBox(text))
{
seTextBox2.ReadOnly = true;
seTextBox2.Text = text;
@ -151,7 +162,7 @@ namespace Nikse.SubtitleEdit.Forms.SeMsgBox
labelText.Text = text;
}
private bool ShouldSwitchToTextBox(string text)
private static bool ShouldSwitchToTextBox(string text)
{
if (text.Length > 500)
{