Beispiel #1
0
            public void PlantNameEmergency(PlantaLibrary.UserDashboard lib)
            {
                string        date           = DateTime.Today.DayOfYear.ToString();
                List <string> lastWatered    = lib.GetLastWatered();
                List <string> nickName       = lib.GetNick();
                List <string> interval       = lib.GetDays();
                List <int>    needWater      = new List <int>();
                List <int>    emergencyWater = new List <int>();

                for (int i = 0; i < nickName.Count; i++)
                {
                    DateTime watered    = DateTime.Parse(lastWatered[i]);
                    int      difference = watered.DayOfYear - DateTime.Today.DayOfYear;
                    if (difference - int.Parse(interval[i]) == 0)
                    {
                        needWater.Add(i);
                    }
                    else if (difference - int.Parse(interval[i]) < 0)
                    {
                        emergencyWater.Add(i);
                    }
                }
                lib.SetEmergencyList(emergencyWater);
                lib.SetWaterToday(needWater);
            }
        public PlantaLibrary.UserDashboard showDashboard(string fileName)
        {
            PlantaDatabase db = new PlantaDatabase();

            PlantaLibrary.UserDashboard lib   = new PlantaLibrary.UserDashboard();
            PlantaCalc.UserDashboard    logic = new PlantaCalc.UserDashboard();
            db.userPlants(fileName, lib);
            logic.PlantNameEmergency(lib);


            return(lib);
        }
Beispiel #3
0
 public void userPlants(string fileName, PlantaLibrary.UserDashboard lib)
 {
     GetList("..\\..\\..\\" + fileName + ".txt");
     for (int i = 0; i < allFiles.Count; i++)
     {
         string[] files      = allFiles.ToArray();
         string[] userPlants = files[i].Split('+');
         lib.SetNick(userPlants[0]);
         lib.SetName(userPlants[1]);
         lib.SetInterval(userPlants[2]);
         lib.SetLastWatered(userPlants[3]);
         //lib.SetIconNr(userPlants[4]);
     }
 }
Beispiel #4
0
        private void showDashboard()
        {
            this.Panel_content.Controls.Clear();
            this.lbl_currentTab.Text = "Dashboard";
            string        fileName = lbl_username.Text;
            PlantaDisplay ui       = new PlantaDisplay();


            PlantaLibrary.UserDashboard lib = ui.showDashboard(fileName);

            List <int>    waterEmergency = lib.GetWaterEmergency();
            List <int>    waterToday     = lib.GetWaterToday();
            List <string> plantNick      = lib.GetNick();
            GroupBox      groupbox1      = new GroupBox();
            GroupBox      groupbox2      = new GroupBox();
            GroupBox      groupbox3      = new GroupBox();

            groupbox1.Location = new Point(10, 10);
            groupbox2.Location = new Point(10, 80);
            groupbox3.Location = new Point(10, 160);

            groupbox1.Size = new Size(600, 100);
            groupbox2.Size = new Size(600, 120);
            groupbox3.Size = new Size(600, 140);



            Label labelPlant1 = new Label();
            Label labelPlant2 = new Label();
            Label labelPlant3 = new Label();

            labelPlant1.Location = new Point(105, 45);
            labelPlant2.Location = new Point(105, 45);
            labelPlant3.Location = new Point(105, 45);
            labelPlant1.Font     = new Font("Segou UI Emoji", 14);
            labelPlant2.Font     = new Font("Segou UI Emoji", 14);
            labelPlant3.Font     = new Font("Segou UI Emoji", 14);
            PictureBox picBox1 = new PictureBox();
            PictureBox picBox2 = new PictureBox();
            PictureBox picBox3 = new PictureBox();

            picBox1.Location = new Point(5, 10);
            picBox2.Location = new Point(5, 10);
            picBox3.Location = new Point(5, 10);
            picBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            picBox2.SizeMode = PictureBoxSizeMode.StretchImage;
            picBox3.SizeMode = PictureBoxSizeMode.StretchImage;
            picBox1.Height   = 80;
            picBox1.Width    = 80;
            picBox2.Height   = 80;
            picBox2.Width    = 80;
            picBox3.Height   = 80;
            picBox3.Width    = 80;
            Button button1 = new Button();
            Button button2 = new Button();
            Button button3 = new Button();

            button1.Location  = new Point(430, 27);
            button2.Location  = new Point(430, 43);
            button3.Location  = new Point(430, 43);
            button1.Text      = "Water me";
            button2.Text      = "Water me";
            button3.Text      = "Water me";
            button1.Size      = new Size(100, 50);
            button2.Size      = new Size(100, 50);
            button3.Size      = new Size(100, 50);
            button1.BackColor = Color.LightSkyBlue;
            button2.BackColor = Color.LightSkyBlue;
            button3.BackColor = Color.LightSkyBlue;
            button1.Click    += new EventHandler(button1_Clicked);
            button2.Click    += new EventHandler(button2_Clicked);
            button3.Click    += new EventHandler(button3_Clicked);
            int  boxLimit = 0;
            int  count    = 0;
            bool isEmpty  = !waterEmergency.Any();

            if (!isEmpty)
            {
                for (int i = 0; i < plantNick.Count; i++)
                {
                    if (waterEmergency[count] == i && count < 1)
                    {
                        labelPlant1.Text = plantNick[i];
                        groupbox1.Controls.Add(labelPlant1);
                        picBox1.Image = Properties.Resources.Sprout;
                        groupbox1.Controls.Add(picBox1);
                        groupbox1.Controls.Add(button1);
                        groupboxIndex1 = plantNick[i];
                        count++;
                    }
                }
            }

            count   = 0;
            isEmpty = !waterToday.Any();
            if (!isEmpty)
            {
                for (int i = 0; i < plantNick.Count; i++)
                {
                    if (waterToday[count] == i && boxLimit < 1)
                    {
                        labelPlant2.Text = plantNick[i];
                        groupbox2.Controls.Add(labelPlant2);
                        picBox2.Image = Properties.Resources.Plant_rank;
                        groupbox2.Controls.Add(picBox2);
                        groupbox2.Controls.Add(button2);
                        groupboxIndex2 = plantNick[i];
                        boxLimit++;
                        continue;
                    }
                    if (waterToday[count] == i && boxLimit < 1)
                    {
                        labelPlant3.Text = plantNick[i];
                        groupbox3.Controls.Add(labelPlant3);
                        picBox3.Image = Properties.Resources.Seed_rank;
                        groupbox3.Controls.Add(picBox3);
                        groupbox3.Controls.Add(button3);
                        groupboxIndex3 = plantNick[i];
                        boxLimit++;
                        continue;
                    }
                }
            }


            this.Panel_content.Controls.Add(groupbox1);
            this.Panel_content.Controls.Add(groupbox2);
            this.Panel_content.Controls.Add(groupbox3);
        }