Example #1
0
        public static Page GetPage05_Formatted_Text(Drawing doc)
        {
            var page = new Page(8, 4);
            doc.Pages.Add(page);

            // find the id of the master for rounded rectangles
            int rounded_rect_id = doc.GetMasterMetaData("Rounded REctAngle").ID;

            // using that ID draw a rounded rectangle at pinpos(4,3)
            var shape1 = new Shape(rounded_rect_id, 4, 3);
            page.Shapes.Add(shape1);

            // using that ID draw a rounded rectangle at pinpos(2,2) with size (2.5,2)
            var shape2 = new Shape(rounded_rect_id, 2, 2, 2.5, 2);
            page.Shapes.Add(shape2);

            shape1.XForm.Angle.Result = Math.PI/4;

            shape1.Text.Add("HELLO");
            shape2.TextXForm = new TextXForm();
            shape2.TextXForm.PinY.Formula = "-TxtHeight*0.5";

            var font_segoeui = doc.AddFace("Segoe UI");
            var font_gillsans = doc.AddFace("Gill Sans MT");
            var font_trebuchet = doc.AddFace("Trebuchet MS");

            var charfmt1 = new VisioAutomation.VDX.Sections.Char();
            charfmt1.Font.Result = font_gillsans.ID;
            charfmt1.DoubleUnderline.Result = true;
            charfmt1.Size.Result = 18.0;
            charfmt1.Transparency.Result = 0.5;
            charfmt1.Style.Result = CharStyle.Italic | CharStyle.Bold |
                                    CharStyle.Underline;

            var charfmt2 = new VisioAutomation.VDX.Sections.Char();
            charfmt2.Font.Result = font_trebuchet.ID;
            charfmt2.Strikethru.Result = true;
            charfmt2.Size.Result = 26;

            var charfmt3 = new VisioAutomation.VDX.Sections.Char();
            charfmt3.Font.Result = font_segoeui.ID;
            charfmt3.Strikethru.Result = true;
            charfmt3.RTLText.Result = true;

            var parafmt1 = new ParagraphFormat();
            parafmt1.HorzAlign.Result = ParaHorizontalAlignment.Center;

            var parafmt2 = new ParagraphFormat();
            parafmt2.HorzAlign.Result = ParaHorizontalAlignment.Right;

            var parafmt3 = new ParagraphFormat();
            parafmt3.HorzAlign.Result = ParaHorizontalAlignment.Left;

            shape2.CharFormats = new List<VisioAutomation.VDX.Sections.Char>();
            shape2.ParaFormats = new List<ParagraphFormat>();

            shape2.CharFormats.Add(charfmt1);
            shape2.CharFormats.Add(charfmt2);
            shape2.CharFormats.Add(charfmt3);

            shape2.ParaFormats.Add(parafmt1);
            shape2.ParaFormats.Add(parafmt2);
            shape2.ParaFormats.Add(parafmt3);

            shape2.Text.Add("world1\n", 0, 0, null);
            shape2.Text.Add("world2\n", 1, 1, null);
            shape2.Text.Add("world3", 2, 2, null);
            return page;
        }