コード例 #1
0
 public static System.Data.DataTable QueryToDataTable(VA.ShapeSheet.Query.CellQuery cellQuery, bool getresults, ResultType ResultType, IList <int> shapeids, VA.Drawing.DrawingSurface surface)
 {
     if (getresults)
     {
         if (ResultType == ResultType.String)
         {
             var output = cellQuery.GetResults <string>(surface, shapeids);
             return(Helpers.querytable_to_datatable(cellQuery, output));
         }
         else if (ResultType == ResultType.Boolean)
         {
             var output = cellQuery.GetResults <bool>(surface, shapeids);
             return(Helpers.querytable_to_datatable(cellQuery, output));
         }
         else if (ResultType == ResultType.Double)
         {
             var output = cellQuery.GetResults <double>(surface, shapeids);
             return(Helpers.querytable_to_datatable(cellQuery, output));
         }
         else if (ResultType == ResultType.Integer)
         {
             var output = cellQuery.GetResults <int>(surface, shapeids);
             return(Helpers.querytable_to_datatable(cellQuery, output));
         }
         else
         {
             throw new VA.Scripting.VisioApplicationException("Unsupported Result type");
         }
     }
     else
     {
         var output = cellQuery.GetFormulas(surface, shapeids);
         return(Helpers.querytable_to_datatable(cellQuery, output));
     }
 }
コード例 #2
0
        public void ShapeSheet_Query_GetResults_SingleShape()
        {
            var doc1  = this.GetNewDoc();
            var page1 = doc1.Pages[1];

            VisioAutomationTest.SetPageSize(page1, this.StandardPageSize);

            // draw a simple shape
            var s1    = page1.DrawRectangle(this.StandardPageSizeRect);
            int s1_id = s1.ID;

            // format it with setformulas
            var fg_cell  = s1.Cells["FillForegnd"];
            var bg_cell  = s1.Cells["FillBkgnd"];
            var pat_cell = s1.Cells["FillPattern"];

            fg_cell.FormulaU  = "RGB(255,0,0)";
            bg_cell.FormulaU  = "RGB(0,0,255)";
            pat_cell.FormulaU = "40";

            // now retrieve the formulas with GetFormulas

            var query      = new VA.ShapeSheet.Query.CellQuery();
            var col_fg     = query.Columns.Add(SrcConstants.FillForeground, nameof(SrcConstants.FillForeground));
            var col_bg     = query.Columns.Add(SrcConstants.FillBackground, nameof(SrcConstants.FillBackground));
            var col_filpat = query.Columns.Add(SrcConstants.FillPattern, nameof(SrcConstants.FillPattern));

            var shapeids = new[] { s1_id };

            var formulas = query.GetFormulas(page1, shapeids);

            // now verify that the formulas were actually set
            Assert.AreEqual("RGB(255,0,0)", formulas[0].Cells[col_fg]);
            Assert.AreEqual("RGB(0,0,255)", formulas[0].Cells[col_bg]);
            Assert.AreEqual("40", formulas[0].Cells[col_filpat]);

            // now retrieve the results with GetResults as floats
            var float_results = query.GetResults <double>(page1, shapeids);

            Assert.IsNotNull(float_results);
            Assert.AreEqual(40.0, float_results[0].Cells[col_filpat]);

            // now retrieve the results with GetResults as ints
            var int_results = query.GetResults <int>(page1, shapeids);

            Assert.AreEqual(40, int_results[0].Cells[col_filpat]);

            // now retrieve the results with GetResults as strings

            var string_results = query.GetResults <string>(page1, shapeids);

            Assert.AreEqual("RGB(255, 0, 0)", string_results[0].Cells[col_fg]);
            Assert.AreEqual("RGB(0, 0, 255)", string_results[0].Cells[col_bg]);
            Assert.AreEqual("40", string_results[0].Cells[col_filpat]);

            page1.Delete(0);
            doc1.Close(true);
        }
コード例 #3
0
        public void ShapeSheet_Query_GetResults_MultipleShapes()
        {
            var page1 = this.GetNewPage();

            // draw a simple shape
            var s1    = page1.DrawRectangle(this.StandardPageSizeRect);
            int s1_id = s1.ID;

            // format it with setformulas
            var fg_cell  = s1.Cells["FillForegnd"];
            var bg_cell  = s1.Cells["FillBkgnd"];
            var pat_cell = s1.Cells["FillPattern"];

            fg_cell.ResultIU  = 2.0; //red
            bg_cell.ResultIU  = 3.0; //green
            pat_cell.ResultIU = 40.0;

            // now retrieve the formulas with GetFormulas

            var query      = new VA.ShapeSheet.Query.CellQuery();
            var col_fg     = query.Columns.Add(SrcConstants.FillForeground, nameof(SrcConstants.FillForeground));
            var col_bg     = query.Columns.Add(SrcConstants.FillBackground, nameof(SrcConstants.FillBackground));
            var col_filpat = query.Columns.Add(SrcConstants.FillPattern, nameof(SrcConstants.FillPattern));

            var shapeids = new[] { s1_id };

            var formulas = query.GetFormulas(page1, shapeids);

            // now verify that the formulas were actually set
            Assert.AreEqual("2", formulas[0].Cells[col_fg]);
            Assert.AreEqual("3", formulas[0].Cells[col_bg]);
            Assert.AreEqual("40", formulas[0].Cells[col_filpat]);

            // now retrieve the results with GetResults as floats
            var float_results = query.GetResults <double>(page1, shapeids);

            Assert.AreEqual(2.0, float_results[0].Cells[col_fg]);
            Assert.AreEqual(3.0, float_results[0].Cells[col_bg]);
            Assert.AreEqual(40.0, float_results[0].Cells[col_filpat]);

            // now retrieve the results with GetResults as ints
            var int_results = query.GetResults <int>(page1, shapeids);

            Assert.AreEqual(2, int_results[0].Cells[col_fg]);
            Assert.AreEqual(3, int_results[0].Cells[col_bg]);
            Assert.AreEqual(40, int_results[0].Cells[col_filpat]);

            // now retrieve the results with GetResults as strings
            var string_results = query.GetResults <string>(page1, shapeids);

            Assert.AreEqual("2", string_results[0].Cells[col_fg]);
            Assert.AreEqual("3", string_results[0].Cells[col_bg]);
            Assert.AreEqual("40", string_results[0].Cells[col_filpat]);

            page1.Delete(0);
        }
コード例 #4
0
        public VA.ShapeSheet.Query.CellQuery.QueryResultList <T> QueryResults <T>(IList <IVisio.Shape> target_shapes, IVisio.VisSectionIndices section, IList <IVisio.VisCellIndices> cells)
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            var shapes   = this.GetTargetShapes(target_shapes);
            var shapeids = shapes.Select(s => s.ID).ToList();

            var app     = this.Client.VisioApplication;
            var surface = this.Client.Draw.GetDrawingSurfaceSafe();
            var query   = new VA.ShapeSheet.Query.CellQuery();
            var sec     = query.Sections.Add(section);

            int ci = 0;

            foreach (var cell in cells)
            {
                string name = string.Format("Cell{0}", ci);
                sec.Columns.Add((short)cell, name);
                ci++;
            }

            var results = query.GetResults <T>(surface, shapeids);

            return(results);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public void ShapeSheet_Writer_ResultsString_SingleShape()
        {
            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.Commit(shape1, VASS.CellValueType.Formula);

            // Build the query
            var query       = new VASS.Query.CellQuery();
            var col_linepat = query.Columns.Add(LinePattern, nameof(LinePattern));

            // 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]);
            page1.Delete(0);
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        public static VA.Drawing.Size GetSize(IVisio.Shape shape)
        {
            var query = new VA.ShapeSheet.Query.CellQuery();
            var col_w = query.Columns.Add(VA.ShapeSheet.SRCConstants.Width,"Width");
            var col_h = query.Columns.Add(VA.ShapeSheet.SRCConstants.Height,"Height");

            var table = query.GetResults<double>(shape);
            double w = table[col_w.Ordinal];
            double h = table[col_h.Ordinal];
            var size = new VA.Drawing.Size(w, h);
            return size;
        }
コード例 #10
0
        private static VA.Drawing.Size GetSize(IVisio.Page page)
        {
            var    query      = new VA.ShapeSheet.Query.CellQuery();
            var    col_height = query.Columns.Add(VA.ShapeSheet.SRCConstants.PageHeight, "PageHeight");
            var    col_width  = query.Columns.Add(VA.ShapeSheet.SRCConstants.PageWidth, "PageWidth");
            var    results    = query.GetResults <double>(page.PageSheet);
            double height     = results[col_height.Ordinal];
            double width      = results[col_width.Ordinal];
            var    s          = new VA.Drawing.Size(width, height);

            return(s);
        }
コード例 #11
0
        public static VisioAutomation.Drawing.Size GetSize(IVisio.Shape shape)
        {
            var query = new VisioAutomation.ShapeSheet.Query.CellQuery();
            var col_w = query.AddCell(VisioAutomation.ShapeSheet.SRCConstants.Width,"Width");
            var col_h = query.AddCell(VisioAutomation.ShapeSheet.SRCConstants.Height,"Height");

            var table = query.GetResults<double>(shape);
            double w = table[col_w];
            double h = table[col_h];
            var size = new VisioAutomation.Drawing.Size(w, h);
            return size;
        }
コード例 #12
0
        public void ShapeSheet_Query_Demo_MultipleShapes_Verify_Out_Of_order()
        {
            var page1 = this.GetNewPage(new VisioAutomation.Geometry.Size(10, 10));

            // draw a simple shape
            var sa = page1.DrawRectangle(-1, -1, 0, 0);
            var s1 = page1.DrawRectangle(0, 0, 2, 2);
            var sb = page1.DrawRectangle(-1, -1, 0, 0);
            var s2 = page1.DrawRectangle(4, 4, 6, 6);
            var s3 = page1.DrawRectangle(5, 5, 7, 7);

            // notice that the shapes are created as 0, 1,2,3
            // but are queried as 2, 3, 1
            var shapeids = new List <int> {
                s2.ID, s3.ID, s1.ID
            };

            Assert.AreEqual(5, page1.Shapes.Count);

            var query    = new VA.ShapeSheet.Query.CellQuery();
            var col_pinx = query.Columns.Add(SrcConstants.XFormPinX, nameof(SrcConstants.XFormPinX));
            var col_piny = query.Columns.Add(SrcConstants.XFormPinY, nameof(SrcConstants.XFormPinY));

            var data_formulas = query.GetFormulas(page1, shapeids);
            var data_results  = query.GetResults <double>(page1, shapeids);

            var expected_formulas = new[, ]
            {
                { "5 in", "5 in" },
                { "6 in", "6 in" },
                { "1 in", "1 in" }
            };

            var expected_results = new[, ]
            {
                { 5.0, 5.0 },
                { 6.0, 6.0 },
                { 1.0, 1.0 }
            };


            for (int row = 0; row < data_results.Count; row++)
            {
                for (int col = 0; col < query.Columns.Count; col++)
                {
                    Assert.AreEqual(expected_formulas[row, col], data_formulas[row].Cells[col]);
                    Assert.AreEqual(expected_results[row, col], data_results[row].Cells[col]);
                }
            }

            page1.Delete(0);
        }
コード例 #13
0
        public static VisioAutomation.Drawing.Size GetSize(IVisio.Shape shape)
        {
            var query = new VisioAutomation.ShapeSheet.Query.CellQuery();
            var col_w = query.AddCell(VisioAutomation.ShapeSheet.SRCConstants.Width, "Width");
            var col_h = query.AddCell(VisioAutomation.ShapeSheet.SRCConstants.Height, "Height");

            var    table = query.GetResults <double>(shape);
            double w     = table[col_w];
            double h     = table[col_h];
            var    size  = new VisioAutomation.Drawing.Size(w, h);

            return(size);
        }
コード例 #14
0
        public static VA.Drawing.Size GetSize(IVisio.Shape shape)
        {
            var query = new VA.ShapeSheet.Query.CellQuery();
            var col_w = query.Columns.Add(VA.ShapeSheet.SRCConstants.Width, "Width");
            var col_h = query.Columns.Add(VA.ShapeSheet.SRCConstants.Height, "Height");

            var    table = query.GetResults <double>(shape);
            double w     = table[col_w.Ordinal];
            double h     = table[col_h.Ordinal];
            var    size  = new VA.Drawing.Size(w, h);

            return(size);
        }
コード例 #15
0
        internal static Geometry.Size GetSize(IVisio.Page page)
        {
            var query      = new VASS.Query.CellQuery();
            var col_height = query.Columns.Add(VASS.SrcConstants.PageHeight, nameof(VASS.SrcConstants.PageHeight));
            var col_width  = query.Columns.Add(VASS.SrcConstants.PageWidth, nameof(VASS.SrcConstants.PageWidth));

            var    cellqueryresult = query.GetResults <double>(page.PageSheet);
            var    row             = cellqueryresult[0];
            double height          = row[col_height];
            double width           = row[col_width];
            var    s = new Geometry.Size(width, height);

            return(s);
        }
コード例 #16
0
        public static DataTable QueryToDataTable(VisioAutomation.ShapeSheet.Query.CellQuery cellQuery, bool getresults, Model.ResultType ResultType, IList <int> shapeids, VisioAutomation.ShapeSheet.ShapeSheetSurface surface)
        {
            if (!getresults)
            {
                var output = cellQuery.GetFormulas(surface, shapeids);
                return(Helpers.querytable_to_datatable(cellQuery, output));
            }

            switch (ResultType)
            {
            case Model.ResultType.String:
            {
                var output = cellQuery.GetResults <string>(surface, shapeids);
                return(Helpers.querytable_to_datatable(cellQuery, output));
            }

            case Model.ResultType.Boolean:
            {
                var output = cellQuery.GetResults <bool>(surface, shapeids);
                return(Helpers.querytable_to_datatable(cellQuery, output));
            }

            case Model.ResultType.Double:
            {
                var output = cellQuery.GetResults <double>(surface, shapeids);
                return(Helpers.querytable_to_datatable(cellQuery, output));
            }

            case Model.ResultType.Integer:
            {
                var output = cellQuery.GetResults <int>(surface, shapeids);
                return(Helpers.querytable_to_datatable(cellQuery, output));
            }
            }

            throw new VisioAutomation.Scripting.VisioApplicationException("Unsupported Result type");
        }
コード例 #17
0
        public static List <ShapeDimensions> Get_ShapeDimensions(IVisio.Page page, List <int> shapeids)
        {
            var query = new VASS.Query.CellQuery();

            var col_XFormAngle   = query.Columns.Add(VASS.SrcConstants.XFormAngle, nameof(VASS.SrcConstants.XFormAngle));
            var col_XFormHeight  = query.Columns.Add(VASS.SrcConstants.XFormHeight, nameof(VASS.SrcConstants.XFormHeight));
            var col_XFormWidth   = query.Columns.Add(VASS.SrcConstants.XFormWidth, nameof(VASS.SrcConstants.XFormWidth));
            var col_XFormLocPinX = query.Columns.Add(VASS.SrcConstants.XFormLocPinX, nameof(VASS.SrcConstants.XFormLocPinX));
            var col_XFormLocPinY = query.Columns.Add(VASS.SrcConstants.XFormLocPinY, nameof(VASS.SrcConstants.XFormLocPinY));
            var col_XFormPinX    = query.Columns.Add(VASS.SrcConstants.XFormPinX, nameof(VASS.SrcConstants.XFormPinX));
            var col_XFormPinY    = query.Columns.Add(VASS.SrcConstants.XFormPinY, nameof(VASS.SrcConstants.XFormPinY));

            var col_OneDBeginX = query.Columns.Add(VASS.SrcConstants.OneDBeginX, nameof(VASS.SrcConstants.OneDBeginX));
            var col_OneDBeginY = query.Columns.Add(VASS.SrcConstants.OneDBeginY, nameof(VASS.SrcConstants.OneDBeginY));
            var col_OneDEndX   = query.Columns.Add(VASS.SrcConstants.OneDEndX, nameof(VASS.SrcConstants.OneDEndX));
            var col_OneDEndY   = query.Columns.Add(VASS.SrcConstants.OneDEndY, nameof(VASS.SrcConstants.OneDEndY));

            var cellqueryresult = query.GetResults <double>(page, shapeids);

            var list_shapedim = new List <VisioScripting.Models.ShapeDimensions>(shapeids.Count);
            int n             = 0;

            foreach (var row in cellqueryresult)
            {
                var shapedim = new VisioScripting.Models.ShapeDimensions();

                shapedim.ShapeID = shapeids[n];

                shapedim.XFormAngle   = row[col_XFormAngle];
                shapedim.XFormWidth   = row[col_XFormWidth];
                shapedim.XFormHeight  = row[col_XFormHeight];
                shapedim.XFormLocPinX = row[col_XFormLocPinX];
                shapedim.XFormLocPinY = row[col_XFormLocPinY];
                shapedim.XFormPinX    = row[col_XFormPinX];
                shapedim.XFormPinY    = row[col_XFormPinY];

                shapedim.OneDBeginX = row[col_OneDBeginX];
                shapedim.OneDBeginY = row[col_OneDBeginY];
                shapedim.OneDEndX   = row[col_OneDEndX];
                shapedim.OneDEndY   = row[col_OneDEndY];

                list_shapedim.Add(shapedim);

                n++;
            }

            return(list_shapedim);
        }
コード例 #18
0
        public void ShapeSheet_Query_Demo_MultipleShapes()
        {
            var page1 = GetNewPage(new VA.Drawing.Size(10, 10));

            // draw a simple shape
            var s1 = page1.DrawRectangle(0, 0, 2, 2);
            var s2 = page1.DrawRectangle(4, 4, 6, 6);
            var s3 = page1.DrawRectangle(5, 5, 7, 7);

            var shapeids = new List <int> {
                s1.ID, s2.ID, s3.ID
            };

            Assert.AreEqual(3, page1.Shapes.Count);

            var query    = new VA.ShapeSheet.Query.CellQuery();
            var col_pinx = query.Columns.Add(VA.ShapeSheet.SRCConstants.PinX, "PinX");
            var col_piny = query.Columns.Add(VA.ShapeSheet.SRCConstants.PinY, "PinY");

            var rf = query.GetFormulas(page1, shapeids);
            var rr = query.GetResults <double>(page1, shapeids);

            var expected_formulas = new[, ]
            {
                { "1 in", "1 in" },
                { "5 in", "5 in" },
                { "6 in", "6 in" }
            };

            var expected_results = new[, ]
            {
                { 1.0, 1.0 },
                { 5.0, 5.0 },
                { 6.0, 6.0 }
            };


            for (int row = 0; row < rr.Count; row++)
            {
                for (int col = 0; col < query.Columns.Count; col++)
                {
                    Assert.AreEqual(expected_formulas[row, col], rf[row][col]);
                    Assert.AreEqual(expected_results[row, col], rr[row][col]);
                }
            }

            page1.Delete(0);
        }
コード例 #19
0
        public static VA.Drawing.Size GetPageSize(IVisio.Page page)
        {
            if (page == null)
            {
                throw new System.ArgumentNullException("page");
            }

            var query = new VA.ShapeSheet.Query.CellQuery();
            var col_height = query.AddCell(VA.ShapeSheet.SRCConstants.PageHeight,"PageHeight");
            var col_width = query.AddCell(VA.ShapeSheet.SRCConstants.PageWidth, "PageWidth");
            var results = query.GetResults<double>(page.PageSheet);
            double height = results[col_height];
            double width = results[col_width];
            var s = new VA.Drawing.Size(width, height);
            return s;
        }
コード例 #20
0
        public VisioAutomation.Geometry.Size GetPageSize(Models.TargetPages target_pages)
        {
            var pages = target_pages.Resolve(this._client);

            var query      = new VisioAutomation.ShapeSheet.Query.CellQuery();
            var col_height = query.Columns.Add(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, nameof(VisioAutomation.ShapeSheet.SrcConstants.PageHeight));
            var col_width  = query.Columns.Add(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, nameof(VisioAutomation.ShapeSheet.SrcConstants.PageWidth));

            var    cellqueryresult = query.GetResults <double>(pages[0].PageSheet);
            var    row             = cellqueryresult[0];
            double height          = row[col_height];
            double width           = row[col_width];
            var    s = new VisioAutomation.Geometry.Size(width, height);

            return(s);
        }
コード例 #21
0
        public static VA.Drawing.Size GetPageSize(IVisio.Page page)
        {
            if (page == null)
            {
                throw new System.ArgumentNullException("page");
            }

            var    query      = new VA.ShapeSheet.Query.CellQuery();
            var    col_height = query.Columns.Add(VA.ShapeSheet.SRCConstants.PageHeight, "PageHeight");
            var    col_width  = query.Columns.Add(VA.ShapeSheet.SRCConstants.PageWidth, "PageWidth");
            var    results    = query.GetResults <double>(page.PageSheet);
            double height     = results[col_height.Ordinal];
            double width      = results[col_width.Ordinal];
            var    s          = new VA.Drawing.Size(width, height);

            return(s);
        }
コード例 #22
0
        public static VisioAutomation.Drawing.Size GetPageSize(IVisio.Page page)
        {
            if (page == null)
            {
                throw new System.ArgumentNullException(nameof(page));
            }

            var    query      = new VisioAutomation.ShapeSheet.Query.CellQuery();
            var    col_height = query.AddCell(VisioAutomation.ShapeSheet.SRCConstants.PageHeight, "PageHeight");
            var    col_width  = query.AddCell(VisioAutomation.ShapeSheet.SRCConstants.PageWidth, "PageWidth");
            var    results    = query.GetResults <double>(page.PageSheet);
            double height     = results[col_height];
            double width      = results[col_width];
            var    s          = new VisioAutomation.Drawing.Size(width, height);

            return(s);
        }
コード例 #23
0
        private void update_from_selection()
        {
            var app = VisioPowerToolsAddIn.Client;

            if (!app.Selection.HasShapes())
            {
                return;
            }

            var application   = app.VisioApplication;
            var active_window = application.ActiveWindow;
            var selection     = active_window.Selection;
            var s1            = selection[1];
            var doc           = application.ActiveDocument;

            var query        = new VA.ShapeSheet.Query.CellQuery();
            var col_fg       = query.Columns.Add(VA.ShapeSheet.SRCConstants.FillForegnd);
            var col_bg       = query.Columns.Add(VA.ShapeSheet.SRCConstants.FillBkgnd);
            var col_fgtrans  = query.Columns.Add(VA.ShapeSheet.SRCConstants.FillForegndTrans);
            var col_bgtrans  = query.Columns.Add(VA.ShapeSheet.SRCConstants.FillBkgndTrans);
            var col_fillpat  = query.Columns.Add(VA.ShapeSheet.SRCConstants.FillPattern);
            var col_sfg      = query.Columns.Add(VA.ShapeSheet.SRCConstants.ShdwForegnd);
            var col_sbg      = query.Columns.Add(VA.ShapeSheet.SRCConstants.ShdwBkgnd);
            var col_sfgtrans = query.Columns.Add(VA.ShapeSheet.SRCConstants.ShdwForegndTrans);
            var col_bfgtrans = query.Columns.Add(VA.ShapeSheet.SRCConstants.ShdwBkgndTrans);
            var col_spat     = query.Columns.Add(VA.ShapeSheet.SRCConstants.ShdwPattern);

            var table  = query.GetResults <double>(s1);
            var colors = doc.Colors;

            double row = table[0];
            // TODFO: fix
            //this.fillGradient1.FillDef.ForegroundColor = (System.Drawing.Color) colors[col_fg.Ordinal].ToColorRGB();
            //this.fillGradient1.FillDef.BackgroundColor = (System.Drawing.Color)colors[col_bg.Ordinal].ToColorRGB();
            //this.fillGradient1.FillDef.ForegroundTransparency = (int)(100.0 * row[col_fgtrans.Ordinal]);
            //this.fillGradient1.FillDef.BackgroundTransparency = (int)(100.0 * row[col_bgtrans]);
            //this.fillGradient1.FillDef.FillPattern = (VA.UI.FillPattern)(int)row[col_fillpat];

            //this.fillGradient1.ShadowDef.ForegroundColor = (System.Drawing.Color)colors[(int)row[col_sfg]].ToColorRGB();
            //this.fillGradient1.ShadowDef.BackgroundColor = (System.Drawing.Color)colors[(int)row[col_sbg]].ToColorRGB();
            //this.fillGradient1.ShadowDef.ForegroundTransparency = (int)(100.0 * row[col_sfgtrans]);
            //this.fillGradient1.ShadowDef.BackgroundTransparency = (int)(100.0 * row[col_bfgtrans]);
            //this.fillGradient1.ShadowDef.FillPattern = (VA.UI.FillPattern)((int)row[col_spat]);
        }
コード例 #24
0
        public VA.Drawing.Size GetSize()
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            var application = this.Client.VisioApplication;
            var active_page = application.ActivePage;


            var    query      = new VA.ShapeSheet.Query.CellQuery();
            var    col_height = query.Columns.Add(VA.ShapeSheet.SRCConstants.PageHeight, "PageHeight");
            var    col_width  = query.Columns.Add(VA.ShapeSheet.SRCConstants.PageWidth, "PageWidth");
            var    results    = query.GetResults <double>(active_page.PageSheet);
            double height     = results[col_height.Ordinal];
            double width      = results[col_width.Ordinal];
            var    s          = new VA.Drawing.Size(width, height);

            return(s);
        }
コード例 #25
0
        public VisioAutomation.Geometry.Size GetPageSize(TargetPages targetpages)
        {
            targetpages = targetpages.Resolve(this._client);

            if (targetpages.Pages.Count < 1)
            {
                throw new System.ArgumentException("No pages found");
            }

            var query      = new VisioAutomation.ShapeSheet.Query.CellQuery();
            var col_height = query.Columns.Add(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, nameof(VisioAutomation.ShapeSheet.SrcConstants.PageHeight));
            var col_width  = query.Columns.Add(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, nameof(VisioAutomation.ShapeSheet.SrcConstants.PageWidth));

            var    cellqueryresult = query.GetResults <double>(targetpages.Pages[0].PageSheet);
            var    row             = cellqueryresult[0];
            double height          = row[col_height];
            double width           = row[col_width];
            var    s = new VisioAutomation.Geometry.Size(width, height);

            return(s);
        }
コード例 #26
0
        public void ShapeSheet_Writer_Formulas_MultipleShapes()
        {
            var page1 = this.GetNewPage();

            var shape1 = page1.DrawRectangle(-1, -1, 0, 0);
            var shape2 = page1.DrawRectangle(-1, -1, 0, 0);
            var shape3 = page1.DrawRectangle(-1, -1, 0, 0);


            // Set the formulas
            var writer = new VASS.Writers.SidSrcWriter();

            writer.SetValue(shape1.ID16, XFormPinX, 0.5);
            writer.SetValue(shape1.ID16, XFormPinY, 0.5);
            writer.SetValue(shape2.ID16, XFormPinX, 1.5);
            writer.SetValue(shape2.ID16, XFormPinY, 1.5);
            writer.SetValue(shape3.ID16, XFormPinX, 2.5);
            writer.SetValue(shape3.ID16, XFormPinY, 2.5);

            writer.Commit(page1, VASS.CellValueType.Formula);

            // Verify that the formulas were set
            var query    = new VASS.Query.CellQuery();
            var col_pinx = query.Columns.Add(XFormPinX, nameof(XFormPinX));
            var col_piny = query.Columns.Add(XFormPinY, nameof(XFormPinY));

            var shapeids = new[] { shape1.ID, shape2.ID, shape3.ID };

            var data_formulas = query.GetFormulas(page1, shapeids);
            var data_results  = query.GetResults <double>(page1, shapeids);

            AssertUtil.AreEqual(("0.5 in", 0.5), (data_formulas[0][col_pinx], data_results[0][col_pinx]));
            AssertUtil.AreEqual(("0.5 in", 0.5), (data_formulas[0][col_piny], data_results[0][col_piny]));
            AssertUtil.AreEqual(("1.5 in", 1.5), (data_formulas[1][col_pinx], data_results[1][col_pinx]));
            AssertUtil.AreEqual(("1.5 in", 1.5), (data_formulas[1][col_piny], data_results[1][col_piny]));
            AssertUtil.AreEqual(("2.5 in", 2.5), (data_formulas[2][col_pinx], data_results[2][col_pinx]));
            AssertUtil.AreEqual(("2.5 in", 2.5), (data_formulas[2][col_piny], data_results[2][col_piny]));

            page1.Delete(0);
        }
コード例 #27
0
        public void ShapeSheet_Update_ResultsDouble_MultipleShapes()
        {
            var page1 = GetNewPage();

            var shape1 = page1.DrawRectangle(-1, -1, 0, 0);
            var shape2 = page1.DrawRectangle(-1, -1, 0, 0);
            var shape3 = page1.DrawRectangle(-1, -1, 0, 0);


            // Set the formulas
            var update = new VA.ShapeSheet.Update();

            update.SetResult(shape1.ID16, src_pinx, 0.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape1.ID16, src_piny, 0.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape2.ID16, src_pinx, 1.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape2.ID16, src_piny, 1.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape3.ID16, src_pinx, 2.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape3.ID16, src_piny, 2.5, IVisio.VisUnitCodes.visNumber);
            update.Execute(page1);

            // Verify that the formulas were set
            var query    = new VA.ShapeSheet.Query.CellQuery();
            var col_pinx = query.Columns.Add(src_pinx, "PinX");
            var col_piny = query.Columns.Add(src_piny, "PinY");

            var shapeids = new[] { shape1.ID, shape2.ID, shape3.ID };

            var rf = query.GetFormulas(page1, shapeids);
            var rr = query.GetResults <double>(page1, shapeids);

            AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_pinx.Ordinal], rr[0][col_pinx.Ordinal]);
            AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_piny.Ordinal], rr[0][col_piny.Ordinal]);
            AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_pinx.Ordinal], rr[1][col_pinx.Ordinal]);
            AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_piny.Ordinal], rr[1][col_piny.Ordinal]);
            AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_pinx.Ordinal], rr[2][col_pinx.Ordinal]);
            AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_piny.Ordinal], rr[2][col_piny.Ordinal]);

            page1.Delete(0);
        }
コード例 #28
0
        public void ShapeSheet_Update_Formulas_MultipleShapes()
        {
            var page1 = this.GetNewPage();

            var shape1 = page1.DrawRectangle(-1, -1, 0, 0);
            var shape2 = page1.DrawRectangle(-1, -1, 0, 0);
            var shape3 = page1.DrawRectangle(-1, -1, 0, 0);


            // Set the formulas
            var update = new VA.ShapeSheet.Update();

            update.SetFormula(shape1.ID16, ShapeSheet_Update_Tests.src_pinx, 0.5);
            update.SetFormula(shape1.ID16, ShapeSheet_Update_Tests.src_piny, 0.5);
            update.SetFormula(shape2.ID16, ShapeSheet_Update_Tests.src_pinx, 1.5);
            update.SetFormula(shape2.ID16, ShapeSheet_Update_Tests.src_piny, 1.5);
            update.SetFormula(shape3.ID16, ShapeSheet_Update_Tests.src_pinx, 2.5);
            update.SetFormula(shape3.ID16, ShapeSheet_Update_Tests.src_piny, 2.5);
            update.Execute(page1);

            // Verify that the formulas were set
            var query    = new VA.ShapeSheet.Query.CellQuery();
            var col_pinx = query.AddCell(ShapeSheet_Update_Tests.src_pinx, "PinX");
            var col_piny = query.AddCell(ShapeSheet_Update_Tests.src_piny, "PinY");

            var shapeids = new[] { shape1.ID, shape2.ID, shape3.ID };

            var rf = query.GetFormulas(page1, shapeids);
            var rr = query.GetResults <double>(page1, shapeids);

            AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_pinx], rr[0][col_pinx]);
            AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_piny], rr[0][col_piny]);
            AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_pinx], rr[1][col_pinx]);
            AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_piny], rr[1][col_piny]);
            AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_pinx], rr[2][col_pinx]);
            AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_piny], rr[2][col_piny]);

            page1.Delete(0);
        }
コード例 #29
0
        public void ShapeSheet_Update_Formulas_MultipleShapes()
        {
            var page1 = this.GetNewPage();

            var shape1 = page1.DrawRectangle(-1, -1, 0, 0);
            var shape2 = page1.DrawRectangle(-1, -1, 0, 0);
            var shape3 = page1.DrawRectangle(-1, -1, 0, 0);


            // Set the formulas
            var update = new VA.ShapeSheet.Update();
            update.SetFormula(shape1.ID16, ShapeSheet_Update_Tests.src_pinx, 0.5);
            update.SetFormula(shape1.ID16, ShapeSheet_Update_Tests.src_piny, 0.5);
            update.SetFormula(shape2.ID16, ShapeSheet_Update_Tests.src_pinx, 1.5);
            update.SetFormula(shape2.ID16, ShapeSheet_Update_Tests.src_piny, 1.5);
            update.SetFormula(shape3.ID16, ShapeSheet_Update_Tests.src_pinx, 2.5);
            update.SetFormula(shape3.ID16, ShapeSheet_Update_Tests.src_piny, 2.5);
            update.Execute(page1);

            // Verify that the formulas were set
            var query = new VA.ShapeSheet.Query.CellQuery();
            var col_pinx = query.AddCell(ShapeSheet_Update_Tests.src_pinx, "PinX");
            var col_piny = query.AddCell(ShapeSheet_Update_Tests.src_piny, "PinY");

            var shapeids = new[] { shape1.ID, shape2.ID, shape3.ID };

            var rf = query.GetFormulas(page1, shapeids);
            var rr = query.GetResults<double>(page1, shapeids);

            AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_pinx], rr[0][col_pinx]);
            AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_piny], rr[0][col_piny]);
            AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_pinx], rr[1][col_pinx]);
            AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_piny], rr[1][col_piny]);
            AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_pinx], rr[2][col_pinx]);
            AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_piny], rr[2][col_piny]);

            page1.Delete(0);
        }
コード例 #30
0
        /// <summary>
        /// Caches the resize (the results, not formulas) of a the first currently selected shape
        /// </summary>
        public void CopySize()
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            if (!this.Client.HasSelectedShapes())
            {
                return;
            }

            var application = this.Client.VisioApplication;
            var active_window = application.ActiveWindow;
            var selection = active_window.Selection;
            var shape = selection[1];

            var query = new VA.ShapeSheet.Query.CellQuery();
            var width_col = query.Columns.Add(VA.ShapeSheet.SRCConstants.Width, "Width");
            var height_col = query.Columns.Add(VA.ShapeSheet.SRCConstants.Height, "Height");
            var queryresults = query.GetResults<double>(shape);

            cached_size_width = queryresults[width_col.Ordinal];
            cached_size_height = queryresults[height_col.Ordinal];
        }
コード例 #31
0
        /// <summary>
        /// Caches the resize (the results, not formulas) of a the first currently selected shape
        /// </summary>
        public void CopySize()
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            if (!this.Client.HasSelectedShapes())
            {
                return;
            }

            var application   = this.Client.VisioApplication;
            var active_window = application.ActiveWindow;
            var selection     = active_window.Selection;
            var shape         = selection[1];

            var query        = new VA.ShapeSheet.Query.CellQuery();
            var width_col    = query.Columns.Add(VA.ShapeSheet.SRCConstants.Width, "Width");
            var height_col   = query.Columns.Add(VA.ShapeSheet.SRCConstants.Height, "Height");
            var queryresults = query.GetResults <double>(shape);

            cached_size_width  = queryresults[width_col.Ordinal];
            cached_size_height = queryresults[height_col.Ordinal];
        }
コード例 #32
0
        public static List <PageDimensions> Get_PageDimensions(IList <IVisio.Page> pages)
        {
            var list_pagedim = new List <VisioScripting.Models.PageDimensions>(pages.Count);

            var query                 = new VASS.Query.CellQuery();
            var col_PageHeight        = query.Columns.Add(VASS.SrcConstants.PageHeight, nameof(VASS.SrcConstants.PageHeight));
            var col_PageWidth         = query.Columns.Add(VASS.SrcConstants.PageWidth, nameof(VASS.SrcConstants.PageWidth));
            var col_PrintBottomMargin =
                query.Columns.Add(VASS.SrcConstants.PrintBottomMargin, nameof(VASS.SrcConstants.PrintBottomMargin));
            var col_PrintTopMargin =
                query.Columns.Add(VASS.SrcConstants.PrintTopMargin, nameof(VASS.SrcConstants.PrintTopMargin));
            var col_PrintLeftMargin =
                query.Columns.Add(VASS.SrcConstants.PrintLeftMargin, nameof(VASS.SrcConstants.PrintLeftMargin));
            var col_PrintRightMargin =
                query.Columns.Add(VASS.SrcConstants.PrintRightMargin, nameof(VASS.SrcConstants.PrintRightMargin));


            foreach (var page in pages)
            {
                var pagedim = new VisioScripting.Models.PageDimensions();

                pagedim.PageID = page.ID;

                var cellqueryresult = query.GetResults <double>(page.PageSheet);
                var row             = cellqueryresult[0];
                pagedim.PageHeight        = row[col_PageHeight];
                pagedim.PageWidth         = row[col_PageWidth];
                pagedim.PrintBottomMargin = row[col_PrintBottomMargin];
                pagedim.PrintLeftMargin   = row[col_PrintLeftMargin];
                pagedim.PrintRightMargin  = row[col_PrintRightMargin];
                pagedim.PrintTopMargin    = row[col_PrintTopMargin];

                list_pagedim.Add(pagedim);
            }

            return(list_pagedim);
        }
コード例 #33
0
        public VA.ShapeSheet.Query.CellQuery.QueryResultList <T> QueryResults <T>(IList <IVisio.Shape> target_shapes, IList <VA.ShapeSheet.SRC> srcs)
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            var shapes   = this.GetTargetShapes(target_shapes);
            var surface  = this.Client.Draw.GetDrawingSurfaceSafe();
            var shapeids = shapes.Select(s => s.ID).ToList();

            var query = new VA.ShapeSheet.Query.CellQuery();

            int ci = 0;

            foreach (var src in srcs)
            {
                string colname = string.Format("Col{0}", ci);
                query.Columns.Add(src, colname);
                ci++;
            }

            var results = query.GetResults <T>(surface, shapeids);

            return(results);
        }
コード例 #34
0
 private static VA.Drawing.Size GetSize(IVisio.Page page)
 {
     var query = new VA.ShapeSheet.Query.CellQuery();
     var col_height = query.Columns.Add(VA.ShapeSheet.SRCConstants.PageHeight,"PageHeight");
     var col_width = query.Columns.Add(VA.ShapeSheet.SRCConstants.PageWidth, "PageWidth");
     var results = query.GetResults<double>(page.PageSheet);
     double height = results[col_height.Ordinal];
     double width = results[col_width.Ordinal];
     var s = new VA.Drawing.Size(width, height);
     return s;
 }
コード例 #35
0
        /// <summary>
        /// Returns all the directed,connected pairs of shapes in the  page
        /// </summary>
        /// <param name="page"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public static IList <ConnectorEdge> GetDirectedEdges(
            IVisio.Page page,
            ConnectorEdgeHandling flag)
        {
            if (page == null)
            {
                throw new System.ArgumentNullException("page");
            }

            var edges = GetDirectedEdgesRaw(page);

            if (flag == ConnectorEdgeHandling.Raw)
            {
                return(edges);
            }

            // At this point we know we need to analyze the connetor arrows to produce the correct results

            var connnector_ids = edges.Select(e => e.Connector.ID).ToList();

            // Get the arrows for each connector
            var src_beginarrow = VA.ShapeSheet.SRCConstants.BeginArrow;
            var src_endarrow   = VA.ShapeSheet.SRCConstants.EndArrow;

            var query          = new VA.ShapeSheet.Query.CellQuery();
            var col_beginarrow = query.Columns.Add(src_beginarrow, "BeginArrow");
            var col_endarrow   = query.Columns.Add(src_endarrow, "EndArrow");

            var arrow_table = query.GetResults <int>(page, connnector_ids);

            IList <ConnectorEdge> directed_edges = new List <ConnectorEdge>();

            int connector_index = 0;

            foreach (var e in edges)
            {
                int beginarrow = arrow_table[connector_index][col_beginarrow.Ordinal];
                int endarrow   = arrow_table[connector_index][col_endarrow.Ordinal];

                if ((beginarrow < 1) && (endarrow < 1))
                {
                    // the line has no arrows
                    if (flag == ConnectorEdgeHandling.Arrow_TreatConnectorsWithoutArrowsAsBidirectional)
                    {
                        // in this case treat the connector as pointing in both directions
                        var de1 = new ConnectorEdge(e.Connector, e.To, e.From);
                        var de2 = new ConnectorEdge(e.Connector, e.From, e.To);
                        directed_edges.Add(de1);
                        directed_edges.Add(de2);
                    }
                    else if (flag == ConnectorEdgeHandling.Arrow_ExcludeConnectorsWithoutArrows)
                    {
                        // in this case ignore the connector completely
                    }
                    else
                    {
                        throw new AutomationException("Internal error");
                    }
                }
                else
                {
                    // The connector has either a from-arrow, a to-arrow, or both

                    // handle if it has a from arrow
                    if (beginarrow > 0)
                    {
                        var de = new ConnectorEdge(e.Connector, e.To, e.From);
                        directed_edges.Add(de);
                    }

                    // handle if it has a to arrow
                    if (endarrow > 0)
                    {
                        var de = new ConnectorEdge(e.Connector, e.From, e.To);
                        directed_edges.Add(de);
                    }
                }

                connector_index++;
            }

            return(directed_edges);
        }
コード例 #36
0
        public VA.Drawing.Size GetSize()
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            var application = this.Client.VisioApplication;
            var active_page = application.ActivePage;

            var query = new VA.ShapeSheet.Query.CellQuery();
            var col_height = query.Columns.Add(VA.ShapeSheet.SRCConstants.PageHeight,"PageHeight");
            var col_width = query.Columns.Add(VA.ShapeSheet.SRCConstants.PageWidth,"PageWidth");
            var results = query.GetResults<double>(active_page.PageSheet);
            double height = results[col_height.Ordinal];
            double width = results[col_width.Ordinal];
            var s = new VA.Drawing.Size(width, height);
            return s;
        }
コード例 #37
0
        public void ShapeSheet_Query_GetResults_SingleShape()
        {
            var doc1  = this.GetNewDoc();
            var page1 = doc1.Pages[1];

            VisioAutomationTest.SetPageSize(page1, this.StandardPageSize);

            // draw a simple shape
            var s1    = page1.DrawRectangle(this.StandardPageSizeRect);
            int s1_id = s1.ID;

            // format it with setformulas
            var fg_cell  = s1.Cells["FillForegnd"];
            var bg_cell  = s1.Cells["FillBkgnd"];
            var pat_cell = s1.Cells["FillPattern"];

            fg_cell.FormulaU  = "RGB(255,0,0)";
            bg_cell.FormulaU  = "RGB(0,0,255)";
            pat_cell.FormulaU = "40";

            // now retrieve the formulas with GetFormulas

            var src_fg     = VA.ShapeSheet.SRCConstants.FillForegnd;
            var src_bg     = VA.ShapeSheet.SRCConstants.FillBkgnd;
            var src_filpat = VA.ShapeSheet.SRCConstants.FillPattern;

            var query         = new VA.ShapeSheet.Query.CellQuery();
            var col_fg        = query.Columns.Add(src_fg, "Foreground");
            var col_bg        = query.Columns.Add(src_bg, "Background");
            var col_filpat    = query.Columns.Add(src_filpat, "FillPattern");
            var sec_char      = query.Sections.Add(IVisio.VisSectionIndices.visSectionCharacter);
            var col_charcase  = sec_char.Columns.Add(VA.ShapeSheet.SRCConstants.CharCase, "Case");
            var col_charcolor = sec_char.Columns.Add(VA.ShapeSheet.SRCConstants.CharColor, "Color");
            var col_chartrans = sec_char.Columns.Add(VA.ShapeSheet.SRCConstants.CharColorTrans, "ColorTrans");

            var shapeids = new[] { s1_id };

            var formulas = query.GetFormulas(page1, shapeids);

            // now verify that the formulas were actually set
            Assert.AreEqual("RGB(255,0,0)", formulas[0][col_fg.Ordinal]);
            Assert.AreEqual("RGB(0,0,255)", formulas[0][col_bg.Ordinal]);
            Assert.AreEqual("40", formulas[0][col_filpat.Ordinal]);

            // now retrieve the results with GetResults as floats
            var float_results = query.GetResults <double>(page1, shapeids);

            Assert.IsNotNull(float_results);
            Assert.AreEqual(40.0, float_results[0][col_filpat.Ordinal]);

            // now retrieve the results with GetResults as ints
            var int_results = query.GetResults <int>(page1, shapeids);

            Assert.AreEqual(40, int_results[0][col_filpat.Ordinal]);

            // now retrieve the results with GetResults as strings

            var string_results = query.GetResults <string>(page1, shapeids);

            Assert.AreEqual("RGB(255, 0, 0)", string_results[0][col_fg.Ordinal]);
            Assert.AreEqual("RGB(0, 0, 255)", string_results[0][col_bg.Ordinal]);
            Assert.AreEqual("40", string_results[0][col_filpat.Ordinal]);

            page1.Delete(0);
            doc1.Close(true);
        }
コード例 #38
0
        public void ShapeSheet_Query_GetResults_MultipleShapes()
        {
            var page1 = this.GetNewPage();

            // draw a simple shape
            var s1 = page1.DrawRectangle(this.StandardPageSizeRect);
            int s1_id = s1.ID;

            // format it with setformulas
            var fg_cell = s1.Cells["FillForegnd"];
            var bg_cell = s1.Cells["FillBkgnd"];
            var pat_cell = s1.Cells["FillPattern"];

            fg_cell.ResultIU = 2.0; //red
            bg_cell.ResultIU = 3.0; //green
            pat_cell.ResultIU = 40.0;

            var src_fg = VA.ShapeSheet.SRCConstants.FillForegnd;
            var src_bg = VA.ShapeSheet.SRCConstants.FillBkgnd;
            var src_filpat = VA.ShapeSheet.SRCConstants.FillPattern;

            // now retrieve the formulas with GetFormulas

            var query = new VA.ShapeSheet.Query.CellQuery();
            var col_fg = query.AddCell(src_fg, "FillForegnd");
            var col_bg = query.AddCell(src_bg, "FillBkgnd");
            var col_filpat = query.AddCell(src_filpat, "FillPattern");

            var shapeids = new[] {s1_id};

            var formulas = query.GetFormulas(page1, shapeids);

            // now verify that the formulas were actually set
            Assert.AreEqual("2", formulas[0][col_fg]);
            Assert.AreEqual("3", formulas[0][col_bg]);
            Assert.AreEqual("40", formulas[0][col_filpat]);

            // now retrieve the results with GetResults as floats

            var float_results = query.GetResults<double>(page1,shapeids);
            Assert.AreEqual(2.0, float_results[0][col_fg]);
            Assert.AreEqual(3.0, float_results[0][col_bg]);
            Assert.AreEqual(40.0, float_results[0][col_filpat]);

            // now retrieve the results with GetResults as ints
            var int_results = query.GetResults<int>(page1,shapeids);

            Assert.AreEqual(2, int_results[0][col_fg]);
            Assert.AreEqual(3, int_results[0][col_bg]);
            Assert.AreEqual(40, int_results[0][col_filpat]);

            // now retrieve the results with GetResults as strings
            var string_results = query.GetResults<string>(page1,shapeids);
            Assert.AreEqual("2", string_results[0][col_fg]);
            Assert.AreEqual("3", string_results[0][col_bg]);
            Assert.AreEqual("40", string_results[0][col_filpat]);

            page1.Delete(0);
        }
コード例 #39
0
        private void update_from_selection()
        {
            var app = VisioPowerToolsAddIn.Client;

            if (!app.Selection.HasShapes())
            {
                return;
            }

            var application = app.VisioApplication;
            var active_window = application.ActiveWindow;
            var selection = active_window.Selection;
            var s1 = selection[1];
            var doc = application.ActiveDocument;

            var query = new VA.ShapeSheet.Query.CellQuery();
            var col_fg = query.Columns.Add(VA.ShapeSheet.SRCConstants.FillForegnd);
            var col_bg = query.Columns.Add(VA.ShapeSheet.SRCConstants.FillBkgnd);
            var col_fgtrans = query.Columns.Add(VA.ShapeSheet.SRCConstants.FillForegndTrans);
            var col_bgtrans = query.Columns.Add(VA.ShapeSheet.SRCConstants.FillBkgndTrans);
            var col_fillpat = query.Columns.Add(VA.ShapeSheet.SRCConstants.FillPattern);
            var col_sfg = query.Columns.Add(VA.ShapeSheet.SRCConstants.ShdwForegnd);
            var col_sbg = query.Columns.Add(VA.ShapeSheet.SRCConstants.ShdwBkgnd);
            var col_sfgtrans = query.Columns.Add(VA.ShapeSheet.SRCConstants.ShdwForegndTrans);
            var col_bfgtrans = query.Columns.Add(VA.ShapeSheet.SRCConstants.ShdwBkgndTrans);
            var col_spat = query.Columns.Add(VA.ShapeSheet.SRCConstants.ShdwPattern);

            var table = query.GetResults<double>(s1);
            var colors = doc.Colors;

            double row = table[0];
            // TODFO: fix
            //this.fillGradient1.FillDef.ForegroundColor = (System.Drawing.Color) colors[col_fg.Ordinal].ToColorRGB();
            //this.fillGradient1.FillDef.BackgroundColor = (System.Drawing.Color)colors[col_bg.Ordinal].ToColorRGB();
            //this.fillGradient1.FillDef.ForegroundTransparency = (int)(100.0 * row[col_fgtrans.Ordinal]);
            //this.fillGradient1.FillDef.BackgroundTransparency = (int)(100.0 * row[col_bgtrans]);
            //this.fillGradient1.FillDef.FillPattern = (VA.UI.FillPattern)(int)row[col_fillpat];

            //this.fillGradient1.ShadowDef.ForegroundColor = (System.Drawing.Color)colors[(int)row[col_sfg]].ToColorRGB();
            //this.fillGradient1.ShadowDef.BackgroundColor = (System.Drawing.Color)colors[(int)row[col_sbg]].ToColorRGB();
            //this.fillGradient1.ShadowDef.ForegroundTransparency = (int)(100.0 * row[col_sfgtrans]);
            //this.fillGradient1.ShadowDef.BackgroundTransparency = (int)(100.0 * row[col_bfgtrans]);
            //this.fillGradient1.ShadowDef.FillPattern = (VA.UI.FillPattern)((int)row[col_spat]);
        }
コード例 #40
0
        public void ShapeSheet_Query_Demo_MultipleShapes_Verify_Out_Of_order()
        {
            var page1 = this.GetNewPage(new VisioAutomation.Drawing.Size(10, 10));

            // draw a simple shape
            var sa = page1.DrawRectangle(-1, -1, 0, 0);
            var s1 = page1.DrawRectangle(0, 0, 2, 2);
            var sb = page1.DrawRectangle(-1, -1, 0, 0);
            var s2 = page1.DrawRectangle(4, 4, 6, 6);
            var s3 = page1.DrawRectangle(5, 5, 7, 7);

            // notice that the shapes are created as 0, 1,2,3
            // but are queried as 2, 3, 1
            var shapeids = new List<int> { s2.ID, s3.ID, s1.ID };

            Assert.AreEqual(5, page1.Shapes.Count);

            var query = new VA.ShapeSheet.Query.CellQuery();
            var col_pinx = query.AddCell(VA.ShapeSheet.SRCConstants.PinX, "PinX");
            var col_piny = query.AddCell(VA.ShapeSheet.SRCConstants.PinY, "PinY");

            var rf = query.GetFormulas(page1, shapeids);
            var rr = query.GetResults<double>(page1, shapeids);

            var expected_formulas = new[,]
                                      {
                                          {"5 in", "5 in"},
                                          {"6 in", "6 in"},
                                          {"1 in", "1 in"}
                                      };

            var expected_results = new[,]
                                      {
                                          {5.0, 5.0},
                                          {6.0, 6.0},
                                          {1.0, 1.0}
                                      };


            for (int row = 0; row < rr.Count; row++)
            {
                for (int col = 0; col < query.CellColumns.Count; col++)
                {
                    Assert.AreEqual(expected_formulas[row, col], rf[row][col]);
                    Assert.AreEqual(expected_results[row, col], rr[row][col]);
                }
            }

            page1.Delete(0);
        }
コード例 #41
0
        public void ShapeSheet_Update_ResultsDouble_MultipleShapes()
        {
            var page1 = GetNewPage();

            var shape1 = page1.DrawRectangle(-1, -1, 0, 0);
            var shape2 = page1.DrawRectangle(-1, -1, 0, 0);
            var shape3 = page1.DrawRectangle(-1, -1, 0, 0);

            // Set the formulas
            var update = new VA.ShapeSheet.Update();
            update.SetResult(shape1.ID16, src_pinx, 0.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape1.ID16, src_piny, 0.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape2.ID16, src_pinx, 1.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape2.ID16, src_piny, 1.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape3.ID16, src_pinx, 2.5, IVisio.VisUnitCodes.visNumber);
            update.SetResult(shape3.ID16, src_piny, 2.5, IVisio.VisUnitCodes.visNumber);
            update.Execute(page1);

            // Verify that the formulas were set
            var query = new VA.ShapeSheet.Query.CellQuery();
            var col_pinx = query.Columns.Add(src_pinx,"PinX");
            var col_piny = query.Columns.Add(src_piny,"PinY");

            var shapeids = new[] { shape1.ID, shape2.ID, shape3.ID };

            var rf = query.GetFormulas(page1, shapeids);
            var rr = query.GetResults<double>(page1, shapeids);

            AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_pinx.Ordinal], rr[0][col_pinx.Ordinal]);
            AssertVA.AreEqual("0.5 in", 0.5, rf[0][col_piny.Ordinal], rr[0][col_piny.Ordinal]);
            AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_pinx.Ordinal], rr[1][col_pinx.Ordinal]);
            AssertVA.AreEqual("1.5 in", 1.5, rf[1][col_piny.Ordinal], rr[1][col_piny.Ordinal]);
            AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_pinx.Ordinal], rr[2][col_pinx.Ordinal]);
            AssertVA.AreEqual("2.5 in", 2.5, rf[2][col_piny.Ordinal], rr[2][col_piny.Ordinal]);

            page1.Delete(0);
        }
コード例 #42
0
        public void ShapeSheet_Query_GetResults_SingleShape()
        {
            var doc1 = this.GetNewDoc();
            var page1 = doc1.Pages[1];
            VisioAutomationTest.SetPageSize(page1, this.StandardPageSize);

            // draw a simple shape
            var s1 = page1.DrawRectangle(this.StandardPageSizeRect);
            int s1_id = s1.ID;

            // format it with setformulas
            var fg_cell = s1.Cells["FillForegnd"];
            var bg_cell = s1.Cells["FillBkgnd"];
            var pat_cell = s1.Cells["FillPattern"];

            fg_cell.FormulaU = "RGB(255,0,0)";
            bg_cell.FormulaU = "RGB(0,0,255)";
            pat_cell.FormulaU = "40";

            // now retrieve the formulas with GetFormulas

            var src_fg = VA.ShapeSheet.SRCConstants.FillForegnd;
            var src_bg = VA.ShapeSheet.SRCConstants.FillBkgnd;
            var src_filpat = VA.ShapeSheet.SRCConstants.FillPattern;

            var query = new VA.ShapeSheet.Query.CellQuery();
            var col_fg = query.AddCell(src_fg, "FillForegnd");
            var col_bg = query.AddCell(src_bg, "FillBkgnd");
            var col_filpat = query.AddCell(src_filpat, "FillPattern");
            var sec_char = query.AddSection(IVisio.VisSectionIndices.visSectionCharacter);
            Assert.AreEqual("Character",sec_char.Name);
            var col_charcase = sec_char.AddCell(VA.ShapeSheet.SRCConstants.CharCase, "CharCase");
            var col_charcolor = sec_char.AddCell(VA.ShapeSheet.SRCConstants.CharColor, "CharColor");
            var col_chartrans = sec_char.AddCell(VA.ShapeSheet.SRCConstants.CharColorTrans, "CharColorTrans");

            var shapeids = new[] {s1_id};

            var formulas = query.GetFormulas(page1, shapeids);

            // now verify that the formulas were actually set
            Assert.AreEqual("RGB(255,0,0)", formulas[0][col_fg]);
            Assert.AreEqual("RGB(0,0,255)", formulas[0][col_bg]);
            Assert.AreEqual("40", formulas[0][col_filpat]);

            // now retrieve the results with GetResults as floats
            var float_results = query.GetResults<double>(page1,shapeids);
            Assert.IsNotNull(float_results);
            Assert.AreEqual(40.0, float_results[0][col_filpat]);

            // now retrieve the results with GetResults as ints
            var int_results = query.GetResults<int>(page1,shapeids);
            Assert.AreEqual(40, int_results[0][col_filpat]);

            // now retrieve the results with GetResults as strings

            var string_results = query.GetResults<string>(page1,shapeids);

            Assert.AreEqual("RGB(255, 0, 0)", string_results[0][col_fg]);
            Assert.AreEqual("RGB(0, 0, 255)", string_results[0][col_bg]);
            Assert.AreEqual("40", string_results[0][col_filpat]);

            page1.Delete(0);
            doc1.Close(true);
        }
コード例 #43
0
        public void ShapeSheet_Query_Demo_MultipleShapes()
        {
            var page1 = GetNewPage(new VA.Drawing.Size(10, 10));

            // draw a simple shape
            var s1 = page1.DrawRectangle(0, 0, 2, 2);
            var s2 = page1.DrawRectangle(4, 4, 6, 6);
            var s3 = page1.DrawRectangle(5, 5, 7, 7);

            var shapeids = new List<int> { s1.ID, s2.ID, s3.ID };

            Assert.AreEqual(3, page1.Shapes.Count);

            var query = new VA.ShapeSheet.Query.CellQuery();
            var col_pinx = query.Columns.Add(VA.ShapeSheet.SRCConstants.PinX,"PinX");
            var col_piny = query.Columns.Add(VA.ShapeSheet.SRCConstants.PinY,"PinY");

            var rf = query.GetFormulas(page1, shapeids);
            var rr = query.GetResults<double>(page1, shapeids);

            var expected_formulas = new[,]
                                      {
                                          {"1 in", "1 in"},
                                          {"5 in", "5 in"},
                                          {"6 in", "6 in"}
                                      };

            var expected_results = new[,]
                                      {
                                          {1.0, 1.0},
                                          {5.0, 5.0},
                                          {6.0, 6.0}
                                      };

            for (int row = 0; row < rr.Count; row++)
            {
                for (int col = 0; col < query.Columns.Count; col++)
                {
                    Assert.AreEqual(expected_formulas[row,col], rf[row][col]);
                    Assert.AreEqual(expected_results[row,col], rr[row][col]);
                }
            }

            page1.Delete(0);
        }