protected override void InitDiagram()
        {
            base.InitDiagram();

            NDrawing drawing    = m_DrawingDocument.Content;
            NPage    activePage = drawing.ActivePage;

            // hide the grid
            drawing.ScreenVisibility.ShowGrid = false;

            string[] tableDescription = new string[] { "Table With Column Ports", "Table With Row Ports", "Table With Cell Ports", "Table With Grid Ports" };
            ENPortsDistributionMode[] tablePortDistributionModes = new ENPortsDistributionMode[] { ENPortsDistributionMode.ColumnsOnly, ENPortsDistributionMode.RowsOnly, ENPortsDistributionMode.CellBased, ENPortsDistributionMode.GridBased };
            NTableBlock[]             tableBlocks = new NTableBlock[tablePortDistributionModes.Length];

            double margin    = 40;
            double tableSize = 200;
            double gap       = (drawing.ActivePage.Width - margin * 2 - tableSize * 2);


            double yPos = margin;
            int    portDistributionModeIndex = 0;

            for (int y = 0; y < 2; y++)
            {
                double xPos = margin;

                for (int x = 0; x < 2; x++)
                {
                    NShape shape = new NShape();
                    shape.SetBounds(new NRectangle(xPos, yPos, tableSize, tableSize));

                    xPos += tableSize + gap;

                    // create table
                    NTableBlock tableBlock = CreateTableBlock(tableDescription[portDistributionModeIndex]);

                    // collect the block to connect it to the center shape
                    tableBlocks[portDistributionModeIndex] = tableBlock;

                    tableBlock.Content.AllowSpacingBetweenCells = false;
                    tableBlock.ResizeMode            = ENTableBlockResizeMode.FitToShape;
                    tableBlock.PortsDistributionMode = tablePortDistributionModes[portDistributionModeIndex++];
                    shape.TextBlock = tableBlock;

                    drawing.ActivePage.Items.AddChild(shape);
                }

                yPos += tableSize + gap;
            }

            NShape centerShape = new NBasicShapeFactory().CreateShape(ENBasicShape.Rectangle);

            centerShape.Text = "Table Ports allow you to connect tables to other shapes";
            centerShape.TextBlock.FontStyleBold = true;
            ((NTextBlock)centerShape.TextBlock).VerticalAlignment   = ENVerticalAlignment.Center;
            ((NTextBlock)centerShape.TextBlock).HorizontalAlignment = ENAlign.Center;
            drawing.ActivePage.Items.AddChild(centerShape);

            double center    = drawing.ActivePage.Width / 2.0;
            double shapeSize = 100;

            centerShape.SetBounds(new NRectangle(center - shapeSize / 2.0, center - shapeSize / 2.0, shapeSize, shapeSize));

            // get the column port for the first column on the bottom side
            NTableColumnPort columnPort;

            if (tableBlocks[0].TryGetColumnPort(0, false, out columnPort))
            {
                Connect(columnPort, centerShape.GetPortByName("Left"));
            }

            // get the row port for the second row on the left side
            NTableRowPort rowPort;

            if (tableBlocks[1].TryGetRowPort(1, true, out rowPort))
            {
                Connect(rowPort, centerShape.GetPortByName("Top"));
            }

            // get the cell port of the first cell on the top side
            NTableCellPort cellPort;

            if (tableBlocks[2].TryGetCellPort(0, 0, ENTableCellPortDirection.Top, out cellPort))
            {
                Connect(cellPort, centerShape.GetPortByName("Bottom"));
            }

            // get the cell port of the first row on the left side
            NTableRowPort rowPort1;

            if (tableBlocks[3].TryGetRowPort(0, true, out rowPort1))
            {
                Connect(rowPort1, centerShape.GetPortByName("Right"));
            }
        }