PDA

View Full Version : سوال کشیدن کمان در wpf



hhojjatt
پنج شنبه 14 آبان 1388, 08:54 صبح
چطوری می شود یک کمان در canvas رسم کرد ممنون

رضا عربلو
پنج شنبه 14 آبان 1388, 11:30 صبح
با path
مثال:


// draw arc by creating a geometry object that contains the arc
void DrawArc(DrawingContext drawingContext, Brush brush,
Pen pen, Point start, Point end, Size radius)
{
// setup the geometry object
PathGeometry geometry = new PathGeometry();
PathFigure figure = new PathFigure();
geometry.Figures.Add(figure);
figure.StartPoint = start;
// add the arc to the geometry
figure.Segments.Add(new ArcSegment(end, radius,
0, false, SweepDirection.Clockwise, true));

// draw the arc
drawingContext.DrawGeometry(brush, pen, geometry);
}

hhojjatt
پنج شنبه 14 آبان 1388, 15:43 عصر
دوست عزیز واقعا متشکرم ولی شی از نوع DrawingContext نتونستم ایجاد کنم new نتونستم بکنم بعد کدوم قسمتش را canvas.children.add بکنم لطفا راهنمایی کن ممنون

رضا عربلو
پنج شنبه 14 آبان 1388, 16:04 عصر
DrawingContext در فضای نام System.Windows.Media (http://msdn.microsoft.com/en-us/library/system.windows.media.aspx) وجود دارد.
اینجا را ببین:
http://blogs.vertigo.com/personal/ralph/Blog/archive/2007/02/09/wpf-drawing-arcs.aspx

hhojjatt
جمعه 15 آبان 1388, 09:31 صبح
ببخشید من یکم تازه کار هستم بازم نشد میگه این کلاس abstrac است و نمی توان از ان شی تعریف کرد تعریف هم نمی کنیم باز ایراد میگیرد و متد drawarc را کی فرا خوانی کنم

رضا عربلو
شنبه 16 آبان 1388, 10:37 صبح
یک مثال:


SolidColorBrush blueBrush = new SolidColorBrush();
blueBrush.Color = Colors.Blue;
SolidColorBrush blackBrush = new SolidColorBrush();
blackBrush.Color = Colors.Black;
// Create a Path with black brush and blue fill
Path bluePath = new Path();
bluePath.Stroke = blackBrush;
bluePath.StrokeThickness = 3;
bluePath.Fill = blueBrush;

// setup the geometry object
PathGeometry geometry = new PathGeometry();
PathFigure figure = new PathFigure();
geometry.Figures.Add(figure);
figure.StartPoint = new Point(10d, 10d);
// add the arc to the geometry
figure.Segments.Add(new ArcSegment(new Point(200d, 200d), new Size(150d, 150d), 20d, false, SweepDirection.Clockwise, true));
GeometryGroup gp = new GeometryGroup();
gp.Children.Add(geometry);
bluePath.Data = gp;
convas1.Children.Add(bluePath);