/// <summary>
        /// Copy config to UI
        /// </summary>
        /// <param name="effectTokenCopy">Config to apply</param>
        protected override void InitDialogFromToken(StyleTransferEffectConfigToken effectTokenCopy)
        {
            Contract.Requires(effectTokenCopy != null);

            var properties = effectTokenCopy.Properties;

            // set UI from token
            trackBarAmount.Value          = properties.StyleAmount;
            numericUpDownAmount.Value     = properties.StyleAmount;
            trackBarSize.Value            = properties.StyleSize;
            numericUpDownSize.Value       = properties.StyleSize;
            pictureBoxStyle.ImageLocation = properties.StyleImage;
            buttonOk.Enabled = !string.IsNullOrEmpty(properties.StyleImage);
            radioButtonStyleQuality.Checked     = properties.StyleModel == ModelType.Quality;
            radioButtonStyleFast.Checked        = properties.StyleModel == ModelType.Fast;
            radioButtonTransformQuality.Checked = properties.TransformerModel == ModelType.Quality;
            radioButtonTransformFast.Checked    = properties.TransformerModel == ModelType.Fast;
            checkBoxAspect.Checked = properties.MatchAspectRatio;

            if (properties.IsPreset)
            {
                comboBoxPreset.SelectedValue = properties.PresetName;
                tabControlMode.SelectedTab   = tabPagePresets;
                buttonOk.Enabled             = comboBoxPreset.SelectedIndex > 0;
            }
            else
            {
                comboBoxPreset.SelectedIndex = 0;
                tabControlMode.SelectedTab   = tabPageCustom;
            }
        }
        /// <summary>
        /// Copy UI state to config
        /// </summary>
        protected override void LoadIntoTokenFromDialog(StyleTransferEffectConfigToken token)
        {
            Contract.Requires(token != null);

            var properties = token.Properties;

            // set token from UI
            properties.StyleAmount      = trackBarAmount.Value;
            properties.StyleSize        = trackBarSize.Value;
            properties.StyleImage       = pictureBoxStyle.ImageLocation;
            properties.StyleModel       = radioButtonStyleQuality.Checked ? ModelType.Quality : ModelType.Fast;
            properties.TransformerModel = radioButtonTransformQuality.Checked ? ModelType.Quality : ModelType.Fast;
            properties.MatchAspectRatio = checkBoxAspect.Checked;
        }
        /// <summary>
        /// Copy UI state to config
        /// </summary>
        protected override void LoadIntoTokenFromDialog(StyleTransferEffectConfigToken token)
        {
            Contract.Requires(token != null);

            var properties = token.Properties;

            // set token from UI
            properties.StyleAmount      = trackBarAmount.Value;
            properties.StyleSize        = trackBarSize.Value;
            properties.StyleImage       = pictureBoxStyle.ImageLocation;
            properties.StyleModel       = radioButtonStyleQuality.Checked ? ModelType.Quality : ModelType.Fast;
            properties.TransformerModel = radioButtonTransformQuality.Checked ? ModelType.Quality : ModelType.Fast;
            properties.MatchAspectRatio = checkBoxAspect.Checked;
            properties.IsPreset         = comboBoxPreset.SelectedIndex > 0 && tabControlMode.SelectedTab == tabPagePresets;
            properties.PresetName       = properties.IsPreset ? (string)comboBoxPreset.SelectedValue : string.Empty;
        }
        /// <summary>
        /// Copy config to UI
        /// </summary>
        /// <param name="effectTokenCopy">Config to apply</param>
        protected override void InitDialogFromToken(StyleTransferEffectConfigToken effectTokenCopy)
        {
            Contract.Requires(effectTokenCopy != null);

            var properties = effectTokenCopy.Properties;

            // set UI from token
            trackBarAmount.Value          = properties.StyleAmount;
            numericUpDownAmount.Value     = properties.StyleAmount;
            trackBarSize.Value            = properties.StyleSize;
            numericUpDownSize.Value       = properties.StyleSize;
            pictureBoxStyle.ImageLocation = properties.StyleImage;
            buttonOk.Enabled = !string.IsNullOrEmpty(properties.StyleImage);
            radioButtonStyleQuality.Checked     = properties.StyleModel == ModelType.Quality;
            radioButtonStyleFast.Checked        = properties.StyleModel == ModelType.Fast;
            radioButtonTransformQuality.Checked = properties.TransformerModel == ModelType.Quality;
            radioButtonTransformFast.Checked    = properties.TransformerModel == ModelType.Fast;
            checkBoxAspect.Checked = properties.MatchAspectRatio;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Copy from other instance
 /// </summary>
 /// <param name="other">Instance to copy from</param>
 protected StyleTransferEffectConfigToken(StyleTransferEffectConfigToken other) : base(other)
 {
     Contract.Requires(other != null);
     Properties = other.Properties;
 }