Represents a text style, including Bold, Italic and Underline.
상속: ICloneable
예제 #1
0
	/// <summary>Initializes a new instance of the <see cref="Subtitle" /> class, given the
	/// global subtitles' properties and the subtitle's text and style.</summary>
	/// <param name="properties">The subtitles' properties.</param>
	/// <param name="text">The subtitle's text.</param>
	/// <param name="style">The subtitle's style.</param>
	public Subtitle (SubtitleProperties properties, SubtitleText text, Style style) {
		this.properties = properties;
		this.text = text;
		this.style = style;

		times = new Times(this);
		frames = new Frames(this);
	}
예제 #2
0
	internal override string EndOfStyleToString (Style style) {
		string styleText = String.Empty;
		if (style.Underline)
			styleText += "</u>";
		if (style.Bold)
			styleText += "</b>";
		if (style.Italic)
			styleText += "</i>";
		return styleText;
	}
예제 #3
0
	private void ReadSubtitles (Encoding encoding, ParsingProperties properties, SubtitleCollection collection) {

		string[] lines = text.Split(new char[] {'\n'});
		for (int i = 0; i < lines.Length; i++) {
			SubtitleText stext = ParseSubtitleText(lines[i]);
			Style style = new Style();
			if(!stext.IsEmpty) {
				Subtitle subtitle = new Subtitle(null, stext, style);
				collection.Add(subtitle);
			}
		}

	}
예제 #4
0
        private void GetStyleMarkup(SubLib.Core.Domain.Style subtitleStyle, ref string prefix, ref string suffix)
        {
            if (subtitleStyle.Italic)
            {
                prefix += "<i>";
                suffix  = "</i>" + suffix;
            }

            if (subtitleStyle.Bold)
            {
                prefix += "<b>";
                suffix  = "</b>" + suffix;
            }

            if (subtitleStyle.Underline)
            {
                prefix += "<u>";
                suffix  = "</u>" + suffix;
            }
        }
예제 #5
0
        private void RenderTextCell(CellRendererText renderer, TreeIter iter, SubtitleText subtitleText, SubLib.Core.Domain.Style subtitleStyle)
        {
            /* If there's no text, return empty text without line count */
            if (subtitleText.IsEmpty)
            {
                RenderEmptyTextCell(renderer);
                return;
            }

            string textMarkup  = String.Empty;
            string stylePrefix = String.Empty;
            string styleSuffix = String.Empty;

            GetStyleMarkup(subtitleStyle, ref stylePrefix, ref styleSuffix);

            bool first           = true;
            bool viewLineLengths = Base.Config.ViewLineLengths;

            foreach (string line in subtitleText)
            {
                textMarkup += (first ? String.Empty : "\n") + stylePrefix + GLib.Markup.EscapeText(line) + styleSuffix + (viewLineLengths ? " <span size=\"small\"><sup>(" + line.Length + ")</sup></span>" : String.Empty);
                if (first)
                {
                    first = false;
                }
            }

            renderer.Markup = textMarkup;
        }
예제 #6
0
	internal virtual string EndOfStyleToString (Style style) {
		return String.Empty;
	}
예제 #7
0
	internal virtual Style StringToStyle (string styleText) {
		Style style = new Style();
		foreach (char character in styleText) {
			if ((character == 'u') || (character == 'U'))
				style.Underline = true;
			else if ((character == 'b') || (character == 'B'))
				style.Bold = true;
			else if ((character == 'i') || (character == 'I'))
				style.Italic = true;
		}
		return style;
	}
 /// <summary>Sets font with bold and italic if applicable.</summary>
 private void SetFont(SubLib.Core.Domain.Style style)
 {
     Pango.FontDescription font = Pango.FontDescription.FromString(this.textFont + (style.Bold ? " bold" : String.Empty) + (style.Italic ? " italic" : String.Empty) + " " + this.textFontSize);
     this.textView.OverrideFont(font);
 }
예제 #9
0
	/* Private methods */

	private void SetFieldsForDeepClone (SubtitleProperties properties, Times times, Frames frames, SubtitleText text, SubtitleText translation, Style style) {
		this.properties = properties;
		this.times = times;
		this.frames = frames;
		this.text = text;
		this.translation = translation;
		this.style = style;
	}
	internal override string EndOfStyleToString (Style style) {
		return StyleToString(style, "0");
	}
	internal override string StyleToString (Style style) {
		return StyleToString(style, "1");
	}
	protected string StyleToString (Style style, string suffix) {
		string styleText = String.Empty;
		if (style.Underline)
			styleText += @"{\u" + suffix + "}";
		if (style.Bold)
			styleText += @"{\b" + suffix + "}";
		if (style.Italic)
			styleText += @"{\i" + suffix + "}";
		return styleText;