コード例 #1
0
            void INMouseEventCallback.OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e)
            {
                NThinDiagramControl diagramControl = (NThinDiagramControl)control;
                NNodeList           nodes          = diagramControl.HitTest(new NPointF(e.X, e.Y));
                NNodeList           shapes         = nodes.Filter(CellFilter);

                if (shapes.Count == 0)
                {
                    return;
                }

                NClickomaniaGame game = (NClickomaniaGame)diagramControl.Document.Tag;
                NTableCell       cell = (NTableCell)shapes[0];

                if (cell.ParentNode.ParentNode != game.BoardShape)
                {
                    return;
                }

                if (String.IsNullOrEmpty(cell.StyleSheetName))
                {
                    return;
                }

                if (game.OnCellClicked(cell) == false)
                {
                    return;
                }

                // The user has clicked on a cell that is part of a region
                diagramControl.ServerSettings.EnableAutoUpdate = true;
                diagramControl.Update();
            }
コード例 #2
0
    void Start()
    {
        for (int i = 0; i < transform.childCount; i++)
        {
            NTableCell cell = transform.GetChild(i).GetComponent <NTableCell>();
            if (cell != null)
            {
                availableCells.Add(cell);
                cell.gameObject.SetActive(false);
            }
        }
        if (availableCells.Count > 0)
        {
            //offset = (m_Orienatation == TableViewOrienatation.Vertical) ? availableCells[0].height: availableCells[0].width;
        }



        VisibleProcess();
        m_start.SetActive(true);
        m_start.transform.localPosition = ((m_Orienatation == TableViewOrienatation.Vertical) ? Vector3.down : Vector3.right);
        m_end.SetActive(true);
        m_end.transform.localPosition = ((m_Orienatation == TableViewOrienatation.Vertical)?Vector3.down:Vector3.right) * (defualtMinSize - 1);
        NotifyUpdate();
        m_ScrollView.onMomentumMove += ScrollMoving;
        m_ScrollView.onDragStarted  += DragStarted;
        m_ScrollView.onDragFinished += DragFinished;
    }
コード例 #3
0
        private NTable CreateTable()
        {
            NTable table = new NTable();

            int rowCount = 3;
            int colCount = 3;

            // first create the columns
            for (int i = 0; i < colCount; i++)
            {
                table.Columns.Add(new NTableColumn());
            }

            // then add rows with cells count matching the number of columns
            for (int row = 0; row < rowCount; row++)
            {
                NTableRow tableRow = new NTableRow();
                table.Rows.Add(tableRow);

                for (int col = 0; col < colCount; col++)
                {
                    NTableCell tableCell = new NTableCell();
                    tableRow.Cells.Add(tableCell);
                    tableCell.Margins = new NMargins(4);

                    tableCell.Border          = NBorder.CreateFilledBorder(NColor.Black);
                    tableCell.BorderThickness = new NMargins(1);

                    NParagraph paragraph = new NParagraph("This is table cell [" + row.ToString() + ", " + col.ToString() + "]");
                    tableCell.Blocks.Add(paragraph);
                }
            }

            return(table);
        }
コード例 #4
0
    void SetCell(bool update = false)
    {
        if (listData == null)
        {
            return;
        }
        List <NTableCell>      needHide = new List <NTableCell>();
        Dictionary <int, bool> hasItem  = new Dictionary <int, bool>();
        int n = topItemIndex + visibleItemCount;

        if (n > listData.Count - 1)
        {
            n = listData.Count - 1;
        }
        for (int i = 0; i < visibleCells.Count; i++)
        {
            int index = (int)(((m_Orienatation == TableViewOrienatation.Vertical) ? -visibleCells[i].transform.localPosition.y : visibleCells[i].transform.localPosition.x) / (size + cellSpace));
            if (index < topItemIndex || index > n)
            {
                visibleCells[i].gameObject.SetActive(false);
                needHide.Add(visibleCells[i]);
            }
            else
            {
                if (!hasItem.ContainsKey(index))
                {
                    if (update)
                    {
                        visibleCells[i].OnDraw(index, listData[index]);
                    }
                    hasItem.Add(index, true);
                }
                else
                {
                    visibleCells[i].gameObject.SetActive(false);
                    needHide.Add(visibleCells[i]);
                }
            }
        }
        for (int i = 0; i < needHide.Count; i++)
        {
            availableCells.Add(needHide[i]);
            visibleCells.Remove(needHide[i]);
        }
        for (int i = topItemIndex; i <= n; i++)
        {
            if (!hasItem.ContainsKey(i) && availableCells.Count > 0)
            {
                NTableCell newCell = availableCells[0];
                availableCells.RemoveAt(0);
                newCell.transform.localPosition = ((m_Orienatation == TableViewOrienatation.Vertical) ? Vector3.down : Vector3.right) * (i * (size + cellSpace));
                newCell.gameObject.SetActive(true);
                newCell.OnDraw(i, listData[i]);
                visibleCells.Add(newCell);
            }
        }
    }
コード例 #5
0
        /// <summary>
        /// Creates a table cell with border
        /// </summary>
        /// <returns></returns>
        private NTableCell CreateTableCellWithBorder()
        {
            NTableCell tableCell = new NTableCell();

            tableCell.Border          = NBorder.CreateFilledBorder(NColor.Black);
            tableCell.BorderThickness = new NMargins(1);

            return(tableCell);
        }
コード例 #6
0
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Table Master Cells Example", "This example shows how to programmatically create and add master cells.", 1));

            // first create the table
            NTable table = new NTable(5, 5);

            table.AllowSpacingBetweenCells = false;

            for (int row = 0; row < table.Rows.Count; row++)
            {
                for (int col = 0; col < table.Columns.Count; col++)
                {
                    NParagraph paragraph = new NParagraph("Normal Cell");

                    NTableCell tableCell = table.Rows[row].Cells[col];
                    tableCell.BorderThickness = new Nov.Graphics.NMargins(1);
                    tableCell.Border          = NBorder.CreateFilledBorder(NColor.Black);

                    // by default cells contain a single paragraph
                    tableCell.Blocks.Clear();
                    tableCell.Blocks.Add(paragraph);
                }
            }

            // set cell [0, 2] to be column master
            NTableCell colMasterCell = table.Rows[0].Cells[2];

            colMasterCell.ColSpan        = 2;
            colMasterCell.BackgroundFill = new NColorFill(ENNamedColor.LightSkyBlue);
            colMasterCell.Blocks.Clear();
            colMasterCell.Blocks.Add(new NParagraph("Column Master Cell"));

            // set cell [1, 0] to be row master
            NTableCell rowMasterCell = table.Rows[1].Cells[0];

            rowMasterCell.RowSpan        = 2;
            rowMasterCell.BackgroundFill = new NColorFill(ENNamedColor.LightSteelBlue);
            rowMasterCell.Blocks.Clear();
            rowMasterCell.Blocks.Add(new NParagraph("Row Master Cell"));

            // set cell [2, 2] to be column and row master
            NTableCell rowColMasterCell = table.Rows[2].Cells[2];

            rowColMasterCell.ColSpan        = 2;
            rowColMasterCell.RowSpan        = 2;
            rowColMasterCell.BackgroundFill = new NColorFill(ENNamedColor.MediumTurquoise);
            rowColMasterCell.Blocks.Clear();
            rowColMasterCell.Blocks.Add(new NParagraph("Row\\Col Master Cell"));

            section.Blocks.Add(table);
        }
コード例 #7
0
        /// <summary>
        /// Adds a total row to the shopping cart
        /// </summary>
        void AddTotalRow()
        {
            NTableRow totalRow = m_CartTable.Rows.CreateNewRow();

            NTableCell totalCell = totalRow.Cells[0];

            totalCell.Blocks.Clear();
            totalCell.ColSpan = 3;
            totalCell.Blocks.Add(new NParagraph("Grand Total:"));

            m_CartTable.Rows.Add(totalRow);
        }
コード例 #8
0
        protected override void PopulateRichText()
        {
            NDocumentBlock documentBlock = m_RichText.Content;

            documentBlock.Layout = ENTextLayout.Print;

            NSection section = new NSection();

            documentBlock.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Barcode Widget Inlines",
                                                   "Nevron Open Vision lets you easily insert barcodes in text documents as widget inlines.", 1));

            // Create a table
            NTable table = new NTable(2, 2);

            section.Blocks.Add(table);

            // Create a linear barcode
            NLinearBarcode linearBarcode = new NLinearBarcode(ENLinearBarcodeSymbology.EAN13, "0123456789012");
            NWidgetInline  widgetInline  = new NWidgetInline(linearBarcode);

            // Create a paragraph to host the linear barcode widget inline
            NTableCell cell = table.Rows[0].Cells[0];

            cell.HorizontalAlignment = ENAlign.Center;
            NParagraph paragraph = (NParagraph)cell.Blocks[0];

            paragraph.Inlines.Add(widgetInline);

            // Create a paragraph to the right with some text
            cell      = table.Rows[0].Cells[1];
            paragraph = (NParagraph)cell.Blocks[0];
            paragraph.Inlines.Add(new NTextInline("The linear barcode to the left uses the EAN13 symbology."));

            // Create a QR code widget inline
            NMatrixBarcode qrCode = new NMatrixBarcode(ENMatrixBarcodeSymbology.QrCode, "https://www.nevron.com");

            widgetInline = new NWidgetInline(qrCode);

            // Create a paragraph to host the QR code widget inline
            cell = table.Rows[1].Cells[0];
            cell.HorizontalAlignment = ENAlign.Center;
            paragraph = (NParagraph)cell.Blocks[0];
            paragraph.Inlines.Add(widgetInline);

            // Create a paragraph to the right with some text
            cell      = table.Rows[1].Cells[1];
            paragraph = (NParagraph)cell.Blocks[0];
            paragraph.Inlines.Add(new NTextInline("The QR code to the left contains a link to "));
            paragraph.Inlines.Add(new NHyperlinkInline("https://www.nevron.com", "https://www.nevron.com"));
            paragraph.Inlines.Add(new NTextInline("."));
        }
コード例 #9
0
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Table Cell Orientation Example", "This example shows how to programmatically modify the orientation of cells.", 1));

            // first create the table
            NTable table = new NTable(5, 5);

            table.AllowSpacingBetweenCells = false;

            for (int row = 0; row < table.Rows.Count; row++)
            {
                for (int col = 0; col < table.Columns.Count; col++)
                {
                    NParagraph paragraph = new NParagraph("Normal Cell");

                    NTableCell tableCell = table.Rows[row].Cells[col];
                    tableCell.BorderThickness = new Nov.Graphics.NMargins(1);
                    tableCell.Border          = NBorder.CreateFilledBorder(NColor.Black);

                    // by default cells contain a single paragraph
                    tableCell.Blocks.Clear();
                    tableCell.Blocks.Add(paragraph);
                }
            }

            // set cell [1, 0] to be row master
            NTableCell leftToRightCell = table.Rows[1].Cells[0];

            leftToRightCell.RowSpan        = int.MaxValue;
            leftToRightCell.BackgroundFill = new NColorFill(ENNamedColor.LightSteelBlue);
            leftToRightCell.Blocks.Clear();
            leftToRightCell.Blocks.Add(new NParagraph("Cell With Left to Right Orientation"));
            leftToRightCell.TextDirection       = ENTableCellTextDirection.LeftToRight;
            leftToRightCell.HorizontalAlignment = ENAlign.Center;
            leftToRightCell.VerticalAlignment   = ENVAlign.Center;

            // set cell [1, 0] to be row master
            NTableCell rightToLeftCell = table.Rows[1].Cells[table.Columns.Count - 1];

            rightToLeftCell.RowSpan        = int.MaxValue;
            rightToLeftCell.BackgroundFill = new NColorFill(ENNamedColor.LightGreen);
            rightToLeftCell.Blocks.Clear();
            rightToLeftCell.Blocks.Add(new NParagraph("Cell With Right to Left Orientation"));
            rightToLeftCell.TextDirection       = ENTableCellTextDirection.RightToLeft;
            rightToLeftCell.HorizontalAlignment = ENAlign.Center;
            rightToLeftCell.VerticalAlignment   = ENVAlign.Center;

            section.Blocks.Add(table);
        }
コード例 #10
0
        private NTableBlock CreateTableBlock(string description)
        {
            NTableBlock tableBlock = new NTableBlock(4, 3, NBorder.CreateFilledBorder(NColor.Black), new NMargins(1));

            NTableBlockContent tableBlockContent = tableBlock.Content;

            NTableCell tableCell = tableBlock.Content.Rows[0].Cells[0];

            tableCell.ColSpan = int.MaxValue;

            tableCell.Blocks.Clear();
            NParagraph par = new NParagraph(description);

            par.FontStyleBold = true;
            tableCell.Blocks.Add(par);

            for (int rowIndex = 1; rowIndex < tableBlockContent.Rows.Count; rowIndex++)
            {
                NTableRow row = tableBlockContent.Rows[rowIndex];

                for (int colIndex = 0; colIndex < tableBlockContent.Columns.Count; colIndex++)
                {
                    NTableCell cell = row.Cells[colIndex];

                    cell.Blocks.Clear();
                    cell.Blocks.Add(new NParagraph("This is table cell [" + rowIndex.ToString() + ", " + colIndex.ToString() + "]"));
                }
            }

            NTableCellIterator iter = new NTableCellIterator(tableBlockContent);

            while (iter.MoveNext())
            {
                iter.Current.VerticalAlignment   = ENVAlign.Center;
                iter.Current.HorizontalAlignment = ENAlign.Center;
            }

            // make sure all columns are percentage based
            double percent = 100 / tableBlockContent.Columns.Count;

            for (int i = 0; i < tableBlockContent.Columns.Count; i++)
            {
                tableBlockContent.Columns[i].PreferredWidth = new Nevron.Nov.NMultiLength(Nevron.Nov.ENMultiLengthUnit.Percentage, percent);
            }

            return(tableBlock);
        }
コード例 #11
0
        private NWidget CreateRTFDemo()
        {
            NStackPanel stack = new NStackPanel();

            stack.FillMode = ENStackFillMode.Last;
            stack.FitMode  = ENStackFitMode.Last;

            NButton setButton = new NButton("Set Clipboard RTF");

            setButton.Click += new Function <NEventArgs>(OnSetRTFButtonClick);

            NButton getButton = new NButton("Get Clipboard RTF");

            getButton.Click += new Function <NEventArgs>(OnGetRTFButtonClick);

            NPairBox pairBox = new NPairBox(setButton, getButton);

            pairBox.HorizontalPlacement = ENHorizontalPlacement.Left;
            pairBox.Spacing             = NDesign.HorizontalSpacing;
            stack.Add(pairBox);

            // Create a rich text view and some content
            m_RichText = new NRichTextView();
            m_RichText.PreferredSize = new NSize(400, 300);

            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            NTable table = new NTable(2, 2);

            table.AllowSpacingBetweenCells = false;

            section.Blocks.Add(table);
            for (int i = 0; i < 4; i++)
            {
                NTableCell cell = table.Rows[i / 2].Cells[i % 2];
                cell.Border          = NBorder.CreateFilledBorder(NColor.Black);
                cell.BorderThickness = new NMargins(1);
                NParagraph paragraph = (NParagraph)cell.Blocks[0];
                paragraph.Inlines.Add(new NTextInline("Cell " + (i + 1).ToString(CultureInfo.InvariantCulture)));
            }

            stack.Add(m_RichText);
            return(stack);
        }
コード例 #12
0
        private NTableShape CreateInfoShape(NDrawingDocument document, NClickomaniaGame game)
        {
            NTableShape shape = new NTableShape();

            shape.Name = "Info";

            int i;
            int count = GradientSchemes.Length;

            shape.InitTable(2, count + 2);
            shape.BeginUpdate();

            shape.ShowGrid = false;

            NTableCell headerCell = shape[0, 0];

            headerCell.ColumnSpan = 2;
            headerCell.Padding    = new Nevron.Diagram.NMargins(2, 2, 2, 0);
            headerCell.Borders    = TableCellBorder.Bottom;
            headerCell.Text       = "Cells:";

            for (i = 0; i < count; i++)
            {
                NTableCell colorCell = shape[0, i + 1];
                colorCell.Text           = CellText;
                colorCell.StyleSheetName = GradientSchemes[i].ToString();
                colorCell.Margins        = new Nevron.Diagram.NMargins(4, 4, 4, 4);
                colorCell.Borders        = TableCellBorder.All;

                NTableCell countCell = shape[1, i + 1];
                countCell.Text = game.CellCount[i].ToString();
            }

            NTableCell scoreCell = shape[0, i + 1];

            scoreCell.ColumnSpan = 2;
            scoreCell.Padding    = new Nevron.Diagram.NMargins(2, 2, 2, 0);
            scoreCell.Borders    = TableCellBorder.Top;
            scoreCell.Text       = String.Format("Score:{0}{1}", Environment.NewLine, game.Score);

            game.InfoShape = shape;
            document.ActiveLayer.AddChild(shape);

            shape.EndUpdate();
            return(shape);
        }
コード例 #13
0
        /// <summary>
        ///
        /// </summary>
        protected override void PopulateRichText()
        {
            m_Books            = new NBookInfoList();
            m_CurrentBookIndex = 0;

            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);
            m_RichText.Document.StyleSheets.Add(CreateShoppingCartStyleSheet());

            {
                NTable navigationTable = new NTable(1, 2);

                NTableCell cell0 = navigationTable.Rows[0].Cells[0];

                NButton showPrevBookButton = new NButton("Show Prev Book");
                showPrevBookButton.Click += new Function <NEventArgs>(OnShowPrevBookButtonClick);

                cell0.Blocks.Clear();
                cell0.Blocks.Add(CreateWidgetParagraph(showPrevBookButton));

                NTableCell cell1 = navigationTable.Rows[0].Cells[1];

                NButton showNextBookButton = new NButton("Show Next Book");
                showNextBookButton.Click += new Function <NEventArgs>(OnShowNextBookButtonClick);

                cell1.Blocks.Clear();
                cell1.Blocks.Add(CreateWidgetParagraph(showNextBookButton));

                section.Blocks.Add(navigationTable);
            }

            m_BookInfoPlaceHolder = new NGroupBlock();
            section.Blocks.Add(m_BookInfoPlaceHolder);

            {
                m_BookInfoPlaceHolder.Blocks.Add(CreateBookContent(m_Books[0]));
            }

            {
                m_ShoppingCartPlaceHolder = new NGroupBlock();
                AddEmptyShoppingCartText();

                section.Blocks.Add(m_ShoppingCartPlaceHolder);
            }
        }
コード例 #14
0
            /// <summary>
            /// Handles a cell click event highlighting all cells that form a
            /// region with the clicked cell. If the clicked cell is not part
            /// of a region this method returns false.
            /// </summary>
            /// <param name="cell"></param>
            public bool OnCellClicked(NTableCell cell)
            {
                if (m_CellsToClear.Count > 0)
                {
                    return(false);
                }

                NPoint p     = GetCellAddress(cell);
                string color = cell.StyleSheetName;

                if (Test(p.X, p.Y, color) == false)
                {
                    return(false);
                }

                HighlightCell(p.X, p.Y, color);
                return(true);
            }
コード例 #15
0
        /// <summary>
        /// Returns the address of the given cell in the table.
        /// </summary>
        /// <param name="cell"></param>
        /// <returns></returns>
        private NPoint GetCellAddress(NTableCell cell)
        {
            int i, j;
            int rowCount    = table.RowCount;
            int columnCount = table.ColumnCount;

            for (i = 0; i < rowCount; i++)
            {
                for (j = 0; j < columnCount; j++)
                {
                    if (table[j, i] == cell)
                    {
                        return(new NPoint(j, i));
                    }
                }
            }

            return(new NPoint(-1, -1));
        }
コード例 #16
0
        private void EventSinkService_NodeMouseDown(NNodeMouseEventArgs args)
        {
            NTableCell cell = args.Node as NTableCell;

            if (cell == null)
            {
                return;
            }

            if (cell.ParentNode.ParentNode != table)
            {
                return;
            }

            if (cell.StyleSheetName != null && cell.StyleSheetName != string.Empty)
            {
                if (CellClicked(cell))
                {
                    UpdateInfo();

                    // Check for end of the game
                    string status = string.Empty;
                    if (AllClear())
                    {
                        score *= 2;
                        status = "Congratulations you've cleared all cells !!!" + Environment.NewLine;
                    }

                    if (status == string.Empty && GameOver())
                    {
                        status = "Game Over !" + Environment.NewLine;
                    }

                    if (status != string.Empty)
                    {
                        status += "Your score is " + score.ToString();
                        MessageBox.Show(status);
                    }
                }
            }

            args.Handled = true;
        }
コード例 #17
0
            private static void InitCell(NTableCell cell, int rowSpan, int colSpan, string text)
            {
                if (rowSpan != 1)
                {
                    cell.RowSpan = rowSpan;
                }

                if (colSpan != 1)
                {
                    cell.ColSpan = colSpan;
                }

                // By default cells contain a single paragraph
                cell.Blocks.Clear();
                cell.Blocks.Add(new NParagraph(text));

                // Create a border
                cell.Border          = NBorder.CreateFilledBorder(NColor.Black);
                cell.BorderThickness = new NMargins(1);
            }
コード例 #18
0
        /// <summary>
        /// Handles a cell click. Returns true if the player clicked on a region.
        /// </summary>
        /// <param name="cell"></param>
        /// <returns></returns>
        private bool CellClicked(NTableCell cell)
        {
            NPoint p     = GetCellAddress(cell);
            string color = cell.StyleSheetName;

            if (!Test(p.X, p.Y, color))
            {
                return(false);
            }

            int cellsCleared = 0;

            ClearCell(p.X, p.Y, color, ref cellsCleared);

            cells[IndexOf(color)] -= cellsCleared;
            cellsCleared--;
            score += cellsCleared * cellsCleared;

            ApplyGravity();
            return(true);
        }
コード例 #19
0
        /// <summary>
        /// Creates a table based on the book info
        /// </summary>
        /// <param name="bookInfo"></param>
        /// <returns></returns>
        Nevron.Nov.Text.NBlock CreateBookContent(NBookInfo bookInfo)
        {
            NTable table = new NTable(4, 2);

            // Create the image
            NTableCell imageTableCell = table.Rows[0].Cells[0];

            imageTableCell.RowSpan = int.MaxValue;
            imageTableCell.Blocks.Clear();
            imageTableCell.Blocks.Add(CreateImageParagraph(bookInfo.Image));

            NTableCell titleTableCell = table.Rows[0].Cells[1];

            titleTableCell.Blocks.Clear();
            titleTableCell.Blocks.Add(CreateTitleParagraph(bookInfo.Name));

            NTableCell descriptionTableCell = table.Rows[1].Cells[1];

            descriptionTableCell.Blocks.Clear();
            descriptionTableCell.Blocks.Add(CreateDescriptionParagraph(bookInfo.Description));

            NTableCell authorTableCell = table.Rows[2].Cells[1];

            authorTableCell.Blocks.Clear();
            authorTableCell.Blocks.Add(CreateAuthorParagraph(bookInfo.Author));

            NTableCell addToCartTableCell = table.Rows[3].Cells[1];

            addToCartTableCell.RowSpan = int.MaxValue;
            addToCartTableCell.Blocks.Clear();

            NButton addToCartButton = new NButton("Add To Cart");

            addToCartButton.Click += new Function <NEventArgs>(OnAddTableRow);
            addToCartTableCell.VerticalAlignment = ENVAlign.Bottom;
            addToCartTableCell.Blocks.Add(CreateWidgetParagraph(addToCartButton));

            return(table);
        }
コード例 #20
0
        /// <summary>
        /// Updates the total values in the shopping cart
        /// </summary>
        void UpdateTotals()
        {
            if (m_CartTable == null || m_CartTable.Columns.Count != 5)
            {
                return;
            }

            double grandTotal = 0;

            // sum all book info price * quantity
            for (int i = 0; i < m_CartTable.Rows.Count; i++)
            {
                NTableRow row      = m_CartTable.Rows[i];
                NBookInfo bookInfo = row.Tag as NBookInfo;

                if (bookInfo != null)
                {
                    NVFlowBlockCollection <Nevron.Nov.Text.NBlock> blocks = row.Cells[1].Blocks;

                    NComboBox combo = (NComboBox)blocks.GetFirstDescendant(new NInstanceOfSchemaFilter(NComboBox.NComboBoxSchema));

                    if (combo != null)
                    {
                        double total = (combo.SelectedIndex + 1) * bookInfo.Price;

                        row.Cells[3].Blocks.Clear();
                        row.Cells[3].Blocks.Add(new NParagraph(total.ToString()));

                        grandTotal += total;
                    }
                }
            }

            NTableCell grandTotalCell = m_CartTable.Rows[m_CartTable.Rows.Count - 1].Cells[3];

            grandTotalCell.Blocks.Clear();
            grandTotalCell.Blocks.Add(new NParagraph(grandTotal.ToString()));
        }
コード例 #21
0
        /// <summary>
        /// Called when a new row must be added to the shopping cart
        /// </summary>
        /// <param name="arg"></param>
        void OnAddTableRow(NEventArgs arg)
        {
            if (m_CartTable == null)
            {
                m_CartTable     = new NTable(1, 5);
                m_CartTable.Tag = "ShoppingCart";
                m_CartTable.AllowSpacingBetweenCells = false;

                m_ShoppingCartPlaceHolder.Blocks.Clear();
                m_ShoppingCartPlaceHolder.Blocks.Add(m_CartTable);

                NTableCell nameCell = m_CartTable.Rows[0].Cells[0];
                nameCell.Blocks.Clear();
                nameCell.Blocks.Add(new NParagraph("Name"));

                NTableCell quantity = m_CartTable.Rows[0].Cells[1];
                quantity.Blocks.Clear();
                quantity.Blocks.Add(new NParagraph("Quantity"));

                NTableCell priceCell = m_CartTable.Rows[0].Cells[2];
                priceCell.Blocks.Clear();
                priceCell.Blocks.Add(new NParagraph("Price"));

                NTableCell totalCell = m_CartTable.Rows[0].Cells[3];
                totalCell.Blocks.Clear();
                totalCell.Blocks.Add(new NParagraph("Total"));

                NTableCell deleteCell = m_CartTable.Rows[0].Cells[4];
                deleteCell.Blocks.Clear();

                AddTotalRow();
            }

            AddBookRow();

            UpdateTotals();
        }
コード例 #22
0
        /// <summary>
        /// Adds a book row to the shopping cart
        /// </summary>
        void AddBookRow()
        {
            NBookInfo bookInfo = m_Books[m_CurrentBookIndex];

            NTableRow bookRow = new NTableRow();

            bookRow.Tag = bookInfo;

            NTableCell nameCell = new NTableCell();

            nameCell.Blocks.Add(new NParagraph(bookInfo.Name));
            bookRow.Cells.Add(nameCell);

            NTableCell quantityCell = new NTableCell();

            quantityCell.Blocks.Add(CreateWidgetParagraph(CreateQuantityCombo()));
            bookRow.Cells.Add(quantityCell);

            NTableCell priceCell = new NTableCell();

            priceCell.Blocks.Add(new NParagraph(bookInfo.Price.ToString()));
            bookRow.Cells.Add(priceCell);

            NTableCell totalCell = new NTableCell();

            totalCell.Blocks.Add(new NParagraph());
            bookRow.Cells.Add(totalCell);

            NTableCell deleteCell      = new NTableCell();
            NButton    deleteRowButton = new NButton("Delete");

            deleteRowButton.Click += new Function <NEventArgs>(OnDeleteRowButtonClick);
            deleteCell.Blocks.Add(CreateWidgetParagraph(deleteRowButton));
            bookRow.Cells.Add(deleteCell);

            m_CartTable.Rows.Insert(m_CartTable.Rows.Count - 1, bookRow);
        }
コード例 #23
0
        /// <summary>
        ///
        /// </summary>
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            NParagraph paragraph = new NParagraph();

            paragraph.HorizontalAlignment = ENAlign.Center;
            paragraph.Inlines.Add(CreateHeaderText("ACME Corporation"));
            paragraph.Inlines.Add(new NLineBreakInline());
            paragraph.Inlines.Add(CreateNormalText("Monthly Health Report"));

            section.Blocks.Add(paragraph);

            // generate sample data
            double[] sales      = new double[12];
            double[] hours      = new double[12];
            double[] profitloss = new double[12];
            string[] months     = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
            Random   random     = new Random();

            for (int i = 0; i < 12; i++)
            {
                sales[i]      = 50 + random.Next(50);
                hours[i]      = 50 + random.Next(50);
                profitloss[i] = 25 - random.Next(50);
            }

            NTable table = new NTable();

            section.Blocks.Add(table);

            table.Columns.Add(new NTableColumn());
            table.Columns.Add(new NTableColumn());

            {
                NTableRow tableRow = new NTableRow();

                NTableCell tableCell1 = new NTableCell();

                NParagraph par1 = new NParagraph();
                par1.Inlines.Add(CreateHeaderText("Sales New Projects"));
                tableCell1.Blocks.Add(par1);
                tableRow.Cells.Add(tableCell1);

                NTableCell tableCell2 = new NTableCell();
                tableCell2.Blocks.Add(new NParagraph());
                tableRow.Cells.Add(tableCell2);

                table.Rows.Add(tableRow);
            }

            {
                NTableRow tableRow = new NTableRow();

                NTableCell tableCell1 = new NTableCell();

                NParagraph par1 = new NParagraph();
                par1.Inlines.Add(CreateHeaderText("Total Sales: " + GetTotal(sales).ToString()));
                par1.Inlines.Add(new NLineBreakInline());
                par1.Inlines.Add(CreateNormalText("Last Month: " + sales[11].ToString()));
                tableCell1.Blocks.Add(par1);
                tableRow.Cells.Add(tableCell1);

                NTableCell tableCell2 = new NTableCell();
                tableCell2.Blocks.Add(CreateBarChart(true, new NSize(400, 200), "Sales", sales, months));
                tableRow.Cells.Add(tableCell2);

                table.Rows.Add(tableRow);
            }

            {
                NTableRow tableRow = new NTableRow();

                NTableCell tableCell1 = new NTableCell();

                NParagraph par1 = new NParagraph();
                par1.Inlines.Add(CreateHeaderText("Billable Hours: " + GetTotal(hours).ToString()));
                par1.Inlines.Add(new NLineBreakInline());
                par1.Inlines.Add(CreateNormalText("Last Month: " + hours[11].ToString()));
                tableCell1.Blocks.Add(par1);
                tableRow.Cells.Add(tableCell1);

                NTableCell tableCell2 = new NTableCell();
                tableCell2.Blocks.Add(CreateBarChart(false, new NSize(400, 200), "Hours", hours, months));
                tableRow.Cells.Add(tableCell2);

                table.Rows.Add(tableRow);
            }

            {
                NTableRow tableRow = new NTableRow();

                NTableCell tableCell1 = new NTableCell();

                NParagraph par1 = new NParagraph();
                par1.Inlines.Add(CreateHeaderText("Profit / Loss: " + GetTotal(profitloss).ToString()));
                par1.Inlines.Add(new NLineBreakInline());
                par1.Inlines.Add(CreateNormalText("Last Month: " + profitloss[11].ToString()));
                tableCell1.Blocks.Add(par1);
                tableRow.Cells.Add(tableCell1);

                NTableCell tableCell2 = new NTableCell();
                tableCell2.Blocks.Add(CreateBarChart(false, new NSize(400, 200), "Profit / Loss", hours, months));
                tableRow.Cells.Add(tableCell2);

                table.Rows.Add(tableRow);
            }
        }
コード例 #24
0
        protected void NDrawingView1_AsyncClick(object sender, EventArgs e)
        {
            NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs;

            NNodeList nodes  = NDrawingView1.HitTest(args);
            NNodeList shapes = nodes.Filter(CELL_FILTER);

            if (shapes.Count == 0)
            {
                return;
            }

            NTableCell cell = (NTableCell)shapes[0];

            if (cell.ParentNode.ParentNode != table)
            {
                return;
            }

            if (cell.StyleSheetName != null && cell.StyleSheetName != string.Empty)
            {
                if (CellClicked(cell))
                {
                    UpdateInfo();

                    // Check for end of the game
                    string status = string.Empty;
                    if (AllClear())
                    {
                        score *= 2;
                        status = "You've cleared all cells !!!" + Environment.NewLine;
                    }

                    if (status == string.Empty && GameOver())
                    {
                        status = "Game Over !" + Environment.NewLine;
                    }

                    if (status != string.Empty)
                    {
                        status += "Your score is " + score.ToString();
                        NTableShape gameOver = new NTableShape();
                        document.ActiveLayer.AddChild(gameOver);

                        gameOver.BeginUpdate();
                        gameOver.CellPadding = new Nevron.Diagram.NMargins(2, 2, 8, 8);
                        gameOver[0, 0].Text  = status;

                        NStyle.SetFillStyle(gameOver, new NAdvancedGradientFillStyle(AdvancedGradientScheme.Ocean1, 0));
                        NStyle.SetStrokeStyle(gameOver, new NStrokeStyle(Color.DarkBlue));

                        NTextStyle textStyle = (NTextStyle)table.ComposeTextStyle().Clone();
                        textStyle.FillStyle = new NColorFillStyle(Color.DarkBlue);
                        NStyle.SetTextStyle(gameOver, textStyle);

                        gameOver.EndUpdate();
                        gameOver.Center = table.Center;
                    }
                }
            }
        }
コード例 #25
0
 private static void InitCell(NTableCell cell, string text)
 {
     InitCell(cell, 1, 1, text);
 }
コード例 #26
0
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            {
                section.Blocks.Add(GetDescriptionBlock("Table Borders Example", "This examples shows how table borders behave when the table allows or not table cells spacing.", 1));

                // first create the table
                NTable table = CreateTable(2, 3);

                table.AllowSpacingBetweenCells   = true;
                table.TableCellHorizontalSpacing = 3;
                table.TableCellVerticalSpacing   = 3;

                for (int col = 0; col < table.Columns.Count; col++)
                {
                    for (int row = 0; row < table.Rows.Count; row++)
                    {
                        NTableCell cell = table.Rows[row].Cells[col];

                        switch (col % 3)
                        {
                        case 0:
                            cell.Border          = NBorder.CreateFilledBorder(NColor.Red);
                            cell.Margins         = new NMargins(3);
                            cell.Padding         = new NMargins(3);
                            cell.BorderThickness = new NMargins(1);
                            break;

                        case 1:
                            cell.Border          = NBorder.CreateFilledBorder(NColor.Green);
                            cell.Margins         = new NMargins(5);
                            cell.Padding         = new NMargins(5);
                            cell.BorderThickness = new NMargins(3);
                            break;

                        case 2:
                            cell.Border          = NBorder.CreateFilledBorder(NColor.Blue);
                            cell.Margins         = new NMargins(7);
                            cell.Padding         = new NMargins(7);
                            cell.BorderThickness = new NMargins(2);
                            break;
                        }
                    }
                }

                table.Border          = NBorder.CreateFilledBorder(NColor.Red);
                table.BorderThickness = new NMargins(2, 2, 2, 2);

                section.Blocks.Add(table);

                section.Blocks.Add(new NParagraph("This is a 2x3 table, with borders in collapsed table border mode:"));

                // first create the table
                table = CreateTable(2, 3);

                table.AllowSpacingBetweenCells = false;

                for (int col = 0; col < table.Columns.Count; col++)
                {
                    for (int row = 0; row < table.Rows.Count; row++)
                    {
                        NTableCell cell = table.Rows[row].Cells[col];

                        switch (col % 3)
                        {
                        case 0:
                            cell.Border          = NBorder.CreateFilledBorder(NColor.Red);
                            cell.Margins         = new NMargins(3);
                            cell.Padding         = new NMargins(3);
                            cell.BorderThickness = new NMargins(1);
                            break;

                        case 1:
                            cell.Border          = NBorder.CreateFilledBorder(NColor.Green);
                            cell.Margins         = new NMargins(5);
                            cell.Padding         = new NMargins(5);
                            cell.BorderThickness = new NMargins(3);
                            break;

                        case 2:
                            cell.Border          = NBorder.CreateFilledBorder(NColor.Blue);
                            cell.Margins         = new NMargins(7);
                            cell.Padding         = new NMargins(7);
                            cell.BorderThickness = new NMargins(2);
                            break;
                        }
                    }
                }

                table.Border = NBorder.CreateFilledBorder(NColor.Red);

                section.Blocks.Add(table);
            }
        }
コード例 #27
0
        private NTable CreateTable(int rowCount, int colCount)
        {
            // first create the table
            NTable table = new NTable(rowCount, colCount);

            table.AllowSpacingBetweenCells   = true;
            table.TableCellHorizontalSpacing = 3;
            table.TableCellVerticalSpacing   = 3;

            for (int col = 0; col < table.Columns.Count; col++)
            {
                // set table column preferred width
                string headerText = string.Empty;
                switch (col)
                {
                case 0:     // Fixed column
                    table.Columns[col].PreferredWidth = new NMultiLength(ENMultiLengthUnit.Dip, 80);
                    headerText = "Fixed [80dips]";
                    break;

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

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

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

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

                for (int row = 0; row < table.Rows.Count; row++)
                {
                    NParagraph paragraph;
                    if (row == 0)
                    {
                        paragraph = new NParagraph(headerText);
                    }
                    else
                    {
                        paragraph = new NParagraph("Cell");
                    }

                    NTableCell cell = table.Rows[row].Cells[col];

                    cell.Blocks.Clear();
                    cell.Blocks.Add(paragraph);
                }
            }

            return(table);
        }
コード例 #28
0
        protected override void PopulateRichText()
        {
            {
                NSection headerSection = new NSection();
                m_RichText.Content.Sections.Add(headerSection);

                headerSection.Blocks.Add(CreateTitleParagraph("Welcome to our annual report\nFurther information on Sample Group can be found at:\n www.samplegroup.com"));
                headerSection.Blocks.Add(CreateContentParagraph("Sample Group is a diversified international market infrastructure and capital markets business sitting at the heart of the world’s financial community."));
                headerSection.Blocks.Add(CreateContentParagraph("The Group operates a broad range of international equity, bond and derivatives markets, including Stock Exchange; Europe’s leading fixed income market; and a pan-European equities MTF. Through its platforms, the Group offers international business and investors unrivalled access to Europe’s capital markets."));
                headerSection.Blocks.Add(CreateContentParagraph("Post trade and risk management services are a significant part of the Group’s business operations. In addition to majority ownership of multi-asset global CCP operator, Sunset Group, the Group operates G&B, a clearing house; Monte Span, the European settlement business; and AutoSettle, the Group’s newly established central securities depository based in Luxembourg. The Group is a global leader in indexing and analytic solutions. The Group also provides customers with an extensive range of real time and reference data products. The Group is a leading developer of high performance trading platforms and capital markets software for customers around the world, through MillenniumIT. Since December 2014, the Group has owned Bonita Investments, an investment management business."));
                headerSection.Blocks.Add(CreateContentParagraph("Headquartered in London, with significant operations in North America, China and Russia, the Group employs approximately 6000 people"));
            }

            {
                NSection financialHighlightsSection = new NSection();
                financialHighlightsSection.BreakType = ENSectionBreakType.NextPage;
                m_RichText.Content.Sections.Add(financialHighlightsSection);
                financialHighlightsSection.Blocks.Add(CreateTitleParagraph("Financial highlights"));
                financialHighlightsSection.Blocks.Add(CreateContentParagraph("The following charts provide insight to the group's total income, operating profit, and earnings per share for the years since 2008."));

                NSize chartSize = new NSize(300, 200);
                {
                    NTable table = new NTable();
                    table.AllowSpacingBetweenCells = false;
                    table.Columns.Add(new NTableColumn());
                    table.Columns.Add(new NTableColumn());
                    financialHighlightsSection.Blocks.Add(table);

                    {
                        NTableRow tableRow = new NTableRow();
                        table.Rows.Add(tableRow);
                        {
                            NTableCell tableCell = new NTableCell();
                            tableCell.Blocks.Add(CreateSampleBarChart(chartSize, "Adjusted total income", new double[] { 674.9, 814.8, 852.9, 1, 213.1, 1, 043.9, 1, 096.4, 1, 381.1 }, new string[] { "2008", "2009", "2010", "2011", "2012", "2013", "2014" }));
                            tableRow.Cells.Add(tableCell);
                        }

                        {
                            NTableCell tableCell = new NTableCell();
                            tableCell.Blocks.Add(CreateSampleBarChart(chartSize, "Adjusted operating profit", new double[] { 341.1, 441.9, 430.2, 514.7, 417.5, 479.9, 558.0 }, new string[] { "2008", "2009", "2010", "2011", "2012", "2013", "2014" }));
                            tableRow.Cells.Add(tableCell);
                        }
                    }

                    {
                        NTableRow tableRow = new NTableRow();
                        table.Rows.Add(tableRow);
                        {
                            NTableCell tableCell = new NTableCell();
                            tableCell.Blocks.Add(CreateSampleBarChart(chartSize, "Operating profit", new double[] { 283.0, 358.5, 348.4, 353.1, 242.1, 329.4, 346.0 }, new string[] { "2008", "2009", "2010", "2011", "2012", "2013", "2014" }));
                            tableRow.Cells.Add(tableCell);
                        }

                        {
                            NTableCell tableCell = new NTableCell();
                            tableCell.Blocks.Add(CreateSampleBarChart(chartSize, "Adjusted earnings per share", new double[] { 67.9, 92.6, 97.0, 98.6, 75.6, 96.5, 103.3 }, new string[] { "2008", "2009", "2010", "2011", "2012", "2013", "2014" }));
                            tableRow.Cells.Add(tableCell);
                        }
                    }
                }
            }

            {
                NSection operationalHighlights = new NSection();
                operationalHighlights.ColumnCount = 2;
                operationalHighlights.BreakType   = ENSectionBreakType.NextPage;
                operationalHighlights.Blocks.Add(CreateTitleParagraph("Operational highlights"));
                m_RichText.Content.Sections.Add(operationalHighlights);

                operationalHighlights.Blocks.Add(CreateContentParagraph("The Group is delivering on its strategy, leveraging its range of products and services and further diversifying its offering through new product development and strategic investments. A few examples of the progress being made are highlighted below: "));

                operationalHighlights.Blocks.Add(CreateContentParagraph("Capital Markets"));

                {
                    NBulletList bulletList = new NBulletList(ENBulletListTemplateType.Bullet);
                    m_RichText.Content.BulletLists.Add(bulletList);

                    {
                        NParagraph par = CreateContentParagraph("Revenues for calendar year 2014 increased by 12 per cent to £333.2 million (2013: £296.8 million). Primary Markets saw a seven year high in new issue activity with 219 new companies admitted, including AA, the largest UK capital raising IPO of the year");
                        par.SetBulletList(bulletList, 0);
                        operationalHighlights.Blocks.Add(par);
                    }

                    {
                        NParagraph par = CreateContentParagraph("UK cash equity average daily value traded increased 15 per cent and average daily number of trades in Italy increased 16 per cent");
                        par.SetBulletList(bulletList, 0);
                        operationalHighlights.Blocks.Add(par);
                    }

                    {
                        NParagraph par = CreateContentParagraph("Average daily value traded on Turquoise, our European cash equities MTF, increased 42 per cent to €3.7 billion per day and share of European trading increased to over 9 per cent");
                        par.SetBulletList(bulletList, 0);
                        operationalHighlights.Blocks.Add(par);
                    }

                    {
                        NParagraph par = CreateContentParagraph("In Fixed Income, MTS cash and BondVision value traded increased by 32 per cent, while MTS Repo value traded increased by 3 per cent");
                        par.SetBulletList(bulletList, 0);
                        operationalHighlights.Blocks.Add(par);
                    }
                }
                operationalHighlights.Blocks.Add(CreateContentParagraph("Post Trade Services"));
                {
                    NBulletList bulletList = new NBulletList(ENBulletListTemplateType.Bullet);
                    m_RichText.Content.BulletLists.Add(bulletList);

                    {
                        NParagraph par = CreateContentParagraph("Revenues for calendar year 2014 increased by 3 per cent in constant currency terms. In sterling terms revenues declined by 2 per cent to £96.5 million");
                        par.SetBulletList(bulletList, 0);
                        operationalHighlights.Blocks.Add(par);
                    }

                    {
                        NParagraph par = CreateContentParagraph("Our Group  cleared 69.7 million equity trades, up 16 per cent and 39.0 million derivative contracts up 20 per cent");
                        par.SetBulletList(bulletList, 0);
                        operationalHighlights.Blocks.Add(par);
                    }

                    {
                        NParagraph par = CreateContentParagraph("Our Group is the largest CSD entering the first wave of TARGET2-Securities from June 2015. Successful testing with the European Central Bank finished in December 2014. In addition, Our Group moved settlement of contracts executed on the Italian market from T+3 to T+2 in October 2014");
                        par.SetBulletList(bulletList, 0);
                        operationalHighlights.Blocks.Add(par);
                    }
                }

                operationalHighlights.Blocks.Add(CreateContentParagraph("Post Trade Services 2"));

                {
                    NBulletList bulletList = new NBulletList(ENBulletListTemplateType.Bullet);
                    m_RichText.Content.BulletLists.Add(bulletList);

                    {
                        NParagraph par = CreateContentParagraph("Adjusted income for the calendar year 2014 was £389.4 million, up 24 per cent on a pro forma constant currency basis. LCH.Clearnet received EMIR reauthorisation for the UK and France businesses — SwapClear, the world’s leading interest rate swap clearing service, cleared $642 trillion notional, up 26 per cent");
                        par.SetBulletList(bulletList, 0);
                        operationalHighlights.Blocks.Add(par);
                    }

                    {
                        NParagraph par = CreateContentParagraph("Compression services at SwapClear reduced level of notional outstanding, from $426 trillion to $362 trillion");
                        par.SetBulletList(bulletList, 0);
                        operationalHighlights.Blocks.Add(par);
                    }

                    {
                        NParagraph par = CreateContentParagraph("Our Group was granted clearing house recognition in Canada and Australia");
                        par.SetBulletList(bulletList, 0);
                        operationalHighlights.Blocks.Add(par);
                    }
                    {
                        NParagraph par = CreateContentParagraph("Clearing of commodities for the London Metal Exchange ceased in September 2014 as expected");
                        par.SetBulletList(bulletList, 0);
                        operationalHighlights.Blocks.Add(par);
                    }
                    {
                        NParagraph par = CreateContentParagraph("RepoClear, one of Europe’s largest fixed income clearers, cleared €73.4 trillion in nominal value, up 1 per cent");
                        par.SetBulletList(bulletList, 0);
                        operationalHighlights.Blocks.Add(par);
                    }

                    operationalHighlights.Blocks.Add(CreateContentParagraph("Group Adjusted Total Income by segment"));

                    NTable table = new NTable();
                    table.Margins = new NMargins(10);
                    table.AllowSpacingBetweenCells = false;
                    operationalHighlights.Blocks.Add(table);

                    table.Columns.Add(new NTableColumn());
                    table.Columns.Add(new NTableColumn());
                    table.Columns.Add(new NTableColumn());

                    {
                        NTableRow tableRow = new NTableRow();
                        table.Rows.Add(tableRow);

                        NTableCell tc1 = CreateTableCellWithBorder();
                        tableRow.Cells.Add(tc1);

                        NTableCell tc2 = CreateTableCellWithBorder();
                        tc2.Blocks.Add(CreateContentParagraph("2013"));
                        tableRow.Cells.Add(tc2);

                        NTableCell tc3 = CreateTableCellWithBorder();
                        tc3.Blocks.Add(CreateContentParagraph("2014"));
                        tableRow.Cells.Add(tc3);
                    }

                    {
                        NTableRow tableRow = new NTableRow();
                        table.Rows.Add(tableRow);

                        NTableCell tc1 = CreateTableCellWithBorder();
                        tc1.Blocks.Add(CreateContentParagraph("Capital Markets"));
                        tableRow.Cells.Add(tc1);

                        NTableCell tc2 = CreateTableCellWithBorder();
                        tc2.Blocks.Add(CreateContentParagraph("249.1"));
                        tableRow.Cells.Add(tc2);

                        NTableCell tc3 = CreateTableCellWithBorder();
                        tc3.Blocks.Add(CreateContentParagraph("333.2"));
                        tableRow.Cells.Add(tc3);
                    }

                    {
                        NTableRow tableRow = new NTableRow();
                        table.Rows.Add(tableRow);

                        NTableCell tc1 = CreateTableCellWithBorder();
                        tc1.Blocks.Add(CreateContentParagraph("Post Trade Service"));
                        tableRow.Cells.Add(tc1);

                        NTableCell tc2 = CreateTableCellWithBorder();
                        tc2.Blocks.Add(CreateContentParagraph("94.7"));
                        tableRow.Cells.Add(tc2);

                        NTableCell tc3 = CreateTableCellWithBorder();
                        tc3.Blocks.Add(CreateContentParagraph("129.1"));
                        tableRow.Cells.Add(tc3);
                    }

                    {
                        NTableRow tableRow = new NTableRow();
                        table.Rows.Add(tableRow);

                        NTableCell tc1 = CreateTableCellWithBorder();
                        tc1.Blocks.Add(CreateContentParagraph("Information Services "));
                        tableRow.Cells.Add(tc1);

                        NTableCell tc2 = CreateTableCellWithBorder();
                        tc2.Blocks.Add(CreateContentParagraph("281.0"));
                        tableRow.Cells.Add(tc2);

                        NTableCell tc3 = CreateTableCellWithBorder();
                        tc3.Blocks.Add(CreateContentParagraph("373.0"));
                        tableRow.Cells.Add(tc3);
                    }

                    {
                        NTableRow tableRow = new NTableRow();
                        table.Rows.Add(tableRow);

                        NTableCell tc1 = CreateTableCellWithBorder();
                        tc1.Blocks.Add(CreateContentParagraph("Technology Services"));
                        tableRow.Cells.Add(tc1);

                        NTableCell tc2 = CreateTableCellWithBorder();
                        tc2.Blocks.Add(CreateContentParagraph("47.3"));
                        tableRow.Cells.Add(tc2);

                        NTableCell tc3 = CreateTableCellWithBorder();
                        tc3.Blocks.Add(CreateContentParagraph("66.0"));
                        tableRow.Cells.Add(tc3);
                    }

                    {
                        NTableRow tableRow = new NTableRow();
                        table.Rows.Add(tableRow);

                        NTableCell tc1 = CreateTableCellWithBorder();
                        tc1.Blocks.Add(CreateContentParagraph("Other"));
                        tableRow.Cells.Add(tc1);

                        NTableCell tc2 = CreateTableCellWithBorder();
                        tc2.Blocks.Add(CreateContentParagraph("87.2"));
                        tableRow.Cells.Add(tc2);

                        NTableCell tc3 = CreateTableCellWithBorder();
                        tc3.Blocks.Add(CreateContentParagraph("90.4"));
                        tableRow.Cells.Add(tc3);
                    }
                }
            }
        }
コード例 #29
0
        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);
            }
        }