Subtitle: Chain ctor and make obj creation consistent

This commit is contained in:
Ivandro Jao 2023-06-30 22:24:27 +01:00
parent a4b039a03f
commit 921006c347

View File

@ -27,24 +27,23 @@ namespace Nikse.SubtitleEdit.Core.Common
public List<HistoryItem> HistoryItems { get; }
public bool CanUndo => HistoryItems.Count > 0;
public Subtitle()
public Subtitle() : this(new List<Paragraph>(), new List<HistoryItem>())
{
Paragraphs = new List<Paragraph>();
HistoryItems = new List<HistoryItem>();
FileName = "Untitled";
}
public Subtitle(List<HistoryItem> historyItems)
: this()
public Subtitle(List<Paragraph> paragraphs) : this(paragraphs, new List<HistoryItem>())
{
}
public Subtitle(List<HistoryItem> historyItems) : this(new List<Paragraph>(), historyItems)
{
HistoryItems = historyItems;
}
public Subtitle(List<Paragraph> paragraphs, List<HistoryItem> historyItems)
: this()
{
HistoryItems = historyItems;
Paragraphs = paragraphs;
FileName = "Untitled";
}
/// <summary>
@ -76,10 +75,6 @@ namespace Nikse.SubtitleEdit.Core.Common
OriginalEncoding = subtitle.OriginalEncoding;
}
public Subtitle(List<Paragraph> paragraphs) : this()
{
Paragraphs = paragraphs;
}
/// <summary>
/// Get the paragraph of index, null if out of bounds