private void changeToDate(DateTime date) { this.periodContents.Width = 310; this.TaskAdd.Visible = false; this.TaskTake.Visible = false; this.TaskEdit.Visible = false; Program.CalendarDay day = Program.getProgram().getEventsForDate(date); Program.PeriodStruct currentPeriod = Program.getProgram().getPeriodAtCurrentTime(day); this.toolTip2.SetToolTip(this.periodContents, ""); string timeTo = " - " + (currentPeriod.startTime - System.DateTime.Now).ToString().Substring(0, 5); if (currentPeriod.startTime.Date == System.DateTime.Now.Date) { if (currentPeriod.startTime <= System.DateTime.Now) { timeTo = " - Now"; } } else { timeTo = ""; } if (Properties.Settings.Default.TimeTo) { title.Text = currentPeriod.name + " " + currentPeriod.room + timeTo; } else { title.Text = currentPeriod.name + " " + currentPeriod.room; } periodContents.Text = ""; for (int i = 0; i < day.names.Count; i++) { periodContents.Text += day.names[i] + " " + day.rooms[i]; if (Properties.Settings.Default.Times) { if (Properties.Settings.Default.AMPM) { periodContents.Text += " - " + day.times[i]; } else { periodContents.Text += " - " + day.times[i].Replace("AM", "").Replace("PM", ""); } if (Properties.Settings.Default.Ends) { if (Properties.Settings.Default.AMPM) { periodContents.Text += " - " + day.ends[i]; } else { periodContents.Text += " - " + day.ends[i].Replace("AM", "").Replace("PM", ""); } } } periodContents.Text += System.Environment.NewLine; } }
public void changeDate() { Program.CalendarDay day = Program.getProgram().getEventsForDate(System.DateTime.Now); Program.PeriodStruct currentPeriod = Program.getProgram().getPeriodAtCurrentTime(day); string timeTo = (currentPeriod.startTime - System.DateTime.Now).ToString().Substring(0, 5); if (currentPeriod.startTime <= System.DateTime.Now) { timeTo = "Now"; } int biggest = 100; if (Properties.Settings.Default.TimeTo) { title.Text = currentPeriod.name + " " + currentPeriod.room + " - " + timeTo; } else { title.Text = currentPeriod.name + " " + currentPeriod.room; } Font bigFont = new Font("Microsoft Sans Serif", 10.0f, FontStyle.Bold, GraphicsUnit.Pixel); Font smallFont = new Font("Microsoft Sans Serif", 8.0f, GraphicsUnit.Pixel); if (getWidth(title.Text, bigFont) >= biggest) { biggest = getWidth(title.Text, bigFont); } periodContents.Text = ""; string line = ""; for (int i = 0; i < day.names.Count; i++) { line = ""; line += day.names[i] + " " + day.rooms[i]; if (Properties.Settings.Default.Times) { if (Properties.Settings.Default.AMPM) { line += " - " + day.times[i]; } else { line += " - " + day.times[i].Replace("AM", "").Replace("PM", ""); } if (Properties.Settings.Default.Ends) { if (Properties.Settings.Default.AMPM) { line += " - " + day.ends[i]; } else { line += " - " + day.ends[i].Replace("AM", "").Replace("PM", ""); } } } if (getWidth(line, smallFont) >= biggest) { biggest = getWidth(line, smallFont); } periodContents.Text += line + System.Environment.NewLine; } Height = (30 * day.names.Count) + 40; title.Text += " " + biggest; Width = (int)((float)biggest * 2.1f) + 40; periodContents.Height = (30 * day.names.Count) + 64; }