示例#1
0
        CreateAndSaveSubgraphImageInFolder
        (
            IGraph oSubgraph,
            String sVertexName,
            CreateSubgraphImagesAsyncArgs oCreateSubgraphImagesAsyncArgs
        )
        {
            Debug.Assert(oSubgraph != null);
            Debug.Assert(!String.IsNullOrEmpty(sVertexName));
            Debug.Assert(oCreateSubgraphImagesAsyncArgs != null);
            Debug.Assert(oCreateSubgraphImagesAsyncArgs.SaveToFolder);
            AssertValid();

            // Save the graph to a bitmap.

            Bitmap oBitmap = CreateSubgraphImage(oSubgraph,
                                                 oCreateSubgraphImagesAsyncArgs,
                                                 oCreateSubgraphImagesAsyncArgs.ImageSizePx);

            try
            {
                // Save the bitmap in the specified folder.

                SaveSubgraphImage(oBitmap,
                                  oCreateSubgraphImagesAsyncArgs.Folder,
                                  sVertexName, oCreateSubgraphImagesAsyncArgs
                                  );
            }
            finally
            {
                GraphicsUtil.DisposeBitmap(ref oBitmap);
            }
        }
示例#2
0
        CreateAndSaveThumbnailImage
        (
            IGraph oSubgraph,
            String sVertexName,
            CreateSubgraphImagesAsyncArgs oCreateSubgraphImagesAsyncArgs,
            TemporaryImages oThumbnailImages
        )
        {
            Debug.Assert(oSubgraph != null);
            Debug.Assert(!String.IsNullOrEmpty(sVertexName));
            Debug.Assert(oCreateSubgraphImagesAsyncArgs != null);
            Debug.Assert(oCreateSubgraphImagesAsyncArgs.CreateThumbnails);
            Debug.Assert(oThumbnailImages != null);
            AssertValid();

            if (oThumbnailImages.Folder == null)
            {
                // Create a temporary folder where the thumbnail images will be
                // stored.

                String sTemporaryFolder = Path.Combine(
                    Path.GetTempPath(),
                    Path.GetRandomFileName()
                    );

                Directory.CreateDirectory(sTemporaryFolder);

                oThumbnailImages.Folder = sTemporaryFolder;
            }

            // Save the graph to a bitmap.

            Bitmap oBitmap = CreateSubgraphImage(oSubgraph,
                                                 oCreateSubgraphImagesAsyncArgs,
                                                 oCreateSubgraphImagesAsyncArgs.ThumbnailSizePx);

            try
            {
                // Save the bitmap in the temporary folder.

                String sTemporaryFileName = SaveSubgraphImage(oBitmap,
                                                              oThumbnailImages.Folder, sVertexName,
                                                              oCreateSubgraphImagesAsyncArgs
                                                              );

                // Add the file name to the dictionary.  They key is the vertex
                // name and the value is the file name, without a path.

                oThumbnailImages.FileNames[sVertexName] = sTemporaryFileName;
            }
            finally
            {
                GraphicsUtil.DisposeBitmap(ref oBitmap);
            }
        }