Пример #1
0
        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);
        }
Пример #2
0
        public string Convert(ITextConvertor convertor, string rawText)
        {
            ParagraphReader reader    = new ParagraphReader();
            ParagraphText   paragraph = reader.ReadParagraph(rawText);

            return(convertor.Convert(paragraph));
        }
Пример #3
0
        public string Convert(ParagraphText paragraph)
        {
            if (paragraph == null)
            {
                return string.Empty;
            }
            StringBuilder sb = new StringBuilder();

            int maxColumns = paragraph.MaxWordsInLine;

            sb.Append("Lines");
            //Add CSV Header till max columns
            for (int i = 1; i <= maxColumns; i++)
            {
                sb.Append(",Word" + i.ToString());
            }

            //Add CSV data to rows
            int lineCount = 0;
            foreach (Sentence line in paragraph.Lines)
            {
                lineCount++;
                sb.AppendLine("<br/>");
                sb.Append("Line" + lineCount.ToString());
                foreach (string word in line.Words)
                {
                    sb.Append("," + word);
                }
            }
            return sb.ToString();
        }
Пример #4
0
        async void CreateParagraphTextAsync(VGCore.Layer layer, ParagraphText paragraphText, CMYKAssign cmykAssign, CancellationTokenSource cts)
        {
            VGCore.Shape     shape   = null;
            VGCore.Outline   outline = null;
            VGCore.Fill      fill    = null;
            VGCore.Color     color   = null;
            VGCore.Text      text    = null;
            VGCore.TextRange story   = null;

            try
            {
                shape = layer.CreateParagraphText(
                    paragraphText.Left,
                    paragraphText.Top,
                    paragraphText.Right,
                    paragraphText.Bottom,
                    paragraphText.Text
                    );
                fill  = shape.Fill;
                color = fill.UniformColor;
                color.CMYKAssign(
                    cmykAssign.C,
                    cmykAssign.M,
                    cmykAssign.Y,
                    cmykAssign.K
                    );
                text            = shape.Text;
                story           = text.Story;
                story.Style     = VGCore.cdrFontStyle.cdrBoldFontStyle;
                story.Size      = paragraphText.Size;
                story.Alignment = (VGCore.cdrAlignment)paragraphText.Alignment;//VGCore.cdrAlignment.cdrLeftAlignment;
                outline         = shape.Outline;
                outline.SetNoOutline();
                shape.Name = paragraphText.Name;
            }
            catch (OperationCanceledException)
            {
                await mainWindow.OutputText.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate()
                {
                    mainWindow.OutputText.Text += "Операция была отменена пользователем!\n";
                }));
            }
            catch (Exception ex)
            {
                await mainWindow.OutputText.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate()
                {
                    mainWindow.OutputText.Text += $"Work is failed.\n{ex.Message}\n";
                }));
            }
            finally
            {
                Marshal.ReleaseComObject(story);
                Marshal.ReleaseComObject(text);
                Marshal.ReleaseComObject(color);
                Marshal.ReleaseComObject(fill);
                Marshal.ReleaseComObject(outline);
                Marshal.ReleaseComObject(shape);
            }
        }
Пример #5
0
        private RenderObject CreateAggregate1(string caption, string aggregateName, Style captionStyle, Style aggregateStyle)
        {
            RenderParagraph result = new RenderParagraph();
            ParagraphText   pt     = new ParagraphText(caption + "\r");

            pt.Style.Parents = captionStyle;
            result.Content.Add(pt);
            pt = new ParagraphText("[Aggregates!" + aggregateName + ".Value]");
            pt.Style.Parents = aggregateStyle;
            result.Content.Add(pt);

            return(result);
        }
Пример #6
0
        public string Convert(ParagraphText paragraph)
        {
            var stringwriter = new System.IO.StringWriter();
            var serializer   = new XmlSerializer(paragraph.GetType());

            serializer.Serialize(stringwriter, paragraph);
            string convertedText = stringwriter.ToString();

            // replacing string collection as this will be serilized with name string and we want word as per req.
            convertedText = convertedText.Replace("<string>", "<Word>");
            convertedText = convertedText.Replace("<Words>", string.Empty);
            convertedText = convertedText.Replace("</Words>", string.Empty);
            return(convertedText.Replace("</string>", "</Word>"));
        }
Пример #7
0
        /// <summary>
        /// Creates a RenderParagraph containing a caption (label) and an expression
        /// referencing an aggregate with the specified name, delimited by a newline.
        /// The aggregate must be added to the document's DataSchema.Aggregates separately.
        /// </summary>
        /// <param name="caption">The caption text</param>
        /// <param name="aggregateName">The aggregate name.</param>
        /// <param name="captionStyle">Style for the caption text.</param>
        /// <param name="aggregateStyle">Style for the aggregate value.</param>
        /// <param name="currency">If true, value is formatted as currency.</param>
        /// <returns>The created RenderParagraph object.</returns>
        private RenderObject CreateAggregate1(string caption, string aggregateName,
                                              C1.C1Preview.Style captionStyle, C1.C1Preview.Style aggregateStyle, bool currency)
        {
            RenderParagraph result = new RenderParagraph();
            ParagraphText   pt     = new ParagraphText(caption + "\r");

            pt.Style.Parents = captionStyle;
            result.Content.Add(pt);
            if (currency)
            {
                pt = new ParagraphText("[string.Format(\"{0:C}\",Aggregates!" + aggregateName + ".Value)]");
            }
            else
            {
                pt = new ParagraphText("[Aggregates!" + aggregateName + ".Value]");
            }
            pt.Style.Parents = aggregateStyle;
            result.Content.Add(pt);
            return(result);
        }
Пример #8
0
        public ParagraphText ReadParagraph(string rawtext)
        {
            ParagraphText paragraph = new ParagraphText();

            string[] lines = rawtext.Split('.', ',');
            foreach (string line in lines)
            {
                Sentence singleLine    = new Sentence();
                string[] wordsFromLine = line.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); // filterout blank words

                //perfrom sorting
                string[] words = wordsFromLine.OrderBy(x => x).ToArray();
                foreach (string word in words)
                {
                    singleLine.Words.Add(word);
                }
                if (singleLine.Words.Count > 0)
                {
                    paragraph.Lines.Add(singleLine);
                }
            }
            return(paragraph);
        }
Пример #9
0
        async void StartCorelDRAWAsync(List <DataModel> datas, CancellationTokenSource cts)
        {
            CorelDRAW.Application corelApp = null;
            VGCore.Document       document = null;
            VGCore.Page           page     = null;
            VGCore.Layer          layer    = null;
            VGCore.Shape          shape    = null;
            VGCore.Shape          siteLogo = null;
            //VGCore.Rect rect = null;
            VGCore.ImportFilter importFilter = null;
            VGCore.DataItem     image        = null;
            const string        LOGO         = "www.vash-sadik.com";
            //RectanglePosition rectanglePosition;
            RGBAssign     rgbAssign;
            ArtisticText  artisticText;
            CMYKAssign    cmykAssign;
            ParagraphText paragraphText;
            Stopwatch     sw    = new Stopwatch();
            int           count = 0;
            string        fullPath;

            string[]         name;
            string           fullName;
            float            fontSize;
            List <DataModel> data;

            try
            {
                data = datas;
                OpenFile("CorelDRAW files(*.cdr)|*.cdr");
                await mainWindow.ProgressBar.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(delegate()
                {
                    mainWindow.ProgressBar.Value = 0;
                }));

                await mainWindow.OutputText.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate()
                {
                    mainWindow.OutputText.Text += "Подождите, идёт обработка файла CorelDRAW.\n";
                }));

                corelApp = new CorelDRAW.Application
                {
                    Visible       = false,
                    Optimization  = true,
                    EventsEnabled = false
                };

                document = corelApp.OpenDocument(FileName, 1);
                document.BeginCommandGroup("Fast");
                document.SaveSettings();
                document.PreserveSelection = false;

                sw.Start();

                document.Unit = VGCore.cdrUnit.cdrMillimeter;

                foreach (DataModel item in data)
                {
                    if (item.IsUp)
                    {
                        page  = document.InsertPagesEx(1, false, document.ActivePage.Index, 297, 210);
                        layer = page.Layers[2];

                        //rect = new VGCore.Rect
                        //{
                        //    Width = 297,
                        //    Height = 100
                        //};
                        //rgbAssign = new RGBAssign(255, 255, 255);
                        //rectanglePosition = new RectanglePosition(0, 210);
                        //CreateRectangleRectAsync(rect, layer, rectanglePosition, rgbAssign, cts);

                        //Add background image
                        fullPath = Path.GetDirectoryName(FileName) + @"\fon\" + item.BackgroundNumber + ".jpg";
                        if (item.BackgroundNumber != "0")
                        {
                            importFilter = layer.ImportEx(fullPath, VGCore.cdrFilter.cdrJPEG);
                            importFilter.Finish();

                            shape       = page.Shapes[item.BackgroundNumber + ".jpg"];
                            image       = shape.ObjectData["Name"];
                            image.Value = item.BackgroundNumber;

                            shape.SizeWidth  = 297;
                            shape.SizeHeight = 100;
                            shape.PositionX  = 0;
                            shape.PositionY  = 210;
                        }

                        name = item.ChildName.Split(' ');
                        if (name.Length > 1)
                        {
                            fullName = name[0] + "\r\n" + name[1];
                            fontSize = 102.5f;
                        }
                        else
                        {
                            fullName = name[0];
                            fontSize = 205f;
                        }

                        rgbAssign    = new RGBAssign(255, 72, 41);
                        artisticText = new ArtisticText(31.369, 138.2776, fullName, "Kabarett Simple", fontSize, "Name1");
                        CreateArtisticTextAsync(layer, artisticText, rgbAssign, cts);
                        shape = page.Shapes["Name1"];
                        //shape.SizeHeight = 61.761;
                        shape.CenterY = 160;

                        cmykAssign    = new CMYKAssign(0, 0, 0, 100);
                        paragraphText = new ParagraphText(13.555, 105, 29.112, 110, item.ImageNumber, "Arial", 12, "ImageNumber1");
                        CreateParagraphTextAsync(layer, paragraphText, cmykAssign, cts);

                        cmykAssign    = new CMYKAssign(100, 0, 0, 0);
                        paragraphText = new ParagraphText(29.669, 105, 45.227, 110, item.DoorWidth.ToString(), "Arial", 12, "DoorWidth1");
                        CreateParagraphTextAsync(layer, paragraphText, cmykAssign, cts);

                        cmykAssign    = new CMYKAssign(100, 0, 100, 0);
                        paragraphText = new ParagraphText(45.783, 105, 72.548, 110, item.Pocket, "Arial", 12, "Pocket1");
                        CreateParagraphTextAsync(layer, paragraphText, cmykAssign, cts);

                        cmykAssign    = new CMYKAssign(0, 88, 97, 0);
                        paragraphText = new ParagraphText(73.104, 105, 149.288, 110, item.Customer, "Arial", 12, "Customer1");
                        CreateParagraphTextAsync(layer, paragraphText, cmykAssign, cts);

                        fullPath = Path.GetDirectoryName(FileName) + @"\img\" + item.ImageNumber + ".png";

                        rgbAssign    = new RGBAssign(255, 41, 41);
                        artisticText = new ArtisticText(193.745, 128.413, LOGO, "Arial", 16.591f, "Logo1", 63.174);
                        CreateArtisticTextAsync(layer, artisticText, rgbAssign, cts);
                        siteLogo = page.Shapes["Logo1"];
                        siteLogo.Rotate(90);
                        siteLogo.SizeHeight = 63.174;
                        siteLogo.SizeWidth  = 4.255;

                        if (item.DoorWidth < 23)
                        {
                            siteLogo.CenterX = 195.872;
                        }
                        else if (item.DoorWidth >= 23 && item.DoorWidth < 25)
                        {
                            siteLogo.CenterX = 215.872;
                        }
                        else if (item.DoorWidth >= 25 && item.DoorWidth < 27)
                        {
                            siteLogo.CenterX = 235.872;
                        }
                        else if (item.DoorWidth >= 27 && item.DoorWidth < 29)
                        {
                            siteLogo.CenterX = 255.872;
                        }
                        else if (item.DoorWidth >= 29)
                        {
                            siteLogo.CenterX = 275.872;
                        }
                        siteLogo.CenterY = 160;

                        if (item.ImageNumber != "0")
                        {
                            importFilter = layer.ImportEx(fullPath, VGCore.cdrFilter.cdrPNG);
                            importFilter.Finish();

                            shape       = page.Shapes[item.ImageNumber + ".png"];
                            image       = shape.ObjectData["Name"];
                            image.Value = item.ImageNumber;

                            shape.CenterX = siteLogo.CenterX - siteLogo.SizeWidth / 2 - 10 - shape.SizeWidth / 2;
                            shape.CenterY = siteLogo.CenterY;
                        }

                        count++;
                        await mainWindow.OutputText.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate()
                        {
                            mainWindow.OutputText.Text += "Обработанно: " + count + " строк.\n";
                            mainWindow.OutputText.ScrollToEnd();
                        }));

                        await mainWindow.ProgressBar.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(delegate()
                        {
                            mainWindow.ProgressBar.Value = (double)count * 100 / data.Count;
                        }));
                    }
                    else
                    {
                        //rect = new VGCore.Rect
                        //{
                        //    Width = 297,
                        //    Height = 100
                        //};
                        //rgbAssign = new RGBAssign(255, 255, 255);
                        //rectanglePosition = new RectanglePosition(0, 100);
                        //CreateRectangleRectAsync(rect, layer, rectanglePosition, rgbAssign, cts);

                        fullPath = Path.GetDirectoryName(FileName) + @"\fon\" + item.BackgroundNumber + ".jpg";
                        if (item.BackgroundNumber != "0")
                        {
                            importFilter = layer.ImportEx(fullPath, VGCore.cdrFilter.cdrJPEG);
                            importFilter.Finish();

                            shape       = page.Shapes[item.BackgroundNumber + ".jpg"];
                            image       = shape.ObjectData["Name"];
                            image.Value = item.BackgroundNumber;

                            shape.SizeWidth  = 297;
                            shape.SizeHeight = 100;
                            shape.PositionX  = 0;
                            shape.PositionY  = 100;
                        }

                        name = item.ChildName.Split(' ');
                        if (name.Length > 1)
                        {
                            fullName = name[0] + "\r\n" + name[1];
                            fontSize = 102.5f;
                        }
                        else
                        {
                            fullName = name[0];
                            fontSize = 205f;
                        }
                        rgbAssign    = new RGBAssign(255, 72, 41);
                        artisticText = new ArtisticText(31.369, 28.7782, fullName, "Kabarett Simple", fontSize, "Name2");
                        CreateArtisticTextAsync(layer, artisticText, rgbAssign, cts);
                        shape         = page.Shapes["Name2"];
                        shape.CenterY = 50;

                        cmykAssign    = new CMYKAssign(0, 0, 0, 100);
                        paragraphText = new ParagraphText(226.538, 100, 242.096, 105, item.ImageNumber, "Arial", 12, "ImageNumber2", 2);
                        CreateParagraphTextAsync(layer, paragraphText, cmykAssign, cts);

                        cmykAssign    = new CMYKAssign(100, 0, 0, 0);
                        paragraphText = new ParagraphText(242.652, 100, 258.21, 105, item.DoorWidth.ToString(), "Arial", 12, "DoorWidth2", 2);
                        CreateParagraphTextAsync(layer, paragraphText, cmykAssign, cts);

                        cmykAssign    = new CMYKAssign(100, 0, 100, 0);
                        paragraphText = new ParagraphText(258.767, 100, 285.868, 105, item.Pocket, "Arial", 12, "Pocket2", 2);
                        CreateParagraphTextAsync(layer, paragraphText, cmykAssign, cts);

                        cmykAssign    = new CMYKAssign(0, 88, 97, 0);
                        paragraphText = new ParagraphText(149.845, 100, 225.982, 105, item.Customer, "Arial", 12, "Customer2", 2);
                        CreateParagraphTextAsync(layer, paragraphText, cmykAssign, cts);

                        fullPath = Path.GetDirectoryName(FileName) + @"\img\" + item.ImageNumber + ".png";

                        rgbAssign    = new RGBAssign(255, 41, 41);
                        artisticText = new ArtisticText(193.745, 128.413, LOGO, "Arial", 16.591f, "Logo2", 63.174);
                        CreateArtisticTextAsync(layer, artisticText, rgbAssign, cts);
                        siteLogo = page.Shapes["Logo2"];
                        siteLogo.Rotate(90);
                        siteLogo.SizeHeight = 63.174;
                        siteLogo.SizeWidth  = 4.255;

                        if (item.DoorWidth < 23)
                        {
                            siteLogo.CenterX = 195.872;
                        }
                        else if (item.DoorWidth >= 23 && item.DoorWidth < 25)
                        {
                            siteLogo.CenterX = 215.872;
                        }
                        else if (item.DoorWidth >= 25 && item.DoorWidth < 27)
                        {
                            siteLogo.CenterX = 235.872;
                        }
                        else if (item.DoorWidth >= 27 && item.DoorWidth < 29)
                        {
                            siteLogo.CenterX = 255.872;
                        }
                        else if (item.DoorWidth >= 29)
                        {
                            siteLogo.CenterX = 275.872;
                        }
                        siteLogo.CenterY = 50;

                        if (item.ImageNumber != "0")
                        {
                            importFilter = layer.ImportEx(fullPath, VGCore.cdrFilter.cdrPNG);
                            importFilter.Finish();

                            shape       = page.Shapes[item.ImageNumber + ".png"];
                            image       = shape.ObjectData["Name"];
                            image.Value = item.ImageNumber;

                            shape.CenterX = siteLogo.CenterX - siteLogo.SizeWidth / 2 - 10 - shape.SizeWidth / 2;
                            shape.CenterY = siteLogo.CenterY;
                        }

                        count++;
                        await mainWindow.OutputText.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate()
                        {
                            mainWindow.OutputText.Text += "Обработанно: " + count + " строк.\n";
                            mainWindow.OutputText.ScrollToEnd();
                        }));

                        await mainWindow.ProgressBar.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(delegate()
                        {
                            mainWindow.ProgressBar.Value = (double)count * 100 / data.Count;
                        }));
                    }
                }

                await mainWindow.OutputText.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate()
                {
                    mainWindow.OutputText.Text += "Файл CorelDRAW, обработан. Можете продолжить работу.\n";

                    sw.Stop();

                    mainWindow.OutputText.Text += "Время обработки файла CorelDRAW: " + (sw.ElapsedMilliseconds / 1000.0).ToString() + " сек.\n";
                    mainWindow.OutputText.Text += "Обработанно: " + data.Count + " строк.\n";
                    mainWindow.OutputText.ScrollToEnd();
                }));

                await mainWindow.ProgressBar.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(delegate()
                {
                    mainWindow.ProgressBar.Value = 0;
                }));

                document.PreserveSelection = true;
                document.ResetSettings();
                corelApp.EventsEnabled = true;
                corelApp.Optimization  = false;
                document.EndCommandGroup();
                corelApp.Refresh();
                corelApp.ActiveWindow.Refresh();
                corelApp.Visible = true;
            }
            catch (OperationCanceledException)
            {
                await mainWindow.OutputText.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate()
                {
                    mainWindow.OutputText.Text += "Операция была отменена пользователем!\n";
                    mainWindow.OutputText.ScrollToEnd();
                }));
            }
            catch (Exception ex)
            {
                await mainWindow.OutputText.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate()
                {
                    mainWindow.OutputText.Text += $"Work is failed.\n{ex.Message}\n";
                    mainWindow.OutputText.ScrollToEnd();
                }));
            }
            finally
            {
                Marshal.ReleaseComObject(image);
                Marshal.ReleaseComObject(importFilter);
                //Marshal.ReleaseComObject(rect);
                Marshal.ReleaseComObject(siteLogo);
                Marshal.ReleaseComObject(shape);
                Marshal.ReleaseComObject(layer);
                Marshal.ReleaseComObject(page);
                Marshal.ReleaseComObject(document);
                Marshal.ReleaseComObject(corelApp);
            }
        }
Пример #10
0
        /// <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);
        }
 private static void AddVerbalIllustrations(ParagraphText textPart, JArray array)
 => textPart.Parts.Last().Vis.AddRange(array.ParseNextAs <List <VerbalIllustration> >());
 private static void SetText(ParagraphText textPart, JArray array)
 => textPart.Parts.Add(new ParagraphTextPart {
     Text = array.ParseNextAsString()
 });
Пример #13
0
        static public C1PrintDocument TextStyles()
        {
            C1.C1Preview.C1PrintDocument doc = new C1.C1Preview.C1PrintDocument();

            RenderText rtxt = new RenderText(doc);

            rtxt.Text                = "Text styles in C1PrintDocument";
            rtxt.Style.FontName      = "Arial";
            rtxt.Style.FontSize      = 18;
            rtxt.Style.FontBold      = true;
            rtxt.Style.TextAlignHorz = AlignHorzEnum.Center;
            rtxt.Style.Padding.All   = new Unit("5mm");
            doc.Body.Children.Add(rtxt);

            // setup some text styles
            Style s1 = doc.Style.Children.Add();

            s1.TextColor = Colors.Blue;
            s1.FontBold  = true;

            Style s2 = doc.Style.Children.Add();

            s2.BackColor = Colors.Chartreuse;

            Style s3 = doc.Style.Children.Add();

            s3.TextColor = Colors.Red;

            Style s4 = doc.Style.Children.Add();

            s4.FontName   = "Arial";
            s4.FontSize   = 14;
            s4.FontBold   = true;
            s4.FontItalic = true;

            Style s5 = doc.Style.Children.Add();

            s5.BackColor = s2.BackColor;
            s5.TextColor = s3.TextColor;
            s5.Font      = s4.Font;

            RenderParagraph rp = new RenderParagraph(doc);

            ParagraphObject po = new ParagraphText("In ");

            rp.Content.Add(po);
            po = new ParagraphText("C1PrintDocument");
            po.Style.AssignNonInheritedFrom(s1);
            rp.Content.Add(po);
            rp.Content.Add(new ParagraphText(", multi-style text is fully supported via "));
            rp.Content.Add(new ParagraphText("RenderParagraph", Colors.Blue));
            rp.Content.Add(new ParagraphText(" render objects."));

            rp.Content.Add(new ParagraphText("\rWithin a single paragraph, you can change "));

            po = new ParagraphText("background color,");
            po.Style.Parent = s2;
            rp.Content.Add(po);

            po = new ParagraphText(" text color,");
            po.Style.AssignNonInheritedFrom(s3);
            rp.Content.Add(po);

            po = new ParagraphText(" font,");
            po.Style.AssignNonInheritedFrom(s4);
            rp.Content.Add(po);

            po = new ParagraphText(" or all together.");
            po.Style.AssignNonInheritedFrom(s5);
            rp.Content.Add(po);

            rp.Content.Add(new ParagraphText("\rFont sub-properties such as "));
            rp.Content.Add(new ParagraphText("bold, "));
            rp.Content[rp.Content.Count - 1].Style.FontBold = true;
            rp.Content.Add(new ParagraphText("italic "));
            rp.Content[rp.Content.Count - 1].Style.FontItalic = true;
            rp.Content.Add(new ParagraphText("or "));
            rp.Content.Add(new ParagraphText("underline"));
            rp.Content[rp.Content.Count - 1].Style.FontUnderline = true;
            rp.Content.Add(new ParagraphText(" can be individually adjusted."));

            rp.Content.Add(new ParagraphText("\rText positions such as "));
            rp.Content.Add(new ParagraphText("superscript", TextPositionEnum.Superscript));
            rp.Content.Add(new ParagraphText(" and "));
            rp.Content.Add(new ParagraphText("subscript", TextPositionEnum.Subscript));
            rp.Content.Add(new ParagraphText(" are supported."));

            po = new ParagraphText("\rInline images ");
            rp.Content.Add(po);
            System.Drawing.Image inlineImage = System.Drawing.Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("DemoTables.check.png"));
            po = new ParagraphImage(inlineImage);
            rp.Content.Add(po);
            po = new ParagraphText(" can be embedded in the text as well.");
            rp.Content.Add(po);

            doc.Body.Children.Add(rp);

            return(doc);
        }
Пример #14
0
        public static JObject parseArticle2Json(Article article)
        {
            JObject result = new JObject();

            result["type"]   = article.Type;
            result["title"]  = article.Title;
            result["author"] = article.Author;

            JObject cover = new JObject();

            cover["cover_type"] = article.Cover.CoverType;
            if (article.Cover.CoverType == "photo")
            {
                CoverPhoto photoCover = (CoverPhoto)article.Cover;
                cover["photo_url"] = photoCover.PhotoUrl;
            }
            else
            {
                CoverVideo videoCover = (CoverVideo)article.Cover;
                cover["cover_view"] = videoCover.CoverView.getValue();
                cover["video_id"]   = videoCover.VideoId;
            }
            cover["status"] = article.Cover.Status.getValue();
            result["cover"] = cover;

            result["description"] = article.Description;

            JArray body = new JArray();

            foreach (Paragraph paragraph in article.Body)
            {
                JObject paragraphJson = new JObject();
                paragraphJson["type"] = paragraph.Type;
                switch (paragraph.Type)
                {
                case "text":
                    ParagraphText textParagraph = (ParagraphText)paragraph;
                    paragraphJson["content"] = textParagraph.Content;
                    break;

                case "image":
                    ParagraphImage imageParagraph = (ParagraphImage)paragraph;
                    paragraphJson["url"]     = imageParagraph.Url;
                    paragraphJson["caption"] = imageParagraph.Caption;
                    break;

                case "video":
                    ParagraphVideo videoParagraph = (ParagraphVideo)paragraph;
                    if (videoParagraph.Url != null)
                    {
                        paragraphJson["url"] = videoParagraph.Url;
                    }
                    else
                    {
                        paragraphJson["video_id"] = videoParagraph.VideoId;
                    }
                    paragraphJson["thumb"] = videoParagraph.Thumb;
                    break;

                case "product":
                    ParagraphProduct productParagraph = (ParagraphProduct)paragraph;
                    paragraphJson["id"] = productParagraph.Id;
                    break;
                }
                body.Add(paragraphJson);
            }
            result["body"] = body;

            JArray related_medias = new JArray();

            foreach (RelatedMedia relatedMedia in article.RelatedMedias)
            {
                JObject relatedMediaJson = new JObject();
                relatedMediaJson["id"] = relatedMedia.Id;
                related_medias.Add(relatedMediaJson);
            }

            result["related_medias"] = related_medias;

            if (article.TrackingLink != null)
            {
                if (article.TrackingLink.Length != 0)
                {
                    result["tracking_link"] = article.TrackingLink;
                }
            }
            result["status"]  = article.Status.getValue();
            result["comment"] = article.Comment.getValue();

            return(result);
        }
Пример #15
0
        private C1.C1Preview.C1PrintDocument makeDoc_TextStyles()
        {
            C1.C1Preview.C1PrintDocument doc = new C1.C1Preview.C1PrintDocument();

            RenderText rtxt = new RenderText(doc);

            rtxt.Text                = "Text styles in the new C1PrintDocument";
            rtxt.Style.Font          = new Font("Arial", 18, FontStyle.Bold);
            rtxt.Style.TextAlignHorz = AlignHorzEnum.Center;
            rtxt.Style.Padding.All   = new Unit("5mm");
            doc.Body.Children.Add(rtxt);

            // setup some text styles
            Style s1 = doc.Style.Children.Add();

            s1.TextColor = Color.Blue;
            s1.Font      = new Font(s1.Font, FontStyle.Bold);

            Style s2 = doc.Style.Children.Add();

            s2.BackColor = Color.Chartreuse;

            Style s3 = doc.Style.Children.Add();

            s3.TextColor = Color.Red;

            Style s4 = doc.Style.Children.Add();

            s4.Font = new Font("Arial", 14, FontStyle.Bold | FontStyle.Italic);

            Style s5 = doc.Style.Children.Add();

            s5.BackColor = s2.BackColor;
            s5.TextColor = s3.TextColor;
            s5.Font      = s4.Font;


            RenderParagraph rp = new RenderParagraph(doc);

            ParagraphObject po = new ParagraphText("In the new ");

            rp.Content.Add(po);
            po = new ParagraphText("C1PrintDocument");
            po.Style.AssignNonInheritedFrom(s1);
            rp.Content.Add(po);
            po = new ParagraphText(" multi-style text is fully supported. You can change ", TextPositionEnum.Normal);
            rp.Content.Add(po);

            po = new ParagraphText("the background color,");
            // po.Style.AssignNonInheritedFrom(s2);
            po.Style.Parent = s2;
            rp.Content.Add(po);

            po = new ParagraphText(" text color,");
            po.Style.AssignNonInheritedFrom(s3);
            rp.Content.Add(po);

            po = new ParagraphText(" font,");
            po.Style.AssignNonInheritedFrom(s4);
            rp.Content.Add(po);

            po = new ParagraphText(" or all together.");
            po.Style.AssignNonInheritedFrom(s5);
            rp.Content.Add(po);

            po = new ParagraphText(" Superscript", TextPositionEnum.Superscript);
            rp.Content.Add(po);

            po = new ParagraphText(" and ");
            rp.Content.Add(po);

            po = new ParagraphText("Subscript", TextPositionEnum.Subscript);
            rp.Content.Add(po);

            po = new ParagraphText(" text can be rendered.");
            rp.Content.Add(po);

            po = new ParagraphText(" Additionally, images ");
            rp.Content.Add(po);
            po = new ParagraphImage(pictureBox2.Image);
            rp.Content.Add(po);
            po = new ParagraphText(" can be embedded in the text as well.");
            rp.Content.Add(po);

            doc.Body.Children.Add(rp);

            return(doc);
        }
Пример #16
0
        private void CreateDoc(C1PrintDocument doc)
        {
            doc.Clear();

            doc.PageLayout.PageSettings.Landscape = true;

            Style codeStyle = doc.Style.Children.Add();

            codeStyle.Font = new Font("Courier New", 12);
            Style captionStyle = doc.Style.Children.Add();

            captionStyle.Font = new Font("Tahoma", 18, FontStyle.Bold);

            RenderParagraph rp = new RenderParagraph();

            rp.Style.Borders.All = new LineDef("1mm", Color.Blue);
            rp.Style.BackColor   = Color.LightBlue;
            rp.Style.Font        = new Font("Tahoma", 16);
            rp.Content.Add(new ParagraphText("This sample demostrates using of HyperlinkPageNo tag\r\r", captionStyle));
            rp.Content.Add(new ParagraphText("It returns number of page that hyperlink points. For example:\r\r"));
            rp.Content.Add(new ParagraphText("rt = new RenderText();\r", codeStyle));
            rp.Content.Add(new ParagraphText("rt.Text = \"(C1LinkTargetDocumentLocation) Goto page: [HyperlinkPageNo]\";\r", codeStyle));
            rp.Content.Add(new ParagraphText("rt.Hyperlink = new C1Hyperlink(new C1LinkTargetDocumentLocation(rt2));\r", codeStyle));
            rp.Content.Add(new ParagraphText("rt.Style.Borders.All = LineDef.Default;\r", codeStyle));
            rp.Content.Add(new ParagraphText("doc.Body.Children.Add(rt);", codeStyle));
            rp.Content.Add(new ParagraphText("\r\rTag HyperlinkPageNo will be replaced with number of page where object rt2 is.\r"));
            rp.Content.Add(new ParagraphText("It must be taken into consideration that when the document is being resolved, it is not always possible to evaluate HyperlinkPageNo (e.g. if it references an object that has not been resolved yet). "));
            rp.Content.Add(new ParagraphText("In such cases, if the object contains many HyperlinkPageNo tags and has auto width and/or height, the calculated size may differ from the correct size as instead of actual page numbers, the string \"XXX\" is used for size calculation.\r"));
            rp.Content.Add(new ParagraphText("To minimize such errors::\r"));
            rp.Content.Add(new ParagraphText("- use absolute sizes for such objets;\r"));
            rp.Content.Add(new ParagraphText("- place hyperlinks after the objects they reference.\r\r"));
            rp.Content.Add(new ParagraphText("In this sample, the document contains two RenderParagraph objects, each of which has HyperlinkPageNo tags. "));
            rp.Content.Add(new ParagraphText("The first paragraph is placed before the table, and hence its size is slightly bigger. The other paragraph follows the table and hence its size is exactly right."));
            doc.Body.Children.Add(rp);

            doc.Style.Font = new Font("Tahoma", 16);

            // generate siple table (3 x 100)
            RenderTable rt = new RenderTable();

            for (int r = 0; r < 100; r++)
            {
                for (int c = 0; c < 3; c++)
                {
                    rt.Cells[r, c].Text = string.Format("Cell {0}:{1}", r, c);
                }
            }
            rt.Style.GridLines.All = LineDef.DefaultBold;

            // generate RenderParagraph with hyperlinks
            rp = new RenderParagraph();
            rp.Style.Borders.All = new LineDef("1mm", Color.Red);
            rp.Style.Spacing.All = "5mm";
            rp.Style.Padding.All = "1mm";
            rp.RepeatBordersVert = true;
            rp.Content.Add(new ParagraphText("Content:\r\r", new Font("Verdana", 20)));
            for (int r = 0; r < rt.Rows.Count; r++)
            {
                ParagraphText pt = new ParagraphText(string.Format("Row{0} ([HyperlinkPageNo])", r));
                pt.Hyperlink = new C1Hyperlink(new C1LinkTargetDocumentLocation(rt.Cells[r, 0]));
                rp.Content.Add(pt);
                if (r < rt.Rows.Count - 1)
                {
                    rp.Content.Add(new ParagraphText(", "));
                }
            }
            // add paragraph into document BEFORE table
            doc.Body.Children.Add(rp);
            // add table
            doc.Body.Children.Add(rt);

            // add paragraph into document AFTER table
            RenderParagraph rp2 = (RenderParagraph)rp.Clone();

            doc.Body.Children.Add(rp2);

            doc.Generate();
        }