public void TestComplex() { var complex = new ComplexShape(); complex.Add(new Rectangle()); complex.Add(new Rectangle()); complex.Add(new Rectangle()); complex.Add(new Rectangle()); double expectedArea = 4.0; double actualArea = complex.Area(); Assert.AreEqual(expectedArea, actualArea); double expectedPerimeter = 16.0; double actualPerimeter = complex.Perimeter(); Assert.AreEqual(expectedPerimeter, actualPerimeter); }
private void CreateBoxNeedle(INeedle needle) { ComplexShape needleShape = (ComplexShape)needle.Shape; needleShape.Collection.Clear(); BoxShape shape = new BoxShape(new RectangleF2D(new PointF(-10, 0), new SizeF(100, 10))); shape.Appearance.ContentBrush = new SolidBrushObject(Color.Gray); shape.Name = "boxNeedle"; needleShape.Add(shape); }
private void CreateSectorShape(INeedle needle) { ComplexShape needleShape = (ComplexShape)needle.Shape; needleShape.Collection.Clear(); SectorShape shape = new SectorShape(new RectangleF2D(new PointF(0, 30), new SizeF(80, 10)), 40, 270); shape.Appearance.ContentBrush = new SolidBrushObject(Color.Red); shape.Name = "sectorShape"; needleShape.Add(shape); }
private void CreateArcNeedle(INeedle needle) { ComplexShape needleShape = (ComplexShape)needle.Shape; needleShape.Collection.Clear(); ArcShape shape = new ArcShape(new RectangleF2D(new PointF(-10, 0), new SizeF(20, 10)), 180, -60); shape.Appearance.ContentBrush = new SolidBrushObject(Color.White); shape.Name = "arcNeedle"; needleShape.Add(shape); }
private void CreateTextShape(INeedle needle) { ComplexShape needleShape = (ComplexShape)needle.Shape; needleShape.Collection.Clear(); TextShape shape = new TextShape(); shape.Box = new RectangleF2D(new PointF(-10, 0), new SizeF(100, 10)); shape.Text = " > > > > > "; shape.AppearanceText.TextBrush = new SolidBrushObject(Color.Salmon); needleShape.Add(shape); }
private void CreateEllipseNeedle(INeedle needle) { ComplexShape needleShape = (ComplexShape)needle.Shape; needleShape.Collection.Clear(); EllipseShape shape = new EllipseShape(new RectangleF2D(new PointF(-10, 0), new SizeF(100, 10))); LinearGradientBrushObject brush = new LinearGradientBrushObject(new PointF2D(2, 0), new PointF2D(0, 2)); brush.StartColor = Color.Yellow; brush.EndColor = Color.Magenta; shape.Appearance.ContentBrush = brush; shape.Name = "ellipseNeedle"; needleShape.Add(shape); }
private void CreatePolylineNeedle(INeedle needle) { ComplexShape needleShape = (ComplexShape)needle.Shape; needleShape.Collection.Clear(); PolylineShape shape = new PolylineShape(); shape.Points = new PointF[] { new PointF(0, 20), new PointF(-40, 25), new PointF(20, 5), new PointF(100, 0), new PointF(20, -5), new PointF(-40, -25), new PointF(0, -20) }; shape.Appearance.ContentBrush = new SolidBrushObject(Color.Yellow); shape.Name = "polylineNeedle"; needleShape.Add(shape); }
private void CreatePolygonNeedle(INeedle needle) { ComplexShape needleShape = (ComplexShape)needle.Shape; needleShape.Collection.Clear(); PolygonShape shape = new PolygonShape(); shape.Points = new PointF[] { new PointF(0, 10), new PointF(75, 10), new PointF(70, -5), new PointF(100, 0), new PointF(65, -10), new PointF(70, 5), new PointF(0, -10) }; shape.Appearance.ContentBrush = new SolidBrushObject(Color.AliceBlue); shape.Name = "polygonNeedle"; needleShape.Add(shape); }
private void CreatePathNeedle(INeedle needle) { ComplexShape needleShape = (ComplexShape)needle.Shape; needleShape.Collection.Clear(); PathShape shape = new PathShape(); shape.Points = new ShapePoint[] { new ShapePoint(new PointF(0, 20), PathPointType.Start), new ShapePoint(new PointF(50, 0), PathPointType.Line), new ShapePoint(new PointF(0, -20), PathPointType.Line), new ShapePoint(new PointF(100, 0), PathPointType.Line), new ShapePoint(new PointF(0, 20), PathPointType.CloseSubpath | PathPointType.Line) }; SolidBrushObject brush = new SolidBrushObject(Color.Red); shape.Appearance.ContentBrush = brush; shape.Name = "pathNeedle"; needleShape.Add(shape); }