Represents a text style, including Bold, Italic and Underline.
Inheritance: ICloneable
コード例 #1
0
ファイル: Subtitle.cs プロジェクト: GNOME/gnome-subtitles
	/// <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;
	}
コード例 #8
0
 /// <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
ファイル: Subtitle.cs プロジェクト: GNOME/gnome-subtitles
	/* 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;
	}
コード例 #10
0
	internal override string EndOfStyleToString (Style style) {
		return StyleToString(style, "0");
	}
コード例 #11
0
	internal override string StyleToString (Style style) {
		return StyleToString(style, "1");
	}
コード例 #12
0
	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;