private void SaveNtsClick(object sender, RoutedEventArgs e) { TreeViewItem cur = (TreeViewItem)Tree.SelectedItem; for (int i = 0; i < Sems.Count; i++) { //Find semester of cur Semester sem = (Semester)Sems[i]; if (cur.Name.Contains(sem.Name)) { //Find class of cur for (int j = 0; j < sem.classes.Count; j++) { SchoolClass cls = (SchoolClass)sem.classes[j]; if (cur.Name.Contains(cls.Name)) { //cur is a day, find it for (int h = 0; h < cls.days.Count; h++) { Day day = (Day)cls.days[h]; if (cur.Name.Contains(day.date)) { TextRange t = new TextRange(LargeTxt.Document.ContentStart, LargeTxt.Document.ContentEnd); FileStream file = new FileStream("Notes_" + sem.Name + "_" + cls.Name + "_" + CleanString(day.date) + ".rtf", FileMode.Create); t.Save(file, System.Windows.DataFormats.Rtf); file.Close(); return; //stop iterating after adding the assignment } } } } } } }
private void TreeClicked(object sender, RoutedEventArgs e) { TreeViewItem cur = (TreeViewItem)Tree.SelectedItem; if (cur == null) { return; } if (cur.Name.Contains("asg_")) { //Clicked on an assignment, display the description! for (int i = 0; i < Sems.Count; i++) { //Find semester of cur Semester sem = (Semester)Sems[i]; if (cur.Name.Contains(sem.Name)) { //Find class of cur for (int j = 0; j < sem.classes.Count; j++) { SchoolClass cls = (SchoolClass)sem.classes[j]; if (cur.Name.Contains(cls.Name)) { //cur is a day, find it for (int h = 0; h < cls.days.Count; h++) { Day day = (Day)cls.days[h]; if (cur.Name.Contains(day.date)) { for (int z = 0; z < day.Assigns.Count; z++) { string assign = (string)day.Assigns[z]; if (assign.Contains(cur.Header.ToString())) { LargeTxt.SelectAll(); LargeTxt.Selection.Text = ""; LargeTxt.AppendText(assign); return; } } //stop iterating after displaying } } } } } } } else if (cur.Name.Contains("Notes_")) { LargeTxt.SelectAll(); LargeTxt.Selection.Text = ""; TextRange t = new TextRange(LargeTxt.Document.ContentStart, LargeTxt.Document.ContentEnd); FileStream file = new FileStream(cur.Name + ".rtf", FileMode.Open); t.Load(file, System.Windows.DataFormats.Rtf); file.Close(); } else if (cur.Name.Contains("sem_")) { for (int i = 0; i < Sems.Count; i++) { Semester sem = (Semester)Sems[i]; if (cur.Name.Contains(sem.Name)) { if (sem.DueDates.Count > 0) { int closedues = 0; StringBuilder sb = new StringBuilder(); for (int j = 0; j < sem.DueDates.Count; j = j + 2) { DateTime dt = (DateTime)sem.DueDates[j]; DateTime current = DateTime.Today; for (int h = 0; h < 8; h++) { DateTime tempcur = current.AddDays(h); if (tempcur == dt) { string temp = (string)sem.DueDates[j + 1]; sb.Append(dt.ToShortDateString() + ": " + temp); sb.Append(Environment.NewLine); closedues++; } } } if (closedues > 0) { SmallTxt.Text = ""; SmallTxt.Text = sb.ToString(); } } } } } }
private void AddClsClick(object sender, RoutedEventArgs e) { //New window for class info input var newWindow = new AddCls(); newWindow.ShowDialog(); //If it wasn't closed with ok, just return and do nothing if (newWindow.closedwithok == false) { return; } //Must have selected a semester to even click this button, record which semester and create new class TreeViewItem cur = (TreeViewItem)Tree.SelectedItem; //Look for Semester for (int i = 0; i < Sems.Count; i++) { Semester sem = (Semester)Sems[i]; if (cur.Name.Contains(sem.Name)) { //Found semester, add the new class TreeViewItem newCls = new TreeViewItem() { Header = newWindow.ClsName, Name = "cls_" + CleanString(newWindow.ClsName) + "_" + sem.Name }; cur.Items.Add(newCls); SchoolClass newcls = new SchoolClass(newWindow.ClsName); sem.AddClass(newcls); for (int j = 0; j < sem.weeks; j++) { //Add Week i for every week of classes for semester //Each item is named "week_x" TreeViewItem week = new TreeViewItem() { Header = "Week " + (j + 1), Name = "week_" + (j + 1) }; newCls.Items.Add(week); for (int h = 0; h < newWindow.Days.Count; h++) { //Add each day for every week if ((string)newWindow.Days[h] == "Monday") { DateTime dt = sem.Start.AddDays(1 + (j * 7)); week.Items.Add(new TreeViewItem() { Header = (dt.ToShortDateString()), Name = "day_" + sem.Name + "_" + newcls.Name }); newcls.AddDay(new Day(dt)); } else if ((string)newWindow.Days[h] == "Tuesday") { DateTime dt = sem.Start.AddDays(2 + (j * 7)); week.Items.Add(new TreeViewItem() { Header = (dt.ToShortDateString()), Name = "day_" + sem.Name + "_" + newcls.Name }); newcls.AddDay(new Day(dt)); } else if ((string)newWindow.Days[h] == "Wednesday") { DateTime dt = sem.Start.AddDays(3 + (j * 7)); week.Items.Add(new TreeViewItem() { Header = (dt.ToShortDateString()), Name = "day_" + sem.Name + "_" + newcls.Name }); newcls.AddDay(new Day(dt)); } else if ((string)newWindow.Days[h] == "Thursday") { DateTime dt = sem.Start.AddDays(4 + (j * 7)); week.Items.Add(new TreeViewItem() { Header = (dt.ToShortDateString()), Name = "day_" + sem.Name + "_" + newcls.Name }); newcls.AddDay(new Day(dt)); } else if ((string)newWindow.Days[h] == "Friday") { DateTime dt = sem.Start.AddDays(5 + (j * 7)); week.Items.Add(new TreeViewItem() { Header = (dt.ToShortDateString()), Name = "day_" + sem.Name + "_" + newcls.Name }); newcls.AddDay(new Day(dt)); } } } } } }