Esempio n. 1
0
    /* Creates the Text UI
     * Returns the RectTransform of the highlighted Day
     */
    private RectTransform displayText(string _location, Day _highlightDay)
    {
        if (!days.ContainsKey(_location))
        {
            Debug.LogError("No valid location: " + _location);
            return(new RectTransform());
        }
        RectTransform rHighlighDay = new RectTransform();

        foreach (Day day in days[_location])
        {
            Text      txtTime   = Instantiate(lessonPrefab, contenTransform);
            NormalDay normalDay = day as NormalDay;
            if (normalDay != null)
            {
                if (normalDay.Equals(_highlightDay))
                {
                    txtTime.text      = Config.mainCultureInfo.DateTimeFormat.GetDayName(normalDay.date.DayOfWeek) + ", " + normalDay.date.Date.ToString("d", Config.mainCultureInfo);
                    txtTime.fontStyle = FontStyle.Bold;
                    txtTime.color     = new Color(0.8f, 0.2f, 0.2f);
                    rHighlighDay      = txtTime.gameObject.GetComponent <RectTransform>();
                }
                else
                {
                    txtTime.text      = Config.mainCultureInfo.DateTimeFormat.GetDayName(normalDay.date.DayOfWeek) + ", " + normalDay.date.Date.ToString("d", Config.mainCultureInfo);
                    txtTime.fontStyle = FontStyle.Bold;
                }

                foreach (Lesson lesson in normalDay.lessons)
                {
                    Text txt = Instantiate(lessonPrefab, contenTransform);
                    txt.text = lesson.ToString();
                }
            }
            else if (day is InfoDay)
            {
                txtTime.text      = ((InfoDay)day).info;
                txtTime.fontStyle = FontStyle.Bold;
                txtTime.fontStyle = FontStyle.BoldAndItalic;
            }
            else   //Should never happen
            {
                throw new InvalidCastException("No such class: " + day.GetType().Name);
            }
        }
        return(rHighlighDay);
    }
Esempio n. 2
0
    private NormalDay findDayToHighlight(string _location, DateTime _date)
    {
        Debug.Log("Currently checking date: " + _date.ToString("D"));
        NormalDay d = (NormalDay)Array.Find(days[_location], _day => _day is NormalDay && ((NormalDay)_day).date.Equals(_date.Date));

        if (d == null)
        {
            d = findDayToHighlight(_location, _date.Date.AddDays(1.0));
        }
        else
        {
            Debug.Log("<color=red>" + d.date.ToString("D") + "</color>");
            foreach (Lesson lesson in d.lessons)
            {
                Debug.Log(lesson);
            }
        }
        return(d);
    }
Esempio n. 3
0
 ///<summary>Returns the hash code for this instance.</summary>
 ///<returns>A 32-bit signed integer hash code.</returns>
 public override int GetHashCode()
 {
     return(Month.GetHashCode() ^ NormalDay.GetHashCode() ^ Fallback.GetHashCode());
 }
Esempio n. 4
0
    private static Dictionary <string, Day[]> convertToDic(string[] _talbeOnly)
    {
        Dictionary <string, Day[]> tmpDays = new Dictionary <string, Day[]>();

        //TODO: dont loop over evey location. Data is there. Redundant. Need to fix this
        for (int location = 0; location < Config.locations.Length; location++)
        {
            Debug.Log("<color=white>" + Config.locations[location] + "</color>");
            List <Day> tmpDay = new List <Day>();
            bool       skipAdditionalLessonsForThisDay = false;
            foreach (string dDay in _talbeOnly)
            {
                string tmp     = dDay.Substring(4);
                string dataDay = StringUtility.getBetween(tmp, "<td>", "</td>");
                tmp = tmp.Substring(9 + dataDay.Length);
                Lesson[] dataLessons = new Lesson[Config.locations.Length];
                for (int loc = 0; loc < Config.locations.Length; loc++)
                {
                    tmp = tmp.Substring(4);
                    string time = StringUtility.getBetween(tmp, "<td>", "</td>");
                    tmp = tmp.Substring(9 + time.Length);

                    tmp = tmp.Substring(4);
                    string topic = StringUtility.getBetween(tmp, "<td>", "</td>");
                    tmp = tmp.Substring(9 + topic.Length);

                    dataLessons[loc] = Lesson.createLesson(time, topic);
                }
                if (dataDay.Equals(""))
                {
                    if (skipAdditionalLessonsForThisDay)
                    {
                        continue;
                    }
                    NormalDay normalDay = tmpDay[tmpDay.Count - 1] as NormalDay;
                    if (normalDay == null)
                    {
                        continue;                    //should never be true
                    }
                    NormalDay day = normalDay;
                    day.lessons = addLessonIfNeeded(day.lessons, dataLessons[location]);
                    Debug.Log("<color=green>" + tmpDay.Count + " " + tmpDay[tmpDay.Count - 1] + "</color>");
                }
                else if (dataDay.Substring(5).Split('.').Length == 3) //its a valid date
                {
                    //string[] dateSplit = dataDay.Substring(5).Split('.');
                    //DateTime dateOfDay = new DateTime(int.Parse(dateSplit[2]), int.Parse(dateSplit[1]), int.Parse(dateSplit[0])); //convert string date into DateTime object
                    DateTime dateOfDay = DateTime.Parse(dataDay.Substring(5), new CultureInfo("de-DE")); //has to be de-DE

                    if (dataLessons[location].topic.Equals("kein Unterricht") || string.IsNullOrEmpty(dataLessons[location].topic) && dataLessons[location].timeIsEmpty())
                    {
                        Debug.Log("<color=black>Kein Unterricht: " + dateOfDay.Date.ToString("D", Config.mainCultureInfo) + "</color>");
                        skipAdditionalLessonsForThisDay = true;
                        continue;
                    }
                    NormalDay day = new NormalDay(dateOfDay, new[] { dataLessons[location] });
                    skipAdditionalLessonsForThisDay = false;
                    tmpDay.Add(day);
                    Debug.Log("<color=blue>" + tmpDay.Count + " " + tmpDay[tmpDay.Count - 1] + "</color>");
                }
                else
                {
                    //its an InfoDay
                    tmpDay.Add(new InfoDay(dataDay));
                    Debug.Log("<color=yellow>" + tmpDay.Count + " " + tmpDay[tmpDay.Count - 1] + "</color>");
                }
            }
            tmpDays.Add(Config.locations[location], tmpDay.ToArray());
        }

        return(tmpDays);
    }