void tb_MouseEnter(object sender, MouseEventArgs e) { TextBlock tb = (TextBlock)sender; Rent r = (Rent)(tb.Tag); tb.Background = MyColor.NameBrush(r.Info, 0.8); }
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; }
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); } }