当前位置: 首页>>代码示例>>C#>>正文


C# ElementAddedEventArgs类代码示例

本文整理汇总了C#中ElementAddedEventArgs的典型用法代码示例。如果您正苦于以下问题:C# ElementAddedEventArgs类的具体用法?C# ElementAddedEventArgs怎么用?C# ElementAddedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ElementAddedEventArgs类属于命名空间,在下文中一共展示了ElementAddedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ElementAdded

        /// <summary>
        ///     Do the following when a new EntityType shape is created:
        ///     - Add the new EntityType to the model
        /// </summary>
        /// <param name="e"></param>
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            base.ElementAdded(e);

            var addedEntity = e.ModelElement as EntityType;
            Debug.Assert(addedEntity != null);
            Debug.Assert(addedEntity.EntityDesignerViewModel != null);

            if ((addedEntity != null)
                && (addedEntity.EntityDesignerViewModel != null))
            {
                var viewModel = addedEntity.EntityDesignerViewModel;
                Debug.Assert(viewModel != null);

                var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store);
                Debug.Assert(tx != null, "Make sure we have a Current Active Tx");
                if (tx != null
                    && !tx.IsSerializing)
                {
                    // Remove the added DSL EntityType.
                    // When Escher model is updated, there will be a code that will create the EntityType back
                    viewModel.EntityTypes.Remove(addedEntity);
                    addedEntity.Delete();

                    // create the model change and add it to the current transaction changelist
                    ViewModelChangeContext.GetNewOrExistingContext(tx).ViewModelChanges.Add(new EntityTypeAdd());
                }
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:34,代码来源:EntityType_AddRule.cs

示例2: ElementAdded

        /// <summary>
        ///     Do the following when a new Association is created:
        ///     - Initialize the "End1" and "End2" properties (displayed on the connector decorators)
        ///     - Set the "Name" property to a sensible default
        ///     - Update the navigation property of the Source and Target entities
        /// </summary>
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            base.ElementAdded(e);

            var addedAssociation = e.ModelElement as Association;

            Debug.Assert(addedAssociation != null);
            Debug.Assert(addedAssociation.SourceEntityType != null);
            Debug.Assert(addedAssociation.TargetEntityType != null);
            Debug.Assert(addedAssociation.SourceEntityType.EntityDesignerViewModel != null);

            if (addedAssociation != null
                && addedAssociation.SourceEntityType != null
                && addedAssociation.TargetEntityType != null
                && addedAssociation.SourceEntityType.EntityDesignerViewModel != null)
            {
                var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store);
                Debug.Assert(tx != null);
                if (tx != null
                    && !tx.IsSerializing)
                {
                    // create the new association
                    ViewModelChangeContext.GetNewOrExistingContext(tx).ViewModelChanges.Add(new AssociationAdd(addedAssociation));
                }
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:32,代码来源:Association_AddRule.cs

示例3: ElementAdded

        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            DomainProperty domainProperty = e.ModelElement as DomainProperty;
            if (domainProperty != null)
            {
                if (domainProperty.Type == null)
                    foreach (DomainType type in domainProperty.Element.ParentModelContext.MetaModel.DomainTypes)
                        if (type.Name == "String")
                        {
                            domainProperty.Type = type;
                            break;
                        }

                if (domainProperty.SerializationName == "")
                {
                    domainProperty.SerializationName = domainProperty.Name;
                    domainProperty.IsSerializationNameTracking = TrackingEnum.IgnoreOnce;
                }
            }
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:31,代码来源:DomainPropertyAddRule.cs

示例4: ElementAdded

        public override void ElementAdded(ElementAddedEventArgs e)
        {
            ShapeElementContainsChildShapes con = e.ModelElement as ShapeElementContainsChildShapes;
            if (con != null)
            {
                NodeShape childShape = con.ChildShape;
                NodeShape parentShape = con.ParentShape;

                if (childShape != null && parentShape != null)
                {
                    if (childShape.IsDeleted)
                        return;
                    if (parentShape.IsDeleted)
                        return;

                    parentShape.AddToShapeMapping(childShape);
                    childShape.UpdateAbsoluteLocation();

                    if (childShape.Location == PointD.Empty)
                        childShape.SetAtFreePositionOnParent();
                }
                else 
                    con.Delete();
            }
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:25,代码来源:ShapeElementContainsChildShapesAddRule.cs

示例5: ElementAdded

        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            GeneratedDomainElement generatedDomainElement = e.ModelElement as GeneratedDomainElement;
            if (generatedDomainElement != null)
            {
                System.Collections.ObjectModel.ReadOnlyCollection<ModelElement> elements = generatedDomainElement.Store.ElementDirectory.FindElements(DomainClass.DomainClassId);
                foreach (ModelElement m in elements)
                    if (m is DomainClass)
                        if ((m as DomainClass).IsDomainModel)
                        {
                            generatedDomainElement.Namespace = (m as DomainClass).Namespace;

                            return;
                        }
            }
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:27,代码来源:GeneratedDomainElementAddRule.cs

示例6: ElementAdded

        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            DomainClass domainClass = e.ModelElement as DomainClass;
            if (domainClass != null)
            {
                if (domainClass.DomainModelTreeNodes.Count == 0)
                {
                    RootNode node = new RootNode(domainClass.Store);
                    node.DomainElement = domainClass;
                    node.IsElementHolder = true;

                    // add to the domain model diagram tree
                    domainClass.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(node);
                    domainClass.ModelContext.ViewContext.DomainModelTreeView.RootNodes.Add(node);
                }
            }
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:28,代码来源:DomainClassAddRule.cs

示例7: OnElementAdded

        /// <summary>
        /// Called whenever a model element is added to the store.
        /// </summary>
        /// <param name="sender">ViewModelStore</param>
        /// <param name="args">Event Arguments for notification of the creation of new model element.</param>
        protected virtual void OnElementAdded(object sender, ElementAddedEventArgs args)
        {
            EventManager.GetEvent<ModelElementAddedEvent>().Publish(args);

            if( args.ModelElement is ElementLink )
                EventManager.GetEvent<ModelElementLinkAddedEvent>().Publish(args);            
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:12,代码来源:ViewModelStore.cs

示例8: ElementAdded

        public override void ElementAdded(ElementAddedEventArgs e)
        {
             if (e.ModelElement != null)
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                        return;

            if (e.ModelElement == null)
                return;

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
                return;

            EnumerationLiteral enumerationLiteral = e.ModelElement as EnumerationLiteral;
            if (enumerationLiteral != null)
            {
                if (enumerationLiteral.DisplayName == "")
                {
                    enumerationLiteral.DisplayName = StringHelper.BreakUpper(enumerationLiteral.Name);
                    enumerationLiteral.IsDisplayNameTracking = TrackingEnum.IgnoreOnce;
                }

                if (enumerationLiteral.SerializationName == "")
                {
                    enumerationLiteral.SerializationName = enumerationLiteral.Name;
                    enumerationLiteral.IsSerializationNameTracking = TrackingEnum.IgnoreOnce;
                }
            }
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:29,代码来源:EnumerationLiteralAddRule.cs

示例9: ElementAdded

        public override void ElementAdded(ElementAddedEventArgs e)
        {
            // if aren't adding a shape, just return
            var addedShape = e.ModelElement as ShapeElement;
            if (addedShape == null)
            {
                return;
            }

            // only layout classes and links
            if (!(addedShape is EntityTypeShape ||
                  addedShape is AssociationConnector ||
                  addedShape is InheritanceConnector))
            {
                return;
            }

            // layout this new shape
            var diagram = addedShape.Diagram as EntityDesignerDiagram;
            if (diagram != null
                && diagram.Arranger != null)
            {
                diagram.Arranger.Add(addedShape, false);
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:25,代码来源:EntityDesignerDiagram_AddRule.cs

示例10: OnElementAdded

        private void OnElementAdded(ElementAddedEventArgs args)
        {
            SpecificDependenciesItemViewModel vm = this.CreateSpecificViewModel(this.ViewModelStore, args.ModelElement);
            this.itemViewModels.Add(vm);

            UpdateIndices();
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:7,代码来源:SpecificDependenciesViewModel.cs

示例11: ElementAdded

		public override void ElementAdded(ElementAddedEventArgs e)
		{
			PrimitiveDataTypeCollection dataContractPrimitiveCollection = e.ModelElement as PrimitiveDataTypeCollection;
			if (dataContractPrimitiveCollection == null)
			{
				return;
			} 

			DataContractModel root = dataContractPrimitiveCollection.DataContractModel;
			if(root != null &&
			   root.ImplementationTechnology != null)
			{
				ExtensionProviderHelper.AttachObjectExtender(dataContractPrimitiveCollection, root.ImplementationTechnology);
			}

			if(string.IsNullOrEmpty(dataContractPrimitiveCollection.ItemType))
			{
				dataContractPrimitiveCollection.ItemType = typeof(string).FullName;
			}

			if (String.IsNullOrEmpty(dataContractPrimitiveCollection.Namespace))
			{
				dataContractPrimitiveCollection.Namespace = ArtifactLinkHelper.DefaultNamespace(e.ModelElement);
			}

			UpdateDataContractCollectionType(dataContractPrimitiveCollection, CollectionTypes.Values[CollectionTypes.ListKey]);
		}
开发者ID:Phidiax,项目名称:open-wssf-2015,代码行数:27,代码来源:PrimitiveDataTypeCollectionAddRule.cs

示例12: ElementAdded

        /// <summary>
        /// Triggers this notification rule whether a <see cref="ElementSchema"/> is added.
        /// </summary>
        /// <param name="e">The provided data for this event.</param>
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            Guard.NotNull(() => e, e);

            var element = (ExtensionPointSchema)e.ModelElement;

            if (!element.Store.TransactionManager.CurrentTransaction.IsSerializing)
            {
                if (element.Owner == null)
                {
                    var relationship = (ViewHasExtensionPoints)DomainRelationshipInfo.FindEmbeddingElementLink(element);

                    if (relationship != null)
                    {
                        relationship.WithTransaction(r =>
                        {
                            r.Cardinality = Runtime.Cardinality.ZeroToMany;
                        });
                    }
                }
                else
                {
                    var relationship = (ElementHasExtensionPoints)DomainRelationshipInfo.FindEmbeddingElementLink(element);

                    if (relationship != null)
                    {
                        relationship.WithTransaction(r =>
                        {
                            r.Cardinality = Runtime.Cardinality.ZeroToMany;
                        });
                    }
                }
            }
        }
开发者ID:StevenVanDijk,项目名称:NuPattern,代码行数:38,代码来源:ExtensionPointSchemaAddRule.cs

示例13: ElementAdded

        /// <summary>
        /// Triggers this notification rule whether a <see cref="AbstractElement"/> is added.
        /// </summary>
        /// <param name="e">The provided data for this event.</param>
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            Guard.NotNull(() => e, e);

            var element = (AbstractElement)e.ModelElement;

            var info = FindInfo(element);
            if (info != null)
            {
                element.Info = info;

                if (string.IsNullOrEmpty(element.InstanceName))
                {
                    element.InstanceName = info.DisplayName;
                }

                element.SyncPropertiesFrom(info.Properties);
                element.SyncElementsFrom(info.Elements);

                var patternManager = element.Store.GetService<IPatternManager>();
                if (patternManager != null)
                {
                    element.SyncExtensionPointsFrom(info.ExtensionPoints, patternManager);
                }
            }
            else
            {
                tracer.Warn(Resources.TracerWarning_ElementInfoNotFound, element.Id);
            }
        }
开发者ID:StevenVanDijk,项目名称:NuPattern,代码行数:34,代码来源:AbstractElementAddRule.cs

示例14: ElementAdded

        /// <summary>
        /// This method is called when the rule is fired, that is when a new connection is added to the model.
        /// </summary>
        /// <param name="e">the ElementAddedEventArgs</param>
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            BinaryLinkShape c = e.ModelElement as BinaryLinkShape;
            if (c == null)
                return;

            CompartmentMappingUtil.RerouteCompartmentMappings(c);
        }
开发者ID:thabart,项目名称:SimpleOrm,代码行数:12,代码来源:CompartmentMappingAddRuleBase.cs

示例15: ElementAdded

 public override void ElementAdded(ElementAddedEventArgs e)
 {
     NodeShape nodeShape = e.ModelElement as NodeShape;
     if (nodeShape != null)
     {
         //nodeShape.FixUpMissingLinkShapes();
     }
 }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:8,代码来源:NodeShapeAddedRule.cs


注:本文中的ElementAddedEventArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。