예제 #1
0
 public EntityTypeDesigner(UIEntityType entityType)
     : base(entityType)
 {
     EntityType = entityType;
     entityType.BaseTypeChanged +=
         () =>
         {
             if (EntityType.BusinessInstance.BaseType == null)
                 DeleteBaseInheritanceRelation();
             else if (_baseRelationContener == null)
                 DrawBaseInheritanceRelation();
         };
     entityTypeExpander.SetBinding(OpacityProperty, new Binding("IsCompletlyMapped") { Source = ((EntityType)UIType.BusinessInstance).Mapping, Converter = new BoolToOpacityConverter(), ConverterParameter = 0.75 });
 }
예제 #2
0
 public EntityTypeDesigner(UIEntityType entityType)
     : base(entityType)
 {
     EntityType = entityType;
     entityType.BaseTypeChanged +=
         () =>
     {
         if (EntityType.BusinessInstance.BaseType == null)
         {
             DeleteBaseInheritanceRelation();
         }
         else if (_baseRelationContener == null)
         {
             DrawBaseInheritanceRelation();
         }
     };
     entityTypeExpander.SetBinding(OpacityProperty, new Binding("IsCompletlyMapped")
     {
         Source = ((EntityType)UIType.BusinessInstance).Mapping, Converter = new BoolToOpacityConverter(), ConverterParameter = 0.75
     });
 }
예제 #3
0
 public UIEntityType AddEntityType(string entityTypeName, UIEntityType baseType)
 {
     return(EntityTypes[CSDL.AddEntityType(entityTypeName, baseType != null ? null : string.Concat(entityTypeName, "Set"), baseType == null ? null : baseType.BusinessInstance)]);
 }
예제 #4
0
 public void AddType(UIEntityType uiEntityType, Point position)
 {
     AddType(new EntityTypeDesigner(uiEntityType), position, uiEntityType);
 }
예제 #5
0
        public UIAssociation AddAssociation(string associationName, string navigationProperty1Name, UIEntityType navigationProperty1EntityType, Cardinality navigationProperty1Cardinality, string navigationProperty2Name, UIEntityType navigationProperty2EntityType, Cardinality navigationProperty2Cardinality)
        {
            var association = CSDL.AddAssociation(associationName, navigationProperty1Name, navigationProperty1EntityType.BusinessInstance, navigationProperty1Cardinality, navigationProperty2Name, navigationProperty2EntityType.BusinessInstance, navigationProperty2Cardinality);

            return(new UIAssociation {
                NavigationProperty1 = navigationProperty1EntityType.Properties[association.PropertyEnd1] as UIRelatedProperty, NavigationProperty2 = navigationProperty2EntityType.Properties[association.PropertyEnd2] as UIRelatedProperty
            });
        }
 public static ExecutedRoutedEventHandler AddAssociationExecuted(UIElement parent, Func<CSDLView> getCSDLView, Func<DesignerView> getDesignerView, UIEntityType defaultEntityType1, Action<UIAssociation> specialActionToDoWhenNewItemAdded)
 {
     return (object sender, ExecutedRoutedEventArgs e) =>
      {
          var csdlView = getCSDLView();
          var designerView = getDesignerView();
          var addAssociationWindow = new AddAssociationWindow { Owner = VisualTreeHelperUtil.GetControlAscendant<Window>(parent), DataContext = csdlView, NavigationProperty1EntityType = defaultEntityType1 };
          switch (addAssociationWindow.ShowDialog())
          {
              case true:
                  var uiAssociation = csdlView.AddAssociation(addAssociationWindow.AssociationName, addAssociationWindow.NavigationProperty1Name, addAssociationWindow.NavigationProperty1EntityType, addAssociationWindow.NavigationProperty1Cardinality.Value, addAssociationWindow.NavigationProperty2Name, addAssociationWindow.NavigationProperty2EntityType, addAssociationWindow.NavigationProperty2Cardinality.Value);
                  SizeChangedEventHandler actionToDoWhenNewItemAdded = null;
                  bool drawAssociation = false;
                  DesignerCanvas designerCanvas = parent as DesignerCanvas;
                  if (designerCanvas == null)
                      designerCanvas = VisualTreeHelperUtil.GetControlAscendant<DesignerCanvas>(parent);
                  var navigationProperty1EntityTypeDesigner = designerCanvas.GetTypeDesigner(uiAssociation.NavigationProperty1.ParentType);
                  var navigationProperty2EntityTypeDesigner = designerCanvas.GetTypeDesigner(uiAssociation.NavigationProperty2.ParentType);
                  actionToDoWhenNewItemAdded =
                      (object o, SizeChangedEventArgs scea) =>
                      {
                          if (designerView.ContainsEntityType(uiAssociation.NavigationProperty1.ParentType) && designerView.ContainsEntityType(uiAssociation.NavigationProperty2.ParentType))
                          {
                              if (drawAssociation)
                                  navigationProperty1EntityTypeDesigner.DrawAssociation(navigationProperty2EntityTypeDesigner, uiAssociation.NavigationProperty1.BusinessInstance as NavigationProperty);
                              else
                                  drawAssociation = true;
                          }
                          if (specialActionToDoWhenNewItemAdded != null)
                              specialActionToDoWhenNewItemAdded(uiAssociation);
                          ((ListView)o).SizeChanged -= actionToDoWhenNewItemAdded;
                      };
                  navigationProperty1EntityTypeDesigner.propertiesListView.SizeChanged += actionToDoWhenNewItemAdded;
                  if (navigationProperty2EntityTypeDesigner != null)
                      navigationProperty2EntityTypeDesigner.propertiesListView.SizeChanged += actionToDoWhenNewItemAdded;
                  break;
          }
      };
 }
 public static ExecutedRoutedEventHandler AddAssociationExecuted(UIElement parent, Func <CSDLView> getCSDLView, Func <DesignerView> getDesignerView, UIEntityType defaultEntityType1, Action <UIAssociation> specialActionToDoWhenNewItemAdded)
 {
     return((object sender, ExecutedRoutedEventArgs e) =>
     {
         var csdlView = getCSDLView();
         var designerView = getDesignerView();
         var addAssociationWindow = new AddAssociationWindow {
             Owner = VisualTreeHelperUtil.GetControlAscendant <Window>(parent), DataContext = csdlView, NavigationProperty1EntityType = defaultEntityType1
         };
         switch (addAssociationWindow.ShowDialog())
         {
         case true:
             var uiAssociation = csdlView.AddAssociation(addAssociationWindow.AssociationName, addAssociationWindow.NavigationProperty1Name, addAssociationWindow.NavigationProperty1EntityType, addAssociationWindow.NavigationProperty1Cardinality.Value, addAssociationWindow.NavigationProperty2Name, addAssociationWindow.NavigationProperty2EntityType, addAssociationWindow.NavigationProperty2Cardinality.Value);
             SizeChangedEventHandler actionToDoWhenNewItemAdded = null;
             bool drawAssociation = false;
             DesignerCanvas designerCanvas = parent as DesignerCanvas;
             if (designerCanvas == null)
             {
                 designerCanvas = VisualTreeHelperUtil.GetControlAscendant <DesignerCanvas>(parent);
             }
             var navigationProperty1EntityTypeDesigner = designerCanvas.GetTypeDesigner(uiAssociation.NavigationProperty1.ParentType);
             var navigationProperty2EntityTypeDesigner = designerCanvas.GetTypeDesigner(uiAssociation.NavigationProperty2.ParentType);
             actionToDoWhenNewItemAdded =
                 (object o, SizeChangedEventArgs scea) =>
             {
                 if (designerView.ContainsEntityType(uiAssociation.NavigationProperty1.ParentType) && designerView.ContainsEntityType(uiAssociation.NavigationProperty2.ParentType))
                 {
                     if (drawAssociation)
                     {
                         navigationProperty1EntityTypeDesigner.DrawAssociation(navigationProperty2EntityTypeDesigner, uiAssociation.NavigationProperty1.BusinessInstance as NavigationProperty);
                     }
                     else
                     {
                         drawAssociation = true;
                     }
                 }
                 if (specialActionToDoWhenNewItemAdded != null)
                 {
                     specialActionToDoWhenNewItemAdded(uiAssociation);
                 }
                 ((ListView)o).SizeChanged -= actionToDoWhenNewItemAdded;
             };
             navigationProperty1EntityTypeDesigner.propertiesListView.SizeChanged += actionToDoWhenNewItemAdded;
             if (navigationProperty2EntityTypeDesigner != null)
             {
                 navigationProperty2EntityTypeDesigner.propertiesListView.SizeChanged += actionToDoWhenNewItemAdded;
             }
             break;
         }
     });
 }
예제 #8
0
 public void AddType(UIEntityType uiEntityType, Point position)
 {
     AddType(new EntityTypeDesigner(uiEntityType), position, uiEntityType);
 }
예제 #9
0
 public UIEntityType AddEntityType(string entityTypeName, UIEntityType baseType)
 {
     return EntityTypes[CSDL.AddEntityType(entityTypeName, baseType != null ? null : string.Concat(entityTypeName, "Set"), baseType == null ? null : baseType.BusinessInstance)];
 }
예제 #10
0
 public UIAssociation AddAssociation(string associationName, string navigationProperty1Name, UIEntityType navigationProperty1EntityType, Cardinality navigationProperty1Cardinality, string navigationProperty2Name, UIEntityType navigationProperty2EntityType, Cardinality navigationProperty2Cardinality)
 {
     var association = CSDL.AddAssociation(associationName, navigationProperty1Name, navigationProperty1EntityType.BusinessInstance, navigationProperty1Cardinality, navigationProperty2Name, navigationProperty2EntityType.BusinessInstance, navigationProperty2Cardinality);
     return new UIAssociation { NavigationProperty1 = navigationProperty1EntityType.Properties[association.PropertyEnd1] as UIRelatedProperty, NavigationProperty2 = navigationProperty2EntityType.Properties[association.PropertyEnd2] as UIRelatedProperty };
 }