public VisioAutomation.SurfaceTarget GetDrawingSurface() { this._client.Application.AssertApplicationAvailable(); this._client.Document.AssertDocumentAvailable(); var surf_Application = this._client.Application.Get(); var surf_Window = surf_Application.ActiveWindow; var surf_Window_subtype = surf_Window.SubType; // TODO: Revisit the logic here // TODO: And what about a selected shape as a surface? this._client.WriteVerbose("Window SubType: {0}", surf_Window_subtype); if (surf_Window_subtype == 64) { this._client.WriteVerbose("Window = Master Editing"); var surf_Master = (IVisio.Master)surf_Window.Master; var surface = new VisioAutomation.SurfaceTarget(surf_Master); return(surface); } else { this._client.WriteVerbose("Window = Page "); var surf_Page = surf_Application.ActivePage; var surface = new VisioAutomation.SurfaceTarget(surf_Page); return(surface); } }
public VisioAutomation.SurfaceTarget GetActiveDrawingSurface() { var cmdtarget = this._client.GetCommandTargetDocument(); var surf_application = cmdtarget.Application; var surf_window = surf_application.ActiveWindow; var surf_window_subtype = surf_window.SubType; // TODO: Revisit the logic here // TODO: And what about a selected shape as a surface? this._client.Output.WriteVerbose("Window SubType: {0}", surf_window_subtype); if (surf_window_subtype == 64) { this._client.Output.WriteVerbose("Window = Master Editing"); var surf_master = (IVisio.Master)surf_window.Master; var surface = new VisioAutomation.SurfaceTarget(surf_master); return(surface); } else { this._client.Output.WriteVerbose("Window = Page "); var surf_Page = surf_application.ActivePage; var surface = new VisioAutomation.SurfaceTarget(surf_Page); return(surface); } }
public IVisio.Shape DrawBezier(VisioScripting.TargetPage targetpage, IEnumerable <VisioAutomation.Geometry.Point> points) { targetpage = targetpage.ResolveToPage(this._client); var surface = new VisioAutomation.SurfaceTarget(targetpage.Page); using (var undoscope = this._client.Undo.NewUndoScope(nameof(DrawOval))) { var shape = surface.DrawBezier(points.ToList()); return(shape); } }
public IVisio.Shape DrawOval(VisioScripting.TargetPage targetpage, VisioAutomation.Geometry.Rectangle rect) { targetpage = targetpage.ResolveToPage(this._client); var surface = new VisioAutomation.SurfaceTarget(targetpage.Page); using (var undoscope = this._client.Undo.NewUndoScope(nameof(DrawOval))) { var shape = surface.DrawOval(rect); return(shape); } }
public IVisio.Shape DrawPolyLine(VisioScripting.TargetPage targetpage, IList <VisioAutomation.Geometry.Point> points) { targetpage = targetpage.ResolveToPage(this._client); var surface = new VisioAutomation.SurfaceTarget(targetpage.Page); using (var undoscope = this._client.Undo.NewUndoScope(nameof(DrawPolyLine))) { var shape = surface.DrawPolyLine(points); return(shape); } }
protected override void ProcessRecord() { var targetshapes = new VisioScripting.TargetShapes(this.Shape).ResolveToShapes(this.Client); if (targetshapes.Shapes.Count < 1) { return; } if (this.Cells == null || this.Cells.Length < 1) { return; } var targetshapeids = targetshapes.ToShapeIDs(); var writer = new VisioAutomation.ShapeSheet.Writers.SidSrcWriter(); writer.BlastGuards = this.BlastGuards; writer.TestCircular = this.TestCircular; foreach (int i in Enumerable.Range(0, targetshapeids.Count)) { int shapeid_index = i; int cells_index = i % this.Cells.Length; var shapeid = targetshapeids[shapeid_index]; var shape_cells = this.Cells[cells_index]; shape_cells.Apply(writer, (short)shapeid); } var page = targetshapes.Shapes[0].ContainingPage; var surface = new VisioAutomation.SurfaceTarget(page); this.Client.Output.WriteVerbose("BlastGuards: {0}", this.BlastGuards); this.Client.Output.WriteVerbose("TestCircular: {0}", this.TestCircular); this.Client.Output.WriteVerbose("Number of Shapes : {0}", targetshapeids.Count); using (var undoscope = this.Client.Undo.NewUndoScope(nameof(SetVisioShapeCells))) { this.Client.Output.WriteVerbose("Start Update"); writer.CommitFormulas(surface); this.Client.Output.WriteVerbose("End Update"); } }
public static DataTable QueryToDataTable( VASS.Query.CellQuery query, VisioAutomation.ShapeSheet.CellValueType value_type, Models.ResultType result_type, IList <int> shapeids, VisioAutomation.SurfaceTarget surface) { if (value_type == VASS.CellValueType.Formula) { var output = query.GetFormulas(surface, shapeids); var dt = DataTableHelpers.querytable_to_datatable(query, output); return(dt); } if (value_type != VASS.CellValueType.Result) { throw new System.ArgumentOutOfRangeException(nameof(value_type)); } if (result_type == ResultType.String) { var output = query.GetResults <string>(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(query, output)); } else if (result_type == ResultType.Bool) { var output = query.GetResults <string>(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(query, output)); } else if (result_type == ResultType.Double) { var output = query.GetResults <double>(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(query, output)); } else if (result_type == ResultType.Int) { var output = query.GetResults <int>(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(query, output)); } else { string msg = string.Format("Unsupported value of \"{0}\" for type {1}", result_type, nameof(result_type)); throw new System.ArgumentOutOfRangeException(nameof(result_type), msg); } }
public static DataTable QueryToDataTable( VASS.Query.CellQuery query, CellOutputType output_type, IList <int> shapeids, VisioAutomation.SurfaceTarget surface) { switch (output_type) { case CellOutputType.Formula: { var output = query.GetFormulas(surface, shapeids); var dt = DataTableHelpers.querytable_to_datatable(query, output); return(dt); } case CellOutputType.ResultString: { var output = query.GetResults <string>(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(query, output)); } case CellOutputType.ResultBoolean: { var output = query.GetResults <bool>(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(query, output)); } case CellOutputType.ResultDouble: { var output = query.GetResults <double>(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(query, output)); } case CellOutputType.ResultInteger: { var output = query.GetResults <int>(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(query, output)); } } string msg = string.Format("Unsupported value of \"{0}\" for type {1}", output_type, nameof(CellOutputType)); throw new System.ArgumentOutOfRangeException(nameof(output_type), msg); }
protected override void ProcessRecord() { var valuetype = this.Results ? VisioAutomation.ShapeSheet.CellValueType.Result : VisioAutomation.ShapeSheet.CellValueType.Formula; var targetpages = new VisioScripting.TargetPages(this.Page).ResolveToPages(this.Client); if (targetpages.Pages.Count < 1) { return; } var template = new VisioPowerShell.Models.PageCells(); var dicof_name_to_cell = VisioPowerShell.Internal.NamedSrcDictionary.FromCells(template); var desired_cells = this.Cell ?? dicof_name_to_cell.Keys.ToArray(); var query = _create_query(dicof_name_to_cell, desired_cells); var datatable = new System.Data.DataTable(); foreach (var page in targetpages.Pages) { var shapesheet = page.PageSheet; var shapeids = new List <int> { shapesheet.ID }; var surface = new VisioAutomation.SurfaceTarget(page); var temp_datatable = VisioPowerShell.Internal.DataTableHelpers.QueryToDataTable(query, valuetype, this.ResultType, shapeids, surface); datatable.Merge(temp_datatable); } // Annotate the returned datatable to disambiguate rows var pageid_col = datatable.Columns.Add("PageID", typeof(int)); int pageid_colindex = 0; pageid_col.SetOrdinal(pageid_colindex); foreach (int row_index in Enumerable.Range(0, targetpages.Pages.Count)) { var page = targetpages.Pages[row_index]; datatable.Rows[row_index][pageid_colindex] = page.ID; } this.WriteObject(datatable); }
private void _drop_shape() { var targetpage = VisioScripting.TargetPage.Auto.ResolveToPage(this.Client); var shapeids = this.Client.Master.DropMasters(targetpage, this.Master, this.Position); var shape_objects = VisioAutomation.Shapes.ShapeHelper.GetShapesFromIDs(targetpage.Page.Shapes, shapeids); // If there are cells to set, then use them if (this.Cells != null) { var writer = new VisioAutomation.ShapeSheet.Writers.SidSrcWriter(); writer.BlastGuards = true; writer.TestCircular = true; for (int i = 0; i < shapeids.Count(); i++) { var shapeid = shapeids[i]; var shape_cells = this.Cells[i % this.Cells.Length]; shape_cells.Apply(writer, (short)shapeid); } var surface = new VisioAutomation.SurfaceTarget(targetpage.Page); using (var undoscope = this.Client.Undo.NewUndoScope(nameof(NewVisioShape) + ":CommitCells")) { writer.CommitFormulas(surface); } } // Visio does not select dropped masters by default - unlike shapes that are directly drawn // so force visio to select the dropped shapes ((SMA.Cmdlet) this).WriteVerbose("Clearing the selection"); this.Client.Selection.SelectNone(VisioScripting.TargetWindow.Auto); ((SMA.Cmdlet) this).WriteVerbose("Selecting the shapes that were dropped"); this.Client.Selection.SelectShapes(VisioScripting.TargetWindow.Auto, shape_objects); this.WriteObject(shape_objects, true); }
public ShapeSheetReader(Client client, IVisio.Page page) { this.Client = client; this.Surface = new VisioAutomation.SurfaceTarget(page); this.SidSrcs = new List <VisioAutomation.ShapeSheet.SidSrc>(); }
public void Commit(VisioAutomation.SurfaceTarget surface) { this.CommitFormulas(surface); this.CommitResults(surface); }
public static DataTable QueryToDataTable(CellQuery cell_query, bool getresults, ResultType result_type, IList <int> shapeids, VisioAutomation.SurfaceTarget surface) { if (!getresults) { var output = cell_query.GetFormulas(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(cell_query, output)); } switch (result_type) { case ResultType.String: { var output = cell_query.GetResults <string>(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(cell_query, output)); } case ResultType.Boolean: { var output = cell_query.GetResults <bool>(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(cell_query, output)); } case ResultType.Double: { var output = cell_query.GetResults <double>(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(cell_query, output)); } case ResultType.Integer: { var output = cell_query.GetResults <int>(surface, shapeids); return(DataTableHelpers.querytable_to_datatable(cell_query, output)); } } throw new System.ArgumentOutOfRangeException("Unsupported Result type"); }
public static Geometry.Rectangle GetBoundingBox(this IVisio.Master master, IVisio.VisBoundingBoxArgs args) { var surface = new VisioAutomation.SurfaceTarget(master); return(surface.GetBoundingBox(args)); }
public ShapeSheetWriter(Client client, IVisio.Page page) { this.Client = client; this.Surface = new VisioAutomation.SurfaceTarget(page); this.Writer = new SidSrcWriter(); }
public ShapeSheetReader(Client client, IVisio.Page page) { this.Client = client; this.Surface = new VisioAutomation.SurfaceTarget(page); this.SidSrcStreamBuilder = new VisioAutomation.ShapeSheet.Streams.SidSrcStreamBuilder(); }
public ShapeSheetWriter(Client client, Microsoft.Office.Interop.Visio.Page page) { this.Client = client; this.Surface = new VisioAutomation.SurfaceTarget(page); this.writer = new SidSrcWriter(); }