Example #1
0
        public IActionResult Index()
        {
            var effects = effectController.GetEffects().OrderBy(e => e.IsEnabled == false);
            List <BaseViewModel> viewModels = new List <BaseViewModel>();

            foreach (var effect in effects)
            {
                var editatableProperties = new List <EditablePropertyViewModel>();

                var properties = effect.GetType().GetProperties();

                foreach (var property in properties)
                {
                    var setMethod = property.GetSetMethod();
                    if (setMethod != null)
                    {
                        editatableProperties.Add(new EditablePropertyViewModel()
                        {
                            Id           = effect.Id,
                            DisplayName  = GetDisplayName(property) ?? property.Name,
                            Description  = GetDescription(property) ?? "",
                            PropertyName = property.Name,
                            Value        = property.GetValue(effect)
                        });
                    }
                }

                if (effect is CurveEffect curveEffect)
                {
                    viewModels.Add(new CurveEffectViewModel()
                    {
                        Properties = editatableProperties
                    });
                }
                else if (effect is ScrollImageEffect scrollImageEffect)
                {
                    viewModels.Add(new ScrollImageEffectViewModel()
                    {
                        Properties = editatableProperties
                    });
                }
                else if (effect is ColorWheelEffect colorWheelEffect)
                {
                    viewModels.Add(new ColorWheelEffectViewModel()
                    {
                        Properties = editatableProperties
                    });
                }
                else if (effect is Rainbow2DEffect rainbow2DEffect)
                {
                    viewModels.Add(new Rainbow2DEffectViewModel()
                    {
                        Properties = editatableProperties
                    });
                }
            }
            return(View(new PixelViewModel()
            {
                BaseViewModels = viewModels
            }));
        }