Exemplo n.º 1
0
    public void DisplayScheduledEvents()
    {
        // Delivery Events
        List <DeliveryEvent> deliveryEvents = parentPanel.dm.eventScheduler.GetDeliveryEvents();

        foreach (DeliveryEvent deliveryEvent in deliveryEvents)
        {
            CalendarDisplayObject displayObject = GetCalendarDisplayObject(deliveryEvent.eventStartDate);
            if (displayObject != null)
            {
                displayObject.AddEvent(deliveryEvent);
            }
        }

        // Smoke Lounge Events
        List <SmokeLoungeEvent> smokeLoungeEvents = parentPanel.dm.eventScheduler.GetSmokeLoungeEvents();

        foreach (SmokeLoungeEvent smokeLoungeEvent in smokeLoungeEvents)
        {
            CalendarDisplayObject displayObject = GetCalendarDisplayObject(smokeLoungeEvent.eventStartDate);
            if (displayObject != null)
            {
                displayObject.AddEvent(smokeLoungeEvent);
            }
        }

        // Glass Shop Events
        List <GlassShopEvent> glassShopEvents = parentPanel.dm.eventScheduler.GetGlassShopEvents();

        foreach (GlassShopEvent glassShopEvent in glassShopEvents)
        {
            CalendarDisplayObject displayObject = GetCalendarDisplayObject(glassShopEvent.eventStartDate);
            if (displayObject != null)
            {
                displayObject.AddEvent(glassShopEvent);
            }
        }

        // Growroom Events
        List <GrowroomEvent> growroomEvents = parentPanel.dm.eventScheduler.GetGrowroomEvents();

        foreach (GrowroomEvent growroomEvent in growroomEvents)
        {
            CalendarDisplayObject displayObject = GetCalendarDisplayObject(growroomEvent.eventStartDate);
            if (displayObject != null)
            {
                displayObject.AddEvent(growroomEvent);
            }
        }
    }
    public void SelectDate(CalendarDisplayObject displayObject)
    {
        dateSelected = new SelectedDate(displayObject.thisDate, displayObject);
        dateSelected.eventsScheduledToday = dm.eventScheduler.GetEvents(dateSelected.selectedDate);
        bool skipEventSchedulerToggle = false;

        if (currentActiveCalendar != null)
        {
            if (currentActiveCalendar.viewMode == Calendar.ViewMode.scheduledEvents)
            {
                if (eventSchedulerPanel.onScreen)
                {
                    if (!currentActiveCalendar.gameObject.name.Equals("EventSchedulerCalendar"))
                    { // Dont load the calendar if its already loaded, the user is simply selecting a new day
                        LoadCalendar(ViewMode.eventScheduler);
                    }
                }
                else
                {
                    if (!currentActiveCalendar.gameObject.name.Equals("DaySelectedCalendar"))
                    { // Dont load the calendar if its already loaded, the user is simply selecting a new day
                        LoadCalendar(ViewMode.simpleDaySelected);
                    }
                }
            }
            else
            {
                if (!currentActiveCalendar.gameObject.name.Equals("DaySelectedCalendar"))
                { // Dont load the calendar if its already loaded, the user is simply selecting a new day
                    skipEventSchedulerToggle = true;
                    LoadCalendar(ViewMode.simpleDaySelected);
                }
            }
        }
        if (viewMode == ViewMode.simpleDaySelected && !skipEventSchedulerToggle)
        {
            if (eventSchedulerPanel.onScreen)
            {
                EventSchedulerToggle();
            }
        }
        DisplaySelectedDateInformation();
    }
 public SelectedDate(Date date, CalendarDisplayObject displayObject_)
 {
     selectedDate  = date;
     displayObject = displayObject_;
 }
Exemplo n.º 4
0
    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;
        }
    }