Exemplo n.º 1
0
            /**
             * Reloads a list item within the long list selector items source.
             */
            public void ReloadListItem(ListViewSection section, ListViewItem item)
            {
                if (mListSections.Count > section.ItemsSourceSectionIndex)
                {
                    ListSection<ListItem> sectionToReload = mListSections[section.ItemsSourceSectionIndex];
                    if (sectionToReload.Count > item.ItemsSourceItemIndex)
                    {
                        ListItem itemToReload = sectionToReload[item.ItemsSourceItemIndex];
                        itemToReload.Height = item.Height;
                        itemToReload.Width = item.Width;
                        itemToReload.Title = item.Text;
                        itemToReload.Subtitle = item.Subtitle;
                        itemToReload.FontSize = item.GetFontSize();
                        itemToReload.FontColor = item.GetFontColor();
                        itemToReload.SubtitleFontColor = item.GetSubtitleFontColor();
                        if (mListViewStyle == ListViewStyle.NoSubtitle)
                        {
                            itemToReload.SubtitleVisibility = Visibility.Collapsed;
                        }
                        else
                        {
                            itemToReload.SubtitleVisibility = Visibility.Visible;
                        }
                        itemToReload.ImageSource = item.IconImageSource;

                        sectionToReload[item.ItemsSourceItemIndex] = itemToReload;
                    }
                }
            }
Exemplo n.º 2
0
        public void AddSection(string header, BaseAdapter adapter, int headcolor)
        {
            var  listSection = new ListSection(header, adapter, headcolor);
            bool issection = false, isoriginal = false;

            foreach (var section in Sections)
            {
                if (section.Header.Equals(listSection.Header))
                {
                    issection = true;
                }
            }

            foreach (var original in Original)
            {
                if (original.Header.Equals(listSection.Header))
                {
                    isoriginal = true;
                }
            }


            if (!isoriginal)
            {
                Original.Add(listSection);
            }

            if (!issection)
            {
                Sections.Add(listSection);
            }
        }
Exemplo n.º 3
0
            /**
             * Reloads a list section within the long list selector items source.
             */
            public void ReloadListSection(ListViewSection section)
            {
                if (mListSections.Count > section.ItemsSourceSectionIndex)
                {
                    ListSection<ListItem> sectionToReload = mListSections[section.ItemsSourceSectionIndex];
                    sectionToReload.Title = section.Title;
                    sectionToReload.Header = section.Header;
                    sectionToReload.HeaderColor = section.GetHeaderBackgroundColor();
                    sectionToReload.HeaderFontColor = section.GetHeaderFontColor();
                    sectionToReload.HeaderFontFamily = section.GetHeaderFontFamily();
                    sectionToReload.HeaderFontSize = section.GetHeaderFontSize();
                    sectionToReload.HeaderFontStyle = section.GetHeaderFontStyle();
                    sectionToReload.HeaderFontWeight = section.GetHeaderFontWeight();
                    sectionToReload.HeaderTextHorizontalAlignment = section.GetHeaderHorizontalAlignment();
                    sectionToReload.HeaderTextVerticalAlignment = section.GetHeaderVerticalAlignment();
                    sectionToReload.Footer = section.Footer;
                    sectionToReload.FooterColor = section.GetFooterBackgroundColor();
                    sectionToReload.FooterFontColor = section.GetFooterFontColor();
                    sectionToReload.FooterFontFamily = section.GetFooterFontFamily();
                    sectionToReload.FooterFontSize = section.GetFooterFontSize();
                    sectionToReload.FooterFontStyle = section.GetFooterFontStyle();
                    sectionToReload.FooterFontWeight = section.GetFooterFontWeight();
                    sectionToReload.FooterTextHorizontalAlignment = section.GetFooterHorizontalAlignment();
                    sectionToReload.FooterTextVerticalAlignment = section.GetFooterVerticalAlignment();
                    sectionToReload.GroupHeaderColor = section.GetGroupHeaderBackgroundColor();

                    mListSections[section.ItemsSourceSectionIndex] = sectionToReload;
                }
            }
Exemplo n.º 4
0
 /**
  * Reloads a section at a certain index inside the long list selector items source.
  */
 public void UpdateSection(int sectionIndex, ListSection<ListItem> newSection)
 {
     if (mListSections.Count > sectionIndex)
     {
         mListSections[sectionIndex] = newSection;
     }
 }
Exemplo n.º 5
0
            /**
             * Creates a section model from the added widget.
             */
            private ListSection<ListItem> CreateSectionModelFromWidget(ListViewSection section)
            {
                ListSection<ListItem> currentSection = new ListSection<ListItem>();
                currentSection.Title = section.Title;
                currentSection.Header = section.Header;
                currentSection.Footer = section.Footer;
                currentSection.HeaderColor = section.GetHeaderBackgroundColor();
                currentSection.HeaderFontColor = section.GetHeaderFontColor();
                currentSection.HeaderFontFamily = section.GetHeaderFontFamily();
                currentSection.HeaderFontSize = section.GetHeaderFontSize();
                currentSection.HeaderFontStyle = section.GetHeaderFontStyle();
                currentSection.HeaderFontWeight = section.GetHeaderFontWeight();
                currentSection.HeaderTextHorizontalAlignment = section.GetHeaderHorizontalAlignment();
                currentSection.HeaderTextVerticalAlignment = section.GetHeaderVerticalAlignment();
                currentSection.Footer = section.Footer;
                currentSection.FooterColor = section.GetFooterBackgroundColor();
                currentSection.FooterFontColor = section.GetFooterFontColor();
                currentSection.FooterFontFamily = section.GetFooterFontFamily();
                currentSection.FooterFontSize = section.GetFooterFontSize();
                currentSection.FooterFontStyle = section.GetFooterFontStyle();
                currentSection.FooterFontWeight = section.GetFooterFontWeight();
                currentSection.FooterTextHorizontalAlignment = section.GetFooterHorizontalAlignment();
                currentSection.FooterTextVerticalAlignment = section.GetFooterVerticalAlignment();
                currentSection.GroupHeaderColor = section.GetGroupHeaderBackgroundColor();

                for (int i = 0; i < section.ChildrenCount; i++ )
                {
                    IWidget widget = section.GetChild(i);
                    if (widget is ListViewItem)
                    {
                        ListViewItem listItem = widget as ListViewItem;
                        ListItem newItem = new ListItem();
                        newItem.Height = listItem.Height;
                        newItem.Width = listItem.Width;
                        newItem.Title = listItem.Text;
                        newItem.Subtitle = listItem.Subtitle;
                        newItem.FontSize = listItem.GetFontSize();
                        newItem.FontColor = listItem.GetFontColor();
                        newItem.SubtitleFontColor = listItem.GetSubtitleFontColor();
                        if (mListViewStyle == ListViewStyle.NoSubtitle)
                        {
                            newItem.SubtitleVisibility = Visibility.Collapsed;
                        }
                        else
                        {
                            newItem.SubtitleVisibility = Visibility.Visible;
                        }
                        newItem.ImageSource = listItem.IconImageSource;

                        listItem.ItemsSourceItemIndex = currentSection.Count;

                        currentSection.Add(newItem);

                        mModelToItemWidgetMap.Add(newItem.UniqueID, listItem);
                    }
                }

                return currentSection;
            }
Exemplo n.º 6
0
        public ListSection <T> _locals;     // Pointer to _stack, if there are local variables to the method.

        public STATE()
        {
            _stack      = new STACK();
            _this       = null;
            _arguments  = null;
            _locals     = null;
            _struct_ret = null;
        }
Exemplo n.º 7
0
        public ListSection <T> _locals;     // Pointer to _stack, if there are local variables to the method.

        public STATE()
        {
            _stack      = new StackQueue <T>();
            _this       = null;
            _arguments  = null;
            _locals     = null;
            _struct_ret = null;
        }
 public override bool MouseDoubleClick(Point pt)
 {
     if (_displayMode == DisplayMode.Header && PointInChangeWidthHotSpot(pt))
     {
         ListSection listSection = ListSection;
         if (listSection != null)
         {
             listSection.SizeColumnsToFit(Column);
         }
     }
     return(true);
 }
Exemplo n.º 9
0
 public STATE(STATE <T, STACK> other)
 {
     _stack = new STACK();
     for (int i = 0; i < other._stack.Count; ++i)
     {
         _stack.Push(other._stack.PeekBottom(i));
     }
     _struct_ret = _stack.Section(other._struct_ret.Base, other._struct_ret.Len);
     _this       = _stack.Section(other._this.Base, other._this.Len);
     _arguments  = _stack.Section(other._arguments.Base, other._arguments.Len);
     _locals     = _stack.Section(other._locals.Base, other._locals.Len);
 }
Exemplo n.º 10
0
 /**
  * Adds a ListViewSection to the LongListSelector.
  * @param section The list view section to be added.
  */
 private void AddListSection(ListViewSection section)
 {
     base.AddChild(section);
     MoSync.Util.RunActionOnMainThreadSync(() =>
     {
         section.ListStyle = mListViewStyle;
         ListSection<ListItem> sectionModel = CreateSectionModelFromWidget(section);
         section.ItemsSourceSectionIndex = mListSections.Count;
         mListSections.Add(sectionModel);
         section.SectionIndex = mListSections.Count - 1;
     });
 }
Exemplo n.º 11
0
            /**
             * Rebuilds the list model.
             */
            public void RebuildList()
            {
                mListSections = new ObservableCollection<ListSection<ListItem>>();

                foreach (IWidget widget in mChildren)
                {
                    if (widget is ListViewSection)
                    {
                        ListViewSection section = widget as ListViewSection;
                        ListSection<ListItem> sectionModel = CreateSectionModelFromWidget(section);
                        mListSections.Add(sectionModel);
                    }
                }

                ReloadListData();
            }
Exemplo n.º 12
0
        private OrderListSection ParseOrderListSection(int level)
        {
            List <ListItemSection> items = new List <ListItemSection>();

            while (lineParser.Type != LineType.EOF)
            {
                if (lineParser.Type == LineType.ORDER_LIST_ITEM && lineParser.Level == level)
                {
                    items.Add(new ListItemSection(ParseText(lineParser.Text, lineParser.LineCount), '\0'));
                    if (lineParser.Parse() == false)
                    {
                        return(new OrderListSection(items.ToArray()));
                    }
                }
                else if (lineParser.Level > level)
                {
                    ListSection section = null;
                    if (lineParser.Type == LineType.LIST_ITEM)
                    {
                        section = ParseListSection(level + 1);
                    }
                    else if (lineParser.Type == LineType.ORDER_LIST_ITEM)
                    {
                        section = ParseOrderListSection(level + 1);
                    }
                    else
                    {
                        break;
                    }

                    // 要素がない場合は空白のリストアイテムを作成
                    if (items.Count <= 0)
                    {
                        items.Add(new ListItemSection(null, '\0'));
                    }

                    items[items.Count - 1].ChildList.Add(section);
                }
                else
                {
                    break;
                }
            }
            return(new OrderListSection(items.ToArray()));
        }
Exemplo n.º 13
0
        public override void Layout(GraphicsSettings gs, Size maximumSize)
        {
            CustomiseGroupingSection groupSection   = (CustomiseGroupingSection)_customiseGroupingSection;
            OptionsToolbarSection    optionsSection = (OptionsToolbarSection)_optionsToolbarSection;
            ListSection listSection = ListSection;

            groupSection.Location = Location;
            groupSection.Layout(gs, maximumSize);

            optionsSection.Layout(gs,
                                  new Size(Math.Max(optionsSection.MinimumWidth, maximumSize.Width - groupSection.MinimumWidth),
                                           groupSection.Size.Height));

            groupSection.Size       = new Size(maximumSize.Width - optionsSection.Size.Width, groupSection.Size.Height);
            optionsSection.Location = new Point(groupSection.Rectangle.Right, Location.Y);
            optionsSection.Visible  = true;

            Size = new Size(maximumSize.Width, optionsSection.Size.Height);
        }
Exemplo n.º 14
0
            /**
             * Inserts a list view section at a certain index.
             * @param child The widget to be added to the list.
             * @param index The index where the widget should be added.
             */
            private void InsertListSection(ListViewSection section, int index)
            {
                base.InsertChild(section, index);
                MoSync.Util.RunActionOnMainThreadSync(() =>
                {
                    section.ListStyle = mListViewStyle;
                    ListSection<ListItem> sectionModel = CreateSectionModelFromWidget(section);
                    section.ItemsSourceSectionIndex = index;
                    mListSections.Insert(index, sectionModel);
                    section.SectionIndex = index;

                    // update the section indexes for all the sections after the inserted one
                    for (int i = index + 1; i < mChildren.Count; i++)
                    {
                        if (mChildren[i] is ListViewSection)
                        {
                            (mChildren[i] as ListViewSection).ItemsSourceSectionIndex++;
                        }
                    }
                });
            }
Exemplo n.º 15
0
 /**
  * Reloads a section at a certain index inside the long list selector items source.
  */
 public void UpdateSection(int sectionIndex, ListSection<ListItem> newSection)
 {
     if (mListSections.Count > sectionIndex)
     {
         mListSections[sectionIndex] = newSection;
     }
 }
Exemplo n.º 16
0
            /**
             * Creates a section model from the added widget.
             */
            private ListSection<ListItem> CreateSectionModelFromWidget(ListViewSection section)
            {
                ListSection<ListItem> currentSection = new ListSection<ListItem>();
                currentSection.Title = section.Title;
                currentSection.Header = section.Header;
                currentSection.Footer = section.Footer;
                currentSection.HeaderColor = section.GetHeaderBackgroundColor();
                currentSection.HeaderFontColor = section.GetHeaderFontColor();
                currentSection.HeaderFontFamily = section.GetHeaderFontFamily();
                currentSection.HeaderFontSize = section.GetHeaderFontSize();
                currentSection.HeaderFontStyle = section.GetHeaderFontStyle();
                currentSection.HeaderFontWeight = section.GetHeaderFontWeight();
                currentSection.HeaderTextHorizontalAlignment = section.GetHeaderHorizontalAlignment();
                currentSection.HeaderTextVerticalAlignment = section.GetHeaderVerticalAlignment();
                currentSection.Footer = section.Footer;
                currentSection.FooterColor = section.GetFooterBackgroundColor();
                currentSection.FooterFontColor = section.GetFooterFontColor();
                currentSection.FooterFontFamily = section.GetFooterFontFamily();
                currentSection.FooterFontSize = section.GetFooterFontSize();
                currentSection.FooterFontStyle = section.GetFooterFontStyle();
                currentSection.FooterFontWeight = section.GetFooterFontWeight();
                currentSection.FooterTextHorizontalAlignment = section.GetFooterHorizontalAlignment();
                currentSection.FooterTextVerticalAlignment = section.GetFooterVerticalAlignment();
                currentSection.GroupHeaderColor = section.GetGroupHeaderBackgroundColor();

                for (int i = 0; i < section.ChildrenCount; i++ )
                {
                    IWidget widget = section.GetChild(i);
                    if (widget is ListViewItem)
                    {
                        ListViewItem listItem = widget as ListViewItem;
                        ListItem newItem = new ListItem();
                        newItem.Height = listItem.Height;
                        newItem.Width = listItem.Width;
                        newItem.Title = listItem.Text;
                        newItem.Subtitle = listItem.Subtitle;
                        newItem.FontSize = listItem.GetFontSize();
                        newItem.FontColor = listItem.GetFontColor();
                        newItem.SubtitleFontColor = listItem.GetSubtitleFontColor();
                        if (mListViewStyle == ListViewStyle.NoSubtitle)
                        {
                            newItem.SubtitleVisibility = Visibility.Collapsed;
                        }
                        else
                        {
                            newItem.SubtitleVisibility = Visibility.Visible;
                        }
                        newItem.ImageSource = listItem.IconImageSource;

                        listItem.ItemsSourceItemIndex = currentSection.Count;

                        currentSection.Add(newItem);

                        mModelToItemWidgetMap.Add(newItem.UniqueID, listItem);
                    }
                }

                return currentSection;
            }
        public static void Run()
        {
            // ExStart:AddTableOfContents
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();

            // Create a PDF instance
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
            // Create a list section 
            Aspose.Pdf.Generator.ListSection tocSection = new Aspose.Pdf.Generator.ListSection("Table Of Contents");
            // Set its list type as table of contents
            tocSection.ListType = ListType.TableOfContents;
            // Add the list section to the sections collection of the Pdf document
            pdf.Sections.Add(tocSection);

            // Define the format of the four levels list by setting the left margins and
            // Text format settings of each level
            tocSection.ListFormatArray.Length = 4;
            tocSection.ListFormatArray[0].LeftMargin = 0;
            tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true;
            tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true;
            tocSection.ListFormatArray[1].LeftMargin = 10;
            tocSection.ListFormatArray[1].TextInfo.IsUnderline = true;
            tocSection.ListFormatArray[1].TextInfo.FontSize = 10;
            tocSection.ListFormatArray[2].LeftMargin = 20;
            tocSection.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true;
            tocSection.ListFormatArray[3].LeftMargin = 30;
            tocSection.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true;

            // Create a section in the Pdf document
            Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();

            // Add four headings in the section
            for (int Level = 1; Level < 5; Level++)
            {
                Aspose.Pdf.Generator.Heading heading1 = new Aspose.Pdf.Generator.Heading(pdf, sec1, Level);
                Segment segment1 = new Segment(heading1);
                heading1.Segments.Add(segment1);
                heading1.IsAutoSequence = true;
                segment1.Content = "this is heading of level ";
                segment1.Content += Level.ToString();

                // Add the heading into Table Of Contents. 
                heading1.IsInList = true;
                // Heading2.TOC = tocSection;
                sec1.Paragraphs.Add(heading1);
            }

            // Create a list section 
            ListSection tocSection2 = new ListSection("Second Table Of Contents");
            // Set its list type as table of of contents
            tocSection2.ListType = ListType.TableOfContents;
            // Add the list section to the sections collection of the Pdf document
            pdf.Sections.Add(tocSection2);

            // Define the format of the four levels list by setting the left margins and
            // Text format settings of each level
            tocSection2.ListFormatArray.Length = 4;
            tocSection2.ListFormatArray[0].LeftMargin = 0;
            tocSection2.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true;
            tocSection2.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true;
            tocSection2.ListFormatArray[1].LeftMargin = 10;
            tocSection2.ListFormatArray[1].TextInfo.IsUnderline = true;
            tocSection2.ListFormatArray[1].TextInfo.FontSize = 10;
            tocSection2.ListFormatArray[2].LeftMargin = 20;
            tocSection2.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true;
            tocSection2.ListFormatArray[3].LeftMargin = 30;
            tocSection2.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true;

            // Create a section in the Pdf document
            Aspose.Pdf.Generator.Section sec2 = pdf.Sections.Add();

            // Add four headings in the section
            for (int Level = 1; Level < 5; Level++)
            {
                Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf, sec1, Level);
                Segment segment2 = new Segment(heading2);
                heading2.Segments.Add(segment2);
                heading2.IsAutoSequence = true;
                segment2.Content = "this is heading of level ";
                segment2.Content += Level.ToString();

                // Add the heading into Table Of Contents. 
                heading2.IsInList = true;
                // Add the heading elements to second ListSection
                heading2.TOC = tocSection2;
                // Add the heading obejct to paragraphs colelction of section2
                sec2.Paragraphs.Add(heading2);
            }     
           
            dataDir = dataDir + "Multiple_TOC_out.pdf";
            // Save the resultant PDF document
            pdf.Save(dataDir);
            // ExEnd:AddTableOfContents           
        }        
Exemplo n.º 18
0
 public virtual void DeSerializeState(TextReader reader)
 {
     ListSection.DeSerializeState(reader);
 }
Exemplo n.º 19
0
            /**
             * Outputs the index of the section in focus and the index of the selected item
             * within that section.
             */
            private void GetSectionAndSelectedItemIndex(out int sectionIndex, out int itemIndex)
            {
                // we need to find the selected item through the LongListSelector
                // items source and through the child widgets aswell in order to
                // set its selected state
                sectionIndex = -1;
                itemIndex = -1;

                // we need to first find the selected item index and its section index
                // within the long list selector items source
                int itemsSourceSectionIndex = -1;
                int itemsSourceItemIndex = -1;

                for (int i = 0; i < mListSections.Count; i++)
                {
                    ListSection<ListItem> section = mListSections[i];

                    int index = section.IndexOf(mLongListSelector.SelectedItem as ListItem);
                    if ( index >= 0)
                    {
                        itemsSourceSectionIndex = i;
                        itemsSourceItemIndex = index;
                    }

                    // deselect all the items
                    for (int j = 0; j < section.Count; j++)
                    {
                        section[j].FontColor = mModelToItemWidgetMap[section[j].UniqueID].GetFontColor();
                        section[j].SubtitleFontColor = mModelToItemWidgetMap[section[j].UniqueID].GetSubtitleFontColor();
                    }
                }

                // select the current item
                SolidColorBrush phoneAccentBrush = Application.Current.Resources["PhoneAccentBrush"] as SolidColorBrush;
                (mLongListSelector.SelectedItem as ListItem).FontColor = phoneAccentBrush;
                (mLongListSelector.SelectedItem as ListItem).SubtitleFontColor = phoneAccentBrush;

                // set the coresponding list view item widget selection status
                ListViewItem selectedItem = mModelToItemWidgetMap[(mLongListSelector.SelectedItem as ListItem).UniqueID];
                selectedItem.ItemSelected = true;

                if (mLastSelectedItemWidget != null)
                {
                    mLastSelectedItemWidget.ItemSelected = false;
                }
                mLastSelectedItemWidget = selectedItem;

                // then we need to go through the widget children and find
                // the section/item that match the section/item indexes within
                // the items source
                for (int i = 0; i < mChildren.Count; i++)
                {
                    if (mChildren[i] is ListViewSection)
                    {
                        ListViewSection section = mChildren[i] as ListViewSection;
                        if (section.ItemsSourceSectionIndex == itemsSourceSectionIndex)
                        {
                            for (int j = 0; j < section.ChildrenCount; j++)
                            {
                                if (section.GetChild(j) is ListViewItem)
                                {
                                    ListViewItem item = section.GetChild(j) as ListViewItem;
                                    if (item.ItemsSourceItemIndex == itemsSourceItemIndex)
                                    {
                                        sectionIndex = i;
                                        itemIndex = j;
                                    }
                                }
                            }
                        }
                    }
                }
            }
Exemplo n.º 20
0
 /// <summary>
 /// Sets the column width to fit the specified columns contents.
 /// </summary>
 /// <param name="columns">Columns to size</param>
 public void SizeColumnsToFit(Column[] columns)
 {
     ListSection.SizeColumnsToFit(columns);
 }
Exemplo n.º 21
0
            public override bool Equals(object obj)
            {
                ListSection <T> that = obj as ListSection <T>;

                return((that != null) && (this.Title.Equals(that.Title)));
            }
Exemplo n.º 22
0
        private void EncodeInternal(TextWriter writer, Section[] sections)
        {
            Dictionary <HeadSection, string> headRefs = CreateTableOfContents(sections);

            for (int i = 0; i < sections.Length; i++)
            {
                Section section = sections[i];

                if (section is ParagraphSection)
                {
                    ParagraphSection s = (ParagraphSection)section;

                    writer.Write("<p>");
                    WriteText(writer, s.Text);
                    writer.WriteLine("</p>");
                }
                else if (section is HeadSection)
                {
                    HeadSection s = (HeadSection)section;

                    writer.Write("<a name=\"{0}\">", headRefs[s]);
                    writer.Write("<h{0}>", s.Level);
                    WriteText(writer, s.Text);
                    writer.Write("</h{0}>", s.Level);
                    writer.WriteLine("</a>");
                }
                else if (section is HorizonSection)
                {
                    HorizonSection s = (HorizonSection)section;

                    writer.Write("<hr/>");
                }
                else if (section is CodeSection)
                {
                    CodeSection s = (CodeSection)section;

                    writer.Write("<pre class=\"code\"><code>");
                    writer.Write(Escape(s.Text));
                    writer.WriteLine("</code></pre>");
                }
                else if (section is QuoteSection)
                {
                    QuoteSection s = (QuoteSection)section;

                    writer.Write("<blockquote>");
                    EncodeInternal(writer, s.Texts);
                    writer.WriteLine("</blockquote>");
                }
                else if (section is OrderListSection)
                {
                    OrderListSection s = (OrderListSection)section;

                    writer.WriteLine("<ol>");
                    foreach (ListItemSection j in s.Items)
                    {
                        writer.Write("<li>");
                        WriteText(writer, j.Text);
                        EncodeInternal(writer, j.ChildList.ToArray());
                        writer.WriteLine("</li>");
                    }
                    writer.WriteLine("</ol>");
                }
                else if (section is ListSection)
                {
                    ListSection s = (ListSection)section;

                    writer.WriteLine("<ul>");
                    foreach (ListItemSection j in s.Items)
                    {
                        writer.Write(String.Format("<li {0}>", GetListClass(j.Mark)));
                        WriteText(writer, j.Text);
                        EncodeInternal(writer, j.ChildList.ToArray());
                        writer.WriteLine("</li>");
                    }
                    writer.WriteLine("</ul>");
                }
                else if (section is DefinitionListSection)
                {
                    DefinitionListSection s = (DefinitionListSection)section;

                    writer.Write("<dl>");
                    foreach (DefinitionItemSection j in s.Items)
                    {
                        writer.Write("<dt>");
                        WriteText(writer, j.Caption);
                        writer.WriteLine("</dt>");
                        writer.Write("<dd>");
                        WriteText(writer, j.Data);
                        writer.WriteLine("</dd>");
                    }
                    writer.WriteLine("</dl>");
                }
                else if (section is ContentsSection)
                {
                    ContentsSection s = (ContentsSection)section;

                    List <ContentItem> contents
                        = ContentsTableGenerator.Generate(sections, i, s.LevelLower, s.LevelUpper);

                    WriteContents(writer, contents, headRefs);
                }
                else if (section is ContentsAllSection)
                {
                    ContentsAllSection s = (ContentsAllSection)section;

                    List <ContentItem> contents
                        = ContentsTableGenerator.GenerateAll(sections, s.LevelLower, s.LevelUpper);

                    WriteContents(writer, contents, headRefs);
                }
            }
        }
Exemplo n.º 23
0
        public static void Run()
        {
            // ExStart:AddTableOfContents
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();

            // Create a PDF instance
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
            // Create a list section
            Aspose.Pdf.Generator.ListSection tocSection = new Aspose.Pdf.Generator.ListSection("Table Of Contents");
            // Set its list type as table of contents
            tocSection.ListType = ListType.TableOfContents;
            // Add the list section to the sections collection of the Pdf document
            pdf.Sections.Add(tocSection);

            // Define the format of the four levels list by setting the left margins and
            // Text format settings of each level
            tocSection.ListFormatArray.Length        = 4;
            tocSection.ListFormatArray[0].LeftMargin = 0;
            tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontBold   = true;
            tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true;
            tocSection.ListFormatArray[1].LeftMargin                  = 10;
            tocSection.ListFormatArray[1].TextInfo.IsUnderline        = true;
            tocSection.ListFormatArray[1].TextInfo.FontSize           = 10;
            tocSection.ListFormatArray[2].LeftMargin                  = 20;
            tocSection.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true;
            tocSection.ListFormatArray[3].LeftMargin                  = 30;
            tocSection.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true;

            // Create a section in the Pdf document
            Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();

            // Add four headings in the section
            for (int Level = 1; Level < 5; Level++)
            {
                Aspose.Pdf.Generator.Heading heading1 = new Aspose.Pdf.Generator.Heading(pdf, sec1, Level);
                Segment segment1 = new Segment(heading1);
                heading1.Segments.Add(segment1);
                heading1.IsAutoSequence = true;
                segment1.Content        = "this is heading of level ";
                segment1.Content       += Level.ToString();

                // Add the heading into Table Of Contents.
                heading1.IsInList = true;
                // Heading2.TOC = tocSection;
                sec1.Paragraphs.Add(heading1);
            }

            // Create a list section
            ListSection tocSection2 = new ListSection("Second Table Of Contents");

            // Set its list type as table of of contents
            tocSection2.ListType = ListType.TableOfContents;
            // Add the list section to the sections collection of the Pdf document
            pdf.Sections.Add(tocSection2);

            // Define the format of the four levels list by setting the left margins and
            // Text format settings of each level
            tocSection2.ListFormatArray.Length        = 4;
            tocSection2.ListFormatArray[0].LeftMargin = 0;
            tocSection2.ListFormatArray[0].TextInfo.IsTrueTypeFontBold   = true;
            tocSection2.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true;
            tocSection2.ListFormatArray[1].LeftMargin                  = 10;
            tocSection2.ListFormatArray[1].TextInfo.IsUnderline        = true;
            tocSection2.ListFormatArray[1].TextInfo.FontSize           = 10;
            tocSection2.ListFormatArray[2].LeftMargin                  = 20;
            tocSection2.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true;
            tocSection2.ListFormatArray[3].LeftMargin                  = 30;
            tocSection2.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true;

            // Create a section in the Pdf document
            Aspose.Pdf.Generator.Section sec2 = pdf.Sections.Add();

            // Add four headings in the section
            for (int Level = 1; Level < 5; Level++)
            {
                Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf, sec1, Level);
                Segment segment2 = new Segment(heading2);
                heading2.Segments.Add(segment2);
                heading2.IsAutoSequence = true;
                segment2.Content        = "this is heading of level ";
                segment2.Content       += Level.ToString();

                // Add the heading into Table Of Contents.
                heading2.IsInList = true;
                // Add the heading elements to second ListSection
                heading2.TOC = tocSection2;
                // Add the heading obejct to paragraphs colelction of section2
                sec2.Paragraphs.Add(heading2);
            }

            dataDir = dataDir + "Multiple_TOC_out.pdf";
            // Save the resultant PDF document
            pdf.Save(dataDir);
            // ExEnd:AddTableOfContents
        }
Exemplo n.º 24
0
 public virtual void SerializeState(TextWriter writer)
 {
     ListSection.SerializeState(writer);
 }