public VisioScripting.Models.PageOrientation GetOrientation() { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); var application = this._client.Application.Get(); var active_page = application.ActivePage; return(PageCommands.GetOrientation(active_page)); }
public void SetOrientation(VisioScripting.Models.PageOrientation orientation) { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); var app = this._client.Application.Get(); var application = app; var active_page = application.ActivePage; if (orientation != VisioScripting.Models.PageOrientation.Landscape && orientation != VisioScripting.Models.PageOrientation.Portrait) { throw new System.ArgumentOutOfRangeException(nameof(orientation), "must be either Portrait or Landscape"); } var old_orientation = PageCommands.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 writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, new_width); writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, new_height); writer.SetFormula(VisioAutomation.ShapeSheet.SrcConstants.PrintPageOrientation, (int)orientation); using (var undoscope = this._client.Application.NewUndoScope("Set Page Orientation")) { writer.Commit(active_page.PageSheet); } }