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; } }
void tb_MouseLeave(object sender, MouseEventArgs e) { TextBlock tb = (TextBlock)sender; if (!tb.Text.Contains(":")) { tb.Background = MyColor.NameBrush(tb.Text, 0.05);//new SolidColorBrush(MyColor.NameColor(tb.Text, 0.05)); } else { tb.Background = MyColor.NameBrush(tb.Text); // new SolidColorBrush(MyColor.NameColor(tb.Text)); } }
private TextBlock Hightlight(TextBlock tbh, Rent r, Grid grid) { if (grid.Children.Contains(tbh)) { tbh.Visibility = Visibility.Collapsed; grid.Children.Remove(tbh); } if (r == null) { return(null); } tbh = new TextBlock(); grid.Children.Add(tbh); TextBlockInitialize(tbh, r, false); tbh.Background = MyColor.NameBrush(r.Info, 1); return(tbh); }
//初始化单个课程 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 stackPanel_Loaded(object sender, RoutedEventArgs e) { switch (WindowIndex.currSkin) { case WindowIndex.skin.Starry: BorderBack.Background = new ImageBrush(WindowIndex.ChangeBitmapToImageSource(Properties.Resources.listback)); break; case WindowIndex.skin.ColorBox: BorderBack.Background = new ImageBrush(WindowIndex.ChangeBitmapToImageSource(Properties.Resources.Color1)); break; } foreach (Building building in Building.AllBuildings) { TextBlock tbTitle = new TextBlock(); tbTitle.Padding = new Thickness(24, 16, 26, 10); tbTitle.TextWrapping = TextWrapping.Wrap; tbTitle.Text = building.Name; tbTitle.FontSize = 24; // tbTitle.Background = new SolidColorBrush(MyColor.NameColor(building.Name, 0.05)); WrapPanel subPanel = new WrapPanel(); subPanel.Orientation = Orientation.Horizontal; subPanel.Margin = new Thickness(24, 0, 24, 0); foreach (Classroom classroom in building.Classrooms) { TextBlock tb = new TextBlock(); tb.Height = 125; tb.Width = 125; tb.FontSize = 16; tb.Margin = new Thickness(5); tb.TextWrapping = TextWrapping.Wrap; Rent rent = rentTable.GetClassroom(classroom.cId); if (rent == null) { tb.Height = 60; tb.Width = 60; tb.FontSize = 12; tb.Text = classroom.Name; tb.Background = MyColor.NameBrush(tb.Text, 0.05); //new SolidColorBrush(MyColor.NameColor(tb.Text, 0.05)); } else { tb.Text = classroom.Name + ":" + rent.Info; tb.Background = MyColor.NameBrush(tb.Text); //new SolidColorBrush(MyColor.NameColor(tb.Text)); } tb.Tag = classroom; tb.MouseDown += tb_MouseDown; tb.MouseEnter += tb_MouseEnter; tb.MouseLeave += tb_MouseLeave; subPanel.Children.Add(tb); } stackPanel.Children.Add(tbTitle); stackPanel.Children.Add(subPanel); } }
void tbRent_MouseEnter(object sender, MouseEventArgs e) { TextBlock tb = sender as TextBlock; tb.Background = new SolidColorBrush(MyColor.NameColor(tb.Text, 0.2)); }
private void TBclassroom_MouseEnter(object sender, MouseEventArgs e) { Label tb = (Label)sender; tb.Background = new SolidColorBrush(MyColor.NameColor(TBinfo.Text, 0.2)); }
private void TB_MouseEnter(object sender, MouseEventArgs e) { Label tb = (Label)sender; tb.Background = new SolidColorBrush(MyColor.NameColor(rent.Info, 0.2)); }