Hey everyone,
I have a problem that I cannot solve on my own, so I need your help. I have two PathFigure-s and they are added to a PathGeometry and that is added to a Path. Then I add that Path to Canvas. I need to fill space between two PathFigures with color. Here's my code:
PathFigure fig1 = new PathFigure(); fig1.StartPoint = new Point(100, 100); fig1.Segments.Add(new LineSegment(new Point(200, 200), true)); PathFigure fig2 = new PathFigure(); fig2.StartPoint = new Point(200, 200); fig2.Segments.Add(new LineSegment(new Point(100, 200), true)); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures.Add(fig1); pathGeometry.Figures.Add(fig2); Path path = new Path(); path.Data = pathGeometry; path.Fill = Brushes.Green; path.Stroke = Brushes.Black; Can.Children.Add(path); // Can is a Canvas object
I can do this if two lines are segments inside one PathFigure. But I need to draw lines with mouse, so I need separate PathFigures. Can two PathFigures be merged somehow?
If that's not possible, please tell me how to dynamically add lines and fill space with color.
Please help me with some C# code. Thank you all.
Knowledge: C, C++, C#, Java, Pawn