diff --git a/HFUTCourseSimulation/ImageExport.cs b/HFUTCourseSimulation/ImageExport.cs index 3fe6013..a93e9c6 100644 --- a/HFUTCourseSimulation/ImageExport.cs +++ b/HFUTCourseSimulation/ImageExport.cs @@ -9,108 +9,108 @@ using System.Windows; namespace HFUTCourseSimulation { - public static class ImageExport { + //public static class ImageExport { - public static readonly int WeekHeaderHeight = 50; - public static readonly int BodyCellWidth = 150; - public static readonly int BodyCellHeight = 80; - public static readonly int HeaderCellHeight = 40; - public static readonly int LeftCellWidth = 25; - public static readonly int Blank = 20; + // public static readonly int WeekHeaderHeight = 50; + // public static readonly int BodyCellWidth = 150; + // public static readonly int BodyCellHeight = 80; + // public static readonly int HeaderCellHeight = 40; + // public static readonly int LeftCellWidth = 25; + // public static readonly int Blank = 20; - static Dictionary weekDict = new Dictionary() { - {0, "星期一"}, - {1, "星期二"}, - {2, "星期三"}, - {3, "星期四"}, - {4, "星期五"}, - {5, "星期六"}, - {6, "星期日"} - }; + // static Dictionary weekDict = new Dictionary() { + // {0, "星期一"}, + // {1, "星期二"}, + // {2, "星期三"}, + // {3, "星期四"}, + // {4, "星期五"}, + // {5, "星期六"}, + // {6, "星期日"} + // }; - public static bool Export(DateTime startDate, int weekCount, string file) { + // public static bool Export(DateTime startDate, int weekCount, string file) { - var simuCore = new SimulationCore(startDate, weekCount); - simuCore.Generate(); - if (simuCore.ErrorList.Count != 0) return false; + // var simuCore = new SimulationCore(startDate, weekCount); + // simuCore.Generate(); + // if (simuCore.ErrorList.Count != 0) return false; - //define size - int weekPerLine = (int)Math.Sqrt(weekCount) + 1; + // //define size + // int weekPerLine = (int)Math.Sqrt(weekCount) + 1; - var weekWidth = (Blank + LeftCellWidth + 7 * BodyCellWidth); - var weekHeight = (Blank + WeekHeaderHeight + HeaderCellHeight + 11 * BodyCellHeight); - var img = new Bitmap(Blank + weekPerLine * weekWidth, Blank + (weekCount / weekPerLine + (weekCount % weekPerLine == 0 ? 0 : 1)) * weekHeight); - var graphics = Graphics.FromImage(img); + // var weekWidth = (Blank + LeftCellWidth + 7 * BodyCellWidth); + // var weekHeight = (Blank + WeekHeaderHeight + HeaderCellHeight + 11 * BodyCellHeight); + // var img = new Bitmap(Blank + weekPerLine * weekWidth, Blank + (weekCount / weekPerLine + (weekCount % weekPerLine == 0 ? 0 : 1)) * weekHeight); + // var graphics = Graphics.FromImage(img); - //declare graphics value - var background = new SolidBrush(Color.White); - var headerBrush = new SolidBrush(Color.Gray); - var textBrush = new SolidBrush(Color.Black); - Brush cellBrush; - var textFont = new Font("Microsoft YaHei UI", 12); + // //declare graphics value + // var background = new SolidBrush(Color.White); + // var headerBrush = new SolidBrush(Color.Gray); + // var textBrush = new SolidBrush(Color.Black); + // Brush cellBrush; + // var textFont = new Font("Microsoft YaHei UI", 12); - var textMargin = graphics.MeasureString("测试字符", textFont).Height; + // var textMargin = graphics.MeasureString("测试字符", textFont).Height; - //overlay all background - graphics.FillRectangle(background, 0, 0, Blank + weekPerLine * weekWidth, Blank + (weekCount / weekPerLine + (weekCount % weekPerLine == 0 ? 0 : 1)) * weekHeight); + // //overlay all background + // graphics.FillRectangle(background, 0, 0, Blank + weekPerLine * weekWidth, Blank + (weekCount / weekPerLine + (weekCount % weekPerLine == 0 ? 0 : 1)) * weekHeight); - //output each week - for (int i = 0; i < weekCount; i++) { - //generate week data - var weekData = simuCore.Render(i + 1); + // //output each week + // for (int i = 0; i < weekCount; i++) { + // //generate week data + // var weekData = simuCore.Render(i + 1); - //get start position - var top = Blank + (i / weekPerLine) * weekHeight; - var left = Blank + (i % weekPerLine) * weekWidth; - graphics.TranslateTransform(left, top); + // //get start position + // var top = Blank + (i / weekPerLine) * weekHeight; + // var left = Blank + (i % weekPerLine) * weekWidth; + // graphics.TranslateTransform(left, top); - //draw week head - graphics.DrawString($"教学周:{weekData.WeekIndex}", textFont, textBrush, 0, 0); - //move transform - graphics.TranslateTransform(0, WeekHeaderHeight); + // //draw week head + // graphics.DrawString($"教学周:{weekData.WeekIndex}", textFont, textBrush, 0, 0); + // //move transform + // graphics.TranslateTransform(0, WeekHeaderHeight); - //draw header - graphics.FillRectangle(headerBrush, 0, 0, weekWidth - Blank, HeaderCellHeight); - graphics.FillRectangle(headerBrush, 0, 0, LeftCellWidth, weekHeight - WeekHeaderHeight - Blank); - //draw header text - for (int j = 0; j < 7; j++) { - graphics.DrawString(weekDict[j], textFont, textBrush, LeftCellWidth + j * BodyCellWidth, 0); - graphics.DrawString(weekData.WeekDate[j], textFont, textBrush, LeftCellWidth + j * BodyCellWidth, textMargin); - } - //draw left text - for (int j = 0; j < 11; j++) { - graphics.DrawString((j + 1).ToString(), textFont, textBrush, 0, HeaderCellHeight + j * BodyCellHeight); - } + // //draw header + // graphics.FillRectangle(headerBrush, 0, 0, weekWidth - Blank, HeaderCellHeight); + // graphics.FillRectangle(headerBrush, 0, 0, LeftCellWidth, weekHeight - WeekHeaderHeight - Blank); + // //draw header text + // for (int j = 0; j < 7; j++) { + // graphics.DrawString(weekDict[j], textFont, textBrush, LeftCellWidth + j * BodyCellWidth, 0); + // graphics.DrawString(weekData.WeekDate[j], textFont, textBrush, LeftCellWidth + j * BodyCellWidth, textMargin); + // } + // //draw left text + // for (int j = 0; j < 11; j++) { + // graphics.DrawString((j + 1).ToString(), textFont, textBrush, 0, HeaderCellHeight + j * BodyCellHeight); + // } - //move transform - graphics.TranslateTransform(LeftCellWidth, HeaderCellHeight); - foreach(var courses in weekData.CourseList) { - var cellx = courses.Start.week - 1; - var celly = courses.Start.index - 1; - //background - cellBrush = new SolidBrush(Util.ColorTrans.ToWinformColor(courses.BkColor)); - graphics.FillRectangle(cellBrush, cellx * BodyCellWidth, celly * BodyCellHeight, BodyCellWidth, BodyCellHeight * courses.Span); + // //move transform + // graphics.TranslateTransform(LeftCellWidth, HeaderCellHeight); + // foreach(var courses in weekData.CourseList) { + // var cellx = courses.Start.week - 1; + // var celly = courses.Start.index - 1; + // //background + // cellBrush = new SolidBrush(Util.ColorTrans.ToWinformColor(courses.BkColor)); + // graphics.FillRectangle(cellBrush, cellx * BodyCellWidth, celly * BodyCellHeight, BodyCellWidth, BodyCellHeight * courses.Span); - //draw text - var rect = new RectangleF(cellx * BodyCellWidth, celly * BodyCellHeight, BodyCellWidth, celly * BodyCellHeight); - graphics.DrawString(courses.Name, textFont, textBrush, rect); - var thisTextMargin = graphics.MeasureString(courses.Name, textFont, BodyCellWidth).Height; - graphics.DrawString(courses.Desc, textFont, textBrush, cellx * BodyCellWidth, celly * BodyCellHeight + thisTextMargin); - } + // //draw text + // var rect = new RectangleF(cellx * BodyCellWidth, celly * BodyCellHeight, BodyCellWidth, celly * BodyCellHeight); + // graphics.DrawString(courses.Name, textFont, textBrush, rect); + // var thisTextMargin = graphics.MeasureString(courses.Name, textFont, BodyCellWidth).Height; + // graphics.DrawString(courses.Desc, textFont, textBrush, cellx * BodyCellWidth, celly * BodyCellHeight + thisTextMargin); + // } - //reset - graphics.TranslateTransform(-LeftCellWidth, -HeaderCellHeight); - graphics.TranslateTransform(0, -WeekHeaderHeight); - graphics.TranslateTransform(-left, -top); - } + // //reset + // graphics.TranslateTransform(-LeftCellWidth, -HeaderCellHeight); + // graphics.TranslateTransform(0, -WeekHeaderHeight); + // graphics.TranslateTransform(-left, -top); + // } - System.IO.File.Delete(file); - img.Save(file, ImageFormat.Png); - img.Dispose(); - return true; - } + // System.IO.File.Delete(file); + // img.Save(file, ImageFormat.Png); + // img.Dispose(); + // return true; + // } - } + //} } diff --git a/HFUTCourseSimulation/Kernel/Arranger.cs b/HFUTCourseSimulation/Kernel/Arranger.cs index d0e24e8..8860618 100644 --- a/HFUTCourseSimulation/Kernel/Arranger.cs +++ b/HFUTCourseSimulation/Kernel/Arranger.cs @@ -187,14 +187,13 @@ namespace HFUTCourseSimulation.Kernel { const char DASH = '-'; // 分析文本组成,决定其整数集合类型 + // 如果包含DASH,则肯定是Range,否则按Individual处理 + // (比如只有一项的Individual是没有COMMA的) IntegerCollectionKind kind; - if (s.Contains(COMMA)) { - kind = IntegerCollectionKind.Individual; - } else if (s.Contains(DASH)) { + if (s.Contains(DASH)) { kind = IntegerCollectionKind.Range; } else { - reporter.Error($"{field_name}的值“{s}”无法被解析"); - return null; + kind = IntegerCollectionKind.Individual; } // 根据整数集合类型,决定分割用字符 @@ -322,15 +321,17 @@ namespace HFUTCourseSimulation.Kernel { lessons.Add(current_lesson); current_lesson = null; } - // 然后设置当前课程 - var this_course = semester.courses[this_course_index]; - current_lesson = new Data.Presentation.Lesson() { - name = this_course.name, - description = this_course.description, - color = this_course.color, - startIndex = index, - indexSpan = 1 - }; + // 然后如果当前有课程,就设置当前课程 + if (this_course_index >= 0) { + var this_course = semester.courses[this_course_index]; + current_lesson = new Data.Presentation.Lesson() { + name = this_course.name, + description = this_course.description, + color = this_course.color, + startIndex = index, + indexSpan = 1 + }; + } } else { // 课程未曾发生改变,如果当前有课程,我们只需要单纯地自增其节次跨度 if (previous_course_index >= 0) { diff --git a/HFUTCourseSimulation/Kernel/Data/Built.cs b/HFUTCourseSimulation/Kernel/Data/Built.cs index 5be9113..6574645 100644 --- a/HFUTCourseSimulation/Kernel/Data/Built.cs +++ b/HFUTCourseSimulation/Kernel/Data/Built.cs @@ -55,7 +55,7 @@ namespace HFUTCourseSimulation.Kernel.Data.Built { private int _start, _end; public IEnumerator GetEnumerator() { - return Enumerable.Range(_start, _end).GetEnumerator(); + return Enumerable.Range(_start, _end - _start + 1).GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); diff --git a/HFUTCourseSimulation/MainWindow.xaml b/HFUTCourseSimulation/MainWindow.xaml index 368f525..6d9ca9f 100644 --- a/HFUTCourseSimulation/MainWindow.xaml +++ b/HFUTCourseSimulation/MainWindow.xaml @@ -29,6 +29,7 @@ + diff --git a/HFUTCourseSimulation/MainWindow.xaml.cs b/HFUTCourseSimulation/MainWindow.xaml.cs index 716c371..cbc38d7 100644 --- a/HFUTCourseSimulation/MainWindow.xaml.cs +++ b/HFUTCourseSimulation/MainWindow.xaml.cs @@ -237,6 +237,12 @@ namespace HFUTCourseSimulation { this.Close(); } + private void uiMenuCheck_Click(object sender, RoutedEventArgs e) { + var semester = CurrentSemester.ToStorage(); + var reporter = new Kernel.Reporter(); + var rv = Kernel.Arranger.Arrange(semester, reporter); + } + private void uiMenuSimulator_Click(object sender, RoutedEventArgs e) { //var win = new Simulation(); //win.ShowDialog(); diff --git a/HFUTCourseSimulation/Simulation.xaml.cs b/HFUTCourseSimulation/Simulation.xaml.cs index 1dfa4da..c109304 100644 --- a/HFUTCourseSimulation/Simulation.xaml.cs +++ b/HFUTCourseSimulation/Simulation.xaml.cs @@ -18,44 +18,44 @@ namespace HFUTCourseSimulation { /// public partial class Simulation : Window { - SimulationCore simulationKernel; + //SimulationCore simulationKernel; public Simulation() { InitializeComponent(); - //init colums and rows - for (int i = 0; i < 11; i++) { - var rows = new RowDefinition(); - rows.Height = new GridLength(1, GridUnitType.Star); - this.uiArrangeGrid.RowDefinitions.Add(rows); - } + ////init colums and rows + //for (int i = 0; i < 11; i++) { + // var rows = new RowDefinition(); + // rows.Height = new GridLength(1, GridUnitType.Star); + // this.uiArrangeGrid.RowDefinitions.Add(rows); + //} - for (int i = 0; i < 7; i++) { - var colums = new ColumnDefinition(); - colums.Width = new GridLength(1, GridUnitType.Star); - this.uiArrangeGrid.ColumnDefinitions.Add(colums); - } + //for (int i = 0; i < 7; i++) { + // var colums = new ColumnDefinition(); + // colums.Width = new GridLength(1, GridUnitType.Star); + // this.uiArrangeGrid.ColumnDefinitions.Add(colums); + //} - try { - originDate = DateTime.Parse(General.GeneralSheet.StartDate); - weekCount = General.GeneralSheet.WeekCount; - } catch (Exception) { - MessageBox.Show("周数或日期转换错误,请关闭窗口", "错误", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); - this.uiArrangeError.IsEnabled = false; - this.uiBtnNext.IsEnabled = false; - this.uiBtnPre.IsEnabled = false; - return; - } + //try { + // originDate = DateTime.Parse(General.GeneralSheet.StartDate); + // weekCount = General.GeneralSheet.WeekCount; + //} catch (Exception) { + // MessageBox.Show("周数或日期转换错误,请关闭窗口", "错误", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); + // this.uiArrangeError.IsEnabled = false; + // this.uiBtnNext.IsEnabled = false; + // this.uiBtnPre.IsEnabled = false; + // return; + //} - simulationKernel = new SimulationCore(originDate, weekCount); - simulationKernel.Generate(); - //refresh error list - this.uiArrangeError.Items.Clear(); - foreach (var item in simulationKernel.ErrorList) { - this.uiArrangeError.Items.Add(item); - } - currentWeek = 1; - this.RenderGrid(simulationKernel.Render(currentWeek)); + //simulationKernel = new SimulationCore(originDate, weekCount); + //simulationKernel.Generate(); + ////refresh error list + //this.uiArrangeError.Items.Clear(); + //foreach (var item in simulationKernel.ErrorList) { + // this.uiArrangeError.Items.Add(item); + //} + //currentWeek = 1; + //this.RenderGrid(simulationKernel.Render(currentWeek)); } @@ -64,67 +64,67 @@ namespace HFUTCourseSimulation { DateTime originDate; void RenderGrid(RenderWeek weekRes) { - //set date - uiWeek.Text = weekRes.WeekIndex.ToString(); - uiWeek1.Text = weekRes.WeekDate[0]; - uiWeek2.Text = weekRes.WeekDate[1]; - uiWeek3.Text = weekRes.WeekDate[2]; - uiWeek4.Text = weekRes.WeekDate[3]; - uiWeek5.Text = weekRes.WeekDate[4]; - uiWeek6.Text = weekRes.WeekDate[5]; - uiWeek7.Text = weekRes.WeekDate[6]; + ////set date + //uiWeek.Text = weekRes.WeekIndex.ToString(); + //uiWeek1.Text = weekRes.WeekDate[0]; + //uiWeek2.Text = weekRes.WeekDate[1]; + //uiWeek3.Text = weekRes.WeekDate[2]; + //uiWeek4.Text = weekRes.WeekDate[3]; + //uiWeek5.Text = weekRes.WeekDate[4]; + //uiWeek6.Text = weekRes.WeekDate[5]; + //uiWeek7.Text = weekRes.WeekDate[6]; - //remove all old grid - this.uiArrangeGrid.Children.Clear(); + ////remove all old grid + //this.uiArrangeGrid.Children.Clear(); - //generate new - foreach (var item in weekRes.CourseList) { - var warp = new Border(); - warp.Background = new SolidColorBrush(item.BkColor); - warp.CornerRadius = new CornerRadius(5); - Grid.SetRowSpan(warp, item.Span); - var nGrid = new Grid(); - nGrid.ToolTip = item.Desc; - var courseName = new TextBlock(); - courseName.VerticalAlignment = VerticalAlignment.Center; - courseName.Text = item.Name; - nGrid.Children.Add(courseName); - warp.Child = nGrid; + ////generate new + //foreach (var item in weekRes.CourseList) { + // var warp = new Border(); + // warp.Background = new SolidColorBrush(item.BkColor); + // warp.CornerRadius = new CornerRadius(5); + // Grid.SetRowSpan(warp, item.Span); + // var nGrid = new Grid(); + // nGrid.ToolTip = item.Desc; + // var courseName = new TextBlock(); + // courseName.VerticalAlignment = VerticalAlignment.Center; + // courseName.Text = item.Name; + // nGrid.Children.Add(courseName); + // warp.Child = nGrid; - Grid.SetRow(warp, item.Start.index - 1); - Grid.SetColumn(warp, item.Start.week - 1); + // Grid.SetRow(warp, item.Start.index - 1); + // Grid.SetColumn(warp, item.Start.week - 1); - this.uiArrangeGrid.Children.Add(warp); - } + // this.uiArrangeGrid.Children.Add(warp); + //} } private void uiBtnPre_Click(object sender, RoutedEventArgs e) { - if (currentWeek == 1) { - MessageBox.Show("已经是第一周了", "错误", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); - return; - } + //if (currentWeek == 1) { + // MessageBox.Show("已经是第一周了", "错误", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); + // return; + //} - currentWeek--; - this.RenderGrid(simulationKernel.Render(currentWeek)); + //currentWeek--; + //this.RenderGrid(simulationKernel.Render(currentWeek)); } private void uiBtnNext_Click(object sender, RoutedEventArgs e) { - if (currentWeek == weekCount) { - MessageBox.Show("已经是最后一周了", "错误", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); - return; - } + //if (currentWeek == weekCount) { + // MessageBox.Show("已经是最后一周了", "错误", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); + // return; + //} - currentWeek++; - this.RenderGrid(simulationKernel.Render(currentWeek)); + //currentWeek++; + //this.RenderGrid(simulationKernel.Render(currentWeek)); } private void uiArrangeError_MouseDoubleClick(object sender, MouseButtonEventArgs e) { - if (this.uiArrangeError.SelectedIndex < 0) { - MessageBox.Show("未选择任何项", "错误", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); - return; - } + //if (this.uiArrangeError.SelectedIndex < 0) { + // MessageBox.Show("未选择任何项", "错误", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); + // return; + //} - MessageBox.Show(this.simulationKernel.ErrorList[this.uiArrangeError.SelectedIndex], "错误详情", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); + //MessageBox.Show(this.simulationKernel.ErrorList[this.uiArrangeError.SelectedIndex], "错误详情", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); } } } diff --git a/HFUTCourseSimulation/SimulationCore.cs b/HFUTCourseSimulation/SimulationCore.cs index bc9b0be..4a3f510 100644 --- a/HFUTCourseSimulation/SimulationCore.cs +++ b/HFUTCourseSimulation/SimulationCore.cs @@ -6,156 +6,156 @@ using System.Threading.Tasks; using System.Windows.Media; namespace HFUTCourseSimulation { - public class SimulationCore { + //public class SimulationCore { - public SimulationCore(DateTime startDate, int weekCount) { - this.weekCount = weekCount; - this.originDate = startDate; - } + // public SimulationCore(DateTime startDate, int weekCount) { + // this.weekCount = weekCount; + // this.originDate = startDate; + // } - Dictionary itemDict = new Dictionary(); - public List ErrorList { get; } = new List(); + // Dictionary itemDict = new Dictionary(); + // public List ErrorList { get; } = new List(); - //List uiList = new List(); + // //List uiList = new List(); - DateTime originDate; - int weekCount; - //int currentWeek; + // DateTime originDate; + // int weekCount; + // //int currentWeek; - public void Generate() { - //pre-generate - foreach (var item in General.GeneralSheet.Courses) { - foreach (var inner in item.Schedule) { - var weekRes = GetArrange(inner.Week); - var dayRes = GetArrange(inner.Day); - var indexRes = GetArrange(inner.Index); + // public void Generate() { + // //pre-generate + // foreach (var item in General.GeneralSheet.Courses) { + // foreach (var inner in item.Schedule) { + // var weekRes = GetArrange(inner.Week); + // var dayRes = GetArrange(inner.Day); + // var indexRes = GetArrange(inner.Index); - foreach (var weekItem in weekRes) { - foreach (var dayItem in dayRes) { - foreach (var indexItem in indexRes) { - var vectorCache = new Vector3(weekItem, dayItem, indexItem); - if (this.itemDict.Keys.Contains(vectorCache)) { - ErrorList.Add($"课程冲突:无法将{item.Name}安排到 {weekItem}周,星期{dayItem},第{indexItem}节。因为此处已被{itemDict[vectorCache].Name}占据"); - } else { - itemDict.Add(vectorCache, new SimulationItem() { Name = item.Name, Desc = item.Description, BkColor = Util.ColorTrans.ToWpfColor(item.BkColor) }); - } - } - } - } + // foreach (var weekItem in weekRes) { + // foreach (var dayItem in dayRes) { + // foreach (var indexItem in indexRes) { + // var vectorCache = new Vector3(weekItem, dayItem, indexItem); + // if (this.itemDict.Keys.Contains(vectorCache)) { + // ErrorList.Add($"课程冲突:无法将{item.Name}安排到 {weekItem}周,星期{dayItem},第{indexItem}节。因为此处已被{itemDict[vectorCache].Name}占据"); + // } else { + // itemDict.Add(vectorCache, new SimulationItem() { Name = item.Name, Desc = item.Description, BkColor = Util.ColorTrans.ToWpfColor(item.BkColor) }); + // } + // } + // } + // } - } - } - } + // } + // } + // } - List GetArrange(string str) { - var res = new List(); - try { - if (str.Contains('-')) { - var strSp = str.Split('-'); - int start = int.Parse(strSp[0]), end = int.Parse(strSp[1]); - for (int i = start; i <= end; i++) { - res.Add(i); - } + // List GetArrange(string str) { + // var res = new List(); + // try { + // if (str.Contains('-')) { + // var strSp = str.Split('-'); + // int start = int.Parse(strSp[0]), end = int.Parse(strSp[1]); + // for (int i = start; i <= end; i++) { + // res.Add(i); + // } - } else if (str.Contains(',')) { - var strSp = str.Split(','); - foreach (var item in strSp) { - res.Add(int.Parse(item)); - } - } else { - res.Add(int.Parse(str)); - } - } catch (Exception) { - ErrorList.Add("解析错误:" + str); - } + // } else if (str.Contains(',')) { + // var strSp = str.Split(','); + // foreach (var item in strSp) { + // res.Add(int.Parse(item)); + // } + // } else { + // res.Add(int.Parse(str)); + // } + // } catch (Exception) { + // ErrorList.Add("解析错误:" + str); + // } - return res; - } + // return res; + // } - public RenderWeek Render(int currentWeek) { - //remove all old grid - var result = new RenderWeek(); - result.WeekDate = new List(); + // public RenderWeek Render(int currentWeek) { + // //remove all old grid + // var result = new RenderWeek(); + // result.WeekDate = new List(); - //update date - //comput start date - result.WeekIndex = currentWeek; - var pointer = originDate; - pointer = pointer.AddDays(7 * (currentWeek - 1)); - result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); - pointer = pointer.AddDays(1); - result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); - pointer = pointer.AddDays(1); - result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); - pointer = pointer.AddDays(1); - result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); - pointer = pointer.AddDays(1); - result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); - pointer = pointer.AddDays(1); - result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); - pointer = pointer.AddDays(1); - result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); + // //update date + // //comput start date + // result.WeekIndex = currentWeek; + // var pointer = originDate; + // pointer = pointer.AddDays(7 * (currentWeek - 1)); + // result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); + // pointer = pointer.AddDays(1); + // result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); + // pointer = pointer.AddDays(1); + // result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); + // pointer = pointer.AddDays(1); + // result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); + // pointer = pointer.AddDays(1); + // result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); + // pointer = pointer.AddDays(1); + // result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); + // pointer = pointer.AddDays(1); + // result.WeekDate.Add($"{pointer.Month}/{pointer.Day}"); - result.CourseList = new List(); - //create grid - var query = (from item in itemDict.Keys - where item.teachingweek == currentWeek - select item).ToList(); + // result.CourseList = new List(); + // //create grid + // var query = (from item in itemDict.Keys + // where item.teachingweek == currentWeek + // select item).ToList(); - while (query.Count != 0) { - var core = query[0]; - var data = itemDict[core]; + // while (query.Count != 0) { + // var core = query[0]; + // var data = itemDict[core]; - int length = 1; - //check below - if (core.index != 1 && query.Contains(core + new Vector3(0, 0, -1))) { - if (itemDict[core + new Vector3(0, 0, -1)].Name == data.Name) { - //if below have. jump this->move this to the end - query.RemoveAt(0); - query.Add(core); - continue; - } - } + // int length = 1; + // //check below + // if (core.index != 1 && query.Contains(core + new Vector3(0, 0, -1))) { + // if (itemDict[core + new Vector3(0, 0, -1)].Name == data.Name) { + // //if below have. jump this->move this to the end + // query.RemoveAt(0); + // query.Add(core); + // continue; + // } + // } - //check follow - while (true) { - if (query.Contains(core + new Vector3(0, 0, length)) && itemDict[core + new Vector3(0, 0, length)].Name == data.Name) { - query.Remove(core + new Vector3(0, 0, length)); - length++; - } else break; - } + // //check follow + // while (true) { + // if (query.Contains(core + new Vector3(0, 0, length)) && itemDict[core + new Vector3(0, 0, length)].Name == data.Name) { + // query.Remove(core + new Vector3(0, 0, length)); + // length++; + // } else break; + // } - //create - result.CourseList.Add(new SimulationRenderItem() { Name = data.Name, Desc = data.Desc, BkColor = data.BkColor, Start = core, Span = length }); - /* - var warp = new Border(); - warp.Background = new SolidColorBrush(Colors.LightBlue); - warp.CornerRadius = new CornerRadius(5); - Grid.SetRowSpan(warp, length); - var nGrid = new Grid(); - nGrid.ToolTip = data.Desc; - var courseName = new TextBlock(); - courseName.VerticalAlignment = VerticalAlignment.Center; - courseName.Text = data.Name; - nGrid.Children.Add(courseName); - warp.Child = nGrid; + // //create + // result.CourseList.Add(new SimulationRenderItem() { Name = data.Name, Desc = data.Desc, BkColor = data.BkColor, Start = core, Span = length }); + // /* + // var warp = new Border(); + // warp.Background = new SolidColorBrush(Colors.LightBlue); + // warp.CornerRadius = new CornerRadius(5); + // Grid.SetRowSpan(warp, length); + // var nGrid = new Grid(); + // nGrid.ToolTip = data.Desc; + // var courseName = new TextBlock(); + // courseName.VerticalAlignment = VerticalAlignment.Center; + // courseName.Text = data.Name; + // nGrid.Children.Add(courseName); + // warp.Child = nGrid; - Grid.SetRow(warp, core.index - 1); - Grid.SetColumn(warp, core.week - 1); + // Grid.SetRow(warp, core.index - 1); + // Grid.SetColumn(warp, core.week - 1); - this.uiArrangeGrid.Children.Add(warp); - */ + // this.uiArrangeGrid.Children.Add(warp); + // */ - //remove first item - query.RemoveAt(0); - } + // //remove first item + // query.RemoveAt(0); + // } - return result; - } + // return result; + // } - } + //}