如何在silverlight中增加动态创建弧的大小?

时间:2013-01-16 18:10:09

标签: oop silverlight-4.0

我在silverlight中动态创建了arcsegements。 我在for循环中调用它来创建许多弧形,比如彩虹,就像滑块1移动一样。 现在我想在另一个slider2值的变化上增加所有这10个弧的大小。 但我的问题是,要在我的新函数中访问这些arcsegments(增加大小),应该全局声明arcsegments对象。但是当我这样做时,它只生成一个带有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);
        }

0 个答案:

没有答案
相关问题