Example #1
0
        private void FarmPanelUserControl_Click(object o, EventArgs a)
        {
            FarmPanelUserControl p = (FarmPanelUserControl)o;

            _selectedPanel = Convert.ToInt32(p.Tag);
            CropLoad();
            LoadChart1();
        }
Example #2
0
        void FarmLoad()
        {
            foreach (FarmInfo farm in Farms)
            {
                #region Create Farm Panel
                FarmPanelUserControl farmPanel = new FarmPanelUserControl();
                farmPanel.Tag = _tag;
                _tag++;
                farmPanel.Click        += FarmPanelUserControl_Click;
                farmPanel.AutoSize      = false;
                farmPanel.FarmName.Text = farm.Farm;
                myFarmsFlowPanel.Controls.Add(farmPanel);
                #endregion
                foreach (CropInfo crop in farm.Crops)
                {
                    #region Create Crop Panel
                    Panel cp = new Panel
                    {
                        BackColor = System.Drawing.Color.FromArgb(180, 9, 105, 54),
                        Location  = new Point(0, 50),
                        ForeColor = System.Drawing.Color.White,
                        AutoSize  = false,
                        Size      = new Size(80, 95),
                    };
                    cp.Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, cp.Width, cp.Height, 20, 20));
                    var cropImage = Properties.Resources.natural_food_80px;
                    if (crop.Crop.ToLower() == "potato")
                    {
                        cropImage = Properties.Resources.potato_80px;
                    }
                    if (crop.Crop.ToLower() == "carrot")
                    {
                        cropImage = Properties.Resources.carrot_80px;
                    }
                    if (crop.Crop.ToLower() == "apple")
                    {
                        cropImage = Properties.Resources.apple_80px;
                    }
                    if (crop.Crop.ToLower() == "onion")
                    {
                        cropImage = Properties.Resources.onion_80px;
                    }
                    if (crop.Crop.ToLower() == "garlic")
                    {
                        cropImage = Properties.Resources.garlic_80px;
                    }
                    if (crop.Crop.ToLower() == "tomato")
                    {
                        cropImage = Properties.Resources.tomato_80px;
                    }
                    if (crop.Crop.ToLower() == "rice")
                    {
                        cropImage = Properties.Resources.rice_bowl_80px;
                    }
                    if (crop.Crop.ToLower() == "wheat")
                    {
                        cropImage = Properties.Resources.wheat_80px;
                    }
                    if (crop.Crop.ToLower() == "bell pepper")
                    {
                        cropImage = Properties.Resources.paprika_80px;
                    }
                    PictureBox cropPic = new PictureBox
                    {
                        Image     = cropImage,
                        SizeMode  = PictureBoxSizeMode.StretchImage,
                        Size      = new Size(70, 70),
                        Location  = new Point(5, 10),
                        BackColor = System.Drawing.Color.Transparent
                    };
                    Label nName = new Label
                    {
                        Font      = new Font("Arial", 10, FontStyle.Bold),
                        Text      = crop.Crop,
                        Location  = new Point(3, 78),
                        ForeColor = System.Drawing.Color.White,
                        AutoSize  = true,
                        BackColor = System.Drawing.Color.Transparent
                    };
                    #endregion

                    farmPanel.flowPanel.Controls.Add(cp);
                    cp.Controls.Add(cropPic);
                    cp.Controls.Add(nName);
                }
            }
            SetScrollBar();
        }