public int LoadChart(DateTime start, DateTime end, TimetableItem timetable, Dictionary <string, List <EventItem> > data, int mode = 0) { //viewEvList.Clear(); timetable.Clear(); for (DateTime date = start; date <= end; date = date.AddDays(1)) { if (mode != 2) { timetable.Clear(); } foreach (var Ev in this.Items) { foreach (var itr in Ev.Items) { if (itr.Date == date) { timetable.Update(Ev.Category, itr.Time, (double)24); } } } foreach (var cat in data) { double time = 0; timetable.GetTime(cat.Key, ref time); data[cat.Key].Add(new EventItem(date, time, "")); } } return(1); }
public void CreateSubs(Category Cty) { foreach (var itr in Cty.Subs) { TimetableItem item = new TimetableItem(itr.Name); this.Subs.Add(item); item.CreateSubs(itr); } }
public static void AddCategoryIndex(TimetableItem category, string prex, Dictionary <string, string> CategoryIndexes) { int i = 0; foreach (var sub in category.Subs) { CategoryIndexes.Add(sub.Name, prex + (++i).ToString()); AddCategoryIndex(sub, prex + i.ToString(), CategoryIndexes); } }
private void LoadTimetableItemSubs(TimetableItem item, TreeNode node) { TreeNode n = new TreeNode(item.Print()); n.Name = item.Name; node.Nodes.Add(n); foreach (var itr in item.Subs) { LoadTimetableItemSubs(itr, n); } }
public static void InitCategoryCompare(TimetableItem category) { if (ViewEventItem.CategoryIndexes == null) { ViewEventItem.CategoryIndexes = new Dictionary <string, string>(); //CategoryIndexes.Add(category.Name, "0"); int i = 0; foreach (var sub in category.Subs) { AddCategoryIndex(sub, (++i).ToString(), ViewEventItem.CategoryIndexes); } } }
private void DisplayTimetable(TimetableItem item, TreeNode node) { if (item.Name == node.Name) { node.Text = item.Print(); } foreach (var itr in item.Subs) { foreach (var n in node.Nodes) { TreeNode child = ((TreeNode)n); if (itr.Name == child.Name) { DisplayTimetable(itr, child); } } } }
public void AnalysisCategoryStr(string name, TimetableItem tb) { try { int n = Convert.ToInt32(name); List <int> list = new List <int>(); while (n >= 10) { list.Add(n % 10); n = n / 10; } list.Add(n); list.Reverse(); TimetableItem cur = tb; foreach (var i in list) { cur = cur.Subs[i - 1]; } this.Category = cur.Name; } catch { } }
//Timetable Read public TimetableItem ReadTimetable(DateTime curDate, ModelCategory mCategory) { EndTime = DateTime.MaxValue; foreach (var itr in mCategory.Items) { if (itr.Name == "Event" && itr.Date > curDate) { EndTime = itr.Date; } else if (itr.Name == "Event" && itr.Date <= curDate) { Timetable = new TimetableItem(itr.Category); StartTime = itr.Date; break; } } if (Timetable == null) { Timetable = new TimetableItem("Event"); //throw new Exception("No Timetable is found in \"Category.xml\"."); } return(Timetable); }