Esempio n. 1
0
 public void AddCssProperties(CssProperties properties)
 {
     if (StartTag != "")
     {
         StartTag = StartTag.Insert(StartTag.Length - 1, properties.AllCssProperiesToString());
     }
 }
Esempio n. 2
0
        /// <summary>Searches the current animated properties for the named property on the given element.</summary>
        /// <param name="animating">The element being animated.</param>
        /// <param name="property">The CSS property to look for. Note: Must not be a composite property such as color-overlay.
        /// Must be a full property such as color-overlay-r.</param>
        /// <returns>An AnimatedProperty if it was found; Null otherwise.</returns>
        public static AnimatedProperty GetAnimatedProperty(Element animating, string property)
        {
            // Grab the inner index:
            int innerIndex = Css.Value.GetInnerIndex(ref property);

            // Get the property:
            return(GetAnimatedProperty(animating, CssProperties.Get(property), innerIndex));
        }
Esempio n. 3
0
        public string createHtmlWithCssClass(MdNode mdNode)
        {
            var tree       = new MdTree(mdNode);
            var properties = new CssProperties()
            {
                ClassName = "mdClass"
            };
            var htmlConverter = new HtmlConverter(properties);

            return(htmlConverter.Convert(tree));
        }
Esempio n. 4
0
        public Property(CssProperty prop, string name)
        {
            RawProperty = CssProperties.Get(name);

            if (RawProperty == null)
            {
                throw new Exception("CSS Specification failure: Property '" + name + "' is required.");
            }

            CssCompositeProperty compProp = prop as CssCompositeProperty;

            if (compProp != null)
            {
                SetInfo = compProp.GetPropertySetInfo(RawProperty);
            }
        }
Esempio n. 5
0
        public override void OnTagLoaded()
        {
            // If we follow a br, we have height, otherwise just act like a block element.
            Element previousElement = Element.previousSibling;

            if (previousElement != null && previousElement.computedStyle.Display == Css.DisplayType.Block)
            {
                // Act like we have content.
                // This will enforce the height to be set of the tag when fontsize changes.

                // Get the content CSS property:
                CssProperty property = CssProperties.Get("content");

                if (property != null)
                {
                    property.Apply(Element.style.Computed, null);
                }
            }

            base.OnTagLoaded();
        }
Esempio n. 6
0
 /// <summary>Searches the current animated properties for the named property on the given element.</summary>
 /// <param name="animating">The element being animated.</param>
 /// <param name="property">The CSS property to look for. Note: Must not be a composite property such as color-overlay.
 /// Must be a full property such as color-overlay-r.</param>
 /// <returns>An AnimatedProperty if it was found; Null otherwise.</returns>
 public static AnimatedProperty GetAnimatedProperty(Node animating, string property)
 {
     // Get the property:
     return(GetAnimatedProperty(animating, CssProperties.Get(property)));
 }
Esempio n. 7
0
 public HtmlConverter()
 {
     css = new CssProperties();
 }
Esempio n. 8
0
 public HtmlConverter(CssProperties properties)
 {
     css = properties;
 }
Esempio n. 9
0
 public HtmlConverter(string basicUri, CssProperties properties)
 {
     this.basicUri = basicUri;
     css           = properties;
 }
Esempio n. 10
0
 public HtmlConverter(string basicUri)
 {
     this.basicUri = basicUri;
     css           = new CssProperties();
 }
Esempio n. 11
0
        /// <summary>Creates a new UIAnimation for animating CSS and immediately animates it.
        /// See <see cref="PowerUI.Element.animate"/>.</summary>
        /// <param name="animating">The element being animated.</param>
        /// <param name="properties">The CSS property string. Each property should define the value it will be when the animation is done.</param>
        /// <param name="constantSpeedTime">How long this animation lasts for at a constant speed.</param>
        /// <param name="timeToAccelerateFor">How long this animation accelerates for. Creates smooth animations when used.</param>
        /// <param name="timeToDecelerateFor">How long this animation decelerates for. Creates smooth animations when used.</param>
        public UIAnimation(Element animating, string properties, float constantSpeedTime, float timeToAccelerateFor, float timeToDecelerateFor)
        {
            Animating    = animating;
            ElementStyle = Animating.Style;

            if (string.IsNullOrEmpty(properties))
            {
                Wrench.Log.Add("No properties given to animate!");
                return;
            }

            if (constantSpeedTime < 0f)
            {
                constantSpeedTime = 0f;
            }

            if (timeToAccelerateFor < 0f)
            {
                timeToAccelerateFor = 0f;
            }

            if (timeToDecelerateFor < 0f)
            {
                timeToDecelerateFor = 0f;
            }

            TotalTime = (timeToDecelerateFor + timeToAccelerateFor + constantSpeedTime);

            ConstantSpeedTime   = constantSpeedTime;
            TimeToAccelerateFor = timeToAccelerateFor;
            TimeToDecelerateFor = timeToDecelerateFor;

            if (TotalTime == 0f)
            {
                // Instant - probably a fault somewhere in the users request, so we won't do anything.
                Wrench.Log.Add("Instant css animation request ignored. Told to take no time to transition.");
                return;
            }

            if (timeToDecelerateFor == 0f)
            {
                Decelerate = false;
            }
            else
            {
                Decelerate   = true;
                DecelerateAt = timeToAccelerateFor + constantSpeedTime;
            }

            if (properties.StartsWith(".") || properties.StartsWith("#"))
            {
                // Targeting a selector, e.g. #fadedBox
                // First, get the selector style:
                Css.SelectorStyle selector = animating.Document.getStyleBySelector(properties);

                if (selector == null)
                {
                    return;
                }

                // Animate each property:
                foreach (KeyValuePair <CssProperty, Css.Value> kvp in selector.Properties)
                {
                    // Is it a composite property?
                    Css.Value value = kvp.Value;

                    // Grab the type:
                    Css.ValueType type = value.Type;

                    if (type == Css.ValueType.Null || type == Css.ValueType.Text)
                    {
                        // Can't deal with either of these.
                        continue;
                    }

                    if (type == Css.ValueType.Rectangle || type == Css.ValueType.Point || type == Css.ValueType.Color)
                    {
                        // Animate it (note that we don't need to copy it):
                        AnimateComposite(kvp.Key, value);
                    }
                    else
                    {
                        // Animate it (note that we don't need to copy it):
                        Animate(kvp.Key, -1, value, true);
                    }
                }

                return;
            }

            string[] propertySet = properties.Split(';');

            foreach (string currentProperty in propertySet)
            {
                if (currentProperty == "")
                {
                    continue;
                }

                string[] keyValue = currentProperty.Split(Css.Style.Delimiter, 2);

                if (keyValue.Length != 2)
                {
                    continue;
                }

                string key = keyValue[0].Trim();

                if (key == "opacity")
                {
                    key = "color-overlay-a";
                }

                // Grab the inner index:
                int innerIndex = Css.Value.GetInnerIndex(ref key);

                // Get the property:
                CssProperty property = CssProperties.Get(key);

                if (property == null)
                {
                    Wrench.Log.Add("Warning: CSS property '" + keyValue[0] + "' not found during animate.");
                    continue;
                }

                // Trim shouldn't be applied to inner-text's value, but we can't animate that anyway! This is all we need to do:
                string value = keyValue[1].Trim();

                // Key could be a composite property - for example padding, which needs to be broken down into it's individual inner elements (e.g. padding-left)

                Css.ValueType type;

                if (innerIndex == -1)
                {
                    type = Css.Value.TypeOf(property, ref value);
                }
                else
                {
                    type = Css.Value.TypeOf(value);
                }

                if (type == Css.ValueType.Null || type == Css.ValueType.Text)
                {
                    // Can't deal with either of these.
                    continue;
                }
                else if (type == Css.ValueType.Rectangle || type == Css.ValueType.Point || type == Css.ValueType.Color)
                {
                    // We have a composite property (and we're animating the whole thing).
                    Css.Value tempValue = new Css.Value();
                    tempValue.Set(value, type);

                    // Animate it:
                    AnimateComposite(property, tempValue);
                }
                else
                {
                    Animate(property, innerIndex, new Css.Value(value, type), true);
                }
            }
        }