public void SetPageOrientation(TargetPages targetpages, Models.PageOrientation orientation) { if (orientation != VisioScripting.Models.PageOrientation.Landscape && orientation != VisioScripting.Models.PageOrientation.Portrait) { throw new System.ArgumentOutOfRangeException(nameof(orientation), "must be either Portrait or Landscape"); } targetpages = targetpages.ResolveToPages(this._client); using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetPageOrientation))) { foreach (var page in targetpages.Pages) { var old_orientation = PageCommands._get_page_orientation(page); if (old_orientation == orientation) { // don't need to do anything return; } var old_size = VisioAutomation.Pages.PageHelper.GetSize(page); double new_height = old_size.Width; double new_width = old_size.Height; var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); writer.SetValue(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, new_width); writer.SetValue(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, new_height); writer.SetValue(VisioAutomation.ShapeSheet.SrcConstants.PrintPageOrientation, (int)orientation); writer.Commit(page.PageSheet, CellValueType.Formula); } } }
public short Render(IVisio.Shape shape) { short sec_index = ShapeGeometryHelper.AddSection(shape); short row_count = shape.RowCount[sec_index]; var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); var src_nofill = new VA.ShapeSheet.Src(sec_index, 0, ShapeSheet.SrcConstants.GeometryNoFill.Cell); var src_noline = new VA.ShapeSheet.Src(sec_index, 0, ShapeSheet.SrcConstants.GeometryNoLine.Cell); var src_noshow = new VA.ShapeSheet.Src(sec_index, 0, ShapeSheet.SrcConstants.GeometryNoShow.Cell); var src_nosnap = new VA.ShapeSheet.Src(sec_index, 0, ShapeSheet.SrcConstants.GeometryNoSnap.Cell); var src_noquickdrag = new VA.ShapeSheet.Src(sec_index, 0, ShapeSheet.SrcConstants.GeometryNoQuickDrag.Cell); writer.SetValue(src_nofill, this.NoFill); writer.SetValue(src_noline, this.NoLine); writer.SetValue(src_noshow, this.NoShow); writer.SetValue(src_nosnap, this.NoSnap); writer.SetValue(src_noquickdrag, this.NoQuickDrag); foreach (var row in this.Rows) { row.AddTo(shape, writer, row_count, sec_index); row_count++; } writer.Commit(shape, CellValueType.Formula); return(0); }
public void Check_Consistent_ResultTypes() { var page1 = this.GetNewPage(); var shape1 = page1.DrawRectangle(0, 0, 1, 1); // Setup the modifications to the cell values var writer = new VASS.Writers.SrcWriter(); writer.SetValue(LinePattern, "7"); writer.SetValue(XFormPinX, 2); writer.Commit(shape1, VASS.CellValueType.Result); // Build the query var query = new VASS.Query.CellQuery(); var col_linepat = query.Columns.Add(LinePattern, nameof(LinePattern)); var col_pinx = query.Columns.Add(XFormPinX, nameof(XFormPinX)); // Retrieve the values var data_formulas = query.GetFormulas(shape1); var data_results = query.GetResults <double>(shape1); int rownum = 0; // Verify Assert.AreEqual("7", data_formulas[rownum][col_linepat]); Assert.AreEqual(7, data_results[rownum][col_linepat]); Assert.AreEqual("2 in", data_formulas[rownum][col_pinx]); Assert.AreEqual(2, data_results[rownum][col_pinx]); page1.Delete(0); }
internal static void SetSize(IVisio.Page page, Geometry.Size size) { var writer = new VASS.Writers.SrcWriter(); writer.SetValue(VASS.SrcConstants.PageWidth, size.Width); writer.SetValue(VASS.SrcConstants.PageHeight, size.Height); writer.Commit(page.PageSheet, VASS.CellValueType.Formula); }
public static void Set(IVisio.Shape shape, string name, UserDefinedCellCells cells) { if (shape == null) { throw new System.ArgumentNullException(nameof(shape)); } if (cells == null) { throw new System.ArgumentNullException(nameof(cells)); } UserDefinedCellHelper.CheckValidName(name); if (UserDefinedCellHelper.Contains(shape, name)) { // The user-defined cell already exists string full_udcell_name = UserDefinedCellHelper.__GetRowName(name); if (cells.Value.HasValue) { string value_cell_name = full_udcell_name; var cell = shape.CellsU[value_cell_name]; cell.FormulaU = cells.Value.Value; } if (cells.Prompt.HasValue) { string prompt_cell_name = full_udcell_name + ".Prompt"; var cell = shape.CellsU[prompt_cell_name]; cell.FormulaU = cells.Prompt.Value; } } else { // The user-defined cell doesn't already exist short row = shape.AddNamedRow(_udcell_section, name, (short)IVisio.VisRowIndices.visRowUser); var src_value = new ShapeSheet.Src(_udcell_section, row, (short)IVisio.VisCellIndices.visUserValue); var src_prompt = new ShapeSheet.Src(_udcell_section, row, (short)IVisio.VisCellIndices.visUserPrompt); var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); if (cells.Value.HasValue) { writer.SetValue(src_value, cells.Value.Value); } if (cells.Prompt.HasValue) { writer.SetValue(src_prompt, cells.Prompt.Value); } writer.CommitFormulas(shape); } }
public static void SetTabStops(IVisio.Shape shape, IList <TabStop> stops) { if (shape == null) { throw new System.ArgumentNullException(nameof(shape)); } if (stops == null) { throw new System.ArgumentNullException(nameof(stops)); } _clear_tab_stops(shape); if (stops.Count < 1) { return; } const short row = 0; var 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(culture); // set the number of tab stobs allowed for the shape var tagtab = _get_tab_tag_for_stops(stops.Count); shape.RowType[tab_section, (short)IVisio.VisRowIndices.visRowTab] = (short)tagtab; // add tab properties for each stop var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); for (int stop_index = 0; stop_index < stops.Count; stop_index++) { int i = stop_index * 3; var alignment = ((int)stops[stop_index].Alignment).ToString(culture); var position = ((int)stops[stop_index].Position).ToString(culture); var src_tabpos = new ShapeSheet.Src(tab_section, row, (short)(i + 1)); var src_tabalign = new ShapeSheet.Src(tab_section, row, (short)(i + 2)); var src_tabother = new ShapeSheet.Src(tab_section, row, (short)(i + 3)); writer.SetValue(src_tabpos, position); // tab position writer.SetValue(src_tabalign, alignment); // tab alignment writer.SetValue(src_tabother, "0"); // tab unknown } writer.Commit(shape, VASS.CellValueType.Formula); }
public static void SetPageSize(IVisio.Page page, VisioAutomation.Geometry.Size size) { if (page == null) { throw new System.ArgumentNullException(nameof(page)); } var page_sheet = page.PageSheet; var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); writer.SetValue(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, size.Width); writer.SetValue(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, size.Height); writer.Commit(page_sheet, CellValueType.Formula); }
public void SetPageSize(Models.TargetPages targetpages, VisioAutomation.Geometry.Size new_size) { var pages = targetpages.Resolve(this._client); using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetPageSize))) { foreach (var page in pages) { var page_sheet = page.PageSheet; var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); writer.SetValue(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, new_size.Width); writer.SetValue(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, new_size.Height); writer.CommitFormulas(page_sheet); } } }
/// <summary> /// Remove all tab stops on the shape /// </summary> /// <param name="shape"></param> private static void _clear_tab_stops(IVisio.Shape shape) { if (shape == null) { throw new System.ArgumentNullException(nameof(shape)); } int num_existing_tabstops = _get_tab_stop_count(shape); if (num_existing_tabstops < 1) { return; } var cell_tabstopcount = shape.CellsSRC[ShapeSheet.SrcConstants.TabStopCount.Section, ShapeSheet.SrcConstants.TabStopCount.Row, ShapeSheet.SrcConstants.TabStopCount.Cell]; cell_tabstopcount.FormulaForce = "0"; const string formula = "0"; var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); for (int i = 1; i < num_existing_tabstops * 3; i++) { var src = new ShapeSheet.Src(tab_section, (short)IVisio.VisRowIndices.visRowTab, (short)i); writer.SetValue(src, formula); } writer.Commit(shape, VASS.CellValueType.Formula); }
public static void Duplicate( IVisio.Page src_page, IVisio.Page dest_page) { init_page_srcs(); var app = src_page.Application; short copy_paste_flags = (short)IVisio.VisCutCopyPasteCodes.visCopyPasteNoTranslate; // handle the source page if (src_page == null) { throw new System.ArgumentNullException(nameof(src_page)); } if (dest_page == null) { throw new System.ArgumentNullException(nameof(dest_page)); } if (dest_page == src_page) { throw new System.ArgumentException("Destination Page cannot be Source Page"); } if (src_page != app.ActivePage) { throw new System.ArgumentException("Source page must be active page."); } var src_page_shapes = src_page.Shapes; int num_src_shapes = src_page_shapes.Count; if (num_src_shapes > 0) { var active_window = app.ActiveWindow; active_window.SelectAll(); var selection = active_window.Selection; selection.Copy(copy_paste_flags); active_window.DeselectAll(); } // Get the Cells from the Source var query = new VASS.Query.CellQuery(); int i = 0; foreach (var src in _static_page_srcs) { query.Columns.Add(src, "Col" + i.ToString()); i++; } var src_formulas = query.GetFormulas(src_page.PageSheet); // Set the Cells on the Destination var writer = new VASS.Writers.SrcWriter(); for (i = 0; i < _static_page_srcs.Count; i++) { int row = 0; writer.SetValue(_static_page_srcs[i], src_formulas[row][i]); } writer.Commit(dest_page.PageSheet, VASS.CellValueType.Formula); // make sure the new page looks like the old page dest_page.Background = src_page.Background; // then paste any contents from the first page if (num_src_shapes > 0) { dest_page.Paste(copy_paste_flags); } }
internal void ApplyFormulas(VisioAutomation.ShapeSheet.Writers.SrcWriter writer, short row) { writer.SetValue(SrcConstants.ParaIndentLeft.CloneWithNewRow(row), this.IndentLeft); writer.SetValue(SrcConstants.ParaIndentFirst.CloneWithNewRow(row), this.IndentFirst); writer.SetValue(SrcConstants.ParaIndentRight.CloneWithNewRow(row), this.IndentRight); writer.SetValue(SrcConstants.ParaSpacingAfter.CloneWithNewRow(row), this.SpacingAfter); writer.SetValue(SrcConstants.ParaSpacingBefore.CloneWithNewRow(row), this.SpacingBefore); writer.SetValue(SrcConstants.ParaSpacingLine.CloneWithNewRow(row), this.SpacingLine); writer.SetValue(SrcConstants.ParaHorizontalAlign.CloneWithNewRow(row), this.HorizontalAlign); writer.SetValue(SrcConstants.ParaBulletFont.CloneWithNewRow(row), this.BulletFont); writer.SetValue(SrcConstants.ParaBullet.CloneWithNewRow(row), this.Bullet); writer.SetValue(SrcConstants.ParaBulletFontSize.CloneWithNewRow(row), this.BulletFontSize); writer.SetValue(SrcConstants.ParaLocalizeBulletFont.CloneWithNewRow(row), this.LocBulletFont); writer.SetValue(SrcConstants.ParaTextPosAfterBullet.CloneWithNewRow(row), this.TextPosAfterBullet); writer.SetValue(SrcConstants.ParaFlags.CloneWithNewRow(row), this.Flags); writer.SetValue(SrcConstants.ParaBulletString.CloneWithNewRow(row), this.BulletString); }
internal void ApplyFormulas(VisioAutomation.ShapeSheet.Writers.SrcWriter writer, short row) { writer.SetValue(SrcConstants.CharColor.CloneWithNewRow(row), this.Color); writer.SetValue(SrcConstants.CharFont.CloneWithNewRow(row), this.Font); writer.SetValue(SrcConstants.CharSize.CloneWithNewRow(row), this.Size); writer.SetValue(SrcConstants.CharStyle.CloneWithNewRow(row), this.Style); writer.SetValue(SrcConstants.CharColorTransparency.CloneWithNewRow(row), this.Transparency); writer.SetValue(SrcConstants.CharAsianFont.CloneWithNewRow(row), this.AsianFont); writer.SetValue(SrcConstants.CharCase.CloneWithNewRow(row), this.Case); writer.SetValue(SrcConstants.CharComplexScriptFont.CloneWithNewRow(row), this.ComplexScriptFont); writer.SetValue(SrcConstants.CharComplexScriptSize.CloneWithNewRow(row), this.ComplexScriptSize); writer.SetValue(SrcConstants.CharDoubleUnderline.CloneWithNewRow(row), this.DoubleUnderline); writer.SetValue(SrcConstants.CharDoubleStrikethrough.CloneWithNewRow(row), this.DoubleStrikeThrough); writer.SetValue(SrcConstants.CharLangID.CloneWithNewRow(row), this.LangID); writer.SetValue(SrcConstants.CharFontScale.CloneWithNewRow(row), this.FontScale); writer.SetValue(SrcConstants.CharLangID.CloneWithNewRow(row), this.LangID); writer.SetValue(SrcConstants.CharLetterspace.CloneWithNewRow(row), this.Letterspace); writer.SetValue(SrcConstants.CharLocale.CloneWithNewRow(row), this.Locale); writer.SetValue(SrcConstants.CharLocalizeFont.CloneWithNewRow(row), this.LocalizeFont); writer.SetValue(SrcConstants.CharOverline.CloneWithNewRow(row), this.Overline); writer.SetValue(SrcConstants.CharPerpendicular.CloneWithNewRow(row), this.Perpendicular); writer.SetValue(SrcConstants.CharPos.CloneWithNewRow(row), this.Pos); writer.SetValue(SrcConstants.CharRTLText.CloneWithNewRow(row), this.RTLText); writer.SetValue(SrcConstants.CharStrikethru.CloneWithNewRow(row), this.Strikethru); writer.SetValue(SrcConstants.CharUseVertical.CloneWithNewRow(row), this.UseVertical); }