public void Init(DbRelationship rel)
        {
            lblRel.Text = String.Format("{0} ----- {1}", rel.OriginalTable, rel.RefTable);

            Relationship = rel;
            Model = null;

            cmbRelType.SelectedItem = cmbRelType.Items[cmbRelType.Items.IndexOf(rel.RelType.ToString())];
            cmbCascStyleDirect.SelectedItem = cmbCascStyleDirect.Items[cmbCascStyleDirect.Items.IndexOf(rel.CascadeStyleDirect.ToString())];
            cmbCascStyleInverse.SelectedItem = cmbCascStyleDirect.Items[cmbCascStyleDirect.Items.IndexOf(rel.CascadeStyleInverse.ToString())];
            chkGenerate.Checked = rel.Generate;
            chkGenInverse.Checked = rel.GenerateInverse;
            chkLazyDirect.Checked = rel.LazyLoadingDirect;
            chkLazyInverse.Checked = rel.LazyLoadingInverse;
            chkNullableDirect.Checked = rel.NullableDirect;

            AdjustDisplay();
        }
        public void Init(TableModel model)
        {
            lblTab.Text = String.Format("{0}", model.Name);

            Model = model;
            Relationship = null;
            txtClassName.Text = model.UserMapping.ClassName;
            txtCollectionName.Text = model.UserMapping.SetName;

            isView = model.ObjectType == DbObjectType.View;
            if (isView)
            {
                cmbFields.Items.Clear();
                cmbFields.Items.Add("");
                cmbFields.Items.AddRange(Model.MetaData.Columns.Select(t => t.Name).ToArray());
                if (String.IsNullOrEmpty(model.ForcedPrimaryKey))
                    cmbFields.SelectedItem = "";
                else
                    cmbFields.SelectedItem = model.ForcedPrimaryKey;
            }

            AdjustDisplay();
        }
        public void UpdateRelationshipLabel(DbRelationship newRel, List<TableModel> tableContainer = null)
        {
            int count = TableDiagram.Shapes.Count(t => (string) t.Tag == String.Format("{0}|{1}L", newRel.OriginalTable, newRel.RefTable));
            if (count > 1)
                return;

            var toUpdLabel = (Label)TableDiagram.Shapes.SingleOrDefault(t => (string) t.Tag == String.Format("{0}|{1}L", newRel.OriginalTable, newRel.RefTable));
            var rel = (RectangularLine)TableDiagram.Shapes.SingleOrDefault(t => (string) t.Tag == String.Format("{0}|{1}R", newRel.OriginalTable, newRel.RefTable));

            if (rel == null && toUpdLabel == null)
                return;

            if (!newRel.Generate)
            {
                toUpdLabel.CharacterStyle = (ICharacterStyle) Project.Design.FindStyleByName("LabelStyleNotGen", typeof (CharacterStyle));
                rel.LineStyle = (ILineStyle) Project.Design.FindStyleByName("RelNotGenerated", typeof (LineStyle));
            }
            else
            {
                toUpdLabel.CharacterStyle = (ICharacterStyle) Project.Design.FindStyleByName("LabelStyle", typeof (CharacterStyle));
                rel.LineStyle = (ILineStyle) Project.Design.FindStyleByName("RelGenerated", typeof (LineStyle));
            }

            switch (newRel.RelType)
            {
                case DbRelationshipType.OneToOne:
                    toUpdLabel.Text = "<-1...1->";
                    break;
                case DbRelationshipType.ManyToOne:
                    if (tableContainer == null)
                    {
                        toUpdLabel.Text = "--N...1->";
                        break;
                    }

                    var direction = GetLabelDirectionByRelationshipEntities(rel, tableContainer);
                    if (direction == LabelDirection.Left)
                        toUpdLabel.Text = "<-1...N--";
                    else if (direction == LabelDirection.Right)
                        toUpdLabel.Text = "--N...1->";
                    break;
            }
            Repository.Update((Shape) toUpdLabel);
            Repository.Update((Shape) rel);
        }
        public void UpdateRelationshipLine(DbRelationship newRel)
        {
            var toUpdRel = TableDiagram.Shapes.Single(t => (string) t.Tag == String.Format("{0}|{1}R", newRel.OriginalTable, newRel.RefTable));

            switch (newRel.RelType)
            {
                case DbRelationshipType.OneToOne:
                    ((RectangularLine) toUpdRel).StartCapStyle = Project.Design.CapStyles.ClosedArrow;
                    ((RectangularLine) toUpdRel).EndCapStyle = Project.Design.CapStyles.ClosedArrow;
                    break;
                case DbRelationshipType.ManyToOne:
                    ((RectangularLine) toUpdRel).StartCapStyle = Project.Design.CapStyles.None;
                    ((RectangularLine) toUpdRel).EndCapStyle = Project.Design.CapStyles.ClosedArrow;
                    break;
            }
            Repository.Update(toUpdRel);
        }