public string Export(SequenceData data) { string currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); String filePath = Path.Combine(currentDirectory, "tempseq.pic"); using (var sw = new StreamWriter(filePath, false)) { Write(sw, ".PS"); Write(sw, "copy \"sequence.pic\";"); Write(sw, "maxpswid = 20;"); Write(sw, "maxpsht = 20;"); Write(sw, "boxwid = 1.9;"); Write(sw, "movewid = 0.1;"); Write(sw, "spacing = 0.3;"); Write(sw, "step();"); objectList = data.GetObjectList(); foreach (ObjectInstanceInfo oInfo in objectList) { WriteObject(sw, oInfo.TypeName, oInfo.Key); //Write(sw, "active(" + oInfo.Key + ");"); } Write(sw, "step();"); Write(sw, "step();"); foreach (MethodCallInfo mInfo in data.GetMethodList()) { WriteMessage(sw, mInfo); } Write(sw, "step();"); Write(sw, "step();"); // reverse iterate the object collection to put complete objectList.Reverse(); foreach (ObjectInstanceInfo oInfo in objectList) { WriteComplete(sw, oInfo.Key); } Write(sw, ".PE"); } return this.ExecutePlot(currentDirectory, filePath, data.ToString()); }
public string Export(SequenceData data) { DiagramViewer viewer = new DiagramViewer(); Size size = new Size(2000D, 2000D); viewer.Measure(size); viewer.Arrange(new Rect(size)); string outputFileName = data.ToString(); outputFileName = Helper.RemoveInvalidCharsFromFileName(outputFileName); string extension = "xps"; if (!this.UseUniqueFileName) { outputFileName = "seq"; } outputFileName = Path.Combine(this.DestinationPath, string.Concat(outputFileName, ".", extension)); using (SaveContextScope saveScope = ContextHelper.CreateSaveScope(viewer, outputFileName)) { using (SequenceContextScope renderScope = ContextHelper.CreateSequenceScope()) { foreach (ObjectInstanceInfo item in data.GetObjectList()) { renderScope.CurrentContext.AddSequenceObject(item.Key, item.TypeName); } foreach (MethodCallInfo item in data.GetMethodList()) { string sourceKey = data.GetObjectList().Find(objectInfo => objectInfo.TypeName.Equals(item.TypeName, StringComparison.Ordinal)).Key; string targetKey = data.GetObjectList().Find(objectInfo => objectInfo.TypeName.Equals(item.MethodCallType, StringComparison.Ordinal)).Key; renderScope.CurrentContext.AddMessage(sourceKey, targetKey, item.MethodCallName, item); } renderScope.CurrentContext.Render(); } } return outputFileName; }