public Formatting()
 {
     this.FormatCells = new VA.Shapes.FormatCells();
     this.CharacterCells = new VA.Text.CharacterCells();
     this.ParagraphCells = new VA.Text.ParagraphCells();
     this.TextCells = new VA.Text.TextCells();
 }
Example #2
0
 public Formatting()
 {
     this.FormatCells    = new VA.Shapes.FormatCells();
     this.CharacterCells = new VA.Text.CharacterCells();
     this.ParagraphCells = new VA.Text.ParagraphCells();
     this.TextCells      = new VA.Text.TextCells();
 }
 public TextBlock(VA.Drawing.Size size, string text)
 {
     this.Text = text;
     this.Size = size;
     this.Textcells = new VA.Text.TextCells();
     this.ParagraphCells = new VA.Text.ParagraphCells();
     this.FormatCells = new VA.Shapes.FormatCells();
     this.CharacterCells = new VA.Text.CharacterCells();
 }
Example #4
0
 public TextBlock(VA.Drawing.Size size, string text)
 {
     this.Text           = text;
     this.Size           = size;
     this.Textcells      = new VA.Text.TextCells();
     this.ParagraphCells = new VA.Text.ParagraphCells();
     this.FormatCells    = new VA.Shapes.FormatCells();
     this.CharacterCells = new VA.Text.CharacterCells();
 }
        public static void ColorGrid()
        {
            // Draws a grid rectangles and then formats the shapes
            // with different colors

            // Demonstrates:
            // How use the GridLayout object to quickly drop a grid
            // How to use ShapeFormatCells to apply formatting to shapes
            // How UpdateBase can be used to modfiy multiple shapes at once

            int[] colors = {
                    0x0A3B76, 0x4395D1, 0x99D9EA, 0x0D686B, 0x00A99D, 0x7ACCC8, 0x82CA9C,
                    0x74A402,
                    0xC4DF9B, 0xD9D56F, 0xFFF468, 0xFFF799, 0xFFC20E, 0xEB6119, 0xFBAF5D,
                    0xE57300, 0xC14000, 0xB82832, 0xD85171, 0xFEDFEC, 0x563F7F, 0xA186BE,
                    0xD9CFE5
                };

            const int num_cols = 5;
            const int num_rows = 5;

            var page = SampleEnvironment.Application.ActiveDocument.Pages.Add();

            var page_size = new VA.Drawing.Size(10, 10);
            SampleEnvironment.SetPageSize(page,page_size);

            var stencil = SampleEnvironment.Application.Documents.OpenStencil("basic_u.vss");
            var master = stencil.Masters["Rectangle"];

            var layout = new VA.Models.Grid.GridLayout(num_cols, num_rows, new VA.Drawing.Size(1, 1), master);
            layout.Origin = new VA.Drawing.Point(0, 0);
            layout.CellSpacing = new VA.Drawing.Size(0, 0);
            layout.RowDirection = VA.Models.Grid.RowDirection.BottomToTop;

            layout.PerformLayout();
            layout.Render(page);

            var fmtcells = new VA.Shapes.FormatCells();
            int i = 0;
            var update = new VA.ShapeSheet.Update();
            foreach (var node in layout.Nodes)
            {
                var shapeid = node.ShapeID;
                int color_index = i%colors.Length;
                var color = colors[color_index];
                fmtcells.FillForegnd = new VA.Drawing.ColorRGB(color).ToFormula();
                fmtcells.LinePattern = 0;
                fmtcells.LineWeight = 0;
                update.SetFormulas(shapeid, fmtcells);
                i++;
            }

            update.Execute(page);

            var bordersize = new VA.Drawing.Size(1,1);
            page.ResizeToFitContents(bordersize);
        }
Example #6
0
        public static void ProgressBar()
        {
            var page_a = SampleEnvironment.Application.ActiveDocument.Pages.Add();


            // Draw some shapes
            var background = page_a.DrawRectangle(0, 0, 5, 1);
            var progress   = page_a.DrawRectangle(0, 0, 1, 1);

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

            background_fmt.FillForegnd = "rgb(240,240,240)";
            background_fmt.LineColor   = "rgb(100,100,100)";


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

            progress_fmt.FillForegnd = "rgb(100,150,240)";
            progress_fmt.LineColor   = "rgb(100,100,100)";

            // group the two shapes together
            page_a.Application.ActiveWindow.SelectAll();
            var group = page_a.Application.ActiveWindow.Selection.Group();

            // Set the progress shape update itself based on its position
            string bkname = background.NameID;
            var    xform  = new VA.Shapes.XFormCells();

            xform.PinX   = string.Format("GUARD({0}!PinX-{0}!LocPinX+LocPinX)", bkname);
            xform.PinY   = string.Format("GUARD({0}!PinY)", bkname);
            xform.Width  = string.Format("GUARD({0}!Width*(PAGENUMBER()/PAGECOUNT()))", bkname);
            xform.Height = string.Format("GUARD({0}!Height)", bkname);

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

            update.SetFormulas(progress.ID16, xform);
            update.SetFormulas(progress.ID16, background_fmt);
            update.SetFormulas(progress.ID16, progress_fmt);
            update.Execute(page_a);

            var markup1 = new VA.Text.Markup.TextElement();

            markup1.AddField(VA.Text.Markup.FieldConstants.PageName);
            markup1.AddText(" (");
            markup1.AddField(VA.Text.Markup.FieldConstants.PageNumber);
            markup1.AddText(" of ");
            markup1.AddField(VA.Text.Markup.FieldConstants.NumberOfPages);
            markup1.AddText(") ");
            markup1.SetText(group);
        }
Example #7
0
        public static void Spirograph()
        {
            var page = SampleEnvironment.Application.ActiveDocument.Pages.Add();

            page.Name = "Spirograph";

            var colors = new[]
            {
                0xf26420, 0xf7931c, 0xfec20d, 0xfff200,
                0xcada28, 0x8cc63e, 0x6c9d30, 0x288f39,
                0x006f3a, 0x006f71, 0x008eb0, 0x00adee,
                0x008ed3, 0x0071bb, 0x0053a6, 0x2e3091,
                0x5b57a6, 0x652d91, 0x92278e, 0xbd198c,
                0xec008b, 0xec1c23, 0xc1272c, 0x981a1e
            };

            var    origin             = new VA.Drawing.Point(4, 4);
            double radius             = 3.0;
            int    numpoints          = colors.Length;
            double angle_step         = (System.Math.PI * 2 / numpoints);
            var    angles             = Enumerable.Range(0, numpoints).Select(i => i * angle_step).ToList();
            var    centers            = angles.Select(a => GetPointAtRadius(origin, a, radius)).ToList();
            var    shapes             = centers.Select(p => draw_leaf(page, p)).ToList();
            var    angles_as_formulas = angles.Select(a => a.ToString()).ToList();

            var color_formulas = colors.Select(x => new VA.Drawing.ColorRGB(x).ToFormula()).ToList();

            var shapeids = shapes.Select(s => s.ID16).ToList();

            var update = new VA.ShapeSheet.Update();
            var format = new VA.Shapes.FormatCells();
            var xfrm   = new VA.Shapes.XFormCells();

            foreach (int i in Enumerable.Range(0, shapeids.Count))
            {
                short shapeid = shapeids[i];

                xfrm.Angle              = angles_as_formulas[i];
                format.FillForegnd      = color_formulas[i];
                format.LineWeight       = 0;
                format.LinePattern      = 0;
                format.FillForegndTrans = 0.5;

                update.SetFormulas(shapeid, xfrm);
                update.SetFormulas(shapeid, format);
            }

            update.Execute(page);
            VA.Pages.PageHelper.ResizeToFitContents(page, new VA.Drawing.Size(1.0, 1.0));
        }
        public static void Spirograph()
        {
            var page = SampleEnvironment.Application.ActiveDocument.Pages.Add();
            page.Name = "Spirograph";

            var colors = new[]
                    {
                        0xf26420, 0xf7931c, 0xfec20d, 0xfff200, 
                        0xcada28, 0x8cc63e, 0x6c9d30, 0x288f39,
                        0x006f3a, 0x006f71, 0x008eb0, 0x00adee, 
                        0x008ed3, 0x0071bb, 0x0053a6, 0x2e3091, 
                        0x5b57a6, 0x652d91, 0x92278e, 0xbd198c, 
                        0xec008b, 0xec1c23, 0xc1272c, 0x981a1e
                    };

            var origin = new VA.Drawing.Point(4, 4);
            double radius = 3.0;
            int numpoints = colors.Length;
            double angle_step = (System.Math.PI*2/numpoints);
            var angles = Enumerable.Range(0, numpoints).Select(i => i*angle_step).ToList();
            var centers = angles.Select(a => PlaygroundSamples.GetPointAtRadius(origin, a, radius)).ToList();
            var shapes = centers.Select(p => PlaygroundSamples.draw_leaf(page, p)).ToList();
            var angles_as_formulas = angles.Select(a => a.ToString(CultureInfo.InvariantCulture)).ToList();

            var color_formulas = colors.Select(x => new VA.Drawing.ColorRGB(x).ToFormula()).ToList();

            var shapeids = shapes.Select(s => s.ID16).ToList();

            var update = new VA.ShapeSheet.Update();
            var format = new VA.Shapes.FormatCells();
            var xfrm = new VA.Shapes.XFormCells();

            foreach (int i in Enumerable.Range(0, shapeids.Count))
            {
                short shapeid = shapeids[i];

                xfrm.Angle = angles_as_formulas[i];
                format.FillForegnd = color_formulas[i];
                format.LineWeight = 0;
                format.LinePattern = 0;
                format.FillForegndTrans = 0.5;

                update.SetFormulas(shapeid, xfrm);
                update.SetFormulas(shapeid, format);
            }

            update.Execute(page);
            VA.Pages.PageHelper.ResizeToFitContents(page, new VA.Drawing.Size(1.0, 1.0));
        }
        public static void ProgressBar()
        {
            var page_a = SampleEnvironment.Application.ActiveDocument.Pages.Add();


            // Draw some shapes
            var background = page_a.DrawRectangle(0, 0, 5, 1);
            var progress = page_a.DrawRectangle(0, 0, 1, 1);

            var background_fmt = new VA.Shapes.FormatCells();
            background_fmt.FillForegnd= "rgb(240,240,240)";
            background_fmt.LineColor = "rgb(100,100,100)";


            var progress_fmt = new VA.Shapes.FormatCells();
            progress_fmt.FillForegnd = "rgb(100,150,240)";
            progress_fmt.LineColor = "rgb(100,100,100)";

            // group the two shapes together
            page_a.Application.ActiveWindow.SelectAll();
            var group = page_a.Application.ActiveWindow.Selection.Group();

            // Set the progress shape update itself based on its position
            string bkname = background.NameID;
            var xform = new VA.Shapes.XFormCells();
            xform.PinX = string.Format("GUARD({0}!PinX-{0}!LocPinX+LocPinX)", bkname);
            xform.PinY = string.Format("GUARD({0}!PinY)", bkname);
            xform.Width = string.Format("GUARD({0}!Width*(PAGENUMBER()/PAGECOUNT()))", bkname);
            xform.Height = string.Format("GUARD({0}!Height)", bkname); 

            var update = new VA.ShapeSheet.Update();
            update.SetFormulas(progress.ID16, xform);
            update.SetFormulas(progress.ID16, background_fmt);
            update.SetFormulas(progress.ID16, progress_fmt);
            update.Execute(page_a);

            var markup1 = new VA.Text.Markup.TextElement();
            markup1.AddField(VA.Text.Markup.FieldConstants.PageName);
            markup1.AddText(" (");
            markup1.AddField(VA.Text.Markup.FieldConstants.PageNumber);
            markup1.AddText(" of ");
            markup1.AddField(VA.Text.Markup.FieldConstants.NumberOfPages);
            markup1.AddText(") ");
            markup1.SetText(group);
        }
Example #10
0
        public void Set(IList <IVisio.Shape> target_shapes, VA.Shapes.FormatCells format)
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes(target_shapes);

            if (shapes.Count < 1)
            {
                return;
            }

            var update   = new VA.ShapeSheet.Update();
            var shapeids = shapes.Select(s => s.ID).ToList();

            foreach (int shapeid in shapeids)
            {
                update.SetFormulas((short)shapeid, format);
            }

            update.Execute(this.Client.VisioApplication.ActivePage);
        }
Example #11
0
        private void buttonSetFillGradient_Click(object sender, System.EventArgs e)
        {
            var client    = VisioPowerToolsAddIn.Client;
            var selection = client.Selection.Get();

            if (selection.Count < 1)
            {
                return;
            }

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

            format.FillPattern          = (int)this.fillGradient1.FillDef.FillPattern;
            format.FillForegnd          = VA.Convert.ColorToFormulaRGB(this.fillGradient1.FillDef.ForegroundColor);
            format.FillBkgnd            = VA.Convert.ColorToFormulaRGB(this.fillGradient1.FillDef.BackgroundColor);
            format.FillForegndTrans     = this.fillGradient1.FillDef.ForegroundTransparency / 100.0;
            format.FillBkgndTrans       = this.fillGradient1.FillDef.BackgroundTransparency / 100.0;
            format.ShdwPattern          = (int)this.fillGradient1.ShadowDef.FillPattern;
            format.ShdwForegnd          = VA.Convert.ColorToFormulaRGB(this.fillGradient1.ShadowDef.ForegroundColor);
            format.ShdwBkgnd            = VA.Convert.ColorToFormulaRGB(this.fillGradient1.ShadowDef.BackgroundColor);
            format.ShdwForegndTrans     = this.fillGradient1.ShadowDef.ForegroundTransparency / 100.0;
            format.ShdwBkgndTrans       = this.fillGradient1.ShadowDef.BackgroundTransparency / 100.0;
            format.ShapeShdwOffsetX     = 0.0;
            format.ShapeShdwOffsetY     = 0.0;
            format.ShapeShdwScaleFactor = 1.0;
            format.ShapeShdwType        = 5;


            var update   = new VA.ShapeSheet.Update();
            var shapes   = client.Selection.GetShapes().ToList();
            var shapeids = shapes.Select(s => s.ID).ToList();

            foreach (int shapeid in shapeids)
            {
                update.SetFormulas((short)shapeid, format);
            }

            update.Execute(client.VisioApplication.ActivePage);
        }
        private void buttonSetFillGradient_Click(object sender, System.EventArgs e)
        {
            var client = VisioPowerToolsAddIn.Client;
            var selection = client.Selection.Get();
            if (selection.Count < 1)
            {
                return;
            }

            var format = new VA.Shapes.FormatCells();
            format.FillPattern = (int) this.fillGradient1.FillDef.FillPattern;
            format.FillForegnd= VA.Convert.ColorToFormulaRGB(this.fillGradient1.FillDef.ForegroundColor);
            format.FillBkgnd= VA.Convert.ColorToFormulaRGB(this.fillGradient1.FillDef.BackgroundColor);
            format.FillForegndTrans= this.fillGradient1.FillDef.ForegroundTransparency/100.0;
            format.FillBkgndTrans= this.fillGradient1.FillDef.BackgroundTransparency / 100.0;
            format.ShdwPattern= (int) this.fillGradient1.ShadowDef.FillPattern;
            format.ShdwForegnd= VA.Convert.ColorToFormulaRGB(this.fillGradient1.ShadowDef.ForegroundColor);
            format.ShdwBkgnd = VA.Convert.ColorToFormulaRGB(this.fillGradient1.ShadowDef.BackgroundColor);
            format.ShdwForegndTrans = this.fillGradient1.ShadowDef.ForegroundTransparency/100.0;
            format.ShdwBkgndTrans= this.fillGradient1.ShadowDef.BackgroundTransparency/100.0;
            format.ShapeShdwOffsetX = 0.0;
            format.ShapeShdwOffsetY = 0.0;
            format.ShapeShdwScaleFactor = 1.0;
            format.ShapeShdwType= 5;

            var update = new VA.ShapeSheet.Update();
            var shapes = client.Selection.GetShapes().ToList();
            var shapeids = shapes.Select(s => s.ID).ToList();

            foreach (int shapeid in shapeids)
            {
                update.SetFormulas((short)shapeid,format);
            }

            update.Execute(client.VisioApplication.ActivePage);
        }
        public static void ColorGrid()
        {
            // Draws a grid rectangles and then formats the shapes
            // with different colors

            // Demonstrates:
            // How use the GridLayout object to quickly drop a grid
            // How to use ShapeFormatCells to apply formatting to shapes
            // How UpdateBase can be used to modfiy multiple shapes at once

            int[] colors =
            {
                0x0A3B76, 0x4395D1, 0x99D9EA, 0x0D686B, 0x00A99D, 0x7ACCC8, 0x82CA9C,
                0x74A402,
                0xC4DF9B, 0xD9D56F, 0xFFF468, 0xFFF799, 0xFFC20E, 0xEB6119, 0xFBAF5D,
                0xE57300, 0xC14000, 0xB82832, 0xD85171, 0xFEDFEC, 0x563F7F, 0xA186BE,
                0xD9CFE5
            };

            const int num_cols = 5;
            const int num_rows = 5;

            var page = SampleEnvironment.Application.ActiveDocument.Pages.Add();

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

            SampleEnvironment.SetPageSize(page, page_size);

            var stencil = SampleEnvironment.Application.Documents.OpenStencil("basic_u.vss");
            var master  = stencil.Masters["Rectangle"];

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

            layout.Origin       = new VA.Drawing.Point(0, 0);
            layout.CellSpacing  = new VA.Drawing.Size(0, 0);
            layout.RowDirection = VA.Models.Grid.RowDirection.BottomToTop;

            layout.PerformLayout();
            layout.Render(page);

            var fmtcells = new VA.Shapes.FormatCells();
            int i        = 0;
            var update   = new VA.ShapeSheet.Update();

            foreach (var node in layout.Nodes)
            {
                var shapeid     = node.ShapeID;
                int color_index = i % colors.Length;
                var color       = colors[color_index];
                fmtcells.FillForegnd = new ColorRGB(color).ToFormula();
                fmtcells.LinePattern = 0;
                fmtcells.LineWeight  = 0;
                update.SetFormulas(shapeid, fmtcells);
                i++;
            }

            update.Execute(page);

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

            page.ResizeToFitContents(bordersize);
        }
        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 VA.Drawing.ColorRGB(0xffdddd);
            var color2 = new VA.Drawing.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);
        }
Example #15
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 VA.Drawing.ColorRGB(0xffdddd);
            var color2 = new VA.Drawing.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);
        }