Make SSA/ASSA preview text customizable - thx Elto :)

This commit is contained in:
Nikolaj Olsson 2019-09-15 08:09:31 +02:00
parent f284256d53
commit a4a1bbdc16
5 changed files with 17 additions and 43 deletions

View File

@ -751,6 +751,7 @@ $HorzAlign = Center
public bool CheckForUpdates { get; set; }
public DateTime LastCheckForUpdates { get; set; }
public bool AutoSave { get; set; }
public string PreviewAssaText { get; set; }
public bool ShowProgress { get; set; }
public long CurrentVideoOffsetInMs { get; set; }
public bool UseDarkTheme { get; set; }
@ -857,6 +858,7 @@ $HorzAlign = Center
LastCheckForUpdates = DateTime.Now;
ShowProgress = false;
UseDarkTheme = false;
PreviewAssaText = "ABCDEFGHIJKL abcdefghijkl 123";
ShowBetaStuff = false;
NewEmptyDefaultMs = 2000;
@ -2430,6 +2432,12 @@ $HorzAlign = Center
settings.General.AutoSave = Convert.ToBoolean(subNode.InnerText.Trim());
}
subNode = node.SelectSingleNode("PreviewAssaText");
if (subNode != null)
{
settings.General.PreviewAssaText = subNode.InnerText;
}
subNode = node.SelectSingleNode("ShowProgress");
if (subNode != null)
{
@ -5927,6 +5935,7 @@ $HorzAlign = Center
textWriter.WriteElementString("CheckForUpdates", settings.General.CheckForUpdates.ToString());
textWriter.WriteElementString("LastCheckForUpdates", settings.General.LastCheckForUpdates.ToString("yyyy-MM-dd"));
textWriter.WriteElementString("AutoSave", settings.General.AutoSave.ToString());
textWriter.WriteElementString("PreviewAssaText", settings.General.PreviewAssaText);
textWriter.WriteElementString("ShowProgress", settings.General.ShowProgress.ToString());
textWriter.WriteElementString("UseDarkTheme", settings.General.UseDarkTheme.ToString());
textWriter.WriteElementString("ShowBetaStuff", settings.General.ShowBetaStuff.ToString());

View File

@ -1734,7 +1734,7 @@ namespace Nikse.SubtitleEdit.Forms
bool newLine = false;
var sb = new StringBuilder();
sb.Append("This is a test!");
sb.Append(Configuration.Settings.General.PreviewAssaText);
var measuredWidth = TextDraw.MeasureTextWidth(font, sb.ToString(), checkBoxSsaFontBold.Checked) + 1;
var measuredHeight = TextDraw.MeasureTextHeight(font, sb.ToString(), checkBoxSsaFontBold.Checked) + 1;
@ -1762,7 +1762,7 @@ namespace Nikse.SubtitleEdit.Forms
{
var shadowPath = new GraphicsPath();
sb.Clear();
sb.Append("This is a test!");
sb.Append(Configuration.Settings.General.PreviewAssaText);
int pathPointsStart2 = -1;
TextDraw.DrawText(font, sf, shadowPath, sb, false, checkBoxSsaFontBold.Checked, false, left + i + outline, top + i + outline, ref newLine, leftMargin, ref pathPointsStart2);
g.FillPath(new SolidBrush(Color.FromArgb(200, Color.Black)), shadowPath);

View File

@ -207,7 +207,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
bool newLine = false;
var sb = new StringBuilder();
sb.Append("This is a test!");
sb.Append(Configuration.Settings.General.PreviewAssaText);
var measuredWidth = TextDraw.MeasureTextWidth(font, sb.ToString(), checkBoxFontBold.Checked) + 1;
var measuredHeight = TextDraw.MeasureTextHeight(font, sb.ToString(), checkBoxFontBold.Checked) + 1;
@ -219,11 +219,11 @@ namespace Nikse.SubtitleEdit.Forms.Styles
}
else if (radioButtonTopRight.Checked || radioButtonMiddleRight.Checked || radioButtonBottomRight.Checked)
{
left = bmp.Width - (measuredWidth + ((float)numericUpDownMarginRight.Value));
left = bmp.Width - (measuredWidth + (float)numericUpDownMarginRight.Value);
}
else
{
left = (float)(bmp.Width - measuredWidth * 0.8 + 15) / 2;
left = (bmp.Width - measuredWidth) / 2;
}
float top;

View File

@ -1080,7 +1080,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
bool newLine = false;
var sb = new StringBuilder();
sb.Append("This is a test!");
sb.Append(Configuration.Settings.General.PreviewAssaText);
var measuredWidth = TextDraw.MeasureTextWidth(font, sb.ToString(), checkBoxFontBold.Checked) + 1;
var measuredHeight = TextDraw.MeasureTextHeight(font, sb.ToString(), checkBoxFontBold.Checked) + 1;
@ -1096,7 +1096,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
}
else
{
left = ((float)(bmp.Width - measuredWidth * 0.8 + 15) / 2);
left = (bmp.Width - measuredWidth) / 2;
}
float top;

View File

@ -138,49 +138,14 @@ namespace Nikse.SubtitleEdit.Forms.Styles
g.SmoothingMode = SmoothingMode.AntiAlias;
var sf = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near };
var path = new GraphicsPath();
bool newLine = false;
var sb = new StringBuilder();
sb.Append("This is a test!");
var measuredWidth = TextDraw.MeasureTextWidth(font, sb.ToString(), comboBoxFontWeight.Text == "bold") + 1;
var measuredHeight = TextDraw.MeasureTextHeight(font, sb.ToString(), comboBoxFontWeight.Text == "bold") + 1;
sb.Append(Configuration.Settings.General.PreviewAssaText);
const float left = 5f;
//if (radioButtonTopLeft.Checked || radioButtonMiddleLeft.Checked || radioButtonBottomLeft.Checked)
// left = (float)numericUpDownMarginLeft.Value;
//else if (radioButtonTopRight.Checked || radioButtonMiddleRight.Checked || radioButtonBottomRight.Checked)
// left = bmp.Width - (measuredWidth + ((float)numericUpDownMarginRight.Value));
//else
// left = ((float)(bmp.Width - measuredWidth * 0.8 + 15) / 2);
const float top = 2f;
//if (radioButtonTopLeft.Checked || radioButtonTopCenter.Checked || radioButtonTopRight.Checked)
// top = (float)numericUpDownMarginVertical.Value;
//else if (radioButtonMiddleLeft.Checked || radioButtonMiddleCenter.Checked || radioButtonMiddleRight.Checked)
// top = (bmp.Height - measuredHeight) / 2;
//else
// top = bmp.Height - measuredHeight - ((int)numericUpDownMarginVertical.Value);
const int leftMargin = 0;
int pathPointsStart = -1;
//if (radioButtonOpaqueBox.Checked)
//{
// if (_isSubStationAlpha)
// g.FillRectangle(new SolidBrush(panelBackColor.BackColor), left, top, measuredWidth + 3, measuredHeight + 3);
// else
// g.FillRectangle(new SolidBrush(panelOutlineColor.BackColor), left, top, measuredWidth + 3, measuredHeight + 3);
//}
TextDraw.DrawText(font, sf, path, sb, comboBoxFontStyle.Text == "italic", comboBoxFontWeight.Text == "bold", false, left, top, ref newLine, leftMargin, ref pathPointsStart);
//int outline = 0; // (int)numericUpDownOutline.Value;
//if (outline > 0)
//{
// Color outlineColor = Color.White;
// g.DrawPath(new Pen(outlineColor, outline), path);
//}
g.FillPath(new SolidBrush(panelFontColor.BackColor), path);
}
pictureBoxPreview.Image = bmp;