public void SsaSimpleFontColorAndItalic() { var target = new SubStationAlpha(); var subtitle = new Subtitle(); target.LoadSubtitle(subtitle, GetSsaLines(@"{\c&HFFFF00&\i1}CYAN{\i0}"), null); string actual = subtitle.Paragraphs[0].Text; const string expected = "<font color=\"#00ffff\"><i>CYAN</i></font>"; Assert.AreEqual(expected, actual); }
private void buttonRemoveAll_Click(object sender, EventArgs e) { listViewStyles.Items.Clear(); var sub = new Subtitle(); if (_isSubStationAlpha) { var ssa = new SubStationAlpha(); string text = ssa.ToText(sub, string.Empty); string[] lineArray = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); var lines = new List<string>(); foreach (string line in lineArray) lines.Add(line); ssa.LoadSubtitle(sub, lines, string.Empty); Header = Header.Remove(Header.IndexOf("[V4 Styles]")) + sub.Header.Substring(sub.Header.IndexOf("[V4 Styles]")); } else { var ass = new AdvancedSubStationAlpha(); string text = ass.ToText(sub, string.Empty); string[] lineArray = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); var lines = new List<string>(); foreach (string line in lineArray) lines.Add(line); ass.LoadSubtitle(sub, lines, string.Empty); Header = Header.Remove(Header.IndexOf("[V4+ Styles]")) + sub.Header.Substring(sub.Header.IndexOf("[V4+ Styles]")); } InitializeListView(); }
public SubStationAlphaProperties(Subtitle subtitle, SubtitleFormat format, string videoFileName, string subtitleFileName) { InitializeComponent(); _subtitle = subtitle; _isSubStationAlpha = format.FriendlyName == new SubStationAlpha().FriendlyName; _videoFileName = videoFileName; var l = Configuration.Settings.Language.SubStationAlphaProperties; if (_isSubStationAlpha) { Text = l.TitleSubstationAlpha; labelWrapStyle.Visible = false; comboBoxWrapStyle.Visible = false; checkBoxScaleBorderAndShadow.Visible = false; Height = Height - (comboBoxWrapStyle.Height + checkBoxScaleBorderAndShadow.Height + 8); } else { Text = l.Title; } comboBoxWrapStyle.SelectedIndex = 2; comboBoxCollision.SelectedIndex = 0; string header = subtitle.Header; if (subtitle.Header == null) { SubStationAlpha ssa = new SubStationAlpha(); var sub = new Subtitle(); var lines = new List<string>(); foreach (string line in subtitle.ToText(ssa).Replace(Environment.NewLine, "\n").Split('\n')) lines.Add(line); string title = "Untitled"; if (!string.IsNullOrEmpty(subtitleFileName)) title = Path.GetFileNameWithoutExtension(subtitleFileName); else if (!string.IsNullOrEmpty(videoFileName)) title = Path.GetFileNameWithoutExtension(videoFileName); ssa.LoadSubtitle(sub, lines, title); header = sub.Header; } if (header != null) { foreach (string line in header.Split(Utilities.NewLineChars, StringSplitOptions.RemoveEmptyEntries)) { string s = line.ToLower().Trim(); if (s.StartsWith("title:")) { textBoxTitle.Text = s.Remove(0, 6).Trim(); } else if (s.StartsWith("original script:")) { textBoxOriginalScript.Text = s.Remove(0, 16).Trim(); } else if (s.StartsWith("original translation:")) { textBoxTranslation.Text = s.Remove(0, 21).Trim(); } else if (s.StartsWith("original editing:")) { textBoxEditing.Text = s.Remove(0, 17).Trim(); } else if (s.StartsWith("original timing:")) { textBoxTiming.Text = s.Remove(0, 16).Trim(); } else if (s.StartsWith("synch point:")) { textBoxSyncPoint.Text = s.Remove(0, 12).Trim(); } else if (s.StartsWith("script updated by:")) { textBoxUpdatedBy.Text = s.Remove(0, 18).Trim(); } else if (s.StartsWith("update details:")) { textBoxUpdateDetails.Text = s.Remove(0, 15).Trim(); } else if (s.StartsWith("collisions:")) { if (s.Remove(0, 11).Trim() == "reverse") comboBoxCollision.SelectedIndex = 1; } else if (s.StartsWith("playresx:")) { int number; if (int.TryParse(s.Remove(0, 9).Trim(), out number)) numericUpDownVideoWidth.Value = number; } else if (s.StartsWith("playresy:")) { int number; if (int.TryParse(s.Remove(0, 9).Trim(), out number)) numericUpDownVideoHeight.Value = number; } else if (s.StartsWith("scaledborderandshadow:")) { checkBoxScaleBorderAndShadow.Checked = s.Remove(0, 22).Trim().ToLower() == "yes"; } } } groupBoxScript.Text = l.Script; labelTitle.Text = l.ScriptTitle; labelOriginalScript.Text = l.OriginalScript; labelTranslation.Text = l.Translation; labelEditing.Text = l.Editing; labelTiming.Text = l.Timing; labelSyncPoint.Text = l.SyncPoint; labelUpdatedBy.Text = l.UpdatedBy; labelUpdateDetails.Text = l.UpdateDetails; groupBoxResolution.Text = l.Resolution; labelVideoResolution.Text = l.VideoResolution; groupBoxOptions.Text = l.Options; labelCollision.Text = l.Collision; labelWrapStyle.Text = l.WrapStyle; checkBoxScaleBorderAndShadow.Text = l.ScaleBorderAndShadow; buttonOK.Text = Configuration.Settings.Language.General.Ok; buttonCancel.Text = Configuration.Settings.Language.General.Cancel; FixLargeFonts(); }
/// <summary> /// Initializes a new instance of the <see cref="SubStationAlphaProperties"/> class. /// </summary> /// <param name="subtitle"> /// The subtitle. /// </param> /// <param name="format"> /// The format. /// </param> /// <param name="videoFileName"> /// The video file name. /// </param> /// <param name="subtitleFileName"> /// The subtitle file name. /// </param> public SubStationAlphaProperties(Subtitle subtitle, SubtitleFormat format, string videoFileName, string subtitleFileName) { this.InitializeComponent(); this._subtitle = subtitle; this._isSubStationAlpha = format.Name == SubStationAlpha.NameOfFormat; this._videoFileName = videoFileName; var l = Configuration.Settings.Language.SubStationAlphaProperties; if (this._isSubStationAlpha) { this.Text = l.TitleSubstationAlpha; this.labelWrapStyle.Visible = false; this.comboBoxWrapStyle.Visible = false; this.checkBoxScaleBorderAndShadow.Visible = false; this.Height = this.Height - (this.comboBoxWrapStyle.Height + this.checkBoxScaleBorderAndShadow.Height + 8); } else { this.Text = l.Title; } this.comboBoxWrapStyle.SelectedIndex = 2; this.comboBoxCollision.SelectedIndex = 0; string header = subtitle.Header; if (subtitle.Header == null) { var ssa = new SubStationAlpha(); var sub = new Subtitle(); var lines = new List<string>(); foreach (string line in subtitle.ToText(ssa).SplitToLines()) { lines.Add(line); } string title = "Untitled"; if (!string.IsNullOrEmpty(subtitleFileName)) { title = Path.GetFileNameWithoutExtension(subtitleFileName); } else if (!string.IsNullOrEmpty(videoFileName)) { title = Path.GetFileNameWithoutExtension(videoFileName); } ssa.LoadSubtitle(sub, lines, title); header = sub.Header; } if (header != null) { foreach (string line in header.SplitToLines()) { string s = line.ToLowerInvariant().Trim(); if (s.StartsWith("title:")) { this.textBoxTitle.Text = s.Remove(0, 6).Trim(); } else if (s.StartsWith("original script:")) { this.textBoxOriginalScript.Text = s.Remove(0, 16).Trim(); } else if (s.StartsWith("original translation:")) { this.textBoxTranslation.Text = s.Remove(0, 21).Trim(); } else if (s.StartsWith("original editing:")) { this.textBoxEditing.Text = s.Remove(0, 17).Trim(); } else if (s.StartsWith("original timing:")) { this.textBoxTiming.Text = s.Remove(0, 16).Trim(); } else if (s.StartsWith("synch point:")) { this.textBoxSyncPoint.Text = s.Remove(0, 12).Trim(); } else if (s.StartsWith("script updated by:")) { this.textBoxUpdatedBy.Text = s.Remove(0, 18).Trim(); } else if (s.StartsWith("update details:")) { this.textBoxUpdateDetails.Text = s.Remove(0, 15).Trim(); } else if (s.StartsWith("collisions:")) { if (s.Remove(0, 11).Trim() == "reverse") { this.comboBoxCollision.SelectedIndex = 1; } } else if (s.StartsWith("playresx:")) { int number; if (int.TryParse(s.Remove(0, 9).Trim(), out number)) { this.numericUpDownVideoWidth.Value = number; } } else if (s.StartsWith("playresy:")) { int number; if (int.TryParse(s.Remove(0, 9).Trim(), out number)) { this.numericUpDownVideoHeight.Value = number; } } else if (s.StartsWith("scaledborderandshadow:")) { this.checkBoxScaleBorderAndShadow.Checked = s.Remove(0, 22).Trim().Equals("yes"); } } } this.groupBoxScript.Text = l.Script; this.labelTitle.Text = l.ScriptTitle; this.labelOriginalScript.Text = l.OriginalScript; this.labelTranslation.Text = l.Translation; this.labelEditing.Text = l.Editing; this.labelTiming.Text = l.Timing; this.labelSyncPoint.Text = l.SyncPoint; this.labelUpdatedBy.Text = l.UpdatedBy; this.labelUpdateDetails.Text = l.UpdateDetails; this.groupBoxResolution.Text = l.Resolution; this.labelVideoResolution.Text = l.VideoResolution; this.groupBoxOptions.Text = l.Options; this.labelCollision.Text = l.Collision; this.labelWrapStyle.Text = l.WrapStyle; this.checkBoxScaleBorderAndShadow.Text = l.ScaleBorderAndShadow; this.buttonOK.Text = Configuration.Settings.Language.General.Ok; this.buttonCancel.Text = Configuration.Settings.Language.General.Cancel; Utilities.FixLargeFonts(this, this.buttonCancel); }