public static List <ShapeXFormData> Get(IVisio.Page page, TargetShapeIDs target) { if (_static_query == null) { _static_query = new VASS.Query.CellQuery(); var cols = _static_query.Columns; _static_col_x_form_pin_x = cols.Add(VASS.SrcConstants.XFormPinX, nameof(ShapeXFormData.XFormPinX)); _static_col_x_form_pin_y = cols.Add(VASS.SrcConstants.XFormPinY, nameof(ShapeXFormData.XFormPinY)); _static_col_x_form_loc_pin_x = cols.Add(VASS.SrcConstants.XFormLocPinX, nameof(ShapeXFormData.XFormLocPinX)); _static_col_x_form_loc_pin_y = cols.Add(VASS.SrcConstants.XFormLocPinY, nameof(ShapeXFormData.XFormLocPinY)); _static_col_x_form_width = cols.Add(VASS.SrcConstants.XFormWidth, nameof(ShapeXFormData.XFormWidth)); _static_col_x_form_height = cols.Add(VASS.SrcConstants.XFormHeight, nameof(ShapeXFormData.XFormHeight)); } var results = _static_query.GetResults <double>(page, target.ShapeIDs); if (results.Count != target.ShapeIDs.Count) { throw new VisioAutomation.Exceptions.InternalAssertionException("Didn't get as many rows back as expected"); } var list = new List <ShapeXFormData>(target.ShapeIDs.Count); foreach (var row in results) { var xform = new ShapeXFormData(); xform.XFormPinX = row[_static_col_x_form_pin_x]; xform.XFormPinY = row[_static_col_x_form_pin_y]; xform.XFormLocPinX = row[_static_col_x_form_loc_pin_x]; xform.XFormLocPinY = row[_static_col_x_form_loc_pin_y]; xform.XFormWidth = row[_static_col_x_form_width]; xform.XFormHeight = row[_static_col_x_form_height]; list.Add(xform); } return(list); }
public TargetShapeIDs ToShapeIDs() { if (this.Shapes == null) { throw new System.ArgumentException("Target shapes must be resolved before calling ToShapeIDs()"); } var shapeids = this.Shapes.Select(s => s.ID).ToList(); var target_shapeids = new TargetShapeIDs(shapeids); return(target_shapeids); }
public static List <ShapeXFormData> Get(Microsoft.Office.Interop.Visio.Page page, TargetShapeIDs target) { if (query == null) { query = new CellQuery(); ColPinX = query.Columns.Add(VisioAutomation.ShapeSheet.SrcConstants.XFormPinX, nameof(VisioAutomation.ShapeSheet.SrcConstants.XFormPinX)); ColPinY = query.Columns.Add(VisioAutomation.ShapeSheet.SrcConstants.XFormPinY, nameof(VisioAutomation.ShapeSheet.SrcConstants.XFormPinY)); ColLocPinX = query.Columns.Add(VisioAutomation.ShapeSheet.SrcConstants.XFormLocPinX, nameof(VisioAutomation.ShapeSheet.SrcConstants.XFormLocPinX)); ColLocPinY = query.Columns.Add(VisioAutomation.ShapeSheet.SrcConstants.XFormLocPinY, nameof(VisioAutomation.ShapeSheet.SrcConstants.XFormLocPinY)); ColWidth = query.Columns.Add(VisioAutomation.ShapeSheet.SrcConstants.XFormWidth, nameof(VisioAutomation.ShapeSheet.SrcConstants.XFormWidth)); ColHeight = query.Columns.Add(VisioAutomation.ShapeSheet.SrcConstants.XFormHeight, nameof(VisioAutomation.ShapeSheet.SrcConstants.XFormHeight)); } var results = query.GetResults <double>(page, target.ShapeIDs); if (results.Count != target.ShapeIDs.Count) { throw new VisioAutomation.Exceptions.InternalAssertionException("Didn't get as many rows back as expected"); } var list = new List <ShapeXFormData>(target.ShapeIDs.Count); foreach (var row in results) { var xform = new ShapeXFormData(); xform.PinX = row.Cells[ColPinX]; xform.PinY = row.Cells[ColPinY]; xform.LocPinX = row.Cells[ColLocPinX]; xform.LocPinY = row.Cells[ColLocPinY]; xform.Width = row.Cells[ColWidth]; xform.Height = row.Cells[ColHeight]; list.Add(xform); } return(list); }