/// <summary> /// Initializes a new instance of the <see cref="SsaStyle"/> class. /// </summary> /// <param name="ssaStyle"> /// The ssa style. /// </param> public SsaStyle(SsaStyle ssaStyle) { this.Name = ssaStyle.Name; this.FontName = ssaStyle.FontName; this.FontSize = ssaStyle.FontSize; this.Italic = ssaStyle.Italic; this.Bold = ssaStyle.Bold; this.Underline = ssaStyle.Underline; this.Primary = ssaStyle.Primary; this.Secondary = ssaStyle.Secondary; this.Tertiary = ssaStyle.Tertiary; this.Outline = ssaStyle.Outline; this.Background = ssaStyle.Background; this.ShadowWidth = ssaStyle.ShadowWidth; this.OutlineWidth = ssaStyle.OutlineWidth; this.Alignment = ssaStyle.Alignment; this.MarginLeft = ssaStyle.MarginLeft; this.MarginRight = ssaStyle.MarginRight; this.MarginVertical = ssaStyle.MarginVertical; this.BorderStyle = ssaStyle.BorderStyle; this.RawLine = ssaStyle.RawLine; this.LoadedFromHeader = ssaStyle.LoadedFromHeader; }
public SsaStyle(SsaStyle ssaStyle) { Name = ssaStyle.Name; FontName = ssaStyle.FontName; FontSize = ssaStyle.FontSize; Italic = ssaStyle.Italic; Bold = ssaStyle.Bold; Underline = ssaStyle.Underline; Primary = ssaStyle.Primary; Secondary = ssaStyle.Secondary; Tertiary = ssaStyle.Tertiary; Outline = ssaStyle.Outline; Background = ssaStyle.Background; ShadowWidth = ssaStyle.ShadowWidth; OutlineWidth = ssaStyle.OutlineWidth; Alignment = ssaStyle.Alignment; MarginLeft = ssaStyle.MarginLeft; MarginRight = ssaStyle.MarginRight; MarginVertical = ssaStyle.MarginVertical; BorderStyle = ssaStyle.BorderStyle; RawLine = ssaStyle.RawLine; LoadedFromHeader = ssaStyle.LoadedFromHeader; }
private void AddStyleToHeader(SsaStyle newStyle, SsaStyle oldStyle) { if (listViewStyles.SelectedItems.Count == 1) { string newLine = oldStyle.RawLine; newLine = newLine.Replace(oldStyle.Name + ",", newStyle.Name + ","); int indexOfEvents = Header.IndexOf("[Events]"); if (indexOfEvents > 0) { int i = indexOfEvents - 1; while (i > 0 && Environment.NewLine.Contains(Header[i].ToString())) i--; Header = Header.Insert(i + 1, Environment.NewLine + newLine); } else { Header += Environment.NewLine + newLine; } } }
private void SetControlsFromStyle(SsaStyle style) { textBoxStyleName.Text = style.Name; textBoxStyleName.BackColor = listViewStyles.BackColor; comboBoxFontName.Text = style.FontName; checkBoxFontItalic.Checked = style.Italic; checkBoxFontBold.Checked = style.Bold; checkBoxFontUnderline.Checked = style.Underline; if (style.FontSize > 0 && style.FontSize <= numericUpDownFontSize.Maximum) numericUpDownFontSize.Value = style.FontSize; else numericUpDownFontSize.Value = 20; panelPrimaryColor.BackColor = style.Primary; panelSecondaryColor.BackColor = style.Secondary; if (_isSubStationAlpha) panelOutlineColor.BackColor = style.Tertiary; else panelOutlineColor.BackColor = style.Outline; panelBackColor.BackColor = style.Background; numericUpDownOutline.Value = style.OutlineWidth; numericUpDownShadowWidth.Value = style.ShadowWidth; if (_isSubStationAlpha) { switch (style.Alignment) { case "1": radioButtonBottomLeft.Checked = true; break; case "3": radioButtonBottomRight.Checked = true; break; case "9": radioButtonMiddleLeft.Checked = true; break; case "10": radioButtonMiddleCenter.Checked = true; break; case "11": radioButtonMiddleRight.Checked = true; break; case "5": radioButtonTopLeft.Checked = true; break; case "6": radioButtonTopCenter.Checked = true; break; case "7": radioButtonTopRight.Checked = true; break; default: radioButtonBottomCenter.Checked = true; break; } } else { switch (style.Alignment) { case "1": radioButtonBottomLeft.Checked = true; break; case "3": radioButtonBottomRight.Checked = true; break; case "4": radioButtonMiddleLeft.Checked = true; break; case "5": radioButtonMiddleCenter.Checked = true; break; case "6": radioButtonMiddleRight.Checked = true; break; case "7": radioButtonTopLeft.Checked = true; break; case "8": radioButtonTopCenter.Checked = true; break; case "9": radioButtonTopRight.Checked = true; break; default: radioButtonBottomCenter.Checked = true; break; } } if (style.MarginLeft >= 0 && style.MarginLeft <= numericUpDownMarginLeft.Maximum) numericUpDownMarginLeft.Value = style.MarginLeft; else numericUpDownMarginLeft.Value = 10; if (style.MarginRight >= 0 && style.MarginRight <= numericUpDownMarginRight.Maximum) numericUpDownMarginRight.Value = style.MarginRight; else numericUpDownMarginRight.Value = 10; if (style.MarginVertical >= 0 && style.MarginVertical <= numericUpDownMarginVertical.Maximum) numericUpDownMarginVertical.Value = style.MarginVertical; else numericUpDownMarginVertical.Value = 10; if (style.BorderStyle == "3") { radioButtonOpaqueBox.Checked = true; } else { radioButtonOutline.Checked = true; } }
public static void AddStyle(ListView lv, SsaStyle ssaStyle, Subtitle subtitle, bool isSubstationAlpha) { var item = new ListViewItem(ssaStyle.Name.Trim()); item.UseItemStyleForSubItems = false; var subItem = new ListViewItem.ListViewSubItem(item, ssaStyle.FontName); item.SubItems.Add(subItem); subItem = new ListViewItem.ListViewSubItem(item, ssaStyle.FontSize.ToString()); item.SubItems.Add(subItem); int count = 0; foreach (Paragraph p in subtitle.Paragraphs) { if (string.IsNullOrEmpty(p.Extra) && ssaStyle.Name.TrimStart('*') == "Default") count++; else if (p.Extra != null && string.Compare(ssaStyle.Name.TrimStart('*'), p.Extra.TrimStart('*'), StringComparison.OrdinalIgnoreCase) == 0) count++; } subItem = new ListViewItem.ListViewSubItem(item, count.ToString()); item.SubItems.Add(subItem); subItem = new ListViewItem.ListViewSubItem(item, string.Empty); subItem.BackColor = ssaStyle.Primary; item.SubItems.Add(subItem); subItem = new ListViewItem.ListViewSubItem(item, string.Empty); if (isSubstationAlpha) subItem.BackColor = ssaStyle.Background; else 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); lv.Items.Add(item); }