public void Apply(FormulaWriterSIDSRC writer, short shapeid_label, short shapeid_box) { this.CharacterCells.SetFormulas(shapeid_label, writer, 0); this.ParagraphCells.SetFormulas(shapeid_label, writer, 0); this.ShapeFormatCells.SetFormulas(shapeid_box, writer); this.TextBlockCells.SetFormulas(shapeid_label, writer); }
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 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 SetFormulas(short shapeid, FormulaWriterSIDSRC writer) { foreach (var pair in this.Pairs) { writer.SetFormula(shapeid, pair.SRC, pair.Formula); } }
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 FormulaWriterSIDSRC(); 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); } }
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 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); } }
public void ApplyFormus(FormulaWriterSIDSRC 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 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 Application.PerfScope(app, this.PerfSettings)) { if (this.Size.HasValue) { this.PageCells.PageHeight = this.Size.Value.Height; this.PageCells.PageWidth = this.Size.Value.Width; } var writer = new FormulaWriterSIDSRC(); this.PageCells.SetFormulas((short)page_sheet.ID, writer); writer.Commit(page); // 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(); } } } }
public void ToogleCase(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 = 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 = TextHelper.toggle_case(t); } // Now restore all the formatting - based on any initial formatting from the text var writer = new FormulaWriterSIDSRC(); 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); } }
public void Finish() { var writer = new FormulaWriterSIDSRC(); 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 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.FillForegnd = "rgb(240,240,240)"; background_fmt.LineColor = "rgb(100,100,100)"; var progress_fmt = new VA.Shapes.ShapeFormatCells(); progress_fmt.FillForegnd = "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 xform = new VA.Shapes.XFormCells(); xform.PinX = string.Format("GUARD({0}!PinX-{0}!LocPinX+LocPinX)", bkname); xform.PinY = string.Format("GUARD({0}!PinY)", bkname); xform.Width = string.Format("GUARD({0}!Width*(PAGENUMBER()/PAGECOUNT()))", bkname); xform.Height = string.Format("GUARD({0}!Height)", bkname); var writer = new FormulaWriterSIDSRC(); xform.SetFormulas(progress.ID16, writer); background_fmt.SetFormulas(progress.ID16, writer); progress_fmt.SetFormulas(progress.ID16, writer); writer.Commit(page_a); var markup1 = new VisioAutomation.Models.Text.TextElement(); 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 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.Drawing.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 angles_as_formulas = angles.Select(a => a.ToString(CultureInfo.InvariantCulture)).ToList(); var color_formulas = colors.Select(x => new VA.Colors.ColorRGB(x).ToFormula()).ToList(); var shapeids = shapes.Select(s => s.ID16).ToList(); var writer = new FormulaWriterSIDSRC(); var format = new VA.Shapes.ShapeFormatCells(); var xfrm = new VA.Shapes.XFormCells(); foreach (int i in Enumerable.Range(0, shapeids.Count)) { short shapeid = shapeids[i]; xfrm.Angle = angles_as_formulas[i]; format.FillForegnd = color_formulas[i]; format.LineWeight = 0; format.LinePattern = 0; format.FillForegndTrans = 0.5; xfrm.SetFormulas(shapeid, writer); format.SetFormulas(shapeid, writer); } writer.Commit(page); VA.Pages.PageHelper.ResizeToFitContents(page, new VA.Drawing.Size(1.0, 1.0)); }
private void UpdateCells(RenderContext context) { this.UpdateCellsWithDropSizes(context); var writer = new FormulaWriterSIDSRC(); 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 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 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 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); }
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 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 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 void Set(TargetShapes targets, Shapes.ShapeFormatCells format) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); targets = targets.ResolveShapes(this._client); if (targets.Shapes.Count < 1) { return; } var writer = new FormulaWriterSIDSRC(); var shapeids = targets.Shapes.Select(s => s.ID).ToList(); foreach (int shapeid in shapeids) { format.SetFormulas((short)shapeid, writer); } var application = this._client.Application.Get(); writer.Commit(application.ActivePage); }
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); }
public static void ColorGrid() { // Draws a grid rectangles and then formats the shapes // with different colors // Demonstrates: // How use the GridLayout object to quickly drop a grid // How to use ShapeFormatCells to apply formatting to shapes // How UpdateBase can be used to modfiy multiple shapes at once int[] colors = { 0x0A3B76, 0x4395D1, 0x99D9EA, 0x0D686B, 0x00A99D, 0x7ACCC8, 0x82CA9C, 0x74A402, 0xC4DF9B, 0xD9D56F, 0xFFF468, 0xFFF799, 0xFFC20E, 0xEB6119, 0xFBAF5D, 0xE57300, 0xC14000, 0xB82832, 0xD85171, 0xFEDFEC, 0x563F7F, 0xA186BE, 0xD9CFE5 }; const int num_cols = 5; const int num_rows = 5; var page = SampleEnvironment.Application.ActiveDocument.Pages.Add(); var page_size = new VA.Drawing.Size(10, 10); SampleEnvironment.SetPageSize(page, page_size); var stencil = SampleEnvironment.Application.Documents.OpenStencil("basic_u.vss"); var master = stencil.Masters["Rectangle"]; var layout = new VA.Models.Layouts.Grid.GridLayout(num_cols, num_rows, new VA.Drawing.Size(1, 1), master); layout.Origin = new VA.Drawing.Point(0, 0); layout.CellSpacing = new VA.Drawing.Size(0, 0); layout.RowDirection = VA.Models.Layouts.Grid.RowDirection.BottomToTop; layout.PerformLayout(); layout.Render(page); var fmtcells = new VA.Shapes.ShapeFormatCells(); int i = 0; var writer = new FormulaWriterSIDSRC(); foreach (var node in layout.Nodes) { var shapeid = node.ShapeID; int color_index = i % colors.Length; var color = colors[color_index]; fmtcells.FillForegnd = new ColorRGB(color).ToFormula(); fmtcells.LinePattern = 0; fmtcells.LineWeight = 0; fmtcells.SetFormulas(shapeid, writer); i++; } writer.Commit(page); var bordersize = new VA.Drawing.Size(1, 1); page.ResizeToFitContents(bordersize); }
public ShapeSheetWriter(Client client, Microsoft.Office.Interop.Visio.Page page) { this.Client = client; this.Surface = new ShapeSheetSurface(page); this.formula_writer = new FormulaWriterSIDSRC(); }
public static void DrawAllGradients() { var app = SampleEnvironment.Application; var docs = app.Documents; var stencil = docs.OpenStencil("basic_u.vss"); var master = stencil.Masters["Rectangle"]; var page = SampleEnvironment.Application.ActiveDocument.Pages.Add(); int num_cols = 7; int num_rows = 7; var page_size = new VA.Drawing.Size(5, 5); SampleEnvironment.SetPageSize(page, page_size); var lowerleft = new VA.Drawing.Point(0, 0); var actual_page_size = SampleEnvironment.GetPageSize(page); var page_rect = new VA.Drawing.Rectangle(lowerleft, actual_page_size); var layout = new GRIDMODEL.GridLayout(num_cols, num_rows, new VA.Drawing.Size(1, 1), master); layout.RowDirection = GRIDMODEL.RowDirection.TopToBottom; layout.Origin = page_rect.UpperLeft; layout.CellSpacing = new VA.Drawing.Size(0, 0); layout.PerformLayout(); int max_grad_id = 40; int n = 0; foreach (var node in layout.Nodes) { int grad_id = n % max_grad_id; node.Text = grad_id.ToString(); n++; } layout.Render(page); var color1 = new VA.Colors.ColorRGB(0xffdddd); var color2 = new VA.Colors.ColorRGB(0x00ffff); var format = new VA.Shapes.ShapeFormatCells(); var writer = new FormulaWriterSIDSRC(); string color1_formula = color1.ToFormula(); string color2_formula = color2.ToFormula(); n = 0; foreach (var node in layout.Nodes) { short shapeid = node.ShapeID; int grad_id = n % max_grad_id; format.FillPattern = grad_id; format.FillForegnd = color1_formula; format.FillBkgnd = color2_formula; format.LinePattern = 0; format.LineWeight = 0; format.SetFormulas(shapeid, writer); n++; } writer.Commit(page); var bordersize = new VA.Drawing.Size(1, 1); page.ResizeToFitContents(bordersize); }
public IVisio.Page Render(IVisio.Document doc) { if (!this.IsLayedOut) { string msg = string.Format("{0} usage error. {1}() before calling {2}().", nameof(ContainerLayout), nameof(PerformLayout), nameof(Render)); throw new AutomationException(msg); } // create a new drawing var app = doc.Application; var docs = app.Documents; var pages = doc.Pages; var page = pages.Add(); // load the stencil used to draw the items var item_stencil = docs.OpenStencil(this.LayoutOptions.ManualItemStencil); var item_stencil_masters = item_stencil.Masters; var item_master = item_stencil_masters[this.LayoutOptions.ManualItemMaster]; var plain_container_master = item_stencil_masters[this.LayoutOptions.ManualContainerMaster]; var page_shapes = page.Shapes; // Drop the container shapes var ct_items = this.Containers.ToList(); var ct_rects = ct_items.Select(item => item.Rectangle).ToList(); var masters = ct_items.Select(i => plain_container_master).ToList(); short[] ct_shapeids = ContainerLayout.DropManyU(page, masters, ct_rects); // associate each container with the corresponding shape oject and shape id for (int i = 0; i < ct_items.Count; i++) { var ct_item = ct_items[i]; var ct_shapeid = ct_shapeids[i]; var shape = page_shapes[ct_shapeid]; ct_item.VisioShape = shape; ct_item.ShapeID = ct_shapeid; } // Render the items var items = this.ContainerItems.ToList(); var item_rects = items.Select(item => item.Rectangle).ToList(); var item_masters = items.Select(i => item_master).ToList(); short[] shapeids = ContainerLayout.DropManyU(page, item_masters, item_rects); // Associate each item with the corresponding shape object and shape id for (int i = 0; i < items.Count; i++) { var item = items[i]; var shapeid = shapeids[i]; var shape = page_shapes[shapeid]; item.VisioShape = shape; item.ShapeID = shapeid; } // Often useful to show everthing because these diagrams can get large app.ActiveWindow.ViewFit = (short)IVisio.VisWindowFit.visFitPage; // Set the items foreach (var item in items.Where(i => i.Text != null)) { item.VisioShape.Text = item.Text; } var writer = new FormulaWriterSIDSRC(); // Format the containers and shapes foreach (var item in this.Containers) { this.LayoutOptions.ContainerFormatting.Apply(writer, item.ShapeID, item.ShapeID); } foreach (var item in this.ContainerItems) { this.LayoutOptions.ContainerItemFormatting.Apply(writer, item.ShapeID, item.ShapeID); } writer.BlastGuards = true; writer.Commit(page); // Set the Container Text foreach (var ct in this.Containers) { if (ct.Text != null) { ct.Text.SetText(ct.VisioShape); } } page.ResizeToFitContents(); app.ActiveWindow.ViewFit = (short)IVisio.VisWindowFit.visFitPage; return(page); }