From 57e1d4649a99955e1e3ca72bd03c2f43993b7962 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sun, 23 Dec 2018 15:23:57 +0800 Subject: [PATCH] More clear UI for simulation window --- HFUTCourseSimulation/Simulation.xaml.cs | 43 ++++++++++++++++++++----- HFUTCourseSimulation/SimulationItem.cs | 5 +++ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/HFUTCourseSimulation/Simulation.xaml.cs b/HFUTCourseSimulation/Simulation.xaml.cs index 16d4763..103647d 100644 --- a/HFUTCourseSimulation/Simulation.xaml.cs +++ b/HFUTCourseSimulation/Simulation.xaml.cs @@ -137,18 +137,38 @@ namespace HFUTCourseSimulation { uiWeek7.Text = $"{pointer.Month}/{pointer.Day}"; //create grid - var query = from item in itemDict.Keys - where item.teachingweek == currentWeek - select item; + var query = (from item in itemDict.Keys + where item.teachingweek == currentWeek + select item).ToList(); - foreach (var item in query) { - //get data - var data = itemDict[item]; + 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; + } + } + + //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 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(); @@ -157,10 +177,17 @@ namespace HFUTCourseSimulation { nGrid.Children.Add(courseName); warp.Child = nGrid; - Grid.SetRow(warp, item.index - 1); - Grid.SetColumn(warp, item.week - 1); + Grid.SetRow(warp, core.index - 1); + Grid.SetColumn(warp, core.week - 1); this.uiArrangeGrid.Children.Add(warp); + + //remove first item + query.RemoveAt(0); + } + + foreach (var item in query) { + } } diff --git a/HFUTCourseSimulation/SimulationItem.cs b/HFUTCourseSimulation/SimulationItem.cs index 5172cfe..e32e73c 100644 --- a/HFUTCourseSimulation/SimulationItem.cs +++ b/HFUTCourseSimulation/SimulationItem.cs @@ -20,6 +20,11 @@ namespace HFUTCourseSimulation { public int week; public int index; + public static Vector3 operator+(Vector3 a, Vector3 b) { + return new Vector3(a.teachingweek + b.teachingweek, + a.week + b.week, a.index + b.index); + } + public static bool operator ==(Vector3 a, Vector3 b) { return (a.teachingweek == b.teachingweek && a.week == b.week && a.index == b.index); }