Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
        }