public EntityMappingDiagram()
        {
            InitializeComponent();

            this.BackColor = Color.Black;

            CategoryFont = new Font(Font.FontFamily, 7.5F, FontStyle.Regular);
            PropertyFont = new Font(Font.FontFamily, 7F, FontStyle.Regular);
            CategoryProperties = new RawCategory("Properties", CategoryFont, PropertyFont, MainShape);
            CategoryInheritedProperties = new RawCategory("Inherited Properties", CategoryFont, PropertyFont, MainShape);
            //CategoryComponents = new RawCategory("Components", CategoryFont, PropertyFont, MainShape);
            CategoryNavigation = new RawCategory("Navigation", CategoryFont, PropertyFont, MainShape);

            //PopulateTableToolstrip();
            //PopulateEntityToolstrip();
            //PopulateReferencedEntityToolstrip();
            //PopulateComponentToolstrip();

            //shapeCanvas1.LineEndWithFocusChanged += new ShapeCanvas.LineEndWithFocusChangedDelegate(shapeCanvas1_LineEndWithFocusChanged);
            shapeCanvas1.MouseClick += new MouseEventHandler(shapeCanvas1_MouseClick);
            shapeCanvas1.MouseMove += new MouseEventHandler(shapeCanvas1_MouseMove);
            CategoryProperties.MultiPropertiesClicked += new RawCategory.MultiPropertiesClickedDelegate(CategoryProperties_MultiPropertiesClicked);

            RefEditorForm.VisibleChanged += new EventHandler(RefEditorForm_VisibleChanged);
            //ComponentMappingEditor.Visible = false;
            //ComponentMappingEditor.VisibleChanged += new EventHandler(ComponentMappingEditor_VisibleChanged);
            //this.Controls.Add(ComponentMappingEditor);

            MappingEditor.Visible = false;
            MappingEditor.VisibleChanged += new EventHandler(MappingEditor_VisibleChanged);
            this.Controls.Add(MappingEditor);
        }
        public void Draw(Graphics g, Point pos, Font font, Brush textBrush, int textHeight)
        {
            g.FillRectangle(BackBrush, Bounds);

            if (SubProperties.Count > 0)
            {
                Point trianglePoint = new Point(pos.X - 8, pos.Y + 6);
                RawCategory.DrawTriangle(g, trianglePoint, IsExpanded, textBrush);
            }
            //if (IsSelected)
            //{
            //    Point selectedPoint = new Point(Bounds.X + 8, pos.Y + 4);
            //    //Point selectedPoint = new Point(Bounds.X + 8, Bounds.Y);
            //    g.FillEllipse(SelectedBrush, selectedPoint.X, selectedPoint.Y, 5, 5);
            //    //DrawImage(g, selectedPoint, ImageTypes.Circle, SelectedBrush);
            //}
            g.DrawString(Text, font, textBrush, pos);
            DrawImage(g, pos, ImageType, ImageBrush);

            if (IsExpanded)
            {
                Point startPos = pos;
                pos.Offset(8, textHeight + 1);

                foreach (RawProperty prop in SubProperties)
                {
                    prop.Bounds = new Rectangle(Bounds.X, pos.Y, Bounds.Width, Bounds.Height - (pos.Y - startPos.Y));
                    prop.Draw(g, pos, font, textBrush, textHeight);
                    pos.Offset(0, textHeight);
                }
                //this.Bounds.Height = textHeight + 1;
            }
        }
        public TableMappingDiagram()
        {
            InitializeComponent();

            this.BackColor = Color.Black;

            CategoryFont = new Font(Font.FontFamily, 7.5F, FontStyle.Regular);
            PropertyFont = new Font(Font.FontFamily, 7F, FontStyle.Regular);
            CategoryColumns = new RawCategory("Columns", CategoryFont, PropertyFont, MainShape);
            CategoryColumns.IsExpanded = true;

            shapeCanvas1.MouseClick += new MouseEventHandler(shapeCanvas1_MouseClick);
            shapeCanvas1.LineEndWithFocusChanged += new Slyce.Common.Controls.Diagramming.Shapes.ShapeCanvas.LineEndWithFocusChangedDelegate(this.shapeCanvas1_LineEndWithFocusChanged);
            shapeCanvas1.MouseMove += new MouseEventHandler(shapeCanvas1_MouseMove);

            //PopulateTableToolstrip();
            //PopulateEntityToolstrip();

            MappingEditor.Visible = false;
            MappingEditor.VisibleChanged += new EventHandler(MappingEditor_VisibleChanged);

            this.Controls.Add(MappingEditor);
        }
        private void CategoryProperties_MultiPropertiesClicked(RawCategory category, List<RawProperty> selectedProperties)
        {
            SelectedProperties.Clear();

            if (selectedProperties.Count <= 1)
                return;

            foreach (var rawProp in selectedProperties)
                SelectedProperties.Add((Property)rawProp.Tag);

            if (selectedProperties.Count <= 1)
                return;

            foreach (ToolStripItem item in contextMenuStrip1.Items)
                item.Visible = false;

            mnuAddComponent.Visible = true;
            mnuRefactorToExistingComponent.Visible = true;
            contextMenuStrip1.Show(Cursor.Position);
            SelectedCategory = category;
        }
        private void Draw()
        {
            if (ComponentSpecification == null)
                return;

            Cursor = Cursors.WaitCursor;
            Font boldFont = new Font(Font, FontStyle.Bold);
            MainShape = new RawComponent(shapeCanvas1, ComponentSpecification.Name, boldFont, ComponentSpecification);
            MainShape.Categories.Clear();

            RawCategory cat = new RawCategory("Properties", Font, MainShape);
            MainShape.Categories.Add(cat);

            foreach (var x in ComponentSpecification.Properties)
            {
                //RawProperty prop = new RawProperty(string.Format("{0} [{1}]", x.Name, x.Type), x);
                RawProperty prop = new RawProperty(x.Name, x);
                cat.Properties.Add(prop);
            }

            //centreShape.Icon = EntityImage;
            //centreShape.Enter += new EventHandler(centreShape_Enter);
            //centreShape.Leave += new EventHandler(centreShape_Leave);
            Font boldUnderlineFont = new Font(Font, FontStyle.Bold | FontStyle.Underline);
            List<RawShape> topLevelShapes = new List<RawShape>();
            List<RawShape> rightAlignedShapes = new List<RawShape>();

            #region References

            foreach (ComponentImpl component in ComponentSpecification.ImplementedComponents)
            {
                RawEntity referencedEntityShape;
                CustomLineCap startCap;
                CustomLineCap endCap;

                referencedEntityShape = new RawEntity(shapeCanvas1, component.ParentEntity.Name, boldFont, component.ParentEntity);
                //string end1 = ArchAngel.Interfaces.Cardinality.One.Equals(reference.Cardinality2) ? "1" : "m";
                //startCap = ArchAngel.Interfaces.Cardinality.One.Equals(reference.Cardinality2) ? LineCaps.One : LineCaps.Many;
                //endCap = ArchAngel.Interfaces.Cardinality.One.Equals(reference.Cardinality1) ? LineCaps.One : LineCaps.Many;
                referencedEntityShape.OriginatingLineStyle.EndTextDataMember = "Name";
                //referencedEntityShape.OriginatingLineStyle.EndTextDataMember = "End2Name";
                //referencedEntityShape.OriginatingLineStyle.StartImageClick += new LinkLine.MouseEndDelegate(OriginatingLineStyle_StartImageClick);
                //referencedEntityShape.OriginatingLineStyle.EndImageClick += new LinkLine.MouseEndDelegate(OriginatingLineStyle_EndImageClick);
                //referencedEntityShape.OriginatingLineStyle.MouseOverEnd1 += new LinkLine.MouseOverEndDelegate(OriginatingLineStyle_MouseOverEnd2);
                //referencedEntityShape.OriginatingLineStyle.MouseOverEnd2 += new LinkLine.MouseOverEndDelegate(OriginatingLineStyle_MouseOverEnd1);

                referencedEntityShape.Icon = EntityImage;
                referencedEntityShape.OriginatingLineStyle.LineStyle = DashStyle.Solid;
                //referencedEntityShape.OriginatingLineStyle.StartCap = startCap;
                //referencedEntityShape.OriginatingLineStyle.EndCap = endCap;
                referencedEntityShape.OriginatingLineStyle.DataObject = component;
                referencedEntityShape.OriginatingLineStyle.ForeColor = Color.White;
                referencedEntityShape.OriginatingLineStyle.DefaultEndText = "";
                //referencedEntityShape.OriginatingLineStyle.StartImage = EditImage;
                //referencedEntityShape.OriginatingLineStyle.EndImage = EditImage;
                referencedEntityShape.OriginatingLineStyle.MiddleImage = InfoImage;
                referencedEntityShape.OriginatingLineStyle.MiddleImageClick += new MouseEventHandler(OriginatingLineStyle_MiddleImageClick);
                referencedEntityShape.MouseDoubleClick += new MouseEventHandler(referencedEntityShape_MouseDoubleClick);
                referencedEntityShape.MouseClick += new MouseEventHandler(referencedEntityShape_MouseClick);
                referencedEntityShape.Cursor = Cursors.Hand;
                topLevelShapes.Add(referencedEntityShape);
            }
            // Add empty reference
            RawShape emptyReference = new RawShape(shapeCanvas1, "Add entity...", boldUnderlineFont)
            {
                BackColor1 = Color.White,
                BackColor2 = Color.White,
                BorderColor = Color.Gray,
                ForeColor = Color.Gray,
                FocusForeColor = Color.Blue,
                FocusBackColor1 = Color.WhiteSmoke,
                FocusBackColor2 = Color.White,
                FocusBorderColor = Color.DarkGray,
                Cursor = Cursors.Hand,
                OriginatingLineStyle = null,// new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow),
                Tag = null
            };
            //emptyReference.OriginatingLineStyle.ForeColor = Color.White;
            emptyReference.MouseClick += new MouseEventHandler(emptyReference_MouseClick);
            topLevelShapes.Add(emptyReference);
            #endregion

            shapeCanvas1.SwimLane1 = new ShapeCanvas.SwimLaneStyle(Color.Gray, Color.Black, Color.White, 180F, "Used By (Entities)", ShapeCanvas.SwimLaneStyle.Styles.Fill);
            //shapeCanvas1.SwimLane3 = new ShapeCanvas.SwimLaneStyle(Color.FromArgb(79, 124, 205), Color.Black, Color.White, 0F, "Mapped Tables", ShapeCanvas.SwimLaneStyle.Styles.Fill);

            shapeCanvas1.BackColor = this.BackColor;
            shapeCanvas1.Height = this.Height;
            shapeCanvas1.KeepMainShapeCentered = true;
            shapeCanvas1.DrawThreeLayerHorizontal(MainShape, topLevelShapes, rightAlignedShapes, KeepMainShapeFull);
            Cursor = Cursors.Default;
        }