3

I have different geometries which are created based on different elements. But what they all have in common are that they are closed figures. Which can be seen on an example in this link. So I want to use these elements to create one element, this I have succeeded in by using GeometryGroup. Using the before mentioned link, it is possible to use these geometries to create one path. The problem for me is the individual geometries in the geometry group are shapes, which I would like to paint in individual colors. but I do not know how to color the individual elements, since the geometries do not posses this property, I have looked at different links but not found anything that seems to work.

Different fill behavior inside a Path GeometryGroup

Filling Color in a hexagon in WPF

http://msdn.microsoft.com/en-us/library/aa970904%28v=vs.110%29.aspx

Does anyone have an idea how to create complex shapes with different colors in c#. Because I have succeeded in the shapes and I then have to export them as a path to use them. So another problem for me is even though I succeed in color the geometry shapes, will this information be lost when I export the geometry group to a path:

            System.Windows.Shapes.Path pathSaved = new System.Windows.Shapes.Path();
            GeometryGroup GroupofDecorations = new GeometryGroup(){ FillRule = FillRule.Nonzero};
            //So How to color the elements I add
            GroupofDecorations.Children.Add(ColoredGeometryAdded);
            pathSaved.Data = GroupofDecorations;

Hope somebody has an idea :) Because I cannot find anything

Community
  • 1
  • 1
JTIM
  • 2,774
  • 1
  • 34
  • 74
  • 1
    Create multiple Path objects, one for each shape, with different values for their `Fill` or `Stroke` properties. – Clemens Sep 14 '14 at 13:18
  • @Clemens The problem with that is that I am using GeometryGroup to have one object. Which therefore defeats the purpose of using multiple path objects, right? I use pathgeometries as geometry elements. – JTIM Sep 14 '14 at 17:15
  • 1
    Yes, but what forces you to do that? If you want to have differently colored shapes, a GeometryGroup is the wrong approach. – Clemens Sep 14 '14 at 17:24
  • @Clemens The GeomtryDrawing does not seem to available on Windows PHone as far as I have read and found earlier. – JTIM Sep 14 '14 at 17:28
  • @Clemens The reason is that I am combining them to one element, such that the user can interact with it. The idea is that the user can create a figure/shape, by using different shapes. When the user then is satisfied I can export it as the user made it as one element. But it loses the colors that the user has specified. This is the reason I used GeometryGroup. But I did not focus on colors before now, and cannot find a solution for it, such that I can also keep one shape. If I created a GeometryGroup in XAML I thought it was possible to specify colors, at least what I saw on links, not for c#. – JTIM Sep 14 '14 at 17:32
  • 2
    No, that is not possible. A Geometry itself does not define fill or stroke related properties. It is displayed by a Path, which defines the `Fill` and `Stroke` proerties. Differently colored shapes means different Paths. Put them in a common Canvas. – Clemens Sep 14 '14 at 17:39

0 Answers0