Ejemplo n.º 1
0
        protected override void ProcessRecord()
        {
            var targetshapes             = new VisioScripting.TargetShapes(this.Shapes);
            var dicof_shape_to_udcelldic = this.Client.UserDefinedCell.GetUserDefinedCells(targetshapes, CellValueType.Formula);

            if (this.GetCells)
            {
                this.WriteObject(dicof_shape_to_udcelldic);
                return;
            }

            foreach (var shape_udcelldic_pair in dicof_shape_to_udcelldic)
            {
                var shape     = shape_udcelldic_pair.Key;
                var udcelldic = shape_udcelldic_pair.Value;
                int shapeid   = shape.ID;
                foreach (var udcellname_udcellcells_pair in udcelldic)
                {
                    string udcellname    = udcellname_udcellcells_pair.Key;
                    var    udcellcells   = udcellname_udcellcells_pair.Value;
                    string udcell_value  = udcellcells.Value.ToString();
                    string udcell_prompt = udcellcells.Prompt.ToString();

                    var udcell_obj = new VisioPowerShell.Models.UserDefinedCell(shapeid, udcellname, udcell_value, udcell_prompt);
                    this.WriteObject(udcell_obj);
                }
            }

            this.WriteObject(dicof_shape_to_udcelldic);
        }
Ejemplo n.º 2
0
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shapes);

            var lockcells = new VisioAutomation.Shapes.LockCells();


            lockcells.Aspect          = this.Aspect ? "1": null;
            lockcells.Begin           = this.Begin ? "1" : null;
            lockcells.CalcWH          = this.CalcWH ? "1" : null;
            lockcells.Crop            = this.Crop ? "1" : null;
            lockcells.CustProp        = this.CustProp ? "1" : null;
            lockcells.Delete          = this.Delete ? "1" : null;
            lockcells.End             = this.End ? "1" : null;
            lockcells.Format          = this.Format ? "1" : null;
            lockcells.FromGroupFormat = this.FromGroupFormat ? "1" : null;
            lockcells.Group           = this.Group ? "1" : null;
            lockcells.Height          = this.Height ? "1" : null;
            lockcells.MoveX           = this.MoveX ? "1" : null;
            lockcells.MoveY           = this.MoveY ? "1" : null;
            lockcells.Rotate          = this.Rotate ? "1" : null;
            lockcells.Select          = this.Select ? "1" : null;
            lockcells.TextEdit        = this.TextEdit ? "1" : null;
            lockcells.ThemeColors     = this.ThemeColors ? "1" : null;
            lockcells.ThemeEffects    = this.ThemeEffects ? "1" : null;
            lockcells.VertexEdit      = this.VertexEdit ? "1" : null;
            lockcells.Width           = this.Width ? "1" : null;

            this.Client.Lock.SetLockCells(targetshapes, lockcells);
        }
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shape);

            targetshapes.ResolveToSelection(this.Client);

            string ext = System.IO.Path.GetExtension(this.Filename).ToLowerInvariant();

            if (!System.IO.File.Exists(this.Filename))
            {
                this.WriteVerbose("File already exists");
                if (this.Overwrite)
                {
                    System.IO.File.Delete(this.Filename);
                }
                else
                {
                    string msg = string.Format("File \"{0}\" already exists", this.Filename);
                    var    exc = new System.ArgumentException(msg);
                    throw exc;
                }
            }

            if (_static_html_extensions.Contains(ext))
            {
                this.Client.Export.ExportSelectionToHtml(VisioScripting.TargetSelection.Auto, this.Filename);
            }
            else
            {
                this.Client.Export.ExportSelectionToImage(VisioScripting.TargetSelection.Auto, this.Filename);
            }
        }
        protected override void ProcessRecord()
        {
            var targetshapes         = new VisioScripting.TargetShapes(this.Shapes);
            var dicof_shape_to_cpdic = this.Client.CustomProperty.GetCustomProperties(targetshapes);

            if (this.GetCells)
            {
                this.WriteObject(dicof_shape_to_cpdic);
                return;
            }

            foreach (var shape_cppdic_pair in dicof_shape_to_cpdic)
            {
                var shape   = shape_cppdic_pair.Key;
                var cpdic   = shape_cppdic_pair.Value;
                int shapeid = shape.ID;
                foreach (var cpname_cpcells_pair in cpdic)
                {
                    string cpname  = cpname_cpcells_pair.Key;
                    var    cpcells = cpname_cpcells_pair.Value;
                    var    cp_obj  = new CustomProperty(shapeid, cpname, cpcells);
                    this.WriteObject(cp_obj);
                }
            }
        }
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shape);
            var dic          = this.Client.Lock.GetLockCells(targetshapes, CellValueType.Formula);

            this.WriteObject(dic, true);
        }
Ejemplo n.º 6
0
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shape);
            var dicof_shape_to_hyperlinks = this.Client.Hyperlink.GetHyperlinks(targetshapes, CellValueType.Formula);

            this.WriteObject(dicof_shape_to_hyperlinks);
        }
Ejemplo n.º 7
0
        protected override void ProcessRecord()
        {
            var targetshapes  = new VisioScripting.TargetShapes(this.Shape);
            var listof_string = this.Client.Text.GetShapeText(targetshapes);

            this.WriteObject(listof_string);
        }
        public void Scripting_ShapeSheet_SetNoShapes()
        {
            var client = this.GetScriptingClient();

            client.Document.NewDocument();
            client.Page.NewPage(VisioScripting.TargetDocument.Auto, new VA.Geometry.Size(4, 4), false);

            var s1 = client.Draw.DrawRectangle(VisioScripting.TargetPage.Auto, 1, 1, 1.25, 1.5);
            var s2 = client.Draw.DrawRectangle(VisioScripting.TargetPage.Auto, 2, 3, 2.5, 3.5);
            var s3 = client.Draw.DrawRectangle(VisioScripting.TargetPage.Auto, 4.5, 2.5, 6, 3.5);

            client.Selection.SelectNone(VisioScripting.TargetWindow.Auto);

            var targetshapes   = new VisioScripting.TargetShapes(s1, s2, s3);
            var targetshapeids = targetshapes.ToShapeIDs();
            var writer         = client.ShapeSheet.GetWriterForPage(VisioScripting.TargetPage.Auto);

            foreach (var shapeid in targetshapeids)
            {
                writer.SetFormula((short)shapeid, VA.ShapeSheet.SrcConstants.XFormPinX, "1.0");
            }

            writer.Commit();

            client.Document.CloseDocument(VisioScripting.TargetDocuments.Auto);
        }
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shapes);

            var dic = this.Client.ConnectionPoint.GetConnectionPoints(targetshapes);

            if (this.GetCells)
            {
                this.WriteObject(dic);
                return;
            }

            foreach (var shape_points in dic)
            {
                var shape  = shape_points.Key;
                var points = shape_points.Value;

                int shapeid = shape.ID;

                foreach (var point_cells in points)
                {
                    var cp = new Models.ConnectionPoint(shapeid, point_cells);
                    this.WriteObject(cp);
                }
            }
        }
Ejemplo n.º 10
0
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shape);

            targetshapes.ResolveToSelection(this.Client);

            if (this.NudgeX != 0.0 || this.NudgeY != 0.0)
            {
                this.Client.Arrange.Nudge(VisioScripting.TargetSelection.Auto, this.NudgeX, this.NudgeY);
            }

            if (this.DistributeHorizontal)
            {
                this.Client.Arrange.DistributeOnAxis(VisioScripting.TargetSelection.Auto, VisioScripting.Models.Axis.XAxis);
            }

            if (this.DistributeVertical)
            {
                this.Client.Arrange.DistributeOnAxis(VisioScripting.TargetSelection.Auto, VisioScripting.Models.Axis.YAxis);
            }

            if (this.AlignVertical.HasValue)
            {
                this.Client.Arrange.AlignVertical(VisioScripting.TargetSelection.Auto, this.AlignVertical.Value);
            }

            if (this.AlignHorizontal.HasValue)
            {
                this.Client.Arrange.AlignHorizontal(VisioScripting.TargetSelection.Auto, this.AlignHorizontal.Value);
            }
        }
Ejemplo n.º 11
0
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shape);
            var type         = VASS.CellValueType.Formula;
            var dic_shape_to_listofcontrolscells = this.Client.Control.GetControls(targetshapes, type);

            this.WriteObject(dic_shape_to_listofcontrolscells);
        }
Ejemplo n.º 12
0
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shape);
            targetshapes.ResolveToSelection(this.Client);

            var group = this.Client.Grouping.Group(VisioScripting.TargetSelection.Auto);
            this.WriteObject(group);
        }
        protected override void ProcessRecord()
        {
            var targetshapes             = new VisioScripting.TargetShapes(this.Shape);
            var type                     = VASS.CellValueType.Formula;
            var dicof_shape_to_udcelldic = this.Client.UserDefinedCell.GetUserDefinedCellsAsShapeDictionary(targetshapes, type);

            this.WriteObject(dicof_shape_to_udcelldic);
        }
        protected override void ProcessRecord()
        {
            var targetshapes         = new VisioScripting.TargetShapes(this.Shape);
            var type                 = VASS.CellValueType.Formula;
            var dicof_shape_to_cpdic = this.Client.CustomProperty.GetCustomPropertiesAsShapeDictionary(targetshapes, type);

            this.WriteObject(dicof_shape_to_cpdic);
        }
Ejemplo n.º 15
0
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shape);

            targetshapes.ResolveToSelection(this.Client);

            this.Client.Selection.DuplicateShapes(VisioScripting.TargetSelection.Auto);
        }
        private void _set_from_parameters()
        {
            // this will set .Value and automatically set
            // .Type as needed.
            var cp = _create_cust_prop_from_object(this.Value);

            // The user can override .Type if desired
            if (this.Type >= 0)
            {
                cp.Type = this.Type;
            }

            if (this.Label != null)
            {
                cp.Label = this.Label;
            }

            if (this.Format != null)
            {
                cp.Format = this.Format;
            }

            if (this.Prompt != null)
            {
                cp.Prompt = this.Prompt;
            }

            if (this.LangId >= 0)
            {
                cp.LangID = this.LangId;
            }

            if (this.SortKey >= 0)
            {
                cp.SortKey = this.SortKey;
            }

            if (this.Ask >= 0)
            {
                cp.Ask = this.Ask;
            }

            if (this.Calendar >= 0)
            {
                cp.Calendar = this.Calendar;
            }

            if (this.Invisible >= 0)
            {
                cp.Invisible = this.Invisible;
            }

            var targetshapes = new VisioScripting.TargetShapes(this.Shapes);

            this.Client.CustomProperty.SetCustomProperty(targetshapes, this.Name, cp);
        }
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shapes);
            var udcell       = new VisioScripting.Models.UserDefinedCell(this.Name, this.Value);

            if (this.Prompt != null)
            {
                udcell.Cells.Prompt = this.Prompt;
            }

            this.Client.UserDefinedCell.SetUserDefinedCell(targetshapes, udcell);
        }
Ejemplo n.º 18
0
        public void Scripting_Controls_Scenarios()
        {
            var client = this.GetScriptingClient();

            client.Document.NewDocument();
            client.Page.NewPage(new VisioAutomation.Geometry.Size(4, 4), false);

            var s1 = client.Draw.DrawRectangle(1, 1, 1.5, 1.5);
            var s2 = client.Draw.DrawRectangle(2, 3, 2.5, 3.5);
            var s3 = client.Draw.DrawRectangle(1.5, 3.5, 2, 4.0);

            client.Selection.SelectNone();
            client.Selection.SelectShapesById(s1);
            client.Selection.SelectShapesById(s2);
            client.Selection.SelectShapesById(s3);

            var targetshapes = new VisioScripting.TargetShapes();

            var controls0      = client.Control.GetControls(targetshapes, CellValueType.Formula);
            int found_controls = controls0.Count;

            Assert.AreEqual(3, controls0.Count);
            Assert.AreEqual(0, controls0[s1].Count);
            Assert.AreEqual(0, controls0[s2].Count);
            Assert.AreEqual(0, controls0[s3].Count);

            var ctrl = new ControlCells();

            ctrl.X = "Width*0.5";
            ctrl.Y = "0";
            client.Control.AddControlToShapes(targetshapes, ctrl);

            var controls1 = client.Control.GetControls(targetshapes, CellValueType.Formula);

            Assert.AreEqual(3, controls1.Count);
            Assert.AreEqual(1, controls1[s1].Count);
            Assert.AreEqual(1, controls1[s2].Count);
            Assert.AreEqual(1, controls1[s3].Count);

            client.Control.DeleteControlWithIndex(targetshapes, 0);
            var controls2 = client.Control.GetControls(targetshapes, CellValueType.Formula);

            Assert.AreEqual(3, controls0.Count);
            Assert.AreEqual(0, controls2[s1].Count);
            Assert.AreEqual(0, controls2[s2].Count);
            Assert.AreEqual(0, controls2[s3].Count);

            var targetdoc = new VisioScripting.TargetDocument();

            client.Document.CloseDocument(targetdoc, true);
        }
Ejemplo n.º 19
0
 public void DeleteShapes(VisioScripting.TargetShapes targetshapes)
 {
     if (targetshapes.Resolved)
     {
         foreach (var shape in targetshapes.Shapes)
         {
             shape.Delete();
         }
     }
     else
     {
         this._client.Selection.DeleteShapes(VisioScripting.TargetSelection.Auto);
     }
 }
        public void Scripting_Hyperlinks_Scenarios()
        {
            var client = this.GetScriptingClient();

            client.Document.NewDocument();
            client.Page.NewPage(new VisioAutomation.Geometry.Size(4, 4), false);

            var s1 = client.Draw.DrawRectangle(1, 1, 1.5, 1.5);
            var s2 = client.Draw.DrawRectangle(2, 3, 2.5, 3.5);
            var s3 = client.Draw.DrawRectangle(1.5, 3.5, 2, 4.0);

            client.Selection.SelectNone();
            client.Selection.SelectShapesById(s1);
            client.Selection.SelectShapesById(s2);
            client.Selection.SelectShapesById(s3);

            var targetshapes = new VisioScripting.TargetShapes();

            var hyperlinks0 = client.Hyperlink.GetHyperlinks(targetshapes, VASS.CellValueType.Formula);

            Assert.AreEqual(3, hyperlinks0.Count);
            Assert.AreEqual(0, hyperlinks0[s1].Count);
            Assert.AreEqual(0, hyperlinks0[s2].Count);
            Assert.AreEqual(0, hyperlinks0[s3].Count);

            var hyperlink = new VA.Shapes.HyperlinkCells();

            hyperlink.Address = "http://www.microsoft.com";
            client.Hyperlink.AddHyperlink(targetshapes, hyperlink);

            var hyperlinks1 = client.Hyperlink.GetHyperlinks(targetshapes, VASS.CellValueType.Formula);

            Assert.AreEqual(3, hyperlinks1.Count);
            Assert.AreEqual(1, hyperlinks1[s1].Count);
            Assert.AreEqual(1, hyperlinks1[s2].Count);
            Assert.AreEqual(1, hyperlinks1[s3].Count);

            client.Hyperlink.DeleteHyperlinkAtIndex(targetshapes, 0);
            var hyperlinks2 = client.Hyperlink.GetHyperlinks(targetshapes, VASS.CellValueType.Formula);

            Assert.AreEqual(3, hyperlinks0.Count);
            Assert.AreEqual(0, hyperlinks2[s1].Count);
            Assert.AreEqual(0, hyperlinks2[s2].Count);
            Assert.AreEqual(0, hyperlinks2[s3].Count);

            var targetdoc = new VisioScripting.TargetDocument();

            client.Document.CloseDocument(targetdoc, true);
        }
Ejemplo n.º 21
0
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shape).ResolveToShapes(this.Client);

            if (targetshapes.Shapes.Count < 1)
            {
                return;
            }


            var shapeids      = VisioAutomation.ShapeIDPairs.FromShapes(targetshapes.Shapes).Select(i => i.ShapeID).ToList();
            var page          = targetshapes.Shapes[0].ContainingPage;
            var list_shapedim = VisioScripting.Models.ShapeDimensions.Get_ShapeDimensions(page, shapeids);

            this.WriteObject(list_shapedim, true);
        }
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shape);
            var udcell       = new VisioAutomation.Shapes.UserDefinedCellCells();

            if (this.Value != null)
            {
                udcell.Value = this.Value;
            }
            if (this.Prompt != null)
            {
                udcell.Prompt = this.Prompt;
            }

            this.Client.UserDefinedCell.SetUserDefinedCell(targetshapes, this.Name, udcell);
        }
Ejemplo n.º 23
0
        protected override void ProcessRecord()
        {
            if (this.Cells == null)
            {
                return;
            }

            if (this.Cells.Length < 1)
            {
                return;
            }

            var target_shapes = this.Shapes ?? this.Client.Selection.GetShapesInSelection();

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

            var targetshapes   = new VisioScripting.TargetShapes(target_shapes).Resolve(this.Client);
            var targetshapeids = targetshapes.ToShapeIDs();

            var writer = new VisioAutomation.ShapeSheet.Writers.SidSrcWriter();

            writer.BlastGuards  = this.BlastGuards;
            writer.TestCircular = this.TestCircular;

            foreach (int i in Enumerable.Range(0, targetshapeids.Count))
            {
                var shapeid     = targetshapeids[i];
                var shape_cells = this.Cells[i % this.Cells.Length];
                shape_cells.Apply(writer, (short)shapeid);
            }

            var surface = this.Client.ShapeSheet.GetShapeSheetSurface();

            this.Client.Output.WriteVerbose("BlastGuards: {0}", this.BlastGuards);
            this.Client.Output.WriteVerbose("TestCircular: {0}", this.TestCircular);
            this.Client.Output.WriteVerbose("Number of Shapes : {0}", targetshapeids.Count);

            using (var undoscope = this.Client.Undo.NewUndoScope(nameof(SetVisioShapeCells)))
            {
                this.Client.Output.WriteVerbose("Start Update");
                writer.CommitFormulas(surface);
                this.Client.Output.WriteVerbose("End Update");
            }
        }
Ejemplo n.º 24
0
        protected override void ProcessRecord()
        {
            var ctrl = new ControlCells();

            ctrl.XDynamics = this.XDynamics;
            ctrl.YDynamics = this.YDynamics;
            ctrl.XBehavior = this.XBehavior;
            ctrl.YBehavior = this.YBehavior;
            ctrl.X         = this.X;
            ctrl.Y         = this.Y;
            ctrl.CanGlue   = this.CanGlue;
            ctrl.Tip       = this.Tip;

            var targetshapes = new VisioScripting.TargetShapes(this.Shapes);

            this.Client.Control.AddControlToShapes(targetshapes, ctrl);
        }
Ejemplo n.º 25
0
        public void Scripting_Distribute_With_Spacing()
        {
            var client   = this.GetScriptingClient();
            var pagesize = new VA.Geometry.Size(4, 4);

            client.Document.NewDocument();
            client.Page.NewPage(pagesize, false);

            var size1 = new VA.Geometry.Size(0.5, 0.5);
            var size2 = new VA.Geometry.Size(1.0, 1.0);
            var size3 = new VA.Geometry.Size(1.5, 1.5);

            var r1 = new VA.Geometry.Rectangle(new VA.Geometry.Point(1, 1), size1);
            var r2 = new VA.Geometry.Rectangle(new VA.Geometry.Point(2, 2), size2);
            var r3 = new VA.Geometry.Rectangle(new VA.Geometry.Point(4, 4), size3);

            var s1 = client.Draw.DrawRectangle(r1);
            var s2 = client.Draw.DrawRectangle(r2);
            var s3 = client.Draw.DrawRectangle(r3);

            client.Selection.SelectNone();
            client.Selection.SelectShapesById(s1);
            client.Selection.SelectShapesById(s2);
            client.Selection.SelectShapesById(s3);

            var targetshapes = new VisioScripting.TargetShapes();

            client.Distribute.DistributeSelectionOnAxis(targetshapes, VisioScripting.Models.Axis.XAxis, 0.25);
            client.Distribute.DistributeSelectionOnAxis(targetshapes, VisioScripting.Models.Axis.YAxis, 1.0);

            var shapes        = new[] { s1, s2, s3 };
            var shapeids      = shapes.Select(s => (int)s.ID16).ToList();
            var out_xfrms     = VisioAutomation.Shapes.ShapeXFormCells.GetCells(client.Page.GetActivePage(), shapeids, VA.ShapeSheet.CellValueType.Result);
            var out_positions = out_xfrms.Select(xfrm => TestExtensions.ToPoint(xfrm.PinX.Value, xfrm.PinY.Value)).ToArray();

            Assert.AreEqual(1.25, out_positions[0].X);
            Assert.AreEqual(1.25, out_positions[0].Y);
            Assert.AreEqual(2.25, out_positions[1].X);
            Assert.AreEqual(3.00, out_positions[1].Y);
            Assert.AreEqual(3.75, out_positions[2].X);
            Assert.AreEqual(5.25, out_positions[2].Y);

            var targetdoc = new VisioScripting.TargetDocument();

            client.Document.CloseDocument(targetdoc, true);
        }
Ejemplo n.º 26
0
        public void Scripting_Shape_Text_Set()
        {
            var page1   = this.GetNewPage();
            var stencil = "basic_u.vss";

            short flags       = (short)IVisio.VisOpenSaveArgs.visOpenRO | (short)IVisio.VisOpenSaveArgs.visOpenDocked;
            var   app         = page1.Application;
            var   documents   = app.Documents;
            var   stencil_doc = documents.OpenEx(stencil, flags);

            var masters1 = stencil_doc.Masters;
            var masters  = new[] { masters1["Rounded Rectangle"], masters1["Ellipse"] };
            var point0   = new VA.Geometry.Point(1, 2);
            var point1   = new VA.Geometry.Point(3, 4);
            var points   = new[] { point0, point1 };

            Assert.AreEqual(0, page1.Shapes.Count);

            var shapeids = page1.DropManyU(masters, points);

            Assert.AreEqual(2, page1.Shapes.Count);
            Assert.AreEqual(2, shapeids.Length);

            var shapes = VisioAutomation.Shapes.ShapeHelper.GetShapesFromIDs(page1.Shapes, shapeids);
            var client = this.GetScriptingClient();
            var names  = new[] { "TestName", "TestName2" };
            var texts  = names.ToArray();

            var targetshapes = new VisioScripting.TargetShapes(shapes);

            client.Text.SetShapeText(targetshapes, texts);
            client.ShapeSheet.SetShapeName(targetshapes, names);

            for (int i = 0; i < page1.Shapes.Count; i++)
            {
                var shape = shapes[i];
                var name  = names[i];
                var text  = texts[i];
                Assert.AreEqual(name, shape.Name);
                Assert.AreEqual(text, shape.Text);
            }

            page1.Delete(0);
        }
        protected override void ProcessRecord()
        {
            var hlink = new VisioAutomation.Shapes.HyperlinkCells();

            hlink.Address     = this.Address;
            hlink.Description = this.Description;
            hlink.ExtraInfo   = this.ExtraInfo;
            hlink.Frame       = this.Frame;
            hlink.SortKey     = this.SortKey;

            hlink.SubAddress = this.SubAddress;

            hlink.Default   = this.Default;
            hlink.NewWindow = this.NewWindow;
            hlink.Invisible = this.Invisible;

            var targetshapes = new VisioScripting.TargetShapes(this.Shapes);

            this.Client.Hyperlink.AddHyperlink(targetshapes, hlink);
        }
        protected override void ProcessRecord()
        {
            var valuetype = this.Results
                ? VisioAutomation.ShapeSheet.CellValueType.Result
                : VisioAutomation.ShapeSheet.CellValueType.Formula;

            var target_shapes = new VisioScripting.TargetShapes(this.Shape).ResolveToShapes(this.Client);

            if (target_shapes.Shapes.Count < 1)
            {
                return;
            }

            var template = new VisioPowerShell.Models.ShapeCells();

            var dicof_name_to_cell = VisioPowerShell.Internal.NamedSrcDictionary.FromCells(template);

            var desired_cells = this.Cell ?? dicof_name_to_cell.Keys.ToArray();

            var query     = _create_query(dicof_name_to_cell, desired_cells);
            var page      = target_shapes.Shapes[0].ContainingPage;
            var surface   = new VisioAutomation.SurfaceTarget(page);
            var shapeids  = target_shapes.Shapes.Select(s => s.ID).ToList();
            var datatable = VisioPowerShell.Internal.DataTableHelpers.QueryToDataTable(query, valuetype, this.ResultType, shapeids, surface);

            // Annotate the returned datatable to disambiguate rows
            var shapeid_col      = datatable.Columns.Add("ShapeID", typeof(int));
            int shapeid_colindex = 0;

            shapeid_col.SetOrdinal(shapeid_colindex);
            foreach (int row_index in Enumerable.Range(0, shapeids.Count))
            {
                datatable.Rows[row_index][shapeid_colindex] = shapeids[row_index];
                datatable.Rows[row_index][shapeid_colindex] = shapeids[row_index];
            }

            this.WriteObject(datatable);
        }
Ejemplo n.º 29
0
        public void Scripting_Distribute()
        {
            var client   = this.GetScriptingClient();
            var pagesize = new VA.Geometry.Size(4, 4);

            client.Document.NewDocument();
            client.Page.NewPage(pagesize, false);

            var size1 = new VA.Geometry.Size(0.5, 0.5);
            var size2 = new VA.Geometry.Size(1.0, 1.0);
            var size3 = new VA.Geometry.Size(1.5, 1.5);

            var r1 = new VA.Geometry.Rectangle(new VA.Geometry.Point(1, 1), size1);
            var r2 = new VA.Geometry.Rectangle(new VA.Geometry.Point(2, 2), size2);
            var r3 = new VA.Geometry.Rectangle(new VA.Geometry.Point(4, 4), size3);

            var s1 = client.Draw.DrawRectangle(r1);
            var s2 = client.Draw.DrawRectangle(r2);
            var s3 = client.Draw.DrawRectangle(r3);

            client.Selection.SelectNone();
            client.Selection.SelectShapesById(s1);
            client.Selection.SelectShapesById(s2);
            client.Selection.SelectShapesById(s3);

            var targetshapes = new VisioScripting.TargetShapes();

            client.Distribute.DistributeShapesHorizontal(targetshapes, VisioScripting.Models.AlignmentHorizontal.Center);

            var shapes   = new[] { s1, s2, s3 };
            var shapeids = shapes.Select(s => (int)s.ID16).ToList();

            VisioAutomation.Shapes.ShapeXFormCells.GetCells(client.Page.GetActivePage(), shapeids, VA.ShapeSheet.CellValueType.Formula);

            var targetdoc = new VisioScripting.TargetDocument();

            client.Document.CloseDocument(targetdoc, true);
        }
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shapes);
            var dicof_shape_to_hyperlinks = this.Client.Hyperlink.GetHyperlinks(targetshapes, CellValueType.Formula);

            if (this.GetCells)
            {
                this.WriteObject(dicof_shape_to_hyperlinks);
                return;
            }

            foreach (var shape_hyperlinks_pair in dicof_shape_to_hyperlinks)
            {
                var shape      = shape_hyperlinks_pair.Key;
                var hyperlinks = shape_hyperlinks_pair.Value;
                int shapeid    = shape.ID;

                foreach (var hyperlink in hyperlinks)
                {
                    var hl_formulas = new VisioPowerShell.Models.Hyperlink();

                    hl_formulas.ShapeID = shapeid;

                    hl_formulas.Address     = hyperlink.Address.Value;
                    hl_formulas.Default     = hyperlink.Default.Value;
                    hl_formulas.Description = hyperlink.Description.Value;
                    hl_formulas.ExtraInfo   = hyperlink.ExtraInfo.Value;
                    hl_formulas.Frame       = hyperlink.Frame.Value;
                    hl_formulas.Invisible   = hyperlink.Invisible.Value;
                    hl_formulas.NewWindow   = hyperlink.NewWindow.Value;
                    hl_formulas.SortKey     = hyperlink.SortKey.Value;
                    hl_formulas.SubAddress  = hyperlink.SubAddress.Value;

                    this.WriteObject(hl_formulas);
                }
            }
        }