Exemplo n.º 1
0
        public void Radial_DrawPieSlices()
        {
            var doc = this.GetNewDoc();
            var app = doc.Application;
            var page = app.ActivePage;

            var center = new VA.Drawing.Point(4, 5);
            double radius = 1.0;
            var values = new[] {1.0, 2.0};
            var slices = VisioAutomation.Models.Charting.PieSlice.GetSlicesFromValues(center, radius, values);

            var shapes = new IVisio.Shape[values.Length];
            for (int i=0 ;i<values.Length;i++)
            {
                var slice = slices[i];
                var shape = slice.Render(page);
                shapes[i] = shape;
                shape.Text = values[i].ToString(CultureInfo.InvariantCulture);
            }

            var shapeids = shapes.Select(s => s.ID).ToList();
            var xfrms = VisioAutomation.Shapes.XFormCells.GetCells(page, shapeids);

            Assert.AreEqual("4.25 in", xfrms[0].PinX.Formula);
            Assert.AreEqual("5.5 in", xfrms[0].PinY.Formula);
            Assert.AreEqual("4 in", xfrms[1].PinX.Formula);
            Assert.AreEqual("4.9330127018922 in", xfrms[1].PinY.Formula);

            doc.Close(true);
        }
        public SurfaceTarget(IVisio.Master master)
        {
            if (master== null)
            {
                throw new System.ArgumentNullException(nameof(master));
            }

            this.Page = null;
            this.Master = master;
            this.Shape = null;
        }
        public SurfaceTarget(IVisio.Shape shape)
        {
            if (shape== null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            this.Page = null;
            this.Master = null;
            this.Shape = shape;
        }
        public ConnectorEdge(IVisio.Shape connectingshape, IVisio.Shape fromshape, IVisio.Shape toshape) : this()
        {
            if (fromshape == null)
            {
                throw new System.ArgumentNullException(nameof(fromshape));
            }

            if (toshape == null)
            {
                throw new System.ArgumentNullException(nameof(toshape));
            }

            this.Connector = connectingshape;
            this.From = fromshape;
            this.To = toshape;
        }
Exemplo n.º 5
0
        public static List <HyperlinkCells> GetCells(IVisio.Shape shape)
        {
            var query = HyperlinkCells.lazy_query.Value;

            return(query.GetCellGroups(shape));
        }
Exemplo n.º 6
0
        public static PageRulerAndGridCells GetCells(IVisio.Shape shape, VASS.CellValueType type)
        {
            var reader = PageRulerAndGridCells_lazy_builder.Value;

            return(reader.GetCellsSingleRow(shape, type));
        }
Exemplo n.º 7
0
        public static IList <ConnectionPointCells> GetCells(IVisio.Shape shape)
        {
            var query = ConnectionPointCells.lazy_query.Value;

            return(ShapeSheet.CellGroups.CellGroupMultiRow._GetCells <ConnectionPointCells, double>(shape, query, query.GetCells));
        }
Exemplo n.º 8
0
 public ShapeSheetSurface(IVisio.Shape shape)
 {
     this.Target = new SurfaceTarget(shape);
 }
Exemplo n.º 9
0
 public static double GetPropertyDouble(Shape shape, string section, string property, string attribute)
 {
     return GetPropertyDouble(shape, section, property, attribute, measure);
 }
Exemplo n.º 10
0
        public SectionQueryShapeResults <TResult> GetResults <TResult>(IVisio.Shape shape)
        {
            var surface = new SurfaceTarget(shape);

            return(GetResults <TResult>(surface));
        }
Exemplo n.º 11
0
        private void MapItButtonClick(object sender, EventArgs e)
        {
            // open log if not yet open
            var tr2 = new TextWriterTraceListener(File.CreateText(selectedLogFileName.Text));

            Trace.Listeners.Add(tr2);

            // Excel related aspects

            var xlApp = new Microsoft.Office.Interop.Excel.Application {
                Visible = true
            };

            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            // open the excel file
            String   excelFileName = mapFileName.Text;
            Workbook xlWorkBook    = xlApp.Workbooks.Open(excelFileName,
                                                          _missing, _missing, _missing, _missing, _missing, _missing, _missing, _missing,
                                                          _missing, _missing, _missing, _missing, _missing, _missing);


            // read the columns of the sheets containing the map and the elements


            // reference column number --> tag for the elements
            var elementColumnMap = new Dictionary <int, string>();
            int elementMaxColumnNr;
            int elementNameColumnNr;

            MmExcelUtil.BuildColumnMap(xlWorkBook, elementSheetName.Text, elementNameColumnName.Text, elementColumnMap, out elementMaxColumnNr, out elementNameColumnNr);


            // reference column number --> tag for the map
            var taxXColumnMap = new Dictionary <int, string>();
            int taxXMaxColumnNr;
            int taxXNameColumnNr;

            MmExcelUtil.BuildColumnMap(xlWorkBook, xTaxonomySheetName.Text, xTaxonomyNameColumnName.Text, taxXColumnMap, out taxXMaxColumnNr, out taxXNameColumnNr);

            // reference column number --> tag for the map
            var taxYColumnMap = new Dictionary <int, string>();
            int taxYMaxColumnNr;
            int taxYNameColumnNr;

            MmExcelUtil.BuildColumnMap(xlWorkBook, yTaxonomySheetName.Text, yTaxonomyNameColumnName.Text, taxYColumnMap, out taxYMaxColumnNr, out taxYNameColumnNr);

            // list of all the elements to be maped
            var elementList = new List <GenericElement>();

            MmExcelUtil.BuildList(xlWorkBook, elementSheetName.Text, elementNameColumnNr, elementMaxColumnNr, elementColumnMap, elementList, elementNameColumnName.Text);

            // list of all the constituents of the map
            var xTaxonomyList = new List <GenericElement>();

            MmExcelUtil.BuildList(xlWorkBook, xTaxonomySheetName.Text, taxXNameColumnNr, taxXMaxColumnNr, taxXColumnMap, xTaxonomyList, xTaxonomyNameColumnName.Text);

            // list of all the constituents of the map
            var yTaxonomyList = new List <GenericElement>();

            MmExcelUtil.BuildList(xlWorkBook, yTaxonomySheetName.Text, taxYNameColumnNr, taxYMaxColumnNr, taxYColumnMap, yTaxonomyList, yTaxonomyNameColumnName.Text);


            // xTaxonomyMapping
            var xTaxonomyMappingList = new List <Mapping>();

            MmExcelUtil.BuildMapping(xlWorkBook, xTaxonomyMappingList, xMapSheetName.Text, xMapElementNameColumnName.Text,
                                     xMapXTaxNameColumnName.Text);

            var yTaxonomyMappingList = new List <Mapping>();

            MmExcelUtil.BuildMapping(xlWorkBook, yTaxonomyMappingList, yMapSheetName.Text, yMapElementNameColumnName.Text,
                                     yMapYTaxNameColumnName.Text);

            // create the map

            int x      = 0;
            int y      = 0;
            var matrix = new List <String> [xTaxonomyList.Count, yTaxonomyList.Count];

            for (int xi = 0; xi < xTaxonomyList.Count(); xi++)
            {
                for (int yi = 0; yi < yTaxonomyList.Count(); yi++)
                {
                    matrix[xi, yi] = new List <String>();
                }
            }


            foreach (GenericElement yElement in yTaxonomyList)
            {
                x = 0;
                foreach (GenericElement xElement in xTaxonomyList)
                {
                    Trace.WriteLine("  checking for x " + xElement.Name + " and y " + yElement.Name);


                    foreach (GenericElement element in elementList)
                    {
                        // if there is a mapping element to x and y taxonomy then add the element to the matrix

                        Mapping yMap = yTaxonomyMappingList.Find(
                            delegate(Mapping me)
                        {
                            return
                            (me.ElementName == element.Name &&
                             me.MapName == yElement.Name);
                        }
                            );
                        Mapping xMap = xTaxonomyMappingList.Find(
                            delegate(Mapping me)
                        {
                            return
                            (me.ElementName == element.Name &&
                             me.MapName == xElement.Name);
                        }
                            );

                        if (xMap != null && yMap != null)
                        {
                            matrix[x, y].Add(element.Name);
                        }
                    }
                    x += 1;
                }
                y += 1;
            }

            // determine per row the number of different applications and the max number in a cell

            int[] maxNumApplications      = new int [yTaxonomyList.Count];
            int   totalMaxNumApplications = 0;

            int[] diffNumApplications      = new int[yTaxonomyList.Count];
            int   totalDiffNumApplications = 0;
            int   emptyRows = 0;

            for (int yi = 0; yi < yTaxonomyList.Count(); yi++)
            {
                maxNumApplications[yi] = 0;
                List <String> appNames = new List <string>();
                for (int xi = 0; xi < xTaxonomyList.Count(); xi++)
                {
                    maxNumApplications[yi] = Math.Max(maxNumApplications[yi], matrix[xi, yi].Count);
                    foreach (String s in matrix[xi, yi])
                    {
                        if (!appNames.Contains(s))
                        {
                            appNames.Add(s);
                        }
                    }
                }
                diffNumApplications[yi]   = appNames.Count;
                totalDiffNumApplications += diffNumApplications[yi];
                totalMaxNumApplications  += maxNumApplications[yi];
                if (maxNumApplications[yi] == 0)
                {
                    emptyRows++;
                }

                Trace.WriteLine(" Row " + yi + " max num application " + maxNumApplications[yi] + " diff num applications " + diffNumApplications[yi]);
            }

            Trace.WriteLine("Max total number applications " + totalMaxNumApplications);
            Trace.WriteLine("Total number of different applications " + totalDiffNumApplications);
            Trace.WriteLine("Number of empty rows " + emptyRows);

            // Visio related aspects

            var visapp = new Microsoft.Office.Interop.Visio.Application();

            // Prepare Visio
            Document landscape = visapp.Documents.Open(visioFileName.Text);
            Document stencil   = visapp.Documents.OpenEx(stencilFileName.Text, (short)VisOpenSaveArgs.visOpenDocked);
            Page     page      = visapp.ActivePage;


            Master elementStencil   = stencil.Masters[elementStencilName.Text];
            Master taxonomyXStencil = stencil.Masters[xTaxonomyStencilName.Text];
            Master taxomomyYStencil = stencil.Masters[yTaxonomyStencilName.Text];

            if (elementStencil == null)
            {
                throw new ArgumentNullException("elementStencil");
            }
            if (taxonomyXStencil == null)
            {
                throw new ArgumentNullException("taxonomyXStencil");
            }
            if (taxomomyYStencil == null)
            {
                throw new ArgumentNullException("taxomomyYStencil");
            }

            Shape elementShape   = page.Drop(elementStencil, 0.0, 0.0);
            Shape taxonomyXShape = page.Drop(taxonomyXStencil, 0.0, 0.0);
            Shape taxonomyYShape = page.Drop(taxomomyYStencil, 0.0, 0.0);

            double pageWidth = page.PageSheet.CellsU["PageWidth"].ResultIU;
            double pageHight = page.PageSheet.CellsU["PageHeight"].ResultIU;

            double elementWidth  = elementShape.CellsU["Width"].ResultIU;
            double elementHeight = elementShape.CellsU["Height"].ResultIU;

            double taxonomyXHeight = taxonomyXShape.CellsU["Height"].ResultIU;
            double taxonomyXWidth  = taxonomyXShape.CellsU["Width"].ResultIU;
            double taxonomyYHeight = taxonomyYShape.CellsU["Height"].ResultIU;
            double taxonomyYWidth  = taxonomyYShape.CellsU["Width"].ResultIU;


            double space = double.Parse(spaceText.Text);

            elementShape.Delete();
            taxonomyXShape.Delete();
            taxonomyYShape.Delete();

            Trace.WriteLine("Size of an page    " + pageWidth + " " + pageHight);
            Trace.WriteLine("Size of an element " + elementWidth + " " + elementHeight);

            double yTaxonomyYRoot = pageHight - 2 * space - taxonomyXHeight;
            double xTaxonomyXRoot = 2 * space + taxonomyYWidth;

            double taxYHeight = 0.0;

            if (emptyRowSuppressionCheckBox.Checked)
            {
                taxYHeight = (yTaxonomyYRoot - 2 * space) / totalDiffNumApplications;
            }
            else
            {
                taxYHeight = (yTaxonomyYRoot - 2 * space) / (totalDiffNumApplications + emptyRows);
            }
            double taxXWidth = (pageWidth - xTaxonomyXRoot - 2 * space) / xTaxonomyList.Count;


            double yPos = yTaxonomyYRoot;


            for (int xi = 0; xi < xTaxonomyList.Count; xi++)
            {
                MmVisioUtil.PlaceGenericElement(page, taxonomyXStencil, xTaxonomyList[xi],
                                                xTaxonomyXRoot + (xi + 0.5) * taxXWidth,
                                                yTaxonomyYRoot + taxonomyXHeight * 0.5,
                                                taxXWidth,
                                                taxonomyXHeight,
                                                taxXColumnMap,
                                                false);
            }



            for (int yi = 0; yi < yTaxonomyList.Count(); yi++)
            {
                double xPos = space * 2.0 + taxonomyXWidth / 2.0;

                if (emptyRowSuppressionCheckBox.Checked && diffNumApplications[yi] == 0)
                {
                    // do noting
                }
                else
                {
                    double height = Math.Max(1, diffNumApplications[yi]) * taxYHeight;

                    MmVisioUtil.PlaceGenericElement(page, taxomomyYStencil, yTaxonomyList[yi],
                                                    xPos, yPos - height / 2,
                                                    taxonomyYWidth, height,
                                                    taxYColumnMap,
                                                    false);

                    // draw applications

                    List <String> appNames = new List <string>();

                    for (int xi = 0; xi < xTaxonomyList.Count; xi++)
                    {
                        foreach (String s in matrix[xi, yi])
                        {
                            if (!appNames.Contains(s))
                            {
                                appNames.Add(s);
                            }
                        }
                    }

                    int nApp = 0;
                    foreach (String Name in appNames)
                    {
                        GenericElement app = elementList.Find(
                            delegate(GenericElement ele)
                        {
                            return(ele.Name == Name);
                        }
                            );

                        if (app != null)
                        {
                            elementShape = null;

                            for (int xi = 0; xi < xTaxonomyList.Count; xi++)
                            {
                                if (matrix[xi, yi].Contains(Name))
                                {
                                    if (mergeApplicationsCheckBox.Checked && elementShape != null)
                                    {
                                        elementShape.CellsU["Width"].ResultIU += taxXWidth;
                                        elementShape.CellsU["PinX"].ResultIU  += taxXWidth / 2;
                                    }
                                    else
                                    {
                                        if (applySpaceCheckBox.Checked)
                                        {
                                            elementShape = MmVisioUtil.PlaceGenericElement(page, elementStencil, app,
                                                                                           xTaxonomyXRoot +
                                                                                           (xi + 0.5) * (taxXWidth),
                                                                                           yPos -
                                                                                           (nApp + 0.5) * taxYHeight,
                                                                                           taxXWidth - space, taxYHeight,
                                                                                           elementColumnMap,
                                                                                           false);
                                        }
                                        else
                                        {
                                            elementShape = MmVisioUtil.PlaceGenericElement(page, elementStencil, app,
                                                                                           xTaxonomyXRoot +
                                                                                           (xi + 0.5) * taxXWidth,
                                                                                           yPos -
                                                                                           (nApp + 0.5) * taxYHeight,
                                                                                           taxXWidth, taxYHeight,
                                                                                           elementColumnMap,
                                                                                           false);
                                        }
                                    }
                                }
                                else
                                {
                                    elementShape = null;
                                }
                            }
                            nApp++;
                        }
                        else
                        {
                            String error = "### unknown element " + elementShape.Name;
                            Trace.WriteLine(error);
                            errorListBox.Items.Add(error);
                        }
                    }


                    yPos -= height;
                }
            }


            Trace.Flush();
            Trace.Close();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Paints the Shape, and it's composing sub-shapes, with the
        /// given color.
        /// </summary>
        /// <param name="shape">Root shape</param>
        /// <param name="colorIndex">Color, as per index in the Visio Color Palette</param>
        public static void PaintShape( Shape shape, string colorIndex )
        {
            Cell cell = shape.get_CellsSRC( (short) VisSectionIndices.visSectionObject, (short) VisRowIndices.visRowLine, (short) VisCellIndices.visLineColor );
            cell.FormulaU = colorIndex;

            cell = shape.get_CellsSRC((short)VisSectionIndices.visSectionCharacter, (short)VisRowIndices.visRowCharacter, (short)VisCellIndices.visCharacterColor);
            cell.FormulaU = colorIndex;

            foreach (Shape subShape in shape.Shapes)
                PaintShape(subShape, colorIndex);
        }
Exemplo n.º 13
0
        public static bool PaintColoredTransition(Shape shape, XmlNodeList paint)
        {
            string colorIndex="2";// por omissão é erro

            if (shape.Connects.Count > 1)
            {

                string fromShape = GetProperty(shape.Connects[1].ToCell.Shape, "User", "Midgard");
                string toShape = GetProperty(shape.Connects[2].ToCell.Shape, "User", "Midgard");
                if (fromShape != null && toShape != null)
                {

                    colorIndex = ValidColor;
                }
            }
            PaintShape(shape, colorIndex);
            return (colorIndex != "2");
        }
Exemplo n.º 14
0
        public static bool PaintColoredShape(Shape shape, XmlNodeList paint)
        {
            string colorIndex="2";// por omissão é erro

            if (shape.Connects.Count > 1)
            {

                string fromShape = GetProperty(shape.Connects[1].ToCell.Shape, "User", "Midgard");
                string toShape = GetProperty(shape.Connects[2].ToCell.Shape, "User", "Midgard");
                if (fromShape != null && toShape != null)
                {
                    XmlDocument fromShapeDoc = GetPropertiesFromShape(shape.Connects[1].ToCell.Shape);
                    XmlDocument toShapeDoc = GetPropertiesFromShape(shape.Connects[2].ToCell.Shape);

                    string fromShapeScreen = GetElementValueFromProperties(fromShapeDoc, (fromShape == "Business" ? "screen" : "id"));
                    string toShapeScreen = GetElementValueFromProperties(toShapeDoc, (toShape == "Business" ? "screen" : "id"));

                    foreach (XmlNode p in paint)
                    {
                        if (p.Attributes["connectedTo"] != null && p.Attributes["connectedFrom"] != null)
                        {
                            string connectedTo = p.Attributes["connectedTo"].Value;
                            string connectedFrom = p.Attributes["connectedFrom"].Value;
                            bool execute = true;
                            if (p.Attributes["rule"] != null)
                            {
                                string rule = p.Attributes["rule"].Value;
                                if (rule.ToLower() == "differentscreencode")
                                {
                                    execute = (fromShapeScreen != toShapeScreen);
                                }
                            }
                            if (execute)
                            {
                                if (connectedTo.IndexOf(toShape) >= 0 && connectedFrom.IndexOf(fromShape) >= 0)
                                    colorIndex = p.InnerText;
                            }
                        }
                    }
                }
            }
            PaintShape(shape, colorIndex);
            return (colorIndex != "2");
        }
Exemplo n.º 15
0
        public static string GetShapeType(Shape shape)
        {
            string shapeType = null;
            string layerName = null;
            Application app = shape.Document.Application;
            if (!IsProcess(app))
            {
                shapeType = "QuartzShape";
                layerName = "Process";
            }
            else
            {
                shapeType = "ScreenShape";
                layerName = "Screen";
            }

            string name = GetProperty(shape, "User", shapeType);

            if (name != null)
            {
                Shape tmpShape = shape;
                tmpShape.Application.ActivePage.Layers.Add(layerName);
            }
            return name;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Gets the string value of an attribute fom a Shape property.
        /// </summary>
        /// <param name="shape">Visio shape.</param>
        /// <param name="section">Name of the Visio shape-sheep section.</param>
        /// <param name="property">>Name of the shape-sheep property (also known as section rows).</param>
        /// <param name="attribute">Name of the shape-sheep property attribute (also known as section column).</param>
        /// <returns>The string value of the attribute from the designated property, or
        /// null if the property/attribute does not exist.</returns>
        public static string GetPropertyStr( Shape shape, string section, string property, string attribute )
        {
            string cellLocation=string.Empty;
            if((section==string.Empty)&&(property==string.Empty))
                cellLocation=string.Format( "{0}", attribute );
            else
                cellLocation = string.Format( "{0}.{1}.{2}", section, property, attribute );
            Cell cell;

            try
            {
                cell = shape.get_Cells( cellLocation );
            }
            catch ( COMException )
            {
                return null;
            }

            return FormulaToString( cell.get_ResultStr(measure) );
        }
Exemplo n.º 17
0
 /// <summary>
 /// Gets the string value of the Value attribute fom a Shape property.
 /// </summary>
 /// <param name="shape">Visio shape.</param>
 /// <param name="section">Name of the Visio shape-sheep section.</param>
 /// <param name="property">Name of the shape-sheep property (also known as section rows).</param>
 /// <returns>The string value of the Value attribute from the designated property, or
 /// null if the property/attribute does not exist.</returns>
 public static string GetPropertyStr( Shape shape, string section, string property )
 {
     return GetPropertyStr( shape, section, property, "Value" );
 }
Exemplo n.º 18
0
        /// <summary>
        /// Draw an "Entity" Rectangle
        /// </summary>
        /// <param name="page">The Page on which to draw</param>
        /// <param name="entity">The entity to draw</param>
        /// <returns>The newly drawn rectangle</returns>
        private VisioApi.Shape DrawEntityRectangle(VisioApi.Page page, EntityMetadata entity)
        {
            VisioApi.Shape rect = page.DrawRectangle(X_POS1, Y_POS1, X_POS2, Y_POS2);
            rect.Name = entity.LogicalName;
            if (dbp.entityLabelDisplay == 1)
            {
                rect.Text = entity.DisplayName.UserLocalizedLabel.Label + " ";
            }
            else if (dbp.entityLabelDisplay == 2)
            {
                rect.Text = entity.DisplayName.UserLocalizedLabel.Label + " [" + entity.LogicalName + "] ";
            }
            else
            {
                rect.Text = entity.LogicalName + " ";
            }


            // Determine the shape fill color based on entity ownership.
            string fillColor;

            switch (entity.OwnershipType.Value)
            {
            case OwnershipTypes.BusinessOwned:
                fillColor = "RGB(255,202,176)";     // Light orange
                break;

            case OwnershipTypes.OrganizationOwned:
                fillColor = "RGB(255,255,176)";     // Light yellow
                break;

            case OwnershipTypes.UserOwned:
                fillColor = "RGB(204,255,204)";     // Light green
                break;

            default:
                fillColor = "RGB(255,255,255)";     // White
                break;
            }

            // Set the fill color, placement properties, and line weight of the shape.
            rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowMisc, (short)VisioApi.VisCellIndices.visLOFlags).Formula = ((int)VisioApi.VisCellVals.visLOFlagsPlacable).ToString();
            if (dbp.showOwnership)
            {
                rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowFill, (short)VisioApi.VisCellIndices.visFillForegnd).FormulaU = fillColor;
            }

            // Update the style of the entity name
            VisioApi.Characters characters = rect.Characters;
            characters.Begin = 0;
            characters.End   = entity.LogicalName.Length;
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterStyle, (short)VisioApi.VisCellVals.visBold);
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visDarkBlue);
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterSize, NAME_CHARACTER_SIZE);
            //set the font family of the text to segoe for the visio 2013.
            if (VersionName == "15.0")
            {
                characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterFont, (short)FONT_STYLE);
            }

            _processedEntities.Add(new ProcessedEntity {
                entityName = entity.LogicalName, attributes = new List <string> {
                    entity.PrimaryIdAttribute
                }
            });

            //Add Primary Key attribute
            if (dbp.showPrimaryKeys)
            {
                rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowXFormOut, (short)VisioApi.VisCellIndices.visXFormHeight).ResultIU += HEIGHT;
                AttributeMetadata attribute = GetAttributeMetadata(entity, entity.PrimaryIdAttribute);
                rect.Text += getAttributeValue(attribute) + "  [PK]";
            }

            return(rect);
        }
Exemplo n.º 19
0
        public static LockCells GetCells(IVisio.Shape shape)
        {
            var query = LockCells.lazy_query.Value;

            return(ShapeSheet.CellGroups.CellGroup._GetCells <LockCells, double>(shape, query, query.GetCells));
        }
Exemplo n.º 20
0
 /// <summary>
 /// Sets the string value of an attribute fom a Shape property.
 /// </summary>
 /// <param name="shape">Visio shape.</param>
 /// <param name="section">Name of the Visio shape-sheep section.</param>
 /// <param name="property">>Name of the shape-sheep property (also known as section rows).</param>
 /// <param name="value">The value to set.</param>
 public static void SetProperty( Shape shape, string section, string property, string value )
 {
     SetProperty( shape, section, property, "Value", value );
 }
Exemplo n.º 21
0
        public static List <ParagraphFormatCells> GetCells(IVisio.Shape shape, CellValueType type)
        {
            var query = lazy_query.Value;

            return(query.GetCells(shape, type));
        }
Exemplo n.º 22
0
        /// <summary>
        /// Sets the string value of an attribute fom a Shape property.
        /// </summary>
        /// <param name="shape">Visio shape.</param>
        /// <param name="section">Name of the Visio shape-sheep section.</param>
        /// <param name="property">>Name of the shape-sheep property (also known as section rows).</param>
        /// <param name="attribute">Name of the shape-sheep property attribute (also known as section column).</param>
        /// <param name="value">The value to set.</param>
        public static void SetProperty( Shape shape, string section, string property, string attribute, string value )
        {
            string cellLocation = string.Empty;
            if((section==string.Empty)&&(property==string.Empty))
                cellLocation=string.Format( "{0}", attribute );
            else
                cellLocation=string.Format( "{0}.{1}.{2}", section, property, attribute );

            Cell cell;
            try
            {
                cell = shape.get_Cells( cellLocation );
                cell.Formula = StringToFormula( value );
            }
            catch ( COMException )
            {
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Gets the string value of an attribute fom a Shape property.
        /// </summary>
        /// <param name="shape">Visio shape.</param>
        /// <param name="section">Name of the Visio shape-sheep section.</param>
        /// <param name="property">>Name of the shape-sheep property (also known as section rows).</param>
        /// <param name="attribute">Name of the shape-sheep property attribute (also known as section column).</param>
        /// <returns>The string value of the attribute from the designated property, or
        /// null if the property/attribute does not exist.</returns>
        public static int GetPropertyInt( Shape shape, string section, string property, string attribute, string customMesure)
        {
            string cellLocation=string.Empty;
            if((section==string.Empty)&&(property==string.Empty))
                cellLocation=string.Format( "{0}", attribute );
            else
                cellLocation = string.Format( "{0}.{1}.{2}", section, property, attribute );
            Cell cell;

            try
            {
                cell = shape.get_Cells( cellLocation );
            }
            catch ( COMException )
            {
                return -1;
            }

            return cell.get_ResultInt(customMesure, 1);
        }
Exemplo n.º 24
0
        public void Render(IVisio.Page page)
        {
            double sum = this._slices.Select(s => s.Value).Sum();
            var shapes = new List<IVisio.Shape>();
            double start_angle = 0.0;

            // Draw each slice
            for (int i = 0; i < this.Slices.Count; i++)
            {
                var slice = this.Slices[i];
                double cur_val = slice.Value;
                double cur_val_norm = cur_val / sum;
                double cur_angle = cur_val_norm * System.Math.PI * 2.0;
                double end_angle = start_angle + cur_angle;


                slice.StartAngle = start_angle;
                slice.EndAngle = end_angle;

                var ps = new VA.Layout.Models.Radial.PieSlice(this.Center, start_angle, end_angle, this.Radius);
                var shape = ps.Render(page);
                start_angle += cur_angle;

                shapes.Add(shape);
            }


            for (int i = 0; i < shapes.Count; i++)
            {
                var shape = shapes[i];
                var slice = this._slices[i];
                slice.VisioShape = shape;
                if (!string.IsNullOrEmpty(slice.Text))
                {
                    shape.Text = slice.Text;
                }
            }

            if (this.DrawBackground)
            {
                var ll = this.Center.Subtract(this.Radius, this.Radius);
                var ur = this.Center.Add(this.Radius, this.Radius);
                var rect = new VA.Drawing.Rectangle(ll, ur);
                this._backgroundVisioShape = page.DrawOval(rect);
            }
        }
        public void AddTo(IVisio.Shape shape, ShapeSheet.Writers.SrcWriter writer, short row, short section)
        {
            short row_index = shape.AddRow(section, row, (short)this.GetRowTagType());

            this.Update(section, row_index, writer);
        }
Exemplo n.º 26
0
 /// <summary>
 /// Gets the string value of the Value attribute fom a Shape property.
 /// </summary>
 /// <param name="shape">Visio shape.</param>
 /// <param name="section">Name of the Visio shape-sheep section.</param>
 /// <param name="property">Name of the shape-sheep property (also known as section rows).</param>
 /// <returns>The string value of the Value attribute from the designated property, or
 /// null if the property/attribute does not exist.</returns>
 public static int GetPropertyInt( Shape shape, string section, string property )
 {
     return GetPropertyInt( shape, section, property, "Value", measure );
 }
Exemplo n.º 27
0
        public static ShapeLayoutCells GetCells(IVisio.Shape shape)
        {
            var query = ShapeLayoutCells.lazy_query.Value;

            return(query.GetCellGroup(shape));
        }
Exemplo n.º 28
0
        public static List <CustomPropertyCells> GetCells(IVisio.Shape shape)
        {
            var query = CustomPropertyCells.lazy_query.Value;

            return(query.GetCellGroups(shape));
        }
Exemplo n.º 29
0
        public static List <ConnectionPointCells> GetCells(IVisio.Shape shape, CellValueType type)
        {
            var query = lazy_query.Value;

            return(query.GetCells(shape, type));
        }
Exemplo n.º 30
0
        public static List <ParagraphCells> GetCells(IVisio.Shape shape)
        {
            var query = ParagraphCells.lazy_query.Value;

            return(query.GetCellGroups(shape));
        }
Exemplo n.º 31
0
        public static IList <UserDefinedCell> GetCells(IVisio.Shape shape)
        {
            var query = get_query();

            return(_GetCells <UserDefinedCell, string>(shape, query, query.GetCells));
        }
Exemplo n.º 32
0
        public static List <UserDefinedCellCells> GetCells(IVisio.Shape shape, CellValueType type)
        {
            var query = lazy_query.Value;

            return(query.GetCells(shape, type));
        }
Exemplo n.º 33
0
        /// <summary>
        /// Draw on a Visio page the entity relationships defined in the passed-in relationship collection.
        /// </summary>
        /// <param name="entity">Core entity</param>
        /// <param name="rect">Shape representing the core entity</param>
        /// <param name="relationshipCollection">Collection of entity relationships to draw</param>
        /// <param name="areReferencingRelationships">Whether or not the core entity is the referencing entity in the relationship</param>
        /// <param name="worker">The worker.</param>
        /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param>
        private void DrawRelationships(EntityMetadata entity, VisioApi.Shape rect, RelationshipMetadataBase[] relationshipCollection, bool areReferencingRelationships, BackgroundWorker worker, DoWorkEventArgs e)
        {
            ManyToManyRelationshipMetadata currentManyToManyRelationship = null;
            OneToManyRelationshipMetadata  currentOneToManyRelationship  = null;
            EntityMetadata    entity2    = null;
            AttributeMetadata attribute2 = null;
            AttributeMetadata attribute  = null;
            Guid metadataID   = Guid.NewGuid();
            bool isManyToMany = false;

            // Draw each relationship in the relationship collection.
            foreach (RelationshipMetadataBase entityRelationship in relationshipCollection)
            {
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                entity2 = null;

                if (entityRelationship is ManyToManyRelationshipMetadata)
                {
                    isManyToMany = true;
                    currentManyToManyRelationship = entityRelationship as ManyToManyRelationshipMetadata;
                    // The entity passed in is not necessarily the originator of this relationship.
                    if (String.Compare(entity.LogicalName, currentManyToManyRelationship.Entity1LogicalName, true) != 0)
                    {
                        entity2 = GetEntityMetadata(currentManyToManyRelationship.Entity1LogicalName);
                    }
                    else
                    {
                        entity2 = GetEntityMetadata(currentManyToManyRelationship.Entity2LogicalName);
                    }
                    attribute2 = GetAttributeMetadata(entity2, entity2.PrimaryIdAttribute);
                    attribute  = GetAttributeMetadata(entity, entity.PrimaryIdAttribute);
                    metadataID = currentManyToManyRelationship.MetadataId.Value;
                }
                else if (entityRelationship is OneToManyRelationshipMetadata)
                {
                    isManyToMany = false;
                    currentOneToManyRelationship = entityRelationship as OneToManyRelationshipMetadata;
                    entity2    = GetEntityMetadata(areReferencingRelationships ? currentOneToManyRelationship.ReferencingEntity : currentOneToManyRelationship.ReferencedEntity);
                    attribute2 = GetAttributeMetadata(entity2, areReferencingRelationships ? currentOneToManyRelationship.ReferencingAttribute : currentOneToManyRelationship.ReferencedAttribute);
                    attribute  = GetAttributeMetadata(entity, areReferencingRelationships ? currentOneToManyRelationship.ReferencedAttribute : currentOneToManyRelationship.ReferencingAttribute);
                    metadataID = currentOneToManyRelationship.MetadataId.Value;
                }
                // Verify relationship is either ManyToManyMetadata or OneToManyMetadata
                if (entity2 != null)
                {
                    if (_processedRelationships.Contains(metadataID))
                    {
                        // Skip relationships we have already drawn
                        continue;
                    }
                    else
                    {
                        // Record we are drawing this relationship
                        _processedRelationships.Add(metadataID);

                        // Define convenience variables based upon the direction of referencing with respect to the core entity.
                        VisioApi.Shape rect2;

                        // Do not draw relationships involving the entity itself, SystemUser, BusinessUnit,
                        // or those that are intentionally excluded.
                        string selectedEntityFound = selectedEntitiesNames.Find(en => en == entity2.LogicalName);
                        if (String.Compare(entity2.LogicalName, "systemuser", true) != 0 &&
                            String.Compare(entity2.LogicalName, "businessunit", true) != 0 &&
                            String.Compare(entity2.LogicalName, rect.Name, true) != 0 &&
                            (selectedEntityFound != null) &&
                            String.Compare(entity.LogicalName, "systemuser", true) != 0 &&
                            String.Compare(entity.LogicalName, "businessunit", true) != 0)
                        {
                            // Either find or create a shape that represents this secondary entity, and add the name of
                            // the involved attribute to the shape's text.
                            try
                            {
                                rect2 = rect.ContainingPage.Shapes.get_ItemU(entity2.LogicalName);
                                int processedEntity2Index = _processedEntities.FindIndex(pe => pe.entityName == entity2.LogicalName);
                                if (!_processedEntities[processedEntity2Index].attributes.Exists(a => a == attribute2.LogicalName) && dbp.showForeignKeys)
                                {
                                    rect2.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowXFormOut, (short)VisioApi.VisCellIndices.visXFormHeight).ResultIU += 0.25;
                                    rect2.Text += getAttributeValue(attribute2);
                                    _processedEntities[processedEntity2Index].attributes.Add(attribute2.LogicalName);
                                }
                            }
                            catch (System.Runtime.InteropServices.COMException)
                            {
                                rect2 = DrawEntityRectangle(rect.ContainingPage, entity2);
                                int processedEntity2Index = _processedEntities.FindIndex(pe => pe.entityName == entity2.LogicalName);
                                if (!_processedEntities[processedEntity2Index].attributes.Exists(a => a == attribute2.LogicalName) && dbp.showForeignKeys)
                                {
                                    rect2.Text += getAttributeValue(attribute2);
                                    _processedEntities[processedEntity2Index].attributes.Add(attribute2.LogicalName);
                                }
                            }

                            // Add the name of the involved attribute to the core entity's text, if not already present.
                            int processedEntityIndex = _processedEntities.FindIndex(pe => pe.entityName == entity.LogicalName);
                            if (!_processedEntities[processedEntityIndex].attributes.Exists(a => a == attribute.LogicalName) && dbp.showForeignKeys)
                            {
                                rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowXFormOut, (short)VisioApi.VisCellIndices.visXFormHeight).ResultIU += HEIGHT;
                                rect.Text += getAttributeValue(attribute);
                                _processedEntities[processedEntityIndex].attributes.Add(attribute.LogicalName);
                            }

                            // Draw the directional, dynamic connector between the two entity shapes.
                            if (areReferencingRelationships)
                            {
                                DrawDirectionalDynamicConnector(rect, rect2, isManyToMany, entityRelationship.SchemaName);
                            }
                            else
                            {
                                DrawDirectionalDynamicConnector(rect2, rect, isManyToMany, entityRelationship.SchemaName);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 34
0
        public void Execute(IVisio.Shape shape)
        {
            var surface = new ShapeSheetSurface(shape);

            this._Execute(surface);
        }
Exemplo n.º 35
0
        public static IList <UserDefinedCell> GetCells(IVisio.Shape shape)
        {
            var query = UserDefinedCell.lazy_query.Value;

            return(ShapeSheet.CellGroups.CellGroupMultiRow._GetCells <UserDefinedCell, string>(shape, query, query.GetCells));
        }
Exemplo n.º 36
0
        /// <summary>
        /// Decorates the shape with tags if column names (with '_') and shape parameter names match
        /// </summary>
        /// <param name="element"></param>
        /// <param name="columnMap"></param>
        /// <param name="showNotes"></param>
        /// <param name="elementShape"></param>
        public static void DecorateShape(GenericElement element, Dictionary <int, string> columnMap, bool showNotes, Shape elementShape)
        {
            for (int ndx = 1; ndx <= columnMap.Keys.Count; ndx++)
            {
                String tag   = columnMap[ndx];
                String value = element.GetValue(tag);

                String cellName  = "Prop." + tag.Replace(" ", "_");
                String cellValue = cellName + ".Value";

                //                Trace.WriteLine("Cell  " + cellName + " --> " + cellValue);


                if (elementShape.CellExists[cellName, 0] != 0)
                {
                    elementShape.Cells[cellValue].FormulaU = "\"" + value + "\"";
                }
                else if (tag == "Description" && showNotes)
                {
                    elementShape.Text = value;
                }
            }
        }
Exemplo n.º 37
0
        public void CreateVisio3DObjectFromBoundingBox(Visio.Shape visCurShape, out Visio3DObject visio3DObject)
        {
            PointF ptCurOrigin;
            double dblCurOrigX, dblCurOrigY, dblCurAngle, dblCurWidth, dblCurHeight, dblCurThickness, dblCurElevation;
            double dblCurLocPinX, dblCurLocPinY;
            float  fCurAngle, fCurLength, fCurHeight, fCurThickness, fCurElevation;
            string strCurMaterial = "", strBoxTextureFileName = null, strFrontTextureFileName = null;
            Color  elementColor = Color.White;

            VisualShow3DLightUtil.GetDoubleCellVal(visCurShape, "PinX", (int)Visio.VisUnitCodes.visNumber,
                                                   out dblCurOrigX);
            VisualShow3DLightUtil.GetDoubleCellVal(visCurShape, "PinY", (int)Visio.VisUnitCodes.visNumber,
                                                   out dblCurOrigY);
            VisualShow3DLightUtil.GetDoubleCellVal(visCurShape, "LocPinX", (int)Visio.VisUnitCodes.visNumber,
                                                   out dblCurLocPinX);
            VisualShow3DLightUtil.GetDoubleCellVal(visCurShape, "LocPinY", (int)Visio.VisUnitCodes.visNumber,
                                                   out dblCurLocPinY);
            VisualShow3DLightUtil.GetDoubleCellVal(visCurShape, "Angle", (int)Visio.VisUnitCodes.visDegrees,
                                                   out dblCurAngle);
            VisualShow3DLightUtil.GetDoubleCellVal(visCurShape, "Width", (int)Visio.VisUnitCodes.visNumber,
                                                   out dblCurWidth);
            VisualShow3DLightUtil.GetDoubleCellVal(visCurShape, "Height", (int)Visio.VisUnitCodes.visNumber,
                                                   out dblCurThickness);
            try
            {
                VisualShow3DLightUtil.GetDoubleCellVal(visCurShape, "Prop.VS3DHeight", (int)Visio.VisUnitCodes.visNumber, out dblCurHeight);
            }
            catch
            {
                dblCurHeight = 0.0;
            }
            try
            {
                VisualShow3DLightUtil.GetDoubleCellVal(visCurShape, "Prop.VS3DElevation", (int)Visio.VisUnitCodes.visNumber, out dblCurElevation);
            }
            catch
            {
                dblCurElevation = 0.0;
            }
            try
            {
                VisualShow3DLightUtil.GetStringCellProp(visCurShape, "Prop.VS3DMaterial", out strBoxTextureFileName);
            }
            catch
            {
                strCurMaterial = "";
            }
            if (strCurMaterial == "")
            {
                VisualShow3DLightUtil.GetRGBCellVal(visCurShape, "FillForegnd", out strCurMaterial);
                VisualShow3DLightUtil.GetColor(strCurMaterial, out elementColor);
            }
            ptCurOrigin = new PointF((float)dblCurOrigX, (float)dblCurOrigY);
            fCurAngle   = (float)dblCurAngle;
            fCurLength  = (float)dblCurWidth;
            fCurHeight  = (float)dblCurHeight;
            if (VisualShow3DLightUtil.IsOneD(visCurShape))
            {
                fCurThickness = 0.0f;
            }
            else
            {
                fCurThickness = (float)dblCurThickness;
            }
            fCurElevation = (float)dblCurElevation;
            visio3DObject = new Visio3DObject(ptCurOrigin, fCurAngle, fCurLength, fCurHeight, fCurThickness, fCurElevation,
                                              elementColor, Color.White, strBoxTextureFileName, strFrontTextureFileName);
        }
Exemplo n.º 38
0
 public ShapeRef(Shape pShape)
 {
     Shape = pShape;
 }
Exemplo n.º 39
0
        public void SetText(IVisio.Shape shape)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            // First just set all the text
            string full_doc_inner_text = this.GetInnerText();

            shape.Text = full_doc_inner_text;

            // Find all the regions needing formatting
            var markupinfo        = this.GetMarkupInfo();
            var regions_to_format = markupinfo.FormatRegions.Where(region => region.Length >= 1).ToList();


            var default_chars_bias = IVisio.VisCharsBias.visBiasLeft;


            var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter();

            foreach (var region in regions_to_format)
            {
                // Apply character formatting
                var charcells = region.Element.CharacterFormatting;
                if (charcells != null)
                {
                    var chars = shape.Characters;
                    chars.Begin = region.Start;
                    chars.End   = region.End;
                    chars.CharProps[ShapeSheet.SrcConstants.CharColor.Cell] = 0;
                    short rownum = chars.CharPropsRow[(short)default_chars_bias];

                    if (rownum < 0)
                    {
                        throw new VisioAutomation.Exceptions.VisioOperationException("Could not create Character row");
                    }

                    writer.Clear();
                    charcells.ApplyFormulas(writer, rownum);

                    writer.CommitFormulas(shape);
                }

                // Apply paragraph formatting
                var paracells = region.Element.ParagraphFormatting;
                if (paracells != null)
                {
                    var chars = shape.Characters;
                    chars.Begin = region.Start;
                    chars.End   = region.End;
                    chars.ParaProps[ShapeSheet.SrcConstants.ParaBullet.Cell] = 0;
                    short rownum = chars.ParaPropsRow[(short)default_chars_bias];

                    if (rownum < 0)
                    {
                        throw new VisioAutomation.Exceptions.VisioOperationException("Could not create Paragraph row");
                    }

                    writer.Clear();
                    paracells.ApplyFormulas(writer, rownum);

                    writer.CommitFormulas(shape);
                }
            }

            // Insert the fields
            // note: Fields are added in reverse because it is simpler to keep track of the insertion positions
            foreach (var field_region in markupinfo.FieldRegions.Where(region => region.Length >= 1).Reverse())
            {
                var chars = shape.Characters;
                chars.Begin = field_region.Start;
                chars.End   = field_region.End;
                chars.AddField((short)field_region.Field.Category, (short)field_region.Field.Code,
                               (short)field_region.Field.Format);
                var fr = field_region;
            }
        }
Exemplo n.º 40
0
        public static void AutomateVisio()
        {
            Visio.Application oVisio     = null;
            Visio.Documents   oDocs      = null;
            Visio.Document    oDoc       = null;
            Visio.Pages       oPages     = null;
            Visio.Page        oPage      = null;
            Visio.Shape       oRectShape = null;
            Visio.Shape       oOvalShape = null;

            try
            {
                // Create an instance of Microsoft Visio and make it invisible.

                oVisio         = new Visio.Application();
                oVisio.Visible = false;
                Console.WriteLine("Visio.Application is started");

                // Create a new Document based on no template.

                oDocs = oVisio.Documents;
                oDoc  = oDocs.Add("");
                Console.WriteLine("A new document is created");

                // Draw a rectangle and a oval on the first page.

                Console.WriteLine("Draw a rectangle and a oval");

                oPages     = oDoc.Pages;
                oPage      = oPages[1];
                oRectShape = oPage.DrawRectangle(0.5, 10.25, 6.25, 7.375);
                oOvalShape = oPage.DrawOval(1.125, 6, 6.875, 2.125);

                // Save the document as a vsd file and close it.

                Console.WriteLine("Save and close the document");
                string fileName = Path.GetDirectoryName(
                    Assembly.GetExecutingAssembly().Location) + "\\Sample1.vsd";
                oDoc.SaveAs(fileName);
                oDoc.Close();

                // Quit the Visio application.

                Console.WriteLine("Quit the Visio application");
                oVisio.Quit();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Solution1.AutomateVisio throws the error: {0}",
                                  ex.Message);
            }
            finally
            {
                // Clean up the unmanaged Visio COM resources by explicitly
                // calling Marshal.FinalReleaseComObject on all accessor objects.
                // See http://support.microsoft.com/kb/317109.

                if (oOvalShape != null)
                {
                    Marshal.FinalReleaseComObject(oOvalShape);
                    oOvalShape = null;
                }
                if (oRectShape != null)
                {
                    Marshal.FinalReleaseComObject(oRectShape);
                    oRectShape = null;
                }
                if (oPage != null)
                {
                    Marshal.FinalReleaseComObject(oPage);
                    oPage = null;
                }
                if (oPages != null)
                {
                    Marshal.FinalReleaseComObject(oPages);
                    oPages = null;
                }
                if (oDoc != null)
                {
                    Marshal.FinalReleaseComObject(oDoc);
                    oDoc = null;
                }
                if (oDocs != null)
                {
                    Marshal.FinalReleaseComObject(oDocs);
                    oDocs = null;
                }
                if (oVisio != null)
                {
                    Marshal.FinalReleaseComObject(oVisio);
                    oVisio = null;
                }
            }
        }
Exemplo n.º 41
0
        internal static void GetProjectFileInfo(Visio.Application app, string doc, string page, string shape, string shapeu, string[] v)
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           MethodBase.GetCurrentMethod().Name));

            Visio.Page    activePage  = app.ActivePage;
            Visio.Shape   activeShape = app.ActivePage.Shapes[shape];
            List <String> filesToProcess; // = new List<string>();

            try
            {
                FileInfoShape fileInfoShape = new FileInfoShape(activeShape);

                VisioHelper.DisplayInWatchWindow(string.Format("{0}",
                                                               fileInfoShape.ToString()));

                //VisioHelper.DisplayInWatchWindow(string.Format("{0}",
                //    fileInfoShape.DisplayInfo()));

                string configFileFullPath = @"C:\temp\CodeCommandConsole_Config.xml";

                string projectFileName  = fileInfoShape.ProjectFileName;
                string solutionFileName = fileInfoShape.SolutionFileName;
                string branchName       = fileInfoShape.BranchName;
                string solutionName     = fileInfoShape.SolutionName;
                string projectName      = fileInfoShape.ProjectName;


                if (projectFileName.Length > 0)
                {
                    string sourcePath        = fileInfoShape.BranchSourcePath;
                    string projectFolderPath = fileInfoShape.ProjectFolderPath;

                    filesToProcess = VNC.CodeAnalysis.Workspace.Helper.GetSourceFilesToProcessFromVSProject(
                        sourcePath + "\\" + projectFolderPath + "\\" + projectFileName);
                }
                else
                {
                    filesToProcess = VNC.CodeAnalysis.Workspace.Helper.GetSourceFilesToProcessFromConfigFile(configFileFullPath, branchName, solutionName, projectName);
                }

                foreach (string filePath in filesToProcess)
                {
                    VisioHelper.DisplayInWatchWindow(string.Format("{0}",
                                                                   filePath));
                    //if ((Boolean)ceListImpactedFilesOnly.IsChecked)
                    //{
                    //    sb.AppendLine(string.Format("  {0}", filePath));
                    //}
                    //else
                    //{
                    //    StringBuilder sbFileResults = new StringBuilder();

                    //    var sourceCode = "";

                    //    using (var sr = new StreamReader(filePath))
                    //    {
                    //        sourceCode = sr.ReadToEnd();
                    //    }

                    //    SyntaxTree tree = VisualBasicSyntaxTree.ParseText(sourceCode);

                    //    sbFileResults = command(sbFileResults, matches, tree);

                    //    if ((bool)ceAlwaysDisplayFileName.IsChecked || (sbFileResults.Length > 0))
                    //    {
                    //        sb.AppendLine("Searching " + filePath);
                    //    }

                    //    sb.Append(sbFileResults.ToString());
                    //}
                }

                //var sourceCode = "";

                //using (var sr = new StreamReader(fileNameAndPath))
                //{
                //    sourceCode = sr.ReadToEnd();
                //}

                //List<String> methodNames = VNC.CodeAnalysis.Helpers.VB.GetMethodNames(sourceCode);

                //// OK.  Now we have a list of Method Names.  Let's add shapes for each of them.

                //Visio.Master methodMaster = app.Documents[@"API.vssx"].Masters[@"Roslyn SuperFile"];

                //foreach (string methodName in methodNames)
                //{
                //    Visio.Shape newMethod = activePage.Drop(methodMaster, 5.0, 5.0);
                //    newMethod.CellsU["Prop.MethodName"].FormulaU = methodName.WrapInDblQuotes();
                //}
            }
            catch (Exception ex)
            {
                VisioHelper.DisplayInWatchWindow(string.Format("{0}",
                                                               ex.ToString()));
            }
        }
Exemplo n.º 42
0
        public static PageFormatCells GetCells(IVisio.Shape shape)
        {
            var query = PageFormatCells.lazy_query.Value;

            return(query.GetCellGroup(shape));
        }
Exemplo n.º 43
0
        private static void ConnectWithDynamicGlueAndConnector(string connectorName, Visio.Shape shapeFrom, Visio.Shape shapeTo, bool isFeeder)
        {
            if (!cubeList.Contains(shapeFrom) || !cubeList.Contains(shapeTo))
            {
                return;
            }

            Microsoft.Office.Interop.Visio.Cell  beginXCell;
            Microsoft.Office.Interop.Visio.Cell  endXCell;
            Microsoft.Office.Interop.Visio.Shape connector;

            connectionNames(shapeFrom);

            // Add a Dynamic connector to the page.
            connector = DropMasterOnPage(connectorName, 0.0, 0.0);
            if (isFeeder)
            {
                connector.get_CellsSRC((short)Visio.VisSectionIndices.visSectionObject,
                                       (short)Visio.VisRowIndices.visRowLine,
                                       (short)Visio.VisCellIndices.visLineColor).FormulaU = "THEMEGUARD(RGB(255,0,0))";
            }

            // Connect the begin point.
            beginXCell = connector.get_CellsSRC(
                (short)Visio.VisSectionIndices.visSectionObject,
                (short)Visio.VisRowIndices.visRowXForm1D,
                (short)Visio.VisCellIndices.vis1DBeginX);

            beginXCell.GlueTo(shapeFrom.get_CellsSRC(
                                  (short)Visio.VisSectionIndices.visSectionConnectionPts,
                                  isFeeder ? (short)8 : (short)10,
                                  (short)Visio.VisCellIndices.visCnnctX));

            // Connect the end point.
            endXCell = connector.get_CellsSRC(
                (short)Visio.VisSectionIndices.visSectionObject,
                (short)Visio.VisRowIndices.visRowXForm1D,
                (short)Visio.VisCellIndices.vis1DEndX);

            endXCell.GlueTo(shapeTo.get_CellsSRC(
                                (short)Visio.VisSectionIndices.visSectionConnectionPts,
                                isFeeder ? (short)9 : (short)11,
                                (short)Visio.VisCellIndices.visCnnctX));
        }
Exemplo n.º 44
0
 public static int GetPropertyInt( Shape shape, string section, string property, string attribute)
 {
     return GetPropertyInt(shape, section, property, attribute, measure);
 }
Exemplo n.º 45
0
        public static LockCells GetCells(IVisio.Shape shape, VASS.CellValueType type)
        {
            var reader = LockCells_lazy_builder.Value;

            return(reader.GetCellsSingleRow(shape, type));
        }
Exemplo n.º 46
0
        public static PageCells GetCells(IVisio.Shape shape)
        {
            var query = get_query();

            return(VA.ShapeSheet.CellGroups.CellGroup._GetCells <PageCells, double>(shape, query, query.GetCells));
        }
Exemplo n.º 47
0
        private static List <IVisio.Shape> _create_duplicates(IVisio.Page page,
                                                              IVisio.Shape shape,
                                                              int n)
        {
            // NOTE: n is the total number you want INCLUDING the original shape
            // example n=0 then result={s0}
            // example n=1, result={s0}
            // example n=2, result={s0,s1}
            // example n=3, result={s0,s1,s2}
            // where s0 is the original shape

            if (n < 2)
            {
                return(new List <IVisio.Shape> {
                    shape
                });
            }

            int num_doubles = (int)System.Math.Log(n, 2.0);
            int leftover    = n - ((int)System.Math.Pow(2.0, num_doubles));

            if (leftover < 0)
            {
                throw new System.InvalidOperationException("internal error: leftover value must greater than or equal to zero");
            }

            var duplicated_shapes = new List <IVisio.Shape> {
                shape
            };

            var application = page.Application;
            var win         = application.ActiveWindow;

            foreach (int i in Enumerable.Range(0, num_doubles))
            {
                win.DeselectAll();
                win.Select(duplicated_shapes, IVisio.VisSelectArgs.visSelect);
                var selection = win.Selection;
                selection.Duplicate();
                var selection1 = win.Selection;
                duplicated_shapes.AddRange(selection1.ToEnumerable());
            }

            if (leftover > 0)
            {
                var leftover_shapes = duplicated_shapes.Take(leftover);
                win.DeselectAll();
                win.Select(leftover_shapes, IVisio.VisSelectArgs.visSelect);
                var selection = win.Selection;
                selection.Duplicate();
                var selection1 = win.Selection;
                duplicated_shapes.AddRange(selection1.ToEnumerable());
            }

            win.DeselectAll();
            win.Select(duplicated_shapes, IVisio.VisSelectArgs.visSelect);

            if (duplicated_shapes.Count != n)
            {
                string msg = string.Format("internal error: failed to create {0} shapes, instead created {1}", n,
                                           duplicated_shapes.Count);
                throw new VisioAutomation.Exceptions.VisioOperationException(msg);
            }

            var selection2 = win.Selection;

            if (selection2.Count != n)
            {
                throw new VisioAutomation.Exceptions.VisioOperationException("internal error: failed to select the duplicated shapes");
            }

            return(duplicated_shapes);
        }
Exemplo n.º 48
0
        public static XmlDocument GetPropertiesFromShape(Shape shape)
        {
            string xml =GetProperty(shape, "Prop", "ShapeXml");

            if (xml == null)
                return null;

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xml);
            return xmlDoc;
        }