コード例 #1
0
        void parentShape_MouseClick(object sender, MouseEventArgs e)
        {
            SelectedParent = (RawShape)sender;
            SelectedChild  = null;

            if (e.Button == MouseButtons.Right)
            {
                HideAllContextMenuItems();

                Entity parentEntity = (Entity)SelectedParent.Tag;

                if (EntityImpl.DetermineInheritanceTypeWithParent(Entity) == EntityImpl.InheritanceType.TablePerClassHierarchy)
                {
                    mnuCreateInheritanceHierarchy.Text    = "Edit inheritance hierarchy";
                    mnuCreateInheritanceHierarchy.Visible = true;
                }
                mnuRemove.Visible = true;
                mnuRemove.Text    = "Remove parent";
                var inheritanceType = EntityImpl.DetermineInheritanceTypeWithParent(Entity);
                mnuSetDiscriminatorForSubClass.Visible = inheritanceType == EntityImpl.InheritanceType.TablePerSubClass || inheritanceType == EntityImpl.InheritanceType.TablePerSubClassWithDiscriminator;
                contextMenuStrip1.Show(Cursor.Position);
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (EntitySelected != null)
                {
                    EntitySelected((EntityImpl)((RawShape)sender).Tag);
                }
            }
        }
コード例 #2
0
        void parentShape_MouseClick(object sender, MouseEventArgs e)
        {
            SelectedParent = (RawShape)sender;
            SelectedChild  = null;

            if (e.Button == MouseButtons.Right)
            {
                mnuRemove.Text = "Remove parent";
                contextMenuStrip1.Show(Cursor.Position);
            }
        }
コード例 #3
0
        void emptyParent_MouseClick(object sender, MouseEventArgs e)
        {
            SelectedParent = null;
            SelectedChild  = null;

            List <Entity> unavailableEntities = new List <Entity>();

            unavailableEntities.AddRange(Entity.Children);
            unavailableEntities.Add(Entity.Parent);

            UserControls.FormSelectEntityForInheritance form = new UserControls.FormSelectEntityForInheritance(Entity, unavailableEntities, null, "Select or create parent entity", false, UserControls.FormSelectEntityForInheritance.RequestorTypes.Entity_Select_Parent);
            form.ShowDialog();

            if (form.SelectedEntity != null)
            {
                Entity.Parent = form.SelectedEntity;
                Populate();
            }
        }
コード例 #4
0
        private void Populate()
        {
            Font     boldFont          = new Font(Font, FontStyle.Bold);
            Font     boldUnderlineFont = new Font(Font, FontStyle.Bold | FontStyle.Underline);
            RawShape centreShape       = new RawEntity(shapeCanvas1, Entity.Name, boldFont, Entity);

            List <RawShape> level1Shapes       = new List <RawShape>();
            List <RawShape> level3Shapes       = new List <RawShape>();
            List <RawShape> rightAlignedShapes = new List <RawShape>();

            if (Entity.Parent == null)
            {
                RawShape emptyParent = new RawShape(shapeCanvas1, "Add parent...", 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
                };
                emptyParent.MouseClick += new MouseEventHandler(emptyParent_MouseClick);
                level1Shapes.Add(emptyParent);
            }
            else
            {
                RawEntity parentShape = new RawEntity(shapeCanvas1, Entity.Parent.Name, boldFont, Entity.Parent);
                parentShape.OriginatingLineStyle = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow);
                parentShape.MouseClick          += new MouseEventHandler(parentShape_MouseClick);
                level1Shapes.Add(parentShape);

                foreach (var table in Entity.Parent.MappedTables())
                {
                    RawTable tableShape = new RawTable(shapeCanvas1, table.Name, boldFont, table);
                    tableShape.OriginatingLineStyle = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow);
                    tableShape.MouseClick          += new MouseEventHandler(tableShape_MouseClick);
                    rightAlignedShapes.Add(tableShape);
                }
            }
            foreach (var table in Entity.MappedTables())
            {
                RawTable tableShape = new RawTable(shapeCanvas1, table.Name, boldFont, table);
                tableShape.OriginatingLineStyle = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow);
                tableShape.MouseClick          += new MouseEventHandler(tableShape_MouseClick);
                rightAlignedShapes.Add(tableShape);
            }
            foreach (Entity child in Entity.Children)
            {
                RawEntity childShape = new RawEntity(shapeCanvas1, child.Name, boldFont, child);
                childShape.OriginatingLineStyle = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow);
                childShape.MouseClick          += new MouseEventHandler(childShape_MouseClick);
                level3Shapes.Add(childShape);

                foreach (var table in child.MappedTables())
                {
                    RawTable tableShape = new RawTable(shapeCanvas1, table.Name, boldFont, table);
                    tableShape.OriginatingLineStyle = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow);
                    tableShape.MouseClick          += new MouseEventHandler(tableShape_MouseClick);
                    rightAlignedShapes.Add(tableShape);
                }
            }
            #region Add empty child
            RawShape emptyChild = new RawShape(shapeCanvas1, "Add child...", 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,
                Tag = null,
                OriginatingLineStyle = null                //new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow)
            };
            emptyChild.MouseClick += new MouseEventHandler(emptyChild_MouseClick);
            //emptyChild.OriginatingLineStyle.MouseClick += new MouseEventHandler(OriginatingLineStyle_MouseClick);
            level3Shapes.Add(emptyChild);
            #endregion

            shapeCanvas1.BackColor = this.BackColor;
            shapeCanvas1.SwimLane1 = new ShapeCanvas.SwimLaneStyle(Color.FromArgb(100, 100, 100), Color.Black, Color.White, 90F, "Parent", ShapeCanvas.SwimLaneStyle.Styles.Line);
            shapeCanvas1.SwimLane2 = new ShapeCanvas.SwimLaneStyle(Color.FromArgb(100, 100, 100), Color.Black, Color.White, 90F, "Entity", ShapeCanvas.SwimLaneStyle.Styles.Line);
            shapeCanvas1.SwimLane3 = new ShapeCanvas.SwimLaneStyle(Color.FromArgb(100, 100, 100), Color.Black, Color.White, 90F, "Children", ShapeCanvas.SwimLaneStyle.Styles.Line);
            shapeCanvas1.SwimLane4 = new ShapeCanvas.SwimLaneStyle(Color.FromArgb(100, 100, 100), Color.Black, Color.White, 90F, "Mapped Tables", ShapeCanvas.SwimLaneStyle.Styles.Line);

            shapeCanvas1.BackColor = this.BackColor;
            shapeCanvas1.DrawVerticalSwimLanes(centreShape, level1Shapes, level3Shapes, rightAlignedShapes, "Parent", "Entity", "Children", "Mapped Tables");
        }
コード例 #5
0
        private void Populate()
        {
            if (Entity == null || BusyPopulating)
            {
                return;
            }

            BusyPopulating = true;

            try
            {
                Slyce.Common.Utility.SuspendPainting(this);
                Cursor = Cursors.WaitCursor;

                #region Check for Table Per Sub-Class
                HasOneToOne = false;

                foreach (var directedRef in Entity.DirectedReferences)
                {
                    if (ArchAngel.Interfaces.Cardinality.IsOneToOne(directedRef.FromEndCardinality, directedRef.ToEndCardinality))
                    {
                        HasOneToOne = true;
                        break;
                    }
                }
                #endregion

                //shapeCanvasInheritance.main
                Font boldFont          = new Font(Font, FontStyle.Bold);
                Font boldUnderlineFont = new Font(Font, FontStyle.Bold | FontStyle.Underline);
                CentreShape = new RawEntity(shapeCanvasInheritance, Entity.Name, boldFont, Entity);
                //centreShape.Cursor = Cursors.Hand;
                //centreShape.Click += new EventHandler(centreShape_OnClick);
                CentreShape.MouseClick += new MouseEventHandler(centreShape_MouseClick);

                List <RawShape> topLevelShapes    = new List <RawShape>();
                List <RawShape> bottomLevelShapes = new List <RawShape>();

                if (Entity.Parent == null)
                {
                    //if (HasOneToOne)
                    //{
                    RawShape emptyParent = new RawShape(shapeCanvasInheritance, "Add parent...", 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 = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow),
                        Tag = null
                    };
                    emptyParent.OriginatingLineStyle.ForeColor = Color.White;
                    emptyParent.MouseClick += new MouseEventHandler(emptyParent_MouseClick);
                    topLevelShapes.Add(emptyParent);
                    //}
                }
                else
                {
                    RawEntity parentShape = new RawEntity(shapeCanvasInheritance, Entity.Parent.Name, boldFont, Entity.Parent);
                    parentShape.OriginatingLineStyle             = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow);
                    parentShape.OriginatingLineStyle.MiddleImage = InfoImage;
                    //parentShape.OriginatingLineStyle.MiddleImageClick += new MouseEventHandler(ParentOriginatingLineStyle_MiddleImageClick);
                    parentShape.OriginatingLineStyle.ForeColor  = Color.White;
                    parentShape.OriginatingLineStyle.Parent     = parentShape;
                    parentShape.OriginatingLineStyle.MiddleText = GetInheritanceDisplayText(Entity);
                    parentShape.Tag               = Entity.Parent;
                    parentShape.MouseClick       += new MouseEventHandler(parentShape_MouseClick);
                    parentShape.MouseDoubleClick += new MouseEventHandler(parentShape_MouseDoubleClick);
                    parentShape.Cursor            = Cursors.Hand;
                    topLevelShapes.Add(parentShape);
                }

                #region Add empty child
                Slyce.Common.Controls.Diagramming.Shapes.RawShape emptyChild = new Slyce.Common.Controls.Diagramming.Shapes.RawShape(shapeCanvasInheritance, "Add child...", 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,
                    Tag = null,
                    OriginatingLineStyle = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow)
                };
                emptyChild.OriginatingLineStyle.ForeColor = Color.White;
                emptyChild.MouseClick += new MouseEventHandler(emptyChild_MouseClick);
                emptyChild.OriginatingLineStyle.MouseClick += new MouseEventHandler(OriginatingLineStyle_MouseClick);
                bottomLevelShapes.Add(emptyChild);
                #endregion

                foreach (Entity child in Entity.Children)
                {
                    RawEntity childShape = new RawEntity(shapeCanvasInheritance, child.Name, boldFont, child);
                    childShape.OriginatingLineStyle             = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow);
                    childShape.OriginatingLineStyle.MiddleImage = InfoImage;
                    //childShape.OriginatingLineStyle.MiddleImageClick += new MouseEventHandler(ChildOriginatingLineStyle_MiddleImageClick);
                    childShape.OriginatingLineStyle.ForeColor  = Color.White;
                    childShape.OriginatingLineStyle.Parent     = childShape;
                    childShape.OriginatingLineStyle.MiddleText = GetInheritanceDisplayText(child);
                    childShape.Tag               = child;
                    childShape.MouseClick       += new MouseEventHandler(childShape_MouseClick);
                    childShape.MouseDoubleClick += new MouseEventHandler(childShape_MouseDoubleClick);
                    childShape.Cursor            = Cursors.Hand;
                    bottomLevelShapes.Add(childShape);
                }
                shapeCanvasInheritance.BackColor = this.BackColor;
                shapeCanvasInheritance.Height    = this.Height;
                shapeCanvasInheritance.DrawThreeLayerVertical(CentreShape, topLevelShapes, bottomLevelShapes);

                var inheritanceType = EntityImpl.DetermineInheritanceTypeWithParent(Entity);
                mnuSetDiscriminatorForSubClass.Visible = inheritanceType == EntityImpl.InheritanceType.TablePerSubClass || inheritanceType == EntityImpl.InheritanceType.TablePerSubClassWithDiscriminator;
            }
            finally
            {
                this.AutoScrollPosition = ScrollPosition;
                Slyce.Common.Utility.ResumePainting(this);
                Cursor         = Cursors.Default;
                BusyPopulating = false;
            }
        }
コード例 #6
0
        private void ShowSelectParent(bool onlyCreateAbstractParent)
        {
            SelectedParent = null;
            SelectedChild  = null;

            List <Entity> unavailableEntities = new List <Entity>();

            unavailableEntities.AddRange(Entity.Children);
            unavailableEntities.Add(Entity.Parent);

            UserControls.FormSelectEntityForInheritance.RequestorTypes requestType = UserControls.FormSelectEntityForInheritance.RequestorTypes.Entity_Select_Parent;

            if (onlyCreateAbstractParent)
            {
                requestType = UserControls.FormSelectEntityForInheritance.RequestorTypes.Entity_Create_Abstract_Parent;
            }

            EntityImpl originalEntity = Entity;

            UserControls.FormSelectEntityForInheritance form = new UserControls.FormSelectEntityForInheritance(Entity, unavailableEntities, null, "Select or create parent entity", false, requestType);
            form.EntityDeleted += new EventHandler(form_EntityDeleted);
            form.ShowDialog();

            Entity = originalEntity;

            if (form.SelectedEntity != null)
            {
                Entity.Parent = form.SelectedEntity;
                form.SelectedEntity.AddChild(Entity);

                foreach (var directedReference in Entity.DirectedReferences)
                {
                    if (directedReference.ToEntity == Entity.Parent)
                    {
                        Entity.RemoveReference(directedReference.Reference);
                        directedReference.Reference.DeleteSelf();
                    }
                }
                foreach (var directedReference in Entity.Parent.DirectedReferences)
                {
                    if (directedReference.ToEntity == Entity)
                    {
                        Entity.Parent.RemoveReference(directedReference.Reference);
                        directedReference.Reference.DeleteSelf();
                    }
                }
                // Remove the ID property from the child entity because it should share the parent entity's ID instead
                if (!form.SelectedEntity.IsAbstract)
                {
                    for (int i = Entity.Key.Properties.ToList().Count - 1; i >= 0; i--)
                    {
                        Entity.Key.Properties.ElementAt(i).IsPartOfHiddenKey = true;
                    }
                }

                Populate();
                this.Refresh();
                RaiseInheritanceUpdatedEvent();
            }
            form.EntityDeleted -= form_EntityDeleted;
            Populate();
        }
コード例 #7
0
        void emptyChild_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != System.Windows.Forms.MouseButtons.Left)
            {
                return;
            }

            EntityImpl.InheritanceType inheritanceTypeWithChildren = EntityImpl.DetermineInheritanceTypeWithChildren(Entity);

            if (inheritanceTypeWithChildren == EntityImpl.InheritanceType.TablePerClassHierarchy)
            {
                ShowHierarchyEditor();
                return;
            }
            //if ((Entity.Children.Count > 0 && inheritanceTypeWithChildren == EntityImpl.InheritanceType.TablePerSubClass) ||
            //    inheritanceTypeWithChildren == EntityImpl.InheritanceType.TablePerConcreteClass ||
            //    inheritanceTypeWithChildren == EntityImpl.InheritanceType.TablePerClassHierarchy)// ||
            //{
            SelectedParent = null;
            SelectedChild  = null;

            List <Entity> unavailableEntities = new List <Entity>();

            unavailableEntities.AddRange(Entity.Children);

            if (Entity.Parent != null)
            {
                unavailableEntities.Add(Entity.Parent);
            }

            UserControls.FormSelectEntityForInheritance form = new UserControls.FormSelectEntityForInheritance(Entity, unavailableEntities, null, "Select child entities", true, UserControls.FormSelectEntityForInheritance.RequestorTypes.Entity_Select_Child);
            form.EntityDeleted += new EventHandler(form_EntityDeleted);
            form.ShowDialog();

            if (form.SelectedEntities != null && form.SelectedEntities.Count > 0)
            {
                foreach (var entity in form.SelectedEntities)
                {
                    Entity.AddChild(entity);
                    entity.Parent = Entity;

                    foreach (var directedReference in Entity.DirectedReferences)
                    {
                        if (directedReference.ToEntity == entity)
                        {
                            Entity.RemoveReference(directedReference.Reference);
                            directedReference.Reference.DeleteSelf();
                        }
                    }
                    foreach (var directedReference in entity.DirectedReferences)
                    {
                        if (directedReference.ToEntity == Entity)
                        {
                            entity.RemoveReference(directedReference.Reference);
                            directedReference.Reference.DeleteSelf();
                        }
                    }
                    // Remove the ID property from the child entity because it should share the parent entity's ID instead
                    for (int i = entity.Key.Properties.ToList().Count - 1; i >= 0; i--)
                    {
                        if (Entity.IsAbstract)
                        {
                            entity.Key.Properties.ElementAt(i).IsHiddenByAbstractParent = true;
                        }
                        else
                        {
                            entity.Key.Properties.ElementAt(i).IsPartOfHiddenKey = true;
                        }
                    }
                    if (Entity.IsAbstract)
                    {
                        foreach (Property parentProp in Entity.Properties)
                        {
                            Property childProp = entity.ConcreteProperties.SingleOrDefault(p => p.Name == parentProp.Name);

                            if (childProp != null)
                            {
                                childProp.IsHiddenByAbstractParent = true;
                            }
                        }
                    }
                }
                form.EntityDeleted -= form_EntityDeleted;
                Populate();

                RaiseInheritanceUpdatedEvent();
            }
            //}
            //else if (!HasOneToOne)
            //{
            //UserControls.FormInheritanceHierarchy form = new UserControls.FormInheritanceHierarchy(Entity);
            //form.ShowDialog(this);
            //}
        }
コード例 #8
0
        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;
        }
コード例 #9
0
        private void Populate()
        {
            if (Table == null || BusyPopulating)
            {
                return;
            }

            try
            {
                BusyPopulating = true;
                Slyce.Common.Utility.SuspendPainting(this);
                bool hasMultiSchemas = Table.Database.GetSchemas().Count() > 1;
                //HideAllFloatingToolstrips();
                Cursor = Cursors.WaitCursor;
                Font boldFont    = new Font(Font, FontStyle.Bold);
                Font subTextFont = new Font(Font.FontFamily, Font.Size - 0.6F, FontStyle.Regular);
                MainShape = new RawTable(shapeCanvas1, Table.Name, boldFont, CategoryFont, PropertyFont, Table);

                if (hasMultiSchemas)
                {
                    MainShape.SubText = string.Format("  ({0}) ", Table.Schema);
                }

                MainShape.FontSubText = subTextFont;
                MainShape.Icon        = Table.IsView ? ViewImage : TableImage;
                //MainShape.Enter += new EventHandler(centreShape_Enter);
                //MainShape.Leave += new EventHandler(centreShape_Leave);
                MainShape.MouseClick  += new MouseEventHandler(centreShape_MouseClick);
                CategoryColumns.Parent = MainShape;
                CategoryColumns.Properties.Clear();

                MainShape.Categories.Add(CategoryColumns);

                if (Table.Columns.Count > 0)
                {
                    foreach (var column in Table.Columns)
                    {
                        RawProperty prop = new RawProperty(column.Name, column);

                        if (column.InPrimaryKey)
                        {
                            prop.ImageColor = Color.OrangeRed;
                            prop.ImageType  = RawProperty.ImageTypes.Key;
                        }
                        prop.Click       += new MouseEventHandler(Column_Click);
                        prop.DoubleClick += new MouseEventHandler(Column_DoubleClick);
                        CategoryColumns.Properties.Add(prop);
                    }
                }

                List <RawShape> bottomLevelShapes  = new List <RawShape>();
                List <RawShape> rightAlignedShapes = new List <RawShape>();
                Font            boldUnderlineFont  = new Font(Font, FontStyle.Bold | FontStyle.Underline);

                //TheEntity.Discriminator.RootGrouping.
                #region Mapped Entities

                if (ShowMappedEntities)
                {
                    foreach (EntityImpl entity in MappedEntities.OrderBy(e => e.Name))
                    {
                        RawEntity entityShape = new RawEntity(shapeCanvas1, entity.Name, boldFont, entity);

                        CustomLineCap startCap = LineCaps.None;                        //.SolidArrow;
                        CustomLineCap endCap   = LineCaps.None;
                        entityShape.OriginatingLineStyle.LineStyle = DashStyle.Solid;
                        entityShape.Cursor = Cursors.Hand;
                        //entityShape.OriginatingLineStyle.MiddleText = GetDiscriminatorText(entityShape);
                        entityShape.OriginatingLineStyle.StartCap = startCap;
                        entityShape.OriginatingLineStyle.EndCap   = endCap;
                        //entityShape.BackColor1 = Color.Blue;
                        //entityShape.BackColor2 = Color.DarkBlue;
                        //entityShape.RoundedCorners = false;
                        entityShape.Tag  = entity;
                        entityShape.Icon = EntityImage;
                        string discriminatorText = GetDiscriminatorText(entity);
                        entityShape.OriginatingLineStyle.MiddleText = discriminatorText;

                        if (string.IsNullOrEmpty(discriminatorText))
                        {
                            entityShape.OriginatingLineStyle.MiddleImage        = FilterImageDisabled;
                            entityShape.OriginatingLineStyle.MiddleImageFocused = FilterImageDisabled;
                        }
                        else
                        {
                            entityShape.OriginatingLineStyle.MiddleImage        = FilterImage;
                            entityShape.OriginatingLineStyle.MiddleImageFocused = FilterImageFocused;
                        }
                        entityShape.OriginatingLineStyle.MouseClick += new MouseEventHandler(OriginatingLineStyle_MouseClick);
                        entityShape.MouseClick += new MouseEventHandler(entityShape_MouseClick);
                        entityShape.OriginatingLineStyle.MiddleImageClick += new MouseEventHandler(MapLine_MiddleImageClick);
                        entityShape.OriginatingLineStyle.ForeColor         = Color.White;
                        entityShape.OriginatingLineStyle.DataObject        = entity;
                        entityShape.OriginatingLineStyle.ShowMiddleTextOnlyWhenFocused = true;
                        //entityShape.Enter += new EventHandler(entityShape_Enter);
                        //entityShape.Leave += new EventHandler(entityShape_Leave);
                        entityShape.MouseDoubleClick += new MouseEventHandler(entityShape_MouseDoubleClick);

                        //#region Setup discriminator
                        //if (Table.Discriminator != null && Table.Discriminator.RootGrouping != null)
                        //{
                        //    ArchAngel.Providers.EntityModel.Model.DatabaseLayer.Discrimination.Condition firstCondition = Table.Discriminator.RootGrouping.Conditions.ElementAtOrDefault(0);

                        //    if (firstCondition != null)
                        //    {
                        //        IColumn column = firstCondition.Column;
                        //        ArchAngel.Providers.EntityModel.Model.DatabaseLayer.Discrimination.Operator op = firstCondition.Operator;
                        //        string exprText = firstCondition.ExpressionValue.Value;
                        //    }
                        //}
                        //#endregion

                        //tableShape.OriginatingLineStyle.MiddleImageMouseOver += new EventHandler(OriginatingLineStyle_MiddleImageMouseOver);
                        rightAlignedShapes.Add(entityShape);
                    }
                    #region Add empty entity
                    Slyce.Common.Controls.Diagramming.Shapes.RawShape emptyEntity = new Slyce.Common.Controls.Diagramming.Shapes.RawShape(shapeCanvas1, "Map 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,
                        Tag                  = null,
                        RoundedCorners       = false,
                        OriginatingLineStyle = null                         //new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow)
                    };
                    emptyEntity.MouseClick += new MouseEventHandler(emptyEntity_MouseClick);
                    //emptyTable.OriginatingLineStyle.MouseClick += new MouseEventHandler(OriginatingLineStyle_MouseClick);
                    rightAlignedShapes.Add(emptyEntity);
                    #endregion
                }
                #endregion

                #region Relationships
                if (ShowRelatedtables)
                {
                    foreach (Relationship relationship in Table.Relationships.OrderBy(r => r.PrimaryTable == Table ? r.ForeignTable.Name : r.PrimaryTable.Name))
                    {
                        RawShape      relatedTableShape;
                        CustomLineCap startCap;
                        CustomLineCap endCap;

                        if (relationship.PrimaryTable == Table)
                        {
                            relatedTableShape = new RawTable(shapeCanvas1, relationship.ForeignTable.Name, boldFont, relationship.ForeignTable);

                            if (hasMultiSchemas)
                            {
                                relatedTableShape.SubText = string.Format("  ({0}) ", relationship.ForeignTable.Schema);
                            }

                            string end1 = relationship.PrimaryKey.IsUnique ? "1" : "m";
                            endCap   = relationship.ForeignKey.IsUnique ? LineCaps.One : LineCaps.Many;
                            startCap = relationship.PrimaryKey.IsUnique ? LineCaps.One : LineCaps.Many;
                            relatedTableShape.OriginatingLineStyle.MiddleImageClick += new MouseEventHandler(OriginatingLineStyle_MiddleImageClick2);
                            relatedTableShape.Icon = relationship.ForeignTable.IsView ? ViewImage : TableImage;
                        }
                        else if (relationship.ForeignTable == Table)
                        {
                            relatedTableShape = new RawTable(shapeCanvas1, relationship.PrimaryTable.Name, boldFont, relationship.PrimaryTable);

                            if (hasMultiSchemas)
                            {
                                relatedTableShape.SubText = string.Format("  ({0}) ", relationship.PrimaryTable.Schema);
                            }

                            string end1 = relationship.ForeignKey.IsUnique ? "1" : "m";
                            endCap   = relationship.PrimaryKey.IsUnique ? LineCaps.One : LineCaps.Many;
                            startCap = relationship.ForeignKey.IsUnique ? LineCaps.One : LineCaps.Many;
                            relatedTableShape.OriginatingLineStyle.MiddleImageClick += new MouseEventHandler(OriginatingLineStyle_MiddleImageClick2);
                            relatedTableShape.Icon = relationship.PrimaryTable.IsView ? ViewImage : TableImage;
                        }
                        else
                        {
                            throw new Exception("What the...??!");
                        }

                        relatedTableShape.FontSubText = subTextFont;

                        if (relationship.IsUserDefined)
                        {
                            relatedTableShape.OriginatingLineStyle.LineStyle = DashStyle.Dash;
                            relatedTableShape.OriginatingLineStyle.LineColor = Color.Yellow;
                        }
                        else
                        {
                            relatedTableShape.OriginatingLineStyle.LineStyle = DashStyle.Solid;
                        }
                        relatedTableShape.Cursor = Cursors.Hand;
                        relatedTableShape.OriginatingLineStyle.StartCap    = startCap;
                        relatedTableShape.OriginatingLineStyle.EndCap      = endCap;
                        relatedTableShape.OriginatingLineStyle.DataObject  = relationship;
                        relatedTableShape.OriginatingLineStyle.ForeColor   = Color.White;
                        relatedTableShape.OriginatingLineStyle.MiddleImage = InfoImage;
                        relatedTableShape.MouseClick       += new MouseEventHandler(referencedEntityShape_MouseClick);
                        relatedTableShape.MouseDoubleClick += new MouseEventHandler(referencedEntityShape_MouseDoubleClick);
                        bottomLevelShapes.Add(relatedTableShape);
                    }
                    // Add empty relationship
                    RawShape emptyTable = new RawShape(shapeCanvas1, "Add relationship...", 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,
                        Tag = null
                    };
                    emptyTable.MouseClick += new MouseEventHandler(emptyTable_MouseClick);
                    bottomLevelShapes.Add(emptyTable);
                }
                #endregion

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

                shapeCanvas1.BackColor = this.BackColor;
                //shapeCanvas1.DrawStar(centreShape, outerShapes);
                //shapeCanvas1.DrawThreeLayerHorizontal(centreShape, null, outerShapes, false);
                shapeCanvas1.Height = this.Height;
                //shapeCanvas1.DrawThreeLayerVertical(centreShape, null, bottomLevelShapes, rightAlignedShapes);
                shapeCanvas1.KeepMainShapeCentered = true;
                shapeCanvas1.DrawThreeLayerHorizontal(MainShape, bottomLevelShapes, rightAlignedShapes, KeepMainShapeFull);
                //shapeCanvas1.Focus();
            }
            finally
            {
                this.AutoScrollPosition = ScrollPosition;
                Slyce.Common.Utility.ResumePainting(this);
                Cursor         = Cursors.Default;
                BusyPopulating = false;
                this.Focus();
                shapeCanvas1.Focus();
            }
        }
コード例 #10
0
        private void DrawThreeLayers()
        {
            if (Entity == null)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;
            Font boldFont          = new Font(Font, FontStyle.Bold);
            Font boldUnderlineFont = new Font(Font, FontStyle.Bold | FontStyle.Underline);

            RawShape centreShape = new RawEntity(Entity.Name, boldFont, Entity);

            centreShape.MouseClick += new MouseEventHandler(centreShape_MouseClick);

            List <RawShape> topLevelShapes    = new List <RawShape>();
            List <RawShape> bottomLevelShapes = new List <RawShape>();

            foreach (ReferenceImpl reference in Entity.References)
            {
                RawShape      referencedEntityShape;
                CustomLineCap startCap;
                CustomLineCap endCap;

                if (reference.Entity1 == Entity)
                {
                    referencedEntityShape = new RawEntity(reference.Entity2.Name, boldFont, reference.Entity2);
                    string end1 = ArchAngel.Interfaces.Cardinality.One.Equals(reference.Cardinality1) ? "1" : "m";
                    startCap = ArchAngel.Interfaces.Cardinality.One.Equals(reference.Cardinality1) ? LineCaps.One : LineCaps.Many;
                    endCap   = ArchAngel.Interfaces.Cardinality.One.Equals(reference.Cardinality2) ? LineCaps.One : LineCaps.Many;
                    referencedEntityShape.OriginatingLineStyle.StartTextDataMember = "End2Name";
                    referencedEntityShape.OriginatingLineStyle.EndTextDataMember   = "End1Name";
                    referencedEntityShape.OriginatingLineStyle.MouseOverEnd1      += new LinkLine.MouseEndDelegate(OriginatingLineStyle_MouseOverEnd2);
                    referencedEntityShape.OriginatingLineStyle.MouseOverEnd2      += new LinkLine.MouseEndDelegate(OriginatingLineStyle_MouseOverEnd1);
                }
                else if (reference.Entity2 == Entity)
                {
                    referencedEntityShape = new RawEntity(reference.Entity1.Name, boldFont, reference.Entity1);
                    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.StartTextDataMember = "End1Name";
                    referencedEntityShape.OriginatingLineStyle.EndTextDataMember   = "End2Name";
                    referencedEntityShape.OriginatingLineStyle.MouseOverEnd1      += new LinkLine.MouseEndDelegate(OriginatingLineStyle_MouseOverEnd1);
                    referencedEntityShape.OriginatingLineStyle.MouseOverEnd2      += new LinkLine.MouseEndDelegate(OriginatingLineStyle_MouseOverEnd2);
                }
                else
                {
                    throw new Exception("What the...??!");
                }

                referencedEntityShape.OriginatingLineStyle.LineStyle      = DashStyle.Solid;
                referencedEntityShape.OriginatingLineStyle.StartCap       = startCap;
                referencedEntityShape.OriginatingLineStyle.EndCap         = endCap;
                referencedEntityShape.OriginatingLineStyle.DataObject     = reference;
                referencedEntityShape.OriginatingLineStyle.ForeColor      = Color.White;
                referencedEntityShape.OriginatingLineStyle.DefaultEndText = "not set";
                bottomLevelShapes.Add(referencedEntityShape);
            }
            // Add empty reference
            RawShape emptyReference = new RawShape("Add reference...", 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);
            bottomLevelShapes.Add(emptyReference);

            //if (vertical)
            //  canvas1.DrawThreeLayerVertical(centreShape, topLevelShapes, bottomLevelShapes);
            //else
            shapeCanvas1.BackColor = this.BackColor;
            //shapeCanvas1.DrawThreeLayerHorizontal(centreShape, topLevelShapes, bottomLevelShapes, true);
            shapeCanvas1.Height = this.Height;
            //shapeCanvas1.DrawStar(centreShape, bottomLevelShapes);
            shapeCanvas1.KeepMainShapeFull = KeepMainShapeFull;
            shapeCanvas1.DrawThreeLayerVertical(centreShape, null, bottomLevelShapes);

            Cursor = Cursors.Default;
        }