Exemple #1
0
    public void RenderDiagram(SequenceData data)
    {
      using (SequenceContextScope renderingScope = ContextHelper.CreateSequenceScope())
      {
        // add all the objects to the scope's context.
        foreach (var item in data.GetObjectList())
        {
          renderingScope.CurrentContext.AddSequenceObject(item.Key, item.TypeName);
        }

        // add all the messages to the scope's context.
        foreach (var item in data.GetMethodList())
        {
          MethodCallInfo itemCopy = item;

          string sourceKey = data.GetObjectList().Find(objectInfo => objectInfo.TypeName.Equals(itemCopy.TypeName, StringComparison.Ordinal)).Key;
          string targetKey = data.GetObjectList().Find(objectInfo => objectInfo.TypeName.Equals(itemCopy.MethodCallType, StringComparison.Ordinal)).Key;

          renderingScope.CurrentContext.AddMessage(sourceKey, targetKey, item.MethodCallName, item);
        }

        // render the diagram.
        renderingScope.CurrentContext.Render();
      }
    }
Exemple #2
0
    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;
    }
Exemple #3
0
        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());
        }