Represents the text of a subtitle.
Inheritance: ICloneable
Beispiel #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);
	}
Beispiel #2
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);
        }
Beispiel #3
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;
        }
Beispiel #4
0
        public object Clone()
        {
            SubtitleText clone = new SubtitleText();

            foreach (string line in lines)
            {
                clone.lines.Add(line);
            }
            return(clone);
        }
Beispiel #5
0
        /* Public methods */

        /// <summary></summary>
        /// <remarks>SubtitleProperties is not cloned and should be set afterwards.</remarks>
        public Subtitle Clone(SubtitleProperties propertiesClone)
        {
            Subtitle subtitleClone = new Subtitle();

            Times        timesClone       = this.times.Clone(subtitleClone);
            Frames       framesClone      = this.frames.Clone(subtitleClone);
            SubtitleText textClone        = this.text.Clone() as SubtitleText;
            SubtitleText translationClone = (this.translation != null ? this.translation.Clone() as SubtitleText : null);
            Style        styleClone       = this.style.Clone() as Style;

            subtitleClone.SetFieldsForDeepClone(propertiesClone, timesClone, framesClone, textClone, translationClone, styleClone);

            return(subtitleClone);
        }
Beispiel #6
0
 internal void ClearTranslation()
 {
     translation = null;
 }
Beispiel #7
0
	public object Clone() {
		SubtitleText clone = new SubtitleText();
		foreach (string line in lines) {
			clone.lines.Add(line);
		}
		return clone;
	}
Beispiel #8
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;
	}
Beispiel #9
0
	internal void ClearTranslation () {
		translation = null;
	}
Beispiel #10
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) {
			renderer.Text = String.Empty;
			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.PrefsViewLineLengths;
		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;
	}