protected override void PopulateRichText() { // Create some text NDocumentBlock documentBlock = m_RichText.Content; documentBlock.Layout = ENTextLayout.Print; NSection section = new NSection(); documentBlock.Sections.Add(section); NParagraph paragraph = new NParagraph(); paragraph.Inlines.Add(CreateMailMergeField(new NGreetingLineFieldValue())); section.Blocks.Add(paragraph); paragraph = new NParagraph(); paragraph.Inlines.Add(new NTextInline("We would like to offer you a unique software component that will help you leverage multiple platforms with single code base. We believe that as a ")); paragraph.Inlines.Add(CreateMailMergeField(new NMailMergeSourceFieldValue("Title"))); paragraph.Inlines.Add(new NTextInline(" in your company you will be very interested in this solution. If that's the case do not hesitate to contact us in order to arrange a meeting in ")); paragraph.Inlines.Add(CreateMailMergeField(new NMailMergePredefinedFieldValue(ENMailMergeDataField.City))); paragraph.Inlines.Add(new NTextInline(".")); section.Blocks.Add(paragraph); paragraph = new NParagraph(); paragraph.Inlines.Add(new NTextInline("Best Regards,")); paragraph.Inlines.Add(new NLineBreakInline()); paragraph.Inlines.Add(new NTextInline("Nevron Software")); paragraph.Inlines.Add(new NLineBreakInline()); paragraph.Inlines.Add(new NHyperlinkInline("www.nevron.com", "https://www.nevron.com")); section.Blocks.Add(paragraph); // Load a mail merge data source from resource Stream stream = NResources.Instance.GetResourceStream("RSTR_Employees_csv"); NMailMergeDataSource dataSource = NDataSourceFormat.Csv.LoadFromStream(stream, new NDataSourceLoadSettings(null, null, true)); // Create the field mappings NMailMergeFieldMap fieldMap = new NMailMergeFieldMap(); fieldMap.Set(ENMailMergeDataField.CourtesyTitle, "TitleOfCourtesy"); fieldMap.Set(ENMailMergeDataField.FirstName, "FirstName"); fieldMap.Set(ENMailMergeDataField.LastName, "LastName"); fieldMap.Set(ENMailMergeDataField.City, "City"); dataSource.FieldMap = fieldMap; documentBlock.MailMerge.DataSource = dataSource; }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // Hide the grid and the ports drawing.ScreenVisibility.ShowGrid = false; drawing.ScreenVisibility.ShowPorts = false; // Create a shape factory NBasicShapeFactory basicShapeFactory = new NBasicShapeFactory(); basicShapeFactory.DefaultSize = new NSize(100, 100); // Create the Name shape NShape nameShape = basicShapeFactory.CreateShape(ENBasicShape.Rectangle); nameShape.Width = 150; nameShape.PinX = activePage.Width / 2; nameShape.PinY = 100; NParagraph paragraph = new NParagraph(); paragraph.Inlines.Add(new NFieldInline(new NMailMergePredefinedFieldValue(ENMailMergeDataField.FirstName))); paragraph.Inlines.Add(new NTextInline(" ")); paragraph.Inlines.Add(new NFieldInline(new NMailMergePredefinedFieldValue(ENMailMergeDataField.LastName))); nameShape.GetTextBlock().Content.Blocks.Clear(); nameShape.GetTextBlock().Content.Blocks.Add(paragraph); activePage.Items.Add(nameShape); // Create the City shape NShape cityShape = basicShapeFactory.CreateShape(ENBasicShape.SixPointStar); cityShape.PinX = nameShape.PinX - 150; cityShape.PinY = nameShape.PinY + 200; paragraph = new NParagraph(); paragraph.Inlines.Add(new NFieldInline(new NMailMergePredefinedFieldValue(ENMailMergeDataField.City))); cityShape.GetTextBlock().Content.Blocks.Clear(); cityShape.GetTextBlock().Content.Blocks.Add(paragraph); activePage.Items.Add(cityShape); // Create the Birth Date shape NShape birthDateShape = basicShapeFactory.CreateShape(ENBasicShape.Circle); birthDateShape.PinX = nameShape.PinX + 150; birthDateShape.PinY = cityShape.PinY; paragraph = new NParagraph(); paragraph.Inlines.Add(new NFieldInline(new NMailMergeSourceFieldValue("BirthDate"))); birthDateShape.GetTextBlock().Content.Blocks.Clear(); birthDateShape.GetTextBlock().Content.Blocks.Add(paragraph); activePage.Items.Add(birthDateShape); // Connect the shapes NRoutableConnector connector = new NRoutableConnector(); connector.Text = "City"; connector.TextBlock.BackgroundFill = new NColorFill(NColor.White); connector.GlueBeginToNearestPort(nameShape); connector.GlueEndToNearestPort(cityShape); activePage.Items.Add(connector); connector = new NRoutableConnector(); connector.Text = "Birth Date"; connector.TextBlock.BackgroundFill = new NColorFill(NColor.White); connector.GlueBeginToNearestPort(nameShape); connector.GlueEndToNearestPort(birthDateShape); activePage.Items.Add(connector); // Load a mail merge data source from resource Stream stream = NResources.Instance.GetResourceStream("RSTR_Employees_csv"); NMailMergeDataSource dataSource = NDataSourceFormat.Csv.LoadFromStream(stream, new NDataSourceLoadSettings(null, null, true)); // Set some field mappings NMailMergeFieldMap fieldMap = new NMailMergeFieldMap(); fieldMap.Set(ENMailMergeDataField.CourtesyTitle, "TitleOfCourtesy"); fieldMap.Set(ENMailMergeDataField.FirstName, "FirstName"); fieldMap.Set(ENMailMergeDataField.LastName, "LastName"); fieldMap.Set(ENMailMergeDataField.City, "City"); // Configure the drawing's mail merge drawing.MailMerge.DataSource = dataSource; }