示例#1
0
 private void TbkInput_TextChanged(object sender, TextChangedEventArgs e)
 {
     string[] data = TbkInput.Text.Split('\n');
     ClearCExam();
     foreach (var item in data)
     {
         CExam c = ParseCExam(item);
         if (c != null)
         {
             AddCExam(c);
         }
     }
 }
示例#2
0
        /// <summary>
        /// 生成一个课表元素
        /// </summary>
        /// <param name="exam"></param>
        /// <returns></returns>
        private void AddCExam(CExam exam)
        {
            Grid      grid      = new Grid();
            Rectangle rectangle = new Rectangle();
            Color     next      = Get_NextColor();

            next.A            = 128;
            rectangle.Fill    = new SolidColorBrush(next);
            rectangle.RadiusX = 2;
            rectangle.RadiusY = 2;
            grid.Children.Add(rectangle);
            TextBlock tbxDect = new TextBlock();

            tbxDect.VerticalAlignment = VerticalAlignment.Top;
            tbxDect.Padding           = new Thickness(5, 2, 5, 2);
            tbxDect.Text          = exam.Dest;
            tbxDect.FontSize      = 14;
            tbxDect.TextWrapping  = TextWrapping.Wrap;
            tbxDect.Foreground    = Brushes.White;
            tbxDect.TextAlignment = TextAlignment.Center;
            grid.Children.Add(tbxDect);
            TextBlock tbxDetail = new TextBlock();

            tbxDetail.Margin            = new Thickness(0, 35, 0, 0);
            tbxDetail.Padding           = new Thickness(3);
            tbxDetail.VerticalAlignment = VerticalAlignment.Center;
            tbxDetail.TextAlignment     = TextAlignment.Center;
            tbxDetail.FontSize          = 10;
            tbxDetail.TextWrapping      = TextWrapping.Wrap;
            tbxDetail.Foreground        = Brushes.White;
            tbxDetail.Text = exam.Title + ":" + exam.Teacher;
            grid.Children.Add(tbxDetail);
            dics.Add(exam, grid);

            int h      = 2 * (exam.DayOfWeek - 1);
            int vStart = 2 * (exam.TimeStart - 1);
            int vSpan  = 2 * (exam.TimeEnd - exam.TimeStart) + 1;

            GridTable.Children.Add(grid);
            Grid.SetColumn(grid, h);
            Grid.SetRow(grid, vStart);
            Grid.SetRowSpan(grid, vSpan);
        }