private void InitTableShape(NTableShape shape, NEmployee employee)
        {
            string stylesheetName = employee.Position.ToUpper();

            if (stylesheetName.StartsWith("VP"))
            {
                stylesheetName = "VP";
            }

            shape.Name = employee.Name;
            shape.Tag  = employee;
            shape.InitTable(2, 2);
            shape.BeginUpdate();
            shape.ShowGrid    = false;
            shape.CellMargins = new Nevron.Diagram.NMargins(2);

            NTableColumn column = (NTableColumn)shape.Columns.GetChildAt(1);

            column.SizeMode = TableColumnSizeMode.Fixed;
            column.Width    = 108;

            shape[0, 0].Margins        = new Nevron.Diagram.NMargins(5);
            shape[0, 0].RowSpan        = 2;
            shape[0, 0].Bitmap         = new Bitmap(this.MapPathSecure(employee.PhotoFileName));
            shape[0, 0].Borders        = TableCellBorder.All;
            shape[1, 0].Text           = employee.Position;
            shape[1, 1].Text           = employee.Name;
            shape[1, 0].StyleSheetName = "POSITION";
            shape[1, 1].StyleSheetName = "NAME";
            shape.StyleSheetName       = stylesheetName;
            shape.EndUpdate();

            shape.Ports.DefaultInwardPortUniqueId = ((NPort)shape.Ports.GetChildByName("Bottom")).UniqueId;
        }
        private NTableShape CreateShape(Match m)
        {
            NDrawingDocument document = DrawingView.Document;
            NTableShape      table    = new NTableShape();

            document.ActiveLayer.AddChild(table);

            table.InitTable(3, 2);
            table.BeginUpdate();

            table.CellPadding = new Nevron.Diagram.NMargins(2);
            table.ShowGrid    = false;

            NTableColumn column = (NTableColumn)table.Columns.GetChildAt(1);

            column.SizeMode = TableColumnSizeMode.Fixed;
            column.Width    = 90;

            table[0, 0].Bitmap = FLAGS[m.team1];
            table[1, 0].Text   = m.team1;
            table[2, 0].Text   = m.score1.ToString();

            table[0, 1].Bitmap = FLAGS[m.team2];
            table[1, 1].Text   = m.team2;
            table[2, 1].Text   = m.score2.ToString();

            // write the winner in bold
            if (m.score1 > m.score2)
            {
                table[1, 0].Text = "<b>" + table[1, 0].Text + "</b>";
                table[2, 0].Text = "<b>" + table[2, 0].Text + "</b>";
            }
            else
            {
                table[1, 1].Text = "<b>" + table[1, 1].Text + "</b>";
                table[2, 1].Text = "<b>" + table[2, 1].Text + "</b>";
            }

            // make all cells transparent so that the background of the table is visible
            int i, j;
            int rowCount = table.RowCount, colCount = table.ColumnCount;

            for (i = 0; i < rowCount; i++)
            {
                for (j = 0; j < colCount; j++)
                {
                    table[j, i].StyleSheetName = "transparent";
                }
            }

            table.EndUpdate();
            table.Ports.DefaultInwardPortUniqueId = ((NPort)table.Ports.GetChildByName("Right")).UniqueId;

            return(table);
        }
        private void CreateScene(NDrawingDocument document)
        {
            document.BackgroundStyle.FrameStyle.Visible = false;
            document.BackgroundStyle.FillStyle          = new NColorFillStyle(BackgroundColor);

            if (MapLegend != null)
            {
                NTableShape  tableShape  = MapLegend.Create(document.ActiveLayer);
                NTableColumn colorColumn = (NTableColumn)tableShape.Columns.GetChildAt(0);
                colorColumn.SizeMode = TableColumnSizeMode.Fixed;
                colorColumn.Width    = 24;

                NTableColumn textColumn = (NTableColumn)tableShape.Columns.GetChildAt(1);
                textColumn.SizeMode = TableColumnSizeMode.Fixed;
                textColumn.Width    = 180;
            }
        }
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Table Column Types Example", "This example shows how to set the table column preferred width.", 1));

            {
                // create the table
                NTable table = new NTable();

                table.AllowSpacingBetweenCells = false;

                int columnCount = 5;
                int rowCount    = 5;

                for (int row = 0; row < rowCount; row++)
                {
                    NTableRow tableRow = new NTableRow();
                    table.Rows.Add(tableRow);

                    for (int col = 0; col < columnCount; col++)
                    {
                        NParagraph paragraph;

                        if (row == 0)
                        {
                            // set table column preferred width
                            string       headerText  = string.Empty;
                            NTableColumn tableColumn = new NTableColumn();

                            if (col % 2 == 0)
                            {
                                tableColumn.BackgroundFill = new NColorFill(NColor.LightGray);
                            }
                            else
                            {
                                tableColumn.BackgroundFill = new NColorFill(NColor.Beige);
                            }

                            switch (col)
                            {
                            case 0:                                     // Fixed column
                                tableColumn.PreferredWidth = new NMultiLength(ENMultiLengthUnit.Dip, 80);
                                headerText = "Fixed [80dips]";
                                break;

                            case 1:                                     // Auto
                                headerText = "Automatic";
                                break;

                            case 2:                                     // Percentage
                                tableColumn.PreferredWidth = new NMultiLength(ENMultiLengthUnit.Percentage, 20);
                                headerText = "Percentage [20%]";
                                break;

                            case 3:                                     // Fixed
                                tableColumn.PreferredWidth = new NMultiLength(ENMultiLengthUnit.Dip, 160);
                                headerText = "Fixed [160dips]";
                                break;

                            case 4:                                     // Percentage
                                tableColumn.PreferredWidth = new NMultiLength(ENMultiLengthUnit.Percentage, 30);
                                headerText = "Percentage [30%]";
                                break;
                            }

                            table.Columns.Add(tableColumn);
                            paragraph = new NParagraph(headerText);
                        }
                        else
                        {
                            paragraph = new NParagraph("Cell");
                        }

                        // by default cells contain a single paragraph
                        NTableCell tableCell = new NTableCell();
                        tableCell.Border          = NBorder.CreateFilledBorder(NColor.Black);
                        tableCell.BorderThickness = new NMargins(1);
                        tableCell.Blocks.Add(paragraph);

                        tableRow.Cells.Add(tableCell);
                    }
                }

                section.Blocks.Add(table);
            }
        }