public Date(int year_, DateManager.Month newMonth) { year = year_; switch (newMonth) { case DateManager.Month.January: month = 1; break; case DateManager.Month.February: month = 2; break; case DateManager.Month.March: month = 3; break; case DateManager.Month.April: month = 4; break; case DateManager.Month.May: month = 5; break; case DateManager.Month.June: month = 6; break; case DateManager.Month.July: month = 7; break; case DateManager.Month.August: month = 8; break; case DateManager.Month.September: month = 9; break; case DateManager.Month.October: month = 10; break; case DateManager.Month.November: month = 11; break; case DateManager.Month.December: month = 12; break; } day = 1; hour = 0; minute = 0; am = true; }
public void PreviousMonth() { switch (currentMonth) { case DateManager.Month.January: currentMonth = DateManager.Month.December; break; case DateManager.Month.February: currentMonth = DateManager.Month.January; break; case DateManager.Month.March: currentMonth = DateManager.Month.February; break; case DateManager.Month.April: currentMonth = DateManager.Month.March; break; case DateManager.Month.May: currentMonth = DateManager.Month.April; break; case DateManager.Month.June: currentMonth = DateManager.Month.May; break; case DateManager.Month.July: currentMonth = DateManager.Month.June; break; case DateManager.Month.August: currentMonth = DateManager.Month.July; break; case DateManager.Month.September: currentMonth = DateManager.Month.August; break; case DateManager.Month.October: currentMonth = DateManager.Month.September; break; case DateManager.Month.November: currentMonth = DateManager.Month.October; break; case DateManager.Month.December: currentMonth = DateManager.Month.November; break; } BuildCalendar(viewMode, currentMonth); }
public void BuildCalendar(ViewMode newViewMode, DateManager.Month month) { // Ensure proper color Image[] childImages = gameObject.GetComponentsInChildren <Image>(); Text[] childText = gameObject.GetComponentsInChildren <Text>(); foreach (Image img in childImages) { Color oldImgColor = img.color; Color newImgColor = new Color(oldImgColor.r, oldImgColor.g, oldImgColor.b, 1); img.color = newImgColor; } foreach (Text text in childText) { Color oldTextColor = text.color; Color newTextColor = new Color(oldTextColor.r, oldTextColor.g, oldTextColor.b, 1); text.color = newTextColor; } Color oldColor = mainImage.color; Color newColor = new Color(oldColor.r, oldColor.g, oldColor.b, 1); gridImage.color = newColor; topBarImage.color = newColor; // Build calendar calendarDropdown.ManuallySetViewMode(newViewMode); viewMode = newViewMode; currentMonth = month; currentMonthText.text = currentMonth.ToString(); foreach (CalendarDisplayObject displayObject in calendarDisplayObjects) { Destroy(displayObject.gameObject); } calendarDisplayObjects.Clear(); // Calculate sizes float panelWidth = gridImage.rectTransform.rect.width; float panelHeight = gridImage.rectTransform.rect.height; float cellSize_withoutPadding_width = panelWidth / columnCount; float cellSize_withoutPadding_height = panelHeight / rowCount; float cellSize_withoutPadding; if (cellSize_withoutPadding_height < cellSize_withoutPadding_width) { cellSize_withoutPadding = cellSize_withoutPadding_height; } else if (cellSize_withoutPadding_width < cellSize_withoutPadding_height) { cellSize_withoutPadding = cellSize_withoutPadding_width; } else { cellSize_withoutPadding = cellSize_withoutPadding_width; } float padding = cellSize_withoutPadding * .0826f; // Padding is 8.26% of initial cellsize float cellSize = cellSize_withoutPadding - (padding + (padding * .15f)); // Set grid layout group grid.cellSize = new Vector2(cellSize, cellSize); int padding_ = (int)padding; grid.padding = new RectOffset(padding_, padding_, padding_, padding_); grid.spacing = new Vector2(padding, padding); int dayCounter = 0; Date calendarDate = new Date(parentPanel.dm.dateManager.GetCurrentYear(), currentMonth); for (int i = 0; i < rowCount; i++) { for (int j = 0; j < columnCount; j++) { CalendarDisplayObject newDisplayObject = Instantiate(displayPrefab); newDisplayObject.parentCalendar = this; newDisplayObject.gameObject.SetActive(true); newDisplayObject.transform.SetParent(grid.transform, false); newDisplayObject.thisDate = calendarDate; calendarDisplayObjects.Add(newDisplayObject); dayCounter++; newDisplayObject.dayText.text = /*dayCounter.ToString()*/ calendarDate.GetDateString(); calendarDate = calendarDate.GetNextDay(); } } switch (viewMode) { case ViewMode.simple: break; case ViewMode.scheduledEvents: DisplayScheduledEvents(); break; case ViewMode.staffSchedules: DisplayStaffSchedules(); break; case ViewMode.salesReports: DisplaySalesReports(); break; } }