Click here to Skip to main content
15,559,275 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am displaying the images in mediaelement.
Now if i do clicks on the image and select draw shape button the clicked positions should join and form a shape. here iam using Quadraticbezier curves for joing the mous clicks.

When i do odd no. of clicks on the image and select draw shape. the shape is coming perfectly but if i do even no. of clicks the curve is forming without joining the starting point and ending point.
why is this happening plz any find where iam going wrong
code:
C#
void Mediaelement1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

            checkPoints.Add(Mouse.GetPosition(mediaelement1));
        }



Drawshape button code:

SolidColorBrush bgBrush = new SolidColorBrush();
		bgBrush.Color = Colors.Transparent;
		SolidColorBrush borderBrush = new SolidColorBrush();
		borderBrush.Color = Colors.Black;
					
			Path polyPath = new Path();
			polyPath.Stroke = borderBrush;
			polyPath.StrokeThickness = 1;
			polyPath.Fill = bgBrush;
					
			GeometryGroup polyGeometryGroup = new GeometryGroup();
					
			PathFigure pLineFigure = new PathFigure();
	PolyQuadraticBezierSegment PQSegment=new PolyQuadraticBezierSegment ();
					
					
			foreach(var itr in checkPoints)
				{
					PQSegment.Points.Add(itr);
					
				}
					
					
		PQSegment.Points.Add( checkPoints[0]);
		Point startPoint= checkPoints[0];
		pLineFigure.StartPoint = new Point(startPoint.X,startPoint.Y);
		pLineFigure.Segments.Add( PQSegment);
		PathGeometry pGeometry = new PathGeometry();
		pGeometry.Figures.Add(pLineFigure);
					
		polyGeometryGroup.Children.Add(pGeometry);
					
	polyPath.Data = polyGeometryGroup;					
										
					
		this .mediasp.Children.Add (polyPath);
					
			checkPoints.Clear();
}


Plz anyone explain why even no. of clicks are not joininmg startpoint and end point while forming shape.
Posted

1 solution

have you tried setting the IsClosed property on pLineFigure? does that have any effect. There is no immediately obvious cause for your problem in the code supplied
 
Share this answer
 
Comments
VK k 2-Sep-11 0:09am    
setting IsClosed property to true working perfectly..!
Thanks
GParkings

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900