public void Apply(SidSrcWriter writer, short id) { writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutAvenueSizeX, this.PageLayoutAvenueSizeX); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutAvenueSizeY, this.PageLayoutAvenueSizeY); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutBlockSizeX, this.PageLayoutBlockSizeX); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutBlockSizeY, this.PageLayoutBlockSizeY); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutControlAsInput, this.PageLayoutControlAsInput); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutDynamicsOff, this.PageLayoutDynamicsOff); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutEnableGrid, this.PageLayoutEnableGrid); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineAdjustFrom, this.PageLayoutLineAdjustFrom); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineAdjustTo, this.PageLayoutLineAdjustTo); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineJumpCode, this.PageLayoutLineJumpCode); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineJumpFactorX, this.PageLayoutLineJumpFactorX); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineJumpFactorY, this.PageLayoutLineJumpFactorY); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineJumpStyle, this.PageLayoutLineJumpStyle); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineRouteExt, this.PageLayoutLineRouteExt); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineToLineX, this.PageLayoutLineToLineX); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineToLineY, this.PageLayoutLineToLineY); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineToNodeX, this.PageLayoutLineToNodeX); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineToNodeY, this.PageLayoutLineToNodeY); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineJumpDirX, this.PageLayoutPageLineJumpDirX); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutLineJumpDirY, this.PageLayoutPageLineJumpDirY); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutShapeSplit, this.PageShapeSplit); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutPlaceDepth, this.PlaceDepth); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutPlaceFlip, this.PlaceFlip); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutPlaceStyle, this.PlaceStyle); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutPlowCode, this.PlowCode); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutResizePage, this.ResizePage); writer.SetFormula(id, ShapeSheet.SrcConstants.PageLayoutRouteStyle, this.RouteStyle); }
public void SetShapeCells(VisioScripting.Models.TargetShapeIDs targets, Dictionary <string, string> hashtable, bool blast_guards, bool test_circular) { var writer = new SidSrcWriter(); writer.BlastGuards = blast_guards; writer.TestCircular = test_circular; var cellmap = VisioScripting.Models.CellSrcDictionary.GetCellMapForShapes(); var valuemap = new VisioScripting.Models.CellValueDictionary(cellmap, hashtable); foreach (var shape_id in targets.ShapeIDs) { foreach (var cellname in valuemap.Keys) { string cell_value = valuemap[cellname]; var cell_src = valuemap.GetSrc(cellname); writer.SetFormula((short)shape_id, cell_src, cell_value); } } var surface = this._client.ShapeSheet.GetShapeSheetSurface(); this._client.WriteVerbose("BlastGuards: {0}", blast_guards); this._client.WriteVerbose("TestCircular: {0}", test_circular); this._client.WriteVerbose("Number of Shapes : {0}", targets.ShapeIDs.Count); using (var undoscope = this._client.Application.NewUndoScope("Set Shape Cells")) { this._client.WriteVerbose("Start Update"); writer.Commit(surface); this._client.WriteVerbose("End Update"); } }
public void SetSize(TargetShapes targets, double?w, double?h) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var active_page = this._client.Page.Get(); var shapeids = targets.ToShapeIDs(); var writer = new SidSrcWriter(); foreach (int shapeid in shapeids.ShapeIDs) { if (w.HasValue && w.Value >= 0) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SrcConstants.XFormWidth, w.Value); } if (h.HasValue && h.Value >= 0) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SrcConstants.XFormHeight, h.Value); } } using (var undoscope = this._client.Application.NewUndoScope("Set Shape Size")) { writer.Commit(active_page); } }
public void SetShapeCells(VisioScripting.Models.TargetShapeIDs targets, System.Action <SidSrcWriter, short> apply_cells, bool blast_guards, bool test_circular) { var writer = new SidSrcWriter(); writer.BlastGuards = blast_guards; writer.TestCircular = test_circular; foreach (var shape_id in targets.ShapeIDs) { apply_cells(writer, (short)shape_id); } var surface = this._client.ShapeSheet.GetShapeSheetSurface(); this._client.WriteVerbose("BlastGuards: {0}", blast_guards); this._client.WriteVerbose("TestCircular: {0}", test_circular); this._client.WriteVerbose("Number of Shapes : {0}", targets.ShapeIDs.Count); using (var undoscope = this._client.Application.NewUndoScope("Set Shape Cells")) { this._client.WriteVerbose("Start Update"); writer.Commit(surface); this._client.WriteVerbose("End Update"); } }
public void Apply(SidSrcWriter writer, short shapeid_label, short shapeid_box) { this.CharacterFormatCells.SetFormulas(writer, shapeid_label, 0); this.ParagraphFormatCells.SetFormulas(writer, shapeid_label, 0); this.ShapeFormatCells.SetFormulas(writer, shapeid_box); this.TextBlockCells.SetFormulas(writer, shapeid_label); }
public void SetLock(TargetShapes targets, LockCells lockcells) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var page = this._client.Page.Get(); var target_shapeids = targets.ToShapeIDs(); var writer = new SidSrcWriter(); foreach (int shapeid in target_shapeids.ShapeIDs) { lockcells.SetFormulas((short)shapeid, writer); } using (var undoscope = this._client.Application.NewUndoScope("Set Lock Properties")) { writer.Commit(page); } }
private void connect(IVisio.Shape a, IVisio.Shape b, bool a_arrow, bool b_arrow) { var page = a.ContainingPage; var connectors_stencil = page.Application.Documents.OpenStencil("connec_u.vss"); var connectors_masters = connectors_stencil.Masters; var dcm = connectors_masters["Dynamic Connector"]; var drop_point = new VADRAW.Point(-2, -2); var c1 = page.Drop(dcm, drop_point); ConnectorHelper.ConnectShapes(a, b, c1); //a.AutoConnect(b, connect_dir_none, null); if (a_arrow || b_arrow) { var writer = new SidSrcWriter(); if (a_arrow) { writer.SetFormula(c1.ID16, VASS.SrcConstants.LineBeginArrow, "13"); } if (b_arrow) { writer.SetFormula(c1.ID16, VASS.SrcConstants.LineEndArrow, "13"); } writer.Commit(page); } }
public void Apply(SidSrcWriter writer, short shapeid_label, short shapeid_box) { writer.SetValues(shapeid_label, this.ParagraphFormatCells, 0); writer.SetValues(shapeid_label, this.CharacterFormatCells, 0); writer.SetValues(shapeid_box, this.ShapeFormatCells); writer.SetValues(shapeid_box, this.TextBlockCells); }
public void SetFormulas(SidSrcWriter writer, short shapeid) { foreach (var pair in this.SrcValuePairs) { writer.SetFormula(shapeid, pair.Src, pair.Value); } }
public void SetFormulas(short shapeid, SidSrcWriter writer) { foreach (var pair in this.SrcFormulaPairs) { writer.SetFormula(shapeid, pair.Src, pair.Formula); } }
public void SetFormulas(short shapeid, SidSrcWriter writer, short row) { foreach (var pair in this.SrcFormulaPairs) { var new_src = pair.Src.CloneWithNewRow(row); writer.SetFormula(shapeid, new_src, pair.Formula); } }
public void SetFormulas(SidSrcWriter writer, short id) { writer.SetFormula(id, VisioAutomation.ShapeSheet.SrcConstants.XFormPinX, this.PinX); writer.SetFormula(id, VisioAutomation.ShapeSheet.SrcConstants.XFormPinY, this.PinY); writer.SetFormula(id, VisioAutomation.ShapeSheet.SrcConstants.XFormLocPinX, this.LocPinX); writer.SetFormula(id, VisioAutomation.ShapeSheet.SrcConstants.XFormLocPinY, this.LocPinY); writer.SetFormula(id, VisioAutomation.ShapeSheet.SrcConstants.XFormWidth, this.Width); writer.SetFormula(id, VisioAutomation.ShapeSheet.SrcConstants.XFormHeight, this.Height); }
public void ApplyFormus(SidSrcWriter writer) { short title_shapeid = this.VisioShape.ID16; writer.SetValues(title_shapeid, this.TextBlockCells); writer.SetValues(title_shapeid, this.ParagraphFormatCells, 0); writer.SetValues(title_shapeid, this.CharacterFormatCells, 0); writer.SetValues(title_shapeid, this.FormatCells); }
public void ApplyFormus(SidSrcWriter writer) { short titleshape_id = this.VisioShape.ID16; this.TextBlockCells.SetFormulas(titleshape_id, writer); this.ParagraphCells.SetFormulas(titleshape_id, writer, 0); this.CharacterCells.SetFormulas(titleshape_id, writer, 0); this.FormatCells.SetFormulas(titleshape_id, writer); }
public void ToogleCase(VisioScripting.Models.TargetShapes targets) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var application = this._client.Application.Get(); using (var undoscope = this._client.Application.NewUndoScope("Toggle Shape Text Case")) { var shapeids = targets.Shapes.Select(s => s.ID).ToList(); var page = application.ActivePage; // Store all the formatting var formats = VisioAutomation.Text.TextFormat.GetFormat(page, shapeids); // Change the text - this will wipe out all the character and paragraph formatting foreach (var shape in targets.Shapes) { string t = shape.Text; if (t.Length < 1) { continue; } shape.Text = VisioScripting.Helpers.TextHelper.toggle_case(t); } // Now restore all the formatting - based on any initial formatting from the text var writer = new SidSrcWriter(); for (int i = 0; i < targets.Shapes.Count; i++) { var format = formats[i]; if (format.CharacterFormats.Count > 0) { var fmt = format.CharacterFormats[0]; fmt.SetFormulas((short)shapeids[i], writer, 0); } if (format.ParagraphFormats.Count > 0) { var fmt = format.ParagraphFormats[0]; fmt.SetFormulas((short)shapeids[i], writer, 0); } } writer.Commit(page); } }
private static void _modify_pin_positions(IVisio.Page page, IList <int> sorted_shapeids, List <VisioAutomation.Geometry.Point> newpositions) { var writer = new SidSrcWriter(); for (int i = 0; i < newpositions.Count; i++) { writer.SetValue((short)sorted_shapeids[i], VisioAutomation.ShapeSheet.SrcConstants.XFormPinX, newpositions[i].X); writer.SetValue((short)sorted_shapeids[i], VisioAutomation.ShapeSheet.SrcConstants.XFormPinY, newpositions[i].Y); } writer.Commit(page, VisioAutomation.ShapeSheet.CellValueType.Formula); }
private static void ModifyPinPositions(IVisio.Page page, IList <int> sorted_shape_ids, List <VisioAutomation.Drawing.Point> newpositions) { var writer = new SidSrcWriter(); for (int i = 0; i < newpositions.Count; i++) { writer.SetFormula((short)sorted_shape_ids[i], VisioAutomation.ShapeSheet.SrcConstants.XFormPinX, newpositions[i].X); writer.SetFormula((short)sorted_shape_ids[i], VisioAutomation.ShapeSheet.SrcConstants.XFormPinY, newpositions[i].Y); } writer.Commit(page); }
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.RenderPerforfmanceSettings)) { if (this.Size.HasValue) { this.PageFormatCells.Height = this.Size.Value.Height; this.PageFormatCells.Width = this.Size.Value.Width; } var writer = new 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(); } } } }
private static void _modify_sizes(IVisio.Page page, IList <int> sorted_shapeids, List <VisioAutomation.Geometry.Size> newsizes) { var writer = new SidSrcWriter(); for (int i = 0; i < newsizes.Count; i++) { writer.SetValue((short)sorted_shapeids[i], VisioAutomation.ShapeSheet.SrcConstants.XFormWidth, newsizes[i].Width); writer.SetValue((short)sorted_shapeids[i], VisioAutomation.ShapeSheet.SrcConstants.XFormHeight, newsizes[i].Height); } writer.CommitFormulas(page); }
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)); }
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); }
public void Finish() { var writer = new SidSrcWriter(); foreach (var block in this.Blocks) { block.FormatCells.SetFormulas((short)block.VisioShapeID, writer); block.TextBlockCells.SetFormulas((short)block.VisioShapeID, writer); block.ParagraphCells.SetFormulas((short)block.VisioShapeID, writer, 0); block.CharacterCells.SetFormulas((short)block.VisioShapeID, writer, 0); } writer.Commit(this._page); }
public void Finish() { var writer = new SidSrcWriter(); foreach (var block in this.Blocks) { writer.SetValues((short)block.VisioShapeID, block.FormatCells); writer.SetValues((short)block.VisioShapeID, block.TextBlockCells); writer.SetValues((short)block.VisioShapeID, block.ParagraphFormatCells, 0); writer.SetValues((short)block.VisioShapeID, block.CharacterFormatCells, 0); } writer.CommitFormulas(this._page); }
private void UpdateCells(RenderContext context) { this._update_cells_with_drop_sizes(context); var writer = new SidSrcWriter(); var shapes_with_cells = this._shapes.Where(s => s.Cells != null); foreach (var shape in shapes_with_cells) { var fmt = shape.Cells; short id = shape.VisioShapeID; fmt.Apply(writer, id); } writer.Commit(context.VisioPage, ShapeSheet.CellValueType.Formula); }
public static void set_text_wrapping(IVisio.Page page, IList <int> shapeids, bool wrap) { const string formula_wrap = "WIDTH*1"; const string formula_no_wrap = "TEXTWIDTH(TheText)"; string formula = wrap ? formula_wrap : formula_no_wrap; var writer = new SidSrcWriter(); foreach (int shapeid in shapeids) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SrcConstants.TextXFormWidth, formula); } writer.Commit(page); }
private void UpdateCells(RenderContext context) { this.UpdateCellsWithDropSizes(context); var writer = new SidSrcWriter(); var shapes_with_cells = this._shapes.Where(s => s.Cells != null); foreach (var shape in shapes_with_cells) { var fmt = shape.Cells; short id = shape.VisioShapeID; fmt.Apply(writer, id); } writer.Commit(context.VisioPage); }
public void FitShapeToText(VisioScripting.Models.TargetShapes targets) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); var shapes = targets.ResolveShapes2D(this._client); if (shapes.Shapes.Count < 1) { return; } var application = this._client.Application.Get(); var active_page = application.ActivePage; var shapeids = shapes.Shapes.Select(s => s.ID).ToList(); using (var undoscope = this._client.Application.NewUndoScope("Fit Shape To Text")) { // Calculate the new sizes for each shape var new_sizes = new List <VisioAutomation.Drawing.Size>(shapeids.Count); foreach (var shape in shapes.Shapes) { var text_bounding_box = shape.GetBoundingBox(IVisio.VisBoundingBoxArgs.visBBoxUprightText).Size; var wh_bounding_box = shape.GetBoundingBox(IVisio.VisBoundingBoxArgs.visBBoxUprightWH).Size; double max_w = System.Math.Max(text_bounding_box.Width, wh_bounding_box.Width); double max_h = System.Math.Max(text_bounding_box.Height, wh_bounding_box.Height); var max_size = new VisioAutomation.Drawing.Size(max_w, max_h); new_sizes.Add(max_size); } var src_width = VisioAutomation.ShapeSheet.SrcConstants.XFormWidth; var src_height = VisioAutomation.ShapeSheet.SrcConstants.XFormHeight; var writer = new SidSrcWriter(); for (int i = 0; i < new_sizes.Count; i++) { var shapeid = shapeids[i]; var new_size = new_sizes[i]; writer.SetFormula((short)shapeid, src_width, new_size.Width); writer.SetFormula((short)shapeid, src_height, new_size.Height); } writer.Commit(active_page); } }
public void PasteFormat(IVisio.Page page, IList <int> shapeids, FormatPaintCategory paint_category, bool applyformulas) { // Find all the cells that are going to be pasted var matching_cells = this.Cells.Where(c => c.MatchesCategory(paint_category)).ToArray(); // Apply those matched cells to each shape var writer = new SidSrcWriter(); foreach (var shape_id in shapeids) { foreach (var cell in matching_cells) { var sidsrc = new VisioAutomation.ShapeSheet.SidSrc((short)shape_id, cell.Src); var new_formula = applyformulas ? cell.Formula : cell.Result; writer.SetFormula(sidsrc, new_formula); } } writer.Commit(page); }
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 SidSrcWriter(); writer.SetFormula(shape1.ID16, ShapeSheetWriterTests.src_pinx, 0.5); writer.SetFormula(shape1.ID16, ShapeSheetWriterTests.src_piny, 0.5); writer.SetFormula(shape2.ID16, ShapeSheetWriterTests.src_pinx, 1.5); writer.SetFormula(shape2.ID16, ShapeSheetWriterTests.src_piny, 1.5); writer.SetFormula(shape3.ID16, ShapeSheetWriterTests.src_pinx, 2.5); writer.SetFormula(shape3.ID16, ShapeSheetWriterTests.src_piny, 2.5); writer.Commit(page1); // Verify that the formulas were set var query = new ShapeSheetQuery(); var col_pinx = query.AddCell(ShapeSheetWriterTests.src_pinx, "PinX"); var col_piny = query.AddCell(ShapeSheetWriterTests.src_piny, "PinY"); 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].Cells[col_pinx], data_results[0].Cells[col_pinx])); AssertUtil.AreEqual(("0.5 in", 0.5), (data_formulas[0].Cells[col_piny], data_results[0].Cells[col_piny])); AssertUtil.AreEqual(("1.5 in", 1.5), (data_formulas[1].Cells[col_pinx], data_results[1].Cells[col_pinx])); AssertUtil.AreEqual(("1.5 in", 1.5), (data_formulas[1].Cells[col_piny], data_results[1].Cells[col_piny])); AssertUtil.AreEqual(("2.5 in", 2.5), (data_formulas[2].Cells[col_pinx], data_results[2].Cells[col_pinx])); AssertUtil.AreEqual(("2.5 in", 2.5), (data_formulas[2].Cells[col_piny], data_results[2].Cells[col_piny])); page1.Delete(0); }
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 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.CommitFormulas(page1); // Verify that the formulas were set var query = new 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); }