OneNoteConversionTool.OutputGenerator.OneNoteGenerator.SetSubPage C# (CSharp) Method

SetSubPage() public method

Make the page as subpage (if isSet true) or promote it (if isSet if false)
public SetSubPage ( string sectionId, string pageId, bool isSet = true ) : void
sectionId string
pageId string
isSet bool defaults to true, if true, increment pageLevel, else decrement pageLevel
return void
		public void SetSubPage(string sectionId, string pageId, bool isSet = true)
		{
			try
			{
				string hierarchy = string.Empty;
				_mApp.GetHierarchy(sectionId, HierarchyScope.hsPages, out hierarchy);

				XmlDocument doc = new XmlDocument();
				doc.LoadXml(hierarchy);

				string xpath = string.Format("//one:Page[@ID='{0}']", pageId);

				XmlNode page = doc.SelectSingleNode(xpath, GetNSManager(doc.NameTable));
				var pageLevel = int.Parse(page.Attributes["pageLevel"].Value);


				if (isSet)
				{
					++pageLevel;
				}
				else
				{
					--pageLevel;
					pageLevel = pageLevel > 0 ? pageLevel : 1;
				}

				page.Attributes["pageLevel"].Value = pageLevel.ToString();
				_mApp.UpdateHierarchy(doc.OuterXml);
			}
			catch (Exception e)
			{
				throw new ApplicationException("Error in SetAsSubPage: " + e.Message, e);
			}
		}

Usage Example

		/// <summary>
		/// Helper method to include the common code between the trainer and the student create notebook when converting 
		/// Power Point files that have sections
		/// </summary>
		/// <param name="pptOpenXml"></param>
		/// <param name="imgsPath"></param>
		/// <param name="note"></param>
		/// <param name="sectionId"></param>
		/// <param name="sectionNames"></param>
		/// <param name="slidesInSections"></param>
		/// <param name="isTrainer"></param>
		private void ConvertPowerPointWithSectionsToOneNote(PowerPointOpenXml pptOpenXml, string imgsPath, OneNoteGenerator note, 
			string sectionId, List<string> sectionNames, List<List<int>> slidesInSections, bool isTrainer)
		{
			var pptSectionsPageIds = new List<string>();

			for (int i = 0; i < sectionNames.Count; i++)
			{
				string pptSectionPageId = note.CreatePage(sectionNames[i], sectionId);
				foreach (var slideNumber in slidesInSections[i])
				{
					string pageId;
					if (isTrainer)
					{
						pageId = InsertPowerPointSlideInOneNote(slideNumber, pptOpenXml, imgsPath, note, sectionId,
							true, StudentNotesTitle, true, TrainerNotesTitle);

					}
					else
					{
						pageId = InsertPowerPointSlideInOneNote(slideNumber, pptOpenXml, imgsPath, note, sectionId,
							true, StudentNotesTitle, false);
					}
					if (!pageId.Equals(String.Empty))
					{
						note.SetSubPage(sectionId, pageId);
						note.SetShowDate(pageId, false);
						note.SetShowTime(pageId, false);
					}
				}
				pptSectionsPageIds.Add(pptSectionPageId);
			}

			string tocPageId = note.CreateTableOfContentPage(sectionId);
			note.SetShowDate(tocPageId, false);
			note.SetShowTime(tocPageId, false);

			foreach (var pptSectionPageId in pptSectionsPageIds)
			{
				note.SetCollapsePage(pptSectionPageId);
				note.SetShowDate(pptSectionPageId, false);
				note.SetShowTime(pptSectionPageId, false);
			}
		}
All Usage Examples Of OneNoteConversionTool.OutputGenerator.OneNoteGenerator::SetSubPage