我在 Silverlight 中动态创建了 arcsegements。我在 for 循环中调用它来创建许多弧线,比如彩虹,比如 10 条弧线,当滑块 1 移动时。现在我想在另一个slider2值更改时增加所有这10个弧的大小。但我的问题是,要在我的新函数中访问这些弧段(以增加大小),弧段对象应该全局声明。但是当我喜欢它时,它只生成 1 个弧,并在slider1change 上使用新值。这个问题怎么解决???...
我的代码——
private void drawShell()
{
// Path
double a=slider1.value;
Path displayPath = new Path();
displayPath.Stroke = _brush;
displayPath.StrokeThickness = 7;
PathGeometry pathGeometry = new PathGeometry();
PathFigureCollection figureCollection = new PathFigureCollection();
PathFigure pathFigure = new PathFigure();
PathSegmentCollection segmentCollection = new PathSegmentCollection();
ArcSegment arc = new ArcSegment();
// Start Point
pathFigure.StartPoint = new Point(0, 66);
// End point
arc.Point = new Point(50+a, 150-a);
arc.Size = new Size(200-a, 125-a);
arc.RotationAngle = 0;
arc.SweepDirection = SweepDirection.Counterclockwise;
arc.IsLargeArc = false;
segmentCollection.Add(arc);
pathFigure.Segments = segmentCollection;
figureCollection.Add(pathFigure);
pathGeometry.Figures = figureCollection;
displayPath.Data = pathGeometry;
LayoutRoot.Children.Add(displayPath);
}