public ChapterMarkersDialogViewModel(List <SourceChapter> chapters, List <string> currentNames, bool useDefaultNames)
        {
            this.chapters = chapters;

            this.chapterNames = new ObservableCollection <ChapterNameViewModel>();

            TimeSpan startTime = TimeSpan.Zero;

            for (int i = 0; i < this.chapters.Count; i++)
            {
                SourceChapter chapter = this.chapters[i];

                var viewModel = new ChapterNameViewModel {
                    Number = i + 1, StartTime = startTime.ToString(Utilities.TimeFormat)
                };
                if (currentNames != null && i < currentNames.Count)
                {
                    viewModel.Title = currentNames[i];
                }
                else if (!string.IsNullOrWhiteSpace(chapter.Name))
                {
                    viewModel.Title = chapter.Name;
                }
                else
                {
                    viewModel.Title = string.Format(
                        CultureInfo.CurrentCulture,
                        EncodingRes.DefaultChapterName,
                        i + 1);
                }

                this.chapterNames.Add(viewModel);

                startTime += chapter.Duration.ToSpan();
            }

            this.useDefaultNames = useDefaultNames;

            this.ImportCsvFile = ReactiveCommand.Create();
            this.ImportCsvFile.Subscribe(_ => this.ImportCsvFileImpl());
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the ChapterViewModel class.
 /// </summary>
 /// <param name="chapter">The raw source chapter.</param>
 /// <param name="chapterNumber">The 1-based index of the chapter.</param>
 public ChapterViewModel(SourceChapter chapter, int chapterNumber)
 {
     this.Chapter       = chapter;
     this.ChapterNumber = chapterNumber;
 }