public void SetLock(IList <IVisio.Shape> target_shapes, VA.Shapes.LockCells lockcells) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var shapes = GetTargetShapes(target_shapes); if (shapes.Count < 1) { return; } var selection = this.Client.Selection.Get(); var shapeids = selection.GetIDs(); var update = new VA.ShapeSheet.Update(); foreach (int shapeid in shapeids) { update.SetFormulas((short)shapeid, lockcells); } var application = this.Client.VisioApplication; using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication, "Set Shape Lock Properties")) { var active_page = application.ActivePage; update.Execute(active_page); } }
public void PasteFormat(IVisio.Page page, IList <int> shapeids, FormatCategory category, bool applyformulas) { var update = new VA.ShapeSheet.Update(); foreach (var shape_id in shapeids) { foreach (var cellrec in this.Cells) { if (!cellrec.MatchesCategory(category)) { continue; } var sidsrc = new VA.ShapeSheet.SIDSRC((short)shape_id, cellrec.SRC); if (applyformulas) { update.SetFormula(sidsrc, cellrec.Formula); } else { if (cellrec.Result != null) { update.SetFormula(sidsrc, cellrec.Result); } } } } update.Execute(page); }
public void CheckHomogenousUpdates_ResultTypes() { var page1 = GetNewPage(); var shape1 = page1.DrawRectangle(0, 0, 1, 1); // Setup the modifications to the cell values var update = new VA.ShapeSheet.Update(); update.SetResult(src_linepat, "7", IVisio.VisUnitCodes.visNumber); update.SetResult(VA.ShapeSheet.SRCConstants.PinX, 2, IVisio.VisUnitCodes.visNumber); update.Execute(shape1); // Build the query var query = new VA.ShapeSheet.Query.CellQuery(); var col_linepat = query.Columns.Add(src_linepat,"LinePattern"); var col_pinx = query.Columns.Add(VA.ShapeSheet.SRCConstants.PinX,"PinX"); // Retrieve the values var data = query.GetFormulasAndResults<double>(shape1); // Verify AssertVA.AreEqual("7", 7, data[col_linepat.Ordinal]); AssertVA.AreEqual("2 in", 2, data[col_pinx.Ordinal]); page1.Delete(0); }
public static int Add( IVisio.Shape shape, ConnectionPointCells cp) { if (shape == null) { throw new System.ArgumentNullException("shape"); } if (!cp.X.Formula.HasValue) { throw new System.ArgumentException("Must provide an X Formula"); } if (!cp.Y.Formula.HasValue) { throw new System.ArgumentException("Must provide an Y Formula"); } var n = shape.AddRow((short)IVisio.VisSectionIndices.visSectionConnectionPts, (short)IVisio.VisRowIndices.visRowLast, (short)IVisio.VisRowTags.visTagCnnctPt); var update = new VA.ShapeSheet.Update(); update.SetFormulas(cp,n); update.Execute(shape); return n; }
public void MoveTextToBottom(IList<IVisio.Shape> target_shapes) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var shapes = GetTargetShapes(target_shapes); if (shapes.Count < 1) { return ; } var update = new VA.ShapeSheet.Update(); foreach (var shape in 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.VisioApplication; var shapeids = shapes.Select(s=>s.ID); foreach (int shapeid in shapeids) { update.SetFormula((short)shapeid, VA.ShapeSheet.SRCConstants.TxtHeight, "Height*0"); update.SetFormula((short)shapeid, VA.ShapeSheet.SRCConstants.TxtPinY, "Height*0"); update.SetFormula((short)shapeid, VA.ShapeSheet.SRCConstants.VerticalAlign, "0"); } var active_page = application.ActivePage; update.Execute(active_page); }
protected override void ProcessRecord() { if (this.FitContents) { var bordersize = new VisioAutomation.Drawing.Size(this.BorderWidth, this.BorderWidth); this.client.Page.ResizeToFitContents(bordersize, true); } if (this.Width > 0 || this.Height > 0) { var page = this.client.Application.Get().ActivePage; var pagecells = VisioAutomation.Pages.PageCells.GetCells(page.PageSheet); var newpagecells = new VisioAutomation.Pages.PageCells(); if (this.Width > 0) { newpagecells.PageWidth = this.Width; } if (this.Height > 0) { newpagecells.PageHeight = this.Height; } var update = new VisioAutomation.ShapeSheet.Update(); update.SetFormulas(newpagecells); update.BlastGuards = true; update.Execute(page); } }
protected override void ProcessRecord() { if (this.FitContents) { var bordersize = new VisioAutomation.Drawing.Size(this.BorderWidth, this.BorderWidth); this.Client.Page.ResizeToFitContents(bordersize, true); } if (this.Width > 0 || this.Height > 0) { var page = this.Client.Application.Get().ActivePage; var pagecells = VisioAutomation.Pages.PageCells.GetCells(page.PageSheet); var newpagecells = new VisioAutomation.Pages.PageCells(); if (this.Width > 0) { newpagecells.PageWidth = this.Width; } if (this.Height > 0) { newpagecells.PageHeight = this.Height; } var update = new VisioAutomation.ShapeSheet.Update(); update.SetFormulas(newpagecells); update.BlastGuards = true; update.Execute(page); } }
public void CheckHomogenousUpdates_ResultTypes() { var page1 = this.GetNewPage(); var shape1 = page1.DrawRectangle(0, 0, 1, 1); // Setup the modifications to the cell values var update = new VA.ShapeSheet.Update(); update.SetResult(ShapeSheet_Update_Tests.src_linepat, "7", IVisio.VisUnitCodes.visNumber); update.SetResult(VA.ShapeSheet.SRCConstants.PinX, 2, IVisio.VisUnitCodes.visNumber); update.Execute(shape1); // Build the query var query = new VA.ShapeSheet.Query.CellQuery(); var col_linepat = query.AddCell(ShapeSheet_Update_Tests.src_linepat, "LinePattern"); var col_pinx = query.AddCell(VA.ShapeSheet.SRCConstants.PinX, "PinX"); // Retrieve the values var data = query.GetCellData <double>(shape1); // Verify AssertVA.AreEqual("7", 7, data[col_linepat]); AssertVA.AreEqual("2 in", 2, data[col_pinx]); page1.Delete(0); }
internal void ApplyFormulas(VA.ShapeSheet.Update update, short row) { update.SetFormulaIgnoreNull(SRCCON.CharColor.ForRow(row), this.Color); update.SetFormulaIgnoreNull(SRCCON.CharFont.ForRow(row), this.Font); update.SetFormulaIgnoreNull(SRCCON.CharSize.ForRow(row), this.Size); update.SetFormulaIgnoreNull(SRCCON.CharStyle.ForRow(row), this.Style); update.SetFormulaIgnoreNull(SRCCON.CharColorTrans.ForRow(row), this.Transparency); update.SetFormulaIgnoreNull(SRCCON.CharAsianFont.ForRow(row), this.AsianFont); update.SetFormulaIgnoreNull(SRCCON.CharCase.ForRow(row), this.Case); update.SetFormulaIgnoreNull(SRCCON.CharComplexScriptFont.ForRow(row), this.ComplexScriptFont); update.SetFormulaIgnoreNull(SRCCON.CharComplexScriptSize.ForRow(row), this.ComplexScriptSize); update.SetFormulaIgnoreNull(SRCCON.CharDblUnderline.ForRow(row), this.DoubleUnderline); update.SetFormulaIgnoreNull(SRCCON.CharDoubleStrikethrough.ForRow(row), this.DoubleStrikeThrough); update.SetFormulaIgnoreNull(SRCCON.CharLangID.ForRow(row), this.LangID); update.SetFormulaIgnoreNull(SRCCON.CharFontScale.ForRow(row), this.FontScale); update.SetFormulaIgnoreNull(SRCCON.CharLangID.ForRow(row), this.LangID); update.SetFormulaIgnoreNull(SRCCON.CharLetterspace.ForRow(row), this.Letterspace); update.SetFormulaIgnoreNull(SRCCON.CharLocale.ForRow(row), this.Locale); update.SetFormulaIgnoreNull(SRCCON.CharLocalizeFont.ForRow(row), this.LocalizeFont); update.SetFormulaIgnoreNull(SRCCON.CharOverline.ForRow(row), this.Overline); update.SetFormulaIgnoreNull(SRCCON.CharPerpendicular.ForRow(row), this.Perpendicular); update.SetFormulaIgnoreNull(SRCCON.CharPos.ForRow(row), this.Pos); update.SetFormulaIgnoreNull(SRCCON.CharRTLText.ForRow(row), this.RTLText); update.SetFormulaIgnoreNull(SRCCON.CharStrikethru.ForRow(row), this.Strikethru); update.SetFormulaIgnoreNull(SRCCON.CharUseVertical.ForRow(row), this.UseVertical); }
public void Apply(VA.ShapeSheet.Update update, short id) { update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.AvenueSizeX, AvenueSizeX); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.AvenueSizeY, AvenueSizeY); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.BlockSizeX, BlockSizeX); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.BlockSizeY, BlockSizeY); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.CtrlAsInput, CtrlAsInput); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.DynamicsOff, DynamicsOff); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.EnableGrid, EnableGrid); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.LineAdjustFrom, LineAdjustFrom); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.LineAdjustTo, LineAdjustTo); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.LineJumpCode, LineJumpCode); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.LineJumpFactorX, LineJumpFactorX); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.LineJumpFactorY, LineJumpFactorY); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.LineJumpStyle, LineJumpStyle); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.LineRouteExt, LineRouteExt); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.LineToLineX, LineToLineX); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.LineToLineY, LineToLineY); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.LineToNodeX, LineToNodeX); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.LineToNodeY, LineToNodeY); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.PageLineJumpDirX, PageLineJumpDirX); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.PageLineJumpDirY, PageLineJumpDirY); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.PageShapeSplit, PageShapeSplit); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.PlaceDepth, PlaceDepth); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.PlaceFlip, PlaceFlip); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.PlaceStyle, PlaceStyle); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.PlowCode, PlowCode); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.ResizePage, ResizePage); update.SetFormulaIgnoreNull(id, ShapeSheet.SRCConstants.RouteStyle, RouteStyle); }
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 c1 = page.Drop(dcm, new VA.Drawing.Point(-2, -2)); VACXN.ConnectorHelper.ConnectShapes(a, b, c1); //a.AutoConnect(b, connect_dir_none, null); if (a_arrow || b_arrow) { var update = new VA.ShapeSheet.Update(); if (a_arrow) { update.SetFormula(c1.ID16, VA.ShapeSheet.SRCConstants.BeginArrow, "13"); } if (b_arrow) { update.SetFormula(c1.ID16, VA.ShapeSheet.SRCConstants.EndArrow, "13"); } update.Execute(page); } }
private static void TestResize(IVisio.Document doc, VA.Drawing.Size bottomleft_margin, VA.Drawing.Size upperright_margin, VA.Drawing.Size shape_size, VA.Drawing.Size padding_size, double expected_pinx, double expected_piny) { var page = doc.Pages.Add(); var pagecells = new VA.Pages.PageCells(); pagecells.PageTopMargin = upperright_margin.Height; pagecells.PageBottomMargin = bottomleft_margin.Height; pagecells.PageLeftMargin = bottomleft_margin.Width; pagecells.PageRightMargin = upperright_margin.Width; var pageupdate = new VA.ShapeSheet.Update(); pageupdate.SetFormulas(pagecells); pageupdate.Execute(page.PageSheet); var shape = page.DrawRectangle(5, 5, 5 + shape_size.Width, 5+shape_size.Height); page.ResizeToFitContents(padding_size); var xform = VA.Shapes.XFormCells.GetCells(shape); AssertVA.AreEqual(expected_pinx, expected_piny, xform.Pin(), 0.1); page.Delete(0); }
public short Render(IVisio.Shape shape) { short sec_index = GeometryHelper.AddSection(shape); short row_count = shape.RowCount[sec_index]; var update = new VA.ShapeSheet.Update(); var src_nofill = VA.ShapeSheet.SRCConstants.Geometry_NoFill.ForSectionAndRow(sec_index, 0); var src_noline = VA.ShapeSheet.SRCConstants.Geometry_NoLine.ForSectionAndRow(sec_index, 0); var src_noshow = VA.ShapeSheet.SRCConstants.Geometry_NoShow.ForSectionAndRow(sec_index, 0); var src_nosnap = VA.ShapeSheet.SRCConstants.Geometry_NoSnap.ForSectionAndRow(sec_index, 0); //var src_noquickdrag = VA.ShapeSheet.SRCConstants.Geometry_NoQuickDrag.ForSectionAndRow(sec_index, 0); update.SetFormulaIgnoreNull(src_nofill, this.NoFill); update.SetFormulaIgnoreNull(src_noline, this.NoLine); update.SetFormulaIgnoreNull(src_noshow, this.NoShow); update.SetFormulaIgnoreNull(src_nosnap, this.NoSnap); //update.SetFormulaIgnoreNull(src_noquickdrag, this.NoQuickDrag); foreach (var row in this.Rows) { row.AddTo(shape, update, row_count, sec_index); row_count++; } update.Execute(shape); return(0); }
private static void TestResize(IVisio.Document doc, VA.Drawing.Size bottomleft_margin, VA.Drawing.Size upperright_margin, VA.Drawing.Size shape_size, VA.Drawing.Size padding_size, double expected_pinx, double expected_piny) { var page = doc.Pages.Add(); var pagecells = new VA.Pages.PageCells(); pagecells.PageTopMargin = upperright_margin.Height; pagecells.PageBottomMargin = bottomleft_margin.Height; pagecells.PageLeftMargin = bottomleft_margin.Width; pagecells.PageRightMargin = upperright_margin.Width; var pageupdate = new VA.ShapeSheet.Update(); pageupdate.SetFormulas(pagecells); pageupdate.Execute(page.PageSheet); var shape = page.DrawRectangle(5, 5, 5 + shape_size.Width, 5 + shape_size.Height); page.ResizeToFitContents(padding_size); var xform = VA.Shapes.XFormCells.GetCells(shape); AssertVA.AreEqual(expected_pinx, expected_piny, xform.Pin(), 0.1); page.Delete(0); }
public static int Add( IVisio.Shape shape, ConnectionPointCells cp) { if (shape == null) { throw new System.ArgumentNullException("shape"); } if (!cp.X.Formula.HasValue) { throw new System.ArgumentException("Must provide an X Formula"); } if (!cp.Y.Formula.HasValue) { throw new System.ArgumentException("Must provide an Y Formula"); } var n = shape.AddRow((short)IVisio.VisSectionIndices.visSectionConnectionPts, (short)IVisio.VisRowIndices.visRowLast, (short)IVisio.VisRowTags.visTagCnnctPt); var update = new VA.ShapeSheet.Update(); update.SetFormulas(cp, n); update.Execute(shape); return(n); }
public static int Set( IVisio.Shape shape, short row, VACONTROL.ControlCells ctrl) { if (shape == null) { throw new ArgumentNullException("shape"); } if (!ctrl.XDynamics.Formula.HasValue) { ctrl.XDynamics = String.Format("Controls.Row_{0}", row + 1); } if (!ctrl.YDynamics.Formula.HasValue) { ctrl.YDynamics = String.Format("Controls.Row_{0}.Y", row + 1); } var update = new VA.ShapeSheet.Update(); update.SetFormulas(ctrl, row); update.Execute(shape); return(row); }
/// <summary> /// Remove all tab stops on the shape /// </summary> /// <param name="shape"></param> private static void ClearTabStops(IVisio.Shape shape) { if (shape == null) { throw new System.ArgumentNullException("shape"); } int num_existing_tabstops = GetTabStopCount(shape); if (num_existing_tabstops < 1) { return; } var cell_tabstopcount = shape.CellsSRC[src_tabstopcount.Section, src_tabstopcount.Row, src_tabstopcount.Cell]; cell_tabstopcount.FormulaForce = "0"; const string formula = "0"; var update = new VA.ShapeSheet.Update(); for (int i = 1; i < num_existing_tabstops * 3; i++) { var src = new VA.ShapeSheet.SRC(tab_section, (short)IVisio.VisRowIndices.visRowTab, (short)i); update.SetFormula(src, formula); } update.Execute(shape); }
public void SetSize(IList <IVisio.Shape> target_shapes, double?w, double?h) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var shapes = GetTargetShapes(target_shapes); if (shapes.Count < 1) { return; } var shapeids = shapes.Select(s => s.ID).ToList(); var update = new VA.ShapeSheet.Update(); foreach (int shapeid in shapeids) { if (w.HasValue && w.Value >= 0) { update.SetFormula((short)shapeid, VA.ShapeSheet.SRCConstants.Width, w.Value); } if (h.HasValue && h.Value >= 0) { update.SetFormula((short)shapeid, VA.ShapeSheet.SRCConstants.Height, h.Value); } } var application = this.Client.VisioApplication; using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication, "Set Shape Size")) { var active_page = application.ActivePage; update.Execute(active_page); } }
public void Apply(VA.ShapeSheet.Update update, short shapeid_label, short shapeid_box) { update.SetFormulas(shapeid_label, this.CharacterCells, 0); update.SetFormulas(shapeid_label, this.ParagraphCells, 0); update.SetFormulas(shapeid_box, this.FormatCells); update.SetFormulas(shapeid_label, this.TextCells); }
public void ApplyFormus(VA.ShapeSheet.Update update) { short titleshape_id = this.VisioShape.ID16; update.SetFormulas(titleshape_id, this.Textcells); update.SetFormulas(titleshape_id, this.ParagraphCells, 0); update.SetFormulas(titleshape_id, this.CharacterCells, 0); update.SetFormulas(titleshape_id, this.FormatCells); }
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.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.Grid.RowDirection.BottomToTop; layout.PerformLayout(); layout.Render(page); var fmtcells = new VA.Shapes.FormatCells(); int i = 0; var update = new VA.ShapeSheet.Update(); foreach (var node in layout.Nodes) { var shapeid = node.ShapeID; int color_index = i%colors.Length; var color = colors[color_index]; fmtcells.FillForegnd = new VA.Drawing.ColorRGB(color).ToFormula(); fmtcells.LinePattern = 0; fmtcells.LineWeight = 0; update.SetFormulas(shapeid, fmtcells); i++; } update.Execute(page); var bordersize = new VA.Drawing.Size(1,1); page.ResizeToFitContents(bordersize); }
public void Render(IVisio.Page page) { if (page == null) { throw new System.ArgumentNullException("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 VA.Application.PerfScope(app, PerfSettings)) { if (this.Size.HasValue) { this.PageCells.PageHeight = this.Size.Value.Height; this.PageCells.PageWidth = this.Size.Value.Width; } var update = new VA.ShapeSheet.Update(); update.SetFormulas((short)page_sheet.ID, this.PageCells); update.Execute(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(); } } } }
private static void SetSize(IVisio.Page page, VA.Drawing.Size size) { var page_cells = new VA.Pages.PageCells(); page_cells.PageHeight = size.Height; page_cells.PageWidth = size.Width; var pageupdate = new VA.ShapeSheet.Update(); pageupdate.SetFormulas(page_cells); pageupdate.Execute(page.PageSheet); }
public static void Set(IVisio.Shape shape, string name, string value, string prompt) { if (shape == null) { throw new System.ArgumentNullException("shape"); } CheckValidName(name); if (Contains(shape, name)) { string full_prop_name = GetRowName(name); if (value != null) { string value_cell_name = full_prop_name; var cell = shape.CellsU[value_cell_name]; string value_formula = Convert.StringToFormulaString(value); cell.FormulaU = value_formula; } if (prompt != null) { string prompt_cell_name = full_prop_name + ".Prompt"; var cell = shape.CellsU[prompt_cell_name]; var prompt_formula = Convert.StringToFormulaString(prompt); cell.FormulaU = prompt_formula; } return; } short row = shape.AddNamedRow( _userdefinedcell_section, name, (short)IVisio.VisRowIndices.visRowUser); var update = new VA.ShapeSheet.Update(); if (value != null) { string value_formula = Convert.StringToFormulaString(value); var src = new VA.ShapeSheet.SRC(_userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserValue); update.SetFormula(src, value_formula); } if (prompt != null) { string prompt_formula = Convert.StringToFormulaString(prompt); var src = new VA.ShapeSheet.SRC(_userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserPrompt); update.SetFormula(src, prompt_formula); } update.Execute(shape); }
public void Apply(IVisio.Page page) { var pagecells = new VA.Pages.PageCells(); this.SetPageCells(pagecells); var update = new VA.ShapeSheet.Update(); update.SetFormulas(pagecells); var pagesheet = page.PageSheet; update.Execute(pagesheet); page.Layout(); }
public void ToogleCase(IList <IVisio.Shape> target_shapes) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var shapes = this.GetTargetShapes(target_shapes); if (shapes.Count < 1) { return; } using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication, "Toggle Shape Text Case")) { var shapeids = shapes.Select(s => s.ID).ToList(); var page = this.Client.VisioApplication.ActivePage; // Store all the formatting var formats = VA.Text.TextFormat.GetFormat(page, shapeids); // Change the text - this will wipe out all the character and paragraph formatting foreach (var shape in shapes) { string t = shape.Text; if (t.Length < 1) { continue; } shape.Text = TextCommandsUtil.toggle_case(t); } // Now restore all the formatting - based on any initial formatting from the text var update = new VA.ShapeSheet.Update(); for (int i = 0; i < shapes.Count; i++) { var format = formats[i]; if (format.CharacterFormats.Count > 0) { var fmt = format.CharacterFormats[0]; update.SetFormulas((short)shapeids[i], fmt, 0); } if (format.ParagraphFormats.Count > 0) { var fmt = format.ParagraphFormats[0]; update.SetFormulas((short)shapeids[i], fmt, 0); } } update.Execute(page); } }
private static void update_xfrms(IVisio.Page page, IList <int> shapeids, IList <VA.Shapes.XFormCells> xfrms) { var update = new VA.ShapeSheet.Update(); for (int i = 0; i < shapeids.Count; i++) { var shape_id = shapeids[i]; var xfrm = xfrms[i]; update.SetFormulas((short)shape_id, xfrm); } update.Execute(page); }
public static void SetTabStops(IVisio.Shape shape, IList <TabStop> stops) { if (shape == null) { throw new System.ArgumentNullException("shape"); } if (stops == null) { throw new System.ArgumentNullException("stops"); } ClearTabStops(shape); if (stops.Count < 1) { return; } const short row = 0; var invariant_culture = System.Globalization.CultureInfo.InvariantCulture; var vis_tab_stop_count = (short)IVisio.VisCellIndices.visTabStopCount; var tabstopcountcell = shape.CellsSRC[tab_section, row, vis_tab_stop_count]; tabstopcountcell.FormulaU = stops.Count.ToString(invariant_culture); // set the number of tab stobs allowed for the shape var tagtab = GetTabTagForStops(stops.Count); shape.RowType[tab_section, (short)IVisio.VisRowIndices.visRowTab] = (short)tagtab; // add tab properties for each stop var update = new VA.ShapeSheet.Update(); for (int stop_index = 0; stop_index < stops.Count; stop_index++) { int i = stop_index * 3; var alignment = ((int)stops[stop_index].Alignment).ToString(invariant_culture); var position = ((int)stops[stop_index].Position).ToString(invariant_culture); var src_tabpos = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 1)); var src_tabalign = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 2)); var src_tabother = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 3)); update.SetFormula(src_tabpos, position); // tab position update.SetFormula(src_tabalign, alignment); // tab alignment update.SetFormula(src_tabother, "0"); // tab unknown } update.Execute(shape); }
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.FormatCells(); background_fmt.FillForegnd = "rgb(240,240,240)"; background_fmt.LineColor = "rgb(100,100,100)"; var progress_fmt = new VA.Shapes.FormatCells(); 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 update = new VA.ShapeSheet.Update(); update.SetFormulas(progress.ID16, xform); update.SetFormulas(progress.ID16, background_fmt); update.SetFormulas(progress.ID16, progress_fmt); update.Execute(page_a); var markup1 = new VA.Text.Markup.TextElement(); markup1.AddField(VA.Text.Markup.FieldConstants.PageName); markup1.AddText(" ("); markup1.AddField(VA.Text.Markup.FieldConstants.PageNumber); markup1.AddText(" of "); markup1.AddField(VA.Text.Markup.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 => GetPointAtRadius(origin, a, radius)).ToList(); var shapes = centers.Select(p => draw_leaf(page, p)).ToList(); var angles_as_formulas = angles.Select(a => a.ToString()).ToList(); var color_formulas = colors.Select(x => new VA.Drawing.ColorRGB(x).ToFormula()).ToList(); var shapeids = shapes.Select(s => s.ID16).ToList(); var update = new VA.ShapeSheet.Update(); var format = new VA.Shapes.FormatCells(); 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; update.SetFormulas(shapeid, xfrm); update.SetFormulas(shapeid, format); } update.Execute(page); VA.Pages.PageHelper.ResizeToFitContents(page, new VA.Drawing.Size(1.0, 1.0)); }
public static void SetPageSize(IVisio.Page page, VA.Drawing.Size size) { if (page == null) { throw new System.ArgumentNullException("page"); } var page_sheet = page.PageSheet; var update = new VA.ShapeSheet.Update(2); update.SetFormula(VA.ShapeSheet.SRCConstants.PageWidth, size.Width); update.SetFormula(VA.ShapeSheet.SRCConstants.PageHeight, size.Height); update.Execute(page_sheet); }
public void Apply(IVisio.Page page) { var pagecells = new VA.Pages.PageCells(); this.SetPageCells(pagecells); var update = new VA.ShapeSheet.Update(); update.SetFormulas(pagecells); var pagesheet = page.PageSheet; update.Execute(pagesheet); page.Layout(); }
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.Drawing.ColorRGB(x).ToFormula()).ToList(); var shapeids = shapes.Select(s => s.ID16).ToList(); var update = new VA.ShapeSheet.Update(); var format = new VA.Shapes.FormatCells(); 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; update.SetFormulas(shapeid, xfrm); update.SetFormulas(shapeid, format); } update.Execute(page); VA.Pages.PageHelper.ResizeToFitContents(page, new VA.Drawing.Size(1.0, 1.0)); }
private void UpdateCells(RenderContext ctx) { UpdateCellsWithDropSizes(ctx); var update = new VA.ShapeSheet.Update(); 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(update, id); } update.Execute(ctx.VisioPage); }
public static void SetPageSize(IVisio.Page page, VA.Drawing.Size size) { if (page == null) { throw new System.ArgumentNullException("page"); } var page_sheet = page.PageSheet; var update = new VA.ShapeSheet.Update(2); update.SetFormula(VA.ShapeSheet.SRCConstants.PageWidth, size.Width); update.SetFormula(VA.ShapeSheet.SRCConstants.PageHeight, size.Height); update.Execute(page_sheet); }
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 update = new VA.ShapeSheet.Update(); foreach (int shapeid in shapeids) { update.SetFormula((short)shapeid, VA.ShapeSheet.SRCConstants.TxtWidth, formula); } update.Execute(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 update = new VA.ShapeSheet.Update(); foreach (int shapeid in shapeids) { update.SetFormula((short)shapeid, VA.ShapeSheet.SRCConstants.TxtWidth, formula); } update.Execute(page); }
internal void ApplyFormulas(VA.ShapeSheet.Update update, short row) { update.SetFormulaIgnoreNull(SRCCON.Para_IndLeft.ForRow(row), this.IndentLeft); update.SetFormulaIgnoreNull(SRCCON.Para_IndFirst.ForRow(row), this.IndentFirst); update.SetFormulaIgnoreNull(SRCCON.Para_IndRight.ForRow(row), this.IndentRight); update.SetFormulaIgnoreNull(SRCCON.Para_SpAfter.ForRow(row), this.SpacingAfter); update.SetFormulaIgnoreNull(SRCCON.Para_SpBefore.ForRow(row), this.SpacingBefore); update.SetFormulaIgnoreNull(SRCCON.Para_SpLine.ForRow(row), this.SpacingLine); update.SetFormulaIgnoreNull(SRCCON.Para_HorzAlign.ForRow(row), this.HorizontalAlign); update.SetFormulaIgnoreNull(SRCCON.Para_BulletFont.ForRow(row), this.BulletFont); update.SetFormulaIgnoreNull(SRCCON.Para_Bullet.ForRow(row), this.Bullet); update.SetFormulaIgnoreNull(SRCCON.Para_BulletFontSize.ForRow(row), this.BulletFontSize); update.SetFormulaIgnoreNull(SRCCON.Para_LocalizeBulletFont.ForRow(row), this.LocBulletFont); update.SetFormulaIgnoreNull(SRCCON.Para_TextPosAfterBullet.ForRow(row), this.TextPosAfterBullet); update.SetFormulaIgnoreNull(SRCCON.Para_Flags.ForRow(row), this.Flags); update.SetFormulaIgnoreNull(SRCCON.Para_BulletStr.ForRow(row), this.BulletString); }
public void SetSize(VA.Drawing.Size new_size) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var application = this.Client.VisioApplication; using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication, "Set Page Size")) { var active_page = application.ActivePage; var page_sheet = active_page.PageSheet; var update = new VA.ShapeSheet.Update(2); update.SetFormula(VA.ShapeSheet.SRCConstants.PageWidth, new_size.Width); update.SetFormula(VA.ShapeSheet.SRCConstants.PageHeight, new_size.Height); update.Execute(page_sheet); } }
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.FormatCells(); background_fmt.FillForegnd= "rgb(240,240,240)"; background_fmt.LineColor = "rgb(100,100,100)"; var progress_fmt = new VA.Shapes.FormatCells(); 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 update = new VA.ShapeSheet.Update(); update.SetFormulas(progress.ID16, xform); update.SetFormulas(progress.ID16, background_fmt); update.SetFormulas(progress.ID16, progress_fmt); update.Execute(page_a); var markup1 = new VA.Text.Markup.TextElement(); markup1.AddField(VA.Text.Markup.FieldConstants.PageName); markup1.AddText(" ("); markup1.AddField(VA.Text.Markup.FieldConstants.PageNumber); markup1.AddText(" of "); markup1.AddField(VA.Text.Markup.FieldConstants.NumberOfPages); markup1.AddText(") "); markup1.SetText(group); }
public void Page_Query() { var page1 = this.GetNewPage(new VA.Drawing.Size(4, 3)); var pagecells = VA.Pages.PageCells.GetCells(page1.PageSheet); Assert.AreEqual(new VA.Drawing.Size(4, 3), new VA.Drawing.Size(pagecells.PageWidth.Result,pagecells.PageHeight.Result)); // Double each side pagecells.PageWidth = pagecells.PageWidth.Result * 2.0; pagecells.PageHeight = pagecells.PageHeight.Result * 2.0; var update = new VA.ShapeSheet.Update(); update.SetFormulas(pagecells); update.Execute(page1.PageSheet); var pagecells2 = VA.Pages.PageCells.GetCells(page1.PageSheet); Assert.AreEqual(new VA.Drawing.Size(8, 6), new VA.Drawing.Size(pagecells2.PageWidth.Result, pagecells2.PageHeight.Result)); page1.Delete(0); }
private void Update(short section, short row_index, VA.ShapeSheet.Update update) { var x_src = VA.ShapeSheet.SRCConstants.Geometry_X.ForSectionAndRow(section, row_index); var y_src = VA.ShapeSheet.SRCConstants.Geometry_Y.ForSectionAndRow(section, row_index); var a_src = VA.ShapeSheet.SRCConstants.Geometry_A.ForSectionAndRow(section, row_index); var b_src = VA.ShapeSheet.SRCConstants.Geometry_B.ForSectionAndRow(section, row_index); var c_src = VA.ShapeSheet.SRCConstants.Geometry_C.ForSectionAndRow(section, row_index); var d_src = VA.ShapeSheet.SRCConstants.Geometry_D.ForSectionAndRow(section, row_index); var e_src = VA.ShapeSheet.SRCConstants.Geometry_E.ForSectionAndRow(section, row_index); update.SetFormulaIgnoreNull(x_src, this.X); update.SetFormulaIgnoreNull(y_src, this.Y); update.SetFormulaIgnoreNull(a_src, this.A); update.SetFormulaIgnoreNull(b_src, this.B); update.SetFormulaIgnoreNull(c_src, this.C); update.SetFormulaIgnoreNull(d_src, this.D); update.SetFormulaIgnoreNull(e_src, this.E); }
public void CheckHomogenousUpdates_FormulasResults() { var update1 = new VA.ShapeSheet.Update(); update1.SetResult(ShapeSheet_Update_Tests.src_pinx, 5.0, IVisio.VisUnitCodes.visNumber); bool caught1 = false; try { update1.SetFormula(ShapeSheet_Update_Tests.src_pinx, "5.0"); } catch (VA.AutomationException) { caught1 = true; } if (!caught1) { Assert.Fail(); } }
public void CheckHomogenousUpdates_Streams() { var update1 = new VA.ShapeSheet.Update(); update1.SetResult(src_pinx, 5.0, IVisio.VisUnitCodes.visNumber); bool caught1 = false; try { update1.SetResult(1, src_pinx, 5.0, IVisio.VisUnitCodes.visNumber); } catch (VA.AutomationException) { caught1 = true; } if (!caught1) { Assert.Fail(); } }
public void ShapeSheet_Update_ResultsString_SingleShape() { var page1 = this.GetNewPage(); var shape1 = page1.DrawRectangle(0, 0, 1, 1); // Setup the modifications to the cell values var update = new VA.ShapeSheet.Update(); update.SetResult(ShapeSheet_Update_Tests.src_linepat, "7", IVisio.VisUnitCodes.visNumber); update.Execute(shape1); // Build the query var query = new VA.ShapeSheet.Query.CellQuery(); var col_linepat = query.AddCell(ShapeSheet_Update_Tests.src_linepat, "LinePattern"); // Retrieve the values var data = query.GetCellData<double>(shape1); // Verify AssertVA.AreEqual("7", 7, data[col_linepat]); page1.Delete(0); }
protected override void ProcessRecord() { var update = new VisioAutomation.ShapeSheet.Update(); update.BlastGuards = this.BlastGuards; update.TestCircular = this.TestCircular; var cellmap = CellSRCDictionary.GetCellMapForShapes(); var valuemap = new CellValueDictionary(cellmap, this.Hashtable); var target_shapes = this.Shapes ?? this.client.Selection.GetShapes(); this.DumpValues(valuemap); foreach (var shape in target_shapes) { var id = shape.ID16; foreach (var cellname in valuemap.CellNames) { string cell_value = valuemap[cellname]; var cell_src = valuemap.GetSRC(cellname); update.SetFormulaIgnoreNull(id,cell_src, cell_value); } } var surface = this.client.ShapeSheet.GetShapeSheetSurface(); this.WriteVerbose("BlastGuards: {0}", this.BlastGuards); this.WriteVerbose("TestCircular: {0}", this.TestCircular); this.WriteVerbose("Number of Shapes : {0}", target_shapes.Count); this.WriteVerbose("Number of Total Updates: {0}", update.Count()); using (var undoscope = this.client.Application.NewUndoScope( "SetShapeCells")) { this.WriteVerbose("Start Update"); update.Execute(surface); this.WriteVerbose("End Update"); } }
public void ShapeSheet_Update_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 update = new VA.ShapeSheet.Update(); update.SetFormula(shape1.ID16, ShapeSheet_Update_Tests.src_pinx, 0.5); update.SetFormula(shape1.ID16, ShapeSheet_Update_Tests.src_piny, 0.5); update.SetFormula(shape2.ID16, ShapeSheet_Update_Tests.src_pinx, 1.5); update.SetFormula(shape2.ID16, ShapeSheet_Update_Tests.src_piny, 1.5); update.SetFormula(shape3.ID16, ShapeSheet_Update_Tests.src_pinx, 2.5); update.SetFormula(shape3.ID16, ShapeSheet_Update_Tests.src_piny, 2.5); update.Execute(page1); // Verify that the formulas were set var query = new VA.ShapeSheet.Query.CellQuery(); var col_pinx = query.AddCell(ShapeSheet_Update_Tests.src_pinx, "PinX"); var col_piny = query.AddCell(ShapeSheet_Update_Tests.src_piny, "PinY"); var shapeids = new[] { shape1.ID, shape2.ID, shape3.ID }; var rf = query.GetFormulas(page1, shapeids); var rr = query.GetResults<double>(page1, shapeids); AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_pinx], rr[0][col_pinx]); AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_piny], rr[0][col_piny]); AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_pinx], rr[1][col_pinx]); AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_piny], rr[1][col_piny]); AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_pinx], rr[2][col_pinx]); AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_piny], rr[2][col_piny]); page1.Delete(0); }
private void buttonSetFillGradient_Click(object sender, System.EventArgs e) { var client = VisioPowerToolsAddIn.Client; var selection = client.Selection.Get(); if (selection.Count < 1) { return; } var format = new VA.Shapes.FormatCells(); format.FillPattern = (int) this.fillGradient1.FillDef.FillPattern; format.FillForegnd= VA.Convert.ColorToFormulaRGB(this.fillGradient1.FillDef.ForegroundColor); format.FillBkgnd= VA.Convert.ColorToFormulaRGB(this.fillGradient1.FillDef.BackgroundColor); format.FillForegndTrans= this.fillGradient1.FillDef.ForegroundTransparency/100.0; format.FillBkgndTrans= this.fillGradient1.FillDef.BackgroundTransparency / 100.0; format.ShdwPattern= (int) this.fillGradient1.ShadowDef.FillPattern; format.ShdwForegnd= VA.Convert.ColorToFormulaRGB(this.fillGradient1.ShadowDef.ForegroundColor); format.ShdwBkgnd = VA.Convert.ColorToFormulaRGB(this.fillGradient1.ShadowDef.BackgroundColor); format.ShdwForegndTrans = this.fillGradient1.ShadowDef.ForegroundTransparency/100.0; format.ShdwBkgndTrans= this.fillGradient1.ShadowDef.BackgroundTransparency/100.0; format.ShapeShdwOffsetX = 0.0; format.ShapeShdwOffsetY = 0.0; format.ShapeShdwScaleFactor = 1.0; format.ShapeShdwType= 5; var update = new VA.ShapeSheet.Update(); var shapes = client.Selection.GetShapes().ToList(); var shapeids = shapes.Select(s => s.ID).ToList(); foreach (int shapeid in shapeids) { update.SetFormulas((short)shapeid,format); } update.Execute(client.VisioApplication.ActivePage); }
public void SetLock(IList<IVisio.Shape> target_shapes, VA.Shapes.LockCells lockcells) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var shapes = GetTargetShapes(target_shapes); if (shapes.Count < 1) { return; } var selection = this.Client.Selection.Get(); var shapeids = selection.GetIDs(); var update = new VA.ShapeSheet.Update(); foreach (int shapeid in shapeids) { update.SetFormulas((short)shapeid, lockcells); } var application = this.Client.VisioApplication; using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication,"Set Shape Lock Properties")) { var active_page = application.ActivePage; update.Execute(active_page); } }
public void PasteSize(IList<IVisio.Shape> target_shapes, bool paste_width, bool paste_height) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var shapes = this.GetTargetShapes(target_shapes); if (shapes.Count < 1) { return; } if ((!cached_size_width.HasValue) && (!cached_size_height.HasValue)) { return; } var update = new VA.ShapeSheet.Update(); var shapeids = shapes.Select(s => s.ID).ToList(); foreach (var shapeid in shapeids) { if (paste_width) { update.SetFormula((short)shapeid, VA.ShapeSheet.SRCConstants.Width, cached_size_width.Value); } if (paste_height) { update.SetFormula((short)shapeid, VA.ShapeSheet.SRCConstants.Height, cached_size_height.Value); } } var application = this.Client.VisioApplication; var active_page = application.ActivePage; update.Execute(active_page); }
public void PasteFormat(IVisio.Page page, IList<int> shapeids, FormatCategory category, bool applyformulas) { var update = new VA.ShapeSheet.Update(); foreach (var shape_id in shapeids) { foreach (var cellrec in this.Cells) { if (!cellrec.MatchesCategory(category)) { continue; } var sidsrc = new VA.ShapeSheet.SIDSRC((short)shape_id, cellrec.SRC); if (applyformulas) { update.SetFormula(sidsrc, cellrec.Formula); } else { if (cellrec.Result != null) { update.SetFormula(sidsrc, cellrec.Result); } } } } update.Execute(page); }
public void ShapeSheet_Update_ResultsInt_SingleShape() { var page1 = GetNewPage(); var shape1 = page1.DrawRectangle(0, 0, 1, 1); // Setup the modifications to the cell values var update = new VA.ShapeSheet.Update(); update.SetResult(src_linepat, 7, IVisio.VisUnitCodes.visNumber); update.Execute(shape1); // Build the query var query = new VA.ShapeSheet.Query.CellQuery(); var col_linepat = query.Columns.Add(src_linepat,"LinePattern"); // Retrieve the values var data = query.GetFormulasAndResults<double>(shape1); // Verify AssertVA.AreEqual("7", 7, data[col_linepat.Ordinal]); page1.Delete(0); }
public void ShapeSheet_Update_ResultsDouble_MultipleShapes() { var page1 = 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 update = new VA.ShapeSheet.Update(); update.SetResult(shape1.ID16, src_pinx, 0.5, IVisio.VisUnitCodes.visNumber); update.SetResult(shape1.ID16, src_piny, 0.5, IVisio.VisUnitCodes.visNumber); update.SetResult(shape2.ID16, src_pinx, 1.5, IVisio.VisUnitCodes.visNumber); update.SetResult(shape2.ID16, src_piny, 1.5, IVisio.VisUnitCodes.visNumber); update.SetResult(shape3.ID16, src_pinx, 2.5, IVisio.VisUnitCodes.visNumber); update.SetResult(shape3.ID16, src_piny, 2.5, IVisio.VisUnitCodes.visNumber); update.Execute(page1); // Verify that the formulas were set var query = new VA.ShapeSheet.Query.CellQuery(); var col_pinx = query.Columns.Add(src_pinx,"PinX"); var col_piny = query.Columns.Add(src_piny,"PinY"); var shapeids = new[] { shape1.ID, shape2.ID, shape3.ID }; var rf = query.GetFormulas(page1, shapeids); var rr = query.GetResults<double>(page1, shapeids); AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_pinx.Ordinal], rr[0][col_pinx.Ordinal]); AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_piny.Ordinal], rr[0][col_piny.Ordinal]); AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_pinx.Ordinal], rr[1][col_pinx.Ordinal]); AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_piny.Ordinal], rr[1][col_piny.Ordinal]); AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_pinx.Ordinal], rr[2][col_pinx.Ordinal]); AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_piny.Ordinal], rr[2][col_piny.Ordinal]); page1.Delete(0); }
public static int Set( IVisio.Shape shape, short row, VACONTROL.ControlCells ctrl) { if (shape == null) { throw new ArgumentNullException("shape"); } if (!ctrl.XDynamics.Formula.HasValue) { ctrl.XDynamics = String.Format("Controls.Row_{0}", row + 1); } if (!ctrl.YDynamics.Formula.HasValue) { ctrl.YDynamics = String.Format("Controls.Row_{0}.Y", row + 1); } var update = new VA.ShapeSheet.Update(); update.SetFormulas(ctrl, row); update.Execute(shape); return row; }
public void SetOrientation(VA.Pages.PrintPageOrientation orientation) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var application = this.Client.VisioApplication; var active_page = application.ActivePage; if (orientation != VA.Pages.PrintPageOrientation.Landscape && orientation != VA.Pages.PrintPageOrientation.Portrait) { throw new System.ArgumentOutOfRangeException("orientation", "must be either Portrait or Landscape"); } var old_orientation = GetOrientation(active_page); if (old_orientation == orientation) { // don't need to do anything return; } var old_size = this.GetSize(); double new_height = old_size.Width; double new_width = old_size.Height; var update = new VA.ShapeSheet.Update(3); update.SetFormula(VA.ShapeSheet.SRCConstants.PageWidth, new_width); update.SetFormula(VA.ShapeSheet.SRCConstants.PageHeight, new_height); update.SetFormula(VA.ShapeSheet.SRCConstants.PrintPageOrientation, (int)orientation); using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication,"Set Page Orientation")) { update.Execute(active_page.PageSheet); } }
public void ResetOrigin(IVisio.Page page) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var application = this.Client.VisioApplication; if (page == null) { page = application.ActivePage; } var update = new VA.ShapeSheet.Update(); update.SetFormula(VA.ShapeSheet.SRCConstants.XGridOrigin, "0.0"); update.SetFormula(VA.ShapeSheet.SRCConstants.YGridOrigin, "0.0"); update.SetFormula(VA.ShapeSheet.SRCConstants.XRulerOrigin, "0.0"); update.SetFormula(VA.ShapeSheet.SRCConstants.YRulerOrigin, "0.0"); using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication,"Reset Page Origin")) { update.Execute(page.PageSheet); } }
public void SetSize(IList<IVisio.Shape> target_shapes, double? w, double? h) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var shapes = GetTargetShapes(target_shapes); if (shapes.Count < 1) { return; } var shapeids = shapes.Select(s=>s.ID).ToList(); var update = new VA.ShapeSheet.Update(); foreach (int shapeid in shapeids) { if (w.HasValue && w.Value>=0) { update.SetFormula((short)shapeid, VA.ShapeSheet.SRCConstants.Width, w.Value); } if (h.HasValue && h.Value >= 0) { update.SetFormula((short)shapeid, VA.ShapeSheet.SRCConstants.Height, h.Value); } } var application = this.Client.VisioApplication; using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication,"Set Shape Size")) { var active_page = application.ActivePage; update.Execute(active_page); } }
private static void update_xfrms(IVisio.Page page, IList<int> shapeids, IList<VA.Shapes.XFormCells> xfrms) { var update = new VA.ShapeSheet.Update(); for (int i = 0; i < shapeids.Count; i++) { var shape_id = shapeids[i]; var xfrm = xfrms[i]; update.SetFormulas((short)shape_id, xfrm); } update.Execute(page); }
public void SetSize(VA.Drawing.Size new_size) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var application = this.Client.VisioApplication; using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication,"Set Page Size")) { var active_page = application.ActivePage; var page_sheet = active_page.PageSheet; var update = new VA.ShapeSheet.Update(2); update.SetFormula(VA.ShapeSheet.SRCConstants.PageWidth, new_size.Width); update.SetFormula(VA.ShapeSheet.SRCConstants.PageHeight, new_size.Height); update.Execute(page_sheet); } }
public void Set(IList<IVisio.Shape> target_shapes, VA.Shapes.FormatCells format) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var shapes = this.GetTargetShapes(target_shapes); if (shapes.Count<1) { return; } var update = new VA.ShapeSheet.Update(); var shapeids = shapes.Select(s => s.ID).ToList(); foreach (int shapeid in shapeids) { update.SetFormulas((short)shapeid, format); } update.Execute(this.Client.VisioApplication.ActivePage); }