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();
        }
        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);
                }
            }
        }
示例#4
0
        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();
        }
        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);
                }
            }
        }
        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 BuildSummaryTemplate(SnapDocument template, TableCell box, GridSummaryItem source, SummaryRunning running)
        {
            MatchCollection formatFields = formatFinder.Matches(source.DisplayFormat);
            int             k            = 0;

            template.InsertText(box.ContentRange.End, " ");
            foreach (System.Text.RegularExpressions.Match match in formatFields)
            {
                template.InsertText(box.ContentRange.End, source.DisplayFormat.Substring(k, match.Groups[1].Index - k));
                k = match.Groups[1].Index + match.Groups[1].Length;
                SnapText snText = template.CreateSnText(box.ContentRange.End, source.FieldName);
                snText.BeginUpdate();
                snText.SummaryRunning = running;
                snText.SummaryFunc    = source.SummaryType;
                string format = match.Groups[2].Value;
                if (!String.IsNullOrEmpty(format))
                {
                    if (format.EndsWith("C", StringComparison.InvariantCultureIgnoreCase))
                    {
                        snText.FormatString = @"$0.00";
                    }
                }
                snText.EndUpdate();
            }
            template.InsertText(box.ContentRange.End, source.DisplayFormat.Substring(k));
        }
        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);
                }
            }
        }
示例#9
0
        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);
        }
 static void ApplySummary(SnapListGroupInfo group, GridView grid)
 {
     foreach (GridSummaryItem item in grid.GroupSummary)
     {
         GridGroupSummaryItem summary = item as GridGroupSummaryItem;
         if (summary != null)
         {
             if (summary.ShowInGroupColumnFooter == null)
             {
                 BuildSummaryTemplate(group.Header, group.Header.Tables[0].Cell(0, 0), summary, SummaryRunning.Group);
             }
             else
             {
                 int col = grid.VisibleColumns.IndexOf(summary.ShowInGroupColumnFooter);
                 if (col < 0)
                 {
                     continue;
                 }
                 SnapDocument footer = group.Footer;
                 if (footer == null)
                 {
                     footer = group.CreateFooter();
                 }
                 if (footer.Tables.Count == 0 || footer.Tables[0].Rows.Count == 0 || footer.Tables[0].Rows[0].Cells.Count != grid.VisibleColumns.Count)
                 {
                     Table table = footer.Tables.Create(footer.Range.Start, 1, grid.VisibleColumns.Count);
                     AdjustSize(table);
                 }
                 BuildSummaryTemplate(footer, footer.Tables[0].Cell(0, col), summary, SummaryRunning.Group);
             }
         }
     }
 }
示例#11
0
 void LoadTemplate(SnapDocument document, SalesReportType mailTemplate) {
     string template = (mailTemplate.ToFileName() + ".snx");
     using(var stream = MailMergeTemplatesHelper.GetTemplateStream(template))
         document.LoadDocument(stream, DevExpress.Snap.Core.API.SnapDocumentFormat.Snap);
     ribbonControl.ApplicationDocumentCaption = DevExpress.XtraEditors.EnumDisplayTextHelper.GetDisplayText(mailTemplate);
     ViewModel.Modified = snapControl.Modified;
 }
 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;
 }
示例#13
0
        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();
        }
示例#14
0
        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();
        }
示例#15
0
 public static void CreateMailMergeTemplate(SnapDocument document)
 {
     document.CreateSnImage(document.Range.End, "Photo");
     document.Paragraphs.Insert(document.Range.End);
     document.CreateSnText(document.Range.End, "\"First Name\"");
     document.AppendText(" ");
     document.CreateSnText(document.Range.End, "\"Last Name\"");
 }
示例#16
0
        void LoadTemplate(SnapDocument document, SalesReportType mailTemplate)
        {
            string template = (mailTemplate.ToFileName() + ".snx");

            using (var stream = MailMergeTemplatesHelper.GetTemplateStream(template))
                document.LoadDocument(stream, DevExpress.Snap.Core.API.SnapDocumentFormat.Snap);
            ribbonControl.ApplicationDocumentCaption = DevExpress.XtraEditors.EnumDisplayTextHelper.GetDisplayText(mailTemplate);
            ViewModel.Modified = snapControl.Modified;
        }
        void evaluator_OnBeforeCompile(object sender, EventArgs e)
        {
            server.CreateNewDocument();
            SnapDocument document = server.Document;

            document.BeginUpdate();
            codeEditor.BeforeCompile();
            document.Unit = DevExpress.Office.DocumentUnit.Document;
        }
        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
        }
示例#19
0
        void RegisterEventHandlers()
        {
            SnapDocument document = snapControl1.Document;

            document.BeforeInsertSnList        += document_BeforeInsertSnList;
            document.PrepareSnList             += document_PrepareSnList;
            document.BeforeInsertSnListColumns += document_BeforeInsertSnListColumns;
            document.AfterInsertSnListColumns  += document_AfterInsertSnListColumns;
            document.BeforeInsertSnListDetail  += document_BeforeInsertSnListDetail;
            document.PrepareSnListDetail       += document_PrepareSnListDetail;
        }
 static void ApplyDetails(GridLevelNode node, Table table, SnapDocument template, int level)
 {
     if (node.HasChildren)
     {
         foreach (GridLevelNode child in node.Nodes)
         {
             TableRow detail = table.Rows.Append();
             table.MergeCells(detail.FirstCell, detail.LastCell);
             GenerateSnapListForCurrentLevel(child, template, detail.Range.Start, level + 1);
         }
     }
 }
示例#21
0
        void InitializeDataSources()
        {
            var dataSource = new DataSet1();
            var connection = new OleDbConnection();

            connection.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\nwind.mdb";

            EmployeesTableAdapter employees = new EmployeesTableAdapter();

            employees.Connection = connection;
            employees.Fill(dataSource.Employees);

            CustomersTableAdapter customers = new CustomersTableAdapter();

            customers.Connection = connection;
            customers.Fill(dataSource.Customers);

            EmployeeCustomersTableAdapter employeeCustomers = new EmployeeCustomersTableAdapter();

            employeeCustomers.Connection = connection;
            employeeCustomers.Fill(dataSource.EmployeeCustomers);

            OrdersTableAdapter orders = new OrdersTableAdapter();

            orders.Connection = connection;
            orders.Fill(dataSource.Orders);

            Order_DetailsTableAdapter orderDetails = new Order_DetailsTableAdapter();

            orderDetails.Connection = connection;
            orderDetails.Fill(dataSource.Order_Details);

            SnapDocument document = snapControl1.Document;

            document.BeginUpdateDataSource();

            var employeesBinding = new BindingSource()
            {
                DataSource = dataSource, DataMember = employeeDataSourceName
            };

            document.DataSources.Add(new DataSourceInfo(employeeDataSourceName, employeesBinding));

            var customersBinding = new BindingSource()
            {
                DataSource = dataSource, DataMember = customerDataSourceName
            };

            document.DataSources.Add(new DataSourceInfo(customerDataSourceName, customersBinding));

            document.EndUpdateDataSource();
        }
        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
        }
示例#23
0
        void SetTablesStyleCore(SnapDocument document, string styleName)
        {
            TableStyle style = document.TableStyles[styleName];

            if (style == null)
            {
                return;
            }
            foreach (Table table in document.Tables)
            {
                table.Style = style;
            }
        }
示例#24
0
 public void LoadDocument(SnapDocument document)
 {
     this.document = document;
     if (documentData.Content != null)
     {
         using (MemoryStream stream = new MemoryStream()) {
             stream.Write(documentData.Content, 0, documentData.Content.Length);
             stream.Flush();
             stream.Seek(0, SeekOrigin.Begin);
             document.LoadDocument(stream, SnapDocumentFormat.Snap);
         }
     }
     SynchronizeDataSources();
 }
 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);
     }
 }
        public Form1()
        {
            InitializeComponent();
            #region #CreateChart
            SnapDocument document = snapControl.Document;
            // Insert a chart into the document.
            SnapChart chart = document.CreateSnChart(document.Range.Start);
            chart.BeginUpdate();
            // Create a data table and bind the chart to it.
            chart.DataSource = CreateChartData();

            // Populate chart series with data.
            chart.SeriesDataMember = "Year";
            chart.SeriesTemplate.ArgumentDataMember = "Region";
            chart.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Sales" });

            // Specify the series view options.
            chart.SeriesTemplate.ChangeView(ViewType.Bar);
            chart.SeriesNameTemplate.BeginText = "Year: ";

            // Add the chart title.
            ChartTitle chartTitle = new ChartTitle();
            chartTitle.Text      = "DevAV Sales by Regions";
            chartTitle.Alignment = System.Drawing.StringAlignment.Center;
            chartTitle.Dock      = ChartTitleDockStyle.Top;
            chart.Titles.Add(chartTitle);

            // Add the value axis title.
            XYDiagram diagram = (XYDiagram)chart.Diagram;
            diagram.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisY.Title.Alignment  = System.Drawing.StringAlignment.Center;
            diagram.AxisY.Title.Text       = "Millions of Dollars";

            // Set the chart size.
            chart.Size            = new System.Drawing.Size(640, 425);
            chart.UseExplicitSize = true;

            // Change the chart palette.
            chart.PaletteName = "Slipstream";
            chart.EndUpdate();

            document.Fields.Update();
            #endregion #CreateChart
        }
示例#27
0
        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;
                }
            }
        }
示例#28
0
        private void GroupList(SnapList list)
        {
            // Add grouping to the Snap list.
            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;
        }
示例#29
0
        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();
        }
示例#30
0
        void InitializeStyles()
        {
            SnapDocument document = snapControl1.Document;

            document.BeginUpdate();

            TableStyle employee = document.TableStyles.CreateNew();

            employee.Name = employeeStyleName;
            employee.CellBackgroundColor = Color.PaleGreen;
            document.TableStyles.Add(employee);

            TableStyle customer = document.TableStyles.CreateNew();

            customer.Name = customerStyleName;
            customer.CellBackgroundColor = Color.Plum;
            document.TableStyles.Add(customer);

            document.TableStyles["List1"].CellBackgroundColor = Color.White;
            document.TableStyles["List2"].CellBackgroundColor = Color.LightYellow;
            document.EndUpdate();
        }
示例#31
0
 static void Main(string[] args)
 {
     if (args.Length == 0)
     {
         #region #MainAction
         SnapDocumentServer snap     = new SnapDocumentServer();
         SnapDocument       document = snap.Document;
         XTemplateCreator.CreateMailMergeTemplate(document);
         snap.Options.SnapMailMergeVisualOptions.DataSource = XDataSourceHelper.GetData();
         snap.SnapMailMerge("test.pdf", SnapDocumentFormat.Pdf);
         #endregion #MainAction
         System.Diagnostics.Process.Start("test.pdf");
     }
     else if (args[0] == "UseListTemplate")
     {
         SnapDocumentServer snap     = new SnapDocumentServer();
         SnapDocument       document = snap.Document;
         XTemplateCreator.CreateSnListTemplate(document);
         document.DataSource = XDataSourceHelper.GetData();
         snap.ExportToPdf("test.pdf");
         System.Diagnostics.Process.Start("test.pdf");
     }
 }