Exemple #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);
        }
Exemple #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);
        }
Exemple #3
0
        public MainForm()
        {
            InitializeComponent();

            // Initialize project with a shape library
            project.AddLibrary(typeof(ThickArrow).Assembly, false);
            // Add this application as model object library
            project.AddLibrary(GetType().Assembly, false);

            project.Name = "Model Mapping Demo";
            project.Create();

            // Create an instance of the test object (that implements IModelObject)
            Template         template = project.Repository.GetTemplate("ThickArrow");
            MyBusinessObject model    = (MyBusinessObject)project.ModelObjectTypes["MyBusinessObjectType"].CreateInstance();

            InitPropertyMappings(template, model);

            // Create a diagram with a shape that is bound to a business object
            const string diagramName = "Demo Diagram";
            Diagram      diagram     = new Diagram(diagramName);

            // Create a shape from the prepared template
            ThickArrow shape = (ThickArrow)project.Repository.GetTemplate("ThickArrow").CreateShape();

            shape.MoveTo(diagram.Width / 2, diagram.Height / 2);
            shape.Width     = 120;
            shape.HeadWidth = 60;
            shape.Height    = 100;

            diagram.Shapes.Add(shape);
            project.Repository.Insert(shape.ModelObject);
            project.Repository.InsertAll(diagram);

            display1.LoadDiagram(diagramName);

            // Store model object to modify
            businessObj = shape.ModelObject as MyBusinessObject;
            // Update start values
            businessObj.MyBooleanProperty = checkBox.Checked;
            businessObj.MyIntegerProperty = (int)intTrackBar.Value;
            businessObj.MyFloatProperty   = (float)floatTrackBar.Value;
        }