void loadTaskList() { Console.WriteLine(day.ToString() + " " + month.ToString() + " " + year.ToString()); //temp output string string allTasks = ""; List <Task> tempTasks = cal.GetTasks(day, month, year); foreach (Task t in tempTasks) { //format start time string string sT = t.taskTime.startHour.ToString() + ":"; if (t.taskTime.startMin < 10) { sT += "0" + t.taskTime.startMin.ToString(); } else { sT += t.taskTime.startMin.ToString(); } if (t.taskTime.startAmPm) { sT += "am"; } else { sT += "pm"; } //format end time string string eT = t.taskTime.endHour.ToString() + ":"; if (t.taskTime.endMin < 10) { eT += "0" + t.taskTime.endMin.ToString(); } else { eT += t.taskTime.endMin.ToString(); } if (t.taskTime.endAmPm) { eT += " am"; } else { eT += " pm"; } allTasks += "Name: " + t.taskName + "\n Time: " + sT + " -> " + eT + "\n Location: " + t.taskLocation + "\n\t\t Description: " + t.taskDescription + "\n\n"; } Console.WriteLine(allTasks); //set tasks value tasks.Text = allTasks; }
void loadMonth(MonthNames m) { // if buttons in temp button array, delete them if (buttons.Count > 0) { foreach (Button b in buttons) { //this.buttons.Remove(b); this.Controls.Remove(b); //buttons.Clear(); } } // if labels in temp label array, delete them if (labels.Count > 0) { foreach (Label l in labels) { this.Controls.Remove(l); } } //set current month currentMonth = m; //calculate day and shift value, Sun = 0, Sat = 6 int dayShift = ((int)(cal.year.months[(int)currentMonth - 1].days[0].dow)); // for every day in month add button in form1 for ( int d = 0 + dayShift; //get starting day and shift appropriately d < cal.year.months[(int)currentMonth - 1].numDays + dayShift; // total days + shift value d++ ) { Button btn = new Button(); btn.Text = cal.year.months[(int)currentMonth - 1].days[d - dayShift].dayNum.ToString(); btn.Width = daySize - 4; btn.Height = daySize - 4; btn.TextAlign = ContentAlignment.TopLeft; btn.Location = new Point( daySize * (d % 7) + boarder, // x position value daySize * (d / 7) + boarder * 3 // y position value ); //get rid of boarder and change color btn.BackColor = System.Drawing.Color.Ivory; btn.FlatStyle = FlatStyle.Flat; btn.FlatAppearance.BorderSize = 0; btn.Font = new Font("Microsoft Sans serif", 16); // highlight current day in a green color if (System.DateTime.Now.Day == d + 1 - dayShift && System.DateTime.Now.Month == (int)currentMonth && System.DateTime.Now.Year == currentYear) { btn.BackColor = System.Drawing.Color.LightGreen; } // check if day has a task int numTasks = cal.NumTask(d + 1 - dayShift, currentMonth, currentYear); if (numTasks > 0) { // Add indicator for task at this day Button taskLabel = new Button(); taskLabel.Location = new Point( daySize * (d % 7) + boarder + (daySize / 2), // x position value daySize * (d / 7) + boarder * 3 + (daySize / 2) // y position value ); taskLabel.Text = numTasks.ToString(); taskLabel.Width = daySize / 2 - 3; taskLabel.Height = daySize / 2 - 3; //get rid of boarder and change color taskLabel.BackColor = System.Drawing.Color.SeaGreen; taskLabel.FlatStyle = FlatStyle.Flat; taskLabel.FlatAppearance.BorderSize = 0; taskLabel.ForeColor = System.Drawing.Color.White; taskLabel.Font = new Font("Microsoft Sans serif", 12); taskLabel.Name = (d + 1 - dayShift).ToString(); this.Controls.Add(taskLabel); this.buttons.Add(taskLabel); taskLabel.Click += new EventHandler(this.buttonTasks_Click); } btn.Click += new EventHandler(this.buttonDay_Click); this.Controls.Add(btn); //add day buttons to holder list buttons.Add(btn); } //Update labels MonthLabel.Text = currentMonth.ToString(); YearLabel.Text = currentYear.ToString(); //Display Days of week for (int i = 0; i < 7; i++) { Label lbl = new Label(); lbl.Text = ((DayNames)i).ToString(); lbl.Width = daySize; lbl.TextAlign = ContentAlignment.TopCenter; lbl.Location = new Point( daySize * i + boarder, 2 * boarder ); lbl.BackColor = System.Drawing.Color.Transparent; this.Controls.Add(lbl); } }