internal static string Serialize(IList <TopLevelView> items) { var aiPart = new StageElement(ElementName.AIPart); var uiPart = new StageElement(ElementName.UIPart); var root = new StageElement(ElementName.ViewSnippet, aiPart, uiPart); root.AddTextAttribute(AttributeName.SnippetType, ElementName.ViewSnippet); var referencePos = new Vector2(float.MaxValue, float.MaxValue); for (int i = 0; i < items.Count; i++) { var view = items[i]; var selectorView = view as SelectorView; if (selectorView != null) { var item = selectorView.selector; var aiItem = SerializationMaster.Stage(typeof(Selector).Name, item); aiPart.Add(aiItem); var viewItem = WriteSelectorView(selectorView); uiPart.Add(viewItem); //Even though reid also happens on paste we have to do it here as well, otherwise copying linked selectors will fail. item.RegenerateId(); } var linkView = view as AILinkView; if (linkView != null) { var viewItem = WriteAILinkView(linkView); uiPart.Add(viewItem); } if (view.viewArea.xMin < referencePos.x) { referencePos.x = view.viewArea.xMin; } if (view.viewArea.yMin < referencePos.y) { referencePos.y = view.viewArea.yMin; } } uiPart.AddValue(ElementName.ReferencePosition, referencePos); return(SerializationMaster.Serialize(root)); }
internal static string Serialize(QualifierView qualifier) { var aiPart = new StageElement(ElementName.AIPart); var uiPart = new StageElement(ElementName.UIPart); var root = new StageElement(ElementName.QualifierSnippet, aiPart, uiPart); root.AddTextAttribute(AttributeName.SnippetType, ElementName.QualifierSnippet); var aiItem = SerializationMaster.Stage(ElementName.Qualifier, qualifier.qualifier); aiPart.Add(aiItem); var viewItem = WriteQualifierView(qualifier); uiPart.Add(viewItem); return(SerializationMaster.Serialize(root)); }
internal static string Serialize(ActionView action) { var aiPart = new StageElement(ElementName.AIPart); var uiPart = new StageElement(ElementName.UIPart); var root = new StageElement(ElementName.ActionSnippet, aiPart, uiPart); root.AddTextAttribute(AttributeName.SnippetType, ElementName.ActionSnippet); var aiItem = SerializationMaster.Stage(ElementName.Action, action.action); aiPart.Add(aiItem); var viewItem = WriteActionView(action); uiPart.Add(viewItem); return(SerializationMaster.Serialize(root)); }