示例#1
0
        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();
        }
示例#2
0
 private void HomeButton_Click(object sender, EventArgs e)
 {
     cart.Hide();
     store.Show();
 }