PDA

View Full Version : سوال در مورد رسم نیم دایره path در canvas



hhojjatt
چهارشنبه 13 آبان 1388, 12:50 عصر
من با کد زیر می خوام یک نیم دایره در canvas رسم کنم ولی نمیشه به نظر شما ایراد ان کجاست ممنون

public void arcdraw(double heigth, double width, System.Windows.Thickness tn)
{
Color c = new Color();
c.A = 255;
c.B = 0;
c.G = 0;
c.R = 0;
Path pat = new Path();
pat.Height = heigth;//50
pat.Width = width;//50
pat.Stroke = new SolidColorBrush(c);
pat.Margin = tn;
pat.StrokeThickness = 0.4;
cannemodar.Children.Add(pat);
}


tn.left=50,tn.top=50

رضا عربلو
چهارشنبه 13 آبان 1388, 14:57 عصر
اطلاعات شما برای کشیدن Path کم می باشد. path از کجا شروه می شود. تا کدام نقطه چه چیزی می کشد و ...
این متد را نگاه کنید:


Path createPath(ObservableCollection<Point> rawData)
{
Path FinalPath = new Path();
PathGeometry FinalPathGeometry = new PathGeometry();
PathFigure PrimaryFigure = new PathFigure();
//if you want the path to be a shape, you want to close the PathFigure
// that makes up the Path. If you want it to simply by a line, set
// PrimaryFigure.IsClosed = false;
PrimaryFigure.IsClosed = true;
PrimaryFigure.StartPoint = rawData[0];
PathSegmentCollection LineSegmentCollection = new PathSegmentCollection();
for (int i = 1; i < rawData.Count; i++)
{
LineSegment newSegment = new LineSegment();
newSegment.Point = rawData[i];
LineSegmentCollection.Add(newSegment);
}
PrimaryFigure.Segments = LineSegmentCollection;
FinalPathGeometry.Figures.Add(PrimaryFigure);
FinalPath.Data = FinalPathGeometry;
return FinalPath;
}