示例#1
0
        internal IVisio.Page Draw(FormRenderingContext context)
        {
            var r = new InteractiveRenderer(context.Document);

            this.VisioPage = r.CreatePage(this);
            context.Page   = this.VisioPage;

            var titleblock = new TextBlock(new Geometry.Size(7.5, 0.5), this.Title);

            int fontid = context.GetFontID(this.DefaultFont);

            titleblock.TextBlockCells.VerticalAlign         = 0;
            titleblock.ParagraphFormatCells.HorizontalAlign = 0;
            titleblock.FormatCells.LineWeight    = 0;
            titleblock.FormatCells.LinePattern   = 0;
            titleblock.CharacterFormatCells.Font = fontid;
            titleblock.CharacterFormatCells.Size = get_pt_string(this.TitleTextSize);



            // Draw the shapes
            var titleshape = r.AddShape(titleblock);

            r.Linefeed();

            double body_height = r.GetDistanceToBottomMargin();
            var    bodyblock   = new TextBlock(new Geometry.Size(7.5, body_height), this.Body);

            bodyblock.ParagraphFormatCells.HorizontalAlign = 0;
            bodyblock.ParagraphFormatCells.SpacingAfter    = get_pt_string(this.BodyParaSpacingAfter);
            bodyblock.CharacterFormatCells.Font            = fontid;
            bodyblock.CharacterFormatCells.Size            = get_pt_string(this.BodyTextSize);
            bodyblock.FormatCells.LineWeight       = 0;
            bodyblock.FormatCells.LinePattern      = 0;
            bodyblock.TextBlockCells.VerticalAlign = 0;
            bodyblock.FormatCells.LineWeight       = 0;
            bodyblock.FormatCells.LinePattern      = 0;

            var bodyshape = r.AddShape(bodyblock);

            r.Linefeed();

            r.Finish();
            return(this.VisioPage);
        }
示例#2
0
        public IVisio.Document Render(IVisio.Application app)
        {
            var docs = app.Documents;
            var doc  = docs.Add("");

            var context = new FormRenderingContext();

            context.Application = app;
            context.Document    = doc;
            context.Pages       = doc.Pages;
            context.Fonts       = doc.Fonts;

            this.VisioDocument = doc;

            doc.Subject = this.Subject;
            doc.Title   = this.Title;
            doc.Creator = this.Creator;
            doc.Company = this.Company;

            var pages = doc.Pages;

            foreach (var formpage in this.Pages)
            {
                var page = formpage.Draw(context);
            }

            if (pages.Count > 0)
            {
                // Delete the empty first page
                var first_page = this.VisioDocument.Pages[1];
                first_page.Delete(1);
                first_page = pages[1];
                var active_window = app.ActiveWindow;
                active_window.Page = first_page;
            }
            return(doc);
        }