/// <summary>
 ///     Export the capture to the specified page
 /// </summary>
 /// <param name="oneNoteApplication">IOneNoteApplication</param>
 /// <param name="surfaceToUpload">ISurface</param>
 /// <param name="page">OneNotePage</param>
 /// <returns>bool true if everything worked</returns>
 private static bool ExportToPage(IOneNoteApplication oneNoteApplication, ISurface surfaceToUpload, OneNotePage page)
 {
     if (oneNoteApplication == null)
     {
         return(false);
     }
     using (var pngStream = new MemoryStream())
     {
         var pngOutputSettings = new SurfaceOutputSettings(OutputFormats.png, 100, false);
         ImageOutput.SaveToStream(surfaceToUpload, pngStream, pngOutputSettings);
         var base64String   = Convert.ToBase64String(pngStream.GetBuffer());
         var imageXmlStr    = string.Format(XmlImageContent, base64String, surfaceToUpload.Screenshot.Width, surfaceToUpload.Screenshot.Height);
         var pageChangesXml = string.Format(XmlOutline, imageXmlStr, page.ID, OnenoteNamespace2010, page.Name);
         Log.Info().WriteLine("Sending XML: {0}", pageChangesXml);
         oneNoteApplication.UpdatePageContent(pageChangesXml, DateTime.MinValue, XMLSchema.xs2010, false);
         try
         {
             oneNoteApplication.NavigateTo(page.ID, null, false);
         }
         catch (Exception ex)
         {
             Log.Warn().WriteLine(ex, "Unable to navigate to the target page");
         }
         return(true);
     }
 }
Exemple #2
0
 public static void ExportToPage(Bitmap imageToExport, OneNotePage page)
 {
     using (MemoryStream pngStream = new MemoryStream()) {
         imageToExport.Save(pngStream, ImageFormat.Png);
         string base64String   = Convert.ToBase64String(pngStream.GetBuffer());
         string imageXmlStr    = string.Format(XML_IMAGE_CONTENT, base64String, imageToExport.Width, imageToExport.Height);
         string pageChangesXml = string.Format(XML_OUTLINE, new object[] { imageXmlStr, page.PageID, ONENOTE_NAMESPACE_2010, page.PageName });
         using (IOneNoteApplication oneNoteApplication = COMWrapper.GetOrCreateInstance <IOneNoteApplication>()) {
             LOG.InfoFormat("Sending XML: {0}", pageChangesXml);
             oneNoteApplication.UpdatePageContent(pageChangesXml, DateTime.MinValue, XMLSchema.xs2010, false);
         }
     }
 }
Exemple #3
0
 public static void ExportToPage(ISurface surfaceToUpload, OneNotePage page)
 {
     using (MemoryStream pngStream = new MemoryStream()) {
         SurfaceOutputSettings pngOutputSettings = new SurfaceOutputSettings(OutputFormat.png, 100, false);
         ImageOutput.SaveToStream(surfaceToUpload, pngStream, pngOutputSettings);
         string base64String   = Convert.ToBase64String(pngStream.GetBuffer());
         string imageXmlStr    = string.Format(XML_IMAGE_CONTENT, base64String, surfaceToUpload.Image.Width, surfaceToUpload.Image.Height);
         string pageChangesXml = string.Format(XML_OUTLINE, new object[] { imageXmlStr, page.PageID, ONENOTE_NAMESPACE_2010, page.PageName });
         using (IOneNoteApplication oneNoteApplication = COMWrapper.GetOrCreateInstance <IOneNoteApplication>()) {
             LOG.InfoFormat("Sending XML: {0}", pageChangesXml);
             oneNoteApplication.UpdatePageContent(pageChangesXml, DateTime.MinValue, XMLSchema.xs2010, false);
         }
     }
 }
Exemple #4
0
		/// <summary>
		/// Can be used to change the title of a page
		/// </summary>
		/// <param name="oneNoteApplication"></param>
		/// <param name="pageId"></param>
		/// <param name="title"></param>
		private static void UpdatePageTitle(IOneNoteApplication oneNoteApplication, string pageId, string title) {
			try {
				string pageXML = "";
				oneNoteApplication.GetPageContent(pageId, out pageXML, PageInfo.piAll, XMLSchema.xsCurrent);
				XmlDocument doc = new XmlDocument();
				doc.LoadXml(pageXML);
				XmlNamespaceManager namespaceManager = new XmlNamespaceManager(doc.NameTable);
				namespaceManager.AddNamespace("one", ONENOTE_NAMESPACE_2010);

				doc.SelectSingleNode("//one:T", namespaceManager).InnerText = title;
				// Update the page
				oneNoteApplication.UpdatePageContent(doc.OuterXml, DateTime.MinValue, XMLSchema.xs2010, true);

			} catch(Exception ex) {
				LOG.Warn("Couldn't set page title.", ex);
			}
		}
        /// <summary>
        /// Can be used to change the title of a page
        /// </summary>
        /// <param name="oneNoteApplication"></param>
        /// <param name="pageId"></param>
        /// <param name="title"></param>
        private static void UpdatePageTitle(IOneNoteApplication oneNoteApplication, string pageId, string title)
        {
            try {
                string pageXML = "";
                oneNoteApplication.GetPageContent(pageId, out pageXML, PageInfo.piAll, XMLSchema.xsCurrent);
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(pageXML);
                XmlNamespaceManager namespaceManager = new XmlNamespaceManager(doc.NameTable);
                namespaceManager.AddNamespace("one", ONENOTE_NAMESPACE_2010);

                doc.SelectSingleNode("//one:T", namespaceManager).InnerText = title;
                // Update the page
                oneNoteApplication.UpdatePageContent(doc.OuterXml, DateTime.MinValue, XMLSchema.xs2010, true);
            } catch (Exception ex) {
                LOG.Warn("Couldn't set page title.", ex);
            }
        }
 /// <summary>
 /// Export the capture to the specified page
 /// </summary>
 /// <param name="oneNoteApplication">IOneNoteApplication</param>
 /// <param name="surfaceToUpload">ISurface</param>
 /// <param name="page">OneNotePage</param>
 /// <returns>bool true if everything worked</returns>
 private static bool ExportToPage(IOneNoteApplication oneNoteApplication, ISurface surfaceToUpload, OneNotePage page)
 {
     if (oneNoteApplication == null)
     {
         return(false);
     }
     using (MemoryStream pngStream = new MemoryStream()) {
         SurfaceOutputSettings pngOutputSettings = new SurfaceOutputSettings(OutputFormat.png, 100, false);
         ImageOutput.SaveToStream(surfaceToUpload, pngStream, pngOutputSettings);
         string base64String   = Convert.ToBase64String(pngStream.GetBuffer());
         string imageXmlStr    = string.Format(XML_IMAGE_CONTENT, base64String, surfaceToUpload.Image.Width, surfaceToUpload.Image.Height);
         string pageChangesXml = string.Format(XML_OUTLINE, new object[] { imageXmlStr, page.ID, ONENOTE_NAMESPACE_2010, page.Name });
         LOG.InfoFormat("Sending XML: {0}", pageChangesXml);
         oneNoteApplication.UpdatePageContent(pageChangesXml, DateTime.MinValue, XMLSchema.xs2010, false);
         try {
             oneNoteApplication.NavigateTo(page.ID, null, false);
         } catch (Exception ex) {
             LOG.Warn("Unable to navigate to the target page", ex);
         }
         return(true);
     }
 }
Exemple #7
0
		/// <summary>
		/// Export the capture to the specified page
		/// </summary>
		/// <param name="oneNoteApplication">IOneNoteApplication</param>
		/// <param name="surfaceToUpload">ISurface</param>
		/// <param name="page">OneNotePage</param>
		/// <returns>bool true if everything worked</returns>
		private static bool ExportToPage(IOneNoteApplication oneNoteApplication, ISurface surfaceToUpload, OneNotePage page) {
			if(oneNoteApplication == null) {
				return false;
			}
			using (MemoryStream pngStream = new MemoryStream()) {
				SurfaceOutputSettings pngOutputSettings = new SurfaceOutputSettings(OutputFormat.png, 100, false);
				ImageOutput.SaveToStream(surfaceToUpload, pngStream, pngOutputSettings);
				string base64String = Convert.ToBase64String(pngStream.GetBuffer());
				string imageXmlStr = string.Format(XML_IMAGE_CONTENT, base64String, surfaceToUpload.Image.Width, surfaceToUpload.Image.Height);
				string pageChangesXml = string.Format(XML_OUTLINE, new object[] { imageXmlStr, page.ID, ONENOTE_NAMESPACE_2010, page.Name });
				LOG.InfoFormat("Sending XML: {0}", pageChangesXml);
				oneNoteApplication.UpdatePageContent(pageChangesXml, DateTime.MinValue, XMLSchema.xs2010, false);
				try {
					oneNoteApplication.NavigateTo(page.ID, null, false);
				} catch(Exception ex) {
					LOG.Warn("Unable to navigate to the target page", ex);
				}
				return true;
			}
		}