예제 #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);
        }
예제 #2
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);
        }
예제 #3
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;
        }