Ejemplo n.º 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.Geometry.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    culture            = CultureInfo.InvariantCulture;
            var    angles_as_formulas = angles.Select(a => a.ToString(culture)).ToList();

            var color_formulas = colors.Select(x => new VA.Models.Color.ColorRgb(x).ToFormula()).ToList();

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

            var writer = new SidSrcWriter();
            var format = new VA.Shapes.ShapeFormatCells();
            var xfrm   = new VA.Shapes.ShapeXFormCells();

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

                xfrm.Angle                        = angles_as_formulas[i];
                format.FillForeground             = color_formulas[i];
                format.LineWeight                 = 0;
                format.LinePattern                = 0;
                format.FillForegroundTransparency = 0.5;

                writer.SetValues(shapeid, xfrm);
                writer.SetValues(shapeid, format);
            }

            writer.Commit(page, VA.ShapeSheet.CellValueType.Formula);

            page.ResizeToFitContents(new VA.Geometry.Size(1.0, 1.0));
        }
Ejemplo n.º 2
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.ShapeFormatCells();

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


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

            progress_fmt.FillForeground = "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    xfrm   = new VA.Shapes.ShapeXFormCells();

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

            var writer = new SidSrcWriter();

            xfrm.SetFormulas(writer, progress.ID16);
            background_fmt.SetFormulas(writer, progress.ID16);
            progress_fmt.SetFormulas(writer, progress.ID16);

            writer.Commit(page_a);

            var markup1 = new VisioAutomation.Models.Text.Element();

            markup1.AddField(VisioAutomation.Models.Text.FieldConstants.PageName);
            markup1.AddText(" (");
            markup1.AddField(VisioAutomation.Models.Text.FieldConstants.PageNumber);
            markup1.AddText(" of ");
            markup1.AddField(VisioAutomation.Models.Text.FieldConstants.NumberOfPages);
            markup1.AddText(") ");
            markup1.SetText(group);
        }
Ejemplo n.º 3
0
 public static VisioAutomation.Drawing.Point GetPinPosResult(this VisioAutomation.Shapes.ShapeXFormCells xform)
 {
     return(ToPoint(xform.PinX.Result, xform.PinY.Result));
 }
Ejemplo n.º 4
0
 public static VisioAutomation.Geometry.Point GetPinPosResult(this VisioAutomation.Shapes.ShapeXFormCells xform)
 {
     return(ToPoint(xform.PinX.Value, xform.PinY.Value));
 }