private static void FormatList(SnapList list) { // Customize the list header. SnapDocument header = list.ListHeader; Table headerTable = header.Tables[0]; foreach (TableRow row in headerTable.Rows) { foreach (TableCell cell in row.Cells) { // Apply cell formatting. cell.Borders.Left.LineColor = System.Drawing.Color.White; cell.Borders.Right.LineColor = System.Drawing.Color.White; cell.Borders.Top.LineColor = System.Drawing.Color.White; cell.Borders.Bottom.LineColor = System.Drawing.Color.White; cell.BackgroundColor = System.Drawing.Color.SteelBlue; // Apply text formatting. CharacterProperties formatting = header.BeginUpdateCharacters(cell.ContentRange); formatting.Bold = true; formatting.ForeColor = System.Drawing.Color.White; header.EndUpdateCharacters(formatting); } } }
static void ApplySorting(SnapList list, GridView grid) { foreach (GridColumn col in grid.SortedColumns) { list.Sorting.Add(new SnapListGroupParam(col.FieldName, col.SortOrder)); } }
private void Form1_Load(object sender, EventArgs e) { // Create a dataset and bind the Snap control to data. DataSet ds = new DataSet(); DataTable dt = new DataTable("Customers"); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Rows.Add(1, "Steven Buchanan"); dt.Rows.Add(2, "Anne Dodsworth"); dt.Rows.Add(3, "Janet Levering"); ds.Tables.Add(dt); this.snapControl1.DataSources.Add("DS", ds); // Create a Snap list and populate it with the data. SnapList snList = this.snapControl1.Document.CreateSnList( this.snapControl1.Document.Range.Start, "List1"); snList.BeginUpdate(); snList.DataSourceName = "DS"; snList.DataMember = "Customers"; SnapDocument listRow = snList.RowTemplate; Table listRowTable = listRow.Tables.Create(listRow.Range.Start, 1, 2); TableCellCollection listRowCells = listRowTable.FirstRow.Cells; listRow.CreateSnText(listRowCells[0].ContentRange.End, @"Id"); listRow.CreateSnText(listRowCells[1].ContentRange.End, @"Name"); // Define a list separator and specify its format. snList.Separator.AppendText(new string('\f', 1)); // Finalize the Snap list creation. snList.EndUpdate(); snList.Field.Update(); }
static void GenerateSnapListForCurrentLevel(GridLevelNode node, SnapDocument document, DocumentPosition position, int level) { GridView grid = node.LevelTemplate as GridView; if (grid == null || grid.VisibleColumns.Count == 0) { return; } SnapList list = document.CreateSnList(document.Range.End, grid.Name); list.BeginUpdate(); ApplyDataSource(list, node); ApplyGroups(list, grid); ApplySorting(list, grid); ApplyFilter(list, grid); Table table = null; SnapDocument template = null; MakeTemplate(list, grid, out table, out template); MakeReportFooter(list, grid); ApplyDetails(node, table, template, level); list.ApplyTableStyles(level); list.EndUpdate(); }
static void ApplyDataSource(SnapList list, GridLevelNode node) { if (!node.IsRootLevel) { list.DataMember = node.RelationName; } }
static void MakeTemplate(SnapList list, GridView grid, out Table table, out SnapDocument template) { template = list.RowTemplate; SnapDocument header = list.ListHeader; table = template.Tables.Create(template.Range.End, 1, grid.VisibleColumns.Count); Table caption = header.Tables.Create(header.Range.End, 1, grid.VisibleColumns.Count); AdjustSize(table); AdjustSize(caption); foreach (GridColumn col in grid.VisibleColumns) { header.InsertText(caption.Cell(0, col.VisibleIndex).Range.Start, col.FieldName); TableCell cell = table.Cell(0, col.VisibleIndex); DocumentPosition pos = cell.Range.Start; Type colType = GetColType(col); if (colType == typeof(byte[])) { template.CreateSnImage(pos, col.FieldName); } else if (colType == typeof(bool)) { template.CreateSnCheckBox(pos, col.FieldName); } else { template.CreateSnText(pos, col.FieldName); } } }
static void MakeReportFooter(SnapList list, GridView grid) { var tmp = new Dictionary <int, List <GridColumnSummaryItem> >(); foreach (GridColumn column in grid.VisibleColumns) { int colNum = column.VisibleIndex; foreach (GridColumnSummaryItem item in column.Summary) { if (!tmp.ContainsKey(colNum)) { tmp[colNum] = new List <GridColumnSummaryItem>(1); } tmp[colNum].Add(item); } } if (tmp.Count == 0) { return; } SnapDocument footer = list.ListFooter; Table table = footer.Tables.Create(footer.Range.Start, tmp.Values.Max(o => o.Count), grid.VisibleColumns.Count); AdjustSize(table); foreach (KeyValuePair <int, List <GridColumnSummaryItem> > rec in tmp) { int colNum = rec.Key; int rowNum = 0; foreach (GridColumnSummaryItem summary in rec.Value) { BuildSummaryTemplate(footer, table.Cell(rowNum++, colNum), summary, SummaryRunning.Report); } } }
void Document_PrepareSnList(object sender, PrepareSnListEventArgs e) { foreach (var field in e.Template.Fields) { SnapList list = e.Template.ParseField(field) as SnapList; if (object.ReferenceEquals(list, null)) { continue; } list.BeginUpdate(); list.ListHeader.Delete(list.ListHeader.Range); SnapDocument template = list.RowTemplate; template.Delete(template.Range); foreach (DataFieldInfo dataField in this.dataFields) { template.AppendText(string.Format("{0} = ", dataField.DisplayName)); template.CreateSnText(template.Range.End, dataField.DataPaths[dataField.DataPaths.Length - 1]); template.Paragraphs.Append(); } template.Paragraphs.Append(); list.EndUpdate(); break; } this.dataFields = null; }
static void GenerateLayout(SnapDocument document) { // Add a Snap list to the document. SnapList list = document.CreateSnList(document.Range.End, @"List"); list.BeginUpdate(); list.EditorRowLimit = 100500; // Add a header to the Snap list. SnapDocument listHeader = list.ListHeader; Table listHeaderTable = listHeader.Tables.Create(listHeader.Range.End, 1, 3); TableCellCollection listHeaderCells = listHeaderTable.FirstRow.Cells; listHeader.InsertText(listHeaderCells[0].ContentRange.End, "Product Name"); listHeader.InsertText(listHeaderCells[1].ContentRange.End, "Units in Stock"); listHeader.InsertText(listHeaderCells[2].ContentRange.End, "Unit Price"); //Create the row template and fill it with data. SnapDocument listRow = list.RowTemplate; Table listRowTable = listRow.Tables.Create(listRow.Range.End, 1, 3); TableCellCollection listRowCells = listRowTable.FirstRow.Cells; listRow.CreateSnText(listRowCells[0].ContentRange.End, @"ProductName"); listRow.CreateSnText(listRowCells[1].ContentRange.End, @"UnitsInStock"); listRow.CreateSnText(listRowCells[2].ContentRange.End, @"UnitPrice \$ $0.00"); list.EndUpdate(); list.Field.Update(); }
private void AddColumn(SnapList list, string columnName, string caption) { SnapDocument listHeader = list.ListHeader; Table listHeaderTable = listHeader.Tables[0]; listHeaderTable.TableLayout = TableLayoutType.Fixed; TableCellCollection listHeaderCells = listHeaderTable.FirstRow.Cells; TableCell columnHeader = listHeaderCells.InsertAfter(listHeaderCells.Count - 1); listHeader.InsertText(columnHeader.ContentRange.Start, caption); CharacterProperties prop = listHeader.BeginUpdateCharacters(columnHeader.ContentRange); prop.Bold = true; prop.ForeColor = Color.YellowGreen; listHeader.EndUpdateCharacters(prop); SnapDocument listRow = list.RowTemplate; Table listRowTable = listRow.Tables[0]; listRowTable.TableLayout = TableLayoutType.Fixed; TableCellCollection listRowTableCells = listRowTable.FirstRow.Cells; TableCell column = listRowTableCells.InsertAfter(listRowTableCells.Count - 1); listRow.CreateSnText(column.ContentRange.Start, columnName); }
void document_PrepareSnList(object sender, PrepareSnListEventArgs e) { // Change the style applied to the SnapList depending on its data source. for (int i = 0; i < e.Template.Fields.Count; i++) { Field field = e.Template.Fields[i]; SnapEntity eTemplateParseField = e.Template.ParseField(field); SnapList snList = eTemplateParseField as SnapList; if (snList == null) { continue; } if (snList.DataSourceName.Equals(employeeDataSourceName)) { snList.BeginUpdate(); SetTablesStyle(snList, employeeStyleName); snList.EndUpdate(); } else if (snList.DataSourceName.Equals(customerDataSourceName)) { snList.BeginUpdate(); SetTablesStyle(snList, customerStyleName); snList.EndUpdate(); } } }
private void GenerateLayout(SnapDocument doc) { // Add a Snap list to the document. SnapList list = doc.CreateSnList(doc.Range.End, @"List"); list.BeginUpdate(); list.EditorRowLimit = 100; // Add a header to the Snap list. SnapDocument listHeader = list.ListHeader; Table listHeaderTable = listHeader.Tables.Create(listHeader.Range.End, 1, 3); TableCellCollection listHeaderCells = listHeaderTable.FirstRow.Cells; listHeader.InsertText(listHeaderCells[0].ContentRange.End, "Product Name"); listHeader.InsertText(listHeaderCells[1].ContentRange.End, "Units in Stock"); listHeader.InsertText(listHeaderCells[2].ContentRange.End, "Unit Price"); // Customize the row template. SnapDocument listRow = list.RowTemplate; Table listRowTable = listRow.Tables.Create(listRow.Range.End, 1, 3); TableCellCollection listRowCells = listRowTable.FirstRow.Cells; listRow.CreateSnText(listRowCells[0].ContentRange.End, @"ProductName"); listRow.CreateSnText(listRowCells[1].ContentRange.End, @"UnitsInStock"); listRow.CreateSnText(listRowCells[2].ContentRange.End, @"UnitPrice \$ $0.00"); // Apply formatting, filtering and sorting to the Snap list. FormatList(list); FilterList(list); SortList(list); GroupList(list); list.EndUpdate(); list.Field.Update(); }
static void InsertData(SnapDocumentServer server) { #region #InsertData server.LoadDocumentTemplate("Template.snx"); SnapList list = server.Document.FindListByName("Data Source 11"); server.Document.ParseField(list.Field); list.BeginUpdate(); // Add a header to the Snap list. SnapDocument listHeader = list.ListHeader; Table listHeaderTable = listHeader.Tables[0]; TableCellCollection listHeaderCells = listHeaderTable.FirstRow.Cells; listHeader.InsertText(listHeaderCells.InsertAfter(2).ContentRange.End, "Quantity per Unit"); // Add data to the row template: SnapDocument listRow = list.RowTemplate; Table listRowTable = listRow.Tables[0]; TableCellCollection listRowCells = listRowTable.FirstRow.Cells; listRow.CreateSnText(listRowCells.InsertAfter(2).ContentRange.End, @"QuantityPerUnit"); list.EndUpdate(); list.Field.Update(); #endregion #InsertData }
private static void GenerateLayout(SnapDocument doc) { // Delete the document's content. doc.Text = String.Empty; // Add a Snap list to the document. SnapList list = doc.CreateSnList(doc.Range.End, "CustomerList"); list.BeginUpdate(); list.DataMember = "Customers"; // Add a header to the Snap list. SnapDocument listHeader = list.ListHeader; Table listHeaderTable = listHeader.Tables.Create(listHeader.Range.End, 1, 3); TableCellCollection listHeaderCells = listHeaderTable.FirstRow.Cells; listHeader.InsertText(listHeaderCells[0].ContentRange.End, "First Name"); listHeader.InsertText(listHeaderCells[1].ContentRange.End, "Last Name"); listHeader.InsertText(listHeaderCells[2].ContentRange.End, "Company"); // Customize the row template. SnapDocument listRow = list.RowTemplate; Table listRowTable = listRow.Tables.Create(listRow.Range.End, 1, 3); TableCellCollection listRowCells = listRowTable.FirstRow.Cells; listRow.CreateSnText(listRowCells[0].ContentRange.End, @"FirstName"); listRow.CreateSnText(listRowCells[1].ContentRange.End, @"LastName"); listRow.CreateSnText(listRowCells[2].ContentRange.End, @"Company"); FormatList(list); list.EndUpdate(); list.Field.Update(); }
static void ApplyFilter(SnapList list, GridView grid) { string filter = grid.ActiveFilterString; if (!String.IsNullOrEmpty(filter)) { list.Filters.Add(filter); } }
private void FilterList(SnapList list) { const string filter = "[Discontinued] = False"; if (!list.Filters.Contains(filter)) { list.Filters.Add(filter); } }
private void SnapList_OnRightTapped(object sender, RightTappedRoutedEventArgs e) { var baseobj = e.OriginalSource as FrameworkElement; var myObject = baseobj.DataContext as snapper.SnapViewModel; var newIndex = SnapList.Items.IndexOf(myObject); SnapList.SelectedIndex = newIndex; SnapList.ScrollIntoView(SnapList.SelectedItem); }
static void GroupData(SnapDocumentServer server) { #region #GroupData server.LoadDocumentTemplate("Template.snx"); SnapList list = server.Document.FindListByName("Data Source 11"); server.Document.ParseField(list.Field); list.BeginUpdate(); list.EditorRowLimit = 100500; // Add a header to the Snap list. SnapDocument listHeader = list.ListHeader; Table listHeaderTable = listHeader.Tables[0]; SnapListGroupInfo group = list.Groups.CreateSnapListGroupInfo( new SnapListGroupParam("CategoryID", ColumnSortOrder.Ascending)); list.Groups.Add(group); // Add a group header. SnapDocument groupHeader = group.CreateHeader(); Table headerTable = groupHeader.Tables.Create(groupHeader.Range.End, 1, 1); headerTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent); TableCellCollection groupHeaderCells = headerTable.FirstRow.Cells; groupHeader.InsertText(groupHeaderCells[0].ContentRange.End, "Category ID: "); groupHeader.CreateSnText(groupHeaderCells[0].ContentRange.End, "CategoryID"); // Customize the group header formatting. groupHeaderCells[0].BackgroundColor = System.Drawing.Color.LightGray; groupHeaderCells[0].Borders.Bottom.LineColor = System.Drawing.Color.White; groupHeaderCells[0].Borders.Left.LineColor = System.Drawing.Color.White; groupHeaderCells[0].Borders.Right.LineColor = System.Drawing.Color.White; groupHeaderCells[0].Borders.Top.LineColor = System.Drawing.Color.White; // Add a group footer. SnapDocument groupFooter = group.CreateFooter(); Table footerTable = groupFooter.Tables.Create(groupFooter.Range.End, 1, 1); footerTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent); TableCellCollection groupFooterCells = footerTable.FirstRow.Cells; groupFooter.InsertText(groupFooterCells[0].ContentRange.End, "Count = "); groupFooter.CreateSnText(groupFooterCells[0].ContentRange.End, @"CategoryID \sr Group \sf Count"); // Customize the group footer formatting. groupFooterCells[0].BackgroundColor = System.Drawing.Color.LightGray; groupFooterCells[0].Borders.Bottom.LineColor = System.Drawing.Color.White; groupFooterCells[0].Borders.Left.LineColor = System.Drawing.Color.White; groupFooterCells[0].Borders.Right.LineColor = System.Drawing.Color.White; groupFooterCells[0].Borders.Top.LineColor = System.Drawing.Color.White; list.EndUpdate(); //list.Field.Update(); #endregion #GroupData }
private void SnapListAddButton_OnClick(object sender, RoutedEventArgs e) { Snap newSnap = new Snap(store.Snaps.Count, "Title", "Content"); store.AddSnap(newSnap); SnapList.SelectedIndex = SnapList.Items.Count - 1; SnapList.ScrollIntoView(SnapList.SelectedItem); SnapText.Text = SnapList.Items.Count + " Snaps"; SnapContent.Focus(FocusState.Programmatic); }
static void FormatData(SnapDocumentServer server) { #region #FormatData server.LoadDocumentTemplate("Template.snx"); SnapList list = server.Document.FindListByName("Data Source 11"); server.Document.ParseField(list.Field); list.BeginUpdate(); list.EditorRowLimit = 100500; SnapDocument header = list.ListHeader; Table headerTable = header.Tables[0]; headerTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent); foreach (TableRow row in headerTable.Rows) { foreach (TableCell cell in row.Cells) { // Apply cell formatting. cell.Borders.Left.LineColor = System.Drawing.Color.White; cell.Borders.Right.LineColor = System.Drawing.Color.White; cell.Borders.Top.LineColor = System.Drawing.Color.White; cell.Borders.Bottom.LineColor = System.Drawing.Color.White; cell.BackgroundColor = System.Drawing.Color.SteelBlue; // Apply text formatting. CharacterProperties formatting = header.BeginUpdateCharacters(cell.ContentRange); formatting.Bold = true; formatting.ForeColor = System.Drawing.Color.White; header.EndUpdateCharacters(formatting); } } // Customize the row template. SnapDocument rowTemplate = list.RowTemplate; Table rowTable = rowTemplate.Tables[0]; rowTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent); foreach (TableRow row in rowTable.Rows) { foreach (TableCell cell in row.Cells) { cell.Borders.Left.LineColor = System.Drawing.Color.Transparent; cell.Borders.Right.LineColor = System.Drawing.Color.Transparent; cell.Borders.Top.LineColor = System.Drawing.Color.Transparent; cell.Borders.Bottom.LineColor = System.Drawing.Color.LightGray; } } list.EndUpdate(); list.Field.Update(); #endregion #FormatData }
private void EditTemplate() { SnapList list = FindList(); list.BeginUpdate(); AddColumn(list, "Discontinued", "Discontinued"); AddColumn(list, "UnitsInStock", "Units In Stock"); AddColumn(list, "QuantityPerUnit", "Quantity Per Unit"); list.EndUpdate(); list.Field.Update(); }
static void SortList(SnapDocumentServer server) { #region #SortData server.LoadDocumentTemplate("Template.snx"); SnapList list = server.Document.FindListByName("Data Source 11"); server.Document.ParseField(list.Field); list.BeginUpdate(); list.Sorting.Add(new SnapListGroupParam("UnitPrice", ColumnSortOrder.Descending)); list.EndUpdate(); list.Field.Update(); #endregion #SortData }
void document_BeforeInsertSnListDetail(object sender, BeforeInsertSnListDetailEventArgs e) { // Force the EditorRowLimit property of the master list to be lesser than or equal to 5 after // a detail list have been added. SnapList masterList = e.Master; if (masterList.EditorRowLimit <= 5) { return; } masterList.BeginUpdate(); masterList.EditorRowLimit = 5; masterList.EndUpdate(); }
static void ApplyGroups(SnapList list, GridView grid) { foreach (GridColumn col in grid.GroupedColumns) { SnapListGroupInfo group = list.Groups.CreateSnapListGroupInfo(new SnapListGroupParam(col.FieldName, col.SortOrder)); SnapDocument groupHeader = group.CreateHeader(); Table box = groupHeader.Tables.Create(groupHeader.Range.End, 1, 1); AdjustSize(box); groupHeader.CreateSnText(box.Cell(0, 0).Range.Start, col.FieldName); groupHeader.InsertText(box.Cell(0, 0).Range.Start, String.Format("{0}: ", col.FieldName)); ApplySummary(group, grid); list.Groups.Add(group); } }
void document_PrepareSnListDetail(object sender, PrepareSnListDetailEventArgs e) { // Set the row limit for every inserted detail list. foreach (Field field in e.Template.Fields) { SnapList detailList = e.Template.ParseField(field) as SnapList; if (detailList == null) { continue; } detailList.BeginUpdate(); detailList.EditorRowLimit = 5; detailList.EndUpdate(); } }
void document_AfterInsertSnListColumns(object sender, AfterInsertSnListColumnsEventArgs e) { // Mark the inserted columns with red double borders. SnapList snList = e.SnList; snList.BeginUpdate(); snList.RowTemplate.Tables[0].ForEachRow((row, rowIdx) => { TableCellBorder leftBorder = row.Cells[targetColumnIndex].Borders.Left; TableCellBorder rightBorder = row.Cells[targetColumnIndex + targetColumnsCount - 1].Borders.Right; setBorder(leftBorder); setBorder(rightBorder); }); snList.EndUpdate(); snList.Field.Update(); }
public void init() { m_camtrackFolderPath = Project.GetCleanCamtrackFolder(); // removes content of the folder, if any m_descrFilePath = Path.Combine(m_camtrackFolderPath, DESCR_FILE_NAME + ".xml"); string seedXml = "<camtrack/>"; xmlDoc.LoadXml(seedXml); root = xmlDoc.DocumentElement; m_currentFrameNode = null; CameraTrack.camTrackTerraTiles.Clear(); snapLng = null; // will be allocated as the first tile arrives snapLat = null; }
private SnapList FindList() { SnapList list = null; foreach (Field field in snapControl1.Document.Fields) { list = snapControl1.Document.ParseField(field) as SnapList; if (object.ReferenceEquals(list, null)) { continue; } else { break; } } return(list); }
private void FormatList(SnapList list) { // Customize the list header. SnapDocument header = list.ListHeader; Table headerTable = header.Tables[0]; headerTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent); foreach (TableRow row in headerTable.Rows) { foreach (TableCell cell in row.Cells) { // Apply cell formatting. cell.Borders.Left.LineColor = System.Drawing.Color.White; cell.Borders.Right.LineColor = System.Drawing.Color.White; cell.Borders.Top.LineColor = System.Drawing.Color.White; cell.Borders.Bottom.LineColor = System.Drawing.Color.White; cell.BackgroundColor = System.Drawing.Color.SteelBlue; // Apply text formatting. CharacterProperties formatting = header.BeginUpdateCharacters(cell.ContentRange); formatting.Bold = true; formatting.ForeColor = System.Drawing.Color.White; header.EndUpdateCharacters(formatting); } } // Customize the row template. SnapDocument rowTemplate = list.RowTemplate; Table rowTable = rowTemplate.Tables[0]; rowTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent); foreach (TableRow row in rowTable.Rows) { foreach (TableCell cell in row.Cells) { cell.Borders.Left.LineColor = System.Drawing.Color.Transparent; cell.Borders.Right.LineColor = System.Drawing.Color.Transparent; cell.Borders.Top.LineColor = System.Drawing.Color.Transparent; cell.Borders.Bottom.LineColor = System.Drawing.Color.LightGray; } } }
public static void AddTerraTile(string baseName, double lngPerTile, double latPerTile, TileTerra tile) { if (snapLat == null) { snapLng = new SnapList(lngPerTile, false); snapLat = new SnapList(latPerTile, false); } if (!CameraTrack.camTrackTerraTiles.Contains(baseName)) { CameraTrack.camTrackTerraTiles.Add(baseName); // adding to snap lists prepares them for calculating snap points: GeoCoord tl = tile.getTopLeft(); GeoCoord br = tile.getBottomRight(); snapLat.Add(tl.Lat); snapLat.Add(br.Lat); snapLng.Add(tl.Lng); snapLng.Add(br.Lng); } }