コード例 #1
0
        public static Polyline ConnectShapes(Shape Start, Shape End, Object Tag, Dataweb.NShape.WinFormsUI.Display Display,
                                             Dataweb.NShape.Project Project, ILineStyle LineStyle, Layer Layer)
        {
            Polyline arrow = (Polyline)Project.ShapeTypes["Polyline"].CreateInstance();

            arrow.LineStyle          = LineStyle;
            arrow.Tag                = Tag;
            arrow.SecurityDomainName = 'B';

            if (Display.InvokeRequired)
            {
                Display.BeginInvoke(new MethodInvoker(() => AddShape(Display, Project, arrow)));
            }
            else
            {
                Display.Diagram.Shapes.Add(arrow);
                Project.Repository.Insert((Shape)arrow, Display.Diagram);
            }

            arrow.Connect(ControlPointId.FirstVertex, Start, ControlPointId.Reference);
            arrow.Connect(ControlPointId.LastVertex, End, ControlPointId.Reference);

            Display.Diagram.AddShapeToLayers(arrow, Layer.Id);


            return(arrow);
        }
コード例 #2
0
        public static Shape DrawLabel(int Height, int Width, int X, int Y, IFillStyle FillStyle, ILineStyle LineStyle,
                                      String Caption, Object Tag, Char SecurityDomain, Dataweb.NShape.WinFormsUI.Display Display,
                                      Dataweb.NShape.Project Project, Layer Layer)
        {
            Dataweb.NShape.GeneralShapes.Label shape;
            shape        = (Dataweb.NShape.GeneralShapes.Label)Project.ShapeTypes["Label"].CreateInstance();
            shape.Height = Height;
            shape.Width  = Width;

            shape.X = X;

            shape.Y = Y;

            shape.FillStyle = FillStyle;

            shape.SetCaptionText(0, Caption);

            shape.CharacterStyle = Project.Design.CharacterStyles.Heading3;

            shape.Tag = Tag;

            shape.SecurityDomainName = SecurityDomain;

            Display.Diagram.Shapes.Add(shape, 10);

            Display.Diagram.AddShapeToLayers(shape, Layer.Id);

            Project.Repository.Insert((Shape)shape, Display.Diagram);

            return(shape);
        }
コード例 #3
0
        public static Shape DrawCircle(int Diameter, int X, int Y, IFillStyle FillStyle, ILineStyle LineStyle,
                                       String Caption, Object Tag, Char SecurityDomain, Dataweb.NShape.WinFormsUI.Display Display,
                                       Dataweb.NShape.Project Project, Layer Layer)
        {
            CircleBase shape;

            shape          = (CircleBase)Project.ShapeTypes["Circle"].CreateInstance();
            shape.Diameter = Diameter;

            shape.X = X;

            shape.Y = Y;

            shape.FillStyle = FillStyle;

            shape.SetCaptionText(0, Caption);

            shape.CharacterStyle = Project.Design.CharacterStyles.Heading3;

            shape.Tag = Tag;

            shape.SecurityDomainName = SecurityDomain;


            if (Display.InvokeRequired)
            {
                Display.BeginInvoke(new MethodInvoker(() => AddShape(Display, Project, shape)));
            }
            else
            {
                Display.Diagram.Shapes.Add(shape);
                Display.Diagram.AddShapeToLayers(shape, Layer.Id);

                Project.Repository.Insert((Shape)shape, Display.Diagram);
            }


            return(shape);
        }
コード例 #4
0
        public static Shape DrawCircleRadialTree(int Diameter, int LayerShapeCount, int LayerShapeIndex, int LayerDistanceFromCenter, Point LayerCenter,
                                                 IFillStyle FillStyle, ILineStyle LineStyle, String Caption, Object Tag, Char SecurityDomain,
                                                 Dataweb.NShape.WinFormsUI.Display Display, Dataweb.NShape.Project Project, Layer Layer)
        {
            Point DiagramCenter = new Point(Display.Diagram.Width / 2, Display.Diagram.Height / 2);

            Point result = new Point();

            double angle = 0;

            if (LayerShapeCount == 1)
            {
                angle = 2 * Math.PI / LayerShapeCount; //between 0 and 2 * PI (~6.2832), angle is in radians

                if (LayerCenter.X < DiagramCenter.X)
                {
                    angle += Math.PI;
                }
            }

            if (LayerShapeCount > 1)
            {
                angle = 2 * Math.PI / LayerShapeCount * LayerShapeIndex; //between 0 and 2 * PI (~6.2832), angle is in radians

                if (LayerCenter.X < DiagramCenter.X)
                {
                    angle = (Math.PI / LayerShapeCount * LayerShapeIndex) + (0.5 * Math.PI);
                }

                if (LayerCenter.X > DiagramCenter.X)
                {
                    angle = ((Math.PI / LayerShapeCount) * LayerShapeIndex) + (1.5 * Math.PI);
                }
            }

            result.Y = (int)Math.Round(LayerCenter.Y + LayerDistanceFromCenter * Math.Sin(angle));
            result.X = (int)Math.Round(LayerCenter.X + LayerDistanceFromCenter * Math.Cos(angle));

            return(DrawCircle(Diameter, result.X, result.Y, FillStyle, LineStyle, Caption, Tag, SecurityDomain, Display, Project, Layer));
        }
コード例 #5
0
 public static void AddShape(Dataweb.NShape.WinFormsUI.Display Display, Dataweb.NShape.Project Project, Shape shape)
 {
     Display.Diagram.Shapes.Add(shape);
     Project.Repository.Insert(shape, Display.Diagram);
 }
コード例 #6
0
        public static void LayouterTopology(int LayerDistance, int RowDistance, FlowLayouter.FlowDirection Direction, int SpringRate, int Repulsion, int RepulsionRange, int Friction, int Mass, Boolean Fit,
                                            int FitX0, int FitY0, int FitX1, int FitY1, Dataweb.NShape.WinFormsUI.Display Display, int Timeout, LayouterType Type, Dataweb.NShape.Project Project)
        {
            switch (Type)
            {
            case LayouterType.Expansion:
                break;

            case LayouterType.Flow:
                FlowLayouter flowLayouter = new FlowLayouter(Project);
                flowLayouter.Direction     = Direction;
                flowLayouter.LayerDistance = LayerDistance;
                flowLayouter.RowDistance   = RowDistance;
                flowLayouter.AllShapes     = Display.Diagram.Shapes;
                flowLayouter.Shapes        = Display.Diagram.Shapes;

                flowLayouter.Prepare();
                flowLayouter.Execute(Timeout);

                if (Fit)
                {
                    flowLayouter.Fit(FitX0, FitY0, FitX1, FitY1);
                }

                break;

            case LayouterType.Grid:
                break;

            case LayouterType.Repulsion:
                RepulsionLayouter repulsionLayouter = new RepulsionLayouter(Project);
                repulsionLayouter.SpringRate     = SpringRate;     //8
                repulsionLayouter.Repulsion      = Repulsion;      //3
                repulsionLayouter.RepulsionRange = RepulsionRange; //600
                repulsionLayouter.Friction       = Friction;       //0
                repulsionLayouter.Mass           = Mass;           //50
                repulsionLayouter.AllShapes      = Display.Diagram.Shapes;
                repulsionLayouter.Shapes         = Display.Diagram.Shapes;

                repulsionLayouter.Prepare();

                repulsionLayouter.Execute(Timeout);

                if (Fit)
                {
                    repulsionLayouter.Fit(FitX0, FitY0, FitX1, FitY1);
                }

                break;

            default:
                break;
            }
        }
コード例 #7
0
        public static CircularArc ConnectShapesArc(Shape Start, Shape End, ICapStyle StartCapStyle, ICapStyle EndCapStyle, Object Tag,
                                                   Dataweb.NShape.WinFormsUI.Display Display, Dataweb.NShape.Project Project, ILineStyle LineStyle, Layer Layer)
        {
            CircularArc arc = (CircularArc)Project.ShapeTypes["CircularArc"].CreateInstance();

            arc.LineStyle          = LineStyle;
            arc.Tag                = Tag;
            arc.SecurityDomainName = 'B';


            Display.Diagram.Shapes.Add(arc);
            arc.StartCapStyle = StartCapStyle;
            arc.EndCapStyle   = EndCapStyle;
            arc.Connect(ControlPointId.FirstVertex, Start, ControlPointId.Reference);
            arc.Connect(ControlPointId.LastVertex, End, ControlPointId.Reference);

            Point firstPt = arc.GetControlPointPosition(ControlPointId.FirstVertex);
            Point lastPt  = arc.GetControlPointPosition(ControlPointId.LastVertex);
            Point dstPos  = Point.Empty;

            dstPos.X = ((firstPt.X + lastPt.X) / 2) + 1;
            dstPos.Y = ((firstPt.Y + lastPt.Y) / 2) + 1;

            arc.InsertVertex(ControlPointId.LastVertex, dstPos.X, dstPos.Y);

            Display.Diagram.AddShapeToLayers(arc, Layer.Id);

            Project.Repository.Insert((Shape)arc, Display.Diagram);

            return(arc);
        }
コード例 #8
0
        private static Polyline ConnectShapesWithCapStyle(Shape Start, Shape End, ICapStyle StartCapStyle, ICapStyle EndCapStyle, Object Tag, Dataweb.NShape.WinFormsUI.Display Display, Dataweb.NShape.Project Project)
        {
            Polyline arrow = (Polyline)Project.ShapeTypes["Polyline"].CreateInstance();

            arrow.Tag = Tag;
            arrow.SecurityDomainName = 'B';
            Display.Diagram.Shapes.Add(arrow);
            arrow.StartCapStyle = StartCapStyle;
            arrow.EndCapStyle   = EndCapStyle;
            arrow.Connect(ControlPointId.FirstVertex, Start, ControlPointId.Reference);
            arrow.Connect(ControlPointId.LastVertex, End, ControlPointId.Reference);

            Project.Repository.Insert((Shape)arrow, Display.Diagram);


            return(arrow);
        }
コード例 #9
0
        public static Polyline DrawParallelArrow(Polyline Shape, Object Tag, Dataweb.NShape.WinFormsUI.Display Display, Dataweb.NShape.Project Project, ILineStyle LineStyle, Layer Layer)
        {
            Polyline parallel = (Polyline)Project.ShapeTypes["Polyline"].CreateInstance();

            parallel.StartCapStyle      = Project.Design.CapStyles.OpenArrow;
            parallel.LineStyle          = LineStyle;
            parallel.Tag                = Tag;
            parallel.SecurityDomainName = 'B';

            Point p0 = Shape.GetControlPointPosition(ControlPointId.FirstVertex);
            Point p1 = Shape.GetControlPointPosition(ControlPointId.LastVertex);

            Point n0 = Shape.CalcNormalVector(p0);
            Point n1 = Shape.CalcNormalVector(p1);

            parallel.MoveControlPointTo(ControlPointId.FirstVertex, n0.X, n0.Y, ResizeModifiers.None);
            parallel.MoveControlPointTo(ControlPointId.LastVertex, n1.X, n1.Y, ResizeModifiers.None);

            Display.Diagram.Shapes.Add(parallel);

            Display.Diagram.AddShapeToLayers(parallel, Layer.Id);

            Project.Repository.Insert((Shape)parallel, Display.Diagram);

            return(parallel);
        }
コード例 #10
0
        public static Shape DrawBox(int Height, int Width, int X, int Y, IFillStyle FillStyle, ILineStyle LineStyle, ICharacterStyle CharacterStyle, IParagraphStyle ParagraphStyle,
                                    String Caption, Object Tag, Char SecurityDomain, Dataweb.NShape.WinFormsUI.Display Display, Dataweb.NShape.Project Project)
        {
            Box shape;

            shape        = (Box)Project.ShapeTypes["Box"].CreateInstance();
            shape.Height = Height;
            shape.Width  = Width;

            shape.X = X;

            shape.Y = Y;

            shape.FillStyle = FillStyle;

            shape.CharacterStyle = CharacterStyle;

            shape.ParagraphStyle = ParagraphStyle;

            shape.SetCaptionText(0, Caption);

            shape.Tag = Tag;

            shape.SecurityDomainName = SecurityDomain;

            Display.Diagram.Shapes.Add(shape);

            Project.Repository.Insert((Shape)shape, Display.Diagram);

            return(shape);
        }