Exemple #1
0
        /// <summary>
        /// Converts Flowchart.NET arrow into SVG
        /// </summary>
        /// <param name="newArrow">Arrow reference</param>
        /// <returns>TRUE if successfull otherwise FALSE</returns>
        private bool CreateArrow(MindFusion.FlowChartX.Arrow newArrow)
        {
            bool   bOk = false;
            string sPath = "", sPathPart = "";
            int    iCount = 0;


            try
            {
                if (newArrow.Origin != null)
                {
                    if ((!newArrow.Origin.Visible) && (!InvisibleItems))
                    {
                        return(true);
                    }
                }

                if (newArrow.Destination != null)
                {
                    if ((!newArrow.Destination.Visible) && (!InvisibleItems))
                    {
                        return(true);
                    }
                }

                if (newArrow.Style == ArrowStyle.Bezier)
                {
                    sPath = String.Format("M{0},{1} C{2},{3} {4},{5} {6},{7} ",
                                          Unit2Pix(newArrow.ControlPoints[0].X),
                                          Unit2Pix(newArrow.ControlPoints[0].Y),
                                          Unit2Pix(newArrow.ControlPoints[1].X),
                                          Unit2Pix(newArrow.ControlPoints[1].Y),
                                          Unit2Pix(newArrow.ControlPoints[newArrow.ControlPoints.Count - 2].X),
                                          Unit2Pix(newArrow.ControlPoints[newArrow.ControlPoints.Count - 2].Y),
                                          Unit2Pix(newArrow.ControlPoints[newArrow.ControlPoints.Count - 1].X),
                                          Unit2Pix(newArrow.ControlPoints[newArrow.ControlPoints.Count - 1].Y));
                }
                else
                {
                    sPath = String.Format("M{0},{1} ", Unit2Pix(newArrow.ControlPoints[0].X), Unit2Pix(newArrow.ControlPoints[0].Y));

                    for (iCount = 1; iCount < newArrow.ControlPoints.Count; iCount++)
                    {
                        sPathPart = String.Format("L{0},{1} ", Unit2Pix(newArrow.ControlPoints[iCount].X), Unit2Pix(newArrow.ControlPoints[iCount].Y));
                        sPath    += sPathPart;
                    }
                }
                if (sPath == "")
                {
                    return(false);
                }

                sPath = sPath.TrimEnd();
                string sWidth = "1px";
                if (newArrow.Pen.Width != 0)
                {
                    String.Format("{0}px", Unit2Pix(newArrow.Pen.Width));
                }

                sMan.AddPath(sPath, sWidth, newArrow.PenColor, Color.Transparent);


                sPath = "";
                sPath = sMan.GetArrowHead(newArrow.HeadShape);
                XmlNode last_node = sMan.AddPath(sPath, sWidth, newArrow.PenColor, newArrow.PenColor);

                sPath     = "";
                sPath     = sMan.GetArrowHead(newArrow.BaseShape);
                last_node = sMan.AddPath(sPath, sWidth, newArrow.PenColor, newArrow.PenColor);

                RectangleF rect  = RectangleF.Empty;
                float      angle = 0;

                rect = getTextRect(System.Drawing.Graphics.FromHwnd(SvgManager.GetActiveWindow()), newArrow.Style, newArrow.TextStyle,
                                   newArrow.ControlPoints, newArrow.TextColor, newArrow.SegmentCount, newArrow.Text, newArrow.Font,
                                   RectangleF.Empty, ref angle);

                if (!rect.Equals(RectangleF.Empty))
                {
                    StringFormat sf = new StringFormat();
                    sf.Alignment = StringAlignment.Center;

                    XmlNode text_added = sMan.AddText(null, newArrow.Text,
                                                      newArrow.Font,
                                                      rect,
                                                      newArrow.TextColor, sf, false, angle);
                }
                bOk = true;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(String.Format("{0} error {1}\n", "CreateArrow", ex.Message));
                bOk = false;
            }

            return(bOk);
        }