Hallo,
i m trying reload my diagram. Saving is going well but if i m try load data from xml string shapes are loaded correctly but there are no connections between shapes. I m using ObservableGraphSourceBase<GraphNode,Link> as graph source and it inherit ISerializableGraphSource interface. During the debug i ve found out that method DeserializeLink is never call. Could you be so kind and give some advice how to figure it out.
Thank you very much.
Best regards
Jakub
ps: here my serialization class
001.public partial class KnihyXmlGraphSource : ISerializableGraphSource002. {003. private List<GraphNode> SerializedNodes = new List<GraphNode>();004. public void SerializeNode(object model, SerializationInfo info)005. {006. GraphNode node = model as GraphNode;007. 008. string pom = node.ToString();009. info["Content"] = node.Content;010. info["ShapeType"] = node.ToString();011. info["Id"] = node.GetID();012. 013. }014. 015. public void SerializeLink(ILink link, SerializationInfo info)016. {017. var myLink = link as Link;018. if (myLink.Source != null)019. {020. info["Source"] = myLink.Source.GetID();021. }022. if (myLink.Target != null)023. {024. info["Target"] = myLink.Target.GetID();025. }026. if (myLink.Type != null)027. {028. info["Type"] = myLink.Type;029. }030. }031. 032. public ILink DeserializeLink(IConnection connection, SerializationInfo info)033. {034. Link link = new Link();035. string sourceID = string.Empty;036. string targetID = string.Empty;037. 038. 039. if (info["Target"] != null)040. {041. targetID = info["Target"].ToString();042. }043. if (info["Source"] != null)044. {045. sourceID = info["Source"].ToString();046. }047. if (info["Type"] != null)048. {049. switch (info["Type"].ToString())050. {051. case Constants.Type1:052. link.Type = LinkType.Typ1;053. break;054. case Constants.Type2:055. link.Type = LinkType.Typ2;056. break;057. default:058. link.Type = LinkType.Typ3;059. break;060. }061. }062. GraphNode source = SerializedNodes.FirstOrDefault(x => x.GetID().Equals(sourceID));063. if (source != null)064. {065. link.Source = source;066. }067. 068. GraphNode target = SerializedNodes.FirstOrDefault(x => x.GetID().Equals(targetID));069. if (target != null)070. {071. link.Target = target;072. }073. 074. if (info["Type"] != null)075. {076. string type = info["Source"].ToString();077. switch (type)078. {079. case Constants.Type1:080. link.Type = LinkType.Typ1;081. break;082. case Constants.Type2:083. link.Type = LinkType.Typ2;084. break;085. case Constants.Type3:086. link.Type = LinkType.Typ3;087. break;088. default:089. break;090. }091. }092. return link;093. }094. 095. public object DeserializeNode(IShape shape, SerializationInfo info)096. {097. GraphNode node = new GraphNode();098. 099. string pom = string.Empty;100. if (info["ShapeType"] != null)101. {102. pom = (info["ShapeType"].ToString());103. pom = pom.Substring(23);104. switch (pom)105. {106. case Constants.DescriptionNode:107. node = new DescriptionNode();108. node.shape = MindmapItem.ShapeTypes.Description;109. break;110. case Constants.AuthorNode:111. node = new AuthorNode();112. node.shape = MindmapItem.ShapeTypes.Author;113. break;114. case Constants.GenreNode:115. node = new GenreNode();116. node.shape = MindmapItem.ShapeTypes.Genre;117. break;118. case Constants.BookDescriptionNode:119. node = new BookDescriptionNode();120. node.shape = MindmapItem.ShapeTypes.BookDescription;121. break;122. default:123. break;124. }125. }126. 127. if (info["Position"] != null)128. {129. node.Position = Utils.ToPoint(info["Position"].ToString()).Value;130. }131. 132. if (info["Content"] != null)133. {134. node.Content = info["Content"].ToString();135. }136. 137. 138. SerializedNodes.Add(node);139. return node;140. }141. }