private void btnMakeATable_Click(object sender, RoutedEventArgs e) { C1PrintDocument doc = null; if (sender == btnBasicTable) { doc = MakeDocHelper.BasicTable(); } else if (sender == btnStylesInTables) { doc = MakeDocHelper.StylesInTables(); } else if (sender == btnWideTables) { doc = MakeDocHelper.WideTable(); } else if (sender == btnTextStyles) { doc = MakeDocHelper.TextStyles(); } else if (sender == btnLargeTable) { doc = MakeDocHelper.LargeTable(800, 4); } else if (sender == btnTableBorders) { doc = MakeDocHelper.TableBorders(); } c1DocumentViewer1.FitToWidth(); c1DocumentViewer1.Document = doc.FixedDocumentSequence; }
// Set date range tags in a separate method, as it might // be useful to set them before editing style in print setup forms. internal void SetDateRangeTags(C1PrintDocument printDoc, DateTime start, DateTime end) { Tag tag = null; TagCollection Tags = printDoc.Tags; if ((Context & PrintContextType.DateRange) != 0) { if (Tags.IndexOfName("StartDate") >= 0) { tag = Tags["StartDate"]; if (tag != null && tag.Type == typeof(DateTime)) { tag.Value = start; } } if (Tags.IndexOfName("EndDate") >= 0) { tag = Tags["EndDate"]; if (tag != null && tag.Type == typeof(DateTime)) { tag.Value = end; } } } }
private void Form1_Load(object sender, EventArgs e) { C1PrintDocument doc = new C1PrintDocument(); // create a RenderTable object: RenderTable rt = new RenderTable(); // adjust table's properties so that columns are auto-sized: // 1) By default, table width is set to parent (page) width, // for auto-sizing we must change it to auto (i.e. based on content): rt.Width = Unit.Auto; // 2) Set ColumnSizingMode to Auto (default means Fixed for columns): rt.ColumnSizingMode = TableSizingModeEnum.Auto; // that's it, now the table's columns will be auto-sized. // Turn table grid lines on to better see autosizing, add some padding: rt.Style.GridLines.All = LineDef.Default; rt.CellStyle.Padding.All = "2mm"; // add some data rt.Cells[0, 0].Text = "aaa"; rt.Cells[0, 1].Text = "bbbbbbbbbb"; rt.Cells[0, 2].Text = "cccccc"; rt.Cells[1, 0].Text = "aaa aaa aaa"; rt.Cells[1, 1].Text = "bbbbb"; rt.Cells[1, 2].Text = "cccccc cccccc"; rt.Cells[2, 2].Text = "zzzzzzzzzzzzzzz zz z"; // add the table to the document doc.Body.Children.Add(rt); // show the document c1PrintPreviewControl1.Document = doc; }
/// <summary> /// Makes a <see cref="RenderText"/> object representing the page footer /// as specified in the grid's PrintParameters. The returned object /// may be assigned to a C1PrintDocument's PageLayout.PageFooter. /// </summary> /// <param name="doc">The document that is to contain the created render object, or null.</param> /// <returns>The page header footer object.</returns> public RenderObject MakePageFooter(C1PrintDocument doc) { string tagOpenParen = doc == null ? "[" : doc.TagOpenParen; string tagCloseParen = doc == null ? "]" : doc.TagCloseParen; return(MakePageHeader(true, tagOpenParen, tagCloseParen)); }
private void Window_Loaded(object sender, RoutedEventArgs e) { C1PrintDocument doc = new C1PrintDocument(); #if plain doc.Body.Children.Add(new C1.C1Preview.RenderText("Hello, World!")); #else doc.Body.Children.Clear(); RenderText rt = new RenderText("Hello, World!"); rt.X = "2in"; rt.Y = "3in"; rt.Width = "4in"; rt.Height = "3in"; rt.Style.Borders.All = LineDef.Default; rt.Style.FontName = "Arial"; rt.Style.FontSize = 14; rt.Style.TextColor = Colors.Red; rt.Style.BackColor = Colors.PowderBlue; rt.Style.TextAlignHorz = AlignHorzEnum.Center; rt.Style.TextAlignVert = AlignVertEnum.Center; doc.Body.Children.Add(rt); #endif c1DocumentViewer1.FitToWidth(); c1DocumentViewer1.Document = doc.FixedDocumentSequence; }
private RenderObject CreateFieldCaption( C1PrintDocument doc, string caption, bool required, bool password) { ParagraphText pt; RenderParagraph result = new RenderParagraph(doc); if (required) { pt = new ParagraphText("*"); pt.Style.Parents = _requiredCharStyle; result.Content.Add(pt); pt = new ParagraphText(" "); pt.Style.Parents = _fieldCaptionStyle; result.Content.Add(pt); } pt = new ParagraphText(caption); pt.Style.Parents = _fieldCaptionStyle; result.Content.Add(pt); if (password) { pt = new ParagraphText("(Must be at least 5 characters)"); pt.Style.Parents = _passwordInfoStyle; result.Content.Add(pt); } return(result); }
private void Window_Loaded(object sender, RoutedEventArgs e) { C1PrintDocument doc = new C1PrintDocument(); RenderText title = new RenderText("Auto-sized tables"); title.Style.FontSize = 18; title.Style.FontBold = true; title.Style.Spacing.All = "5mm"; title.Style.TextAlignHorz = AlignHorzEnum.Center; doc.Body.Children.Add(title); // add simple autosized table: doc.Body.Children.Add(MakeTable_Simple()); // prepare data source: object bookList = MakeBookList(); // add a bit more interesting data bound table: var rt = MakeTable_TitlePriceStock(bookList); rt.Style.Spacing.Top = "5mm"; doc.Body.Children.Add(rt); // show the document c1DocumentViewer1.Document = doc.FixedDocumentSequence; }
private void Form1_Load(object sender, EventArgs e) { // make a demo C1PrintDocument; a "real" document can be loaded // via the File Open button. C1PrintDocument doc = new C1PrintDocument(); doc.PageLayout.PageHeader = new RenderText("Page [PageNo] of [PageCount]"); doc.PageLayout.PageHeader.Style.TextAlignHorz = AlignHorzEnum.Right; doc.PageLayout.PageHeader.Style.TextAlignVert = AlignVertEnum.Top; doc.PageLayout.PageHeader.Height = "1cm"; RenderText title = new RenderText("This is just a sample; load any C1PrintDocument from a C1D file"); title.Style.Font = new Font("Arial", 16); title.Style.TextAlignHorz = AlignHorzEnum.Center; title.Style.Padding.All = "5mm"; doc.Body.Children.Add(title); RenderTable rt = new RenderTable(); rt.Style.GridLines.All = LineDef.Default; for (int row = 0; row < 100; ++row) { for (int col = 0; col < 4; ++col) { rt.Cells[row, col].Text = string.Format("cell ({0},{1})", row, col); } } doc.Body.Children.Add(rt); c1PrintPreviewControl1.Document = doc; }
/// <summary> /// Builds a document bound to a list of objects in memory. /// </summary> private void btnBindToList_Click(object sender, RoutedEventArgs e) { UpdateButtons(btnBindToList); C1PrintDocument doc = new C1PrintDocument(); // build sample list of customers List <Customer> customers = new List <Customer>(); for (int i = 0; i < 100; i++) { customers.Add(new Customer(i + 1, "Customer " + (i + 1).ToString())); } doc.Style.FontName = "Verdana"; doc.Style.FontSize = 16; // document title: doc.Body.Children.Add(new RenderText("List of Customer objects")); doc.Body.Children.Add(new RenderEmpty("5mm")); // empty space after title // this object will be repeated for each element in the customers list RenderText rt = new RenderText(); rt.Text = "Id: [Fields!Id.Value]\rName: [Fields!Name.Value]"; rt.Style.Borders.All = LineDef.DefaultBold; rt.SplitVertBehavior = SplitBehaviorEnum.SplitIfLarge; // bind the RenderText to the customers list: rt.DataBinding.DataSource = customers; doc.Body.Children.Add(rt); this.c1DocumentViewer1.Document = doc.FixedDocumentSequence; }
/// <summary> /// Builds a simple data bound document, listing product IDs and names /// in a single data bound RenderText. /// </summary> private void btnBindToMdb_Click(object sender, RoutedEventArgs e) { UpdateButtons(btnBindToMdb); C1PrintDocument doc = new C1PrintDocument(); doc.Style.FontName = "Verdana"; doc.Style.FontSize = 16; // define data schema DataSource ds = CreateDemoDataSource(); DataSet dsCities = new DataSet(ds, "select * from Products"); doc.DataSchema.DataSources.Add(ds); doc.DataSchema.DataSets.Add(dsCities); // document title: RenderText rt = new RenderText(); rt.Text = string.Format("ConnectString = {0}\rCommandText={1}", ds.ConnectionProperties.ConnectString, dsCities.Query.CommandText); rt.Style.BackColor = Colors.LightBlue; rt.Style.Borders.All = new LineDef("1mm", Colors.Blue); rt.Style.Spacing.Bottom = "1cm"; doc.Body.Children.Add(rt); // data bound RenderText, listing product IDs and names: rt = new RenderText(); rt.DataBinding.DataSource = dsCities; rt.Text = "Id = [Fields!ProductID.Value] Name = [Fields!ProductName.Value]"; rt.Style.Borders.Bottom = LineDef.Default; doc.Body.Children.Add(rt); c1DocumentViewer1.Document = doc.FixedDocumentSequence; }
private void ListDir(string dir, int level) { if (string.IsNullOrEmpty(dir)) { return; } // get files first: string[] files = Directory.GetFiles(dir, _mask, SearchOption.TopDirectoryOnly); // if there are no matching files - we skip the directory as well: if (files.Length > 0) { C1PrintDocument doc; if (_sdoc != null) { doc = _sdoc; } else { doc = new C1PrintDocument(); SetupDoc(doc); } // directory header: RenderText dirHeader = new RenderText(string.Format("Files in {0}", dir)); dirHeader.Style.FontSize = 12; dirHeader.Style.FontBold = true; dirHeader.Style.Spacing.Bottom = "3mm"; dirHeader.Style.BackColor = Color.LemonChiffon; // Add a dir TOC/outline entry, keep outline as files' parent: OutlineNode dirOutlineNode = this.DirAdded(doc, dirHeader, dir, level); // add files: for (int nfile = 0; nfile < files.Length; ++nfile) { RenderArea file = ListFile(files[nfile], nfile == 0 ? dirHeader : null); doc.Body.Children.Add(file); // Add a file TOC entry: this.FileAdded(doc, dirOutlineNode, file, files[nfile], level + 1); } if (_mdoc != null) { _mdoc.Items.Add(doc); // Make sure all memory used by the added document is released: doc = null; GC.Collect(); GC.WaitForPendingFinalizers(); } } // recurse into sub-dirs: string[] dirs = Directory.GetDirectories(dir, "*", SearchOption.TopDirectoryOnly); for (int ndir = 0; ndir < dirs.Length; ++ndir) { ListDir(dirs[ndir], level + 1); } }
// highlight the render object under the mouse, if any private void c1PrintPreviewControl1_PreviewPane_Paint(object sender, PaintEventArgs e) { #if C1REPORT_PRIOR_TO_2011v2 if (_roUnderMouse == null) { return; } C1PreviewPane pane = c1PrintPreviewControl1.PreviewPane; // paint red rectangles over all fragments of the render object foreach (RenderFragment rf in _roUnderMouse.Fragments) { RectangleD rd = rf.BoundsOnPage; // FromRU converts from "resolved units" (units in which fragment's bounds are // expressed) to any desired unit - in our case, we convert to pixels RectangleD rpreview = _roUnderMouse.Document.FromRU(rd, UnitTypeEnum.Pixel, pane.DpiX, pane.DpiY); // but because the document does not know anything about the preview's zoom // or offset of pages in the preview, we convert "document pixels" to preview ones: RectangleF rectf = pane.DocumentToClient(rf.PageIndex, rpreview.ToRectangleF()); // finally, highlight the rectangle in the preview pane: e.Graphics.DrawRectangle(_hilitePen, rectf.X, rectf.Y, rectf.Width, rectf.Height); } #else if (_roUnderMouse == null && _outlinePageIdx == -1) { return; } C1PreviewPane pane = c1PrintPreviewControl1.PreviewPane; if (_outlinePageIdx != -1) { C1PrintDocument doc = c1PrintPreviewControl1.Document as C1PrintDocument; if (doc == null) { return; } RectangleF rectf = pane.DocumentToClient(_outlinePageIdx, _outlineRc.ToRectangleF()); // finally, highlight the rectangle in the preview pane: e.Graphics.DrawRectangle(_hilitePen, rectf.X, rectf.Y, rectf.Width, rectf.Height); } else { // paint red rectangles over all fragments of the render object foreach (RenderFragment rf in _roUnderMouse.Fragments) { RectangleD rd = rf.BoundsOnPage; // FromRU converts from "resolved units" (units in which fragment's bounds are // expressed) to any desired unit - in our case, we convert to pixels RectangleD rpreview = _roUnderMouse.Document.FromRU(rd, UnitTypeEnum.Pixel, pane.DpiX, pane.DpiY); // but because the document does not know anything about the preview's zoom // or offset of pages in the preview, we convert "document pixels" to preview ones: RectangleF rectf = pane.DocumentToClient(rf.PageIndex, rpreview.ToRectangleF()); // finally, highlight the rectangle in the preview pane: e.Graphics.DrawRectangle(_hilitePen, rectf.X, rectf.Y, rectf.Width, rectf.Height); } } #endif }
/// <summary> /// Initializes a ne instance of the <see cref="PrintInfo"/> class. /// </summary> /// <param name="schedule"></param> public PrintInfo(C1Scheduler schedule) { HidePrivateAppointments = false; _schedule = schedule; PrintDocument = new C1PrintDocument(); PrintStyles = new PrintStyleCollection(); PrintStyles.LoadDefaults(); PrintDocument.DocumentStarting += new EventHandler(_printDoc_DocumentStarting); }
public override void UnLoad() { if (_doc == null) { return; } _doc.LongOperation -= new LongOperationEventHandler(base.LongOperationHandler); _doc = null; }
/// <summary> /// Creates a <see cref="C1PrintDocument"/> that can be used to print, preview or export /// the grid. Page header and footer specified by the grid's PrintParameters are honored. /// </summary> /// <returns>The C1PrintDocument representing the grid.</returns> public C1PrintDocument MakeDocument() { C1PrintDocument doc = new C1PrintDocument(); doc.Body.Children.Add(MakeGridTable(doc)); doc.PageLayout.PageHeader = MakePageHeader(doc); doc.PageLayout.PageFooter = MakePageFooter(doc); return(doc); }
private void SingleDocument_Click(object sender, EventArgs e) { C1PrintDocument doc = new C1PrintDocument(); // ensure document can be cancelled: doc.DoEvents = true; // load into preview: this._pview.Document = doc; ProgressForm pf = new ProgressForm(); pf.Show(); // Build the document: try { FilesPrinter fp = new FilesPrinter(); fp.MakeMultiDocument(doc, tbDir.Text, tbMask.Text, pf); } catch (Exception ex) { MessageBox.Show(ex.Message); } // Reset cancel state of the progress form: pf.DialogResult = System.Windows.Forms.DialogResult.None; // Set up event handlers for better UI: this.FormClosing += (ss, ee) => { if (doc.BusyState == BusyStateEnum.Generating) { doc.Cancel = true; } }; doc.LongOperation += (ss, ee) => { pf.SetProgress(string.Format("Generating C1MultiDocument, {0:P} complete...", ee.Complete), (float)ee.Complete); if (pf.Cancelled && doc.BusyState == BusyStateEnum.Generating) { doc.Cancel = true; } }; doc.DocumentEnded += (ss, ee) => { pf.Hide(); this.Activate(); }; // Generate the document: doc.Generate(); }
static void MakeReport() { // report definition must be in the current directory: string dir = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); // use C1PrintDocument to generate the report: C1PrintDocument doc = new C1PrintDocument(); doc.ImportC1Report(Path.Combine(dir, @"CommonTasks.xml"), @"01: Alternating Background (Greenbar report)"); doc.Generate(); doc.Export(Path.Combine(dir, "OutputFromSampleExternalExe.PDF"), new OutputRange(new int[] { 1, 2 }), false); }
// re-generates the document keeping the current preview position private void RegenerateDocument(C1PrintDocument doc) { // NOTE the use of C1PreviewPane.LayoutSection - it will prevent flickering // and make redisplay smoother. using (new C1PreviewPane.LayoutSection(c1PrintPreviewControl1.PreviewPane, HistorySavedActionsEnum.None)) { PointF pos = c1PrintPreviewControl1.PreviewPane.PreviewScrollPosition; doc.Generate(); c1PrintPreviewControl1.PreviewPane.PreviewScrollPosition = pos; } }
internal RenderTable CreateTable(C1PrintDocument doc, int colCount, int rowCount, string cellTextMask) { RenderTable result = new RenderTable(doc); for (int r = 0; r < rowCount; r++) { for (int c = 0; c < colCount; c++) { result.Cells[r, c].Text = string.Format(cellTextMask, r, c); } } return(result); }
public override void Load() { try { _doc = new C1PrintDocument(); _doc.LongOperation += new LongOperationEventHandler(base.LongOperationHandler); _doc.ImportC1Report(FileName, ReportName); } catch { UnLoad(); throw; } }
// finds the render object given the document, page index, point in the page // (in pixels), and resolution for those pixels. private RenderObject FindRenderObject(object document, int pageIdx, PointF pt, float dpix, float dpiy) { C1PrintDocument doc = document as C1PrintDocument; if (doc != null) { return(FindRenderObject(doc.Pages[pageIdx].Fragments, pt, dpix, dpiy)); } else { return(null); } }
private void MakeDoc1(C1PrintDocument doc) { doc.Clear(); RenderText rtxt = new RenderText(doc); rtxt.Text = "This test demonstrates multiple inheritance of styles in tables. " + "In the table below, the font is redefined for row 4. " + "Then, the text color is redefined for column 1. " + "Finally, a cell group is defined containing cells in rows 4 to 6, cols 1 & 2, " + "and background color is redefined for that cell group. " + "\nThe cell at the intersection of row 4 and col 1 combines all 3 styles.\n\n"; doc.Body.Children.Add(rtxt); doc.Style.Font = new Font("Arial", 12, FontStyle.Regular); const int ROWS = 12; const int COLS = 6; RenderTable rt = new RenderTable(doc); rt.Style.Padding.All = new Unit("4mm"); for (int row = 0; row < ROWS; ++row) { for (int col = 0; col < COLS; ++col) { RenderText celltext = new RenderText(doc); celltext.Text = string.Format("Cell ({0},{1})", row, col); rt.Cells[row, col].RenderObject = celltext; } } // add the table to the document doc.Body.Children.Add(rt); // set up table style rt.Style.GridLines.All = new LineDef("2pt", Color.Black); rt.Style.GridLines.Horz = new LineDef("1pt", Color.Gray); rt.Style.GridLines.Vert = new LineDef("1pt", Color.Gray); // define a row style rt.Rows[4].Style.Font = new Font("Arial", 12, FontStyle.Bold | FontStyle.Italic); // define a column style rt.Cols[1].Style.TextColor = Color.DarkOrange; // define a cell group with a background color rt.UserCellGroups.Add(new UserCellGroup(new Rectangle(1, 4, 2, 3))); rt.UserCellGroups[0].Style.BackColor = Color.PaleGreen; }
/// <summary> /// Initializes glyph images. /// If a non-null doc is specified, images are stored in the document's dicitionary /// which improves performance. /// </summary> /// <param name="doc">The document that will contain the rendered grid. May be null.</param> private void InitGlyphImages(C1PrintDocument doc) { Array glyphs = Enum.GetValues(typeof(GlyphEnum)); if (doc != null) { _glyphImageNames = new Dictionary <GlyphEnum, string>(glyphs.Length); foreach (GlyphEnum ge in glyphs) { string imageName = Utility.MakeUniqueDictName(doc, ge.ToString() + "{0}"); doc.Dictionary.Add(new DictionaryImage(imageName, _grid.Glyphs[ge])); _glyphImageNames[ge] = imageName; } } }
private void GenerateDoc(C1PrintDocument doc) { doc.Style.Font = new Font("Verdana", 18); RenderText rt = new RenderText(); rt.Text = "New style property:\rUnit Style.CharSpacing { get; set; }\rAllows to define character spacing in text. (The default is zero.)"; rt.Style.Borders.All = new LineDef("1mm", Color.Red); rt.Style.Spacing.Bottom = "10mm"; doc.Body.Children.Add(rt); Unit cs = "2mm"; doc.Body.Children.Add(new RenderText("CharSpacing: " + cs.ToString())); rt = new RenderText(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 30; i++) { sb.Append(string.Format("Fragment{0} ", i)); } sb.Remove(sb.Length - 1, 1); rt.Text = sb.ToString(); rt.Style.Borders.All = LineDef.Default; rt.Style.BackColor = Color.LawnGreen; rt.Style.CharSpacing = cs; doc.Body.Children.Add(rt); cs = "-2pt"; doc.Body.Children.Add(new RenderText("CharSpacing: " + cs.ToString())); rt = new RenderText(); sb = new StringBuilder(); for (int i = 0; i < 30; i++) { sb.Append(string.Format("Fragment{0} ", i)); } sb.Remove(sb.Length - 1, 1); rt.Text = sb.ToString(); rt.Style.Borders.All = LineDef.Default; rt.Style.BackColor = Color.LawnGreen; rt.Style.CharSpacing = cs; doc.Body.Children.Add(rt); doc.Generate(); }
public override void Load() { if (_doc != null) { return; } try { _doc = C1PrintDocument.FromFile(FileName, C1DocumentFormatEnum.C1dx); } catch { _doc = C1PrintDocument.FromFile(FileName, C1DocumentFormatEnum.C1d); } _doc.LongOperation += new LongOperationEventHandler(base.LongOperationHandler); }
private void GenerateDoc(C1PrintDocument doc) { doc.Style.Font = new Font("Verdana", 18); RenderText rt = new RenderText(); rt.Text = "New style property:\rfloat Style.CharWidth { get; set; }\rAllows to define the width of text characters, it is define a percent of width relative to normal width i.e. 100 - normal width (default), 200 - 2times wider."; rt.Style.Borders.All = new LineDef("1mm", Color.Red); rt.Style.Spacing.Bottom = "10mm"; doc.Body.Children.Add(rt); float cw = 200; doc.Body.Children.Add(new RenderText("CharWidth: " + cw.ToString())); rt = new RenderText(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 30; i++) { sb.Append(string.Format("Fragment{0} ", i)); } sb.Remove(sb.Length - 1, 1); rt.Text = sb.ToString(); rt.Style.Borders.All = LineDef.Default; rt.Style.BackColor = Color.LawnGreen; rt.Style.CharWidth = cw; doc.Body.Children.Add(rt); cw = 50; doc.Body.Children.Add(new RenderText("CharWidth: " + cw.ToString())); rt = new RenderText(); sb = new StringBuilder(); for (int i = 0; i < 30; i++) { sb.Append(string.Format("Fragment{0} ", i)); } sb.Remove(sb.Length - 1, 1); rt.Text = sb.ToString(); rt.Style.Borders.All = LineDef.Default; rt.Style.BackColor = Color.LawnGreen; rt.Style.CharWidth = cw; doc.Body.Children.Add(rt); doc.Generate(); }
static public C1PrintDocument TableBorders() { C1PrintDocument doc = new C1PrintDocument(); RenderText rtxt = new RenderText(doc); rtxt.Text = "This test shows a non-standard way to draw table borders.\n\n"; doc.Body.Children.Add(rtxt); doc.Style.FontName = "Arial"; doc.Style.FontSize = 14; const int ROWS = 42; const int COLS = 4;// 16; RenderTable rt = new RenderTable(doc); // rt.Width = "16in"; rt.Width = "auto"; rt.ColumnSizingMode = TableSizingModeEnum.Auto; rt.SplitHorzBehavior = SplitBehaviorEnum.SplitIfNeeded; for (int row = 0; row < ROWS; ++row) { for (int col = 0; col < COLS; ++col) { //if (row == col) //continue; RenderText celltext = new RenderText(doc); celltext.Text = string.Format("Cell ({0},{1})", row, col); rt.Cells[row, col].RenderObject = celltext; } } // add the table to the document doc.Body.Children.Add(rt); // set up table style rt.Style.GridLines.All = new LineDef("1pt", Colors.Black); rt.Style.GridLines.Horz = LineDef.Empty; rt.Style.GridLines.Vert = LineDef.Empty; rt.CellStyle.Borders.All = new LineDef("1pt", Colors.DarkOrange); rt.CellStyle.Spacing.All = new Unit("0.5mm"); rt.Style.TextAlignVert = AlignVertEnum.Center; return(doc); }
private void GenerateDoc(C1PrintDocument doc) { doc.Style.Font = new Font("Verdana", 18); RenderText rt = new RenderText(); rt.Text = "New mode of horizontal text alignment: AlignHorzEnum.JustifyChars.\rSpaces added between all chars rather than only between words as is the case with AlignHorzEnum.Justify."; rt.Style.Borders.All = new LineDef("1mm", Color.Red); rt.Style.Spacing.Bottom = "10mm"; doc.Body.Children.Add(rt); doc.Body.Children.Add(new RenderText("AlignHorzEnum.JustifyChars:")); rt = new RenderText(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 30; i++) { sb.Append(string.Format("Fragment{0} ", i)); } sb.Remove(sb.Length - 1, 1); rt.Text = sb.ToString(); rt.Style.Borders.All = LineDef.Default; rt.Style.BackColor = Color.LawnGreen; rt.Style.TextAlignHorz = AlignHorzEnum.JustifyChars; doc.Body.Children.Add(rt); doc.Body.Children.Add(new RenderText("AlignHorzEnum.Justify:")); rt = new RenderText(); sb = new StringBuilder(); for (int i = 0; i < 30; i++) { sb.Append(string.Format("Fragment{0} ", i)); } sb.Remove(sb.Length - 1, 1); rt.Text = sb.ToString(); rt.Style.Borders.All = LineDef.Default; rt.Style.BackColor = Color.LawnGreen; rt.Style.TextAlignHorz = AlignHorzEnum.Justify; doc.Body.Children.Add(rt); doc.Generate(); }
private void c1Button1_Click(object sender, EventArgs e) { //print preview gauge C1PrintPreviewDialog dlg = new C1PrintPreviewDialog(); dlg.Text = "C1PrintPreview"; C1PrintDocument doc = new C1PrintDocument(); doc.StartDoc(); doc.AllowNonReflowableDocs = true; doc.PageLayout.PageSettings.Landscape = true; string date = (weatherData1.Current as DataRowView)["year"].ToString(); doc.RenderBlockText("Weather Statistics on " + date); doc.RenderBlockImage(c1Gauge1.GetImage()); doc.EndDoc(); dlg.Document = doc; dlg.Show(this.ParentForm); }
/// <summary> /// Creates a render object representing the grid. /// </summary> /// <param name="doc">The document that is to contain the created render object, or null. /// Note that this method does not add the created object to the document - /// it is the responsibility of the caller to do that. /// </param> /// <returns>The render object created.</returns> /// <remarks> /// The passed C1PrintDocument object, if not null, is used to optimize the way the grid is rendered. /// </remarks> public RenderTable MakeGridTable(C1PrintDocument doc) { Reset(); InitGlyphImages(doc); HighLightEnum savedHighlight = _grid.HighLight; if (!PrintInfo.PrintHighlight) { _grid.HighLight = HighLightEnum.Never; } try { return(MakeGridTableInternal(doc)); } finally { _grid.HighLight = savedHighlight; } }
/// <summary> /// Fills specified control with a Details style. /// </summary> /// <param name="doc"></param> public static void MakeDetails(C1PrintDocument doc) { doc.Clear(); doc.DocumentInfo.Title = "Details style"; doc.DocumentInfo.Subject = "Details"; AddNamespaces(doc); AddHeadersFooters(doc); doc.Tags["FooterRight"].Value = "[GeneratedDateTime]"; doc.DocumentStartingScript += "If Tags!InsertPageBreaks.Value And Tags!PageBreak.Value <> \"Day\" Then \r\n" + " If Tags.IndexByName(\"LastDate\") = -1 Then\r\n" + " Dim tag As Tag\r\n" + " tag = New Tag(\"LastDate\", Tags!StartDate.Value.Date)\r\n" + " Tags.Add(tag)\r\n" + " Else\r\n" + " Tags!LastDate.Value = Tags!StartDate.Value.Date\r\n" + " End If\r\n" + "End If\r\n" + "Dim dateAppointments As New DateAppointmentsCollection(Tags!StartDate.Value, Tags!EndDate.Value, Tags!Appointments.Value, false)\r\n" + "If Tags.IndexByName(\"DateAppointments\") = -1 Then\r\n" + " Dim tagApps As Tag\r\n" + " tagApps = New Tag(\"DateAppointments\", dateAppointments)\r\n" + " tagApps.SerializeValue = False\r\n" + " Tags.Add(tagApps)\r\n" + "Else\r\n" + " Tags!DateAppointments.Value = dateAppointments\r\n" + "End If"; // RenderArea representing the single day RenderArea ra1 = new RenderArea(); ra1.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value"); ra1.DataBinding.Sorting.Expressions.Add("Fields!Date.Value"); ra1.FormatDataBindingInstanceScript = "If Tags!InsertPageBreaks.Value Then\r\n" + " Dim newDate as DateTime\r\n" + " newDate = RenderObject.Original.DataBinding.Fields!Date.Value\r\n" + " Select Case Tags!PageBreak.Value\r\n" + " Case \"Week\"\r\n" + " Dim tmp as DateTime\r\n" + " tmp = Tags!LastDate.Value.Date.AddDays(1)\r\n" + " While tmp <= newDate\r\n" + " If tmp.DayOfWeek = Tags!CalendarInfo.Value.WeekStart Then\r\n" + " RenderObject.BreakBefore = BreakEnum.Page\r\n" + " Exit While\r\n" + " End If\r\n" + " tmp = tmp.AddDays(1)\r\n" + " End While\r\n" + " Case \"Month\"\r\n" + " If Tags!LastDate.Value.Month <> newDate.Month Then\r\n" + " RenderObject.BreakBefore = BreakEnum.Page\r\n" + " End If\r\n" + " Case Else\r\n" + " RenderObject.BreakBefore = BreakEnum.Page\r\n" + " End Select\r\n" + " Tags!LastDate.Value = newDate\r\n" + "End If"; ra1.Style.Spacing.All = "1mm"; // day header RenderText rt = new RenderText("[String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:D}\", Fields!Date.Value)]"); rt.FormatDataBindingInstanceScript = "RenderObject.Style.Font = Document.Tags!DateHeadingsFont.Value"; rt.Style.Borders.All = LineDef.Default; rt.Style.Padding.All = "2mm"; rt.Style.BackColor = Colors.LightGray; ra1.Children.Add(rt); // RenderArea tepresenting the single appointment RenderArea raApp = new RenderArea(); raApp.Style.Spacing.All = "2mm"; raApp.Stacking = StackingRulesEnum.InlineLeftToRight; // Set the text's data source to the data source of the containing RenderArea - this indicates that the render object is bound to the current group in the specified object: raApp.DataBinding.DataSource = new Expression("Parent.Fields!Appointments.Value"); raApp.DataBinding.Sorting.Expressions.Add("Fields!Start.Value"); raApp.DataBinding.Sorting.Expressions.Add("Fields!Subject.Value"); rt = new RenderText(); rt.Text = "[IIf(Fields!AllDayEvent.Value, \"All Day\", String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:t} - {1:t}\", " + "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, DataBinding.Parent.Fields!Date.Value, Fields!Start.Value), " + "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value.AddDays(1)), CDate(Fields!End.Value)) > 0, DataBinding.Parent.Fields!Date.Value.AddDays(1), Fields!End.Value)))]"; rt.Width = "25%"; rt.Style.FontBold = true; raApp.Children.Add(rt); RenderArea appDetails = new RenderArea(); appDetails.Width = "75%"; appDetails.Stacking = StackingRulesEnum.InlineLeftToRight; RenderText rt1 = new RenderText(); rt1.Text = "[Fields!Subject.Value] "; rt1.Style.FontBold = true; rt1.Width = "Auto"; appDetails.Children.Add(rt1); rt1 = new RenderText(); rt1.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt1.Text = "[\"-- \" & Fields!Location.Value]"; rt1.Style.FontBold = true; rt1.Width = "Auto"; appDetails.Children.Add(rt1); rt1 = new RenderText(); rt1.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Body.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse) \r\n" + "RenderObject.BreakBefore = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Subject.Value & RenderObject.Original.DataBinding.Parent.Fields!Location.Value), BreakEnum.Line, BreakEnum.None)"; rt1.Text = "[Fields!Body.Value]"; appDetails.Children.Add(rt1); rt1 = new RenderText(); rt1.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf(DateDiff(DateInterval.Second, CDate(RenderObject.Original.DataBinding.Parent.Parent.Fields!Date.Value), CDate(RenderObject.Original.DataBinding.Parent.Fields!Start.Value)) < 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt1.Text = "[\"Please See Above\"]"; rt1.Style.FontBold = true; rt1.BreakBefore = BreakEnum.Line; appDetails.Children.Add(rt1); raApp.Children.Add(appDetails); ra1.Children.Add(raApp); doc.Body.Children.Add(ra1); AddCommonTags(doc); Tag newTag = new Tag("Appointments", null, typeof(IList<Appointment>)); newTag.ShowInDialog = false; newTag.SerializeValue = false; doc.Tags.Add(newTag); newTag = new Tag("StartDate", DateTime.Today, typeof(DateTime)); newTag.InputParams = new TagDateTimeInputParams(); doc.Tags.Add(newTag); newTag = new Tag("EndDate", DateTime.Today.AddDays(1), typeof(DateTime)); newTag.InputParams = new TagDateTimeInputParams(); doc.Tags.Add(newTag); newTag = new Tag("InsertPageBreaks", false, typeof(Boolean)); newTag.Description = "Start a new page each"; doc.Tags.Add(newTag); newTag = new Tag("PageBreak", "Day", typeof(string)); newTag.Description = ""; newTag.InputParams = new TagListInputParams(TagListInputParamsTypeEnum.ComboBox, new TagListInputParamsItem("Day", "Day"), new TagListInputParamsItem("Week", "Week"), new TagListInputParamsItem("Month", "Month")); doc.Tags.Add(newTag); newTag = new Tag("HidePrivateAppointments", false, typeof(bool)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); }
/// <summary> /// Adds namespaces (common for all documents) /// </summary> /// <param name="doc"></param> private static void AddNamespaces(C1PrintDocument doc) { doc.TagEscapeString = "\x01"; doc.ScriptingOptions.Namespaces.Add("C1.C1Schedule"); doc.ScriptingOptions.Namespaces.Add("C1.C1Schedule.Printing"); }
/// <summary> /// Fills specified control with a Day style. /// </summary> /// <param name="doc"></param> public static void MakeDay(C1PrintDocument doc) { doc.Clear(); doc.DocumentInfo.Title = "Daily style"; doc.DocumentInfo.Subject = "Day"; AddNamespaces(doc); AddHeadersFooters(doc); doc.Tags["FooterRight"].Value = "[GeneratedDateTime]"; doc.Tags["DateHeadingsFont"].Value = new Font("Segoe UI", 24, FontStyle.Bold); doc.DocumentStartingScript += "Dim tasksNumber As Integer = 0 \r\n" + "If Document.Tags!IncludeTasks.Value Then\r\n" + " tasksNumber = tasksNumber + 1 \r\n" + "End If\r\n" + "If Document.Tags!IncludeBlankNotes.Value Then\r\n" + " tasksNumber = tasksNumber + 1 \r\n" + "End If\r\n" + "If Document.Tags!IncludeLinedNotes.Value Then\r\n" + " tasksNumber = tasksNumber + 1 \r\n" + "End If\r\n" + "If tasksNumber = 1 Then\r\n" + " Document.Tags!TaskHeight.Value = New Unit(\"100%\")\r\n" + "ElseIf tasksNumber = 2 Then\r\n" + " Document.Tags!TaskHeight.Value = New Unit(\"50%\")\r\n" + "Else\r\n" + " Document.Tags!TaskHeight.Value = New Unit(\"33.3%\")\r\n" + "End If\r\n" + "Dim dateAppointments As New DateAppointmentsCollection(Tags!StartDate.Value, Tags!EndDate.Value, Tags!Appointments.Value, Tags!CalendarInfo.Value, True, True)\r\n" + "If Tags.IndexByName(\"DateAppointments\") = -1 Then\r\n" + " Dim tagApps As Tag\r\n" + " tagApps = New Tag(\"DateAppointments\", dateAppointments)\r\n" + " tagApps.SerializeValue = False\r\n" + " Tags.Add(tagApps)\r\n" + "Else\r\n" + " Tags!DateAppointments.Value = dateAppointments\r\n" + "End If\r\n" + "Dim startT As Date = Tags!StartTime.Value \r\n" + "Dim endT As Date = Tags!EndTime.Value \r\n" + "If startT > endT Then\r\n" + " Tags!StartTime.Value = endT \r\n" + " Tags!EndTime.Value = startT \r\n" + "End If"; // RenderArea representing the single page RenderArea raPage = new RenderArea(); raPage.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value"); raPage.DataBinding.Sorting.Expressions.Add("Fields!Date.Value"); raPage.BreakBefore = BreakEnum.Page; raPage.Width = "100%"; raPage.Height = "100%"; raPage.Stacking = StackingRulesEnum.InlineLeftToRight; #region ** day header // day header RenderArea raDayHeader = new RenderArea(); raDayHeader.Style.Borders.All = LineDef.Default; raDayHeader.Width = "100%"; raDayHeader.Height = "28mm"; raDayHeader.Stacking = StackingRulesEnum.InlineLeftToRight; RenderText rt = new RenderText("[CDate(Fields!Date.Value).ToString(\"D\", Document.Tags!CalendarInfo.Value.CultureInfo)]"); rt.FormatDataBindingInstanceScript = "RenderObject.Style.Font = Document.Tags!DateHeadingsFont.Value\r\n" + "Dim startDate As Date = RenderObject.Original.Parent.Parent.DataBinding.Fields!Date.Value\r\n" + "Document.Tags!StartTime.Value = startDate.Add(Document.Tags!StartTime.Value.TimeOfDay)\r\n" + "Document.Tags!EndTime.Value = startDate.Add(Document.Tags!EndTime.Value.TimeOfDay)\r\n" + "Document.Tags!MonthCalendar.Value = New Date(startDate.Year, startDate.Month, 1) \r\n" + "startDate = Document.Tags!StartTime.Value\r\n" + "Document.Tags!DayHours.Value = New Dictionary(of Date, Date)\r\n" + "While startDate < Document.Tags!EndTime.Value\r\n" + " Document.Tags!DayHours.Value.Add(startDate, startDate)\r\n" + " startDate = startDate.AddMinutes(30)\r\n" + "End While"; rt.Style.TextAlignVert = AlignVertEnum.Center; rt.Style.Spacing.Left = "2mm"; rt.Height = "100%"; rt.Width = "parent.Width - 38mm"; raDayHeader.Children.Add(rt); RenderArea monthCalendar = new RenderArea(); monthCalendar.Stacking = StackingRulesEnum.InlineLeftToRight; monthCalendar.Style.Spacing.Left = "1mm"; monthCalendar.Style.Spacing.Right = "3mm"; monthCalendar.Style.Spacing.Top = "0.5mm"; monthCalendar.Width = "36mm"; rt = new RenderText("[CDate(Document.Tags!MonthCalendar.Value).ToString(\"MMMM yyy\", Document.Tags!CalendarInfo.Value.CultureInfo)]"); rt.FormatDataBindingInstanceScript = "Dim startDate As Date = Document.Tags!MonthCalendar.Value\r\n" + "Dim endDate As Date = startDate.AddMonths(1).AddDays(-1)\r\n" + "While startDate.DayOfWeek <> Document.Tags!CalendarInfo.Value.WeekStart \r\n" + " startDate = startDate.AddDays(-1)\r\n" + "End While\r\n" + "Document.Tags!WeekNumber.Value = New List(of Date)\r\n" + "While startDate <= endDate\r\n" + " Document.Tags!WeekNumber.Value.Add(startDate)\r\n" + " startDate = startDate.AddDays(7)\r\n" + "End While"; rt.Style.TextAlignHorz = AlignHorzEnum.Center; rt.Style.Font = new Font("Segoe UI", 8); rt.Width = "100%"; monthCalendar.Children.Add(rt); rt = new RenderText(" "); rt.Style.Font = new Font("Arial", 7f); rt.Style.WordWrap = false; rt.Width = "12.5%"; monthCalendar.Children.Add(rt); rt = new RenderText("[Document.Tags!CalendarInfo.Value.CultureInfo.DateTimeFormat.GetShortestDayName(CDate(Fields!Date.Value).DayOfWeek)]"); rt.DataBinding.DataSource = new Expression("New DateAppointmentsCollection(Document.Tags!WeekNumber.Value(0), Document.Tags!WeekNumber.Value(0).AddDays(6), Document.Tags!Appointments.Value, True)"); rt.DataBinding.Sorting.Expressions.Add("Fields!Date.Value"); rt.Style.Borders.Bottom = LineDef.Default; rt.Style.Font = new Font("Arial", 7f); rt.Style.TextAlignHorz = AlignHorzEnum.Center; rt.Style.WordWrap = false; rt.Width = "12.5%"; monthCalendar.Children.Add(rt); RenderArea raWeek = new RenderArea(); raWeek.DataBinding.DataSource = new Expression("Document.Tags!WeekNumber.Value"); raWeek.Style.Font = new Font("Arial", 7f); raWeek.Width = "100%"; raWeek.Stacking = StackingRulesEnum.InlineLeftToRight; rt = new RenderText("[Document.Tags!CalendarInfo.Value.CultureInfo.Calendar.GetWeekOfYear(CDate(Fields!Date.Value), System.Globalization.CalendarWeekRule.FirstDay, Document.Tags!CalendarInfo.Value.WeekStart)]"); rt.Style.Borders.Right = LineDef.Default; rt.Style.TextAlignHorz = AlignHorzEnum.Right; rt.Style.WordWrap = false; rt.Width = "12.5%"; raWeek.Children.Add(rt); rt = new RenderText("[CDate(Fields!Date.Value).ToString(\"%d\", Document.Tags!CalendarInfo.Value.CultureInfo)]"); rt.DataBinding.DataSource = new Expression("New DateAppointmentsCollection(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value).AddDays(6), Document.Tags!Appointments.Value, True)"); rt.DataBinding.Sorting.Expressions.Add("Fields!Date.Value"); rt.FormatDataBindingInstanceScript = "If RenderObject.Original.DataBinding.Fields!Date.Value.Month <> Document.Tags!MonthCalendar.Value.Month Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Hidden\r\n" + "Else If RenderObject.Original.DataBinding.Fields!HasAppointments.Value Then\r\n" + " RenderObject.Style.FontBold = true\r\n" + "End If"; rt.Style.TextAlignHorz = AlignHorzEnum.Right; rt.Width = "12.5%"; raWeek.Children.Add(rt); monthCalendar.Children.Add(raWeek); raDayHeader.Children.Add(monthCalendar); raPage.Children.Add(raDayHeader); #endregion #region ** day // day RenderArea raDayBody = new RenderArea(); raDayBody.FormatDataBindingInstanceScript = "If Not (Document.Tags!IncludeTasks.Value Or Document.Tags!IncludeBlankNotes.Value Or Document.Tags!IncludeLinedNotes.Value) Then\r\n" + " RenderObject.Width = \"100%\" \r\n" + "End If"; raDayBody.Style.Spacing.Top = "0.5mm"; raDayBody.Style.Borders.All = LineDef.Default; raDayBody.Width = "75%"; raDayBody.Height = "parent.Height - 28mm"; raDayBody.Stacking = StackingRulesEnum.BlockTopToBottom; #region ** all-day events // RenderArea representing the single day RenderArea raDay = new RenderArea(); raDay.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value))"); raDay.DataBinding.Sorting.Expressions.Add("Fields!Date.Value"); raDay.Stacking = StackingRulesEnum.InlineLeftToRight; raDay.Height = "Auto"; RenderText status = new RenderText(" "); status.FormatDataBindingInstanceScript = "If IsNothing(RenderObject.Original.DataBinding.Parent.Fields!BusyStatus.Value) Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Collapse\r\n" + "Else \r\n" + " RenderObject.Style.Brush = RenderObject.Original.DataBinding.Parent.Fields!BusyStatus.Value.Brush.Brush \r\n" + "End If"; status.Width = "100%"; status.Height = "1.5mm"; raDay.Children.Add(status); // RenderArea representing the single appointment RenderArea raApp = new RenderArea(); raApp.Style.Spacing.All = "0.5mm"; raApp.Style.Spacing.Left = "1.25cm"; raApp.FormatDataBindingInstanceScript = "If RenderObject.Original.DataBinding.Fields!AllDayEvent.Value Then\r\n" + " RenderObject.Style.Borders.All = LineDef.Default\r\n" + "ElseIf DateDiff(DateInterval.Second, CDate(Document.Tags!StartTime.Value), CDate(RenderObject.Original.DataBinding.Fields!Start.Value)) >= 0 Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Collapse\r\n" + "End If\r\n" + "If Not IsNothing(RenderObject.Original.DataBinding.Fields!Label.Value) Then\r\n" + " RenderObject.Style.Brush = CType(RenderObject.Original.DataBinding.Fields!Label.Value, Label).Brush.Brush\r\n" + "End If"; raApp.Stacking = StackingRulesEnum.InlineLeftToRight; // Set the text's data source to the data source of the containing RenderArea - this indicates that the render object is bound to the current group in the specified object: raApp.DataBinding.DataSource = new Expression("Parent.Fields!Appointments.Value"); raApp.DataBinding.Sorting.Expressions.Add("Fields!Start.Value"); raApp.DataBinding.Sorting.Expressions.Add("Fields!Subject.Value"); rt = new RenderText(); rt.Text = "[IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, \"> \", String.Empty) & " + "IIf(Fields!AllDayEvent.Value, \"\", String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:t} {1:t}\", " + "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, DataBinding.Parent.Fields!Date.Value, Fields!Start.Value), " + "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value.AddDays(1)), CDate(Fields!End.Value)) > 0, DataBinding.Parent.Fields!Date.Value.AddDays(1), Fields!End.Value)))]"; rt.Width = "Auto"; raApp.Children.Add(rt); rt = new RenderText(); rt.Text = " [Fields!Subject.Value] "; rt.Width = "Auto"; raApp.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[\" (\" & Fields!Location.Value & \")\"]"; rt.Width = "Auto"; raApp.Children.Add(rt); raDay.Children.Add(raApp); raDayBody.Children.Add(raDay); #endregion #region ** slots raDay = new RenderArea(); raDay.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value))"); raDay.DataBinding.Sorting.Expressions.Add("Fields!Date.Value"); raDay.Stacking = StackingRulesEnum.InlineLeftToRight; raDay.Height = "parent - prev.height - next.height"; RenderArea raTimeSlot = new RenderArea(); raTimeSlot.FormatDataBindingInstanceScript = "RenderObject.Height = New Unit((100/CLng(Document.Tags!DayHours.Value.Count) - 0.005).ToString(\"#.###\", System.Globalization.CultureInfo.InvariantCulture) & \"%\")"; raTimeSlot.DataBinding.DataSource = new Expression("Document.Tags!DayHours.Value"); raTimeSlot.Width = "100%"; raTimeSlot.Height = "0.5cm"; raTimeSlot.Stacking = StackingRulesEnum.InlineLeftToRight; RenderParagraph rp = new RenderParagraph(); rp.FormatDataBindingInstanceScript = "Document.Tags!SlotAppointments.Value = Document.Tags!DateAppointments.Value.GetIntervalAppointments(RenderObject.Original.DataBinding.Parent.Fields!Key.Value, RenderObject.Original.DataBinding.PArent.Fields!Key.Value.AddMinutes(30), False)\r\n" + "RenderObject.Visibility = IIf(RenderObject.Original.DataBinding.Parent.Fields!Key.Value.Minute = 0, VisibilityEnum.Visible, VisibilityEnum.Hidden)\r\n" + "Dim headerFont As Font = Document.Tags!DateHeadingsFont.Value\r\n" + "RenderObject.Style.Font = New Font(headerFont.FontFamily, headerFont.Size * 2 / 3)"; rp.Width = "1.65cm"; rp.Style.TextAlignHorz = AlignHorzEnum.Right; rp.Style.Borders.Top = LineDef.Default; rp.Style.Padding.Right = "1mm"; rp.Height = "100%"; ParagraphText pt = new ParagraphText("[IIf(String.IsNullOrEmpty(Document.Tags!CalendarInfo.Value.CultureInfo.DateTimeFormat.AMDesignator), CDate(Fields!Key.Value).ToString(\"%H\"), CDate(Fields!Key.Value).ToString(\"%h\"))]"); pt.Style.FontBold = true; pt.Style.Padding.Right = "1mm"; rp.Content.Add(pt); rp.Content.Add(new ParagraphText("[IIf(String.IsNullOrEmpty(Document.Tags!CalendarInfo.Value.CultureInfo.DateTimeFormat.AMDesignator), \"00\", CDate(Fields!Key.Value).ToString(\"tt\", Document.Tags!CalendarInfo.Value.CultureInfo).ToLower())]", TextPositionEnum.Superscript)); raTimeSlot.Children.Add(rp); RenderArea slot = new RenderArea(); slot.Width = "parent.width - prev.width - prev.left"; slot.Height = "100%"; slot.Style.Borders.Top = LineDef.Default; slot.Style.Borders.Left = LineDef.Default; slot.Stacking = StackingRulesEnum.InlineLeftToRight; // RenderArea representing the single appointment raApp = new RenderArea(); // Set the text's data source to the data source of the containing RenderArea - this indicates that the render object is bound to the current group in the specified object: raApp.DataBinding.DataSource = new Expression("Document.Tags!SlotAppointments.Value"); raApp.DataBinding.Sorting.Expressions.Add("Fields!Start.Value"); raApp.DataBinding.Sorting.Expressions.Add("Fields!Subject.Value"); raApp.Style.Spacing.All = "0.5mm"; raApp.FormatDataBindingInstanceScript = "RenderObject.Width = New Unit((100/CLng(Document.Tags!SlotAppointments.Value.Count) - 0.005).ToString(\"#.###\", System.Globalization.CultureInfo.InvariantCulture) & \"%\")\r\n" + "If Not IsNothing(RenderObject.Original.DataBinding.Fields!Label.Value) Then\r\n" + " RenderObject.Style.Brush = CType(RenderObject.Original.DataBinding.Fields!Label.Value, Label).Brush.Brush\r\n" + "End If"; raApp.Width = "10%"; raApp.Height = "100%"; raApp.Stacking = StackingRulesEnum.InlineLeftToRight; rt = new RenderText(); rt.Text = "[String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:t}-{1:t}\", Fields!Start.Value, Fields!End.Value).ToLower()]"; rt.Width = "Auto"; raApp.Children.Add(rt); rt = new RenderText(); rt.Text = " [Fields!Subject.Value] "; rt.Width = "Auto"; raApp.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[\" (\" & Fields!Location.Value & \")\"]"; rt.Width = "Auto"; raApp.Children.Add(rt); slot.Children.Add(raApp); raTimeSlot.Children.Add(slot); raDay.Children.Add(raTimeSlot); raDayBody.Children.Add(raDay); #endregion #region ** late appointments raDay = new RenderArea(); raDay.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value))"); raDay.DataBinding.Sorting.Expressions.Add("Fields!Date.Value"); raDay.Style.Borders.Top = LineDef.Default; raDay.Stacking = StackingRulesEnum.InlineLeftToRight; raDay.Height = "Auto"; // RenderArea representing the single appointment raApp = new RenderArea(); raApp.Style.Spacing.All = "0.5mm"; raApp.Style.Spacing.Left = "1.25cm"; raApp.FormatDataBindingInstanceScript = "If DateDiff(DateInterval.Second, CDate(Document.Tags!EndTime.Value), CDate(RenderObject.Original.DataBinding.Fields!Start.Value)) >= 0 Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Visible\r\n" + "Else\r\n" + " RenderObject.Visibility = VisibilityEnum.Collapse\r\n" + "End If\r\n" + "If Not IsNothing(RenderObject.Original.DataBinding.Fields!Label.Value) Then\r\n" + " RenderObject.Style.Brush = CType(RenderObject.Original.DataBinding.Fields!Label.Value, Label).Brush.Brush\r\n" + "End If"; raApp.Stacking = StackingRulesEnum.InlineLeftToRight; // Set the text's data source to the data source of the containing RenderArea - this indicates that the render object is bound to the current group in the specified object: raApp.DataBinding.DataSource = new Expression("Parent.Fields!Appointments.Value"); raApp.DataBinding.Sorting.Expressions.Add("Fields!Start.Value"); raApp.DataBinding.Sorting.Expressions.Add("Fields!Subject.Value"); rt = new RenderText(); rt.Text = "[IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, \"> \", String.Empty) & " + "IIf(Fields!AllDayEvent.Value, \"\", String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:t} {1:t}\", " + "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, DataBinding.Parent.Fields!Date.Value, Fields!Start.Value), " + "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value.AddDays(1)), CDate(Fields!End.Value)) > 0, DataBinding.Parent.Fields!Date.Value.AddDays(1), Fields!End.Value)))]"; rt.Width = "Auto"; raApp.Children.Add(rt); rt = new RenderText(); rt.Text = " [Fields!Subject.Value] "; rt.Width = "Auto"; raApp.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[\" (\" & Fields!Location.Value & \")\"]"; rt.Width = "Auto"; raApp.Children.Add(rt); raDay.Children.Add(raApp); raDayBody.Children.Add(raDay); #endregion raPage.Children.Add(raDayBody); #endregion #region ** tasks // tasks RenderArea include = new RenderArea(); include.FormatDataBindingInstanceScript = "If Document.Tags!IncludeTasks.Value Or Document.Tags!IncludeBlankNotes.Value Or Document.Tags!IncludeLinedNotes.Value Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Visible \r\n" + "Else\r\n" + " RenderObject.Visibility = VisibilityEnum.Collapse \r\n" + "End If"; include.Width = "25%"; include.Height = "parent.Height - 28mm"; RenderArea raTasks = new RenderArea(); raTasks.FormatDataBindingInstanceScript = "If Not Document.Tags!IncludeTasks.Value Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Collapse \r\n" + "End If\r\n" + "RenderObject.Height = Document.Tags!TaskHeight.Value"; raTasks.Style.Borders.All = LineDef.Default; raTasks.Style.Spacing.Top = "0.5mm"; raTasks.Style.Spacing.Left = "0.5mm"; raTasks.Width = "100%"; rt = new RenderText(); rt.Text = "Tasks"; rt.Style.Padding.Left = "2mm"; rt.Style.Borders.Bottom = LineDef.Default; raTasks.Children.Add(rt); include.Children.Add(raTasks); RenderArea raNotes = new RenderArea(); raNotes.FormatDataBindingInstanceScript = "If Not Document.Tags!IncludeBlankNotes.Value Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Collapse \r\n" + "End If\r\n" + "RenderObject.Height = Document.Tags!TaskHeight.Value"; raNotes.Style.Borders.All = LineDef.Default; raNotes.Style.Spacing.Top = "0.5mm"; raNotes.Style.Spacing.Left = "0.5mm"; raNotes.Width = "100%"; rt = new RenderText(); rt.Text = "Notes"; rt.Style.Padding.Left = "2mm"; rt.Style.Borders.Bottom = LineDef.Default; raNotes.Children.Add(rt); include.Children.Add(raNotes); raNotes = new RenderArea(); raNotes.FormatDataBindingInstanceScript = "If Not Document.Tags!IncludeLinedNotes.Value Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Collapse \r\n" + "End If\r\n" + "RenderObject.Height = Document.Tags!TaskHeight.Value"; raNotes.Style.Borders.All = LineDef.Default; raNotes.Style.Spacing.Top = "0.5mm"; raNotes.Style.Spacing.Left = "0.5mm"; raNotes.Width = "100%"; rt = new RenderText(); rt.Text = "Notes"; rt.Style.Padding.Left = "2mm"; rt.Style.Borders.Bottom = LineDef.Default; raNotes.Children.Add(rt); RenderTable lines = new RenderTable(); lines.Rows.Insert(0, 1); lines.Rows[0].Height = "0.5cm"; TableVectorGroup gr = lines.RowGroups[0, 1]; gr.Header = TableHeaderEnum.None; List<int> lst = new List<int>(60); for (int i = 0; i < 60; i++) { lst.Add(i); } gr.DataBinding.DataSource = lst; lines.Style.GridLines.Horz = LineDef.Default; lines.RowSizingMode = TableSizingModeEnum.Fixed; raNotes.Children.Add(lines); include.Children.Add(raNotes); raPage.Children.Add(include); #endregion doc.Body.Children.Add(raPage); AddCommonTags(doc); Tag newTag = new Tag("Appointments", null, typeof(IList<Appointment>)); newTag.ShowInDialog = false; newTag.SerializeValue = false; doc.Tags.Add(newTag); newTag = new Tag("WeekNumber", null, typeof(List<DateTime>)); newTag.SerializeValue = false; newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("DayHours", null, typeof(Dictionary<DateTime, DateTime>)); newTag.SerializeValue = false; newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("MonthCalendar", null, typeof(DateTime)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("StartDate", DateTime.Today, typeof(DateTime)); newTag.InputParams = new TagDateTimeInputParams(); doc.Tags.Add(newTag); newTag = new Tag("EndDate", DateTime.Today.AddDays(1), typeof(DateTime)); newTag.InputParams = new TagDateTimeInputParams(); doc.Tags.Add(newTag); newTag = new Tag("StartTime", DateTime.Today.AddHours(7), typeof(DateTime)); newTag.InputParams = new TagDateTimeInputParams(); ((TagDateTimeInputParams)newTag.InputParams).Format = DateTimePickerFormat.Time; doc.Tags.Add(newTag); newTag = new Tag("EndTime", DateTime.Today.AddHours(19), typeof(DateTime)); newTag.InputParams = new TagDateTimeInputParams(); ((TagDateTimeInputParams)newTag.InputParams).Format = DateTimePickerFormat.Time; doc.Tags.Add(newTag); newTag = new Tag("HidePrivateAppointments", false, typeof(bool)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("TaskHeight", new Unit("33.3%"), typeof(Unit)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("SlotAppointments", null, typeof(List<Appointment>)); newTag.SerializeValue = false; newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("IncludeTasks", false, typeof(bool)); newTag.ShowInDialog = true; newTag.InputParams = new TagBoolInputParams(); newTag.Description = "Include Tasks"; doc.Tags.Add(newTag); newTag = new Tag("IncludeBlankNotes", false, typeof(bool)); newTag.ShowInDialog = true; newTag.InputParams = new TagBoolInputParams(); newTag.Description = "Include Notes (blank)"; doc.Tags.Add(newTag); newTag = new Tag("IncludeLinedNotes", false, typeof(bool)); newTag.ShowInDialog = true; newTag.InputParams = new TagBoolInputParams(); newTag.Description = "Include Notes (lined)"; doc.Tags.Add(newTag); }
/// <summary> /// Adds header and footer tags (common for all documents) /// </summary> /// <param name="doc"></param> private static void AddHeadersFooters(C1PrintDocument doc) { RenderTable theader = new RenderTable(); theader.Cells[0, 0].Style.TextAlignHorz = AlignHorzEnum.Left; theader.Cells[0, 1].Style.TextAlignHorz = AlignHorzEnum.Center; theader.Cells[0, 2].Style.TextAlignHorz = AlignHorzEnum.Right; theader.CellStyle.Padding.Bottom = "2mm"; theader.Cells[0, 0].Text = "[Document.Tags!HeaderLeft.Value]"; theader.Cells[0, 1].Text = "[Document.Tags!HeaderCenter.Value]"; theader.Cells[0, 2].Text = "[Document.Tags!HeaderRight.Value]"; doc.PageLayouts.Default.PageHeader = theader; theader = new RenderTable(); theader.Cells[0, 0].Style.TextAlignHorz = AlignHorzEnum.Left; theader.Cells[0, 1].Style.TextAlignHorz = AlignHorzEnum.Center; theader.Cells[0, 2].Style.TextAlignHorz = AlignHorzEnum.Right; theader.CellStyle.Padding.Bottom = "2mm"; theader.Cells[0, 0].Text = "[IIf(Document.Tags!ReverseOnEvenPages.Value, Document.Tags!HeaderRight.Value, Document.Tags!HeaderLeft.Value)]"; theader.Cells[0, 1].Text = "[Document.Tags!HeaderCenter.Value]"; theader.Cells[0, 2].Text = "[IIf(Document.Tags!ReverseOnEvenPages.Value, Document.Tags!HeaderLeft.Value, Document.Tags!HeaderRight.Value)]"; doc.PageLayouts.EvenPages = new PageLayout(); doc.PageLayouts.EvenPages.PageHeader = theader; RenderTable tfooter = new RenderTable(); tfooter.Cells[0, 0].Style.TextAlignHorz = AlignHorzEnum.Left; tfooter.Cells[0, 1].Style.TextAlignHorz = AlignHorzEnum.Center; tfooter.Cells[0, 2].Style.TextAlignHorz = AlignHorzEnum.Right; tfooter.CellStyle.Padding.Top = "2mm"; tfooter.Cells[0, 0].Text = "[Document.Tags!FooterLeft.Value]"; tfooter.Cells[0, 1].Text = "[Document.Tags!FooterCenter.Value]"; tfooter.Cells[0, 2].Text = "[Document.Tags!FooterRight.Value]"; doc.PageLayouts.Default.PageFooter = tfooter; tfooter = new RenderTable(); tfooter.Cells[0, 0].Style.TextAlignHorz = AlignHorzEnum.Left; tfooter.Cells[0, 1].Style.TextAlignHorz = AlignHorzEnum.Center; tfooter.Cells[0, 2].Style.TextAlignHorz = AlignHorzEnum.Right; tfooter.CellStyle.Padding.Top = "2mm"; tfooter.Cells[0, 0].Text = "[IIf(Document.Tags!ReverseOnEvenPages.Value, Document.Tags!FooterRight.Value, Document.Tags!FooterLeft.Value)]"; tfooter.Cells[0, 1].Text = "[Document.Tags!FooterCenter.Value]"; tfooter.Cells[0, 2].Text = "[IIf(Document.Tags!ReverseOnEvenPages.Value, Document.Tags!FooterLeft.Value, Document.Tags!FooterRight.Value)]"; doc.PageLayouts.EvenPages.PageFooter = tfooter; // add page header/footer tags Tag newTag = new Tag("HeaderLeft", String.Empty, typeof(string)); doc.Tags.Add(newTag); newTag = new Tag("HeaderCenter", String.Empty, typeof(string)); doc.Tags.Add(newTag); newTag = new Tag("HeaderRight", String.Empty, typeof(string)); doc.Tags.Add(newTag); newTag = new Tag("FooterLeft", String.Empty, typeof(string)); doc.Tags.Add(newTag); newTag = new Tag("FooterCenter", "[PageNo]", typeof(string)); doc.Tags.Add(newTag); newTag = new Tag("FooterRight", String.Empty, typeof(string)); doc.Tags.Add(newTag); newTag = new Tag("ReverseOnEvenPages", false, typeof(bool)); doc.Tags.Add(newTag); newTag = new Tag("HeaderColor", Colors.Black, typeof(System.Windows.Media.Color)); doc.Tags.Add(newTag); newTag = new Tag("FooterColor", Colors.Black, typeof(System.Windows.Media.Color)); doc.Tags.Add(newTag); newTag = new Tag("HeaderFont", new Font("Tahoma", 8), typeof(Font)); doc.Tags.Add(newTag); newTag = new Tag("FooterFont", new Font("Tahoma", 8), typeof(Font)); doc.Tags.Add(newTag); newTag = new Tag("DateHeadingsFont", new Font("Segoe UI", 12, FontStyle.Bold), typeof(Font)); doc.Tags.Add(newTag); newTag = new Tag("AppointmentsFont", new Font("Segoe UI", 8), typeof(Font)); doc.Tags.Add(newTag); doc.DocumentStartingScript = "Document.Style.Font = Document.Tags!AppointmentsFont.Value\r\n" + "Document.PageLayout.PageFooter.Style.TextColor = Document.Tags!FooterColor.Value\r\n" + "Document.PageLayouts.EvenPages.PageFooter.Style.TextColor = Document.Tags!FooterColor.Value\r\n" + "Document.PageLayout.PageHeader.Style.TextColor = Document.Tags!HeaderColor.Value\r\n" + "Document.PageLayouts.EvenPages.PageHeader.Style.TextColor = Document.Tags!HeaderColor.Value\r\n" + "Document.PageLayout.PageFooter.Style.Font = Document.Tags!FooterFont.Value\r\n" + "Document.PageLayouts.EvenPages.PageFooter.Style.Font = Document.Tags!FooterFont.Value\r\n" + "Document.PageLayout.PageHeader.Style.Font = Document.Tags!HeaderFont.Value\r\n" + "Document.PageLayouts.EvenPages.PageHeader.Style.Font = Document.Tags!HeaderFont.Value\r\n"; }
/// <summary> /// Adds common tags /// </summary> /// <param name="doc"></param> private static void AddCommonTags(C1PrintDocument doc) { // CalendarInfo object contains all calendar-cspecific information // (culture, working days, week start, etc..) Tag newTag = new Tag("CalendarInfo", null, typeof(CalendarInfo)); newTag.ShowInDialog = false; newTag.SerializeValue = false; doc.Tags.Add(newTag); }
/// <summary> /// Fills specified control with a Month style. /// </summary> /// <param name="doc"></param> public static void MakeMonth(C1PrintDocument doc) { doc.Clear(); doc.DocumentInfo.Title = "Monthly style"; doc.DocumentInfo.Subject = "Month"; AddNamespaces(doc); AddHeadersFooters(doc); doc.PageLayout.PageSettings.Landscape = true; doc.Tags["FooterRight"].Value = "[GeneratedDateTime]"; doc.Tags["DateHeadingsFont"].Value = new Font("Segoe UI", 20, FontStyle.Bold); doc.DocumentStartingScript += "Dim daysNumber As Long = 7.0 \r\n" + "If Document.Tags!WorkDaysOnly.Value Then\r\n" + " daysNumber = Document.Tags!CalendarInfo.Value.WorkDays.Count \r\n" + "End If\r\n" + "Document.Tags!DayWidth.Value = New Unit((97.3/daysNumber - 0.005).ToString(\"#.###\", System.Globalization.CultureInfo.InvariantCulture) & \"%\") \r\n" + "Dim tasksNumber As Integer = 0 \r\n" + "If Document.Tags!IncludeTasks.Value Then\r\n" + " tasksNumber = tasksNumber + 1 \r\n" + "End If\r\n" + "If Document.Tags!IncludeBlankNotes.Value Then\r\n" + " tasksNumber = tasksNumber + 1 \r\n" + "End If\r\n" + "If Document.Tags!IncludeLinedNotes.Value Then\r\n" + " tasksNumber = tasksNumber + 1 \r\n" + "End If\r\n" + "If tasksNumber = 1 Then\r\n" + " Document.Tags!TaskHeight.Value = New Unit(\"100%\")\r\n" + "ElseIf tasksNumber = 2 Then\r\n" + " Document.Tags!TaskHeight.Value = New Unit(\"50%\")\r\n" + "Else\r\n" + " Document.Tags!TaskHeight.Value = New Unit(\"33.3%\")\r\n" + "End If\r\n" + "Dim startT As DateTime = Tags!StartDate.Value \r\n" + "Dim endT As DateTime = Tags!EndDate.Value \r\n" + "While startT.DayOfWeek <> Tags!CalendarInfo.Value.WeekStart \r\n" + " startT = startT.AddDays(-1)\r\n" + "End While\r\n" + "Dim days As Long = DateDiff(DateInterval.Day, startT, endT )\r\n" + "endT = endT.AddDays(35 - (days Mod 35))\r\n" + "Dim months As New List(Of Date)\r\n" + "Dim s As DateTime = startT\r\n" + "While s < endT\r\n" + " months.Add(s)\r\n" + " s = s.AddDays(35)\r\n" + "End While\r\n" + "If Tags.IndexByName(\"Months\") = -1 Then\r\n" + " Dim tagMonths As Tag\r\n" + " tagMonths = New Tag(\"Months\", months)\r\n" + " tagMonths.SerializeValue = False\r\n" + " Tags.Add(tagMonths)\r\n" + "Else\r\n" + " Tags!Months.Value = months\r\n" + "End If\r\n" + "\r\n" + "Dim dateAppointments As New DateAppointmentsCollection(startT, endT, Tags!Appointments.Value, Tags!CalendarInfo.Value, True, Not Tags!WorkDaysOnly.Value)\r\n" + "If Tags.IndexByName(\"DateAppointments\") = -1 Then\r\n" + " Dim tagApps As Tag\r\n" + " tagApps = New Tag(\"DateAppointments\", dateAppointments)\r\n" + " tagApps.SerializeValue = False\r\n" + " Tags.Add(tagApps)\r\n" + "Else\r\n" + " Tags!DateAppointments.Value = dateAppointments\r\n" + "End If\r\n"; // RenderArea representing the single page RenderArea raPage = new RenderArea(); raPage.DataBinding.DataSource = new Expression("Document.Tags!Months.Value"); raPage.DataBinding.Sorting.Expressions.Add("Fields!Date.Value"); raPage.BreakBefore = BreakEnum.Page; raPage.Width = "100%"; raPage.Height = "100%"; raPage.Stacking = StackingRulesEnum.InlineLeftToRight; #region ** month header // month header RenderArea raMonthHeader = new RenderArea(); raMonthHeader.Style.Borders.All = LineDef.Default; raMonthHeader.Width = "100%"; raMonthHeader.Height = "28mm"; raMonthHeader.Stacking = StackingRulesEnum.InlineLeftToRight; RenderText rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Style.Font = Document.Tags!DateHeadingsFont.Value\r\n" + "Dim rt As RenderText = RenderObject\r\n" + "Dim startDate As Date = RenderObject.Original.Parent.Parent.DataBinding.Fields!Date.Value\r\n" + "Dim endDate As Date = startDate.AddDays(34)\r\n" + "Dim txt As String = startDate.ToString(\"MMMM\", Document.Tags!CalendarInfo.Value.CultureInfo)\r\n" + "If startDate.Year <> endDate.Year Then\r\n" + " txt = txt & \" \" & startDate.ToString(\"yyy\", Document.Tags!CalendarInfo.Value.CultureInfo)\r\n" + "End If\r\n" + "txt = txt & \" - \" & endDate.ToString(\"MMMM yyy\", Document.Tags!CalendarInfo.Value.CultureInfo)\r\n" + "rt.Text = txt\r\n" + "Document.Tags!WeekTabs.Value = New List(of Date)\r\n" + "Document.Tags!WeekTabs.Value.Add(startDate)\r\n" + "Document.Tags!WeekTabs.Value.Add(startDate.AddDays(7))\r\n" + "Document.Tags!WeekTabs.Value.Add(startDate.AddDays(14))\r\n" + "Document.Tags!WeekTabs.Value.Add(startDate.AddDays(21))\r\n" + "Document.Tags!WeekTabs.Value.Add(startDate.AddDays(28))\r\n" + "Document.Tags!MonthCalendars.Value = New List(of Date)\r\n" + "startDate = New Date(startDate.Year, startDate.Month, 1)\r\n" + "While startDate <= endDate\r\n" + " Document.Tags!MonthCalendars.Value.Add(startDate)\r\n" + " startDate = startDate.AddMonths(1)\r\n" + "End While"; rt.Style.TextAlignVert = AlignVertEnum.Center; rt.Style.Spacing.Left = "2mm"; rt.Height = "100%"; rt.Width = "parent.Width - 102mm"; raMonthHeader.Children.Add(rt); RenderArea monthCalendar = new RenderArea(); monthCalendar.DataBinding.DataSource = new Expression("Document.Tags!MonthCalendars.Value"); monthCalendar.Stacking = StackingRulesEnum.InlineLeftToRight; monthCalendar.Style.Spacing.Left = "1mm"; monthCalendar.Style.Spacing.Right = "1mm"; monthCalendar.Style.Spacing.Top = "0.5mm"; monthCalendar.Width = "34mm"; rt = new RenderText("[CDate(Fields!Date.Value).ToString(\"MMMM yyy\", Document.Tags!CalendarInfo.Value.CultureInfo)]"); rt.FormatDataBindingInstanceScript = "Dim startDate As Date = RenderObject.Original.Parent.DataBinding.Fields!Date.Value\r\n" + "Dim endDate As Date = startDate.AddMonths(1).AddDays(-1)\r\n" + "While startDate.DayOfWeek <> Document.Tags!CalendarInfo.Value.WeekStart \r\n" + " startDate = startDate.AddDays(-1)\r\n" + "End While\r\n" + "Document.Tags!WeekNumber.Value = New List(of Date)\r\n" + "While startDate <= endDate\r\n" + " Document.Tags!WeekNumber.Value.Add(startDate)\r\n" + " startDate = startDate.AddDays(7)\r\n" + "End While"; rt.Style.TextAlignHorz = AlignHorzEnum.Center; rt.Style.Font = new Font("Segoe UI", 8); rt.Width = "100%"; monthCalendar.Children.Add(rt); rt = new RenderText(" "); rt.Style.Font = new Font("Arial", 7f); rt.Style.WordWrap = false; rt.Width = "12.5%"; monthCalendar.Children.Add(rt); rt = new RenderText("[Document.Tags!CalendarInfo.Value.CultureInfo.DateTimeFormat.GetShortestDayName(CDate(Fields!Date.Value).DayOfWeek)]"); rt.DataBinding.DataSource = new Expression("New DateAppointmentsCollection(Document.Tags!WeekNumber.Value(0), Document.Tags!WeekNumber.Value(0).AddDays(6), Document.Tags!Appointments.Value, True)"); rt.DataBinding.Sorting.Expressions.Add("Fields!Date.Value"); rt.Style.Borders.Bottom = LineDef.Default; rt.Style.Font = new Font("Arial", 7f); rt.Style.TextAlignHorz = AlignHorzEnum.Center; rt.Style.WordWrap = false; rt.Width = "12.5%"; monthCalendar.Children.Add(rt); RenderArea raWeek = new RenderArea(); raWeek.DataBinding.DataSource = new Expression("Document.Tags!WeekNumber.Value"); raWeek.Style.Font = new Font("Arial", 7f); raWeek.Width = "100%"; raWeek.Stacking = StackingRulesEnum.InlineLeftToRight; rt = new RenderText("[Document.Tags!CalendarInfo.Value.CultureInfo.Calendar.GetWeekOfYear(CDate(Fields!Date.Value), System.Globalization.CalendarWeekRule.FirstDay, Document.Tags!CalendarInfo.Value.WeekStart)]"); rt.Style.Borders.Right = LineDef.Default; rt.Style.TextAlignHorz = AlignHorzEnum.Right; rt.Style.WordWrap = false; rt.Width = "12.5%"; raWeek.Children.Add(rt); rt = new RenderText("[CDate(Fields!Date.Value).ToString(\"%d\", Document.Tags!CalendarInfo.Value.CultureInfo)]"); rt.DataBinding.DataSource = new Expression("New DateAppointmentsCollection(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value).AddDays(6), Document.Tags!Appointments.Value, True)"); rt.DataBinding.Sorting.Expressions.Add("Fields!Date.Value"); rt.FormatDataBindingInstanceScript = "If RenderObject.Original.DataBinding.Fields!Date.Value.Month <> RenderObject.Original.Parent.Parent.DataBinding.Fields!Date.Value.Month Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Hidden\r\n" + "Else If RenderObject.Original.DataBinding.Fields!HasAppointments.Value Then\r\n" + " RenderObject.Style.FontBold = true\r\n" + "End If"; rt.Style.TextAlignHorz = AlignHorzEnum.Right; rt.Width = "12.5%"; raWeek.Children.Add(rt); monthCalendar.Children.Add(raWeek); raMonthHeader.Children.Add(monthCalendar); raPage.Children.Add(raMonthHeader); #endregion #region ** month // month RenderArea raMonth = new RenderArea(); raMonth.FormatDataBindingInstanceScript = "If Not (Document.Tags!IncludeTasks.Value Or Document.Tags!IncludeBlankNotes.Value Or Document.Tags!IncludeLinedNotes.Value) Then\r\n" + " RenderObject.Width = \"100%\" \r\n" + "End If"; raMonth.Style.Spacing.Top = "0.5mm"; raMonth.Style.Borders.Top = LineDef.Default; raMonth.Style.Borders.Left = LineDef.Default; raMonth.Style.Borders.Bottom = LineDef.Default; raMonth.Width = "80%"; raMonth.Height = "parent.Height - 28mm"; raMonth.Stacking = StackingRulesEnum.InlineLeftToRight; rt = new RenderText(" "); rt.Style.WordWrap = false; rt.Height = "4%"; rt.Style.TextAngle = 90; rt.Width = "2.7%"; raMonth.Children.Add(rt); rt = new RenderText("[CDate(Fields!Date.Value).ToString(\"dddd\", Document.Tags!CalendarInfo.Value.CultureInfo)]"); rt.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value).AddDays(6))"); rt.DataBinding.Sorting.Expressions.Add("Fields!Date.Value"); rt.FormatDataBindingInstanceScript = "RenderObject.Width = Document.Tags!DayWidth.Value"; rt.Style.Borders.Bottom = LineDef.Default; rt.Style.Borders.Right = LineDef.Default; rt.Style.TextAlignHorz = AlignHorzEnum.Center; rt.Style.WordWrap = false; rt.Height = "4%"; raMonth.Children.Add(rt); RenderArea raWeekTab = new RenderArea(); raWeekTab.DataBinding.DataSource = new Expression("Document.Tags!WeekTabs.Value"); raWeekTab.Height = "19.2%"; raWeekTab.Width = "100%"; raWeekTab.Stacking = StackingRulesEnum.InlineLeftToRight; rt = new RenderText(); rt.FormatDataBindingInstanceScript = "Dim txt As RenderText = RenderObject\r\n" + "Dim start As Date = RenderObject.Parent.Original.DataBinding.Fields!Date.Value\r\n" + "Dim endT As Date = start.AddDays(6)\r\n" + "If start.Month = endT.Month Then \r\n" + " txt.Text = start.ToString(\"%d\", Document.Tags!CalendarInfo.Value.CultureInfo) & \" - \" & endT.ToString(\"d.MM\", Document.Tags!CalendarInfo.Value.CultureInfo)\r\n" + "Else\r\n" + " txt.Text = start.ToString(\"d.MM\", Document.Tags!CalendarInfo.Value.CultureInfo) & \" - \" & endT.ToString(\"d.MM\", Document.Tags!CalendarInfo.Value.CultureInfo)\r\n" + "End If"; rt.Style.Borders.Right = LineDef.Default; rt.Style.FontBold = true; rt.Style.TextAngle = 90; rt.Style.TextAlignHorz = AlignHorzEnum.Center; rt.Style.WordWrap = false; rt.Height = "100%"; rt.Width = "2.7%"; raWeekTab.Children.Add(rt); // RenderArea representing the single day RenderArea raDay = new RenderArea(); raDay.DataBinding.DataSource = new Expression("Document.Tags!DateAppointments.Value(Parent.Fields!Date.Value, CDate(Parent.Fields!Date.Value).AddDays(6))"); raDay.DataBinding.Sorting.Expressions.Add("Fields!Date.Value"); raDay.Style.Borders.Right = LineDef.Default; raDay.Style.Borders.Bottom = LineDef.Default; raDay.FormatDataBindingInstanceScript = "RenderObject.Width = Document.Tags!DayWidth.Value"; raDay.Height = "100%"; // day header rt = new RenderText("[IIF(Fields!Date.Value.Day = 1 Or CDate(Fields!Date.Value) = CDate(Document.Tags!WeekTabs.Value(0).Date), String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:m}\", Fields!Date.Value) ,Fields!Date.Value.Day)]"); rt.Style.Borders.Bottom = LineDef.Default; rt.Style.Padding.Left = "1mm"; rt.Style.FontBold = true; rt.Style.BackColor = Colors.White; rt.Style.TextAlignHorz = AlignHorzEnum.Left; rt.Style.WordWrap = false; raDay.Children.Add(rt); RenderText status = new RenderText(" "); status.FormatDataBindingInstanceScript = "If IsNothing(RenderObject.Original.DataBinding.Parent.Fields!BusyStatus.Value) Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Collapse\r\n" + "Else \r\n" + " RenderObject.Style.Brush = RenderObject.Original.DataBinding.Parent.Fields!BusyStatus.Value.Brush.Brush \r\n" + "End If"; status.Width = "100%"; status.Height = "1.5mm"; raDay.Children.Add(status); RenderArea appointments = new RenderArea(); appointments.Height = "parent.Height - Y - 2.5mm"; // RenderArea representing the single appointment RenderArea raApp = new RenderArea(); raApp.Style.Spacing.All = "0.2mm"; raApp.FormatDataBindingInstanceScript = "If RenderObject.Original.DataBinding.Fields!AllDayEvent.Value Then\r\n" + " RenderObject.Style.Borders.All = LineDef.Default\r\n" + "End If\r\n" + "If Not IsNothing(RenderObject.Original.DataBinding.Fields!Label.Value) Then\r\n" + " RenderObject.Style.Brush = CType(RenderObject.Original.DataBinding.Fields!Label.Value, Label).Brush.Brush\r\n" + "End If"; raApp.Stacking = StackingRulesEnum.InlineLeftToRight; raApp.Height = "14pt"; // Set the text's data source to the data source of the containing RenderArea - this indicates that the render object is bound to the current group in the specified object: raApp.DataBinding.DataSource = new Expression("Parent.Fields!Appointments.Value"); raApp.DataBinding.Sorting.Expressions.Add("Fields!Start.Value"); raApp.DataBinding.Sorting.Expressions.Add("Fields!Subject.Value"); rt = new RenderText(); rt.Style.WordWrap = false; rt.Text = "[IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, \"> \", String.Empty) & " + "IIf(Fields!AllDayEvent.Value, \"\", String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:t}\", " + "IIf(DateDiff(DateInterval.Second, CDate(DataBinding.Parent.Fields!Date.Value), CDate(Fields!Start.Value)) < 0, DataBinding.Parent.Fields!Date.Value, Fields!Start.Value)))] [Fields!Subject.Value]"; rt.Width = "Auto"; raApp.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Original.DataBinding.Parent.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[\" (\" & Fields!Location.Value & \")\"]"; rt.Style.WordWrap = false; rt.Width = "Auto"; raApp.Children.Add(rt); appointments.Children.Add(raApp); raDay.Children.Add(appointments); RenderArea overflowArea = new RenderArea(); overflowArea.Name = "overflow"; RenderText arrow = new RenderText(new string((char)0x36, 1), new Font("Webdings", 10)); arrow.Style.Padding.Top = "-1.5mm"; arrow.X = "parent.Width - 4mm"; overflowArea.Children.Add(arrow); overflowArea.ZOrder = 100; overflowArea.Height = "2.5mm"; overflowArea.FragmentResolvedScript = "if (C1PrintDocument.FormatVersion.AssemblyVersion.MinorRevision <> 100) Then\r\n" + " Dim fragment As RenderFragment = RenderFragment.Parent.Children(2)\r\n" + " If (fragment.HasChildren) Then\r\n" + " If (RenderFragment.Parent.BoundsOnPage.Contains(fragment.Children(fragment.Children.Count - 1).BoundsOnPage)) Then\r\n" + " RenderFragment.RenderObject.Visibility = VisibilityEnum.Hidden\r\n" + " else\r\n" + " RenderFragment.RenderObject.Visibility = VisibilityEnum.Visible\r\n" + " end if\r\n" + " else\r\n" + " RenderFragment.RenderObject.Visibility = VisibilityEnum.Hidden\r\n" + " end if\r\n" + "else\r\n" + " RenderFragment.RenderObject.Visibility = VisibilityEnum.Hidden\r\n" + "end if"; raDay.Children.Add(overflowArea); raWeekTab.Children.Add(raDay); raMonth.Children.Add(raWeekTab); raPage.Children.Add(raMonth); #endregion #region ** tasks // tasks RenderArea include = new RenderArea(); include.FormatDataBindingInstanceScript = "If Document.Tags!IncludeTasks.Value Or Document.Tags!IncludeBlankNotes.Value Or Document.Tags!IncludeLinedNotes.Value Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Visible \r\n" + "Else\r\n" + " RenderObject.Visibility = VisibilityEnum.Collapse \r\n" + "End If"; include.Width = "20%"; include.Height = "parent.Height - 28mm"; RenderArea raTasks = new RenderArea(); raTasks.FormatDataBindingInstanceScript = "If Not Document.Tags!IncludeTasks.Value Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Collapse \r\n" + "End If\r\n" + "RenderObject.Height = Document.Tags!TaskHeight.Value"; raTasks.Style.Borders.All = LineDef.Default; raTasks.Style.Spacing.Top = "0.5mm"; raTasks.Style.Spacing.Left = "0.5mm"; raTasks.Width = "100%"; rt = new RenderText(); rt.Text = "Tasks"; rt.Style.Padding.Left = "2mm"; rt.Style.Borders.Bottom = LineDef.Default; raTasks.Children.Add(rt); include.Children.Add(raTasks); RenderArea raNotes = new RenderArea(); raNotes.FormatDataBindingInstanceScript = "If Not Document.Tags!IncludeBlankNotes.Value Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Collapse \r\n" + "End If\r\n" + "RenderObject.Height = Document.Tags!TaskHeight.Value"; raNotes.Style.Borders.All = LineDef.Default; raNotes.Style.Spacing.Top = "0.5mm"; raNotes.Style.Spacing.Left = "0.5mm"; raNotes.Width = "100%"; rt = new RenderText(); rt.Text = "Notes"; rt.Style.Padding.Left = "2mm"; rt.Style.Borders.Bottom = LineDef.Default; raNotes.Children.Add(rt); include.Children.Add(raNotes); raNotes = new RenderArea(); raNotes.FormatDataBindingInstanceScript = "If Not Document.Tags!IncludeLinedNotes.Value Then\r\n" + " RenderObject.Visibility = VisibilityEnum.Collapse \r\n" + "End If\r\n" + "RenderObject.Height = Document.Tags!TaskHeight.Value"; raNotes.Style.Borders.All = LineDef.Default; raNotes.Style.Spacing.Top = "0.5mm"; raNotes.Style.Spacing.Left = "0.5mm"; raNotes.Width = "100%"; rt = new RenderText(); rt.Text = "Notes"; rt.Style.Padding.Left = "2mm"; rt.Style.Borders.Bottom = LineDef.Default; raNotes.Children.Add(rt); RenderTable lines = new RenderTable(); lines.Rows.Insert(0, 1); lines.Rows[0].Height = "0.5cm"; TableVectorGroup gr = lines.RowGroups[0, 1]; gr.Header = TableHeaderEnum.None; List<int> lst = new List<int>(60); for (int i = 0; i < 60; i++) { lst.Add(i); } gr.DataBinding.DataSource = lst; lines.Style.GridLines.Horz = LineDef.Default; lines.RowSizingMode = TableSizingModeEnum.Fixed; raNotes.Children.Add(lines); include.Children.Add(raNotes); raPage.Children.Add(include); #endregion doc.Body.Children.Add(raPage); AddCommonTags(doc); Tag newTag = new Tag("Appointments", null, typeof(IList<Appointment>)); newTag.ShowInDialog = false; newTag.SerializeValue = false; doc.Tags.Add(newTag); newTag = new Tag("WeekTabs", null, typeof(List<DateTime>)); newTag.ShowInDialog = false; newTag.SerializeValue = false; doc.Tags.Add(newTag); newTag = new Tag("WeekNumber", null, typeof(List<DateTime>)); newTag.ShowInDialog = false; newTag.SerializeValue = false; doc.Tags.Add(newTag); newTag = new Tag("MonthCalendars", null, typeof(List<DateTime>)); newTag.ShowInDialog = false; newTag.SerializeValue = false; doc.Tags.Add(newTag); newTag = new Tag("StartDate", DateTime.Today, typeof(DateTime)); newTag.InputParams = new TagDateTimeInputParams(); doc.Tags.Add(newTag); newTag = new Tag("EndDate", DateTime.Today.AddDays(1), typeof(DateTime)); newTag.InputParams = new TagDateTimeInputParams(); doc.Tags.Add(newTag); newTag = new Tag("HidePrivateAppointments", false, typeof(bool)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("TaskHeight", new Unit("33.3%"), typeof(Unit)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("DayWidth", new Unit("13.9%"), typeof(Unit)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("IncludeTasks", false, typeof(bool)); newTag.ShowInDialog = true; newTag.InputParams = new TagBoolInputParams(); newTag.Description = "Include Tasks"; doc.Tags.Add(newTag); newTag = new Tag("IncludeBlankNotes", false, typeof(bool)); newTag.ShowInDialog = true; newTag.InputParams = new TagBoolInputParams(); newTag.Description = "Include Notes (blank)"; doc.Tags.Add(newTag); newTag = new Tag("IncludeLinedNotes", false, typeof(bool)); newTag.ShowInDialog = true; newTag.InputParams = new TagBoolInputParams(); newTag.Description = "Include Notes (lined)"; doc.Tags.Add(newTag); newTag = new Tag("WorkDaysOnly", false, typeof(bool)); newTag.ShowInDialog = true; newTag.InputParams = new TagBoolInputParams(); newTag.Description = "Only Print Workdays"; doc.Tags.Add(newTag); }
/// <summary> /// Fills specified control with a Memo style. /// </summary> /// <param name="doc"></param> public static void MakeMemo(C1PrintDocument doc) { doc.Clear(); doc.DocumentInfo.Title = "Memo style"; doc.DocumentInfo.Subject = "Memo"; AddNamespaces(doc); AddHeadersFooters(doc); doc.Tags["AppointmentsFont"].Value = new Font("Arial", 10); // add string tags (localizable) Tag newTag = new Tag("Subject", "Subject:", typeof(string)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("Location", "Location:", typeof(string)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("Start", "Start:", typeof(string)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("End", "End:", typeof(string)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("ShowTimeAs", "Show Time As:", typeof(string)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("Recurrence", "Recurrence:", typeof(string)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("None", "none", typeof(string)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("Categories", "Categories:", typeof(string)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("Resources", "Resources:", typeof(string)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("Contacts", "Contacts:", typeof(string)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); newTag = new Tag("Importance", "Importance:", typeof(string)); newTag.ShowInDialog = false; doc.Tags.Add(newTag); RenderArea ra = new RenderArea(); ra.Width = "100%"; ra.BreakBefore = BreakEnum.Page; ra.DataBinding.DataSource = new Expression("Document.Tags!Appointments.Value"); ra.DataBinding.Sorting.Expressions.Add("Fields!Start.Value"); ra.DataBinding.Sorting.Expressions.Add("Fields!Subject.Value"); ra.Style.Borders.Top = LineDef.DefaultBold; ra.Stacking = StackingRulesEnum.InlineLeftToRight; ra.Style.Padding.Top = "1mm"; ra.Style.Spacing.All = "1mm"; RenderText rt = new RenderText(); rt.FormatDataBindingInstanceScript = //VisibilityEnum "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Parent.Original.DataBinding.Fields!Subject.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[Document.Tags!Subject.Value]"; rt.Width = "25%"; rt.Style.FontBold = true; ra.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Parent.Original.DataBinding.Fields!Subject.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[Fields!Subject.Value]"; rt.Width = "75%"; ra.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Parent.Original.DataBinding.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[Document.Tags!Location.Value]"; rt.Width = "25%"; rt.Style.FontBold = true; ra.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf(Not String.IsNullOrEmpty(RenderObject.Parent.Original.DataBinding.Fields!Location.Value), VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[Fields!Location.Value]"; rt.Width = "75%"; ra.Children.Add(rt); rt = new RenderText(); rt.Text = "[Document.Tags!Start.Value]"; rt.Width = "25%"; rt.Style.Padding.Top = "2mm"; rt.Style.FontBold = true; ra.Children.Add(rt); rt = new RenderText(); rt.Text = "[String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:ddd} {1:g}\", Fields!Start.Value, Fields!Start.Value)]"; rt.Width = "75%"; rt.Style.Padding.Top = "2mm"; ra.Children.Add(rt); rt = new RenderText(); rt.Text = "[Document.Tags!End.Value]"; rt.Width = "25%"; rt.Style.FontBold = true; ra.Children.Add(rt); rt = new RenderText(); rt.Text = "[String.Format(Document.Tags!CalendarInfo.Value.CultureInfo, \"{0:ddd} {1:g}\", Fields!End.Value, Fields!End.Value)]"; rt.Width = "75%"; ra.Children.Add(rt); rt = new RenderText(); rt.Text = "[Document.Tags!ShowTimeAs.Value]"; rt.Width = "25%"; rt.Style.FontBold = true; ra.Children.Add(rt); rt = new RenderText(); rt.Text = "[Fields!BusyStatus.Value.Text]"; rt.Width = "75%"; ra.Children.Add(rt); rt = new RenderText(); rt.Text = "[Document.Tags!Recurrence.Value]"; rt.Width = "25%"; rt.Style.Padding.Top = "2mm"; rt.Style.FontBold = true; ra.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "Dim index as Integer = RenderObject.Parent.Original.DataBinding.RowNumber - 1 \r\n" + "Dim app As Appointment = Document.Tags!Appointments.Value(index)\r\n" + "Dim text As RenderText = RenderObject\r\n" + "If app.RecurrenceState <> RecurrenceStateEnum.NotRecurring Then\r\n" + " text.Text = app.GetRecurrencePattern().Description\r\n" + "Else\r\n" + " text.Text = Document.Tags!None.Value\r\n" + "End If"; rt.Style.Padding.Top = "2mm"; rt.Width = "75%"; ra.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf((Not (RenderObject.Parent.Original.DataBinding.Fields!Links.Value Is Nothing)) And RenderObject.Parent.Original.DataBinding.Fields!Links.Value.Count > 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[Document.Tags!Contacts.Value]"; rt.Style.Padding.Top = "2mm"; rt.Width = "25%"; rt.Style.FontBold = true; ra.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf((Not (RenderObject.Parent.Original.DataBinding.Fields!Links.Value Is Nothing)) And RenderObject.Parent.Original.DataBinding.Fields!Links.Value.Count > 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[Fields!Links.Value.ToString()]"; rt.Style.Padding.Top = "2mm"; rt.Width = "75%"; ra.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf((Not (RenderObject.Parent.Original.DataBinding.Fields!Categories.Value Is Nothing)) And RenderObject.Parent.Original.DataBinding.Fields!Categories.Value.Count > 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[Document.Tags!Categories.Value]"; rt.Style.Padding.Top = "2mm"; rt.Width = "25%"; rt.Style.FontBold = true; ra.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf((Not (RenderObject.Parent.Original.DataBinding.Fields!Categories.Value Is Nothing)) And RenderObject.Parent.Original.DataBinding.Fields!Categories.Value.Count > 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[Fields!Categories.Value.ToString()]"; rt.Style.Padding.Top = "2mm"; rt.Width = "75%"; ra.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf((Not (RenderObject.Parent.Original.DataBinding.Fields!Resources.Value Is Nothing)) And RenderObject.Parent.Original.DataBinding.Fields!Resources.Value.Count > 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[Document.Tags!Resources.Value]"; rt.Width = "25%"; rt.Style.Padding.Top = "2mm"; rt.Style.FontBold = true; ra.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf((Not (RenderObject.Parent.Original.DataBinding.Fields!Resources.Value Is Nothing)) And RenderObject.Parent.Original.DataBinding.Fields!Resources.Value.Count > 0, VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[Fields!Resources.Value.ToString()]"; rt.Style.Padding.Top = "2mm"; rt.Width = "75%"; ra.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf(Not (RenderObject.Parent.Original.DataBinding.Fields!Importance.Value = 1), VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Text = "[Document.Tags!Importance.Value]"; rt.Style.Padding.Top = "2mm"; rt.Width = "25%"; rt.Style.FontBold = true; ra.Children.Add(rt); rt = new RenderText(); rt.FormatDataBindingInstanceScript = "RenderObject.Visibility = IIf(Not (RenderObject.Parent.Original.DataBinding.Fields!Importance.Value = 1), VisibilityEnum.Visible, VisibilityEnum.Collapse)"; rt.Style.Padding.Top = "2mm"; rt.Text = "[Fields!Importance.Value.ToString()]"; rt.Width = "75%"; ra.Children.Add(rt); rt = new RenderText(); rt.Text = "[Fields!Body.Value.ToString()]"; rt.Style.Padding.Top = "3mm"; rt.Style.Padding.Right = "2mm"; rt.Width = "100%"; ra.Children.Add(rt); doc.Body.Children.Add(ra); AddCommonTags(doc); newTag = new Tag("Appointments", null, typeof(IList<Appointment>)); newTag.ShowInDialog = false; newTag.SerializeValue = false; doc.Tags.Add(newTag); }