Ynote Script

Ynote Script is the Scripting System embedded in Ynote Classic to extend it's functionality. This was achieved using the CSScript Library.

What is YnoteScript ?

YnoteScript is just C#. It is revolving around the IYnote object. It can use all the .NET Framework Classes, Libraries and external libraries too. For eg, to add an external library, add this to the first line of the file -

//css_reference {yourlibrary}.dll;

The library should be located in Ynote's Root Directory. For more information see here.

Getting Ready - Packing your bag

Ynote Classic uses two core libraries - 

Ynote Script is based on the CSScript Library, see the CSScript site for scripting guidelines.

How does a script work ?

Ynote finds and executes the Main Method which has the IYnote object.

static void Main(IYnote ynote)
{
   // code
}

IYnote Interface

IYnote wraps the basic functionality of Ynote Classic. It's contents are

  • OpenFile (string name) : void -> Open's a file
  • SaveEditor (Editor edit) : void -> Saves a typeof Editor
  • CreateNewDoc() : void - Creates a New Document
  • Menu: The MainMenu of the App
  • Panel : DockPanel - The DockPanel of Ynote

References

FastColoredTextBox - See All The Methods of FastColoredTextBox which is the core of Ynote Classic.

DockPanelSuite - The Docking Library. Get Info of Ynote's ActiveDocument etc.

Ynote's Source Code - Best Reference Site. See the code of all objects

Ynote Samples - Some Scripting Samples

Scripting Ynote

Example 1 :Below is a simple Hello Ynote script -

using SS.Ynote.Classic.UI;

static void Main(IYnote ynote)
{
// Define edit as the ActiveTab which is of type Editor
var edit = ynote.Panel.ActiveDocument as Editor;
// Insert Text in Tb (TextBox)
edit.Tb.InsertText(
"Hello, Ynote!");
}

The above script first Defines "edit" as the ActiveDocument of Ynote's DockPanel ("Panel") and casts it to Editor (The form which hosts the FastColoredTextBox denoted by Tb). 

It Asks edit's Tb(FastColoredTextBox) to insert the text - "Hello, Ynote!" into the textArea.

Example 2 : Syntax Highlight

edit.Highlighter.HighlightSyntax(Language.Javascript, new TextChangedEventArgs(edit.Tb);

The above line of code when added to Example 1, will highlight the Javascript code on the ActiveDocument.

Highlighter -> ISyntaxHighlighter Interface

 


Last edited Apr 21, 2014 at 1:19 PM by samarjeet27, version 2

Comments

No comments yet.