private IVisio.Shape[] draw_standard_shapes(IVisio.Page page1)
        {
            var s1 = page1.DrawRectangle(0, 0, 1, 1);
            var s2 = page1.DrawRectangle(0, 3, 1, 4);
            var s3 = page1.DrawRectangle(3, 0, 4, 1);

            s1.Text = "A";
            s2.Text = "B";
            s3.Text = "C";
            return(new[] { s1, s2, s3 });
        }
        private static void AddTOCLinkToPage(Visio.Page page)
        {
            int undoScope = Globals.ThisAddIn.Application.BeginUndoScope("AddTOCLinkToPage");

            // Clear out any existing link.

            foreach (Visio.Shape shape in page.Shapes)
            {
                if (shape.Text == "Table of Contents" || shape.Name == "TOCLink")
                {
                    shape.Delete();
                }
            }

            Visio.Shape tocShape = page.DrawRectangle(
                cTOC_Page_Initial_xLoc, cTOC_PageLink_Initial_yLoc,
                cTOC_Page_Initial_xLoc + cTOC_PageLink_Width, cTOC_PageLink_Initial_yLoc + cTOC_PageLink_Height);

            tocShape.Name = "TOCLink";

            tocShape.Text             = "Table of Contents";
            tocShape.TextStyle        = "Normal";
            tocShape.LineStyle        = "Text Only";
            tocShape.FillStyle        = "Text Only";
            tocShape.Characters.Begin = 0;
            tocShape.Characters.End   = 0;
            tocShape.Characters.set_CharProps((short)Visio.VisCellIndices.visCharacterSize, 6);

            Visio.Hyperlink hlink = tocShape.Hyperlinks.Add();
            // hlink.Name = "do we need a name?";
            hlink.SubAddress = "Table of Contents";

            Globals.ThisAddIn.Application.EndUndoScope(undoScope, true);
        }
Exemplo n.º 3
0
        public static void DrawNode(
            BoxL.Node node,
            VA.Drawing.Rectangle rect, IVisio.Page page)
        {
            var shape = page.DrawRectangle(rect);

            node.Data = shape;
        }
Exemplo n.º 4
0
        public static void DrawNode(
            Node node,
            VA.Geometry.Rectangle rect, IVisio.Page page)
        {
            var shape = page.DrawRectangle(rect);

            node.Data = shape;
        }
Exemplo n.º 5
0
        private IVisio.Shape DesenharForma(IVisio.Page page, StatusSinistro sinistro)
        {
            var shape = page.DrawRectangle(1, 1, 3, 2);

            shape.Text  = string.IsNullOrEmpty(sinistro.NomeStatusSeguinte) ? "Não achei" : sinistro.NomeStatusSeguinte;
            shape.Data1 = sinistro.CodigoStatusAtual;
            shape.Data2 = sinistro.CodigoStatusSeguinte;
            shape.Data3 = sinistro.CodigoTransacao;

            return(shape);
        }
        /// <summary>
        /// Draw an "Entity" Rectangle
        /// </summary>
        /// <param name="page">The Page on which to draw</param>
        /// <param name="entityName">The name of the entity</param>
        /// <param name="ownership">The ownership type of the entity</param>
        /// <returns>The newly drawn rectangle</returns>
        private VisioApi.Shape DrawEntityRectangle(VisioApi.Page page, string entityName, OwnershipTypes ownership)
        {
            VisioApi.Shape rect = page.DrawRectangle(X_POS1, Y_POS1, X_POS2, Y_POS2);
            rect.Name = entityName;
            rect.Text = entityName + " ";

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

            // Update the style of the entity name
            VisioApi.Characters characters = rect.Characters;
            characters.Begin = 0;
            characters.End   = entityName.Length;
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterStyle, (short)VisioApi.VisCellVals.visBold);
            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);
            }

            switch (ownership)
            {
            case OwnershipTypes.BusinessOwned:
                fillColor = "RGB(255,140,0)";                                                                                          // orange
                characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visBlack); // set the font color of the text
                break;

            case OwnershipTypes.OrganizationOwned:
                fillColor = "RGB(127, 186, 0)";                                                                                        // green
                characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visBlack); // set the font color of the text
                break;

            case OwnershipTypes.UserOwned:
                fillColor = "RGB(0,24,143)";                                                                                           // blue
                characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visWhite); // set the font color of the text
                break;

            default:
                fillColor = "RGB(255,255,255)";                                                                                           // White
                characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visDarkBlue); // set the font color of the text
                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).FormulaU     = ((int)VisioApi.VisCellVals.visLOFlagsPlacable).ToString();
            rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowFill, (short)VisioApi.VisCellIndices.visFillForegnd).FormulaU = fillColor;
            return(rect);
        }
Exemplo n.º 7
0
        private static void AddTOCLinkToPage(Visio.Page page)
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           System.Reflection.MethodBase.GetCurrentMethod().Name));

            if (page.Background != 0)
            {
                // Skip background pages
                return;
            }

            int undoScope = Globals.ThisAddIn.Application.BeginUndoScope("AddTOCLinkToPage");

            // Clear out any existing link.

            foreach (Visio.Shape shape in page.Shapes)
            {
                if (shape.Text == "Table of Contents" || shape.Name == "TOCLink")
                {
                    shape.Delete();
                }
            }

            Visio.Shape tocShape = page.DrawRectangle(
                cTOC_Page_Initial_xLoc, cTOC_PageLink_Initial_yLoc,
                cTOC_Page_Initial_xLoc + cTOC_PageLink_Width, cTOC_PageLink_Initial_yLoc + cTOC_PageLink_Height);

            tocShape.Name = "TOCLink";

            tocShape.Text             = "Table of Contents";
            tocShape.TextStyle        = "Normal";
            tocShape.LineStyle        = "Text Only";
            tocShape.FillStyle        = "Text Only";
            tocShape.Characters.Begin = 0;
            tocShape.Characters.End   = 0;
            tocShape.Characters.set_CharProps((short)Visio.VisCellIndices.visCharacterSize, 6);

            Visio.Hyperlink hlink = tocShape.Hyperlinks.Add();
            // hlink.Name = "do we need a name?";
            hlink.SubAddress = "Table of Contents";

            Globals.ThisAddIn.Application.EndUndoScope(undoScope, true);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Draw an "Entity" Rectangle
        /// </summary>
        /// <param name="page">The Page on which to draw</param>
        /// <param name="entityName">The name of the entity</param>
        /// <param name="ownership">The ownership type of the entity</param>
        /// <returns>The newly drawn rectangle</returns>
        private VisioApi.Shape DrawEntityRectangle(VisioApi.Page page, string entityName, string displayName, OwnershipTypes ownership)
        {
            VisioApi.Shape rect = page.DrawRectangle(X_POS1, Y_POS1, X_POS2, Y_POS2);
            rect.Name = entityName;
            rect.Text = displayName + " ";

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

            switch (ownership)
            {
            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).FormulaU     = ((int)VisioApi.VisCellVals.visLOFlagsPlacable).ToString();
            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   = displayName.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);

            return(rect);
        }
        private static void AddPageLinkToTOCPage(Visio.Page pageTOC, Visio.Page page, double xLoc, double yLoc)
        {
            int undoScope = Globals.ThisAddIn.Application.BeginUndoScope("AddPageLinkToTOCPage");

            Visio.Shape pageLinkShape = pageTOC.DrawRectangle(xLoc, yLoc, xLoc + cTOC_Link_Width, yLoc + cTOC_Link_Height);

            pageLinkShape.TextStyle        = "Normal";
            pageLinkShape.LineStyle        = "Text Only";
            pageLinkShape.FillStyle        = "Text Only";
            pageLinkShape.Characters.Begin = 0;
            pageLinkShape.Characters.End   = 0;
            pageLinkShape.Text             = page.Name;
            pageLinkShape.Characters.set_CharProps((short)Visio.VisCellIndices.visCharacterSize, cTOC_Link_FontSize);

            Visio.Hyperlink hlink = pageLinkShape.Hyperlinks.Add();
            // hlink.Name = "do we need a name?";
            hlink.SubAddress = page.Name;

            Globals.ThisAddIn.Application.EndUndoScope(undoScope, true);
        }
Exemplo n.º 10
0
        private static void AddPageLinkToTOCPage(Visio.Page pageTOC, Visio.Page page, double xLoc, double yLoc)
        {
            VisioHelper.DisplayInWatchWindow(string.Format("{0}()",
                                                           System.Reflection.MethodBase.GetCurrentMethod().Name));

            int undoScope = Globals.ThisAddIn.Application.BeginUndoScope("AddPageLinkToTOCPage");

            Visio.Shape pageLinkShape = pageTOC.DrawRectangle(xLoc, yLoc, xLoc + cTOC_Link_Width, yLoc + cTOC_Link_Height);

            pageLinkShape.TextStyle        = "Normal";
            pageLinkShape.LineStyle        = "Text Only";
            pageLinkShape.FillStyle        = "Text Only";
            pageLinkShape.Characters.Begin = 0;
            pageLinkShape.Characters.End   = 0;
            pageLinkShape.Text             = page.NameU;
            pageLinkShape.Characters.set_CharProps((short)Visio.VisCellIndices.visCharacterSize, cTOC_Link_FontSize);

            Visio_Shape.AddHyperLink(pageLinkShape, page.NameU);

            Globals.ThisAddIn.Application.EndUndoScope(undoScope, true);
        }
Exemplo n.º 11
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.º 12
0
        /// <summary>
        /// Creates and outputs a State Transition Table from the given State Machine.
        /// </summary>
        /// <param name="stateMachine">State Machine to convert to Transition Table.</param>
        /// <param name="outputPage">Page to display the Table.</param>
        private void outputStateTransitionTable(List <State> stateMachine, Visio.Page outputPage)
        {
            // drawing the table by drawing rectangles right next to each other
            // and grouping them into a table.

            // sets the drawing position to start at the left of the page
            setShapeDropPosition(outputPage);
            drawXPos = 1.0;
            double leftDrawEdge = drawXPos;

            double rectHeight = 0.5;
            double rectWidth  = 1.5;

            // treat start state, end state (& states that are essentially end states:
            // they don't transition to another state) differently
            // Start the table with the start state & end state shouldn't be listed
            // as a starting state in the table.
            // Removes these states from the state machine to work on them separately.
            State        startState = null;
            List <State> endStates  = new List <State>();

            for (int i = stateMachine.Count - 1; i >= 0; --i)
            {
                State  state = stateMachine[i];
                string type  = state.Type;
                if (type == State.START_STATE)
                {
                    startState = state;
                    stateMachine.RemoveAt(i);
                }
                else if (type == State.END_STATE || state.getNextStateCount() == 0)
                {
                    endStates.Add(state);
                    stateMachine.RemoveAt(i);
                }
            }

            // insert start state back into the beginning of the state machine, so
            // it gets processed first.
            if (startState != null)
            {
                stateMachine.Insert(0, startState);
            }

            // Table header
            double newXPos = drawXPos + rectWidth;
            double newYPos = drawYPos - rectHeight;

            Visio.Shape rect = outputPage.DrawRectangle(drawXPos, drawYPos, newXPos, newYPos);
            rect.Text = "State";

            drawXPos  = newXPos + rectWidth;
            rect      = outputPage.DrawRectangle(newXPos, drawYPos, drawXPos, newYPos);
            rect.Text = "Event";

            newXPos   = drawXPos + rectWidth;
            rect      = outputPage.DrawRectangle(drawXPos, drawYPos, newXPos, newYPos);
            rect.Text = "Operation";

            drawXPos  = newXPos + rectWidth;
            rect      = outputPage.DrawRectangle(newXPos, drawYPos, drawXPos, newYPos);
            rect.Text = "Next State";

            // Adjust the height of each start state rect depending on number of next states
            drawXPos = leftDrawEdge;
            drawYPos = newYPos;
            double eventXPos = drawXPos + rectWidth; // X coordinate of start of event column.
            double eventYPos = drawYPos;             // Y coordinate of start of event column.

            foreach (State s in stateMachine)
            {
                int numNextState = s.getNextStateCount();
                // draw State column
                newXPos   = drawXPos + rectWidth;
                newYPos   = drawYPos - (rectHeight * numNextState);
                rect      = outputPage.DrawRectangle(drawXPos, drawYPos, newXPos, newYPos);
                rect.Text = s.Name;

                // draw transition columns
                List <State.Transition> transitions = s.getTransitions();
                foreach (State.Transition t in transitions)
                {
                    // event column
                    drawXPos  = eventXPos;
                    newXPos   = drawXPos + rectWidth;
                    newYPos   = drawYPos - rectHeight;
                    rect      = outputPage.DrawRectangle(drawXPos, drawYPos, newXPos, newYPos);
                    rect.Text = t.Data;

                    // operation column
                    drawXPos  = newXPos;
                    newXPos   = drawXPos + rectWidth;
                    rect      = outputPage.DrawRectangle(drawXPos, drawYPos, newXPos, newYPos);
                    rect.Text = t.Operation;

                    // next state column
                    drawXPos  = newXPos;
                    newXPos   = drawXPos + rectWidth;
                    rect      = outputPage.DrawRectangle(drawXPos, drawYPos, newXPos, newYPos);
                    rect.Text = t.NextState.Name;

                    // if there are multiple transitions, move one row down for next transition
                    drawYPos = newYPos;
                }

                // reset the drawing position for the next state
                drawXPos = leftDrawEdge;
                drawYPos = newYPos;
            }
        }
Exemplo n.º 13
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.º 14
0
        public void Render(IVisio.Page page)
        {
            this.TotalMarginWidth     = this.Rectangle.Width * (0.10);
            this.TotalBarSpacingWidth = this.Rectangle.Width * (0.10);
            this.TotalBarWidth        = this.Rectangle.Width * (0.80);

            int num_points = this.DataPoints.Count;

            double bar_spacing = num_points > 1 ? this.TotalBarSpacingWidth / num_points : 0.0;
            double bar_width   = num_points > 0 ? this.TotalBarWidth / num_points : this.TotalBarWidth;

            double cur_x = this.Rectangle.Left + (this.TotalMarginWidth / 2.0);

            double max   = this.DataPoints.Select(i => i.Value).Max();
            double min   = this.DataPoints.Select(i => i.Value).Min();
            var    range = ChartUtil.GetValueRangeDistance(min, max);

            double base_y = this.Rectangle.Bottom;

            if (min < 0.0)
            {
                base_y += System.Math.Abs(this.Rectangle.Height * (min / range));
            }

            var category_axis_start_point = new Geometry.Point(this.Rectangle.Left, base_y);
            var category_axis_end_point   = new Geometry.Point(this.Rectangle.Right, base_y);
            var category_axis_shape       = page.DrawLine(category_axis_start_point, category_axis_end_point);

            foreach (var p in this.DataPoints)
            {
                var value_height = System.Math.Abs(this.Rectangle.Height * (p.Value / range));

                Geometry.Point bar_p0;
                Geometry.Point bar_p1;

                if (p.Value >= 0.0)
                {
                    bar_p0 = new Geometry.Point(cur_x, base_y);
                    bar_p1 = new Geometry.Point(cur_x + bar_width, base_y + value_height);
                }
                else
                {
                    bar_p0 = new Geometry.Point(cur_x, base_y - value_height);
                    bar_p1 = new Geometry.Point(cur_x + bar_width, base_y);
                }

                var bar_rect = new Geometry.Rectangle(bar_p0, bar_p1);
                var shape    = page.DrawRectangle(bar_rect);
                p.VisioShape = shape;

                if (p.Label != null)
                {
                    shape.Text = p.Label;
                }

                cur_x += bar_width + bar_spacing;
            }

            var allshapes = this.DataPoints.Select(dp => dp.VisioShape).Where(s => s != null).ToList();

            allshapes.Add(category_axis_shape);

            ChartUtil.GroupShapesIfNeeded(page, allshapes);
        }
Exemplo n.º 15
0
        /// <summary>
        /// This method is drawing core connections diagram header
        /// </summary>
        /// <param name="aPage">page on which header should be placed</param>
        /// <returns>vertical position after drawing</returns>
        private double DrawDiagramHeader(Visio.Page aPage)
        {
            Visio.Shape _newShape = aPage.DrawRectangle(mInitialPosX, mInitialPosY, mInitialPosX + mSingleWidth * 3, mInitialPosY - mSingleHeight);
            SetTextProperties(_newShape, "TITLE", FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _newShape = aPage.DrawRectangle(mInitialPosX + mSingleWidth * 3, mInitialPosY, mInitialPosX + mSingleWidth * 4, mInitialPosY - mSingleHeight);
            SetTextProperties(_newShape, "DRWN BY/DATE", FONT_SIZE, (int)Visio.VisCellVals.visHorzLeft);

            _newShape = aPage.DrawRectangle(mInitialPosX + mSingleWidth * 4, mInitialPosY, mInitialPosX + mSingleWidth * 5, mInitialPosY - mSingleHeight);
            SetTextProperties(_newShape, string.Empty, FONT_SIZE, (int)Visio.VisCellVals.visHorzLeft);

            _newShape = aPage.DrawRectangle(mInitialPosX + mSingleWidth * 5, mInitialPosY, mInitialPosX + mSingleWidth * 7 + mMargin, mInitialPosY - mSingleHeight);
            SetTextProperties(_newShape, "SHEET OF", FONT_SIZE, (int)Visio.VisCellVals.visHorzLeft);

            _newShape = aPage.DrawRectangle(mInitialPosX, mInitialPosY - mSingleHeight, mInitialPosX + mSingleWidth * 3, mInitialPosY - mSingleHeight * 3);
            SetTextProperties(_newShape, string.Empty, FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _newShape = aPage.DrawRectangle(mInitialPosX + mSingleWidth * 3, mInitialPosY - mSingleHeight, mInitialPosX + mSingleWidth * 4, mInitialPosY - mSingleHeight * 2);
            SetTextProperties(_newShape, "CHKD BY/DATE", FONT_SIZE, (int)Visio.VisCellVals.visHorzLeft);

            _newShape = aPage.DrawRectangle(mInitialPosX + mSingleWidth * 4, mInitialPosY - mSingleHeight, mInitialPosX + mSingleWidth * 5, mInitialPosY - mSingleHeight * 2);
            SetTextProperties(_newShape, string.Empty, FONT_SIZE, (int)Visio.VisCellVals.visHorzLeft);

            _newShape = aPage.DrawRectangle(mInitialPosX + mSingleWidth * 5, mInitialPosY - mSingleHeight, mInitialPosX + mSingleWidth * 7 + mMargin, mInitialPosY - mSingleHeight * 2);
            SetTextProperties(_newShape, "SHIP NO:", FONT_SIZE, (int)Visio.VisCellVals.visHorzLeft);

            _newShape = aPage.DrawRectangle(mInitialPosX + mSingleWidth * 3, mInitialPosY - mSingleHeight * 2, mInitialPosX + mSingleWidth * 4, mInitialPosY - mSingleHeight * 3);
            SetTextProperties(_newShape, "APPR BY/DATE", FONT_SIZE, (int)Visio.VisCellVals.visHorzLeft);

            _newShape = aPage.DrawRectangle(mInitialPosX + mSingleWidth * 4, mInitialPosY - mSingleHeight * 2, mInitialPosX + mSingleWidth * 5, mInitialPosY - mSingleHeight * 3);
            SetTextProperties(_newShape, string.Empty, FONT_SIZE, (int)Visio.VisCellVals.visHorzLeft);

            _newShape = aPage.DrawRectangle(mInitialPosX + mSingleWidth * 5, mInitialPosY - mSingleHeight * 2, mInitialPosX + mSingleWidth * 6 + mMargin / 2.0, mInitialPosY - mSingleHeight * 3);
            SetTextProperties(_newShape, "DRG NO:", FONT_SIZE, (int)Visio.VisCellVals.visHorzLeft);

            _newShape = aPage.DrawRectangle(mInitialPosX + mSingleWidth * 6 + mMargin / 2.0, mInitialPosY - mSingleHeight * 2, mInitialPosX + mSingleWidth * 7 + mMargin, mInitialPosY - mSingleHeight * 3);
            SetTextProperties(_newShape, "REV NO:", FONT_SIZE, (int)Visio.VisCellVals.visHorzLeft);

            return(mInitialPosY - mSingleHeight * 3);
        }
Exemplo n.º 16
0
        /// <summary>
        /// This method is drawing header of core connections table
        /// </summary>
        /// <param name="aPage">page to drawn on</param>
        /// <param name="aStartPosY">position in vertical in which table header should start</param>
        /// <returns>vertical position after drawing</returns>
        private double DrawTableHeader(Visio.Page aPage, double aStartPosY)
        {
            double _currentX = mMargin;
            double _nextX    = mMargin + mEquiWidth;

            Visio.Shape _newShape = aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth);
            SetTextProperties(_newShape, "Equipment Name", FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _currentX = _nextX;
            _nextX    = _currentX + mElconnWidth;

            _newShape = aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth);
            SetTextProperties(_newShape, "Conn", FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _currentX = _nextX;
            _nextX    = _currentX + mCoreWidth;

            _newShape = aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth);
            SetTextProperties(_newShape, "Terminator", FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _currentX = _nextX;
            _nextX    = _currentX + mSpaceBetween;

            aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth);

            _currentX = _nextX;
            _nextX    = _currentX + mCoreWidth;

            _newShape = aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth);
            SetTextProperties(_newShape, "Core", FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _currentX = _nextX;
            _nextX    = _currentX + mSpaceBetween;

            aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth);

            _currentX = _nextX;
            _nextX    = _currentX + mCableWidth;

            _newShape = aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth / 2.0);
            SetTextProperties(_newShape, "Cable Name", FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _newShape = aPage.DrawRectangle(_currentX, aStartPosY - mTableHeaderCellWidth / 2.0, _nextX, aStartPosY - mTableHeaderCellWidth);
            SetTextProperties(_newShape, "Cable Component", FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _currentX = _nextX;
            _nextX    = _currentX + mSpaceBetween;

            aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth);

            _currentX = _nextX;
            _nextX    = _currentX + mCoreWidth;

            _newShape = aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth);
            SetTextProperties(_newShape, "Core", FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _currentX = _nextX;
            _nextX    = _currentX + mSpaceBetween;

            aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth);

            _currentX = _nextX;
            _nextX    = _currentX + mCoreWidth;

            _newShape = aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth);
            SetTextProperties(_newShape, "Terminator", FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _currentX = _nextX;
            _nextX    = _currentX + mElconnWidth;

            _newShape = aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth);
            SetTextProperties(_newShape, "Conn", FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _currentX = _nextX;
            _nextX    = _currentX + mEquiWidth;

            _newShape = aPage.DrawRectangle(_currentX, aStartPosY, _nextX, aStartPosY - mTableHeaderCellWidth);
            SetTextProperties(_newShape, "Equipment Name", FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            return(aStartPosY - mTableHeaderCellWidth);
        }
Exemplo n.º 17
0
        /// <summary>
        /// This method is drawing schema for single cable
        /// </summary>
        /// <param name="aPage">page to draw on</param>
        /// <param name="aCableInfo">information about cable to draw</param>
        /// <param name="aPosY">vertical position in which schema should start</param>
        /// <returns>ertical position after drawing</returns>
        private double DrawCable(Visio.Page aPage, CableInfo aCableInfo, double aPosY)
        {
            if (aCableInfo.CoreNo == 0)
            {
                aCableInfo.CoreInfo.Add(new CoreInfo(Database.DbElement.GetElement(), aCableInfo));
            }

            double _cableHeight = aCableInfo.CoreNo * mCoreHeight;

            Visio.Shape _newShape = aPage.DrawLine(mCablePosX, aPosY - _cableHeight / 2.0, mCablePosX + mCableWidth, aPosY - _cableHeight / 2.0);
            SetTextProperties(_newShape, aCableInfo.CableName + Environment.NewLine + aCableInfo.ComponentName, FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter);

            _newShape = aPage.DrawLine(mCablePosX, aPosY, mCablePosX, aPosY - _cableHeight);
            _newShape = aPage.DrawLine(mCablePosX + mCableWidth, aPosY, mCablePosX + mCableWidth, aPosY - _cableHeight);

            int    _lastBeginEqui = 0, _lastEndEqui = 0, _lastBeginElconn = 0, _lastEndElconn = 0, _current = 0;
            string _lastBeginEquiName = string.Empty, _lastEndEquiName = string.Empty, _lastBeginElconnName = string.Empty, _lastEndElconnName = string.Empty;

            foreach (CoreInfo _core in aCableInfo.CoreInfo)
            {
                //draw core boxes
                _newShape = aPage.DrawRectangle(mCablePosX - mCoreWidth - mSpaceBetween, aPosY - _current * mCoreHeight, mCablePosX - mSpaceBetween, aPosY - (_current + 1) * mCoreHeight);
                SetTextProperties(_newShape, _core.CoreName, "6pt", (int)Visio.VisCellVals.visHorzCenter);
                _newShape = aPage.DrawRectangle(mCablePosX + mCableWidth + mSpaceBetween, aPosY - _current * mCoreHeight, mCablePosX + mCableWidth + mSpaceBetween + mCoreWidth, aPosY - (_current + 1) * mCoreHeight);
                SetTextProperties(_newShape, _core.CoreName, "6pt", (int)Visio.VisCellVals.visHorzCenter);

                //draw pin boxes
                _newShape = aPage.DrawRectangle(mCablePosX - (mCoreWidth + mSpaceBetween) * 2, aPosY - _current * mCoreHeight, mCablePosX - mCoreWidth - mSpaceBetween * 2, aPosY - (_current + 1) * mCoreHeight);
                SetTextProperties(_newShape, _core.StartPin, "6pt", (int)Visio.VisCellVals.visHorzCenter);
                _newShape = aPage.DrawRectangle(mCablePosX + mCableWidth + mSpaceBetween * 2 + mCoreWidth, aPosY - _current * mCoreHeight, mCablePosX + mCableWidth + (mSpaceBetween + mCoreWidth) * 2, aPosY - (_current + 1) * mCoreHeight);
                SetTextProperties(_newShape, _core.EndPin, "6pt", (int)Visio.VisCellVals.visHorzCenter);

                //check/draw elconns
                if (_core.StartElconn == string.Empty || _lastBeginElconnName != _core.StartElconn)
                {
                    if (_current > 0)
                    {
                        double _posX = mCablePosX - (mSpaceBetween + mCoreWidth) * 2;
                        double _posY = aPosY - _lastBeginElconn * mCoreHeight;
                        //draw elconn
                        _newShape = aPage.DrawRectangle(_posX - mElconnWidth, _posY, _posX, _posY - (_current - _lastBeginElconn) * mCoreHeight);
                        SetTextProperties(_newShape, _lastBeginElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter);
                        _lastBeginElconn = _current;
                    }
                    _lastBeginElconnName = _core.StartElconn;
                }
                if (_core.EndElconn == string.Empty || _lastEndElconnName != _core.EndElconn)
                {
                    if (_current > 0)
                    {
                        //draw elconn
                        double _posX = mCablePosX + (mSpaceBetween + mCoreWidth) * 2 + mCableWidth;
                        double _posY = aPosY - _lastEndElconn * mCoreHeight;
                        //draw elconn
                        _newShape = aPage.DrawRectangle(_posX, _posY, _posX + mElconnWidth, _posY - (_current - _lastEndElconn) * mCoreHeight);
                        SetTextProperties(_newShape, _lastEndElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter);
                        _lastEndElconn = _current;
                    }
                    _lastEndElconnName = _core.EndElconn;
                }

                //check/draw equips
                if (_core.StartEqui == string.Empty || _lastBeginEquiName != _core.StartEqui)
                {
                    if (_current > 0)
                    {
                        //draw equi
                        double _posX = mCablePosX - (mSpaceBetween + mCoreWidth) * 2 - mElconnWidth;
                        double _posY = aPosY - _lastBeginEqui * mCoreHeight;

                        _newShape = aPage.DrawRectangle(_posX - mEquiWidth, _posY, _posX, _posY - (_current - _lastBeginEqui) * mCoreHeight);
                        SetTextProperties(_newShape, _lastBeginEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter);
                        _lastBeginEqui = _current;
                    }
                    _lastBeginEquiName = _core.StartEqui;
                }
                if (_core.EndEqui == string.Empty || _lastEndEquiName != _core.EndEqui)
                {
                    if (_current > 0)
                    {
                        //draw equi
                        double _posX = mCablePosX + (mSpaceBetween + mCoreWidth) * 2 + mCableWidth + mElconnWidth;
                        double _posY = aPosY - _lastEndEqui * mCoreHeight;

                        _newShape = aPage.DrawRectangle(_posX, _posY, _posX + mEquiWidth, _posY - (_current - _lastEndEqui) * mCoreHeight);
                        SetTextProperties(_newShape, _lastEndEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter);
                        _lastEndEqui = _current;
                    }
                    _lastEndEquiName = _core.EndEqui;
                }
                _current++;
            }
            //draw last elconns
            double _pX = mCablePosX - (mSpaceBetween + mCoreWidth) * 2;
            double _pY = aPosY - _lastBeginElconn * mCoreHeight;

            _newShape = aPage.DrawRectangle(_pX - mElconnWidth, _pY, _pX, _pY - (_current - _lastBeginElconn) * mCoreHeight);
            SetTextProperties(_newShape, _lastBeginElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter);

            _pX = mCablePosX + (mSpaceBetween + mCoreWidth) * 2 + mCableWidth;
            _pY = aPosY - _lastEndElconn * mCoreHeight;

            _newShape = aPage.DrawRectangle(_pX, _pY, _pX + mElconnWidth, _pY - (_current - _lastEndElconn) * mCoreHeight);
            SetTextProperties(_newShape, _lastEndElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter);

            //draw last equips
            _pX = mCablePosX - (mSpaceBetween + mCoreWidth) * 2 - mElconnWidth;
            _pY = aPosY - _lastBeginEqui * mCoreHeight;

            _newShape = aPage.DrawRectangle(_pX - mEquiWidth, _pY, _pX, _pY - (_current - _lastBeginEqui) * mCoreHeight);
            SetTextProperties(_newShape, _lastBeginEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter);

            _pX = mCablePosX + (mSpaceBetween + mCoreWidth) * 2 + mCableWidth + mElconnWidth;
            _pY = aPosY - _lastEndEqui * mCoreHeight;

            _newShape = aPage.DrawRectangle(_pX, _pY, _pX + mEquiWidth, _pY - (_current - _lastEndEqui) * mCoreHeight);
            SetTextProperties(_newShape, _lastEndEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter);

            return(aPosY - _cableHeight);
        }