public void Apply(VASS.Writers.SidSrcWriter writer, short id) { writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutAvenueSizeX, this.PageLayoutAvenueSizeX); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutAvenueSizeY, this.PageLayoutAvenueSizeY); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutBlockSizeX, this.PageLayoutBlockSizeX); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutBlockSizeY, this.PageLayoutBlockSizeY); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutControlAsInput, this.PageLayoutControlAsInput); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutDynamicsOff, this.PageLayoutDynamicsOff); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutEnableGrid, this.PageLayoutEnableGrid); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineAdjustFrom, this.PageLayoutLineAdjustFrom); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineAdjustTo, this.PageLayoutLineAdjustTo); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineJumpCode, this.PageLayoutLineJumpCode); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineJumpFactorX, this.PageLayoutLineJumpFactorX); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineJumpFactorY, this.PageLayoutLineJumpFactorY); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineJumpStyle, this.PageLayoutLineJumpStyle); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineRouteExt, this.PageLayoutLineRouteExt); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineToLineX, this.PageLayoutLineToLineX); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineToLineY, this.PageLayoutLineToLineY); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineToNodeX, this.PageLayoutLineToNodeX); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineToNodeY, this.PageLayoutLineToNodeY); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineJumpDirX, this.PageLayoutPageLineJumpDirX); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutLineJumpDirY, this.PageLayoutPageLineJumpDirY); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutShapeSplit, this.PageShapeSplit); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutPlaceDepth, this.PlaceDepth); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutPlaceFlip, this.PlaceFlip); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutPlaceStyle, this.PlaceStyle); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutPlowCode, this.PlowCode); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutResizePage, this.ResizePage); writer.SetValue(id, ShapeSheet.SrcConstants.PageLayoutRouteStyle, this.RouteStyle); }
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); }
public void SetFormulas(VASS.Writers.SidSrcWriter writer, short id) { writer.SetValue(id, VASS.SrcConstants.XFormPinX, this.XFormPinX); writer.SetValue(id, VASS.SrcConstants.XFormPinY, this.XFormPinY); writer.SetValue(id, VASS.SrcConstants.XFormLocPinX, this.XFormLocPinX); writer.SetValue(id, VASS.SrcConstants.XFormLocPinY, this.XFormLocPinY); writer.SetValue(id, VASS.SrcConstants.XFormWidth, this.XFormWidth); writer.SetValue(id, VASS.SrcConstants.XFormHeight, this.XFormHeight); }
protected override void ProcessRecord() { var targetdoc = new VisioScripting.TargetDocument(this.Document); this.Client.Output.WriteVerbose("Creating a new page"); var page = this.Client.Page.NewPage(targetdoc, 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 targetpage_shapesheet = page.PageSheet; int targetpage_shapesheetid = targetpage_shapesheet.ID; var writer = new VisioAutomation.ShapeSheet.Writers.SidSrcWriter(); writer.BlastGuards = true; writer.TestCircular = true; this.Cells.Apply(writer, (short)targetpage_shapesheetid); this.Client.Output.WriteVerbose("Updating Cells for new page"); writer.Commit(page, VisioAutomation.ShapeSheet.CellValueType.Formula); } this.WriteObject(page); }
public void Apply(VisioAutomation.ShapeSheet.Writers.SidSrcWriter writer, short id) { foreach (var pair in this.GetCellTuples()) { if (pair.Formula != null) { writer.SetFormula(id, pair.Src, pair.Formula); } } }
public void Apply(VASS.Writers.SidSrcWriter writer, short id) { foreach (var tuple in this.GetCellTuples()) { if (tuple.Formula != null) { writer.SetValue(id, tuple.Src, tuple.Formula); } } }
public void Render(IVisio.Page page) { if (page == null) { throw new System.ArgumentNullException(nameof(page)); } // First handle any page properties if (this.Name != null) { page.NameU = this.Name; } this.VisioPage = page; var page_sheet = page.PageSheet; var app = page.Application; using (var perfscope = new RenderPerformanceScope(app, this.RenderPerformanceSettings)) { if (this.Size.HasValue) { this.PageFormatCells.Height = this.Size.Value.Height; this.PageFormatCells.Width = this.Size.Value.Width; } var writer = new VASS.Writers.SidSrcWriter(); writer.SetValues((short)page_sheet.ID, this.PageFormatCells); writer.SetValues((short)page_sheet.ID, this.PageLayoutCells); writer.Commit(page, ShapeSheet.CellValueType.Formula); // Then render the shapes this.Shapes.Render(page); // Perform any additional layout if (this.Layout != null) { this.Layout.Apply(page); } // Optionally, perform page resizing to fit contents if (this.ResizeToFit) { if (this.ResizeToFitMargin.HasValue) { page.ResizeToFitContents(this.ResizeToFitMargin.Value); } else { page.ResizeToFitContents(); } } } }
internal void __SetCells(TargetShapes targetshapes, VASS.CellGroups.CellGroup cellgroup, IVisio.Page page) { targetshapes = targetshapes.Resolve(this._client); var targetshapeids = targetshapes.ToShapeIDs(); var writer = new VASS.Writers.SidSrcWriter(); foreach (var shapeid in targetshapeids) { var cells_mr = (VASS.CellGroups.CellGroup)cellgroup; writer.SetValues((short)shapeid, cells_mr, 0); } writer.Commit(page, VASS.CellValueType.Formula); }
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"); } }
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"); } }
protected override void ProcessRecord() { var targetpages = new VisioScripting.TargetPages(this.Page).ResolveToPages(this.Client); if (targetpages.Pages.Count < 1) { return; } if (this.Cells == null || this.Cells.Length < 1) { return; } 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))) { foreach (int i in Enumerable.Range(0, targetpages.Pages.Count)) { int page_index = i; int cells_index = i % this.Cells.Length; var page = targetpages.Pages[page_index]; var cells = this.Cells[cells_index]; this.Client.Output.WriteVerbose("Start Update Page Name={0}", page.NameU); var shapesheet = page.PageSheet; int shapeid = shapesheet.ID; var writer = new VisioAutomation.ShapeSheet.Writers.SidSrcWriter(); writer.BlastGuards = this.BlastGuards; writer.TestCircular = this.TestCircular; cells.Apply(writer, (short)shapeid); writer.Commit(page, VisioAutomation.ShapeSheet.CellValueType.Formula); this.Client.Output.WriteVerbose("End Update Page Name={0}", page.NameU); } } }
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); }
public void ShapeSheet_Writer_Formulas_MultipleShapes() { var page1 = this.GetNewPage(); var shape1 = page1.DrawRectangle(-1, -1, 0, 0); var shape2 = page1.DrawRectangle(-1, -1, 0, 0); var shape3 = page1.DrawRectangle(-1, -1, 0, 0); // Set the formulas var writer = new VASS.Writers.SidSrcWriter(); writer.SetValue(shape1.ID16, XFormPinX, 0.5); writer.SetValue(shape1.ID16, XFormPinY, 0.5); writer.SetValue(shape2.ID16, XFormPinX, 1.5); writer.SetValue(shape2.ID16, XFormPinY, 1.5); writer.SetValue(shape3.ID16, XFormPinX, 2.5); writer.SetValue(shape3.ID16, XFormPinY, 2.5); writer.Commit(page1, VASS.CellValueType.Formula); // Verify that the formulas were set var query = new VASS.Query.CellQuery(); var col_pinx = query.Columns.Add(XFormPinX, nameof(XFormPinX)); var col_piny = query.Columns.Add(XFormPinY, nameof(XFormPinY)); var shapeids = new[] { shape1.ID, shape2.ID, shape3.ID }; var data_formulas = query.GetFormulas(page1, shapeids); var data_results = query.GetResults <double>(page1, shapeids); AssertUtil.AreEqual(("0.5 in", 0.5), (data_formulas[0][col_pinx], data_results[0][col_pinx])); AssertUtil.AreEqual(("0.5 in", 0.5), (data_formulas[0][col_piny], data_results[0][col_piny])); AssertUtil.AreEqual(("1.5 in", 1.5), (data_formulas[1][col_pinx], data_results[1][col_pinx])); AssertUtil.AreEqual(("1.5 in", 1.5), (data_formulas[1][col_piny], data_results[1][col_piny])); AssertUtil.AreEqual(("2.5 in", 2.5), (data_formulas[2][col_pinx], data_results[2][col_pinx])); AssertUtil.AreEqual(("2.5 in", 2.5), (data_formulas[2][col_piny], data_results[2][col_piny])); page1.Delete(0); }
public void SetLockCells(TargetShapes targetshapes, VA.Shapes.LockCells lockcells) { targetshapes = targetshapes.Resolve(this._client); if (targetshapes.Shapes.Count < 1) { return; } var page = targetshapes.Shapes[0].ContainingPage; var targetshapeids = targetshapes.ToShapeIDs(); var writer = new VASS.Writers.SidSrcWriter(); foreach (int shapeid in targetshapeids) { writer.SetValues((short)shapeid, lockcells); } using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetLockCells))) { writer.Commit(page, VASS.CellValueType.Formula); } }
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); }
protected override void ProcessRecord() { if (this.Cells == null) { return; } if (this.Cells.Length < 1) { return; } var targetpages = new VisioScripting.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 < targetpages.Pages.Count; i++) { var targetpage = targetpages.Pages[i]; this.Client.Output.WriteVerbose("Start Update Page Name={0}", targetpage.NameU); var targetpage_shapesheet = targetpage.PageSheet; int targetpage_shapesheetid = targetpage_shapesheet.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)targetpage_shapesheetid); writer.Commit(targetpage, VisioAutomation.ShapeSheet.CellValueType.Formula); this.Client.Output.WriteVerbose("End Update Page Name={0}", targetpage.NameU); } } }
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); } }