コード例 #1
0
        private static void ProcessDiagramsLinkShapes(Diagram diagram, List<NodeShape> allShapes, LayoutInfo info)
        {
            foreach (LinkShape shape in diagram.LinkShapes)
            {
                if (allShapes.Contains(shape.FromShape) &&
                    allShapes.Contains(shape.ToShape))
                {
                    LinkShapeInfo lInfo = new LinkShapeInfo(info.Store);
                    lInfo.ElementId = shape.Element.Id;
                    lInfo.SourceElementId = shape.FromShape.Element.Id;
                    lInfo.TargetElementId = shape.ToShape.Element.Id;
                    lInfo.LinkDomainClassId = shape.Element.GetDomainClass().Id;

                    lInfo.SourceLocation = shape.SourceAnchor.GetRelativeLocation();
                    lInfo.TargetLocation = shape.TargetAnchor.GetRelativeLocation();

                    lInfo.RoutingMode = shape.RoutingMode;
                    lInfo.EdgePoints = ConvertToRelativeEdgePoints(shape.EdgePoints, shape.SourceAnchor.AbsoluteLocation);

                    info.LinkShapeInfos.Add(lInfo);
                }
            }

            foreach (Diagram d in diagram.IncludedDiagrams)
                ProcessDiagramsLinkShapes(d, allShapes, info);
        }
コード例 #2
0
        /// <summary>
        /// Adds an included diagram to this diagram.
        /// </summary>
        /// <param name="diagram">Included diagram.</param>
        public virtual void AddIncludedDiagram(Diagram diagram)
        {
            bool bFound = false;
            foreach (Diagram d in this.IncludedDiagrams)
                if (d.UniqueName == diagram.UniqueName)
                {
                    bFound = true;
                    break;
                }

            if (!bFound)
                this.IncludedDiagrams.Add(diagram);
        }
コード例 #3
0
        public static LayoutInfo CreateLayoutInfo(NodeShape shapeElement, Diagram diagram)
        {
            // create new layout
            List<NodeShape> allShapes = new List<NodeShape>();
            LayoutInfo l = new LayoutInfo(shapeElement.Store);
            l.HostElementId = shapeElement.Element.Id;
            l.Size = shapeElement.Size;

            foreach (NodeShape shape in shapeElement.Children)
            {
                allShapes.Add(shape);
                l.ChildrenInfos.Add(CreateNodeShapeInfo(shape, allShapes));
            }

            ProcessDiagramsLinkShapes(diagram, allShapes, l);
            return l;
        }
コード例 #4
0
        public static void SaveLayout(NodeShape shapeElement, Diagram diagram)
        {
            DiagramsModel model = GetDiagramsModel(shapeElement);
            
            // see if there is already a layout for the given shape element
            foreach (LayoutInfo layout in model.LayoutInfos)
                if (layout.HostElementId == shapeElement.Element.Id)
                {
                    // delete existing layout
                    model.LayoutInfos.Remove(layout);
                    break;
                }

            // create new layout
            List<NodeShape> allShapes = new List<NodeShape>();
            LayoutInfo l = CreateLayoutInfo(shapeElement, diagram);

            model.LayoutInfos.Add(l);
        }
コード例 #5
0
		/// <summary>
		/// Constructor
		/// Creates a DiagramsModelHasDiagrams link in the same Partition as the given DiagramsModel
		/// </summary>
		/// <param name="source">DiagramsModel to use as the source of the relationship.</param>
		/// <param name="target">Diagram to use as the target of the relationship.</param>
		public DiagramsModelHasDiagrams(DiagramsModel source, Diagram target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(DiagramsModelHasDiagrams.DiagramsModelDomainRoleId, source), new DslModeling::RoleAssignment(DiagramsModelHasDiagrams.DiagramDomainRoleId, target)}, null)
		{
		}
コード例 #6
0
		public static DslModeling::LinkedElementCollection<LinkShape> GetLinkShapes(Diagram element)
		{
			return GetRoleCollection<DslModeling::LinkedElementCollection<LinkShape>, LinkShape>(element, DiagramDomainRoleId);
		}
コード例 #7
0
		/// <summary>
		/// Constructor
		/// Creates a DiagramHasLinkShapes link in the same Partition as the given Diagram
		/// </summary>
		/// <param name="source">Diagram to use as the source of the relationship.</param>
		/// <param name="target">LinkShape to use as the target of the relationship.</param>
		public DiagramHasLinkShapes(Diagram source, LinkShape target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(DiagramHasLinkShapes.DiagramDomainRoleId, source), new DslModeling::RoleAssignment(DiagramHasLinkShapes.LinkShapeDomainRoleId, target)}, null)
		{
		}
コード例 #8
0
        public static void Layout(Diagram diagram)
        {
            TreeNode rootNode = new TreeNode(null);
            Dictionary<Guid, TreeNode> dict = new Dictionary<Guid, TreeNode>();
            List<Guid> shapesNotLinked = new List<Guid>();
            List<TreeNode> shapesCandidatesForRemoval = new List<TreeNode>();

            // create tree nodes
            foreach (NodeShape shape in diagram.Children)
            {
                if (shape.IsDeleting || shape.IsDeleted)
                    continue;

                dict.Add(shape.Id, new TreeNode(shape));
                shapesNotLinked.Add(shape.Id);
            }

            // create tree model
            foreach (LinkShape shape in diagram.LinkShapes)
            {
                if (shape.IsDeleting || shape.IsDeleted)
                    continue;

                NodeShape source = shape.SourceAnchor.FromShape;
                NodeShape target = shape.TargetAnchor.ToShape;
                
                if (source.IsDeleting || source.IsDeleted)
                    continue;

                if (target.IsDeleting || target.IsDeleted)
                    continue;

                // set siblings
                if (shape is MarriedToShape)
                {
                    dict[source.Id].Sibling = dict[target.Id];
                    dict[target.Id].Sibling = dict[source.Id];

                    //shapesNotLinked.Remove(target.Id);
                    shapesCandidatesForRemoval.Add(dict[source.Id]);
                }
            }

            foreach (LinkShape shape in diagram.LinkShapes)
            {
                if (shape.IsDeleting || shape.IsDeleted)
                    continue;

                NodeShape source = shape.SourceAnchor.FromShape;
                NodeShape target = shape.TargetAnchor.ToShape;

                if (source.IsDeleting || source.IsDeleted)
                    continue;

                if (target.IsDeleting || target.IsDeleted)
                    continue;

                // set parent-child mappings
                if (shape is ParentOfShape)
                {
                    shapesNotLinked.Remove(target.Id);

                    if (dict[target.Id].Parents.Count > 0)
                        continue;

                    dict[target.Id].Parents.Add(dict[source.Id]);
                    dict[source.Id].Children.Add(dict[target.Id]);
                    TreeNode s = dict[source.Id].Sibling;
                    if (s != null)
                    {
                        dict[target.Id].Parents.Add(s);
                        if (!s.Children.Contains(dict[target.Id]))
                            s.Children.Add(dict[target.Id]);
                    }
                }
            }

            foreach (TreeNode n in shapesCandidatesForRemoval)
            {
                if (n.Parents.Count > 0)
                {
                    shapesNotLinked.Remove(n.Shape.Id);
                    if( n.Sibling != null )
                        shapesNotLinked.Remove(n.Sibling.Shape.Id);
                }
                else if (n.Sibling != null)
                {
                    if (n.Sibling.Parents.Count > 0)
                    {
                        shapesNotLinked.Remove(n.Shape.Id);
                        shapesNotLinked.Remove(n.Sibling.Shape.Id);
                    }
                    else
                    {
                        shapesNotLinked.Remove(n.Sibling.Shape.Id);
                        if( !shapesNotLinked.Contains(n.Shape.Id) )
                            shapesNotLinked.Add(n.Shape.Id);
                    }
                }

            }

            foreach(Guid shapeId in shapesNotLinked )
                rootNode.Children.Add(dict[shapeId]);

            // layout tree model
            LayoutChildrenFirstPass(rootNode);
            LayoutChildrenSecondPass(rootNode, MarginRoot, MarginRoot);
            LayoutChildrenThirdPass(rootNode);

            foreach (LinkShape shape in diagram.LinkShapes)
            {
                if (shape.IsDeleting || shape.IsDeleted)
                    continue;

                NodeShape source = shape.SourceAnchor.FromShape;
                NodeShape target = shape.TargetAnchor.ToShape;

                if (source.IsDeleting || source.IsDeleted)
                    continue;

                if (target.IsDeleting || target.IsDeleted)
                    continue;

                shape.Layout(FixedGeometryPoints.None);
            }
        }
コード例 #9
0
		public static void SetDiagram(LinkShape element, Diagram newDiagram)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, LinkShapeDomainRoleId, newDiagram);
		}
コード例 #10
0
        private static void RestoreLinkShapes(Diagram diagram, LinkedElementCollection<LinkShapeInfo> infos)
        {                   
            // links
            List<LinkShape> newShapes = new List<LinkShape>();
            foreach (LinkShape shape in diagram.LinkShapes)
            {
                if (!ProcessLinkShape(shape, infos))
                    newShapes.Add(shape);
            }

            foreach (Diagram d in diagram.IncludedDiagrams)
                RestoreLinkShapes(d, infos);

            // update layout of new link shapes
            foreach (LinkShape linkShape in newShapes)
            {
                linkShape.Layout(FixedGeometryPoints.None);

                linkShape.SourceAnchor.DiscardLocationChange = false;
                linkShape.TargetAnchor.DiscardLocationChange = false;
            }
        }
コード例 #11
0
		/// <summary>
		/// This method deserializes all child model elements.
		/// </summary>
		/// <remarks>
		/// The caller will position the reader at the open tag of the first child XML element to deserialized.
		/// This method will read as many child elements as it can. It returns under three circumstances:
		/// 1) When an unknown child XML element is encountered. In this case, this method will position the reader at the 
		///    open tag of the unknown element. This implies that if the first child XML element is unknown, this method 
		///    should return immediately and do nothing.
		/// 2) When all child XML elemnets are read. In this case, the reader will be positioned at the end tag of the parent element.
		/// 3) EOF.
		/// </remarks>
		/// <param name="serializationContext">Serialization context.</param>
		/// <param name="reader">XmlReader to read serialized data from.</param>
		/// <param name="element">In-memory Diagram instance that will get the deserialized data.</param>
		private static void ReadChildElements(DslModeling::SerializationContext serializationContext, Diagram element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				switch (reader.LocalName)
				{
					case "children":	// Relationship "DiagramHasChildren"
						if (reader.IsEmptyElement)
						{	// No instance of this relationship, just skip
							DslModeling::SerializationUtilities.Skip(reader);
						}
						else
						{
							DslModeling::SerializationUtilities.SkipToFirstChild(reader);  // Skip the open tag of <children>
							ReadDiagramHasChildrenInstances(serializationContext, element, reader);
							DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </children>
						}
						break;
					case "linkShapes":	// Relationship "DiagramHasLinkShapes"
						if (reader.IsEmptyElement)
						{	// No instance of this relationship, just skip
							DslModeling::SerializationUtilities.Skip(reader);
						}
						else
						{
							DslModeling::SerializationUtilities.SkipToFirstChild(reader);  // Skip the open tag of <linkShapes>
							ReadDiagramHasLinkShapesInstances(serializationContext, element, reader);
							DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </linkShapes>
						}
						break;
					case "includedDiagrams":	// Relationship "DiagramHasIncludedDiagrams"
						if (reader.IsEmptyElement)
						{	// No instance of this relationship, just skip
							DslModeling::SerializationUtilities.Skip(reader);
						}
						else
						{
							DslModeling::SerializationUtilities.SkipToFirstChild(reader);  // Skip the open tag of <includedDiagrams>
							ReadDiagramHasIncludedDiagramsInstances(serializationContext, element, reader);
							DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </includedDiagrams>
						}
						break;
					default:
						return;  // Don't know this element.
				}
			}
		}
コード例 #12
0
 /// <summary>
 /// Constuctor.
 /// </summary>
 /// <param name="viewModelStore">The store this view model belongs to.</param>
 /// <param name="diagram">Diagram.</param>
 /// <param name="modelContext">Model context.</param>
 /// <param name="bCallIntialize"></param>
 protected BaseDiagramSurfaceViewModel(ViewModelStore viewModelStore, Diagram diagram, ModelContext modelContext, bool bCallIntialize)
     : this(viewModelStore, diagram, modelContext.Name, bCallIntialize)
 {
     this.modelContextName = modelContext.Name;
 }
コード例 #13
0
		/// <summary>
		/// Reads all instances of relationship DiagramHasLinkShapes.
		/// </summary>
		/// <remarks>
		/// The caller will position the reader at the open tag of the first XML element inside the relationship tag, so it can be
		/// either the first instance, or a bogus tag. This method will deserialize all instances and ignore all bogus tags. When the
		/// method returns, the reader will be positioned at the end tag of the relationship (or EOF if somehow that happens).
		/// </remarks>
		/// <param name="serializationContext">Serialization context.</param>
		/// <param name="element">In-memory Diagram instance that will get the deserialized data.</param>
		/// <param name="reader">XmlReader to read serialized data from.</param>
		private static void ReadDiagramHasLinkShapesInstances(DslModeling::SerializationContext serializationContext, Diagram element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				DslModeling::DomainClassXmlSerializer newLinkShapeOfDiagramHasLinkShapesSerializer = serializationContext.Directory.GetSerializer(LinkShape.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newLinkShapeOfDiagramHasLinkShapesSerializer != null, "Cannot find serializer for LinkShape!");
				LinkShape newLinkShapeOfDiagramHasLinkShapes = newLinkShapeOfDiagramHasLinkShapesSerializer.TryCreateInstance(serializationContext, reader, element.Partition) as LinkShape;
				if (newLinkShapeOfDiagramHasLinkShapes != null)
				{
					element.LinkShapes.Add(newLinkShapeOfDiagramHasLinkShapes);
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newLinkShapeOfDiagramHasLinkShapes.GetDomainClass().Id);	
					global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newLinkShapeOfDiagramHasLinkShapes.GetDomainClass().Name + "!");
					targetSerializer.Read(serializationContext, newLinkShapeOfDiagramHasLinkShapes, reader);
				}
				else
				{
					global::System.Type typeofDiagramHasLinkShapes = typeof(DiagramHasLinkShapes);
					DslModeling::DomainRelationshipXmlSerializer newDiagramHasLinkShapesSerializer = serializationContext.Directory.GetSerializer(DiagramHasLinkShapes.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer;
					global::System.Diagnostics.Debug.Assert(newDiagramHasLinkShapesSerializer != null, "Cannot find serializer for DiagramHasLinkShapes!");
					DiagramHasLinkShapes newDiagramHasLinkShapes = newDiagramHasLinkShapesSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as DiagramHasLinkShapes;
					if (newDiagramHasLinkShapes != null)
					{
						if (newDiagramHasLinkShapes.GetType() == typeofDiagramHasLinkShapes)
						{	// The relationship should be serialized in short-form.
							TestDslDefinitionSerializationBehaviorSerializationMessages.ExpectingShortFormRelationship(serializationContext, reader, typeof(DiagramHasLinkShapes));
						}
						DslModeling::DomainRoleInfo.SetRolePlayer (newDiagramHasLinkShapes, DiagramHasLinkShapes.DiagramDomainRoleId, element);
						DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newDiagramHasLinkShapes.GetDomainClass().Id);	
						global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newDiagramHasLinkShapes.GetDomainClass().Name + "!");
						targetSerializer.Read(serializationContext, newDiagramHasLinkShapes, reader);
					}
					else
					{	// Unknown element, skip
						DslModeling::SerializationUtilities.Skip(reader);
					}
				}
			}
		}
コード例 #14
0
		public static DslModeling::LinkedElementCollection<Diagram> GetIncludedDiagrams(Diagram element)
		{
			return GetRoleCollection<DslModeling::LinkedElementCollection<Diagram>, Diagram>(element, SourceDiagramDomainRoleId);
		}
コード例 #15
0
 /// <summary>
 /// Constuctor.
 /// </summary>
 /// <param name="viewModelStore">View model store containing this view model.</param>
 /// <param name="diagram"></param>
 /// <param name="modelContext"></param>
 public SpecificDependenciesViewModel(ViewModelStore viewModelStore, Diagram diagram, ModelContext modelContext)
     : base(viewModelStore, diagram, modelContext)
 {
     this.itemViewModels = new ObservableCollection<SpecificDependenciesItemViewModel>();
 }
コード例 #16
0
		internal static void SetParentDiagram(Diagram element, Diagram newSourceDiagram)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, TargetDiagramDomainRoleId, newSourceDiagram);
		}
コード例 #17
0
		internal static Diagram GetParentDiagram(Diagram element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, TargetDiagramDomainRoleId) as Diagram;
		}
コード例 #18
0
		/// <summary>
		/// Constructor
		/// Creates a DiagramHasIncludedDiagrams link in the same Partition as the given Diagram
		/// </summary>
		/// <param name="source">Diagram to use as the source of the relationship.</param>
		/// <param name="target">Diagram to use as the target of the relationship.</param>
		public DiagramHasIncludedDiagrams(Diagram source, Diagram target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(DiagramHasIncludedDiagrams.SourceDiagramDomainRoleId, source), new DslModeling::RoleAssignment(DiagramHasIncludedDiagrams.TargetDiagramDomainRoleId, target)}, null)
		{
		}
コード例 #19
0
		private static void WriteChildElements(DslModeling::SerializationContext serializationContext, Diagram element, global::System.Xml.XmlWriter writer)
		{
			// DiagramHasChildren
			global::System.Collections.ObjectModel.ReadOnlyCollection<DiagramHasChildren> allDiagramHasChildrenInstances = DiagramHasChildren.GetLinksToChildren(element);
			if (!serializationContext.Result.Failed && allDiagramHasChildrenInstances.Count > 0)
			{
				writer.WriteStartElement("children");
				global::System.Type typeofDiagramHasChildren = typeof(DiagramHasChildren);
				foreach (DiagramHasChildren eachDiagramHasChildrenInstance in allDiagramHasChildrenInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					if (eachDiagramHasChildrenInstance.GetType() != typeofDiagramHasChildren)
					{	// Derived relationships will be serialized in full-form.
						DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachDiagramHasChildrenInstance.GetDomainClass().Id);
						global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachDiagramHasChildrenInstance.GetDomainClass().Name + "!");			
						derivedRelSerializer.Write(serializationContext, eachDiagramHasChildrenInstance, writer);
					}
					else
					{	// No need to serialize the relationship itself, just serialize the role-player directly.
						DslModeling::ModelElement targetElement = eachDiagramHasChildrenInstance.ChildShape;
						DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer(targetElement.GetDomainClass().Id);
						global::System.Diagnostics.Debug.Assert(targetSerializer != null, "Cannot find serializer for " + targetElement.GetDomainClass().Name + "!");			
						targetSerializer.Write(serializationContext, targetElement, writer);
					}
				}
				writer.WriteEndElement();
			}
	
			// DiagramHasLinkShapes
			global::System.Collections.ObjectModel.ReadOnlyCollection<DiagramHasLinkShapes> allDiagramHasLinkShapesInstances = DiagramHasLinkShapes.GetLinksToLinkShapes(element);
			if (!serializationContext.Result.Failed && allDiagramHasLinkShapesInstances.Count > 0)
			{
				writer.WriteStartElement("linkShapes");
				global::System.Type typeofDiagramHasLinkShapes = typeof(DiagramHasLinkShapes);
				foreach (DiagramHasLinkShapes eachDiagramHasLinkShapesInstance in allDiagramHasLinkShapesInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					if (eachDiagramHasLinkShapesInstance.GetType() != typeofDiagramHasLinkShapes)
					{	// Derived relationships will be serialized in full-form.
						DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachDiagramHasLinkShapesInstance.GetDomainClass().Id);
						global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachDiagramHasLinkShapesInstance.GetDomainClass().Name + "!");			
						derivedRelSerializer.Write(serializationContext, eachDiagramHasLinkShapesInstance, writer);
					}
					else
					{	// No need to serialize the relationship itself, just serialize the role-player directly.
						DslModeling::ModelElement targetElement = eachDiagramHasLinkShapesInstance.LinkShape;
						DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer(targetElement.GetDomainClass().Id);
						global::System.Diagnostics.Debug.Assert(targetSerializer != null, "Cannot find serializer for " + targetElement.GetDomainClass().Name + "!");			
						targetSerializer.Write(serializationContext, targetElement, writer);
					}
				}
				writer.WriteEndElement();
			}
	
			// DiagramHasIncludedDiagrams
			global::System.Collections.ObjectModel.ReadOnlyCollection<DiagramHasIncludedDiagrams> allDiagramHasIncludedDiagramsInstances = DiagramHasIncludedDiagrams.GetLinksToIncludedDiagrams(element);
			if (!serializationContext.Result.Failed && allDiagramHasIncludedDiagramsInstances.Count > 0)
			{
				writer.WriteStartElement("includedDiagrams");
				foreach (DiagramHasIncludedDiagrams eachDiagramHasIncludedDiagramsInstance in allDiagramHasIncludedDiagramsInstances)
				{
					if (serializationContext.Result.Failed)
						break;
	
					DslModeling::DomainClassXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(eachDiagramHasIncludedDiagramsInstance.GetDomainClass().Id);
					global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for " + eachDiagramHasIncludedDiagramsInstance.GetDomainClass().Name + "!");
					relSerializer.Write(serializationContext, eachDiagramHasIncludedDiagramsInstance, writer);
				}
				writer.WriteEndElement();
			}
	
		}
コード例 #20
0
		/// <summary>
		/// Reads all instances of relationship DiagramHasIncludedDiagrams.
		/// </summary>
		/// <remarks>
		/// The caller will position the reader at the open tag of the first XML element inside the relationship tag, so it can be
		/// either the first instance, or a bogus tag. This method will deserialize all instances and ignore all bogus tags. When the
		/// method returns, the reader will be positioned at the end tag of the relationship (or EOF if somehow that happens).
		/// </remarks>
		/// <param name="serializationContext">Serialization context.</param>
		/// <param name="element">In-memory Diagram instance that will get the deserialized data.</param>
		/// <param name="reader">XmlReader to read serialized data from.</param>
		private static void ReadDiagramHasIncludedDiagramsInstances(DslModeling::SerializationContext serializationContext, Diagram element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				DslModeling::DomainClassXmlSerializer newDiagramHasIncludedDiagramsSerializer = serializationContext.Directory.GetSerializer(DiagramHasIncludedDiagrams.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newDiagramHasIncludedDiagramsSerializer != null, "Cannot find serializer for DiagramHasIncludedDiagrams!");
				DiagramHasIncludedDiagrams newDiagramHasIncludedDiagrams = newDiagramHasIncludedDiagramsSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as DiagramHasIncludedDiagrams;
				if (newDiagramHasIncludedDiagrams != null)
				{
					DslModeling::DomainRoleInfo.SetRolePlayer (newDiagramHasIncludedDiagrams, DiagramHasIncludedDiagrams.SourceDiagramDomainRoleId, element);
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newDiagramHasIncludedDiagrams.GetDomainClass().Id);	
					global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newDiagramHasIncludedDiagrams.GetDomainClass().Name + "!");
					targetSerializer.Read(serializationContext, newDiagramHasIncludedDiagrams, reader);
				}
				else
				{	// Maybe the relationship is serialized in short-form by mistake.
					DslModeling::DomainClassXmlSerializer newDiagramOfDiagramHasIncludedDiagramsSerializer = serializationContext.Directory.GetSerializer(Diagram.DomainClassId);
					global::System.Diagnostics.Debug.Assert(newDiagramOfDiagramHasIncludedDiagramsSerializer != null, "Cannot find serializer for Diagram!");
					Diagram newDiagramOfDiagramHasIncludedDiagrams = newDiagramOfDiagramHasIncludedDiagramsSerializer.TryCreateInstance(serializationContext, reader, element.Partition) as Diagram;
					if (newDiagramOfDiagramHasIncludedDiagrams != null)
					{
						TestDslDefinitionSerializationBehaviorSerializationMessages.ExpectingFullFormRelationship(serializationContext, reader, typeof(DiagramHasIncludedDiagrams));
						element.IncludedDiagrams.Add(newDiagramOfDiagramHasIncludedDiagrams);
						DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newDiagramOfDiagramHasIncludedDiagrams.GetDomainClass().Id);	
						global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newDiagramOfDiagramHasIncludedDiagrams.GetDomainClass().Name + "!");
						targetSerializer.Read(serializationContext, newDiagramOfDiagramHasIncludedDiagrams, reader);
					}
					else
					{	// Unknown element, skip.
						DslModeling::SerializationUtilities.Skip(reader);
					}
				}
			}
		}
コード例 #21
0
 /// <summary>
 /// Constuctor.
 /// </summary>
 /// <param name="viewModelStore">The store this view model belongs to.</param>
 /// <param name="diagram">Diagram.</param>
 /// <param name="modelContext">Model context.</param>
 protected BaseDiagramSurfaceViewModel(ViewModelStore viewModelStore, Diagram diagram, ModelContext modelContext)
     : this(viewModelStore, diagram, modelContext.Name, true)
 {
     this.modelContextName = modelContext.Name;
 }
コード例 #22
0
		public static DiagramsModel GetDiagramsModel(Diagram element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, DiagramDomainRoleId) as DiagramsModel;
		}
コード例 #23
0
        protected BaseDiagramSurfaceViewModel(ViewModelStore viewModelStore, Diagram diagram, string modelContextName, bool bCallIntialize)
            : base(viewModelStore, false)
        {
            if (String.IsNullOrEmpty(modelContextName))
                this.modelContextName = null;
            else
                this.modelContextName = modelContextName;

            this.EventManager.GetEvent<SelectionChangedEvent>().Subscribe(new Action<SelectionChangedEventArgs>(ReactOnViewSelection));

            if (bCallIntialize)
            {
                //Initialize();
                PreInitialize();
            }
        }
コード例 #24
0
		public static void SetDiagramsModel(Diagram element, DiagramsModel newDiagramsModel)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, DiagramDomainRoleId, newDiagramsModel);
		}
コード例 #25
0
        public static bool RestoreLayout(NodeShape shapeElement, Diagram diagram)
        {
            DiagramsModel model = GetDiagramsModel(shapeElement);
            foreach (LayoutInfo layout in model.LayoutInfos)
                if (layout.HostElementId == shapeElement.Element.Id)
                {
                    // apply layout
                    ApplyLayout(shapeElement, diagram, layout);

                    return true;
                }

            Tum.PDE.ToolFramework.Modeling.Diagrams.Layout.GleeLayouter.Layout(shapeElement);
            
            return false;
        }
コード例 #26
0
		internal static void SetInternalDiagram(NodeShape element, Diagram newDiagram)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, ChildShapeDomainRoleId, newDiagram);
		}
コード例 #27
0
		public static DslModeling::LinkedElementCollection<NodeShape> GetChildren(Diagram element)
		{
			return GetRoleCollection<DslModeling::LinkedElementCollection<NodeShape>, NodeShape>(element, DiagramDomainRoleId);
		}
コード例 #28
0
		/// <summary>
		/// Constructor
		/// Creates a DiagramHasChildren link in the same Partition as the given Diagram
		/// </summary>
		/// <param name="source">Diagram to use as the source of the relationship.</param>
		/// <param name="target">NodeShape to use as the target of the relationship.</param>
		public DiagramHasChildren(Diagram source, NodeShape target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(DiagramHasChildren.DiagramDomainRoleId, source), new DslModeling::RoleAssignment(DiagramHasChildren.ChildShapeDomainRoleId, target)}, null)
		{
		}
コード例 #29
0
        public static void ApplyLayout(NodeShape shapeElement, Diagram diagram, LayoutInfo layout)
        {
            // apply layout
            shapeElement.Size = layout.Size;

            // children
            foreach (NodeShape shape in shapeElement.Children)
            {
                ProcessNodeShape(shape, layout.ChildrenInfos);
            }

            RestoreLinkShapes(diagram, layout.LinkShapeInfos);

        }
コード例 #30
0
        /// <summary>
        /// Verifies if a specific link is already displayed as a child of a diagram.
        /// </summary>
        /// <param name="diagram">Diagram to search for that specific link.</param>
        /// <param name="rsShapeDomainClassType">Type of the relationship shape.</param>
        /// <param name="rsId">Relationship Id.</param>
        /// <param name="fromShapeId">From shape Id.</param>
        /// <param name="toShapeId">To shape Id.</param>
        /// <returns>True of the link is hosted on the diagram. False otherwise.</returns>
        public static bool IsLinkDisplayedOn(Diagram diagram, Guid rsShapeDomainClassType, Guid rsId, Guid fromShapeId, Guid toShapeId)
        {
            foreach(LinkShape shape in diagram.LinkShapes)
                if (shape.GetDomainClass().IsDerivedFrom(rsShapeDomainClassType))
                {
                    if (shape.Element != null && shape.FromShape != null && shape.ToShape != null)
                    {
                        if (shape.Element.Id == rsId &&
                            shape.FromShape.Id == fromShapeId &&
                            shape.ToShape.Id == toShapeId)
                            return true;
                            
                    }
                }

            return false;
        }