GettingStarted01 Question.

SyntaxEditor for Silverlight Forum

Posted 12 years ago by Al
Version: 11.2.0122
Avatar

I'm contemplating updating my old (v3) Syntax Editor for Winforms to Silverlight.  Looking at the sample app it appears that all I need to do to get the GettingStarted01 working is start a new Silverlight project and:

1) Create MainPage.xaml

--------------------------------------------------------------------------------------

<UserControl x:Class="TestSyntaxEditorSL.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:editor="http://schemas.actiprosoftware.com/winfx/xaml/syntaxeditor"

d:DesignHeight="300" d:DesignWidth="400">

<editor:SyntaxEditor x:Name="editor">
<editor:EditorDocument>
<system:String xml:space="preserve">/*
The Simple language is a simplistic C-like language that only knows
several keywords and operators. All variables are integer numbers.

This first sample shows a language project (.langproj) file and
generated language definition (.langdef) file that have been created
using the Actipro Language Designer application. Language projects
are the fastest way to get up and running with a language as they make
it easy to configure syntax highlighting. See the product documentation
for more information on .langproj and .langdef files.

The .langdef file is included in the project as an Embedded Resource
from within the /ProductSamples/SyntaxEditorSamples/Languages/Definitions
folder and is loaded into a SyntaxEditor instance at run-time to
provide the basic syntax highlighting features you see here.
*/

function Add(x, y) {
return x + y;
}

function Increment(x) {
return (x + 1);
}

function IncrementAndMultiply(x, y) {
// This function calls another function
var result;
result = Increment(x);
return result * y;
}
</system:String>
</editor:EditorDocument>
</editor:SyntaxEditor>

</UserControl>

--------------------------------------------------------------------------------------

2) Create a codebehind MainPage.xaml.vb

--------------------------------------------------------------------------------------

Imports System.Windows.Resources
Imports System.IO

Partial Public Class MainPage
Inherits UserControl

Public Sub New()
InitializeComponent()

editor.Document.Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("Simple-Basic.langdef")

End Sub
End Class

--------------------------------------------------------------------------------------

 

3) Add Simple-Basic.langdef to my project as "Embedded Resource", add a copy of SyntaxEditorHelper.vb and run it.

 

This code runs but there is no syntax highlighting as shown.  It looks like a regular multiline text editor.

 

What am I missing?

 

Thanks.

 

-Al

Comments (2)

Answer - Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Al,

You'd have to debug through the SyntaxEditorHelper method to see if a null value is getting returned somewhere there.  I would think it would work fine if the language is properly being loaded from your embedded resource.

You might also try to load the language directly from the file to rule that out.  This documentation topic has information on that:

Language Creation Guide / Loading a Language Definition (.langdef File)


Actipro Software Support

Posted 12 years ago by Al
Avatar

Thanks, that got it.  SyntaxEditorHelper LoadLanguageDefinitionFromResourceStream wasn't finding the .langdef and was returning SyntaxLanguage.PlainText.

 

-Al

The latest build of this product (v18.1 build 0233) was released 4 years ago, which was after the last post in this thread.