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(); } } }
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 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(); }
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 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 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 }
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(); }
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(); }
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(); } }
private void Form1_Load(object sender, EventArgs e) { #region #datasource DevExpress.Spreadsheet.Workbook wb = new DevExpress.Spreadsheet.Workbook(); wb.LoadDocument("Employees.xlsx"); DevExpress.Spreadsheet.RangeDataSourceOptions options = new DevExpress.Spreadsheet.RangeDataSourceOptions(); options.UseFirstRowAsHeader = true; options.CellValueConverter = new MyPictureProvider(wb.Worksheets[0]); options.DataSourceColumnTypeDetector = new MyColumnDetector(); string dsName = wb.Worksheets[0].Tables[0].Name; object ds = wb.Worksheets[0].Tables[0].GetDataSource(options); snapControl1.DataSources.Add(dsName, ds); #endregion #datasource snapControl1.CreateNewDocument(); SnapList list = snapControl1.Document.CreateSnList(snapControl1.Document.Range.End, "EmployeeList"); list.BeginUpdate(); list.DataSourceName = dsName; 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, "Photo"); 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, "\"First Name\""); listRow.CreateSnText(listRowCells[1].ContentRange.End, "\"Last Name\""); listRow.CreateSnImage(listRowCells[2].ContentRange.End, "Photo"); list.EndUpdate(); list.Field.Update(); }
static void FilterData(SnapDocumentServer server) { #region #FilterData // Delete the document's content. server.LoadDocument("Template.snx"); SnapList list = server.Document.FindListByName("Data Source 11"); server.Document.ParseField(list.Field); list.BeginUpdate(); // Apply filtering: const string filter = "[Discontinued] = False"; if (!list.Filters.Contains(filter)) { list.Filters.Add(filter); } list.EndUpdate(); list.Field.Update(); #endregion #FilterData }
static void CreateParameter(SnapDocumentServer server) { #region #CreateParameter server.LoadDocumentTemplate("Template.snx"); server.Document.BeginUpdate(); //Create parameter: Parameter param1 = new Parameter(); param1.Name = "Region"; param1.Type = typeof(System.String); param1.Value = "NEW ENGLAND"; server.Document.Parameters.Add(param1); //Insert parameter field in the document: SnapList list = server.Document.FindListByName("Data Source 11"); server.Document.ParseField(list.Field); list.BeginUpdate(); list.ListHeader.InsertText(list.ListHeader.Tables[0].FirstRow.Cells.InsertAfter(3).ContentRange.End, "Region"); list.RowTemplate.CreateSnText(list.RowTemplate.Tables[0].FirstRow.Cells.InsertAfter(3).ContentRange.End, @"Region \p"); list.Field.Update(); list.EndUpdate(); server.Document.EndUpdate(); server.Document.Fields.Update(); #endregion #CreateParameter }
public static void CreateSnListTemplate(SnapDocument document) { SnapList list = document.CreateSnList(document.Range.End, "EmployeeList"); list.BeginUpdate(); 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, "Photo"); 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, "\"First Name\""); listRow.CreateSnText(listRowCells[1].ContentRange.End, "\"Last Name\""); listRow.CreateSnImage(listRowCells[2].ContentRange.End, "Photo"); list.EndUpdate(); }