Example #1
0
        private RelationContener DrawInheritanceRelation(EntityTypeDesigner baseTypeDesigner, EntityTypeDesigner childTypeDesigner)
        {
            var relationContener = (from rc in Designer.Children.OfType <RelationContener>()
                                    let ir = rc.Content as InheritanceRelation
                                             where ir != null && ir.FromTypeDesigner == childTypeDesigner && ir.ToTypeDesigner == baseTypeDesigner
                                             select rc).FirstOrDefault();

            if (relationContener != null)
            {
                return(relationContener);
            }
            var inheritanceRelation = new InheritanceRelation(Designer, childTypeDesigner, baseTypeDesigner, () => Designer.Children.OfType <EntityTypeDesigner>().FirstOrDefault(etd => etd.EntityType.BusinessInstance == EntityType.BusinessInstance.BaseType));

            relationContener = new RelationContener(inheritanceRelation);
            Designer.Children.Add(relationContener);
            relationContener.SetBinding(Canvas.LeftProperty, new Binding {
                Source = inheritanceRelation, Path = new PropertyPath("CanvasLeft")
            });
            relationContener.SetBinding(Canvas.TopProperty, new Binding {
                Source = inheritanceRelation, Path = new PropertyPath("CanvasTop")
            });
            baseTypeDesigner.AddRelationContenerWithoutRelatedProperty(relationContener);
            childTypeDesigner.AddRelationContenerWithoutRelatedProperty(relationContener);
            return(relationContener);
        }
Example #2
0
 protected void AddRelationContenerWithoutRelatedProperty(RelationContener relationContener)
 {
     if (!(relationContener == null || RelationsContenerWithoutRelatedProperty.Contains(relationContener)))
     {
         RelationsContenerWithoutRelatedProperty.Add(relationContener);
         relationContener.Removed += () => RelationsContenerWithoutRelatedProperty.Remove(relationContener);
     }
 }
Example #3
0
 public void DeleteBaseInheritanceRelation()
 {
     if (_baseRelationContener != null)
     {
         Designer.Children.Remove(_baseRelationContener);
         _baseRelationContener = null;
     }
 }
Example #4
0
        protected void AddRelationContenerByRelatedProperty(UIProperty uiProperty, RelationContener relationContener)
        {
            var uiRelatedProperty = uiProperty as UIRelatedProperty;

            if (!(uiRelatedProperty == null || RelationsContenerByRelatedProperty.ContainsKey(uiRelatedProperty)))
            {
                RelationsContenerByRelatedProperty.Add(uiRelatedProperty, relationContener);
                relationContener.Removed += () => RelationsContenerByRelatedProperty.Remove(uiRelatedProperty);
            }
        }
Example #5
0
        private void DrawBaseInheritanceRelation()
        {
            var baseEntityTypeDesigner = Designer.Children.OfType <EntityTypeDesigner>().FirstOrDefault(etd => etd.EntityType.BusinessInstance == EntityType.BusinessInstance.BaseType);

            if (baseEntityTypeDesigner == null)
            {
                _baseRelationContener = null;
            }
            else
            {
                _baseRelationContener = DrawInheritanceRelation(baseEntityTypeDesigner, this);
            }
        }
Example #6
0
        internal void DrawComplexPropertyRelation(TypeBaseDesigner otherTypeDesigner, UIRelatedProperty relatedProperty)
        {
            if (RelationsContenerByRelatedProperty.ContainsKey(relatedProperty) || otherTypeDesigner.RelationsContenerByRelatedProperty.ContainsKey(relatedProperty))
            {
                return;
            }
            var complexProperty = (ComplexProperty)relatedProperty.BusinessInstance;
            int typeDesignerItemIndex;
            var complexPropertyRelation = new ComplexPropertyRelation(Designer, this, otherTypeDesigner, GetListViewItem(complexProperty, out typeDesignerItemIndex), typeDesignerItemIndex);
            var relationContener        = new RelationContener(complexPropertyRelation);

            Designer.Children.Add(relationContener);
            relationContener.SetBinding(Canvas.LeftProperty, new Binding {
                Source = complexPropertyRelation, Path = new PropertyPath("CanvasLeft")
            });
            relationContener.SetBinding(Canvas.TopProperty, new Binding {
                Source = complexPropertyRelation, Path = new PropertyPath("CanvasTop")
            });
            AddRelationContenerByRelatedProperty(UIType.Properties[complexProperty], relationContener);
            otherTypeDesigner.AddRelationContenerWithoutRelatedProperty(relationContener);
        }
Example #7
0
        internal void DrawAssociation(TypeBaseDesigner otherTypeDesigner, NavigationProperty navigationProperty)
        {
            var csdlAssociation = navigationProperty.Association;
            int otherTypeDesignerItemIndex;
            var otherNavigationProperty = csdlAssociation.PropertiesEnd.First(np => np != navigationProperty);
            var otherListViewItem       = otherTypeDesigner.GetListViewItem(otherNavigationProperty, out otherTypeDesignerItemIndex);
            int typeDesignerItemIndex;
            var typeDesignerListViewItem = GetListViewItem(navigationProperty, out typeDesignerItemIndex);

            ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Relations.Association association;
            if (csdlAssociation.PropertyEnd1 == navigationProperty)
            {
                association = new ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Relations.Association(csdlAssociation, Designer, this, otherTypeDesigner, typeDesignerListViewItem, otherListViewItem, typeDesignerItemIndex, otherTypeDesignerItemIndex);
            }
            else
            {
                association = new ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Relations.Association(csdlAssociation, Designer, otherTypeDesigner, this, otherListViewItem, typeDesignerListViewItem, otherTypeDesignerItemIndex, typeDesignerItemIndex);
            }
            var relationContener = new RelationContener(association);

            Designer.Children.Add(relationContener);
            relationContener.SetBinding(Canvas.LeftProperty, new Binding {
                Source = association, Path = new PropertyPath("CanvasLeft")
            });
            relationContener.SetBinding(Canvas.TopProperty, new Binding {
                Source = association, Path = new PropertyPath("CanvasTop")
            });
            AddRelationContenerByRelatedProperty(UIType.Properties[navigationProperty], relationContener);
            otherTypeDesigner.AddRelationContenerByRelatedProperty(otherTypeDesigner.UIType.Properties[otherNavigationProperty], relationContener);
            NotifyCollectionChangedEventHandler mappingCollectionChanged = delegate
            {
                VisualTreeHelperUtil.GetControlsDecendant <EditableTextBlock>(otherListViewItem).First().GetBindingExpression(EditableTextBlock.OpacityProperty).UpdateTarget();
                VisualTreeHelperUtil.GetControlsDecendant <EditableTextBlock>(typeDesignerListViewItem).First().GetBindingExpression(EditableTextBlock.OpacityProperty).UpdateTarget();
            };

            csdlAssociation.PropertyEnd1.Mapping.CollectionChanged += mappingCollectionChanged;
            csdlAssociation.PropertyEnd2.Mapping.CollectionChanged += mappingCollectionChanged;
        }