Пример #1
0
        public void OpenEffectSettings()
        {
            BaseLayerEffect layerEffect = LayerPropertyGroup.LayerEffect;
            LayerEffectConfigurationDialog configurationViewModel = (LayerEffectConfigurationDialog)layerEffect.ConfigurationDialog;

            if (configurationViewModel == null)
            {
                return;
            }

            try
            {
                // Limit to one constructor, there's no need to have more and it complicates things anyway
                ConstructorInfo[] constructors = configurationViewModel.Type.GetConstructors();
                if (constructors.Length != 1)
                {
                    throw new ArtemisUIException("Effect configuration dialogs must have exactly one constructor");
                }

                ParameterInfo                effectParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerEffect).IsAssignableFrom(p.ParameterType));
                ConstructorArgument          argument        = new(effectParameter.Name, layerEffect);
                EffectConfigurationViewModel viewModel       = (EffectConfigurationViewModel)layerEffect.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
                _windowManager.ShowDialog(new LayerEffectSettingsWindowViewModel(viewModel));
            }
            catch (Exception e)
            {
                _dialogService.ShowExceptionDialog("An exception occured while trying to show the effect's settings window", e);
                throw;
            }
        }
 /// <summary>
 ///     Creates a new instance of the <see cref="EffectConfigurationViewModel" /> class with a validator
 /// </summary>
 /// <param name="layerEffect"></param>
 /// <param name="validator"></param>
 protected EffectConfigurationViewModel(BaseLayerEffect layerEffect, IModelValidator validator) : base(validator)
 {
     LayerEffect = layerEffect;
 }
 /// <summary>
 ///     Creates a new instance of the <see cref="EffectConfigurationViewModel" /> class
 /// </summary>
 /// <param name="layerEffect"></param>
 protected EffectConfigurationViewModel(BaseLayerEffect layerEffect)
 {
     LayerEffect = layerEffect;
 }