Esempio n. 1
0
        private void RefreshEncoderChoices(string containerName, EncoderChoicesRefreshSource refreshSource)
        {
            HBContainer container = HandBrakeEncoderHelpers.GetContainer(containerName);

            HBVideoEncoder oldEncoder = null;

            if (this.selectedEncoder != null)
            {
                oldEncoder = this.selectedEncoder.Encoder;
            }

            this.encoderChoices = new List <VideoEncoderViewModel>();

            foreach (HBVideoEncoder encoder in HandBrakeEncoderHelpers.VideoEncoders)
            {
                if ((encoder.CompatibleContainers & container.Id) > 0)
                {
                    this.EncoderChoices.Add(new VideoEncoderViewModel {
                        Encoder = encoder
                    });
                }
            }

            this.RaisePropertyChanged(nameof(this.EncoderChoices));

            HBVideoEncoder targetEncoder;

            switch (refreshSource)
            {
            case EncoderChoicesRefreshSource.ContainerChange:
                targetEncoder = oldEncoder;
                break;

            case EncoderChoicesRefreshSource.ProfileChange:
                targetEncoder = HandBrakeEncoderHelpers.GetVideoEncoder(this.Profile.VideoEncoder);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(refreshSource), refreshSource, null);
            }

            this.selectedEncoder = this.EncoderChoices.FirstOrDefault(e => e.Encoder == targetEncoder);

            if (this.selectedEncoder == null)
            {
                this.selectedEncoder = this.EncoderChoices[0];
            }

            // If it's a container change we need to commit the new encoder change.
            if (refreshSource == EncoderChoicesRefreshSource.ContainerChange && this.selectedEncoder.Encoder != oldEncoder)
            {
                this.UpdateProfileProperty(nameof(this.Profile.VideoEncoder), this.selectedEncoder.Encoder.ShortName, raisePropertyChanged: false);
                this.SetDefaultQuality();
            }

            this.RaisePropertyChanged(nameof(this.SelectedEncoder));
        }
Esempio n. 2
0
        public void NotifyProfileChanged()
        {
            this.RefreshEncoderChoices(this.Profile.ContainerName, applyDefaults: false);

            this.selectedEncoder = this.EncoderChoices.SingleOrDefault(e => e.Encoder.ShortName == this.Profile.VideoEncoder);

            if (this.selectedEncoder == null)
            {
                this.selectedEncoder = this.EncoderChoices[0];
            }

            this.RefreshEncoderSettings(applyDefaults: false);
        }
Esempio n. 3
0
        private void RefreshEncoderChoices(string containerName, bool applyDefaults)
        {
            HBContainer container = Encoders.GetContainer(containerName);

            HBVideoEncoder oldEncoder = null;

            if (this.selectedEncoder != null)
            {
                oldEncoder = this.selectedEncoder.Encoder;
            }

            this.encoderChoices = new List <VideoEncoderViewModel>();

            foreach (HBVideoEncoder encoder in Encoders.VideoEncoders)
            {
                if ((encoder.CompatibleContainers & container.Id) > 0)
                {
                    this.EncoderChoices.Add(new VideoEncoderViewModel {
                        Encoder = encoder
                    });
                }
            }

            this.RaisePropertyChanged(() => this.EncoderChoices);

            this.selectedEncoder = this.EncoderChoices.FirstOrDefault(e => e.Encoder == oldEncoder);

            if (this.selectedEncoder == null)
            {
                this.selectedEncoder = this.EncoderChoices[0];
            }

            if (this.selectedEncoder.Encoder != oldEncoder)
            {
                RefreshEncoderSettings(applyDefaults);
                this.NotifyEncoderChanged();
            }

            this.RaisePropertyChanged(() => this.SelectedEncoder);
        }
Esempio n. 4
0
		private void RefreshEncoderChoices(string containerName, bool applyDefaults)
		{
			HBContainer container = Encoders.GetContainer(containerName);

			HBVideoEncoder oldEncoder = null;
			if (this.selectedEncoder != null)
			{
				oldEncoder = this.selectedEncoder.Encoder;
			}

			this.encoderChoices = new List<VideoEncoderViewModel>();

			foreach (HBVideoEncoder encoder in Encoders.VideoEncoders)
			{
				if ((encoder.CompatibleContainers & container.Id) > 0)
				{
					this.EncoderChoices.Add(new VideoEncoderViewModel { Encoder = encoder });
				}
			}

			this.RaisePropertyChanged(() => this.EncoderChoices);

			this.selectedEncoder = this.EncoderChoices.FirstOrDefault(e => e.Encoder == oldEncoder);

			if (this.selectedEncoder == null)
			{
				this.selectedEncoder = this.EncoderChoices[0];
			}

			if (this.selectedEncoder.Encoder != oldEncoder)
			{
				RefreshEncoderSettings(applyDefaults);
				this.NotifyEncoderChanged();
			}

			this.RaisePropertyChanged(() => this.SelectedEncoder);
		}
Esempio n. 5
0
		public void NotifyProfileChanged()
		{
			this.RefreshEncoderChoices(this.Profile.ContainerName, applyDefaults: false);

			this.selectedEncoder = this.EncoderChoices.SingleOrDefault(e => e.Encoder.ShortName == this.Profile.VideoEncoder);

			if (this.selectedEncoder == null)
			{
				this.selectedEncoder = this.EncoderChoices[0];
			}

			this.RefreshEncoderSettings(applyDefaults: false);
		}