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 FormulaWriterSIDSRC(); if (a_arrow) { writer.SetFormula(c1.ID16, VASS.SRCConstants.BeginArrow, "13"); } if (b_arrow) { writer.SetFormula(c1.ID16, VASS.SRCConstants.EndArrow, "13"); } writer.Commit(page); } }
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 FormulaWriterSIDSRC(); foreach (int shapeid in shapeids.ShapeIDs) { if (w.HasValue && w.Value >= 0) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.Width, w.Value); } if (h.HasValue && h.Value >= 0) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.Height, h.Value); } } using (var undoscope = this._client.Application.NewUndoScope("Set Shape Size")) { writer.Commit(active_page); } }
public void SetFormulas(short shapeid, FormulaWriterSIDSRC writer) { foreach (var pair in this.Pairs) { writer.SetFormula(shapeid, pair.SRC, pair.Formula); } }
public void SetShapeCells(TargetShapeIDs targets, Dictionary <string, string> hashtable, bool blast_guards, bool test_circular) { var writer = new FormulaWriterSIDSRC(); writer.BlastGuards = blast_guards; writer.TestCircular = test_circular; var cellmap = VisioAutomation.Scripting.ShapeSheet.CellSRCDictionary.GetCellMapForShapes(); var valuemap = new VisioAutomation.Scripting.ShapeSheet.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); this._client.WriteVerbose("Number of Total Updates: {0}", writer.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 FitShapeToText(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 <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 Drawing.Size(max_w, max_h); new_sizes.Add(max_size); } var src_width = VisioAutomation.ShapeSheet.SRCConstants.Width; var src_height = VisioAutomation.ShapeSheet.SRCConstants.Height; var writer = new FormulaWriterSIDSRC(); 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 SetFormulas(short shapeid, FormulaWriterSIDSRC writer, short row) { foreach (var pair in this.Pairs) { var new_src = pair.SRC.CopyWithNewRow(row); writer.SetFormula(shapeid, new_src, pair.Formula); } }
private static short[] DropManyU( IVisio.Page page, IList <IVisio.Master> masters, IList <Drawing.Rectangle> rects) { var points = rects.Select(r => r.Center).ToList(); var shapeids = Pages.PageHelper.DropManyU(page, masters, points); // Dropping takes care of the PinX and PinY // Now set the Width's and Heights var writer = new FormulaWriterSIDSRC(points.Count * 2); for (int i = 0; i < rects.Count(); i++) { writer.SetFormula(shapeids[i], VisioAutomation.ShapeSheet.SRCConstants.Width, rects[i].Width); writer.SetFormula(shapeids[i], VisioAutomation.ShapeSheet.SRCConstants.Height, rects[i].Height); } writer.Commit(page); return(shapeids); }
public void PasteSize(TargetShapes targets, bool paste_width, bool paste_height) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } if ((!this.cached_size_width.HasValue) && (!this.cached_size_height.HasValue)) { return; } var writer = new FormulaWriterSIDSRC(); var shapeids = targets.Shapes.Select(s => s.ID).ToList(); foreach (var shapeid in shapeids) { if (paste_width) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.Width, this.cached_size_width.Value); } if (paste_height) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.Height, this.cached_size_height.Value); } } var application = this._client.Application.Get(); var active_page = application.ActivePage; writer.Commit(active_page); }
public void MoveTextToBottom(TargetShapes targets) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var writer = new FormulaWriterSIDSRC(); foreach (var shape in targets.Shapes) { if (0 == shape.RowExists[ (short)IVisio.VisSectionIndices.visSectionObject, (short)IVisio.VisRowIndices.visRowTextXForm, (short)IVisio.VisExistsFlags.visExistsAnywhere]) { shape.AddRow((short)IVisio.VisSectionIndices.visSectionObject, (short)IVisio.VisRowIndices.visRowTextXForm, (short)IVisio.VisRowTags.visTagDefault); } } var application = this._client.Application.Get(); var shapeids = targets.Shapes.Select(s => s.ID); foreach (int shapeid in shapeids) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.TxtHeight, "Height*0"); writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.TxtPinY, "Height*0"); writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.VerticalAlign, "0"); } var active_page = application.ActivePage; writer.Commit(active_page); }
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 FormulaWriterSIDSRC(); foreach (int shapeid in shapeids) { writer.SetFormula((short)shapeid, VisioAutomation.ShapeSheet.SRCConstants.TxtWidth, formula); } writer.Commit(page); }
public void PasteFormat(IVisio.Page page, IList <int> shapeids, FormatCategory category, bool applyformulas) { // Find all the cells that are going to be pasted var matching_cells = this.Cells.Where(c => c.MatchesCategory(category)).ToArray(); // Apply those matched cells to each shape var writer = new FormulaWriterSIDSRC(); 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 FormulaWriterSIDSRC(); 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 VisioAutomation.ShapeSheet.Queries.Query(); 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 surface = new ShapeSheetSurface(page1); var data_formulas = query.GetFormulas(surface, shapeids); var data_results = query.GetResults <double>(surface, 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 Apply(FormulaWriterSIDSRC writer, short id) { writer.SetFormula(id, ShapeSheet.SRCConstants.AvenueSizeX, this.AvenueSizeX); writer.SetFormula(id, ShapeSheet.SRCConstants.AvenueSizeY, this.AvenueSizeY); writer.SetFormula(id, ShapeSheet.SRCConstants.BlockSizeX, this.BlockSizeX); writer.SetFormula(id, ShapeSheet.SRCConstants.BlockSizeY, this.BlockSizeY); writer.SetFormula(id, ShapeSheet.SRCConstants.CtrlAsInput, this.CtrlAsInput); writer.SetFormula(id, ShapeSheet.SRCConstants.DynamicsOff, this.DynamicsOff); writer.SetFormula(id, ShapeSheet.SRCConstants.EnableGrid, this.EnableGrid); writer.SetFormula(id, ShapeSheet.SRCConstants.LineAdjustFrom, this.LineAdjustFrom); writer.SetFormula(id, ShapeSheet.SRCConstants.LineAdjustTo, this.LineAdjustTo); writer.SetFormula(id, ShapeSheet.SRCConstants.LineJumpCode, this.LineJumpCode); writer.SetFormula(id, ShapeSheet.SRCConstants.LineJumpFactorX, this.LineJumpFactorX); writer.SetFormula(id, ShapeSheet.SRCConstants.LineJumpFactorY, this.LineJumpFactorY); writer.SetFormula(id, ShapeSheet.SRCConstants.LineJumpStyle, this.LineJumpStyle); writer.SetFormula(id, ShapeSheet.SRCConstants.LineRouteExt, this.LineRouteExt); writer.SetFormula(id, ShapeSheet.SRCConstants.LineToLineX, this.LineToLineX); writer.SetFormula(id, ShapeSheet.SRCConstants.LineToLineY, this.LineToLineY); writer.SetFormula(id, ShapeSheet.SRCConstants.LineToNodeX, this.LineToNodeX); writer.SetFormula(id, ShapeSheet.SRCConstants.LineToNodeY, this.LineToNodeY); writer.SetFormula(id, ShapeSheet.SRCConstants.PageLineJumpDirX, this.PageLineJumpDirX); writer.SetFormula(id, ShapeSheet.SRCConstants.PageLineJumpDirY, this.PageLineJumpDirY); writer.SetFormula(id, ShapeSheet.SRCConstants.PageShapeSplit, this.PageShapeSplit); writer.SetFormula(id, ShapeSheet.SRCConstants.PlaceDepth, this.PlaceDepth); writer.SetFormula(id, ShapeSheet.SRCConstants.PlaceFlip, this.PlaceFlip); writer.SetFormula(id, ShapeSheet.SRCConstants.PlaceStyle, this.PlaceStyle); writer.SetFormula(id, ShapeSheet.SRCConstants.PlowCode, this.PlowCode); writer.SetFormula(id, ShapeSheet.SRCConstants.ResizePage, this.ResizePage); writer.SetFormula(id, ShapeSheet.SRCConstants.RouteStyle, this.RouteStyle); }
public void Apply(FormulaWriterSIDSRC writer, short id) { writer.SetFormula(id, ShapeSheet.SRCConstants.Width, this.Width); writer.SetFormula(id, ShapeSheet.SRCConstants.Height, this.Height); writer.SetFormula(id, ShapeSheet.SRCConstants.PinX, this.PinX); writer.SetFormula(id, ShapeSheet.SRCConstants.PinY, this.PinY); writer.SetFormula(id, ShapeSheet.SRCConstants.LocPinX, this.LocPinX); writer.SetFormula(id, ShapeSheet.SRCConstants.LocPinY, this.LocPinY); writer.SetFormula(id, ShapeSheet.SRCConstants.Angle, this.Angle); writer.SetFormula(id, ShapeSheet.SRCConstants.BeginArrow, this.BeginArrow); writer.SetFormula(id, ShapeSheet.SRCConstants.BeginArrowSize, this.BeginArrowSize); writer.SetFormula(id, ShapeSheet.SRCConstants.FillBkgnd, this.FillBkgnd); writer.SetFormula(id, ShapeSheet.SRCConstants.FillBkgndTrans, this.FillBkgndTrans); writer.SetFormula(id, ShapeSheet.SRCConstants.FillForegnd, this.FillForegnd); writer.SetFormula(id, ShapeSheet.SRCConstants.FillForegndTrans, this.FillForegndTrans); writer.SetFormula(id, ShapeSheet.SRCConstants.FillPattern, this.FillPattern); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapeShdwObliqueAngle, this.ShapeShdwObliqueAngle); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapeShdwOffsetX, this.ShapeShdwOffsetX); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapeShdwOffsetY, this.ShapeShdwOffsetY); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapeShdwScaleFactor, this.ShapeShdwScaleFactor); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapeShdwType, this.ShapeShdwType); writer.SetFormula(id, ShapeSheet.SRCConstants.ShdwBkgnd, this.ShdwBkgnd); writer.SetFormula(id, ShapeSheet.SRCConstants.ShdwBkgndTrans, this.ShdwBkgndTrans); writer.SetFormula(id, ShapeSheet.SRCConstants.ShdwForegnd, this.ShdwForegnd); writer.SetFormula(id, ShapeSheet.SRCConstants.ShdwForegndTrans, this.ShdwForegndTrans); writer.SetFormula(id, ShapeSheet.SRCConstants.ShdwPattern, this.ShdwPattern); writer.SetFormula(id, ShapeSheet.SRCConstants.CharCase, this.CharCase); writer.SetFormula(id, ShapeSheet.SRCConstants.CharFont, this.CharFont); writer.SetFormula(id, ShapeSheet.SRCConstants.CharColor, this.CharColor); writer.SetFormula(id, ShapeSheet.SRCConstants.CharSize, this.CharSize); writer.SetFormula(id, ShapeSheet.SRCConstants.CharLetterspace, this.CharLetterspace); writer.SetFormula(id, ShapeSheet.SRCConstants.CharStyle, this.CharStyle); writer.SetFormula(id, ShapeSheet.SRCConstants.CharColorTrans, this.CharTransparency); writer.SetFormula(id, ShapeSheet.SRCConstants.EndArrow, this.EndArrow); writer.SetFormula(id, ShapeSheet.SRCConstants.EndArrowSize, this.EndArrowSize); // Line writer.SetFormula(id, ShapeSheet.SRCConstants.LineColor, this.LineColor); writer.SetFormula(id, ShapeSheet.SRCConstants.LineColorTrans, this.LineColorTrans); writer.SetFormula(id, ShapeSheet.SRCConstants.LinePattern, this.LinePattern); writer.SetFormula(id, ShapeSheet.SRCConstants.LineWeight, this.LineWeight); // Text writer.SetFormula(id, ShapeSheet.SRCConstants.BottomMargin, this.BottomMargin); writer.SetFormula(id, ShapeSheet.SRCConstants.DefaultTabStop, this.DefaultTabstop); writer.SetFormula(id, ShapeSheet.SRCConstants.LeftMargin, this.LeftMargin); writer.SetFormula(id, ShapeSheet.SRCConstants.RightMargin, this.RightMargin); writer.SetFormula(id, ShapeSheet.SRCConstants.TextBkgnd, this.TextBkgnd); writer.SetFormula(id, ShapeSheet.SRCConstants.TextBkgndTrans, this.TextBkgndTrans); writer.SetFormula(id, ShapeSheet.SRCConstants.TextDirection, this.TextDirection); writer.SetFormula(id, ShapeSheet.SRCConstants.TopMargin, this.TopMargin); writer.SetFormula(id, ShapeSheet.SRCConstants.VerticalAlign, this.VerticalAlign); // Paragraph writer.SetFormula(id, ShapeSheet.SRCConstants.Para_Bullet, this.ParaBullet); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_BulletFont, this.ParaBulletFont); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_BulletFontSize, this.ParaBulletFontSize); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_BulletStr, this.ParaBulletString); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_Flags, this.ParaFlags); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_HorzAlign, this.ParaHorizontalAlign); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_IndFirst, this.ParaIndentFirst); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_IndLeft, this.ParaIndentLeft); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_IndRight, this.ParaIndentRight); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_LocalizeBulletFont, this.ParaLocBulletFont); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_SpAfter, this.ParaSpacingAfter); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_SpBefore, this.ParaSpacingBefore); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_SpLine, this.ParaSpacingLine); writer.SetFormula(id, ShapeSheet.SRCConstants.Para_TextPosAfterBullet, this.ParaTextPosAfterBullet); // TextXForm writer.SetFormula(id, ShapeSheet.SRCConstants.TxtAngle, this.TxtAngle); writer.SetFormula(id, ShapeSheet.SRCConstants.TxtHeight, this.TxtHeight); writer.SetFormula(id, ShapeSheet.SRCConstants.TxtLocPinX, this.TxtLocPinX); writer.SetFormula(id, ShapeSheet.SRCConstants.TxtLocPinY, this.TxtLocPinY); writer.SetFormula(id, ShapeSheet.SRCConstants.TxtPinX, this.TxtPinX); writer.SetFormula(id, ShapeSheet.SRCConstants.TxtPinY, this.TxtPinY); writer.SetFormula(id, ShapeSheet.SRCConstants.TxtWidth, this.TxtWidth); // ShapeLayout writer.SetFormula(id, ShapeSheet.SRCConstants.ConFixedCode, this.ConFixedCode); writer.SetFormula(id, ShapeSheet.SRCConstants.ConLineJumpCode, this.ConLineJumpCode); writer.SetFormula(id, ShapeSheet.SRCConstants.ConLineJumpDirX, this.ConLineJumpDirX); writer.SetFormula(id, ShapeSheet.SRCConstants.ConLineJumpDirY, this.ConLineJumpDirY); writer.SetFormula(id, ShapeSheet.SRCConstants.ConLineJumpStyle, this.ConLineJumpStyle); writer.SetFormula(id, ShapeSheet.SRCConstants.ConLineRouteExt, this.ConLineRouteExt); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapeFixedCode, this.ShapeFixedCode); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapePermeablePlace, this.ShapePermeablePlace); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapePermeableX, this.ShapePermeableX); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapePermeableY, this.ShapePermeableY); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapePlaceFlip, this.ShapePlaceFlip); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapePlaceStyle, this.ShapePlaceStyle); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapePlowCode, this.ShapePlowCode); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapeRouteStyle, this.ShapeRouteStyle); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapeSplit, this.ShapeSplit); writer.SetFormula(id, ShapeSheet.SRCConstants.ShapeSplittable, this.ShapeSplittable); }