Ejemplo n.º 1
0
        /// <summary>
        /// Creates a MAP tag HTML source
        /// </summary>
        public string CreateImageMap(string mapName)
        {
            // image map coordinate system starts from 0, 0, so we might have
            // to offset the AREA coordinates to make them match the diagram items
            docOffsetX = flowChart.DocExtents.X;
            docOffsetY = flowChart.DocExtents.Y;

            string html = TAB + "<MAP NAME=\"" + mapName + "\">\r\n";

            // create an AREA tag for each node
            for (int i = flowChart.Objects.Count - 1; i >= 0; i--)
            {
                ChartObject item = flowChart.Objects[i];
                if (!item.Visible)
                {
                    continue;
                }

                Node node = item as Node;
                if (item.HyperLink != "")
                {
                    html += TAB + TAB;
                    string areaTag = "<AREA SHAPE=";

                    if (node != null)
                    {
                        if (node is Box)
                        {
                            Box b = node as Box;
                            switch (b.Style)
                            {
                            case BoxStyle.Rectangle:
                            case BoxStyle.RoundedRectangle:
                                // SHAPE="RECT"
                                areaTag += createRectArea(b.BoundingRect);
                                break;

                            case BoxStyle.Shape:
                            case BoxStyle.Ellipse:
                            case BoxStyle.Delay:
                            case BoxStyle.Rhombus:
                                // SHAPE="POLY"
                                areaTag += createPolyArea(b.getOutlinePoly());
                                break;
                            }
                        }

                        if (node is ControlHost)
                        {
                            // SHAPE="RECT"
                            areaTag = areaTag + createRectArea(node.BoundingRect);
                        }

                        if (node is Table)
                        {
                            Table t = node as Table;

                            // use whole bounding rect if cell AREAs won't be generated
                            RectangleF rect = t.BoundingRect;
                            if (areasForTableCells)
                            {
                                rect.Height = t.CaptionHeight;
                            }

                            areaTag = areaTag + createRectArea(rect);
                        }
                    }
                    else
                    {
                        areaTag += createPolyArea(item.getOutlinePoly());
                    }

                    areaTag += "\r\n";

                    areaTag += TAB + TAB + TAB + "HREF=\"" + item.HyperLink + "\" ";
                    areaTag += "TARGET=\"" + linkTarget + "\" ";
                    areaTag += "TITLE=\"" + item.ToolTip + "\">";

                    if (CreatingArea != null)
                    {
                        AreaEventArgs args = new AreaEventArgs(areaTag, item);
                        CreatingArea(this, args);
                        areaTag = args.AreaTag;
                    }

                    html += areaTag + "\r\n";
                }

                if (node != null)
                {
                    if (areasForTableCells && node is Table)
                    {
                        html += createCellAreas(node as Table);
                    }

                    if (node.Expandable && expandBtnHyperLink != "")
                    {
                        html += createExpBtnArea(node);
                    }
                }
            }

            html += TAB + "</MAP>\r\n";

            return(html);
        }