private IVisio.VisGetSetArgs get_common_flags() { IVisio.VisGetSetArgs f_bg = this.BlastGuards ? IVisio.VisGetSetArgs.visSetBlastGuards : 0; IVisio.VisGetSetArgs f_tc = this.TestCircular ? IVisio.VisGetSetArgs.visSetTestCircular : 0; var flags = (short)f_bg | (short)f_tc; return((IVisio.VisGetSetArgs)flags); }
public void Scripting_Connects_Scenario_0() { var client = this.GetScriptingClient(); client.Document.New(); var pagesize = new VA.Drawing.Size(4, 4); client.Page.New(pagesize, false); var s1 = client.Draw.Rectangle(1, 1, 1.25, 1.5); var s2 = client.Draw.Rectangle(2, 3, 2.5, 3.5); var s3 = client.Draw.Rectangle(4.5, 2.5, 6, 3.5); client.Selection.None(); client.Selection.Select(s1); client.Selection.Select(s2); client.Selection.Select(s3); client.Document.OpenStencil("basic_u.vss"); var connec_stencil = client.Document.OpenStencil("connec_u.vss"); var master = client.Master.Get("Dynamic Connector", connec_stencil); var fromshapes = new [] { s1, s2 }; var toshapes = new [] { s2, s3 }; var directed_connectors = client.Connection.Connect(fromshapes, toshapes, master); client.Selection.None(); client.Selection.Select(directed_connectors); IVisio.VisGetSetArgs flags = 0; client.ShapeSheet.SetFormula(null, new[] { VA.ShapeSheet.SRCConstants.EndArrow }, new [] { "13" }, flags); var undirected_edges0 = client.Connection.GetDirectedEdges(VACONNECT.ConnectorEdgeHandling.Raw); Assert.AreEqual(2, undirected_edges0.Count); var directed_edges0 = client.Connection.GetDirectedEdges(VACONNECT.ConnectorEdgeHandling.Arrow_ExcludeConnectorsWithoutArrows); Assert.AreEqual(2, directed_edges0.Count); var directed_edges1 = client.Connection.GetDirectedEdges(VACONNECT.ConnectorEdgeHandling.Arrow_TreatConnectorsWithoutArrowsAsBidirectional); Assert.AreEqual(2, directed_edges1.Count); client.Document.Close(true); }
public void SetFont(IList <IVisio.Shape> target_shapes, string fontname) { this.Client.Application.AssertApplicationAvailable(); this.Client.Document.AssertDocumentAvailable(); var shapes = this.GetTargetShapes(target_shapes); if (shapes.Count < 1) { return; } var application = this.Client.Application.Get(); var active_document = application.ActiveDocument; var active_doc_fonts = active_document.Fonts; var font = active_doc_fonts[fontname]; IVisio.VisGetSetArgs flags = 0; var srcs = new[] { ShapeSheet.SRCConstants.CharFont }; var formulas = new[] { font.ID.ToString() }; this.Client.ShapeSheet.SetFormula(target_shapes, srcs, formulas, flags); }
public void SetResult( IList <IVisio.Shape> target_shapes, IList <ShapeSheet.SRC> srcs, IList <string> results, IVisio.VisGetSetArgs flags) { this.Client.Application.AssertApplicationAvailable(); this.Client.Document.AssertDocumentAvailable(); var shapes = this.GetTargetShapes(target_shapes); if (shapes.Count < 1) { this.Client.WriteVerbose("SetResult: Zero Shapes. Not performing Operation"); return; } if (srcs == null) { throw new System.ArgumentNullException(nameof(srcs)); } if (results == null) { throw new System.ArgumentNullException(nameof(results)); } if (results.Any(f => f == null)) { this.Client.WriteVerbose("SetResult: One of the Input Results is a NULL value"); throw new System.ArgumentException("results contains a null value", nameof(results)); } this.Client.WriteVerbose("SetResult: src count= {0} and result count = {1}", srcs.Count, results.Count); if (results.Count != srcs.Count) { string msg = $"Must have the same number of srcs ({srcs.Count}) and results ({results.Count})"; throw new System.ArgumentException(msg, nameof(results)); } var shapeids = shapes.Select(s => s.ID).ToList(); int num_results = results.Count; var update = new ShapeSheet.Update(shapes.Count * num_results); update.BlastGuards = ((short)flags & (short)IVisio.VisGetSetArgs.visSetBlastGuards) != 0; update.TestCircular = ((short)flags & (short)IVisio.VisGetSetArgs.visSetTestCircular) != 0; foreach (var shapeid in shapeids) { for (int i = 0; i < num_results; i++) { var src = srcs[i]; var result = results[i]; update.SetResult((short)shapeid, src, result, IVisio.VisUnitCodes.visNumber); } } var surface = this.Client.ShapeSheet.GetShapeSheetSurface(); var application = this.Client.Application.Get(); using (var undoscope = this.Client.Application.NewUndoScope("Set ShapeSheet Result")) { update.Execute(surface); } }
public void SetFormula( IList <IVisio.Shape> target_shapes, IList <VA.ShapeSheet.SRC> srcs, IList <string> formulas, IVisio.VisGetSetArgs flags) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var shapes = this.GetTargetShapes(target_shapes); if (shapes.Count < 1) { this.Client.WriteVerbose("SetFormula: Zero Shapes. Not performing Operation"); return; } if (srcs == null) { throw new System.ArgumentNullException("srcs"); } if (formulas == null) { throw new System.ArgumentNullException("formulas"); } if (formulas.Any(f => f == null)) { this.Client.WriteVerbose("SetFormula: One of the Input Formulas is a NULL value"); throw new System.ArgumentException("formulas contains a null value"); } this.Client.WriteVerbose("SetFormula: src count= {0} and formula count = {1}", srcs.Count, formulas.Count); if (formulas.Count != srcs.Count) { string msg = string.Format("SetFormula: Must have the same number of srcs ({0}) and formulas ({1})", srcs.Count, formulas.Count); throw new System.ArgumentException(msg); } var shapeids = shapes.Select(s => s.ID).ToList(); int num_formulas = formulas.Count; var update = new VA.ShapeSheet.Update(shapes.Count * num_formulas); update.BlastGuards = ((short)flags & (short)IVisio.VisGetSetArgs.visSetBlastGuards) != 0; update.TestCircular = ((short)flags & (short)IVisio.VisGetSetArgs.visSetTestCircular) != 0; foreach (var shapeid in shapeids) { for (int i = 0; i < num_formulas; i++) { var src = srcs[i]; var formula = formulas[i]; update.SetFormula((short)shapeid, src, formula); } } var surface = this.Client.Draw.GetDrawingSurfaceSafe(); using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication, "Set ShapeSheet Formulas")) { update.Execute(surface); } }