public T GetStyleSetter <T>(StyleSetterType setterType,
                             IVisualElement element,
                             IVisualLineage visualLineage)
 {
     return(GetStyleSetter <T>(setterType, VisualStateType.None,
                               element, visualLineage));
 }
Esempio n. 2
0
 public StyleValueDeclaration(IDependencyProperty property,
                              StyleSetterType setterType,
                              T value,
                              Transition?transition)
 {
     _value     = value;
     Property   = property;
     SetterType = setterType;
     Transition = transition;
 }
        public void RegisterStyleSetter <T>(StyleSetterType setterType,
                                            Object value,
                                            IVisualElement scope)
            where T : IVisualElement
        {
            var style = new TypeStyle <T>();

            style[setterType] = value;
            RegisterStyle(style, scope);
        }
        public AssignedStyle(StyleSetterType setterType,
                             VisualStateType type,
                             Object?value = null)
        {
            SetterType = setterType;
            Type       = type;
            Value      = value;

            _hash = (Int32)setterType + ((Int32)type << 16);
        }
Esempio n. 5
0
 public Transition(StyleSetterType setterType,
                   TimeSpan duration,
                   TimeSpan delay,
                   TransitionFunctionType timing)
 {
     SetterType = setterType;
     Duration   = duration;
     Delay      = delay;
     Timing     = timing;
 }
        public virtual Boolean TryGetValue(StyleSetterType setterType,
                                           VisualStateType type,
                                           out Object val)
        {
            foreach (var k in GetUniqueFlags <VisualStateType>(type))
            {
                var key = new AssignedStyle(setterType, k);
                if (_setters.TryGetValue(key, out val !))
                {
                    return(true);
                }
            }

            val = default !;
        public void RegisterStyleSetter(IVisualElement element,
                                        StyleSetterType setterType,
                                        Object value)
        {
            if (!IsTypeValid(setterType, value))
            {
                throw new ArgumentOutOfRangeException(nameof(value));
            }

            if (!_elementStyles.TryGetValue(element.Id, out var style))
            {
                style = new ElementStyle(element, this);
                _elementStyles[element.Id] = style;
            }

            style.AddSetter(setterType, value);
        }
        public override void Add(StyleSetterType setterType,
                                 VisualStateType type,
                                 Object?value)
        {
            var key = new AssignedStyle(setterType, type, value);

            if (setterType == StyleSetterType.Transition)
            {
                var transitions = value as Transition[]
                                  ?? throw new ArgumentOutOfRangeException(nameof(value));

                foreach (var trans in transitions)
                {
                    var tranqui = new AssignedStyle(trans.SetterType, type, trans);
                    _transitions[tranqui] = trans;
                }
            }
            else if (_transitions.TryGetValue(key, out var transition))
            {
                if (!_setters.TryGetValue(key, out var existed))
                {
                    existed = null;
                }

                switch (value)
                {
                //case Thickness _:
                //    var runningThickness = new ThicknessTransition(existed, transition, key, UpdateTransition);
                //    runningThickness.Start();
                //    break;

                //case Double _:
                //    var running = new DoubleTransition(existed,
                //        transition, key, UpdateTransition);
                //    running.Start();
                //    break;

                default:
                    throw new NotImplementedException();
                }
            }
            else
            {
                base.Add(setterType, type, value);
            }
        }
        public T GetStyleSetter <T>(StyleSetterType setterType,
                                    VisualStateType type,
                                    IVisualElement element,
                                    IVisualLineage visualLineage)
        {
            if (TryGetStyleSetterImpl <T>(setterType, type, element, visualLineage, out var found))
            {
                return(found);
            }

            if (type != VisualStateType.None &&
                TryGetStyleSetterImpl(setterType, VisualStateType.None,
                                      element, visualLineage, out found))
            {
                return(found);
            }

            return(_defaultStyle[setterType] is T good ? good : default !);
 public void RegisterStyleSetter <T>(StyleSetterType setterType, Object value, IVisualElement scope) where T : IVisualElement
 {
     ThrowException <Object>();
 }
 public T GetStyleSetter <T>(StyleSetterType setterType, VisualStateType type, IVisualElement element,
                             IVisualLineage visualLineage)
 {
     return(ThrowException <T>());
 }
 public void RegisterStyleSetter(IVisualElement element, StyleSetterType setterType, VisualStateType type, Object value)
 {
     ThrowException <Object>();
 }
Esempio n. 13
0
 public virtual Object?this[StyleSetterType setterType]
 {
     get => TryGetValue(setterType, VisualStateType.None, out var found)