Пример #1
0
        CompositionEffectBrush GetCompositionEffectBrush(CompositionEffectBrush obj)
        {
            if (GetExisting(obj, out CompositionEffectBrush result))
            {
                return(result);
            }

            var effectBase = obj.GetEffect();

            switch (effectBase.Type)
            {
            case GraphicsEffectType.CompositeEffect:
                var compositeEffect = (CompositeEffect)effectBase;

                var newCompositeEffect = new CompositeEffect
                {
                    Mode = compositeEffect.Mode,
                };

                var effectFactory        = _c.CreateEffectFactory(newCompositeEffect);
                var compositeEffectBrush = effectFactory.CreateBrush();

                result = CacheAndInitializeCompositionObject(obj, compositeEffectBrush);

                foreach (var source in compositeEffect.Sources)
                {
                    newCompositeEffect.Sources.Add(new CompositionEffectSourceParameter(source.Name));

                    result.SetSourceParameter(source.Name, GetCompositionBrush(obj.GetSourceParameter(source.Name)));
                }

                break;

            default:
                throw new InvalidOperationException();
            }

            StartAnimationsAndFreeze(obj, result);
            return(result);
        }