Page 1 of 1

[Beta 8.3] PolyLineSegment doesn't initializes itself

Posted: Fri Jul 01, 2016 10:04 am
by xidea
Hi,

just coding for the first time with C#/XAML for HTML5.

I'm in trouble with the creation of a polyline. I've found the way using PolyLineSegment and adding to a Path.
When in runtime, I'm getting a "Null reference" error even if my PolyLineSegment must be not null, as instantiated with "new".

Pls see the screenshot of the debugger:

MAP-0000.jpg
MAP-0000.jpg (82.03 KiB) Viewed 17605 times


Same behaviour with PathFigure, PolyBezierSegment, and perhaps any object that have a collection of graphic elements as a property.

Any idea? Can I draw a polyline in some other way in meantime?

Thanks in advance.

Flavio

Re: [Beta 8.3] PolyLineSegment doesn't initializes itself

Posted: Sat Jul 02, 2016 8:11 am
by JS-Support @Userware
Thanks Flavio. We are going to investigate.

In the meantime, this is what you can do: since it works in XAML, and since XAML is transformed into C# at the beginning of the compilation process, you can have a look at how the generated C# code works for the <Path/> control. This will show you how to do the equivalent thing programmatically in C#. To do so, start by writing and testing some <Path/> control in XAML, then build the project, and look at the generated files under the "obj" subfolder of your project folder.

Regards
JS-Support

Re: [Beta 8.3] PolyLineSegment doesn't initializes itself

Posted: Sun Jul 03, 2016 12:40 am
by xidea
Thanks for quick response,

I've investigated some tricks, and found that I can put a <Path ... ... > in the XAML markup and bind his Data property to a string containing the path coordinates in "mini language" as "Mx,y Lx1,y1 x2,y2 x3,y3 ...".

But neither this way is working at runtime, even if directly writing the Path markup in the XAML is effectively working (the thickness is ignored, though).

So I tried to investigate more, via Reflector, and at some point I encounter this line in the decompiled BindingExpression.cs:

MAP-0035.jpg
MAP-0035.jpg (201.73 KiB) Viewed 17600 times


There is two absign, I don't know if this is a result of poor decompilation, but I think it's not correct. There is no reason to assign to "walker" a boolean value :) x=y=z is  x=(y=z) .
edit: Obviously it's not true, sorry: x=y=z is not like x = y == z, so the code is correct, but in fact it refers to object that are null at runtime: a "Null reference" error is coming from that line, and if I correct the line deleting "= this.PropertyWalker" I again obtain a null reference, but the reason is that binding.INTERNAL_ComputedPath is null.

So I can't find a way to draw a path programatically and that is the only mandatory visual thing I need to implement.

I hope I've give you a clue for fixing.


Flavio

Re: [Beta 8.3] PolyLineSegment doesn't initializes itself

Posted: Sun Jul 03, 2016 2:08 am
by JS-Support @Userware
Thanks Flavio. We investigate.

In the meantime, did you have a look at the generated C# code in the "obj" folder ? You need to open for example "MainPage.g.cs" immediately after building the project. You will see how a normal XAML-defined <Path/> translates to equivalent C#.

Regards
JS-Support

Re: [Beta 8.3] PolyLineSegment doesn't initializes itself

Posted: Sun Jul 03, 2016 3:25 am
by xidea
Hi,

just found another issue:

MAP-0033.jpg
MAP-0033.jpg (59.28 KiB) Viewed 17598 times


Any Thickness I will specify as Margin, the result is the ellipse is placed at 0,0.


I'll be glad to interact with your team in Italian (or English) via Skype, user: spiff967

Regards,


Flavio

Re: [Beta 8.3] PolyLineSegment doesn't initializes itself

Posted: Sun Jul 03, 2016 6:38 am
by xidea
JS-Support wrote:Thanks Flavio. We investigate.

In the meantime, did you have a look at the generated C# code in the "obj" folder ? You need to open for example "MainPage.g.cs" immediately after building the project. You will see how a normal XAML-defined <Path/> translates to equivalent C#.

Regards
JS-Support


Yes, the g.cs contains the code, but there the generated app's dll when decompiled shows a more clean code:

Code: Select all

 path.Data = (Geometry) TypeFromStringConverters.ConvertFromInvariantString(typeof(Geometry), "M 45,45 L 135,45 135,135 215,135");
       


So, using the mini language for drawing is a possible way to do it.

Tested, the code works, however I confirm that Thickness is bypassed (ever = 1), programmatically and by markup. No way to obtain thick lines. I think the problem is on JS side, as the thicknes is correctly rendered in the VS's Design View.


Waiting for updates, Many Thanks


Flavio

Re: [Beta 8.3] PolyLineSegment doesn't initializes itself

Posted: Fri Jul 08, 2016 11:05 am
by JS-Support @Userware
Hi Flavio,

The issue related to StrokeThickness being ignored is now supposed to be fixed in Beta 8.4, available at:

http://forums.cshtml5.com/viewtopic.php?f=6&t=5498

Can you please confirm that it fixes the issue for you?

Thank you.
Regards,
JS-Support

Re: [Beta 8.3] PolyLineSegment doesn't initializes itself

Posted: Sat Jul 09, 2016 11:17 am
by xidea
Yes, now the thickness is correctly rendered, but the point of the path are not correctly positioned. The stroke caps (setted as round, are rendered flat), and any shape is lways positioned in 0,0 ignoring the specified coords.

In this example, you can see in yellow the correct path and shape vs in blue the rendered path and shape. The 0,0 issue comes up for any shape (I've tested oval and rectangle).

MAP-0001.jpg
MAP-0001.jpg (75.56 KiB) Viewed 17557 times


The path is drawn by using programmatically the mini-language, the shape is placed programmatically too.

Waiting for any news, as my project is somehow simple but breaked by these issue (and other) issues.


Regards

Flavio.

Re: [Beta 8.3] PolyLineSegment doesn't initializes itself

Posted: Sun Jul 10, 2016 1:19 am
by JS-Support @Userware
Hi Flavio,

Thanks. Glad to know that the thickness now renders correctly, and sorry for the remaining issues. We are little by little fixing all of them, and we hope to be able to get out of Beta soon.

For the positioning issue, would you mind please posting just a small piece of XAML or programmatic code to reproduce the exact issue? This will help speed up the resolution and ensure that we test the correct scenario before posting any fix.

Also, you mentioned other issues that are breaking your project. Can you please let us know about each of them? Please either submit tickets to support@cshtml5.com or by create new topics on these forums. We are doing our best to fix all the remaining issues.

Thanks again.

Regards
JS-Support

Re: [Beta 8.3] PolyLineSegment doesn't initializes itself

Posted: Sun Jul 10, 2016 6:50 am
by xidea
Hi,

just realized that the issue is about managing the margins of a shape contained in a canvas object, and you can reproduce it even in XAML:

Code: Select all

<Page
    x:Class="Application1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Application1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Canvas>
        <Grid>
            <TextBlock Text="Hello World!" x:Name="TextBlock1" Canvas.Left="20" Canvas.Top="30"/>
            <Rectangle Width="30" Height="30" Fill="#AAAAAAAA" Margin="30 "/>
            <Canvas x:Name="myCanvas">
                <Ellipse Fill="#FF101010" Width="40" Height="40" Margin=" 100,100,0,0"/>
            </Canvas>
        </Grid>
    </Canvas>
</Page>


MAP-0002.jpg
MAP-0002.jpg (19.9 KiB) Viewed 17544 times


The page rendering in the simulator places correctly the rectangle that stays out of the canvas, but places the ellipse at 0,0 within the canvas.

IMHO the textbox too is wrongly placed.


Regards

Flavio