Beispiel #1
0
 private bool TryGetNamedGroup(string name, out PDFListNumberGroup grp)
 {
     foreach (PDFListNumberGroup item in _namedGroups)
     {
         if (string.Equals(item.Name, name))
         {
             grp = item;
             return(true);
         }
     }
     grp = null;
     return(false);
 }
Beispiel #2
0
        public void PushGroup(string name, ListNumberingGroupStyle style, string prefix, string postfix, bool concat, int startIndex)
        {
            PDFListNumberGroup grp;

            if (string.IsNullOrEmpty(name) || this.TryGetNamedGroup(name, out grp) == false)
            {
                grp = new PDFListNumberGroup(name, startIndex, style, prefix, postfix, concat);

                //Add it to the named groups if we have a name
                if (!string.IsNullOrEmpty(name))
                {
                    _namedGroups.Add(grp);
                }
            }
            this._currentGroups.Add(grp);
        }
Beispiel #3
0
        /// <summary>
        /// Pushes either an existing known group with the specified name, or a new one (remembering it if there is a name) onto the current Numbering stack
        /// </summary>
        /// <param name="name">The name of the group to retireve or create</param>
        /// <param name="liststyle"></param>
        public void PushGroup(string name, Styles.Style liststyle)
        {
            PDFListNumberGroup grp;

            if (string.IsNullOrEmpty(name) || this.TryGetNamedGroup(name, out grp) == false)
            {
                int startindex = 1;
                ListNumberingGroupStyle style = liststyle.GetValue(StyleKeys.ListNumberStyleKey, ListNumberingGroupStyle.Decimals);
                string prefix  = liststyle.GetValue(StyleKeys.ListPrefixKey, String.Empty);
                string postfix = liststyle.GetValue(StyleKeys.ListPostfixKey, String.Empty);
                bool   concat  = liststyle.GetValue(StyleKeys.ListConcatKey, false);

                grp = new PDFListNumberGroup(name, startindex, style, prefix, postfix, concat);

                if (!string.IsNullOrEmpty(name))
                {
                    _namedGroups.Add(grp);
                }
            }
            this._currentGroups.Add(grp);
        }
Beispiel #4
0
        public string Increment()
        {
            if (!this.HasCurrentGroup)
            {
                throw new IndexOutOfRangeException(Errors.NoCurrentNumberGroup);
            }

            //Get the highest group that is concatenated
            int last  = this._currentGroups.Count - 1;
            int index = last;

            while (index >= 0)
            {
                if (_currentGroups[index].Concatenate == false)
                {
                    break;
                }
                else if (index == 0)
                {
                    break;
                }
                else
                {
                    index--;
                }
            }

            if (index < 0)
            {
                return(string.Empty);
            }

            StringBuilder sb = new StringBuilder();

            for (int depth = index; depth <= last; depth++)
            {
                PDFListNumberGroup grp = this._currentGroups[depth];
                //If we are the last group then we should increment the value
                if (depth == last)
                {
                    grp.Increment();
                }

                if (!string.IsNullOrEmpty(grp.PreFix))
                {
                    sb.Append(grp.PreFix);
                }

                string value = GetStringValue(grp.CurrentIndex, depth, grp.Style);

                if (!string.IsNullOrEmpty(value))
                {
                    sb.Append(value);
                }

                if (!string.IsNullOrEmpty(grp.PostFix))
                {
                    sb.Append(grp.PostFix);
                }
            }
            return(sb.ToString());
        }