Example #1
0
        /// <summary>
        /// Draw relation line/arrow between two classes in the diagram, provided the class exists in given dictionary
        /// </summary>
        /// <param name="class1Name">Class 1 name. (Departing)/</param>
        /// <param name="class2Name">Class 2 name. (Arrival)</param>
        /// <param name="shapeDictionary">Shape dictionary to use</param>
        public void DrawRelation(string class1Name, string class2Name, Dictionary <string, CaptionedShapeBase> shapeDictionary)
        {
            if (!shapeDictionary.ContainsKey(class1Name))
            {
                MainForm.LogOnDebug("DrawRelation: Departing class missing from dictionary: " + class1Name);
                return;
            }

            if (!shapeDictionary.ContainsKey(class2Name))
            {
                MainForm.LogOnDebug("DrawRelation: Arrival class missing from dictionary: " + class2Name);
                return;
            }

            LineShapeBase line  = (LineShapeBase)_NShapeProject.ShapeTypes["Polyline"].CreateInstance();
            ThickArrow    arrow = (ThickArrow)_NShapeProject.ShapeTypes["ThickArrow"].CreateInstance();

            line.Connect(ControlPointId.FirstVertex, shapeDictionary[class1Name], ControlPointId.Reference);
            line.Connect(ControlPointId.LastVertex, shapeDictionary[class2Name], ControlPointId.Reference);

            arrow.MoveControlPointTo(1, line.GetControlPointPosition(ControlPointId.FirstVertex).X,
                                     line.GetControlPointPosition(ControlPointId.FirstVertex).Y, 0);
            arrow.MoveControlPointTo(6, line.GetControlPointPosition(ControlPointId.LastVertex).X,
                                     line.GetControlPointPosition(ControlPointId.LastVertex).Y, 0);

            _NShapeDiagram.Shapes.Add(arrow);
        }
Example #2
0
        public void DrawRelationInterface(string class1Name, string class2Name, Dictionary <string, CaptionedShapeBase> shapeDictionary)
        {
            if (!shapeDictionary.ContainsKey(class1Name))
            {
                MainForm.LogOnDebug("DrawRelation: Departing class missing from dictionary: " + class1Name);
                return;
            }

            if (!shapeDictionary.ContainsKey(class2Name))
            {
                MainForm.LogOnDebug("DrawRelation: Arrival class missing from dictionary: " + class2Name);
                return;
            }
            LineShapeBase line  = (LineShapeBase)_NShapeProject.ShapeTypes["Polyline"].CreateInstance();
            ThickArrow    arrow = (ThickArrow)_NShapeProject.ShapeTypes["ThickArrow"].CreateInstance();

            line.Connect(ControlPointId.FirstVertex, shapeDictionary[class1Name], ControlPointId.Reference);
            line.Connect(ControlPointId.LastVertex, shapeDictionary[class2Name], ControlPointId.Reference);

            ColorStyle myColorStyle       = new ColorStyle("test", System.Drawing.Color.Green);
            ColorStyle mySecondColorStyle = new ColorStyle("test", System.Drawing.Color.White);
            FillStyle  myFillStyle        = new FillStyle("test", myColorStyle, mySecondColorStyle);

            arrow.FillStyle = myFillStyle;

            arrow.MoveControlPointTo(1, line.GetControlPointPosition(ControlPointId.FirstVertex).X,
                                     line.GetControlPointPosition(ControlPointId.FirstVertex).Y, 0);
            arrow.MoveControlPointTo(6, line.GetControlPointPosition(ControlPointId.LastVertex).X,
                                     line.GetControlPointPosition(ControlPointId.LastVertex).Y, 0);

            _NShapeDiagram.Shapes.Add(arrow);
        }
 /// <override></override>
 protected override void InsertControlPoint(int index, LineShapeBase.LineControlPoint controlPoint)
 {
     if (controlPoint is RelativeLineControlPoint) {
         RelativePosition relPos = ((RelativeLineControlPoint)controlPoint).RelativePosition;
         relPos.B = 0;
         ((RelativeLineControlPoint)controlPoint).RelativePosition = relPos;
     }
     base.InsertControlPoint(index, controlPoint);
 }