private void addToolStripMenuItem_Click(object sender, EventArgs e) { BacnetweekNDay bwd = new BacnetweekNDay(1, 1); CalendarEntryEdit Edit = new CalendarEntryEdit(bwd); Edit.ShowDialog(); if (Edit.OutOK) { object o = Edit.GetBackEntry(); listEntries.Items.Add(o); calendarEntries.Entries.Add(o); SetCalendarDisplayDate(CalendarStartRequested); } }
public void AddEntry(BacnetweekNDay bwd) { CalenarEntry.Entries.Add(bwd); }
public object GetBackEntry() { if (Entry is BacnetDate) { BacnetDate bd = new BacnetDate(); if (wday.SelectedIndex == 7) { bd.wday = 255; } else { bd.wday = (byte)(wday.SelectedIndex + 1); } if (day.SelectedIndex == 32) { bd.day = 255; } else { bd.day = (byte)(day.SelectedIndex + 1); } if (month.SelectedIndex == 14) { bd.month = 255; } else { bd.month = (byte)(month.SelectedIndex + 1); } int valyear = 255; try { valyear = Convert.ToInt32(year.Text) - 1900; } catch { } bd.year = (byte)valyear; return(bd); } if (Entry is BacnetDateRange) { BacnetDateRange bdr = new BacnetDateRange(); if (startDate.Value == DateTimePicker.MinimumDateTime) { bdr.startDate = new BacnetDate(255, 255, 255); } else { bdr.startDate = new BacnetDate((byte)(startDate.Value.Year - 1900), (byte)startDate.Value.Month, (byte)startDate.Value.Day); } if (endDate.Value == DateTimePicker.MaximumDateTime) { bdr.startDate = new BacnetDate(255, 255, 255); } else { bdr.endDate = new BacnetDate((byte)(endDate.Value.Year - 1900), (byte)endDate.Value.Month, (byte)endDate.Value.Day); } return(bdr); } if (Entry is BacnetweekNDay) { BacnetweekNDay bwd = (BacnetweekNDay)Entry; if (wday.SelectedIndex == 7) { bwd.wday = 255; } else { bwd.wday = (byte)(wday.SelectedIndex + 1); } if (month.SelectedIndex == 14) { bwd.month = 255; } else { bwd.month = (byte)(month.SelectedIndex + 1); } return(bwd); } return(null); }
public CalendarEntryEdit(object entry) { InitCalendarEntryEdit(); this.Entry = entry; if (entry is BacnetDate) { dateRangeGrp.Visible = false; DateGrp.Visible = true; DateGrp.Location = dateRangeGrp.Location; BacnetDate bd = (BacnetDate)entry; if (bd.wday != 255) { wday.SelectedIndex = bd.wday - 1; } else { wday.SelectedIndex = 7; } if (bd.day != 255) { day.SelectedIndex = bd.day - 1; } else { day.SelectedIndex = 32; } if (bd.month != 255) { month.SelectedIndex = bd.month - 1; } else { month.SelectedIndex = 14; } if (bd.year != 255) { year.Text = (bd.year + 1900).ToString(); } else { year.Text = "****"; } } if (entry is BacnetDateRange) { dateRangeGrp.Visible = true; DateGrp.Visible = false; BacnetDateRange bdr = (BacnetDateRange)entry; if (bdr.startDate.year != 255) { startDate.Value = bdr.startDate.toDateTime(); } else { startDate.Value = DateTimePicker.MinimumDateTime; } if (bdr.endDate.year != 255) { endDate.Value = bdr.endDate.toDateTime(); } else { endDate.Value = DateTimePicker.MaximumDateTime; } } if (entry is BacnetweekNDay) { dateRangeGrp.Visible = false; DateGrp.Visible = true; DateGrp.Location = dateRangeGrp.Location; year.Visible = false; day.Visible = false; wday.Location = new Point(wday.Location.X + 50, wday.Location.Y); BacnetweekNDay bwd = (BacnetweekNDay)entry; if (bwd.wday != 255) { wday.SelectedIndex = bwd.wday - 1; } else { wday.SelectedIndex = 7; } if (bwd.month != 255) { month.SelectedIndex = bwd.month - 1; } else { month.SelectedIndex = 14; } } }
private void PlaceItemsInCalendarView() { foreach (object e in calendarEntries.Entries) { if (e is BacnetDate) { BacnetDate bd = (BacnetDate)e; if (bd.IsPeriodic) { foreach (CalendarDay dt in calendarView.Days) { if (bd.IsAFittingDate(dt.Date)) { AddCalendarEntry(dt.Date, dt.Date, Color.Blue, "Periodic", bd); } } } else { AddCalendarEntry(bd.toDateTime(), bd.toDateTime(), Color.Green, "", bd); } } else if (e is BacnetDateRange) { BacnetDateRange bdr = (BacnetDateRange)e; DateTime start, end; if (bdr.startDate.year != 255) { start = new DateTime(bdr.startDate.year + 1900, bdr.startDate.month, bdr.startDate.day, 0, 0, 0); } else { start = DateTime.MinValue; } if (bdr.endDate.year != 255) { end = new DateTime(bdr.endDate.year + 1900, bdr.endDate.month, bdr.endDate.day, 23, 59, 59); } else { end = DateTime.MaxValue; } CalendarItem ci = new CalendarItem(calendarView, start, end, ""); ci.ApplyColor(Color.Yellow); ci.Tag = bdr; if (start <= calendarView.Days[calendarView.Days.Length - 1].Date && calendarView.Days[0].Date <= end) { calendarView.Items.Add(ci); } } else { BacnetweekNDay bwnd = (BacnetweekNDay)e; foreach (CalendarDay dt in calendarView.Days) { if (bwnd.IsAFittingDate(dt.Date)) { AddCalendarEntry(dt.Date, dt.Date, Color.Red, "Periodic", bwnd); } } } } }