Ejemplo n.º 1
0
        /// <summary>
        /// Finalize. This method is called on each copied element once all the elements and links are processed.
        /// </summary>
        /// <param name="protoElement">Proto element representation of the element that is to be added.</param>
        /// <param name="groupMerger">
        /// Group merger class used to track id mapping, merge errors/warnings and
        /// postprocess merging by rebuilding reference relationships.
        /// </param>
        public virtual void ModelFinalize(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger)
        {
            if (protoElement.CustomArguments is DiagramModelMergeOptions)
            {
                DiagramModelMergeOptions options = protoElement.CustomArguments as DiagramModelMergeOptions;
                Guid elementID             = options.ElementId;
                ModelProtoElement elementP = groupMerger.GetElementById(elementID);
                if (elementP != null)
                {
                    (this.Element as IModelMergeElements).ModelFinalize(elementP, groupMerger);
                }

                NodeShape shape = this.Store.ElementDirectory.FindElement(
                    groupMerger.GetIdMapping(protoElement.ElementId)) as NodeShape;

                // restore layout
                Store store = new Microsoft.VisualStudio.Modeling.Store(typeof(DiagramsDSLDomainModel));

                LayoutInfo info;
                using (Transaction t = store.TransactionManager.BeginTransaction())
                {
                    info = options.GetLayoutInfo(store);
                    t.Commit();
                }
                LayoutHelper.ApplyLayout(this, this.Diagram, info);
                store.Dispose();

                if (!shape.IsRelativeChildShape)
                {
                    shape.SetLocation(new PointD(RelativePastePoint.X + options.RelativeLocation.X,
                                                 RelativePastePoint.Y + options.RelativeLocation.Y));
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a proto element to the current element.
        /// </summary>
        /// <param name="protoElement">Proto element representation of the element that is to be added.</param>
        /// <param name="groupMerger">
        /// Group merger class used to track id mapping, merge errors/warnings and
        /// postprocess merging by rebuilding reference relationships.
        /// </param>
        /// <param name="isRoot">Root element?</param>
        public virtual void ModelMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger, bool isRoot)
        {
            if (protoElement.CustomArguments is DiagramModelMergeOptions)
            {
                DiagramModelMergeOptions options = protoElement.CustomArguments as DiagramModelMergeOptions;

                Guid elementID             = options.ElementId;
                ModelProtoElement elementP = groupMerger.GetElementById(elementID);
                if (elementP != null)
                {
                    (this.Element as IModelMergeElements).ModelMerge(elementP, groupMerger, isRoot);
                }

                ModelElement copiedElement = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(options.ElementId));

                // create shape for that element
                this.FixUpMissingShapes();

                NodeShape shape = DiagramHelper.FindShape(this.Store, options.ShapeDomainClassId, copiedElement.Id) as NodeShape;
                if (shape != null)
                {
                    groupMerger.SetIdMapping(protoElement.ElementId, shape.Id);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Finalize. This method is called on each copied element once all the elements and links are processed.
        /// </summary>
        /// <param name="protoElement">Proto element representation of the element that is to be added.</param>
        /// <param name="groupMerger">
        /// Group merger class used to track id mapping, merge errors/warnings and 
        /// postprocess merging by rebuilding reference relationships.
        /// </param>
        public virtual void ModelFinalize(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger)
        {
            if (protoElement.CustomArguments is DiagramModelMergeOptions)
            {
                DiagramModelMergeOptions options = protoElement.CustomArguments as DiagramModelMergeOptions;
                Guid elementID = options.ElementId;
                ModelProtoElement elementP = groupMerger.GetElementById(elementID);
                if (elementP != null)
                {
                    (this.Element as IModelMergeElements).ModelFinalize(elementP, groupMerger);
                }

                NodeShape shape = this.Store.ElementDirectory.FindElement(
                    groupMerger.GetIdMapping(protoElement.ElementId)) as NodeShape;

                // restore layout
                Store store = new Microsoft.VisualStudio.Modeling.Store(typeof(DiagramsDSLDomainModel));
                
                LayoutInfo info;
                using (Transaction t = store.TransactionManager.BeginTransaction())
                {
                    info = options.GetLayoutInfo(store);
                    t.Commit();
                }
                LayoutHelper.ApplyLayout(this, this.Diagram, info);
                store.Dispose();

                if (!shape.IsRelativeChildShape)
                {
                    shape.SetLocation(new PointD(RelativePastePoint.X + options.RelativeLocation.X,
                            RelativePastePoint.Y + options.RelativeLocation.Y));
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds a proto element to the current element.
        /// </summary>
        /// <param name="protoElement">Proto element representation of the element that is to be added.</param>
        /// <param name="groupMerger">
        /// Group merger class used to track id mapping, merge errors/warnings and 
        /// postprocess merging by rebuilding reference relationships.
        /// </param>
        /// <param name="isRoot">Root element?</param>
        public virtual void ModelMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger, bool isRoot)
        {
            if (protoElement.CustomArguments is DiagramModelMergeOptions)
            {
                DiagramModelMergeOptions options = protoElement.CustomArguments as DiagramModelMergeOptions;
                
                Guid elementID = options.ElementId;
                ModelProtoElement elementP = groupMerger.GetElementById(elementID);
                if (elementP != null)
                {
                    (this.Element as IModelMergeElements).ModelMerge(elementP, groupMerger, isRoot);
                }

                ModelElement copiedElement = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(options.ElementId));
                
                // create shape for that element
                this.FixUpMissingShapes();

                NodeShape shape = DiagramHelper.FindShape(this.Store, options.ShapeDomainClassId, copiedElement.Id) as NodeShape;
                if (shape != null)
                {
                    groupMerger.SetIdMapping(protoElement.ElementId, shape.Id);
                }
            }
        }