本文整理汇总了C#中MainWindow.GetColumnIdByView方法的典型用法代码示例。如果您正苦于以下问题:C# MainWindow.GetColumnIdByView方法的具体用法?C# MainWindow.GetColumnIdByView怎么用?C# MainWindow.GetColumnIdByView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainWindow
的用法示例。
在下文中一共展示了MainWindow.GetColumnIdByView方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportToXaml
public static string ExportToXaml(OutlinerDocument Document, MainWindow wnd)
{
FlowDocument wholeDocument = new FlowDocument();
wholeDocument.FontFamily = UVOutliner.Settings.DefaultFontFamily;
wholeDocument.FontSize = UVOutliner.Settings.DefaultFontSize;
List<OutlinerNote> linearList = new List<OutlinerNote>();
DocumentHelpers.GetLinearNotesList(Document.RootNode, linearList, false);
double totalWidth = 0;
for (int i = 0; i < Document.ColumnDefinitions.Count; i++)
totalWidth += Document.ColumnDefinitions[i].Width;
// just random
if (totalWidth == 0)
totalWidth = 300;
Table table = new Table();
table.LineHeight = 1;
table.Margin = new Thickness(0);
table.Padding = new Thickness(0);
wholeDocument.Blocks.Add(table);
for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++)
{
int columnId = wnd.GetColumnIdByView(i);
TableColumn column = new TableColumn();
column.Width = new GridLength(Document.ColumnDefinitions[columnId].Width / totalWidth, GridUnitType.Star);
table.Columns.Add(column);
}
// add column headers
if (Document.ColumnDefinitions.Count > 1)
{
TableRowGroup rowGroup = new TableRowGroup();
table.RowGroups.Add(rowGroup);
TableRow row = new TableRow();
rowGroup.Rows.Add(row);
for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++)
{
int columnId = wnd.GetColumnIdByView(i);
row.Cells.Add(new TableCell(new Paragraph(new Run(Document.ColumnDefinitions[columnId].ColumnName))));
}
}
TableRowGroup mainRowGroup = new TableRowGroup();
table.RowGroups.Add(mainRowGroup);
// add all other columns
for (int i = 0; i < linearList.Count; i++)
{
TableRow tableRow = new TableRow();
OutlinerNote note = linearList[i];
if (note.IsEmpty)
{
tableRow.Cells.Add(new TableCell(new Paragraph()));
mainRowGroup.Rows.Add(tableRow);
continue;
}
for (int c = 0; c < wnd.OutlinerTreeColumns.Count; c++)
{
int columnId = wnd.GetColumnIdByView(c);
FlowDocument flowDocument = linearList[i].Columns[columnId].ColumnData as FlowDocument;
if (flowDocument == null)
{
tableRow.Cells.Add(new TableCell());
continue;
}
double indent = note.Level * 20;
TableCell cell = new TableCell();
tableRow.Cells.Add(cell);
Section section = XamlReader.Load(TransformFlowDocumentToSection(flowDocument)) as Section;
if (section == null)
continue;
if (columnId != 0)
cell.Blocks.Add(section);
else
{
Table tbl = new Table();
tbl.LineHeight = 1;
tbl.Margin = new Thickness(0);
tbl.Padding = new Thickness(0);
TableColumn c1 = new TableColumn();
c1.Width = new GridLength(indent + 20 + (Document.CheckboxesVisble ? 20 : 0), GridUnitType.Pixel);
TableColumn c2 = new TableColumn();
c2.Width = new GridLength(1, GridUnitType.Auto);
tbl.Columns.Add(c1);
tbl.Columns.Add(c2);
var tmpRowGroup = new TableRowGroup();
var tmpRow = new TableRow();
tmpRowGroup.Rows.Add(tmpRow);
tbl.RowGroups.Add(tmpRowGroup);
//.........这里部分代码省略.........
示例2: Export
public static string Export(OutlinerDocument Document, MainWindow wnd)
{
StringBuilder writer = new StringBuilder();
writer.AppendLine("<html>");
writer.AppendLine("<head>");
writer.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />");
writer.AppendLine(String.Format("<title>{0}</title>", System.IO.Path.GetFileName(Document.FileName)));
writer.AppendLine("<style>p {{margin:0px;}}");
writer.AppendLine(" td {padding:0px;}");
writer.AppendLine(" th {font-size:12px; align:right; font-family: Helvetica,Arial,sans-serif;}" );
writer.AppendLine(" td#column{padding-left:4px;}");
writer.AppendLine(" td#note{padding-left:4px;}");
writer.AppendLine(" img#exp {padding-right:1px;}");
writer.AppendLine(" img#checkbox {padding-right:1px;}");
writer.AppendLine(" img#bul {padding-right:1px;}");
writer.AppendLine("</style>");
writer.AppendLine("</head>");
writer.AppendLine("<body topmargin=0>\n");
FlowDocument wholeDocument = new FlowDocument();
wholeDocument.FontFamily = UVOutliner.Settings.DefaultFontFamily;
wholeDocument.FontSize = UVOutliner.Settings.DefaultFontSize;
List<OutlinerNote> linearList = new List<OutlinerNote>();
DocumentHelpers.GetLinearNotesList(Document.RootNode, linearList, false);
double totalWidth = 0;
for (int i = 0; i < Document.ColumnDefinitions.Count; i++)
totalWidth += Document.ColumnDefinitions[i].Width;
writer.AppendLine("<table width='100%'>");
int[] columnWidths = new int[wnd.OutlinerTreeColumns.Count];
for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++)
columnWidths[i] = (int)((Document.ColumnDefinitions[wnd.GetColumnIdByView(i)].Width / totalWidth) * 100);
// add column headers
if (Document.ColumnDefinitions.Count > 1)
{
writer.AppendLine("<tr>");
for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++)
{
int columnId = wnd.GetColumnIdByView(i);
writer.Append( String.Format("<th width='{0}%'>", columnWidths[i]));
writer.Append(Document.ColumnDefinitions[columnId].ColumnName);
writer.AppendLine("</th>");
}
writer.AppendLine("</tr>");
}
// add all other columns
for (int i = 0; i < linearList.Count; i++)
{
OutlinerNote note = linearList[i];
double indent = (Math.Max(0, note.Level - 1)) * 20;
string indent_str = ""; for (int t = 0; t < indent / 10; t++) indent_str += " ";
if (note.IsEmpty)
{
writer.AppendLine(indent_str + "<tr><td> </td></tr>");
continue;
}
writer.AppendLine(indent_str + "<tr>");
for (int c = 0; c < wnd.OutlinerTreeColumns.Count; c++)
{
int columnId = wnd.GetColumnIdByView(c);
FlowDocument flowDocument = linearList[i].Columns[columnId].ColumnData as FlowDocument;
if (flowDocument == null)
{
writer.AppendLine(indent_str + "<td></td>");
continue;
}
if (columnId != 0)
{
string style;
var html = OpenSave.HtmlFromReport(flowDocument, out style);
writer.AppendLine(String.Format(indent_str + "<td id=column style='{0}'>{1}</td>", style, html));
}
else
{
writer.AppendLine(indent_str + "<td>");
writer.AppendLine(indent_str + " <table width='100%'>");
writer.AppendLine(indent_str + " <tr><td>");
writer.Append(String.Format(indent_str + " <nobr><div style='margin-left: {0}px;'>", indent));
if (note.SubNotes.Count == 0)
writer.Append("<img src='uvbul.png' id=bul width=14 height=14 alt='•'>");
else
{
if (note.IsExpanded)
writer.Append("<img src='uvndexpa.png' id=exp width=14 height=14>");
else
writer.Append("<img src='uvndcol.png' id=exp width=14 height=14>");
}
if (Document.CheckboxesVisble)
//.........这里部分代码省略.........
示例3: ExportToXaml_MultiColumn
public static string ExportToXaml_MultiColumn(OutlinerDocument Document, MainWindow wnd)
{
FlowDocument wholeDocument = new FlowDocument();
wholeDocument.FontFamily = UVOutliner.Settings.DefaultFontFamily;
wholeDocument.FontSize = UVOutliner.Settings.DefaultFontSize;
List<OutlinerNote> linearList = new List<OutlinerNote>();
DocumentHelpers.GetLinearNotesList(Document.RootNode, linearList, false);
double totalWidth = 0;
for (int i = 0; i < Document.ColumnDefinitions.Count; i++)
totalWidth += Document.ColumnDefinitions[i].Width;
//temporary
//pageWidth = totalWidth;
// just random
if (totalWidth == 0)
totalWidth = 300;
Table table = new Table();
table.LineHeight = 1;
table.Margin = new Thickness(0);
table.Padding = new Thickness(0);
wholeDocument.Blocks.Add(table);
for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++)
{
int columnId = wnd.GetColumnIdByView(i);
TableColumn column = new TableColumn();
//column.Width = new GridLength(Document.ColumnDefinitions[columnId].Width * pageWidth / totalWidth, GridUnitType.Pixel);
column.Width = new GridLength(Document.ColumnDefinitions[columnId].Width / totalWidth, GridUnitType.Star);
//column.Width = new GridLength(0, GridUnitType.Auto);
table.Columns.Add(column);
}
// add column headers
if (Document.ColumnDefinitions.Count > 1)
{
TableRowGroup rowGroup = new TableRowGroup();
table.RowGroups.Add(rowGroup);
TableRow row = new TableRow();
rowGroup.Rows.Add(row);
for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++)
{
int columnId = wnd.GetColumnIdByView(i);
row.Cells.Add(new TableCell(new Paragraph(new Run(Document.ColumnDefinitions[columnId].ColumnName))));
}
}
TableRowGroup mainRowGroup = new TableRowGroup();
table.RowGroups.Add(mainRowGroup);
// add all other columns
for (int i = 0; i < linearList.Count; i++)
{
TableRow tableRow = new TableRow();
OutlinerNote note = linearList[i];
if (note.IsEmpty)
{
tableRow.Cells.Add(new TableCell(new Paragraph()));
mainRowGroup.Rows.Add(tableRow);
continue;
}
for (int c = 0; c < wnd.OutlinerTreeColumns.Count; c++)
{
int columnId = wnd.GetColumnIdByView(c);
FlowDocument flowDocument = linearList[i].Columns[columnId].ColumnData as FlowDocument;
if (flowDocument == null)
{
tableRow.Cells.Add(new TableCell());
continue;
}
double indent = (Math.Max(0, note.Level - 1)) * 20;
TableCell cell = new TableCell();
tableRow.Cells.Add(cell);
Section section = XamlReader.Load(ExportToXaml_Printing.TransformFlowDocumentToSection(flowDocument)) as Section;
if (section == null)
continue;
if (columnId != 0)
cell.Blocks.Add(section);
else
{
Paragraph para = new Paragraph();
para.Margin = new Thickness(indent, 0, 0, 0);
Image expImage = new Image();
expImage.Margin = new Thickness(0, 2, 0, 0);
expImage.Width = 14;
expImage.Height = 14;
expImage.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor);
BitmapImage bImage = new BitmapImage();
//.........这里部分代码省略.........