Page 1 of 1

Displaying a polygon

Posted: 12 Dec 2013, 14:15
by ironic
Hi!

In WPF there is a Polygon shape. How to have the same functionality in Noesis? I found the Path class, but cannot figure out how to use it instead of Polygon in my code. Note that I am doing it from C# code, not XAML.

EDIT
I managed to draw a polygon, but it is not filled. My code looks like this:
var result = new Path();
result.SetFill(new SolidColorBrush(Noesis.Color.Yellow));
result.SetStroke(new SolidColorBrush(Noesis.Color.Green));
var streamGeometry = new StreamGeometry();
var context = streamGeometry.Open();
context.BeginFigure(new Point(10, 10), true);
context.LineTo(new Point(10, 40));
context.LineTo(new Point(40, 40));
context.Dispose();
result.SetFill(new SolidColorBrush(Noesis.Color.Yellow));
result.SetData(streamGeometry);
Thanks!

Re: Displaying a polygon

Posted: 13 Dec 2013, 10:42
by sfernandez
I see what is happening... our code does not behave exactly the same as in WPF. In NoesisGUI you have to call StreamGeometry.Close() explicitly when you have finished entering commands in the context, like this:
var streamGeometry = new StreamGeometry();
var context = streamGeometry.Open();
context.BeginFigure(new Point(10, 10), true);
context.LineTo(new Point(10, 40));
context.LineTo(new Point(40, 40));
streamGeometry.Close();
var path = new Path();
path.SetFill(new SolidColorBrush(Noesis.Color.Yellow));
path.SetStroke(new SolidColorBrush(Noesis.Color.Green));
path.SetData(streamGeometry);
We will change this for the next release, so Close is automatically called when context gets disposed, as it occurs in WPF ;)

Re: Displaying a polygon

Posted: 16 Dec 2013, 13:16
by ironic
I see what is happening... our code does not behave exactly the same as in WPF. In NoesisGUI you have to call StreamGeometry.Close() explicitly when you have finished entering commands in the context, like this:
var streamGeometry = new StreamGeometry();
var context = streamGeometry.Open();
context.BeginFigure(new Point(10, 10), true);
context.LineTo(new Point(10, 40));
context.LineTo(new Point(40, 40));
streamGeometry.Close();
var path = new Path();
path.SetFill(new SolidColorBrush(Noesis.Color.Yellow));
path.SetStroke(new SolidColorBrush(Noesis.Color.Green));
path.SetData(streamGeometry);
We will change this for the next release, so Close is automatically called when context gets disposed, as it occurs in WPF ;)
Thanks a lot! This helped!

Re: Displaying a polygon

Posted: 27 Jan 2014, 16:41
by ironic
Another problem: The figure is not filled. How can I make it filled?

Re: Displaying a polygon

Posted: 27 Jan 2014, 21:16
by sfernandez
Hi, there is a bug with the StreamGeometryContext, I will fix it for the next release.
Thanks for reporting.

Re: Displaying a polygon

Posted: 04 Feb 2014, 00:08
by jsantos
We fixed this problem in v1.1.4