Latest upgrade of imbSCI.Graph library (0.1.1.1) introduces support for Dia .shape and .sheet definitions.
These classes are part of new namespace: imbSCI.Graph.DiagramLibraries.DiaShapes.
Dia is legendary open source diagramming software – project web site with huge amount of free shape libraries. The library allows (for now) you to create, load, modify, save and export (SVG, JPG, PNG, TIFF…) shape definition. It is also capable to create, load, modify and save sheet definition, that connects number of shapes into one “shape library”. Using diaToolKit class, you can collect all shapes from a directory, automatically create new sheet definition and required icon files.
Test example: load shape definition to render it into SVG and raster (PNG by default) image.
[TestMethod] public void TestDiaShape() { folderNode folder = new folderNode().Add("resources", "TestResources", "").Add("flowchart", "Flowchart", "Dia shapes and sheet"); folderNode folderOutput = new folderNode().Add("diagrams", "Diagram test output", "Directory with results of diagram tests"); // Loads original shape definition diaShape shape = diaShape.Load(folder.findFile("preparation.shape")); // Saves shape definition shape.Save(folderOutput, "preparation", "Load, save test"); // Exports SVG with default style shape.SaveSVG(folderOutput); // Renders icon .png file with default size (22px) shape.RenderIcon(folderOutput); }
Below, we use diaToolKit class to automatically generate sheet definition from all shapes found in specified folder.
[TestMethod] public void TestDiaToolkit() { folderNode folder = new folderNode().Add("resources", "TestResources", "").Add("new_shapes", "Shape folder", "New shapes for Dia"); folderNode folderOutput = new folderNode().Add("diagrams", "Diagram test output", "Directory with results of diagram tests").Add("new_shapes", "Toolkit test", "Shapes and sheet definition"); diaToolKit toolkit = new diaToolKit(folder, folderOutput); toolkit.ConstructSheetAndIcons(diaToolKit.diaToolKitOperationEnum.exportIcon | diaToolKit.diaToolKitOperationEnum.exportSheetFile | diaToolKit.diaToolKitOperationEnum.exportSVG | diaToolKit.diaToolKitOperationEnum.sheetNameFromFolder | diaToolKit.diaToolKitOperationEnum.copyShapes | diaToolKit.diaToolKitOperationEnum.exportBigIcon | diaToolKit.diaToolKitOperationEnum.generateOverviewPNG | diaToolKit.diaToolKitOperationEnum.generateOverviewSVG); }
We also perform additional operations, specified with diaToolKitOperationEnum flags:
exportSVG | 1 | Exports SVG file for each shape | |
exportIcon | 2 | The export icon file for each shape | |
exportSheetFile | 4 | The export sheet file: creates sheet file with all shapes from input folder | |
sheetNameFromFolder | 8 | The sheet name from folder: sheet file takes name of source directory | |
copyShapes | 16 | The copy shapes: it will copy each shape into destination directory | |
exportBigIcon | 32 | The export big icon: it will also create big icon for each shape |