This example produces the Rounded Rectangle Smart Shape, which is represented by the following image:
The control point (yellow diamond) alters the size of the rounded corner. The rounded corner is properly adjusted when the shape is resized.
C# |
Copy Code
|
---|---|
NSmartShape shape = new NSmartShape(); shape.Name = "Rounded Rectangle"; NShapeSheet sheet = shape.Sheet; // modify the transform sheet.TransformSection.Width.Value = 200; sheet.TransformSection.Height.Value = 200; sheet.TransformSection.Angle.Value = 0; sheet.TransformSection.PinX.Value = 100; sheet.TransformSection.PinY.Value = 100; sheet.TransformSection.LocPinX.Formula = "Width*0.5"; sheet.TransformSection.LocPinY.Formula = "Height*0.5"; // add a geometry NGeometrySection geometry1 = new NGeometrySection("Geometry1", "Geometry1"); sheet.Sections.Add(geometry1); geometry1.AddMoveTo("Geometry1.X2-Scratch.X1", "MIN(0,Height/2-Scratch.X1)"); geometry1.AddArcTo("MAX(Width,Width/2+Scratch.X1)", "Geometry1.Y1+Scratch.X1", "Scratch.X1*0.2929"); geometry1.AddLineTo("Geometry1.X2", "Geometry1.Y4-Scratch.X1"); geometry1.AddArcTo("Geometry1.X1", "Height-Geometry1.Y1", "Geometry1.A2"); geometry1.AddLineTo("Geometry1.X6+Scratch.X1", "Geometry1.Y4"); geometry1.AddArcTo("Width-Geometry1.X2", "Height-Geometry1.Y2", "Geometry1.A2"); geometry1.AddLineTo("Geometry1.X6", "Geometry1.Y2"); geometry1.AddArcTo("Geometry1.X5", "Geometry1.Y1", "Geometry1.A2"); geometry1.AddLineTo("Geometry1.X1", "Geometry1.Y1"); // add scratches sheet.ScratchSection = new NScratchSection(); sheet.ScratchSection.AddScratch( new NSingleFormulaCell("MIN(Width/2,Height/2,MAX(Controls.X1,0))"), new NSingleFormulaCell(""), new NSingleFormulaCell(""), new NSingleFormulaCell(""), new NSingleFormulaCell(""), new NSingleFormulaCell("")); // add controls sheet.ControlsSection = new NControlsSection(); sheet.ControlsSection.AddControl("40", "Height*0", true, ControlBehavior.OffsetFromNearSide, ControlBehavior.Locked, "First control point"); shape.FillStyle = new NColorFillStyle(Color.Honeydew); shape.StrokeStyle = new NStrokeStyle(1, Color.Black); |
Visual Basic |
Copy Code
|
---|---|
Dim shape As New NSmartShape shape.Name = "Rounded Rectangle" Dim sheet As NShapeSheet = shape.Sheet ' modify the transform sheet.TransformSection.Width.Value = 200 sheet.TransformSection.Height.Value = 200 sheet.TransformSection.Angle.Value = 0 sheet.TransformSection.PinX.Value = 100 sheet.TransformSection.PinY.Value = 100 sheet.TransformSection.LocPinX.Formula = "Width*0.5" sheet.TransformSection.LocPinY.Formula = "Height*0.5" ' add a geometry Dim geometry1 As New NGeometrySection("Geometry1", "Geometry1") sheet.Sections.Add(geometry1) geometry1.AddMoveTo("Geometry1.X2-Scratch.X1", "MIN(0,Height/2-Scratch.X1)") geometry1.AddArcTo("MAX(Width,Width/2+Scratch.X1)", "Geometry1.Y1+Scratch.X1", "Scratch.X1*0.2929") geometry1.AddLineTo("Geometry1.X2", "Geometry1.Y4-Scratch.X1") geometry1.AddArcTo("Geometry1.X1", "Height-Geometry1.Y1", "Geometry1.A2") geometry1.AddLineTo("Geometry1.X6+Scratch.X1", "Geometry1.Y4") geometry1.AddArcTo("Width-Geometry1.X2", "Height-Geometry1.Y2", "Geometry1.A2") geometry1.AddLineTo("Geometry1.X6", "Geometry1.Y2") geometry1.AddArcTo("Geometry1.X5", "Geometry1.Y1", "Geometry1.A2") geometry1.AddLineTo("Geometry1.X1", "Geometry1.Y1") ' add scratches sheet.ScratchSection = New NScratchSection sheet.ScratchSection.AddScratch( _ New NSingleFormulaCell("MIN(Width/2,Height/2,MAX(Controls.X1,0))"), _ New NSingleFormulaCell(""), _ New NSingleFormulaCell(""), _ New NSingleFormulaCell(""), _ New NSingleFormulaCell(""), _ New NSingleFormulaCell("")) ' add controls sheet.ControlsSection = New NControlsSection sheet.ControlsSection.AddControl("40", "Height*0", True, ControlBehavior.OffsetFromNearSide, ControlBehavior.Locked, "First control point") shape.FillStyle = New NColorFillStyle(New NArgbColor(Color.Honeydew)) shape.StrokeStyle = New NStrokeStyle(1, New NArgbColor(Color.Black)) |