ironic
Topic Author
Posts: 17
Joined: 20 Nov 2013, 16:40

Displaying a polygon

12 Dec 2013, 14:15

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!
 
User avatar
sfernandez
Site Admin
Posts: 3188
Joined: 22 Dec 2011, 19:20

Re: Displaying a polygon

13 Dec 2013, 10:42

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 ;)
 
ironic
Topic Author
Posts: 17
Joined: 20 Nov 2013, 16:40

Re: Displaying a polygon

16 Dec 2013, 13:16

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!
 
ironic
Topic Author
Posts: 17
Joined: 20 Nov 2013, 16:40

Re: Displaying a polygon

27 Jan 2014, 16:41

Another problem: The figure is not filled. How can I make it filled?
 
User avatar
sfernandez
Site Admin
Posts: 3188
Joined: 22 Dec 2011, 19:20

Re: Displaying a polygon

27 Jan 2014, 21:16

Hi, there is a bug with the StreamGeometryContext, I will fix it for the next release.
Thanks for reporting.
 
User avatar
jsantos
Site Admin
Posts: 4186
Joined: 20 Jan 2012, 17:18
Contact:

Re: Displaying a polygon

04 Feb 2014, 00:08

We fixed this problem in v1.1.4

Who is online

Users browsing this forum: Ahrefs [Bot] and 5 guests