private NShape CreateFlexiArrow2Shape(NPoint from, NPoint to) { NShape shape = new NShape(); shape.Init1DShape(EN1DShapeXForm.Vector); shape.Height = 0; shape.BeginX = from.X; shape.BeginY = from.Y; shape.EndX = to.X; shape.EndY = to.Y; // add controls NControl controlPoint = new NControl(); controlPoint.SetFx("X", "13.0956"); controlPoint.SetFx("Y", "Height*0.75"); controlPoint.Visible = true; controlPoint.XBehavior = ENCoordinateBehavior.OffsetFromMin; controlPoint.YBehavior = ENCoordinateBehavior.OffsetFromMid; controlPoint.Tooltip = "Modify arrowhead 1"; shape.Controls.AddChild(controlPoint); controlPoint = new NControl(); controlPoint.SetFx("X", "Width-40"); controlPoint.SetFx("Y", "Height*1"); controlPoint.Visible = true; controlPoint.XBehavior = ENCoordinateBehavior.OffsetFromMax; controlPoint.YBehavior = ENCoordinateBehavior.OffsetFromMid; controlPoint.Tooltip = "Modify arrowhead 2"; shape.Controls.AddChild(controlPoint); controlPoint = new NControl(); controlPoint.SetFx("X", "Width-20"); controlPoint.SetFx("Y", "Height*1"); controlPoint.Visible = true; controlPoint.XBehavior = ENCoordinateBehavior.OffsetFromMax; controlPoint.YBehavior = ENCoordinateBehavior.OffsetFromMid; controlPoint.Tooltip = "Modify arrowhead 3"; shape.Controls.AddChild(controlPoint); // add a geometry NGeometry geometry = new NGeometry(); NMoveTo plotFigure = geometry.MoveTo("Width*0", "Height*0.5"); geometry.LineTo("Controls.0.X", "ABS(Controls.0.Y)"); geometry.LineTo("Controls.1.X", "ABS(Controls.1.Y)"); geometry.LineTo("Controls.2.X", "ABS(Controls.2.Y)"); geometry.LineTo("Width", "Height*0.5"); geometry.LineTo("Controls.2.X", "Height-Geometry.3.Y"); geometry.LineTo("Controls.1.X", "Height-Geometry.2.Y"); geometry.LineTo("Controls.0.X", "Height-Geometry.1.Y"); geometry.LineTo("Geometry.0.X", "Geometry.0.Y"); plotFigure.CloseFigure = true; shape.Geometry = geometry; return(shape); }
private NShape CreateTrapezoidShape(double width, double height, double pinX, double pinY) { NShape shape = new NShape(); shape.Init2DShape(); shape.Width = width; shape.Height = height; shape.PinX = pinX; shape.PinY = pinY; // add controls NControl control = new NControl(); control.SetFx(NControl.XProperty, new NShapeWidthFactorFx(0.3)); control.Y = 0.0d; control.XBehavior = ENCoordinateBehavior.OffsetFromMax; control.YBehavior = ENCoordinateBehavior.Locked; control.Tooltip = "Modify strip width"; shape.Controls.Add(control); // add a geometry NGeometry geometry1 = new NGeometry(); { NMoveTo plotFigure = geometry1.MoveTo("MIN(Controls.0.X,Width-Controls.0.X)", 0.0d); geometry1.LineTo("Width-Geometry.0.X", 0.0d); geometry1.LineTo(new NShapeWidthFactorFx(1), new NShapeHeightFactorFx(1)); geometry1.LineTo(0.0d, "Height"); geometry1.LineTo("Geometry.0.X", "Geometry.0.Y"); plotFigure.CloseFigure = true; } shape.Geometry = geometry1; // add ports // top NPort port = new NPort(); port.SetFx(NPort.XProperty, new NShapeWidthFactorFx(0.5)); port.Y = 0.0d; port.GlueMode = ENPortGlueMode.Outward; port.DirX = 0.0d; port.DirY = -1; shape.Ports.Add(port); // right port = new NPort(); port.SetFx(NPort.XProperty, new NShapeWidthFactorFx(1)); port.SetFx(NPort.YProperty, new NShapeHeightFactorFx(0.5)); port.GlueMode = ENPortGlueMode.InwardAndOutward; port.DirX = 1; port.DirY = 0.0d; shape.Ports.Add(port); // bottom port = new NPort(); port.SetFx(NPort.XProperty, "Controls.0.X"); port.SetFx(NPort.YProperty, new NShapeHeightFactorFx(1)); port.DirX = 0.0d; port.DirY = 1; shape.Ports.Add(port); // left port = new NPort(); port.X = 0.0d; port.SetFx(NPort.YProperty, new NShapeHeightFactorFx(0.5)); port.DirX = -1; port.DirY = 0.0d; shape.Ports.Add(port); // shape.FillStyle = new NColorFillStyle(Color.Gray); shape.Geometry.Stroke = new NStroke(1, NColor.Black); shape.Geometry.Stroke.LineJoin = ENLineJoin.Miter; /* NShadow shadow = new NShadow(NColor.Green, 50, 50); * shadow.ScalePinPoint = new NPoint(0.5, 0.5); * shadow.Scale = 1.0; * shadow.UseFillAndStrokeAlpha = false; * shadow.ApplyToFilling = true; * shadow.ApplyToOutline = true; * shape.Shadow = shadow;*/ NStackPanel stack = new NStackPanel(); NButton button = new NButton("Hello Joro"); //button.Click += new Function<NEventArgs>(button_Click); stack.Add(button); NLabel label = new NLabel("Hello World"); stack.Add(label); //shape.Widget = stack; //shape.Widget = new NLabel("Hello World"); return(shape); }
/// <summary> /// Creates a custom shape that is a replica of the Visio Trapedzoid shape. With NOV diagram you can replicate the smart behavior of any Visio smart shape. /// </summary> /// <returns></returns> protected NShape CreateTrapedzoidShape() { NShape shape = new NShape(); shape.Init2DShape(); // add controls NControl control = new NControl(); control.SetFx(NControl.XProperty, new NShapeWidthFactorFx(0.3)); control.Y = 0.0d; control.SetFx(NControl.XBehaviorProperty, string.Format("IF(X<Width/2,{0},{1})", ((int)ENCoordinateBehavior.OffsetFromMin), ((int)ENCoordinateBehavior.OffsetFromMax))); control.YBehavior = ENCoordinateBehavior.Locked; control.Tooltip = "Modify strip width"; shape.Controls.Add(control); // add a geometry NGeometry geometry1 = shape.Geometry; { NMoveTo plotFigure = geometry1.MoveTo("MIN(Controls.0.X,Width-Controls.0.X)", 0.0d); geometry1.LineTo("Width-Geometry.0.X", 0.0d); geometry1.LineTo("Width", "Height"); geometry1.LineTo(0.0d, "Height"); geometry1.LineTo("Geometry.0.X", "Geometry.0.Y"); plotFigure.CloseFigure = true; } // add ports for (int i = 0; i < 4; i++) { NPort port = new NPort(); shape.Ports.Add(port); switch (i) { case 0: // top port.Relative = true; port.X = 0.5; port.Y = 0.0d; port.SetDirection(ENBoxDirection.Up); break; case 1: // right port.SetFx(NPort.XProperty, "(Geometry.1.X + Geometry.2.X) / 2"); port.SetFx(NPort.YProperty, new NShapeHeightFactorFx(0.5)); port.SetDirection(ENBoxDirection.Right); break; case 2: // bottom port.Relative = true; port.X = 0.5; port.Y = 1.0d; port.SetDirection(ENBoxDirection.Down); break; case 3: // left port.SetFx(NPort.XProperty, "(Geometry.0.X + Geometry.3.X) / 2"); port.SetFx(NPort.YProperty, new NShapeHeightFactorFx(0.5)); port.SetDirection(ENBoxDirection.Left); break; } } return(shape); }