KeldorKatarn
Topic Author
Posts: 86
Joined: 30 May 2014, 10:26

Problems porting a WPF project to Noesis for Unity

16 Nov 2018, 12:52

I recently started Evaluating Noesis for my current company. We're a UX company and thinking about using Noesis for projects.
I am running into a couple of problems however. I'll post them as separate threads here, since the recent server crash apparently destroyed my earlier posts.

I was trying to port one of our WPF projects, or rather one of its screens, to Noesis.
We have a bunch of resource dictionaries merged in the App.aml and one viewmodel view combination in this example.

I'm running into several problems with missing APIs or APIs that apparently don't work like WPF and I also don't 100% understand the configuration work I need to do.

One issue I'm running into is declaring fonts, stream geometries and images as resources.

The stream geometry declaration looks like this:
    <StreamGeometry
        x:Key="Icon.Comment">
        F1M0,0z M33,10a3.27,3.27,0,0,0-3-3H10a3.28,3.28,0,0,0-3,3V26a3.28,3.28,0,0,0,3,3H28l5,5V10ZM28,24H12V21H28Zm0-4H12V17H28Zm0-4H12V13H28Z M40,40z
    </StreamGeometry>
And for some reason Noesis tells me that it cannot turn this string into a StreamGeometry. In WPF it works fine. Any idea what the issue is?

I'm also trying to declare a font family but I'm not sure i'm doing it right. I'm getting the same issue basically.
    <FontFamily x:Key="FontFamily.Standard">/Assets/NoesisGUI/HelloWorld/Resources/Fonts/Roboto-Regular.ttf</FontFamily>
Am I referencing the file in the wrong way? Do I need to put the font file in a certain directory for Noesis to find it? In WPF this works, in noesis it doesn't.

In terms of geometry, every type seems to exist except for "Polygon". Why is that type missing and can I expect that to be added?

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 1777
Joined: 22 Dec 2011, 19:20

Re: Problems porting a WPF project to Noesis for Unity

19 Nov 2018, 11:22

Hi, what kind of error are you getting with the StreamGeometry? I was able to load the following xaml without problems in XamlPlayer 2.1.0f1:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid.Resources>
        <StreamGeometry
            x:Key="Icon.Comment">
            F1M0,0z M33,10a3.27,3.27,0,0,0-3-3H10a3.28,3.28,0,0,0-3,3V26a3.28,3.28,0,0,0,3,3H28l5,5V10ZM28,24H12V21H28Zm0-4H12V17H28Zm0-4H12V13H28Z M40,40z
        </StreamGeometry>
    </Grid.Resources>
    <Path Data="{StaticResource Icon.Comment}" Fill="Lime"/>
</Grid>
Regarding the fonts we support the following syntaxes for local fonts:
<FontFamily x:Key="FontFamily.Standard">/Assets/NoesisGUI/HelloWorld/Resources/Fonts/Roboto-Regular.ttf#Roboto</FontFamily>
<FontFamily x:Key="FontFamily.Standard">/Assets/NoesisGUI/HelloWorld/Resources/Fonts/#Roboto</FontFamily>
In the upcoming 2.2 version we will also support system installed fonts, that can be specified like this:
<FontFamily x:Key="FontFamily.Standard">Arial Narrow</FontFamily>
We didn't include Polygon because using a StreamGeometry you can get any shape you want, but please add a request in our bugtracker for Polygon class, if enough clients ask for it we could implement it.
 
KeldorKatarn
Topic Author
Posts: 86
Joined: 30 May 2014, 10:26

Re: Problems porting a WPF project to Noesis for Unity

19 Nov 2018, 15:31

The problems are super hard to diagnose, which is yet another problem.
In Unity when I load a resource chain (i.e. resource dictionaries importing others in a chain to avoid loading resources multiple times), whenever there's a problem in one of the dictionary files,
I'm basically getting

"NoesisException: Assets/NoesisGUI/HelloWorld/MainWindow.xaml(1): Document contains no elements."

from Unity, which tells me absolutely nothing. But under some circumstances I cannot really reproduce it tells me that it cannot parse the string.

To be honest, the fact alone that errors in the creation of resource dictionaries throw such useless errors is already a major deterrent from using Noesis.
We need to be able to understand what Noesis is complaining about. Simply saying a file has no elements, which is clearly not the case, is not helpful at all.
 
KeldorKatarn
Topic Author
Posts: 86
Joined: 30 May 2014, 10:26

Re: Problems porting a WPF project to Noesis for Unity

19 Nov 2018, 16:05

Got it to throw the error again by doing a re-import on the affected XAML
NoesisException: Assets/NoesisGUI/HelloWorld/XamlResources/Basic/IconResources.xaml(27): Can't convert 'F1M0,0z M22.36,16.86A9.4,9.4,0,0,0,20.19,6.78,9.55,9.55,0,0,0,9.44,4.88l6.24,6.28-4.35,4.38L4.94,9.26A9.45,9.45,0,0,0,6.82,20.07a9.27,9.27,0,0,0,10,2.19l13.21,13.3a1.4,1.4,0,0,0,2,0l3.34-3.36a1.32,1.32,0,0,0,.14-2Z M40,40z' into a 'StreamGeometry' object.
    <StreamGeometry
        x:Key="Icon.Comment">
        F1M0,0z M33,10a3.27,3.27,0,0,0-3-3H10a3.28,3.28,0,0,0-3,3V26a3.28,3.28,0,0,0,3,3H28l5,5V10ZM28,24H12V21H28Zm0-4H12V17H28Zm0-4H12V13H28Z M40,40z
    </StreamGeometry>
 
KeldorKatarn
Topic Author
Posts: 86
Joined: 30 May 2014, 10:26

Re: Problems porting a WPF project to Noesis for Unity

20 Nov 2018, 12:50

I also still can't get the font family loaded. no matter which of your variants I use, it can never load it.
<Grid.Resources>
    <FontFamily x:Key="FontFamily.Standard">D:\TestProjects\NoesisEvaluation\Unity\Assets\NoesisGUI\HelloWorld\Resources\Fonts\Roboto-Regular.ttf#Roboto</FontFamily>
</Grid.Resources>
NoesisException: Assets/NoesisGUI/HelloWorld/Views/PowerUpView.xaml(15): Can't convert 'D:\TestProjects\NoesisEvaluation\Unity\Assets\NoesisGUI\HelloWorld\Resources\Fonts\Roboto-Regular.ttf#Roboto' into a 'FontFamily' object.
Rethrow as NoesisException
Noesis.Error.Check () (at Assets/NoesisGUI/Plugins/API/Core/NoesisError.cs:17)
Noesis.GUI.Noesis_LoadComponent_ (System.Runtime.InteropServices.HandleRef component, System.String xaml) (at Assets/NoesisGUI/Plugins/API/Core/NoesisGUI.cs:282)
Noesis.GUI.LoadComponent (System.Object component, System.String xaml) (at Assets/NoesisGUI/Plugins/API/Core/NoesisGUI.cs:135)
HelloWorld.Views.PowerUpView.InitializeComponent () (at Assets/NoesisGUI/HelloWorld/Views/PowerUpView.xaml.cs:29)
HelloWorld.Views.PowerUpView..ctor () (at Assets/NoesisGUI/HelloWorld/Views/PowerUpView.xaml.cs:22)
(wrapper dynamic-method) System.Object.lambda_method(System.Runtime.CompilerServices.Closure)
Noesis.Extend.CreateInstance (System.IntPtr nativeType, System.IntPtr cPtr) (at Assets/NoesisGUI/Plugins/API/Core/NoesisExtend.cs:3933)
Rethrow as NoesisException
Noesis.Error.Check () (at Assets/NoesisGUI/Plugins/API/Core/NoesisError.cs:17)
Noesis.GUI.Noesis_LoadXaml_ (System.String xaml) (at Assets/NoesisGUI/Plugins/API/Core/NoesisGUI.cs:275)
Noesis.GUI.LoadXaml (System.String xaml) (at Assets/NoesisGUI/Plugins/API/Core/NoesisGUI.cs:125)
NoesisXaml.Load () (at Assets/NoesisGUI/Plugins/NoesisXaml.cs:31)
NoesisPostprocessor+<ImportXaml>c__AnonStorey0.<>m__0 () (at Assets/NoesisGUI/Plugins/Editor/NoesisPostprocessor.cs:353)
UnityEngine.Debug:LogException(Exception, Object)
<ImportXaml>c__AnonStorey0:<>m__0() (at Assets/NoesisGUI/Plugins/Editor/NoesisPostprocessor.cs:359)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
Also on TextBlock the property IsHyphenationEnabled is missing.
 
User avatar
sfernandez
Site Admin
Posts: 1777
Joined: 22 Dec 2011, 19:20

Re: Problems porting a WPF project to Noesis for Unity

22 Nov 2018, 17:27

The last geometry you posted is not being parsed correctly by our parser. I created ticket https://www.noesisengine.com/bugs/view.php?id=1359 to keep track of this problem.

Can you report the missing TextBlock.IsHyphenationEnabled property?

For the other problems it would help us a lot if you could create a ticket and attach the project so we can see what is happening. You can create a private ticket if you don't want to share it with anyone else.
 
User avatar
sfernandez
Site Admin
Posts: 1777
Joined: 22 Dec 2011, 19:20

Re: Problems porting a WPF project to Noesis for Unity

23 Nov 2018, 10:23

Hi,

I've been investigating the problem with the font and found a couple of problems.
First, the FontFamilyConverter was not working with back slashes '\\' as path separator, you should use '/'.
And absolute paths with a drive letter are not supported in Unity, an absolute path would be considered to start at Assets/.

You should try to use:
<FontFamily x:Key="FontFamily.Standard">/Assets/NoesisGUI/HelloWorld/Resources/Fonts/Roboto-Regular.ttf#Roboto</FontFamily>
I'm still trying to reproduce without luck the problem with nested dictionaries showing only a "Document contains no elements" error. Our intention is to provide better error messages to help users understand what is wrong so they can fix it, so if you can please provide a way to reproduce this problem we will be thankful.

Who is online

Users browsing this forum: Google [Bot] and 16 guests