public DayCellControl GetCellByDate(DateTime date) { OneMonthControl month = GetOneMonthByDate(date); if (month != null) { return(month.GetCellByDate(date)); } return(null); }
private OneMonthControl CreateNewDefaultOneMonth() { OneMonthControl control = new OneMonthControl(); control.Location = new Point(MonthesMargin.X, MonthesMargin.Y); // oneMonthControl.Location; control.Size = OneMonthSize; // oneMonthControl.Size; control.OwnerMonthsControl = this; control.MonthDayClicked += new OneMonthControl.DayClicked(control_MonthDayClicked); return(control); }
public void CreateAndAdjustMonthsAmount(bool force) { // adjust amount of month calendars in the control according to its size. if (CellPopupControl == null || singleMonths == null || Controls == null || singleMonths.Count == 0) { return; } CellPopupControl.Visible = false; int monthesX = Size.Width / (OneMonthSize.Width + MonthesMargin.X); if (monthesX == 0) { monthesX = 1; } int monthesY = Size.Height / (OneMonthSize.Height + MonthesMargin.Y); if (monthesY == 0) { monthesY = 1; } int monthsAmount = monthesX * monthesY; // new amount of visible monthes if (!force && VisibleMonthsCount == monthsAmount) { // amount of visible months not changed. Do nothing. return; } VisibleMonthsCount = monthsAmount; int maxOfTwo = Math.Max(singleMonths.Count, monthsAmount); for (int i = 0; i < maxOfTwo; i++) { if (singleMonths.Count <= i) // if there is not enough controls for now create one more. { OneMonthControl control = CreateNewDefaultOneMonth(); singleMonths.Add(control); Controls.Add(control); } singleMonths[i].Visible = (i < monthsAmount); // the control is visible if his number is in visible list if (singleMonths[i].Visible) { singleMonths[i].Location = new Point( (i % monthesX) * (OneMonthSize.Width) + MonthesMargin.X * (i % monthesX + 1), (i / monthesX) * (OneMonthSize.Height) + MonthesMargin.Y * (i / monthesX + 1)); if (firstMonthControl.Date != DateTime.MinValue) { singleMonths[i].Date = firstMonthControl.Date.AddMonths(i); } } } }
public MonthsControl() { InitializeComponent(); if (TEXT.Get != null) { ReReadTranslations(); } cellPopupControl = new DayCellPopupControl(this); firstMonthControl = CreateNewDefaultOneMonth(); firstMonthControl.OwnerMonthsControl = this; firstMonthControl.Visible = true; firstMonthControl.MonthDayClicked += new OneMonthControl.DayClicked(control_MonthDayClicked); singleMonths.Add(firstMonthControl); Controls.Add(firstMonthControl); CreateAndAdjustMonthsAmount(); InitializeContextPregnancySubmenu(); }
public void DropMonthMenu(Point screenLocation, OneMonthControl control) { lastDroppedMenuMonth = control; CellPopupControl.Visible = false; MonthMenu.Show(screenLocation); }
/// <summary> /// Create the control on the calenday under the provided month. /// </summary> /// <param name="parent">The month to belong to.</param> public DayCellControl(OneMonthControl parent) { this.OwnerOneMonthControl = parent; this.InitializeComponent(); this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque | ControlStyles.DoubleBuffer | ControlStyles.UserPaint, true); }