CreateSubgraphImagesAsync
(
IGraph graph,
ICollection<IVertex> selectedVertices,
Decimal levels,
Boolean saveToFolder,
String folder,
Size imageSizePx,
ImageFormat imageFormat,
Boolean createThumbnails,
Size thumbnailSizePx,
Boolean selectedVerticesOnly,
Boolean selectVertex,
Boolean selectIncidentEdges,
GeneralUserSettings generalUserSettings,
LayoutUserSettings layoutUserSettings
)
{
Debug.Assert(graph != null);
Debug.Assert(selectedVertices != null);
Debug.Assert(levels >= 0);
Debug.Assert(Decimal.Remainder(levels, 0.5M) == 0M);
Debug.Assert( !saveToFolder || !String.IsNullOrEmpty(folder) );
Debug.Assert( !saveToFolder || imageSizePx.Width > 0);
Debug.Assert( !saveToFolder || imageSizePx.Height > 0);
Debug.Assert( !createThumbnails || thumbnailSizePx.Width > 0);
Debug.Assert( !createThumbnails || thumbnailSizePx.Height > 0);
Debug.Assert(generalUserSettings != null);
AssertValid();
const String MethodName = "CreateSubgraphImagesAsync";
if (this.IsBusy)
{
throw new InvalidOperationException( String.Format(
"{0}:{1}: An asynchronous operation is already in progress."
,
this.ClassName,
MethodName
) );
}
// Wrap the arguments in an object that can be passed to
// BackgroundWorker.RunWorkerAsync().
CreateSubgraphImagesAsyncArgs oCreateSubgraphImagesAsyncArgs =
new CreateSubgraphImagesAsyncArgs();
oCreateSubgraphImagesAsyncArgs.Graph = graph;
oCreateSubgraphImagesAsyncArgs.SelectedVertices = selectedVertices;
oCreateSubgraphImagesAsyncArgs.Levels = levels;
oCreateSubgraphImagesAsyncArgs.SaveToFolder = saveToFolder;
oCreateSubgraphImagesAsyncArgs.Folder = folder;
oCreateSubgraphImagesAsyncArgs.ImageSizePx = imageSizePx;
oCreateSubgraphImagesAsyncArgs.ImageFormat = imageFormat;
oCreateSubgraphImagesAsyncArgs.CreateThumbnails = createThumbnails;
oCreateSubgraphImagesAsyncArgs.ThumbnailSizePx = thumbnailSizePx;
oCreateSubgraphImagesAsyncArgs.SelectedVerticesOnly =
selectedVerticesOnly;
oCreateSubgraphImagesAsyncArgs.SelectVertex = selectVertex;
oCreateSubgraphImagesAsyncArgs.SelectIncidentEdges =
selectIncidentEdges;
oCreateSubgraphImagesAsyncArgs.GeneralUserSettings =
generalUserSettings;
oCreateSubgraphImagesAsyncArgs.Layout =
CreateLayout(layoutUserSettings);
oCreateSubgraphImagesAsyncArgs.Layout.Margin = Margin;
// Note: the NodeXLVisual object can't be created yet, because it must
// be created on the same thread that uses it. It will get created by
// BackgroundWorker_DoWork().
oCreateSubgraphImagesAsyncArgs.NodeXLVisual = null;
// Create a BackgroundWorker and handle its events.
m_oBackgroundWorker = new BackgroundWorker();
m_oBackgroundWorker.WorkerReportsProgress = true;
m_oBackgroundWorker.WorkerSupportsCancellation = true;
m_oBackgroundWorker.DoWork += new DoWorkEventHandler(
BackgroundWorker_DoWork);
m_oBackgroundWorker.ProgressChanged +=
new ProgressChangedEventHandler(BackgroundWorker_ProgressChanged);
m_oBackgroundWorker.RunWorkerCompleted +=
new RunWorkerCompletedEventHandler(
BackgroundWorker_RunWorkerCompleted);
m_oBackgroundWorker.RunWorkerAsync(oCreateSubgraphImagesAsyncArgs);
}