//设置教室。在教室发生变化的时候切换UI
        private void SetCId(int cId)
        {
            Classroom C = Building.GetClassroom(cId);

            if (null == C)
            {
                return;
            }
            if (classroom != null && classroom.cId == C.cId)
            {
                return;
            }

            TextBoxCId.Text = cId.ToString();

            classroom = C;

            LabelClassroom.Content = classroom.Name + "的第" + Schedule.CurrWeek + "周";


            sch2.ChangeOwner(classroom);

            checkoutWeek();
            ChosenRentControl();
        }
        private void MyTextBlockInitialize(TextBlock tb, Rent r)
        {
            tb.Tag    = r;
            tb.Height = 125; tb.Width = 125;
            tb.Margin = new Thickness(10);

            tb.Background = MyColor.NameBrush(r.Info);
            tb.Text       = r.Info; if (!r.Approved)
            {
                tb.Text += "(未审核)";
            }
            Classroom c = Building.GetClassroom(r.cId); if (c != null)

            {
                tb.Text += ("@" + c.Name);
            }

            tb.FontSize = 16;

            //  tb.Foreground = new SolidColorBrush(textColor);
            tb.TextWrapping = TextWrapping.Wrap;

            tb.MouseDown += tb_MouseDown;

            tb.MouseEnter += tb_MouseEnter;
            tb.MouseLeave += tb_MouseLeave;
        }
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            if (rent == null)
            {
                return;
            }

            TBinfo.Text = rent.Info;
            if (!rent.Approved)
            {
                TBinfo.Text += " (未审核)";
            }
            TBinfo.Background = new SolidColorBrush(MyColor.NameColor(rent.Info, 0.2));
            TBinfo.Foreground = new SolidColorBrush(WindowIndex.textColor);

            TBhost.Content = "申请人: " + DatabaseLinker.GetName(rent.pId);

            Classroom c = Building.GetClassroom(rent.cId);

            if (c != null)
            {
                TBclassroom.Content = "教室: " + c.Name;
            }
            else
            {
                TBclassroom.Visibility      = Visibility.Collapsed;
                TBclassroom_Copy.Visibility = Visibility.Collapsed;
            }

            TBrentTime.Content = "时间: " + rent.Time.Display();

            List <int> listPId = DatabaseLinker.GetPIdList(rent.rId);

            TBtakepartinInfo.Content = "参加人数: " + listPId.Count;

            if (rent.Time.BeenOver)
            {
                TBChoose.Content = "课程已结束";
            }
            else if (father.personRentTable.Contains(rent.rId))
            {
                TBChoose.Content = "从我的课程表删除";
            }
            else
            {
                TBChoose.Content = "加入我的课程表";
            }

            if (rent.Approved || father.Peron is User)
            {
                TBOK.Visibility      = Visibility.Collapsed;
                TBDecline.Visibility = Visibility.Collapsed;
            }
        }
        //初始化单个课程
        private void TextBlockInitialize(TextBlock tb, Rent r, bool MouseShow = true)
        {
            tb.Tag = r;

            tb.Background = MyColor.NameBrush(r.Info);
            tb.Text       = r.Info; if (!r.Approved)
            {
                tb.Text += "(未审核)";
            }
            Classroom c = Building.GetClassroom(r.cId); if (c != null)

            {
                tb.Text += ("@" + c.Name);
            }

            if (Father.WindowState == WindowState.Maximized)
            {
                tb.FontSize = 16;
            }
            else
            {
                tb.FontSize = 14;
            }

            tb.Foreground   = new SolidColorBrush(WindowIndex.textColor);
            tb.TextWrapping = TextWrapping.Wrap;


            tb.SetValue(Grid.ColumnProperty, r.Time.WeekDay);
            tb.SetValue(Grid.RowProperty, r.Time.StartClass - 1);
            tb.SetValue(Grid.RowSpanProperty, r.Time.KeepClass);

            tb.MouseDown += tb_MouseDown;

            if (MouseShow)
            {
                tb.MouseEnter += tb_MouseEnter;
                tb.MouseLeave += tb_MouseLeave;
            }
        }
        //(管理员功能)查看未审核课程
        private void TextBlockUnapprovedRentInitialize(TextBlock tb, Rent r)
        {
            string    applicantName = DatabaseLinker.GetName(r.pId);
            string    s             = r.Info;
            Classroom c             = Building.GetClassroom(r.cId); if (c != null)

            {
                s += ("@" + c.Name);
            }

            tb.Inlines.Add(new Bold(new Run(applicantName + ":\r\n")));
            tb.Inlines.Add(new Run("  " + s));

            tb.FontSize = 24;
            tb.Padding  = new Thickness(16);

            tb.MouseDown  += tbRent_MouseDown;
            tb.MouseEnter += tbRent_MouseEnter;
            tb.MouseLeave += tbRent_MouseLeave;

            tb.Tag = r;
        }
Пример #6
0
        public string Display()
        {
            string s = "";

            s += info + "\r\n";
            s += "申请人: " + DatabaseLinker.GetName(pId) + " 编号: R" + rid + "\r\n";

            Classroom c = Building.GetClassroom(cid);

            if (c != null)
            {
                s += "教室: " + c.Name + "  ";
            }
            s += "上课时间: " + Time.Display();


            //s += " :: ";
            //foreach (int id in Students)
            //{
            //    s += DatabaseLinker.GetName(id)+" ";
            //}

            return(s);
        }
        //全体键盘托管
        private void Window_PreviewKeyDown_1(object sender, KeyEventArgs e)
        {
            //换肤
            switch (e.Key)
            {
            case Key.F1: SetSkin(skin.Starry); break;

            case Key.F2: SetSkin(skin.ColorBox); break;

            case Key.D1: SetStatus(status.Info); break;

            case Key.D2: SetStatus(status.Table); break;

            case Key.D3:
                RentTable rt = new RentTable(DatabaseLinker.GetDateRentTable(Schedule.CurrDate).GetFromDateClass(Schedule.CurrDate, Schedule.CurrClass));
                new WindowClassroomList(rt, this).ShowDialog();
                break;

            case Key.D4: SetStatus(status.Message); break;
            }

            switch (currStatus)
            {
            case status.Table:
                //课程表控制
                if (!TextBoxCId.IsKeyboardFocused)
                {
                    switch (e.Key)
                    {
                    case Key.Up: if (Schedule.CurrClass > 1)
                        {
                            --Schedule.CurrClass;
                        }
                        break;

                    case Key.Down: if (Schedule.CurrClass < cntRow)
                        {
                            ++Schedule.CurrClass;
                        }
                        break;

                    case Key.Left: if (Schedule.CurrDate > RentTime.FirstDate)
                        {
                            Schedule.CurrDate -= new TimeSpan(1, 0, 0, 0);
                        }
                        break;

                    case Key.Right: if (Schedule.CurrDate < RentTime.LastDate)
                        {
                            Schedule.CurrDate += new TimeSpan(1, 0, 0, 0);
                        }
                        break;

                    case Key.Home: Schedule.CurrClass = 1; break;

                    case Key.End: Schedule.CurrClass = cntRow; break;

                    case Key.PageUp: if (Schedule.CurrWeek > 1)
                        {
                            Schedule.CurrDate -= new TimeSpan(7, 0, 0, 0);
                        }
                        break;

                    case Key.PageDown: if (Schedule.CurrWeek < 23)
                        {
                            Schedule.CurrDate += new TimeSpan(7, 0, 0, 0);
                        }
                        break;

                    case Key.Enter:
                        Rent r = sch1.ChosenRent;
                        if (r == null)
                        {
                            break;
                        }
                        new WindowRent(r, this).ShowDialog();
                        break;
                    }
                    SetDateClass(Schedule.CurrDate, Schedule.CurrClass);
                }
                else
                //教室控制
                {
                    int b, c;
                    if (classroom == null)
                    {
                        b = 0; c = 0;
                    }
                    else
                    {
                        b = classroom.Building.bId; c = classroom.cId;
                    }

                    switch (e.Key)
                    {
                    case Key.Up:
                        while (c < Classroom.MaxCId)
                        {
                            ++c;
                            if (Building.GetClassroom(c) != null)
                            {
                                break;
                            }
                        }
                        break;

                    case Key.Down:
                        while (c > Classroom.MinCId)
                        {
                            --c;
                            if (Building.GetClassroom(c) != null)
                            {
                                break;
                            }
                        }
                        break;

                    case Key.PageUp:
                        while (b < Building.MaxBId)
                        {
                            ++b;
                            if (Building.GetBuilding(b) != null)
                            {
                                c = Building.GetBuilding(b).Classrooms[0].cId;
                                break;
                            }
                        }
                        break;

                    case Key.PageDown:
                        while (b > Building.MinBId)
                        {
                            --b;
                            if (Building.GetBuilding(b) != null)
                            {
                                c = Building.GetBuilding(b).Classrooms[0].cId;
                                break;
                            }
                        }
                        break;
                    }
                    SetCId(c);
                }
                break;
            }
        }