How do I create a new GeometryCollection from code?
I am creating a new GeometryGroup from code. It seems like I am unable to create a GeometryCollection because the method is protected. Is there a way around that??
This is what I am trying to do in code.
I am stuck. Please let me know if there is something I am not seeing.
I get the error on this line:
Children = new GeometryCollection().
I cannot access GeometryCollection due to it's protection level..So how do I add a geometry collection programatically?
Thanks!!
This is what I am trying to do in code.
Code: Select all
private Path ConstructPath()
{
if (WedgeAngle >= 360)
{
Path path = new Path()
{
Fill = this.Fill,
Stroke = this.Stroke,
StrokeThickness = 1,
Data = new GeometryGroup()
{
FillRule = FillRule.EvenOdd,
Children = new GeometryCollection()
{
new EllipseGeometry()
{
Center = new Point(CentreX, CentreY),
RadiusX = Radius,
RadiusY = Radius
},
new EllipseGeometry()
{
Center = new Point(CentreX, CentreY),
RadiusX = InnerRadius,
RadiusY = InnerRadius
}
...
I get the error on this line:
Children = new GeometryCollection().
I cannot access GeometryCollection due to it's protection level..So how do I add a geometry collection programatically?
Thanks!!
-
- kemarofangs
- Posts: 32
- Joined:
Re: How do I create a new GeometryCollection from code?
I think they have worked on geometry classes some but there is a lot of support missing. I had put in a feature request but never got around to testing their resolution yet (as of 1.2.6f6 version). This concerned reading simple geometry data in the xaml from the code behind. Issue Tracker
Maybe this code could help?
Just wait for the developers to reply about all the supported Geometry objects and classes. They know best. Good luck.
Code: Select all
<Path x:Name="m_path_outline" Data="M 0,0 L100,50 L0,100 Z" Stroke="Black" StrokeThickness="5" Fill="White" />
Code: Select all
path.Data.ToString();
Code: Select all
Noesis.Path path1 = new Noesis.Path() { Data = "M 0,0 L100,50 L0,100 Z" };
Noesis.Path path2 = new Noesis.Path() { Data = "M 70,44 L80,50 L70,56 Z" };
CombinedGeometry combinedGeometry = new CombinedGeometry(path1, path2, GeometryCombineMode.Exclude);
combinedGeometry.Freeze();
Noesis.Path pathCombined = new Noesis.Path() { Data = combinedGeometry };
-
-
sfernandez
Site Admin
- Posts: 3250
- Joined:
Re: How do I create a new GeometryCollection from code?
This is clearly a bug, GeometryCollection (and I saw that other collection classes have the same problem) should have its default constructor public instead of protected.
We will fix it for the next release.
Meanwhile, the good thing is that we assign an empty collection to the Children property when GeometryGroup gets created, so you can just do the following:
We will fix it for the next release.
Meanwhile, the good thing is that we assign an empty collection to the Children property when GeometryGroup gets created, so you can just do the following:
Code: Select all
var g = new GeometryGroup() { FillRule = FillRule.EvenOdd };
g.Children.Add(new EllipseGeometry { Center = new Point(CentreX, CentreY), RadiusX = Radius });
...
Who is online
Users browsing this forum: Baidu [Spider], Google [Bot] and 14 guests