Example #1
0
        private void drop_shape()
        {
            this.WriteVerbose("NoSelect: {0}", this.NoSelect);

            var points   = VisioAutomation.Geometry.Point.FromDoubles(this.Points).ToList();
            var shapeids = this.Client.Master.DropMastersOnActivePage(this.Masters, points);

            var page          = this.Client.Page.GetActivePage();
            var shape_objects = VisioAutomation.Shapes.ShapeHelper.GetShapesFromIDs(page.Shapes, shapeids);

            // If Names is not empty... assign it to the shape
            if (this.Names != null)
            {
                int up_to = System.Math.Min(shape_objects.Count, this.Names.Length);
                for (int i = 0; i < up_to; i++)
                {
                    string cur_name = this.Names[i];
                    if (cur_name != null)
                    {
                        var cur_shape = shape_objects[i];
                        cur_shape.NameU = cur_name;
                    }
                }
            }

            // If there are cells to set, then use them
            if (this.Cells != null)
            {
                var writer = new VisioAutomation.ShapeSheet.Writers.SidSrcWriter();
                writer.BlastGuards  = true;
                writer.TestCircular = true;

                for (int i = 0; i < shapeids.Count(); i++)
                {
                    var shapeid     = shapeids[i];
                    var shape_cells = this.Cells[i % this.Cells.Length];

                    shape_cells.Apply(writer, (short)shapeid);
                }

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

                using (var undoscope = this.Client.Undo.NewUndoScope(nameof(NewVisioShape) + ":CommitCells"))
                {
                    writer.CommitFormulas(surface);
                }
            }

            this.Client.Selection.SelectNone();

            if (!this.NoSelect)
            {
                // Select the Shapes
                ((SMA.Cmdlet) this).WriteVerbose("Selecting");
                this.Client.Selection.SelectShapes(shape_objects);
            }

            this.WriteObject(shape_objects, true);
        }
        protected override void ProcessRecord()
        {
            this.Client.Output.WriteVerbose("Creating a new page");
            var page = this.Client.Page.NewPage(null, false);

            if (this.Name != null)
            {
                if (this.Name.Length == 0)
                {
                    throw new System.ArgumentException("Name can't be empty");
                }

                string n = this.Name.Trim();

                if (n.Length == 0)
                {
                    throw new System.ArgumentException("Name can't be empty");
                }

                this.Client.Output.WriteVerbose("Setting page name \"{0}\"", n);
                page.NameU = n;
            }

            if (this.Width > 0 || this.Height > 0)
            {
                // width and height are used and there isn't a PageCells object
                // then create one
                this.Cells = this.Cells ?? new Models.PageCells();
                if (this.Width > 0)
                {
                    this.Cells.PageWidth = this.Width.ToString(CultureInfo.InvariantCulture);
                }
                if (this.Height > 0)
                {
                    this.Cells.PageHeight = this.Height.ToString(CultureInfo.InvariantCulture);
                }
            }

            if (this.Cells != null)
            {
                var target_pagesheet    = page.PageSheet;
                int target_pagesheet_id = target_pagesheet.ID;

                var writer = new VisioAutomation.ShapeSheet.Writers.SidSrcWriter();
                writer.BlastGuards  = true;
                writer.TestCircular = true;
                this.Cells.Apply(writer, (short)target_pagesheet_id);

                this.Client.Output.WriteVerbose("Updating Cells for new page");
                writer.CommitFormulas(page);
            }

            this.WriteObject(page);
        }
Example #3
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 targets         = new VisioScripting.Models.TargetShapes(target_shapes).ResolveShapes(this.Client);
            var target_shapeids = targets.ToShapeIDs();

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

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

            for (int i = 0; i < target_shapeids.ShapeIDs.Count; i++)
            {
                var shapeid     = target_shapeids.ShapeIDs[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}", target_shapeids.ShapeIDs.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");
            }
        }
Example #4
0
        protected override void ProcessRecord()
        {
            var targetshapes = new VisioScripting.TargetShapes(this.Shape).ResolveToShapes(this.Client);

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

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

            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))
            {
                int shapeid_index = i;
                int cells_index   = i % this.Cells.Length;

                var shapeid     = targetshapeids[shapeid_index];
                var shape_cells = this.Cells[cells_index];

                shape_cells.Apply(writer, (short)shapeid);
            }

            var page    = targetshapes.Shapes[0].ContainingPage;
            var surface = new VisioAutomation.SurfaceTarget(page);

            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");
            }
        }
        private void _drop_shape()
        {
            var targetpage = VisioScripting.TargetPage.Auto.ResolveToPage(this.Client);

            var shapeids      = this.Client.Master.DropMasters(targetpage, this.Master, this.Position);
            var shape_objects = VisioAutomation.Shapes.ShapeHelper.GetShapesFromIDs(targetpage.Page.Shapes, shapeids);

            // If there are cells to set, then use them
            if (this.Cells != null)
            {
                var writer = new VisioAutomation.ShapeSheet.Writers.SidSrcWriter();
                writer.BlastGuards  = true;
                writer.TestCircular = true;

                for (int i = 0; i < shapeids.Count(); i++)
                {
                    var shapeid     = shapeids[i];
                    var shape_cells = this.Cells[i % this.Cells.Length];

                    shape_cells.Apply(writer, (short)shapeid);
                }

                var surface = new VisioAutomation.SurfaceTarget(targetpage.Page);

                using (var undoscope = this.Client.Undo.NewUndoScope(nameof(NewVisioShape) + ":CommitCells"))
                {
                    writer.CommitFormulas(surface);
                }
            }


            // Visio does not select dropped masters by default - unlike shapes that are directly drawn
            // so force visio to select the dropped shapes

            ((SMA.Cmdlet) this).WriteVerbose("Clearing the selection");
            this.Client.Selection.SelectNone(VisioScripting.TargetWindow.Auto);
            ((SMA.Cmdlet) this).WriteVerbose("Selecting the shapes that were dropped");
            this.Client.Selection.SelectShapes(VisioScripting.TargetWindow.Auto, shape_objects);

            this.WriteObject(shape_objects, true);
        }
Example #6
0
        internal void __SetCells(Models.TargetShapes targets, VASS.CellGroups.CellGroup cells, IVisio.Page page)
        {
            targets = targets.ResolveShapes(this._client);
            var shapeids = targets.ToShapeIDs();
            var writer   = new VASS.Writers.SidSrcWriter();

            foreach (var shapeid in shapeids.ShapeIDs)
            {
                if (cells is VASS.CellGroups.CellGroup)
                {
                    var cells_mr = (VASS.CellGroups.CellGroup)cells;
                    writer.SetValues((short)shapeid, cells_mr, 0);
                }
                else
                {
                    var cells_sr = (VASS.CellGroups.CellGroup)cells;
                    writer.SetValues((short)shapeid, cells_sr);
                }
            }

            writer.CommitFormulas(page);
        }
Example #7
0
        protected override void ProcessRecord()
        {
            if (this.Cells == null)
            {
                return;
            }

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

            var target_pages = new VisioScripting.Models.TargetPages(this.Pages);

            this.Client.Output.WriteVerbose("BlastGuards: {0}", this.BlastGuards);
            this.Client.Output.WriteVerbose("TestCircular: {0}", this.TestCircular);

            using (var undoscope = this.Client.Undo.NewUndoScope(nameof(SetVisioPageCells)))
            {
                for (int i = 0; i < target_pages.Pages.Count; i++)
                {
                    var target_page = target_pages.Pages[i];
                    this.Client.Output.WriteVerbose("Start Update Page Name={0}", target_page.NameU);

                    var target_pagesheet    = target_page.PageSheet;
                    int target_pagesheet_id = target_pagesheet.ID;
                    var target_cells        = this.Cells[i % this.Cells.Length];
                    var writer = new VisioAutomation.ShapeSheet.Writers.SidSrcWriter();
                    writer.BlastGuards  = this.BlastGuards;
                    writer.TestCircular = this.TestCircular;
                    target_cells.Apply(writer, (short)target_pagesheet_id);
                    writer.CommitFormulas(target_page);

                    this.Client.Output.WriteVerbose("End Update Page Name={0}", target_page.NameU);
                }
            }
        }
Example #8
0
        public void SetLockCells(Models.TargetShapes targets, LockCells lockcells)
        {
            var cmdtarget = this._client.GetCommandTargetPage();

            targets = targets.ResolveShapes(this._client);
            if (targets.Shapes.Count < 1)
            {
                return;
            }

            var page            = cmdtarget.ActivePage;
            var target_shapeids = targets.ToShapeIDs();
            var writer          = new VASS.Writers.SidSrcWriter();

            foreach (int shapeid in target_shapeids.ShapeIDs)
            {
                writer.SetValues((short)shapeid, lockcells);
            }

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetLockCells)))
            {
                writer.CommitFormulas(page);
            }
        }