This is the basic class that I am trying to display:
public class Day
{
public DateTime Date { get; private set; }
public SpecialDay SpecialDay { get; set; }
public DateTime TimeIn { get; private set; }
public DateTime TimeOut { get; private set; }
public DayOfWeek DayOfWeek
public TimeSpan TotalHours
}
It is contained inside a list in in following class:
public class Month
{
private int _month { get; set; }
private int _year { get; set; }
public DateTime Date
public List<Day> Days { get; private set; }
public TimeSpan TotalHoursInMonth
}
This is the load function of the main display form
private void MonthDataForm_Load(object sender, EventArgs e)
{
int bottomOfPreviousDay = -1;
foreach (var item in MonthDisplaying.Days)
{
DayView dayDisplay = new DayView(item);
if (bottomOfPreviousDay == -1)
{
dayDisplay.Top = this.Top + 10;
}
else
{
dayDisplay.Top = bottomOfPreviousDay + 2;
}
bottomOfPreviousDay = dayDisplay.Bottom;
this.Controls.Add(dayDisplay);
}
this.WindowState = FormWindowState.Maximized;
}
The form shows a list of days for a given month like so
Each line is a separate instance of the Day
class, and in the next stage of development there will be buttons to perform different actions on each instance.
Is there a better way for calculating the position of the user controls that are being added? I don't like the way the if
/else
looks but I am not sure how else to do it.