コード例 #1
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="bookInfo"></param>
 public NBookInfo(NBookInfo bookInfo)
 {
     Name        = bookInfo.Name;
     Author      = bookInfo.Author;
     Description = bookInfo.Description;
     Image       = (NImage)bookInfo.Image.DeepClone();
     Price       = bookInfo.Price;
 }
コード例 #2
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);
        }
コード例 #3
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()));
        }
コード例 #4
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);
        }