本文整理汇总了C#中System.Windows.Documents.Table类的典型用法代码示例。如果您正苦于以下问题:C# Table类的具体用法?C# Table怎么用?C# Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Table类属于System.Windows.Documents命名空间,在下文中一共展示了Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTable
public void CreateTable(int count)
{
// Create the parent FlowDocument...
flowDoc = new FlowDocument();
// Create the Table...
table1 = new Table();
table1.BringIntoView();
// ...and add it to the FlowDocument Blocks collection.
flowDoc.Blocks.Add(table1);
// Set some global formatting properties for the table.
table1.CellSpacing = 10;
table1.Background = Brushes.White;
// Create 6 columns and add them to the table's Columns collection.
int numberOfColumns = 6;
for (int x = 0; x < numberOfColumns; x++)
{
table1.Columns.Add(new TableColumn());
// Set alternating background colors for the middle colums.
if (x % 2 == 0)
table1.Columns[x].Background = Brushes.Beige;
else
table1.Columns[x].Background = Brushes.LightSteelBlue;
}
}
示例2: BuildTable
internal static Table BuildTable(int rowCount,
int columnCount,
Brush borderBrush,
Thickness borderThickness,
double dLineHeight,
TableType tableType)
{
Table table = new Table();
table.Tag = tableType;
table.CellSpacing = 2;
table.BorderBrush = borderBrush;
table.BorderThickness = borderThickness;
table.MouseEnter += new MouseEventHandler(table_MouseEnter);
table.MouseLeave += new MouseEventHandler(table_MouseLeave);
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
{
TableColumn tableColumn = new TableColumn();
tableColumn.Width = double.IsNaN(dLineHeight) ? GridLength.Auto : new GridLength(dLineHeight);
table.Columns.Add(tableColumn);
}
TableRowGroup rowGroup = new TableRowGroup();
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
{
TableRow row = BuildTableRow(columnCount,borderBrush,borderThickness,dLineHeight);
rowGroup.Rows.Add(row);
}
table.RowGroups.Add(rowGroup);
return table;
}
示例3: GetThreatTable
public Table GetThreatTable()
{
var threatTable = new Table();
threatTable.CellSpacing = 0;
threatTable.Columns.Add(new TableColumn());
threatTable.Columns.Add(new TableColumn());
threatTable.Columns.Add(new TableColumn());
threatTable.Columns.Add(new TableColumn());
var headerGroup = new TableRowGroup();
headerGroup.Rows.Add(new TableRow());
headerGroup.Rows[0].FontWeight = FontWeights.Bold;
var headerRow = headerGroup.Rows[0];
headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Skill"))));
headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Count"))));
headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Threat"))));
headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Threat %"))));
threatTable.RowGroups.Add(headerGroup);
var rowGroup = new TableRowGroup();
var totalThreat = TotalThreat;
foreach (var item in ThreatRecordsBySkill.OrderByDescending(records => records.Sum(record => record.Threat)))
{
var row = new TableRow();
row.Cells.Add(new TableCell(new Paragraph(new Run(item.Key))));
row.Cells.Add(new TableCell(new Paragraph(new Run(item.Count().ToString()))));
row.Cells.Add(new TableCell(new Paragraph(new Run(item.Sum(record => record.Threat).ToString()))));
row.Cells.Add(new TableCell(new Paragraph(new Run(item.Sum(record => (double)record.Threat / totalThreat).ToString("0.##%")))));
rowGroup.Rows.Add(row);
}
rowGroup.Rows.Add(new TableRow());
threatTable.RowGroups.Add(rowGroup);
return threatTable;
}
示例4: AddTable
public void AddTable(string tableName, params string[] headers)
{
var table = new Table
{
CellSpacing = 0,
BorderThickness = new Thickness(0.5, 0.5, 0, 0),
BorderBrush = Brushes.Black
};
Document.Blocks.Add(table);
Tables.Add(tableName, table);
var lengths = ColumnLengths.ContainsKey(tableName)
? ColumnLengths[tableName]
: new[] { GridLength.Auto, GridLength.Auto, new GridLength(1, GridUnitType.Star) };
for (var i = 0; i < headers.Count(); i++)
{
var c = new TableColumn { Width = lengths[i] };
table.Columns.Add(c);
}
var rows = new TableRowGroup();
table.RowGroups.Add(rows);
rows.Rows.Add(CreateRow(headers, new[] { TextAlignment.Center }, true));
}
示例5: CancelPreviewInsertTable
internal void CancelPreviewInsertTable()
{
if (_previousTable != null)
{
flowDoc.Blocks.Remove(_previousTable);
_previousTable = null;
}
}
示例6: AddTitleRow
private void AddTitleRow(Table table, string titleName)
{
table.RowGroups[0].Rows.Add(new TableRow());
var row = table.RowGroups[0].Rows[table.RowGroups[0].Rows.Count - 1];
row.Style = (Style)row.FindResource("TableHeaderStyle");
row.Cells.Add(new TableCell(new Paragraph(new Run(titleName))) {ColumnSpan = 2});
}
示例7: AddDescrRow
private void AddDescrRow(Table table, string leftCellText, string rightCellText)
{
table.RowGroups[0].Rows.Add(new TableRow());
var row = table.RowGroups[0].Rows[table.RowGroups[0].Rows.Count - 1];
row.Style = (Style)row.FindResource("TableTextStyle");
row.Cells.Add(new TableCell(new Paragraph(new Run(leftCellText))));
row.Cells.Add(new TableCell(new Paragraph(new Run(rightCellText))));
}
示例8: UserControl_Loaded
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
//rtbMessages.Document.Blocks.Add(new Paragraph());
msgTable = new Table();
rtbMessages.Document.Blocks.Add(msgTable);
msgTable.CellSpacing = 10;
msgTable.Background = Brushes.White;
msgTable.RowGroups.Add(new TableRowGroup());
TX = msgTable.RowGroups[0];
}
示例9: ReadTable
private static IEnumerable<string> ReadTable(Table table)
{
var result = new List<string> { " " };
var colLenghts = new int[table.Columns.Count];
var colAlignments = new TextAlignment[table.Columns.Count];
foreach (var row in table.RowGroups[0].Rows)
{
for (var i = 0; i < row.Cells.Count; i++)
{
if (row == table.RowGroups[0].Rows[1])
colAlignments[i] = (row.Cells[i].Blocks.First()).TextAlignment;
var value = string.Join(" ", ReadBlocks(row.Cells[i].Blocks));
if (value.Length > colLenghts[i] && row.Cells[0].ColumnSpan == 1)
colLenghts[i] = value.Length;
}
}
foreach (var row in table.RowGroups[0].Rows)
{
if (row == table.RowGroups[0].Rows[0]) result.Add("<EB>");
var rowValue = "";
for (var i = 0; i < row.Cells.Count; i++)
{
var values = ReadBlocks(row.Cells[i].Blocks);
if (i == row.Cells.Count - 1 && row != table.RowGroups[0].Rows[0])
rowValue += " | " + string.Join(" ", values);
else
{
var value = string.Join(" ", values);
if (i < row.Cells.Count)
{
value = colAlignments[i] == TextAlignment.Right
? value.PadLeft(colLenghts[i] + 1)
: value.PadRight(colLenghts[i] + 1);
}
rowValue += value;
}
}
if (row == table.RowGroups[0].Rows[0])
{
result.Add("<C00>" + rowValue);
result.Add("<DB>");
}
else result.Add("<J00>" + rowValue);
}
return result;
}
示例10: ReporterCreator
public ReporterCreator(DataBase data, ReportKind reportKind)
{
_reportKind = reportKind;
Document = new FlowDocument { ColumnWidth = 15000 };
var mainTable = new Table
{
FontFamily = new FontFamily("Arial")
};
BaseRows(data, ref mainTable);
Document.Blocks.Add(mainTable);
}
示例11: FillTableWithEmptyCells
private void FillTableWithEmptyCells(Table t)
{
foreach(TableRowGroup trg in t.RowGroups)
{
foreach(TableRow tr in trg.Rows)
{
int addcells = maxc - tr.Cells.Count ;
for (int i = 0; i < addcells;i++ )
{
tr.Cells.Add(new TableCell());
}
}
}
}
示例12: UpdateTable
// Build a table with a given number of rows and columns
internal static Table UpdateTable(Table table,
int rowCount,
int columnCount,
Brush borderBrush,
Thickness borderThickness,
double dLineHeight,
TableType tableType)
{
table.Tag = tableType;
table.CellSpacing = 2;
table.BorderBrush = borderBrush;
table.BorderThickness = borderThickness;
table.MouseEnter += new MouseEventHandler(table_MouseEnter);
table.MouseLeave += new MouseEventHandler(table_MouseLeave);
if (0 >= table.Columns.Count)
{
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
{
TableColumn tableColumn = new TableColumn();
tableColumn.Width = double.IsNaN(dLineHeight) ? GridLength.Auto : new GridLength(dLineHeight);
table.Columns.Add(tableColumn);
}
}
else
{
foreach (TableColumn tableColumn in table.Columns)
{
tableColumn.Width = double.IsNaN(dLineHeight) ? GridLength.Auto : new GridLength(dLineHeight);
}
}
foreach(TableRowGroup rowGroup in table.RowGroups)
{
foreach (TableRow row in rowGroup.Rows)
{
foreach (TableCell cell in row.Cells)
{
cell.BorderBrush = borderBrush;
cell.BorderThickness = borderThickness;
}
}
}
return table;
}
示例13: AddSmallContainers
private void AddSmallContainers(Table tab, List<Container> tempList, int i, int i2)
{
//печатаем заголовок
var i3 = 1;
tab.RowGroups[0].Rows.Add(new TableRow());
var currentRow = tab.RowGroups[0].Rows[i2 + i3];
currentRow.Background = Brushes.White;
currentRow.FontSize = 18;
currentRow.FontWeight = FontWeights.Normal;
currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Шаг " + i + ": Загрузите следующие контейнеры:"))));
currentRow.Cells[0].ColumnSpan = 2;
foreach (var c in tempList)
{
i3++;
tab.RowGroups[0].Rows.Add(new TableRow());
currentRow = tab.RowGroups[0].Rows[i2 + i3];
currentRow.Background = Brushes.White;
currentRow.FontSize = 14;
currentRow.FontWeight = FontWeights.Normal;
currentRow.Cells.Add(
new TableCell(new Paragraph(new Run(c.Name + ": " + c.Vgh + "; " + c.Mass + " кг."))));
currentRow.Cells[0].ColumnSpan = 2;
}
}
示例14: FormatFragmentsList
public static Table FormatFragmentsList(IEnumerable<Fragment> fragments)
{
var thetable = new Table();
var tableRowGroup = new TableRowGroup();
var headerRow = new TableRow { Background = new SolidColorBrush(Colors.LightGray) };
headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Déplacement"))) { BorderBrush = new SolidColorBrush(Colors.Gray) });
headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Taille"))) { BorderBrush = new SolidColorBrush(Colors.Gray) });
headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Bit More Fragments"))) { BorderBrush = new SolidColorBrush(Colors.Gray) });
tableRowGroup.Rows.Add(headerRow);
foreach (var fragment in fragments)
{
var row = new TableRow();
row.Cells.Add(new TableCell(new Paragraph(new Run(fragment.Offset.ToString()))) { BorderBrush = new SolidColorBrush(Colors.Gray), BorderThickness = new Thickness(0, 0, 0, 0.2) });
row.Cells.Add(new TableCell(new Paragraph(new Run(fragment.Length.ToString()))) { BorderBrush = new SolidColorBrush(Colors.Gray), BorderThickness = new Thickness(0, 0, 0, 0.2) });
row.Cells.Add(new TableCell(new Paragraph(new Run(fragment.MoreFragments.ToString()))) { BorderBrush = new SolidColorBrush(Colors.Gray), BorderThickness = new Thickness(0, 0, 0, 0.2) });
tableRowGroup.Rows.Add(row);
}
thetable.RowGroups.Add(tableRowGroup);
return thetable;
}
示例15: GetCellInfoFromPoint
/// <summary>
/// Returns a cellinfo class for a point that may be inside of a cell
/// </summary>
/// <param name="point">
/// Point to hit test
/// </param>
/// <param name="tableFilter">
/// Filter out all results not specific to a given table
/// </param>
/// <returns>
/// Returns cellinfo structure.
/// </returns>
internal CellInfo GetCellInfoFromPoint(Point point, Table tableFilter)
{
// Verify that layout information is valid. Cannot continue if not valid.
if (!IsValid)
{
throw new InvalidOperationException(SR.Get(SRID.TextViewInvalidLayout));
}
return GetCellInfoFromPoint(Columns, FloatingElements, point, tableFilter);
}