Exemplo n.º 1
0
        /// <summary>Increments the named counter.</summary>
        public void IncrementCounter(string name, int amount)
        {
            if (Counters == null)
            {
                return;
            }

            // Find the latest counter with the given name:
            for (int i = Counters.Count - 1; i >= 0; i--)
            {
                if (Counters[i].Name == name)
                {
                    // Match! Increase count:
                    CssCounter counter = Counters[i];
                    counter.Count += amount;
                    Counters[i]    = counter;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>Sets up the values to increment.</summary>
        public void SetIncrements(Css.Value set)
        {
            if (Increments == null)
            {
                Increments = new List <CssCounter>();
            }
            else
            {
                Increments.Clear();
            }

            if (set is Css.ValueSet)
            {
                // For each one..
                for (int i = 0; i < set.Count; i++)
                {
                    // If this is a number then it's the count for the previous increment.
                    Css.Value value = set[i];

                    if (value is Css.Units.DecimalUnit && Increments.Count > 0)
                    {
                        // Number to increment by (for prev counter):
                        CssCounter counter = Increments[Increments.Count - 1];
                        counter.Count = value.GetInteger(null, null);
                        Increments[Increments.Count - 1] = counter;
                    }
                    else
                    {
                        // Another counter:
                        Increments.Add(new CssCounter(value.Text, 1));
                    }
                }
            }
            else
            {
                // Just one:
                Increments.Add(new CssCounter(set.Text, 1));
            }
        }