Framework / Presentation Layer / Smart Shapes / Sample Shapes / Info Shape

Info Shape

This example produces the Info Smart Shape, which is represented by the following image:

This shape is implemented as a group, because the foreground content needs to have different filling and stroke style than the background.

C#
Copy Code
NSmartGroup group = new NSmartGroup();
group.Name = "Info";

NSmartShape background = new NSmartShape();
background.Name = "Background";
group.Shapes.Add(background);

NSmartShape foreground = new NSmartShape();
foreground.Name = "Foreground";
group.Shapes.Add(foreground);

// group transform
group.Sheet.TransformSection.Width.Value = 200;
group.Sheet.TransformSection.Height.Value = 200;
group.Sheet.TransformSection.Angle.Value = 0;
group.Sheet.TransformSection.PinX.Value = 100;
group.Sheet.TransformSection.PinY.Value = 100;
group.Sheet.TransformSection.LocPinX.Formula = "Width*0.5";
group.Sheet.TransformSection.LocPinY.Formula = "Height*0.5";

// group users
group.Sheet.UserDefinedCellsSection = new NUserDefinedCellsSection();
group.Sheet.UserDefinedCellsSection.AddUserCell("Ratio", new NSingleFormulaCell("Width/Height"));

// background shape transform
background.Sheet.TransformSection.Width.Formula = "Group!Width";
background.Sheet.TransformSection.Height.Formula = "Group!Height";
background.Sheet.TransformSection.Angle.Value = 0;
background.Sheet.TransformSection.PinX.Formula = "Width*0.5";
background.Sheet.TransformSection.PinY.Formula = "Height*0.5";
background.Sheet.TransformSection.LocPinX.Formula = "Width*0.5";
background.Sheet.TransformSection.LocPinY.Formula = "Height*0.5";

// background shape geometry
NGeometrySection backgroundGeometry = new NGeometrySection("Geometry1", "Geometry1");
background.Sheet.Sections.Add(backgroundGeometry);

backgroundGeometry.AddMoveTo("Width/2", "0");
backgroundGeometry.AddEllipticalArcTo("Width/2", "Height", "Width", "Height/2", "0", "Group!User.Ratio");
backgroundGeometry.AddEllipticalArcTo("Width/2", "0", "0", "Height/2", "0", "Group!User.Ratio");
backgroundGeometry.CloseFigures.Value = true;

// background appearance
background.FillStyle = new NColorFillStyle(Color.Blue);
background.StrokeStyle = new NStrokeStyle(1, Color.Black);

// foreground shape transform
foreground.Sheet.TransformSection.Width.Formula = "Group!Width";
foreground.Sheet.TransformSection.Height.Formula = "Group!Height";
foreground.Sheet.TransformSection.Angle.Value = 0;
foreground.Sheet.TransformSection.PinX.Formula = "Width*0.5";
foreground.Sheet.TransformSection.PinY.Formula = "Height*0.5";
foreground.Sheet.TransformSection.LocPinX.Formula = "Width*0.5";
foreground.Sheet.TransformSection.LocPinY.Formula = "Height*0.5";

// foreground shape geometry1
NGeometrySection foregroundGeometry1 = new NGeometrySection("Geometry1", "Geometry1");
foreground.Sheet.Sections.Add(foregroundGeometry1);

foregroundGeometry1.AddMoveTo("Width/2", "Height/8");
foregroundGeometry1.AddEllipticalArcTo("Width/2", "Height*3/8", "Width/2+Width/8", "Height/4", "0", "Group!User.Ratio");
foregroundGeometry1.AddEllipticalArcTo("Width/2", "Height/8", "Width/2-Width/8", "Height/4", "0", "Group!User.Ratio");
foregroundGeometry1.CloseFigures.Value = true;

// foreground shape geometry2
NGeometrySection foregroundGeometry2 = new NGeometrySection("Geometry2", "Geometry2");
foreground.Sheet.Sections.Add(foregroundGeometry2);

foregroundGeometry2.AddMoveTo("Width/2-Width/8", "Height/2-Height/16");
foregroundGeometry2.AddLineTo("Width/2+Width/8", "Height/2-Height/16");
foregroundGeometry2.AddLineTo("Width/2+Width/8", "Height-Height/8");
foregroundGeometry2.AddLineTo("Width/2-Width/8", "Height-Height/8");
foregroundGeometry2.CloseFigures.Value = true;

// group appearance
group.FillStyle = new NColorFillStyle(Color.White); 
group.StrokeStyle = new NStrokeStyle(0, Color.Black);
Visual Basic
Copy Code
Dim group As New NSmartGroup
group.Name = "Info"

Dim background As New NSmartShape
background.Name = "Background"
group.Shapes.Add(background)

Dim foreground As New NSmartShape
foreground.Name = "Foreground"
group.Shapes.Add(foreground)

' group transform
group.Sheet.TransformSection.Width.Value = 200
group.Sheet.TransformSection.Height.Value = 200
group.Sheet.TransformSection.Angle.Value = 0
group.Sheet.TransformSection.PinX.Value = 100
group.Sheet.TransformSection.PinY.Value = 100
group.Sheet.TransformSection.LocPinX.Formula = "Width*0.5"
group.Sheet.TransformSection.LocPinY.Formula = "Height*0.5"

' group users
group.Sheet.UserDefinedCellsSection = New NUserDefinedCellsSection
group.Sheet.UserDefinedCellsSection.AddUserCell("Ratio", New NSingleFormulaCell("Width/Height"))

' background shape transform
background.Sheet.TransformSection.Width.Formula = "Group!Width"
background.Sheet.TransformSection.Height.Formula = "Group!Height"
background.Sheet.TransformSection.Angle.Value = 0
background.Sheet.TransformSection.PinX.Formula = "Width*0.5"
background.Sheet.TransformSection.PinY.Formula = "Height*0.5"
background.Sheet.TransformSection.LocPinX.Formula = "Width*0.5"
background.Sheet.TransformSection.LocPinY.Formula = "Height*0.5"

' background shape geometry
Dim backgroundGeometry As New NGeometrySection("Geometry1", "Geometry1")
background.Sheet.Sections.Add(backgroundGeometry)

backgroundGeometry.AddMoveTo("Width/2", "0")
backgroundGeometry.AddEllipticalArcTo("Width/2", "Height", "Width", "Height/2", "0", "Group!User.Ratio")
backgroundGeometry.AddEllipticalArcTo("Width/2", "0", "0", "Height/2", "0", "Group!User.Ratio")
backgroundGeometry.CloseFigures.Value = True

' background appearance
background.FillStyle = New NColorFillStyle(New NArgbColor(Color.Blue))
background.StrokeStyle = New NStrokeStyle(1, New NArgbColor(Color.Black))

' foreground shape transform
foreground.Sheet.TransformSection.Width.Formula = "Group!Width"
foreground.Sheet.TransformSection.Height.Formula = "Group!Height"
foreground.Sheet.TransformSection.Angle.Value = 0
foreground.Sheet.TransformSection.PinX.Formula = "Width*0.5"
foreground.Sheet.TransformSection.PinY.Formula = "Height*0.5"
foreground.Sheet.TransformSection.LocPinX.Formula = "Width*0.5"
foreground.Sheet.TransformSection.LocPinY.Formula = "Height*0.5"

' foreground shape geometry1
Dim foregroundGeometry1 As New NGeometrySection("Geometry1", "Geometry1")
foreground.Sheet.Sections.Add(foregroundGeometry1)

foregroundGeometry1.AddMoveTo("Width/2", "Height/8")
foregroundGeometry1.AddEllipticalArcTo("Width/2", "Height*3/8", "Width/2+Width/8", "Height/4", "0", "Group!User.Ratio")
foregroundGeometry1.AddEllipticalArcTo("Width/2", "Height/8", "Width/2-Width/8", "Height/4", "0", "Group!User.Ratio")
foregroundGeometry1.CloseFigures.Value = True

' foreground shape geometry2
Dim foregroundGeometry2 As New NGeometrySection("Geometry2", "Geometry2")
foreground.Sheet.Sections.Add(foregroundGeometry2)

foregroundGeometry2.AddMoveTo("Width/2-Width/8", "Height/2-Height/16")
foregroundGeometry2.AddLineTo("Width/2+Width/8", "Height/2-Height/16")
foregroundGeometry2.AddLineTo("Width/2+Width/8", "Height-Height/8")
foregroundGeometry2.AddLineTo("Width/2-Width/8", "Height-Height/8")
foregroundGeometry2.CloseFigures.Value = True

' group appearance
group.FillStyle = New NColorFillStyle(New NArgbColor(Color.White))
group.StrokeStyle = New NStrokeStyle(0, New NArgbColor(Color.Black))