private void GetDayEvents(int year, int month, int day, int weekDay) { if (calendar != null) { EventsList dayEvents = new EventsList(); foreach (Event appointment in calendar.Events) { int appointmentYear = appointment.Date.Year; int appointmentMonth = appointment.Date.Month; int appointmentDay = appointment.Date.Day; bool appoinmentIsOnActualDay = day == appointmentDay && month == appointmentMonth && year == appointmentYear; bool isThisUserAppointment = appointment.Owner.Name == user.Name; if (appointment.Participants != null) { foreach (User participant in appointment.Participants.Users) { Console.WriteLine(participant.Name); if (participant.Name == user.Name) { isThisUserAppointment = true; } } } if (appoinmentIsOnActualDay && isThisUserAppointment) { dayEvents.Events.Add(appointment); } } SetDayEvents(dayEvents, weekDay + positionUnit); } }
private void GetMonthEvents() { if (calendar != null) { monthEvents = new EventsList(); foreach (Event appointment in calendar.Events) { bool appointmentIsThisMonth = appointment.Date.Month == month && appointment.Date.Year == year; bool isThisUserAppointment = appointment.Owner.Name == user.Name; if (appointment.Participants != null) { foreach (User participant in appointment.Participants.Users) { if (participant.Name == user.Name) { isThisUserAppointment = true; } } } if (appointmentIsThisMonth && isThisUserAppointment) { monthEvents.Events.Add(appointment); } } } }
public MainWindow(int passedMonth, int passedYear, User passedUser) { calendar = util.ReadEventsSerialFile(); InitializeComponent(); year = passedYear; month = passedMonth; if (passedUser == null) { passedUser = new User(defaultUserName); } user = passedUser; buttonLastMonth.Click += new RoutedEventHandler(LastMonthBtn_Click); buttonNextMonth.Click += new RoutedEventHandler(NextMonthBtn_Click); buttonWeeklyView.Click += new RoutedEventHandler(WeeklyViewBtn_Click); buttonNewEvent.Click += new RoutedEventHandler(NewEventBtn_Click); textBlockUserName.Text = string.Format(CultureInfo.InvariantCulture, "Hola, {0}", user.Name); textBlocksDaysOfMonth = new TextBlock[] { this.TextBlockDay1, this.TextBlockDay2, this.TextBlockDay3, this.TextBlockDay4, this.TextBlockDay5, this.TextBlockDay6, this.TextBlockDay7, this.TextBlockDay8, this.TextBlockDay9, this.TextBlockDay10, this.TextBlockDay11, this.TextBlockDay12, this.TextBlockDay13, this.TextBlockDay14, this.TextBlockDay15, this.TextBlockDay16, this.TextBlockDay17, this.TextBlockDay18, this.TextBlockDay19, this.TextBlockDay20, this.TextBlockDay21, this.TextBlockDay22, this.TextBlockDay23, this.TextBlockDay24, this.TextBlockDay25, this.TextBlockDay26, this.TextBlockDay27, this.TextBlockDay28, this.TextBlockDay29, this.TextBlockDay30, this.TextBlockDay31, this.TextBlockDay32, this.TextBlockDay33, this.TextBlockDay34, this.TextBlockDay35, this.TextBlockDay36, this.TextBlockDay37, this.TextBlockDay38, this.TextBlockDay39, this.TextBlockDay40, this.TextBlockDay41, this.TextBlockDay42 }; listItemsControlEvents = new List <ItemsControl>(); SetDaysOfMonth(); }
private void buttonEvents_Click(object sender, RoutedEventArgs e) { MyEvents myEvents = new MyEvents(user); myEvents.ShowDialog(); calendar = util.ReadEventsSerialFile(); SetDaysOfMonth(); }
private void NewEventBtn_Click(Object sender, EventArgs e) { NewEvent newEvent = new NewEvent(user); newEvent.ShowDialog(); calendar = util.ReadEventsSerialFile(); SetDaysOfMonth(); }
void ReadSerialFile() { if (File.Exists("Events.txt")) { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("Events.txt", FileMode.Open, FileAccess.Read); calendar = (EventsList)formatter.Deserialize(stream); } }
public MyEvents(User passedUser) { InitializeComponent(); ButtonDelete.IsEnabled = false; calendar = util.ReadEventsSerialFile(); allUsers = util.ReadUsersSerialFile(); user = passedUser; FilterCalendar(); AddEventsToListBox(); listBoxAllUsers.ItemsSource = allUsers.Users; }
private void buttonEvents_Click(object sender, RoutedEventArgs e) { MyEvents myEvents = new MyEvents(user); myEvents.ShowDialog(); calendar = util.ReadEventsSerialFile(); Week newWeekView = new Week(month, year, user); newWeekView.Show(); this.Close(); }
private void NewEventBtn_Click(Object sender, EventArgs e) { NewEvent newEvent = new NewEvent(user); newEvent.ShowDialog(); calendar = util.ReadEventsSerialFile(); Week newWeekView = new Week(month, year, user); newWeekView.Show(); this.Close(); }
void GetMonthEvents() { if (calendar != null) { monthEvents = new EventsList(); foreach (Event appointment in calendar.events) { if (appointment.date.Year == year && appointment.date.Month == month) { monthEvents.events.Add(appointment); } } } }
public NewEvent(User passedUser) { Utils util = new Utils(); calendar = util.ReadEventsSerialFile(); allUsers = util.ReadUsersSerialFile(); user = passedUser; InitializeComponent(); SetListBoxItems(); DatePickerEventDate.SelectedDate = DateTime.Today; ButtonCancel.Click += new RoutedEventHandler(CancelBtn_Click); ButtonSave.Click += new RoutedEventHandler(SaveBtn_Click); }
public EventsList ReadEventsSerialFile() { if (File.Exists("Events.txt")) { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("Events.txt", FileMode.Open, FileAccess.Read); EventsList events = (EventsList)formatter.Deserialize(stream); stream.Close(); return(events); } else { return(new EventsList()); } }
private void SetDayEvents(EventsList events, int weekDay) { for (int hour = 0; hour < 24; hour++) { ItemsControl itemsControlEvents = new ItemsControl(); itemControlListEvents.Add(itemsControlEvents); GridHours.Children.Add(itemsControlEvents); Grid.SetColumn(itemsControlEvents, weekDay); Grid.SetRow(itemsControlEvents, hour + positionUnit); foreach (Event appointment in events.Events) { int startHour = int.Parse(appointment.Start[hourIndex], NumberFormatInfo.InvariantInfo); int startMinute = int.Parse(appointment.Start[minuteIndex], NumberFormatInfo.InvariantInfo); int endHour = int.Parse(appointment.End[hourIndex], NumberFormatInfo.InvariantInfo); int endMinute = int.Parse(appointment.End[minuteIndex], NumberFormatInfo.InvariantInfo); TextBlock textBlockEvent = new TextBlock(); bool isStartHour = startHour == hour; bool isEndHour = endHour == hour && endMinute > minuteZero; bool isLastHour = endHour == hour + oneHour && endMinute == minuteZero; bool isMiddleHour = startHour <hour && endHour> hour; if (isStartHour) { textBlockEvent.Text = String.Format(CultureInfo.InvariantCulture, "{0} - Desde {1}:{2}", appointment.Name, appointment.Start[hourIndex], appointment.Start[minuteIndex]); itemsControlEvents.Items.Add(textBlockEvent); } else if (isEndHour) { textBlockEvent.Text = String.Format(CultureInfo.InvariantCulture, "{0} - Hasta {1}:{2}", appointment.Name, appointment.End[hourIndex], appointment.End[minuteIndex]); itemsControlEvents.Items.Add(textBlockEvent); } else if (isLastHour) { textBlockEvent.Text = String.Format(CultureInfo.InvariantCulture, "{0} - Hasta {1}:{2}", appointment.Name, appointment.End[hourIndex], appointment.End[minuteIndex]); itemsControlEvents.Items.Add(textBlockEvent); } else if (isMiddleHour) { textBlockEvent.Text = appointment.Name; itemsControlEvents.Items.Add(textBlockEvent); } } } }
void GetDayEvents(int year, int month, int day, int weekDay) { if (calendar != null) { EventsList dayEvents = new EventsList(); foreach (Event appoinment in calendar.events) { int appointmentYear = appoinment.date.Year; int appointmentMonth = appoinment.date.Month; int appointmentDay = appoinment.date.Day; if (year == appointmentYear && month == appointmentMonth && day == appointmentDay) { dayEvents.events.Add(appoinment); } } SetDayEvents(dayEvents, weekDay + positionUnit); } }
void SetDayEvents(EventsList events, int weekDay) { for (int hour = 0; hour < 24; hour++) { ItemsControl itemsControlEvents = new ItemsControl(); eventsList.Add(itemsControlEvents); GridHours.Children.Add(itemsControlEvents); Grid.SetColumn(itemsControlEvents, weekDay); Grid.SetRow(itemsControlEvents, hour + positionUnit); foreach (Event appointment in events.events) { int startHour = int.Parse(appointment.start[hourIndex]); int startMinute = int.Parse(appointment.start[minuteIndex]); int endHour = int.Parse(appointment.end[hourIndex]); int endMinute = int.Parse(appointment.end[minuteIndex]); TextBlock textBlockEvent = new TextBlock(); if (startHour == hour) { textBlockEvent.Text = appointment.name + " - Desde " + appointment.start[hourIndex] + ":" + appointment.start[minuteIndex]; itemsControlEvents.Items.Add(textBlockEvent); } else if (endHour == hour && endMinute > minuteZero) { textBlockEvent.Text = appointment.name + " - Hasta " + appointment.end[hourIndex] + ":" + appointment.end[minuteIndex]; itemsControlEvents.Items.Add(textBlockEvent); } else if (endHour == hour + oneHour && endMinute == minuteZero) { textBlockEvent.Text = appointment.name + " - Hasta " + appointment.end[hourIndex] + ":" + appointment.end[minuteIndex]; itemsControlEvents.Items.Add(textBlockEvent); } else if (startHour < hour && endHour > hour) { textBlockEvent.Text = appointment.name; itemsControlEvents.Items.Add(textBlockEvent); } } } }
public Week(int passedMonth, int passedYear, User passedUser) { month = passedMonth; year = passedYear; if (passedUser == null) { passedUser = new User(defaultUserName); } user = passedUser; calendar = util.ReadEventsSerialFile(); InitializeComponent(); daysOfWeekTextBlocks = new TextBlock[] { TextBlockMonday, TextBlockTuesday, TextBlockWednesday, TextBlockThursday, TextBlockFriday, TextBlockSaturday, TextBlockSunday }; ButtonMonthlyView.Click += new RoutedEventHandler(MonthlyViewBtn_Click); ButtonNextWeek.Click += new RoutedEventHandler(SetNextWeek_Click); ButtonLastWeek.Click += new RoutedEventHandler(SetLastWeek_Click); ButtonNewEvent.Click += new RoutedEventHandler(NewEventBtn_Click); textBlockUserName.Text = string.Format(CultureInfo.InvariantCulture, "Hola, {0}", user.Name); itemControlListEvents = new List <ItemsControl>(); SetFirstWeek(); }