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 Models.PageOrientation GetPageOrientation(TargetPage targetpage) { targetpage = targetpage.ResolveToPage(this._client); return(PageCommands._get_page_orientation(targetpage.Page)); }