/// <summary> /// Initializes a new instance of the <see cref="SaveContext"/> class. /// </summary> /// <param name="contextParameters">The context parameters.</param> internal SaveContext(ContextParameters contextParameters) { SaveContextParameters scp = contextParameters as SaveContextParameters; if (scp == null) { throw new ArgumentException(Properties.Resources.ArgumentHasInvalidType, "contextParameters"); } this.viewer = scp.Viewer; this.xpsFileName = scp.TargetFileName; }
/// <summary> /// Initializes a new instance of the <see cref="PrintContext"/> class. /// </summary> /// <param name="contextParameters">The context parameters.</param> internal PrintContext(ContextParameters contextParameters) { PrintContextParameters pcp = contextParameters as PrintContextParameters; if (pcp == null) { throw new ArgumentException(Properties.Resources.ArgumentHasInvalidType, "contextParameters"); } this.viewer = pcp.Viewer; this.printDialog = pcp.PrintDialog; }
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; }
/// <summary> /// Creates the save scope. /// </summary> /// <param name="viewer">The viewer.</param> /// <param name="targetFileName">Name of the target file.</param> /// <returns>A new SaveContextScope object.</returns> public static SaveContextScope CreateSaveScope(DiagramViewer viewer, string targetFileName) { return new SaveContextScope(ContextParameters.GetSaveContextParameters(viewer, targetFileName)); }
/// <summary> /// Creates the print scope. /// </summary> /// <param name="viewer">The viewer.</param> /// <param name="printDialog">The print dialog.</param> /// <returns>A new PrintContextScope object.</returns> public static PrintContextScope CreatePrintScope(DiagramViewer viewer, PrintDialog printDialog) { return new PrintContextScope(ContextParameters.GetPrintContextParameters(viewer, printDialog)); }
/// <summary> /// Initializes a new instance of the <see cref="PrintContextParameters"/> class. /// </summary> /// <param name="viewer">The viewer.</param> /// <param name="printDialog">The print dialog.</param> internal PrintContextParameters(DiagramViewer viewer, PrintDialog printDialog) { this.Viewer = viewer; this.PrintDialog = printDialog; }
/// <summary> /// Initializes a new instance of the <see cref="SaveContextParameters"/> class. /// </summary> /// <param name="viewer">The viewer.</param> /// <param name="targetFileName">Name of the target file.</param> internal SaveContextParameters(DiagramViewer viewer, string targetFileName) { this.Viewer = viewer; this.TargetFileName = targetFileName; }
/// <summary> /// Gets the save context parameters. /// </summary> /// <param name="viewer">The viewer.</param> /// <param name="targetFileName">Name of the target file.</param> /// <returns>A new SaveContextParameters object.</returns> internal static ContextParameters GetSaveContextParameters(DiagramViewer viewer, string targetFileName) { return new SaveContextParameters(viewer, targetFileName); }
/// <summary> /// Gets the print context parameters. /// </summary> /// <param name="viewer">The viewer.</param> /// <param name="printDialog">The print dialog.</param> /// <returns>A new PrintContextParameters object.</returns> internal static ContextParameters GetPrintContextParameters(DiagramViewer viewer, PrintDialog printDialog) { return new PrintContextParameters(viewer, printDialog); }