private void AddTimePoint() { for (int i = 0; i < timepointGrid.ColumnDefinitions.Count - 1; i++) { int columnCount = i + 1; CustomBorder cborder = new CustomBorder(); cborder.LeftBorderBrush = blackSB; cborder.RightBorderBrush = redSB; cborder.TopBorderBrush = blackSB; cborder.BottomBorderBrush = blackSB; cborder.BorderThickness = new Thickness(0, 0, 2, 1); Grid grid = new Grid(); for (int j = 0; j < 6; j++) { ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(1, GridUnitType.Star); grid.ColumnDefinitions.Add(cd); Border border = new Border(); border.BorderBrush = blackSB; if (j == 5) { border.BorderThickness = new Thickness(0); } else { border.BorderThickness = new Thickness(0, 0, 1, 0); } Button button = new Button(); button.FontSize = 9; button.Content = (j + 3 * (j + 1)).ToString(); button.Name = "timebutton" + columnCount.ToString() + j.ToString(); button.Tag = columnCount; StackPanel sp = new StackPanel(); TextBlock tb1 = new TextBlock(); tb1.FontWeight = FontWeights.Heavy; tb1.Text = "日期:" + DateTime.Today.AddDays(columnCount).ToShortDateString(); TextBlock tb2 = new TextBlock(); tb2.Text = "时间:" + (j + 3 * (j + 1)).ToString(); sp.Children.Add(tb1); sp.Children.Add(tb2); button.ToolTip = sp; button.BorderThickness = new Thickness(0); button.Background = transSB; button.Click += TimePointButtonClick; border.Child = button; grid.Children.Add(border); Grid.SetColumn(border, j); } cborder.Child = grid; timepointGrid.Children.Add(cborder); Grid.SetColumn(cborder, columnCount); Grid.SetRow(cborder, 0); } }
private void AddOther() { for (int i = 0; i < othersGrid.ColumnDefinitions.Count - 1; i++) { for (int j = 0; j < othersGrid.RowDefinitions.Count; j++) { int columnCount = i + 1; int rowCount = j; CustomBorder cborder = new CustomBorder(); cborder.LeftBorderBrush = blackSB; cborder.RightBorderBrush = redSB; cborder.TopBorderBrush = blackSB; cborder.BottomBorderBrush = blackSB; //呼吸 if (rowCount == 0) { cborder.BorderThickness = new Thickness(0, 1, 2, 1); Grid grid = new Grid(); for (int a = 0; a < 6; a++) { ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(1, GridUnitType.Star); grid.ColumnDefinitions.Add(cd); Border border = new Border(); border.BorderBrush = blackSB; if (a == 5) { border.BorderThickness = new Thickness(0); } else { border.BorderThickness = new Thickness(0, 0, 1, 0); } TextBlock textblock = new TextBlock(); textblock.FontSize = 10; textblock.Foreground = new SolidColorBrush(Colors.Red); textblock.Text = (20).ToString(); if (a % 2 == 0) { textblock.VerticalAlignment = VerticalAlignment.Top; } else { textblock.VerticalAlignment = VerticalAlignment.Bottom; } textblock.HorizontalAlignment = HorizontalAlignment.Center; border.Child = textblock; grid.Children.Add(border); Grid.SetColumn(border, a); } cborder.Child = grid; } //血压 else if (rowCount == 1) { cborder.BorderThickness = new Thickness(0, 0, 2, 1); Grid grid = new Grid(); for (int b = 0; b < 2; b++) { ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(1, GridUnitType.Star); grid.ColumnDefinitions.Add(cd); Border border = new Border(); border.BorderBrush = blackSB; if (b == 1) { border.BorderThickness = new Thickness(0); } else { border.BorderThickness = new Thickness(0, 0, 1, 0); } TextBlock textblock = new TextBlock(); textblock.FontSize = 10; textblock.Text = "133/88"; if (b % 2 == 0) { textblock.VerticalAlignment = VerticalAlignment.Top; } else { textblock.VerticalAlignment = VerticalAlignment.Bottom; } textblock.HorizontalAlignment = HorizontalAlignment.Center; border.Child = textblock; grid.Children.Add(border); Grid.SetColumn(border, b); } cborder.Child = grid; } //其他奇怪的项 else { cborder.BorderThickness = new Thickness(0, 0, 2, 1); TextBlock textblock = new TextBlock(); textblock.Name = "textblock" + columnCount.ToString() + rowCount.ToString(); textblock.FontSize = 10; textblock.Text = "1"; textblock.VerticalAlignment = VerticalAlignment.Top; textblock.HorizontalAlignment = HorizontalAlignment.Center; cborder.Child = textblock; } othersGrid.Children.Add(cborder); Grid.SetColumn(cborder, columnCount); Grid.SetRow(cborder, rowCount); } } }
private void AddTableHead() { for (int i = 0; i < tableheadGrid.ColumnDefinitions.Count - 1; i++) { for (int j = 0; j < tableheadGrid.RowDefinitions.Count; j++) { int columnCount = i + 1; int rowCount = j; CustomBorder cborder = new CustomBorder(); cborder.LeftBorderBrush = blackSB; cborder.RightBorderBrush = redSB; cborder.TopBorderBrush = blackSB; cborder.BottomBorderBrush = blackSB; //住院日数 if (rowCount == 1) { cborder.BorderThickness = new Thickness(0, 0, 2, 0); TextBlock textblock = new TextBlock(); textblock.Name = "textblock" + columnCount.ToString() + rowCount.ToString(); DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); dtFormat.ShortDatePattern = "yyyy/MM/dd"; DateTime dt = Convert.ToDateTime(dateTextblock.Text, dtFormat); TimeSpan ts = DateTime.Today - dt; int days = ts.Days + columnCount; textblock.Text = days.ToString(); textblock.VerticalAlignment = VerticalAlignment.Center; textblock.HorizontalAlignment = HorizontalAlignment.Center; cborder.Child = textblock; } //日期按钮 else if (rowCount == 0) { cborder.BorderThickness = new Thickness(0, 1, 2, 1); Button button = new Button(); button.Name = "datebutton" + columnCount.ToString(); StackPanel sp = new StackPanel(); TextBlock tb1 = new TextBlock(); tb1.FontWeight = FontWeights.Heavy; tb1.Text = "日期:" + DateTime.Today.AddDays(columnCount).ToShortDateString(); TextBlock tb2 = new TextBlock(); tb2.Text = "血压:" + "133/80"; sp.Children.Add(tb1); sp.Children.Add(tb2); button.ToolTip = sp; button.Content = DateTime.Today.AddDays(columnCount).ToShortDateString(); button.Click += HeaderButtonClick; button.Background = new SolidColorBrush(Colors.White); button.BorderThickness = new Thickness(0); cborder.Child = button; } //手术后日期 else { cborder.BorderThickness = new Thickness(0, 1, 2, 1); TextBlock textblock = new TextBlock(); textblock.Name = "textblock" + columnCount.ToString() + rowCount.ToString(); //textblock.Text = "textblock" + columnCount.ToString() + rowCount.ToString(); textblock.VerticalAlignment = VerticalAlignment.Center; textblock.HorizontalAlignment = HorizontalAlignment.Center; cborder.Child = textblock; } tableheadGrid.Children.Add(cborder); Grid.SetColumn(cborder, columnCount); Grid.SetRow(cborder, rowCount); } } }
public static Grid GetBackground() { Grid grid = new Grid(); grid.Width = 85; grid.Height = 65; for (int a = 0; a < 6; a++) { ColumnDefinition cd = new ColumnDefinition(); cd.Width = new GridLength(1, GridUnitType.Star); grid.ColumnDefinitions.Add(cd); } for (int b = 0; b < 5; b++) { RowDefinition rd = new RowDefinition(); rd.Height = new GridLength(1, GridUnitType.Star); grid.RowDefinitions.Add(rd); } for (int i = 0; i < 6; i++) { for (int j = 0; j < 5; j++) { if (i == 5 && j == 4) { CustomBorder cborder = new CustomBorder(); cborder.LeftBorderBrush = new SolidColorBrush(Colors.Black); cborder.RightBorderBrush = new SolidColorBrush(Colors.Red); cborder.TopBorderBrush = new SolidColorBrush(Colors.Black); cborder.BottomBorderBrush = new SolidColorBrush(Colors.Black); cborder.BorderThickness = new Thickness(0, 0, 2, 2); grid.Children.Add(cborder); Grid.SetColumn(cborder, i); Grid.SetRow(cborder, j); } else if (i == 5) { CustomBorder cborder = new CustomBorder(); cborder.LeftBorderBrush = new SolidColorBrush(Colors.Black); cborder.RightBorderBrush = new SolidColorBrush(Colors.Red); cborder.TopBorderBrush = new SolidColorBrush(Colors.Black); cborder.BottomBorderBrush = new SolidColorBrush(Colors.Black); cborder.BorderThickness = new Thickness(0, 0, 2, 1); grid.Children.Add(cborder); Grid.SetColumn(cborder, i); Grid.SetRow(cborder, j); } else if (j == 4) { Border border = new Border(); border.BorderBrush = new SolidColorBrush(Colors.Black); border.BorderThickness = new Thickness(0, 0, 1, 2); grid.Children.Add(border); Grid.SetColumn(border, i); Grid.SetRow(border, j); } else { Border border = new Border(); border.BorderBrush = new SolidColorBrush(Colors.Black); border.BorderThickness = new Thickness(0, 0, 1, 1); grid.Children.Add(border); Grid.SetColumn(border, i); Grid.SetRow(border, j); } } } return(grid); }