Export style now possible from 'SSA/ASS style' window - thx vicgol :)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1735 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2013-03-14 09:35:36 +00:00
parent e50f3e4a6b
commit aec2e40e36
10 changed files with 96 additions and 4 deletions

View File

@ -98,6 +98,8 @@
this.colorDialogSSAStyle = new System.Windows.Forms.ColorDialog(); this.colorDialogSSAStyle = new System.Windows.Forms.ColorDialog();
this.openFileDialogImport = new System.Windows.Forms.OpenFileDialog(); this.openFileDialogImport = new System.Windows.Forms.OpenFileDialog();
this.saveFileDialogStyle = new System.Windows.Forms.SaveFileDialog(); this.saveFileDialogStyle = new System.Windows.Forms.SaveFileDialog();
this.labelStatus = new System.Windows.Forms.Label();
this.timerClearStatus = new System.Windows.Forms.Timer(this.components);
this.contextMenuStripStyles.SuspendLayout(); this.contextMenuStripStyles.SuspendLayout();
this.groupBoxStyles.SuspendLayout(); this.groupBoxStyles.SuspendLayout();
this.groupBoxProperties.SuspendLayout(); this.groupBoxProperties.SuspendLayout();
@ -840,11 +842,26 @@
// //
this.saveFileDialogStyle.OverwritePrompt = false; this.saveFileDialogStyle.OverwritePrompt = false;
// //
// labelStatus
//
this.labelStatus.AutoSize = true;
this.labelStatus.Location = new System.Drawing.Point(15, 577);
this.labelStatus.Name = "labelStatus";
this.labelStatus.Size = new System.Drawing.Size(59, 13);
this.labelStatus.TabIndex = 6;
this.labelStatus.Text = "labelStatus";
//
// timerClearStatus
//
this.timerClearStatus.Interval = 9000;
this.timerClearStatus.Tick += new System.EventHandler(this.timerClearStatus_Tick);
//
// SubStationAlphaStyles // SubStationAlphaStyles
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(982, 602); this.ClientSize = new System.Drawing.Size(982, 602);
this.Controls.Add(this.labelStatus);
this.Controls.Add(this.groupBoxProperties); this.Controls.Add(this.groupBoxProperties);
this.Controls.Add(this.groupBoxStyles); this.Controls.Add(this.groupBoxStyles);
this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonCancel);
@ -885,6 +902,7 @@
this.groupBoxPreview.ResumeLayout(false); this.groupBoxPreview.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
@ -959,5 +977,7 @@
private System.Windows.Forms.ColumnHeader columnHeaderUseCount; private System.Windows.Forms.ColumnHeader columnHeaderUseCount;
private System.Windows.Forms.Button buttonExport; private System.Windows.Forms.Button buttonExport;
private System.Windows.Forms.SaveFileDialog saveFileDialogStyle; private System.Windows.Forms.SaveFileDialog saveFileDialogStyle;
private System.Windows.Forms.Label labelStatus;
private System.Windows.Forms.Timer timerClearStatus;
} }
} }

View File

@ -25,6 +25,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
InitializeComponent(); InitializeComponent();
labelStatus.Text = string.Empty;
Header = subtitle.Header; Header = subtitle.Header;
_format = format; _format = format;
_isSubStationAlpha = _format.FriendlyName == new SubStationAlpha().FriendlyName; _isSubStationAlpha = _format.FriendlyName == new SubStationAlpha().FriendlyName;
@ -308,6 +309,22 @@ namespace Nikse.SubtitleEdit.Forms
subItem.BackColor = ssaStyle.Background; subItem.BackColor = ssaStyle.Background;
else else
subItem.BackColor = ssaStyle.Outline; subItem.BackColor = ssaStyle.Outline;
subItem.Text = Configuration.Settings.Language.General.Text;
subItem.ForeColor = ssaStyle.Primary;
try
{
if (ssaStyle.Bold || ssaStyle.Italic)
subItem.Font = new Font(ssaStyle.FontName, subItem.Font.Size, FontStyle.Bold | FontStyle.Italic);
else if (ssaStyle.Bold)
subItem.Font = new Font(ssaStyle.FontName, subItem.Font.Size, FontStyle.Bold);
else if (ssaStyle.Italic)
subItem.Font = new Font(ssaStyle.FontName, subItem.Font.Size, FontStyle.Italic);
else if (ssaStyle.Italic)
subItem.Font = new Font(ssaStyle.FontName, subItem.Font.Size, FontStyle.Regular);
}
catch
{
}
item.SubItems.Add(subItem); item.SubItems.Add(subItem);
lv.Items.Add(item); lv.Items.Add(item);
@ -570,7 +587,8 @@ namespace Nikse.SubtitleEdit.Forms
colorDialogSSAStyle.Color = panelPrimaryColor.BackColor; colorDialogSSAStyle.Color = panelPrimaryColor.BackColor;
if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK) if (colorDialogSSAStyle.ShowDialog() == DialogResult.OK)
{ {
listViewStyles.SelectedItems[0].SubItems[3].BackColor = colorDialogSSAStyle.Color; listViewStyles.SelectedItems[0].SubItems[4].BackColor = colorDialogSSAStyle.Color;
listViewStyles.SelectedItems[0].SubItems[5].ForeColor = colorDialogSSAStyle.Color;
panelPrimaryColor.BackColor = colorDialogSSAStyle.Color; panelPrimaryColor.BackColor = colorDialogSSAStyle.Color;
string name = listViewStyles.SelectedItems[0].Text; string name = listViewStyles.SelectedItems[0].Text;
SetSsaStyle(name, "primarycolour", GetSsaColorString(colorDialogSSAStyle.Color)); SetSsaStyle(name, "primarycolour", GetSsaColorString(colorDialogSSAStyle.Color));
@ -1173,6 +1191,10 @@ namespace Nikse.SubtitleEdit.Forms
_doUpdate = true; _doUpdate = true;
SetControlsFromStyle(style); SetControlsFromStyle(style);
listViewStyles_SelectedIndexChanged(null, null); listViewStyles_SelectedIndexChanged(null, null);
if (!string.IsNullOrEmpty(Configuration.Settings.Language.SubStationAlphaStyles.StyleXImportedFromFileY)) // TODO: Remove in 3.4
labelStatus.Text = string.Format(Configuration.Settings.Language.SubStationAlphaStyles.StyleXImportedFromFileY, style.Name, openFileDialogImport.FileName);
timerClearStatus.Start();
} }
} }
} }
@ -1209,17 +1231,19 @@ namespace Nikse.SubtitleEdit.Forms
if (saveFileDialogStyle.ShowDialog(this) == DialogResult.OK) if (saveFileDialogStyle.ShowDialog(this) == DialogResult.OK)
{ {
if (System.IO.File.Exists(saveFileDialogStyle.FileName)) if (System.IO.File.Exists(saveFileDialogStyle.FileName))
{ {
Encoding encoding = null; Encoding encoding = null;
var s = new Subtitle(); var s = new Subtitle();
var format = s.LoadSubtitle(saveFileDialogStyle.FileName, out encoding, null); var format = s.LoadSubtitle(saveFileDialogStyle.FileName, out encoding, null);
if (format == null) if (format == null)
{ {
MessageBox.Show("Not subtitle format: " + _format.Name); MessageBox.Show("Not subtitle format: " + _format.Name);
return;
} }
else if (format.Name != _format.Name) else if (format.Name != _format.Name)
{ {
MessageBox.Show(string.Format("Cannot save {1} style in {0} file!", format.Name, _format.Name)); MessageBox.Show(string.Format("Cannot save {1} style in {0} file!", format.Name, _format.Name));
return;
} }
else else
{ {
@ -1251,6 +1275,11 @@ namespace Nikse.SubtitleEdit.Forms
} }
} }
sb.AppendLine(line); sb.AppendLine(line);
if (stylesOn && line.Replace(" ", string.Empty).Trim().ToLower().StartsWith("style:" + styleName.Replace(" ", string.Empty).Trim().ToLower() + ","))
{
MessageBox.Show(string.Format(Configuration.Settings.Language.SubStationAlphaStyles.StyleAlreadyExits, styleName));
return;
}
} }
System.IO.File.WriteAllText(saveFileDialogStyle.FileName, sb.ToString(), Encoding.UTF8); System.IO.File.WriteAllText(saveFileDialogStyle.FileName, sb.ToString(), Encoding.UTF8);
} }
@ -1280,6 +1309,16 @@ namespace Nikse.SubtitleEdit.Forms
System.IO.File.WriteAllText(saveFileDialogStyle.FileName, content, Encoding.UTF8); System.IO.File.WriteAllText(saveFileDialogStyle.FileName, content, Encoding.UTF8);
} }
} }
if (!string.IsNullOrEmpty(Configuration.Settings.Language.SubStationAlphaStyles.StyleXImportedFromFileY)) // TODO: Remove in 3.4
labelStatus.Text = string.Format(Configuration.Settings.Language.SubStationAlphaStyles.StyleXExportedToFileY, styleName, saveFileDialogStyle.FileName);
timerClearStatus.Start();
} }
private void timerClearStatus_Tick(object sender, EventArgs e)
{
timerClearStatus.Stop();
labelStatus.Text = string.Empty;
}
} }
} }

View File

@ -129,4 +129,7 @@
<metadata name="saveFileDialogStyle.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="saveFileDialogStyle.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>529, 17</value> <value>529, 17</value>
</metadata> </metadata>
<metadata name="timerClearStatus.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>685, 17</value>
</metadata>
</root> </root>

View File

@ -2052,6 +2052,7 @@ namespace Nikse.SubtitleEdit.Forms
textWriter.WriteAttributeString("Text", oc.Text); textWriter.WriteAttributeString("Text", oc.Text);
textWriter.WriteAttributeString("Width", oc.Width.ToString(CultureInfo.InvariantCulture)); textWriter.WriteAttributeString("Width", oc.Width.ToString(CultureInfo.InvariantCulture));
textWriter.WriteAttributeString("Height", oc.Height.ToString(CultureInfo.InvariantCulture)); textWriter.WriteAttributeString("Height", oc.Height.ToString(CultureInfo.InvariantCulture));
textWriter.WriteAttributeString("MarginTop", oc.MarginTop.ToString(CultureInfo.InvariantCulture));
foreach (NOcrPoint op in oc.LinesForeground) foreach (NOcrPoint op in oc.LinesForeground)
{ {
textWriter.WriteStartElement("Point", ""); textWriter.WriteStartElement("Point", "");
@ -2095,6 +2096,7 @@ namespace Nikse.SubtitleEdit.Forms
var oc = new NOcrChar(node.Attributes["Text"].Value); var oc = new NOcrChar(node.Attributes["Text"].Value);
oc.Width = Convert.ToInt32(node.Attributes["Width"].Value, CultureInfo.InvariantCulture); oc.Width = Convert.ToInt32(node.Attributes["Width"].Value, CultureInfo.InvariantCulture);
oc.Height = Convert.ToInt32(node.Attributes["Height"].Value, CultureInfo.InvariantCulture); oc.Height = Convert.ToInt32(node.Attributes["Height"].Value, CultureInfo.InvariantCulture);
oc.MarginTop = Convert.ToInt32(node.Attributes["MarginTop"].Value, CultureInfo.InvariantCulture);
foreach (XmlNode pointNode in node.SelectNodes("Point")) foreach (XmlNode pointNode in node.SelectNodes("Point"))
{ {
var op = new NOcrPoint(DecodePoint(pointNode.Attributes["Start"].Value), DecodePoint(pointNode.Attributes["End"].Value)); var op = new NOcrPoint(DecodePoint(pointNode.Attributes["Start"].Value), DecodePoint(pointNode.Attributes["End"].Value));

View File

@ -134,6 +134,7 @@
this.textBoxCharacters.Name = "textBoxCharacters"; this.textBoxCharacters.Name = "textBoxCharacters";
this.textBoxCharacters.Size = new System.Drawing.Size(107, 20); this.textBoxCharacters.Size = new System.Drawing.Size(107, 20);
this.textBoxCharacters.TabIndex = 22; this.textBoxCharacters.TabIndex = 22;
this.textBoxCharacters.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxCharacters_KeyDown);
// //
// buttonOK // buttonOK
// //

View File

@ -25,6 +25,7 @@ namespace Nikse.SubtitleEdit.Forms
int _imageHeight; int _imageHeight;
int _mx; int _mx;
int _my; int _my;
bool _warningNoNotForegroundLinesShown = false;
public VobSubOcrNOcrCharacter() public VobSubOcrNOcrCharacter()
{ {
@ -77,9 +78,11 @@ namespace Nikse.SubtitleEdit.Forms
_vobSubForm = vobSubForm; _vobSubForm = vobSubForm;
_additions = additions; _additions = additions;
_nocrChar = new NOcrChar(); _nocrChar = new NOcrChar();
_nocrChar.MarginTop = character.Y;
_imageWidth = character.Bitmap.Width; _imageWidth = character.Bitmap.Width;
_imageHeight = character.Bitmap.Height; _imageHeight = character.Bitmap.Height;
_drawLineOn = false; _drawLineOn = false;
_warningNoNotForegroundLinesShown = false;
buttonShrinkSelection.Visible = showShrink; buttonShrinkSelection.Visible = showShrink;
@ -161,9 +164,10 @@ namespace Nikse.SubtitleEdit.Forms
MessageBox.Show("No foreground lines!"); MessageBox.Show("No foreground lines!");
return; return;
} }
if (listBoxlinesBackground.Items.Count == 0) if (listBoxlinesBackground.Items.Count == 0 && !_warningNoNotForegroundLinesShown)
{ {
MessageBox.Show("No not-foreground lines!"); MessageBox.Show("No not-foreground lines!");
_warningNoNotForegroundLinesShown = true;
return; return;
} }
if (textBoxCharacters.Text.Length == 0) if (textBoxCharacters.Text.Length == 0)
@ -333,5 +337,14 @@ namespace Nikse.SubtitleEdit.Forms
ShowOcrPoints(); ShowOcrPoints();
} }
private void textBoxCharacters_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
e.SuppressKeyPress = true;
buttonOK_Click(null, null);
}
}
} }
} }

View File

@ -146,6 +146,7 @@ E-mail: mailto:nikse.dk@gmail.com</AboutText1>
<ConvertOptions>Konverter indstillinger</ConvertOptions> <ConvertOptions>Konverter indstillinger</ConvertOptions>
<RemoveFormatting>Fjern formaterings- tags</RemoveFormatting> <RemoveFormatting>Fjern formaterings- tags</RemoveFormatting>
<RemoveTextForHI>fjerne tekst for høre-hæmmede</RemoveTextForHI> <RemoveTextForHI>fjerne tekst for høre-hæmmede</RemoveTextForHI>
<OverwriteOriginalFiles>Overskriv originale filer (kun hvis format ikke ændres)</OverwriteOriginalFiles>
<ReDoCasing>Sæt store/små bogstaver</ReDoCasing> <ReDoCasing>Sæt store/små bogstaver</ReDoCasing>
<Convert>Konverter</Convert> <Convert>Konverter</Convert>
<NothingToConvert>Intet at konvertere!</NothingToConvert> <NothingToConvert>Intet at konvertere!</NothingToConvert>
@ -154,6 +155,9 @@ E-mail: mailto:nikse.dk@gmail.com</AboutText1>
<ConvertedX>Konverteret ({0})</ConvertedX> <ConvertedX>Konverteret ({0})</ConvertedX>
<Settings>Indstillinger</Settings> <Settings>Indstillinger</Settings>
<AutoBalance>Auto-balancer linjer</AutoBalance> <AutoBalance>Auto-balancer linjer</AutoBalance>
<ScanFolder>Scan mappe...</ScanFolder>
<ScanningFolder>Scanner {0} og undermapper for undertekster...</ScanningFolder>
<Recursive>Medtag undermapper</Recursive>
</BatchConvert> </BatchConvert>
<Beamer> <Beamer>
<Title>Undertekst fremviser</Title> <Title>Undertekst fremviser</Title>
@ -1587,6 +1591,9 @@ Fortsæt?</SubtitleAppendPrompt>
<ImportStyleFromFile>Importer style fra fil...</ImportStyleFromFile> <ImportStyleFromFile>Importer style fra fil...</ImportStyleFromFile>
<ExportStyleToFile>Export style til fil...</ExportStyleToFile> <ExportStyleToFile>Export style til fil...</ExportStyleToFile>
<ChooseStyle>Vælg style der skal importeres</ChooseStyle> <ChooseStyle>Vælg style der skal importeres</ChooseStyle>
<StyleAlreadyExits>Style findes allerede: {0}</StyleAlreadyExits>
<StyleXExportedToFileY>Style '{0}' eksporteret til '{1}'</StyleXExportedToFileY>
<StyleXImportedFromFileY>Style '{0}' importeret fra '{1}'</StyleXImportedFromFileY>
</SubStationAlphaStyles> </SubStationAlphaStyles>
<PointSync> <PointSync>
<Title>Punkt synkronisering</Title> <Title>Punkt synkronisering</Title>

View File

@ -267,7 +267,7 @@ namespace Nikse.SubtitleEdit.Logic
OverwriteOriginalFiles = "Overwrite original files (new extension if format is changed)", OverwriteOriginalFiles = "Overwrite original files (new extension if format is changed)",
ScanFolder = "Scan folder...", ScanFolder = "Scan folder...",
ScanningFolder = "Scanning {0} and subfolders for subtitle files...", ScanningFolder = "Scanning {0} and subfolders for subtitle files...",
Recursive = "Resursive", Recursive = "Include sub folders",
}; };
Beamer = new LanguageStructure.Beamer Beamer = new LanguageStructure.Beamer
@ -1847,6 +1847,9 @@ can edit in same subtitle file (collaboration)",
ImportStyleFromFile = "Import style from file...", ImportStyleFromFile = "Import style from file...",
ExportStyleToFile = "Export style to file... (will add style if file already exists)", ExportStyleToFile = "Export style to file... (will add style if file already exists)",
ChooseStyle = "Choose style to import", ChooseStyle = "Choose style to import",
StyleAlreadyExits = "Style already exists: {0}",
StyleXExportedToFileY = "Style '{0}' exported to file '{1}'",
StyleXImportedFromFileY = "Style '{0}' imported from file '{1}'",
}; };
PointSync = new LanguageStructure.PointSync PointSync = new LanguageStructure.PointSync

View File

@ -1752,6 +1752,9 @@
public string ImportStyleFromFile { get; set; } public string ImportStyleFromFile { get; set; }
public string ExportStyleToFile { get; set; } public string ExportStyleToFile { get; set; }
public string ChooseStyle { get; set; } public string ChooseStyle { get; set; }
public string StyleAlreadyExits { get; set; }
public string StyleXExportedToFileY { get; set; }
public string StyleXImportedFromFileY { get; set; }
} }
public class PointSync public class PointSync

View File

@ -8,6 +8,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR
public string Text { get; set; } public string Text { get; set; }
public int Width { get; set; } public int Width { get; set; }
public int Height { get; set; } public int Height { get; set; }
public int MarginTop { get; set; }
public List<NOcrPoint> LinesForeground { get; private set; } public List<NOcrPoint> LinesForeground { get; private set; }
public List<NOcrPoint> LinesBackground { get; private set; } public List<NOcrPoint> LinesBackground { get; private set; }
public string Id { get; set; } public string Id { get; set; }