Programtically adding Inks to page

D

David

Hi
I would like to create OneNote 07 addin.
1) How can I add custom toolbar and button to OneNote? I found IOneNoteAddIn
but it has no tolbars/buttons interfaces.
2) I will add new section and page and want to add Microsoft Ink to the
page. I guess I have to serialize Ink and craft some XML, but I connot find
any explanation or API.
Please help,
Thanks, David
 
D

David

Thanks for the tip,

1)About buttons: each toolbar can have only one button?
2)Is there any sample code for adding inks ?
thanks, David
 
A

Ani

Each toolbar button launches a user specified program . The details of how to
set that up can be found here...

http://blogs.msdn.com/descapa/archive/2006/08/31/734298.aspx


Here is some code I have to update the title of a page. Instead of putting
in text in the XML you could put in the ink content. I would recommend
looking at a sample XML generated by a OneNote page using OMSpy
http://blogs.msdn.com/descapa/archive/2007/02/12/omspy-a-onenote-developer-s-tool.aspx

This will give you an idea of the kind of XML you will need to put in.

private void changePageTitle(TreeNode tnode, String newTitle)
{

// load page
String pageContent;
onApp.GetPageContent(getAttribute(tnode, "ID"), out pageContent,
OneNote.PageInfo.piAll);
XmlDocument pageXml = new XmlDocument();
// C# note :- if we pass a String we get URI too long error
pageXml.Load(new System.IO.StringReader(pageContent));
string OneNoteNamespace =
"http://schemas.microsoft.com/office/onenote/2007/onenote";
XmlNamespaceManager nsmgr = new
XmlNamespaceManager(pageXml.NameTable);
nsmgr.AddNamespace("one", OneNoteNamespace);

// Clear Previous Title ( Handwritten or otherwise)
XmlNode titleElem =
pageXml.SelectSingleNode("//one:Title/one:OE", nsmgr);
if (titleElem != null)
{
titleElem.InnerXml = "";
// Create new Tittle Element and push in new title
// IF we want to add Font change functionality code to go
here :)
XmlElement newTitleNode = pageXml.CreateElement("one:T",
pageXml.DocumentElement.NamespaceURI);


newTitleNode.InnerXml = "<![CDATA[" + newTitle.Trim() + "]]>";
titleElem.AppendChild(newTitleNode);
//newTitleNode.InnerXml = "<![CDATA[Testing]]>";

onApp.UpdatePageContent(pageXml.InnerXml,
System.DateTime.MinValue);
}


}
 
D

David

Hi
thanks for erpsonse, its very useful.
About inks : xml node has position and size attributes, but what is a
coordinate system that OneNote uses to plcae its objects?
what this means :
<one:position x="404.2488098144531" y="41.41414642333984" z="25" />
<one:Size width="68.28662109375" height="157.1244049072266" />
David.

Ani said:
Each toolbar button launches a user specified program . The details of how to
set that up can be found here...

http://blogs.msdn.com/descapa/archive/2006/08/31/734298.aspx


Here is some code I have to update the title of a page. Instead of putting
in text in the XML you could put in the ink content. I would recommend
looking at a sample XML generated by a OneNote page using OMSpy
http://blogs.msdn.com/descapa/archive/2007/02/12/omspy-a-onenote-developer-s-tool.aspx

This will give you an idea of the kind of XML you will need to put in.

private void changePageTitle(TreeNode tnode, String newTitle)
{

// load page
String pageContent;
onApp.GetPageContent(getAttribute(tnode, "ID"), out pageContent,
OneNote.PageInfo.piAll);
XmlDocument pageXml = new XmlDocument();
// C# note :- if we pass a String we get URI too long error
pageXml.Load(new System.IO.StringReader(pageContent));
string OneNoteNamespace =
"http://schemas.microsoft.com/office/onenote/2007/onenote";
XmlNamespaceManager nsmgr = new
XmlNamespaceManager(pageXml.NameTable);
nsmgr.AddNamespace("one", OneNoteNamespace);

// Clear Previous Title ( Handwritten or otherwise)
XmlNode titleElem =
pageXml.SelectSingleNode("//one:Title/one:OE", nsmgr);
if (titleElem != null)
{
titleElem.InnerXml = "";
// Create new Tittle Element and push in new title
// IF we want to add Font change functionality code to go
here :)
XmlElement newTitleNode = pageXml.CreateElement("one:T",
pageXml.DocumentElement.NamespaceURI);


newTitleNode.InnerXml = "<![CDATA[" + newTitle.Trim() + "]]>";
titleElem.AppendChild(newTitleNode);
//newTitleNode.InnerXml = "<![CDATA[Testing]]>";

onApp.UpdatePageContent(pageXml.InnerXml,
System.DateTime.MinValue);
}


}











David said:
Thanks for the tip,

1)About buttons: each toolbar can have only one button?
2)Is there any sample code for adding inks ?
thanks, David
 
D

David

Hi
I still cannot understand how Ink element shall be crafted. How shall I
create ObjectID? Any chance for real sample code? ( not "add blankpage,add
title thing")
Documenation is very,very poor here...
Please help.
David


David said:
Hi
thanks for erpsonse, its very useful.
About inks : xml node has position and size attributes, but what is a
coordinate system that OneNote uses to plcae its objects?
what this means :
<one:position x="404.2488098144531" y="41.41414642333984" z="25" />
<one:Size width="68.28662109375" height="157.1244049072266" />
David.

Ani said:
Each toolbar button launches a user specified program . The details of how to
set that up can be found here...

http://blogs.msdn.com/descapa/archive/2006/08/31/734298.aspx


Here is some code I have to update the title of a page. Instead of putting
in text in the XML you could put in the ink content. I would recommend
looking at a sample XML generated by a OneNote page using OMSpy
http://blogs.msdn.com/descapa/archive/2007/02/12/omspy-a-onenote-developer-s-tool.aspx

This will give you an idea of the kind of XML you will need to put in.

private void changePageTitle(TreeNode tnode, String newTitle)
{

// load page
String pageContent;
onApp.GetPageContent(getAttribute(tnode, "ID"), out pageContent,
OneNote.PageInfo.piAll);
XmlDocument pageXml = new XmlDocument();
// C# note :- if we pass a String we get URI too long error
pageXml.Load(new System.IO.StringReader(pageContent));
string OneNoteNamespace =
"http://schemas.microsoft.com/office/onenote/2007/onenote";
XmlNamespaceManager nsmgr = new
XmlNamespaceManager(pageXml.NameTable);
nsmgr.AddNamespace("one", OneNoteNamespace);

// Clear Previous Title ( Handwritten or otherwise)
XmlNode titleElem =
pageXml.SelectSingleNode("//one:Title/one:OE", nsmgr);
if (titleElem != null)
{
titleElem.InnerXml = "";
// Create new Tittle Element and push in new title
// IF we want to add Font change functionality code to go
here :)
XmlElement newTitleNode = pageXml.CreateElement("one:T",
pageXml.DocumentElement.NamespaceURI);


newTitleNode.InnerXml = "<![CDATA[" + newTitle.Trim() + "]]>";
titleElem.AppendChild(newTitleNode);
//newTitleNode.InnerXml = "<![CDATA[Testing]]>";

onApp.UpdatePageContent(pageXml.InnerXml,
System.DateTime.MinValue);
}


}











David said:
Thanks for the tip,

1)About buttons: each toolbar can have only one button?
2)Is there any sample code for adding inks ?
thanks, David


:

Here are some resources you might find useful

1.
http://blogs.msdn.com/johnguin/archive/2007/12/20/how-to-create-a-floating-toolbar-in-onenote.aspx

( John's post explaining how to create a toolbar )

2.
http://www.microsoft.com/downloads/...80-f2c0-4b80-9ad1-2cb0c300aef9&displaylang=en

contains the XML schema reference for OneNote which outlines the format for
ink XML.

3. OneNote API :
http://msdn.microsoft.com/en-us/office/aa905452.aspx






:

Hi
I would like to create OneNote 07 addin.
1) How can I add custom toolbar and button to OneNote? I found IOneNoteAddIn
but it has no tolbars/buttons interfaces.
2) I will add new section and page and want to add Microsoft Ink to the
page. I guess I have to serialize Ink and craft some XML, but I connot find
any explanation or API.
Please help,
Thanks, David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top