コード例 #1
0
        public static VA.Text.Markup.TextElement AddElementEx(this VA.Text.Markup.TextElement p, string text,
                                                              int?font, double?size, int?color,
                                                              VA.Drawing.AlignmentHorizontal?halign,
                                                              VA.Text.CharStyle?cs)
        {
            var el = p.AddElement(text);

            if (font != null)
            {
                el.CharacterCells.Font = font.Value;
            }
            if (size.HasValue)
            {
                el.CharacterCells.Size = string.Format("{0}pt", size.Value);
            }
            if (color.HasValue)
            {
                var c = new ColorRGB(color.Value);
                el.CharacterCells.Color = c.ToFormula();
            }
            if (halign.HasValue)
            {
                el.ParagraphCells.HorizontalAlign = (int)halign.Value;
            }

            if (cs.HasValue)
            {
                el.CharacterCells.Style = (int)cs;
            }

            return(el);
        }
コード例 #2
0
        public static void GradientTransparencies()
        {
            int num_cols = 1;
            int num_rows = 10;
            var color1   = new ColorRGB(0xff000);
            var color2   = new ColorRGB(0x000ff);

            var page_size = new VA.Drawing.Size(num_rows / 2.0, num_rows);
            var upperleft = new VA.Drawing.Point(0, page_size.Height);

            var page    = SampleEnvironment.Application.ActiveDocument.Pages.Add();
            var app     = page.Application;
            var docs    = app.Documents;
            var stencil = docs.OpenStencil("basic_U.vss");
            var master  = stencil.Masters["Rectangle"];

            SampleEnvironment.SetPageSize(page, page_size);

            var layout = new GRIDMODEL.GridLayout(num_cols, num_rows, new VA.Drawing.Size(6.0, 1.0), master);

            layout.RowDirection = GRIDMODEL.RowDirection.TopToBottom;
            layout.Origin       = upperleft;
            layout.CellSpacing  = new VA.Drawing.Size(0.1, 0.1);
            layout.PerformLayout();

            double[] trans = EffectsSamples.RangeSteps(0.0, 1.0, num_rows).ToArray();

            int i = 0;

            foreach (var node in layout.Nodes)
            {
                double transparency = trans[i];

                var fmt = new VA.DOM.ShapeCells();
                node.Cells = fmt;

                fmt.FillPattern      = 25; // Linear pattern left to right
                fmt.FillForegnd      = color1.ToFormula();
                fmt.FillBkgnd        = color2.ToFormula();
                fmt.FillForegndTrans = 0;
                fmt.FillBkgndTrans   = transparency;
                fmt.LinePattern      = 0;

                node.Text = string.Format("bg trans = {0}%", transparency);
                i++;
            }

            layout.Render(page);

            page.ResizeToFitContents();
        }
コード例 #3
0
        public static void TextMarkup11()
        {
            var page = SampleEnvironment.Application.ActiveDocument.Pages.Add();

            // Create the Shapes that will hold the text
            var s1  = page.DrawRectangle(0, 0, 8.5, 11);
            var tnr = page.Document.Fonts["Times New Roman"];

            var e1        = new VisioAutomation.Models.Text.TextElement();
            var color_red = new ColorRGB(0xff0000);

            e1.CharacterFormatting.Color = color_red.ToFormula();
            e1.CharacterFormatting.Font  = tnr.ID;
            e1.CharacterFormatting.Font  = "20pt";
            e1.AddText("Hello World");
            e1.SetText(s1);
        }
コード例 #4
0
        public static void TextMarkup12()
        {
            var page = SampleEnvironment.Application.ActiveDocument.Pages.Add();

            // Create the Shapes that will hold the text
            var s1  = page.DrawRectangle(0, 0, 8.5, 11);
            var tnr = page.Document.Fonts["Times New Roman"];

            var e1        = new VA.Text.Markup.TextElement();
            var color_red = new ColorRGB(0xff0000);

            e1.CharacterCells.Color = color_red.ToFormula();
            e1.CharacterCells.Font  = tnr.ID;
            e1.CharacterCells.Font  = "20pt";
            e1.AddText("Hello ");

            var e2 = e1.AddElementEx("World", null, null, null, null, VA.Text.CharStyle.Italic);

            e1.SetText(s1);
        }
コード例 #5
0
        public static void DrawAllGradients()
        {
            var app     = SampleEnvironment.Application;
            var docs    = app.Documents;
            var stencil = docs.OpenStencil("basic_u.vss");
            var master  = stencil.Masters["Rectangle"];
            var page    = SampleEnvironment.Application.ActiveDocument.Pages.Add();

            int num_cols = 7;
            int num_rows = 7;

            var page_size = new VA.Drawing.Size(5, 5);

            SampleEnvironment.SetPageSize(page, page_size);

            var lowerleft        = new VA.Drawing.Point(0, 0);
            var actual_page_size = SampleEnvironment.GetPageSize(page);
            var page_rect        = new VA.Drawing.Rectangle(lowerleft, actual_page_size);

            var layout = new GRIDMODEL.GridLayout(num_cols, num_rows, new VA.Drawing.Size(1, 1), master);

            layout.RowDirection = GRIDMODEL.RowDirection.TopToBottom;
            layout.Origin       = page_rect.UpperLeft;
            layout.CellSpacing  = new VA.Drawing.Size(0, 0);
            layout.PerformLayout();

            int max_grad_id = 40;
            int n           = 0;

            foreach (var node in layout.Nodes)
            {
                int grad_id = n % max_grad_id;
                node.Text = grad_id.ToString();
                n++;
            }

            layout.Render(page);

            var color1 = new ColorRGB(0xffdddd);
            var color2 = new ColorRGB(0x00ffff);

            var format = new VA.Shapes.FormatCells();

            var update = new VA.ShapeSheet.Update();

            string color1_formula = color1.ToFormula();
            string color2_formula = color2.ToFormula();

            n = 0;

            foreach (var node in layout.Nodes)
            {
                short shapeid = node.ShapeID;
                int   grad_id = n % max_grad_id;

                format.FillPattern = grad_id;
                format.FillForegnd = color1_formula;
                format.FillBkgnd   = color2_formula;
                format.LinePattern = 0;
                format.LineWeight  = 0;
                update.SetFormulas(shapeid, format);

                n++;
            }

            update.Execute(page);

            var bordersize = new VA.Drawing.Size(1, 1);

            page.ResizeToFitContents(bordersize);
        }