Esempio n. 1
0
		public SubtitleDialogViewModel(Subtitles currentSubtitles)
		{
			this.container = Encoders.GetContainer(this.presetsViewModel.SelectedPreset.Preset.EncodingProfile.ContainerName);

			this.sourceSubtitles = new ObservableCollection<SourceSubtitleViewModel>();
			this.srtSubtitles = new ObservableCollection<SrtSubtitleViewModel>();

			if (currentSubtitles != null)
			{
				if (!currentSubtitles.SourceSubtitles.Any(s => s.TrackNumber == 0))
				{
					this.sourceSubtitles.Add(
						new SourceSubtitleViewModel(
							this,
							new SourceSubtitle
								{
									TrackNumber = 0,
									BurnedIn = false,
									Forced = false,
									Default = false
								}));
				}

				foreach (SourceSubtitle subtitle in currentSubtitles.SourceSubtitles)
				{
					this.sourceSubtitles.Add(new SourceSubtitleViewModel(this, subtitle.Clone()) { Selected = true });
				}
				
				foreach (SrtSubtitle subtitle in currentSubtitles.SrtSubtitles)
				{
					this.srtSubtitles.Add(new SrtSubtitleViewModel(this, subtitle.Clone()));
				}
			}

			// Fill in remaining unselected source subtitles
			foreach (Subtitle subtitle in this.mainViewModel.SelectedTitle.Subtitles)
			{
				if (!currentSubtitles.SourceSubtitles.Any(s => s.TrackNumber == subtitle.TrackNumber))
				{
					var newSubtitle = new SourceSubtitle
					    {
					        TrackNumber = subtitle.TrackNumber,
					        Default = false,
					        Forced = false,
					        BurnedIn = false
					    };

					this.sourceSubtitles.Add(new SourceSubtitleViewModel(this, newSubtitle));
				}
			}

			this.sourceSubtitles.CollectionChanged += this.SourceCollectionChanged;
			this.srtSubtitles.CollectionChanged += this.SrtCollectionChanged;

			this.UpdateBoxes();
		}
Esempio n. 2
0
		public SourceSubtitleViewModel(SubtitleDialogViewModel subtitleDialogViewModel, SourceSubtitle subtitle)
		{
			this.SubtitleDialogViewModel = subtitleDialogViewModel;
			this.subtitle = subtitle;

			MessengerInstance.Register<ContainerChangedMessage>(this,
				m =>
				{
					this.RefreshBoxes();
				});
		}