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; }
private static VerticalAlignment FourPointsVerticalAlignement(Association association) { switch (Compare(association.Y4, association.Y3)) { case -1: return VerticalAlignment.Bottom; case 0: case 1: return VerticalAlignment.Top; default: throw new NotImplementedException(); } }
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; }
private static HorizontalAlignment FourPointsHorizontalAlignement(Association association) { switch (Compare(association.X4, association.X3)) { case -1: return HorizontalAlignment.Right; case 0: case 1: return HorizontalAlignment.Left; default: throw new NotImplementedException(); } }