Example #1
0
        public StorePanel(CartPanel reference)
        {
            cartPanelRef = reference;

            this.Name        = "Store";
            this.Dock        = DockStyle.Fill;
            this.ColumnCount = 2;
            this.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 300));
            this.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 40));

            itemPanel = new TableLayoutPanel
            {
                Dock       = DockStyle.Fill,
                AutoScroll = true,
            };
            this.Controls.Add(itemPanel);

            descriptionPanel = new TableLayoutPanel
            {
                RowCount = 4,
                Dock     = DockStyle.Fill,
            };
            descriptionPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
            descriptionPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 10));
            descriptionPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 40));
            descriptionPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 60));

            this.Controls.Add(descriptionPanel);

            descriptionPicture = new PictureBox {
                Dock        = DockStyle.Fill, SizeMode = PictureBoxSizeMode.StretchImage,
                BorderStyle = BorderStyle.Fixed3D,
            };
            descriptionPanel.Controls.Add(descriptionPicture);

            nameLabel = new Label {
                Dock      = DockStyle.Fill, TextAlign = ContentAlignment.MiddleCenter,
                FlatStyle = FlatStyle.Popup, BackColor = Color.WhiteSmoke
            };
            descriptionPanel.Controls.Add(nameLabel);

            descriptionLabel = new Label {
                Dock      = DockStyle.Fill, TextAlign = ContentAlignment.TopLeft,
                FlatStyle = FlatStyle.Popup, BackColor = Color.WhiteSmoke
            };
            descriptionPanel.Controls.Add(descriptionLabel);

            addToCart = new Button {
                Text = "Add to cart", FlatStyle = FlatStyle.Popup, TextAlign = ContentAlignment.MiddleCenter,
                Dock = DockStyle.Fill,
            };
            descriptionPanel.Controls.Add(addToCart);
        }
        public MyForm()
        {
            this.MinimumSize = new Size(800, 500);
            this.Font        = new Font("Sans serif", 13);

            #region Main form panels

            mainPanel = new TableLayoutPanel
            {
                Margin          = new Padding(0, 0, 0, 0),
                Dock            = DockStyle.Fill,
                BackColor       = Color.WhiteSmoke,
                CellBorderStyle = TableLayoutPanelCellBorderStyle.Single,
                RowCount        = 2,
                ColumnCount     = 2,
            };
            mainPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 120));
            mainPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 70));
            mainPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 60));
            mainPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 70));
            Controls.Add(mainPanel);


            cart  = new CartPanel();
            store = new StorePanel(cart);
            mainPanel.Controls.Add(store, 1, 1);
            mainPanel.Controls.Add(cart, 1, 1);
            cart.Hide();

            topLeftSidePanel = new TableLayoutPanel
            {
                Margin    = new Padding(0, 0, 0, 0),
                Dock      = DockStyle.Fill,
                BackColor = Color.Bisque,
                RowCount  = 2,
            };
            topLeftSidePanel.RowStyles.Add(new RowStyle(SizeType.Percent, 60));
            topLeftSidePanel.RowStyles.Add(new RowStyle(SizeType.Percent, 40));
            mainPanel.Controls.Add(topLeftSidePanel);

            Button searchButton = new Button {
                Text      = "Filter items.", Dock = DockStyle.Fill,
                TextAlign = ContentAlignment.MiddleCenter, BackColor = Color.WhiteSmoke, FlatStyle = FlatStyle.Popup,
            };
            topLeftSidePanel.Controls.Add(searchButton);

            searchBox = new TextBox
            {
                Dock = DockStyle.Fill,
            };
            topLeftSidePanel.Controls.Add(searchBox);

            topRightSidePanel = new TableLayoutPanel
            {
                Margin      = new Padding(0, 0, 0, 0),
                ColumnCount = 3,
                Dock        = DockStyle.Fill,
                BackColor   = Color.BlanchedAlmond,
            };
            topRightSidePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 60));
            topRightSidePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20));
            topRightSidePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20));
            mainPanel.Controls.Add(topRightSidePanel);

            Label shopTitle = new Label
            {
                Text      = "[ SHOP TITLE ]",
                Dock      = DockStyle.Fill,
                TextAlign = ContentAlignment.MiddleCenter
            };
            topRightSidePanel.Controls.Add(shopTitle);

            Button storeButton = new Button
            {
                Text      = "Store",
                Dock      = DockStyle.Fill,
                FlatStyle = FlatStyle.Popup,
                BackColor = Color.LightBlue,
            };
            topRightSidePanel.Controls.Add(storeButton);
            storeButton.Click += ChangeStoreView_Click;

            Button cartButton = new Button
            {
                Text      = "Cart",
                Dock      = DockStyle.Fill,
                FlatStyle = FlatStyle.Popup,
                BackColor = Color.LightBlue,
            };
            topRightSidePanel.Controls.Add(cartButton);
            cartButton.Click += ChangeStoreView_Click;

            bottomLeftSidePanel = new TableLayoutPanel
            {
                Dock      = DockStyle.Fill,
                Margin    = new Padding(0, 0, 0, 0),
                BackColor = Color.Bisque,
                RowCount  = 2,
            };
            bottomLeftSidePanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 120));
            bottomLeftSidePanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 80));
            bottomLeftSidePanel.RowStyles.Add(new RowStyle(SizeType.AutoSize, 100));
            mainPanel.Controls.Add(bottomLeftSidePanel);

            homeButton = new Button {
                Text = "Home", Dock = DockStyle.Fill, BackColor = Color.LightBlue, FlatStyle = FlatStyle.Popup,
            };
            homeButton.Click += HomeButton_Click;
            bottomLeftSidePanel.Controls.Add(homeButton);

            #endregion

            QueryFromCSVToList();
        }