Exemple #1
0
        /// <summary>
        /// Converts Flowchart.NET box into SVG
        /// </summary>
        /// <param name="newArrow">Box reference</param>
        /// <returns>TRUE if successfull otherwise FALSE</returns>
        private bool CreateBox(MindFusion.FlowChartX.Box newBox)
        {
            bool  bOk = false;
            float fX = 0, fY = 0, fW = 0, fH = 0, fLine = 0;
            long  lLine = 0;

            XmlNode last_node = null;

            try
            {
                if (newBox == null)
                {
                    throw new Exception("Empty box reference passed");
                }

                if ((!newBox.Visible) && (!InvisibleItems))
                {
                    return(true);
                }

                if ((newBox.Transparent) && (newBox.Image == null))
                {
                    sMan.AddText(newBox);
                    return(true);
                }


                fX    = newBox.BoundingRect.X;
                fY    = newBox.BoundingRect.Y;
                fW    = newBox.BoundingRect.Width;
                fH    = newBox.BoundingRect.Height;
                fLine = newBox.Pen.Width;

                if ((newBox.ShapeOrientation == 90) || (newBox.ShapeOrientation == 270))
                {
                    float lTemp = fW;
                    fW = fH;
                    fH = lTemp;
                }

                lLine = Unit2Pix(fLine);
                if (lLine == 0)
                {
                    lLine = 1;
                }

                //Color boxFillColor = newBox.Locked ? Color.Transparent : newBox.FillColor;
                Color boxFillColor = newBox.FillColor;


                switch (GetBoxStyle(newBox))
                {
                case BoxStyle.Rhombus:
                    last_node = sMan.AddPath(sMan.Shape2Path(newBox),
                                             String.Format("{0}px", lLine),
                                             newBox.Pen.Color,
                                             boxFillColor);
                    break;

                case BoxStyle.Ellipse:


                    last_node = sMan.AddEllipse(String.Format("{0}px", Unit2Pix(fX + fW / 2)),
                                                String.Format("{0}px", Unit2Pix(fY + fH / 2)),
                                                String.Format("{0}px", Unit2Pix(fW / 2)),
                                                String.Format("{0}px", Unit2Pix(fH / 2)), String.Format("{0}px", lLine),
                                                boxFillColor,
                                                newBox.Pen.Color);


                    break;

                case BoxStyle.Rectangle:
                    last_node = sMan.AddRect(String.Format("{0}px", Unit2Pix(fX)),
                                             String.Format("{0}px", Unit2Pix(fY)),
                                             String.Format("{0}px", Unit2Pix(fW)),
                                             String.Format("{0}px", Unit2Pix(fH)),
                                             String.Format("{0}px", lLine),
                                             boxFillColor,
                                             newBox.Pen.Color,
                                             null,
                                             null,
                                             newBox.Image,
                                             newBox.Transparent ? pChart.BackColor : Color.Empty);

                    break;

                case BoxStyle.RoundedRectangle:

                    last_node = sMan.AddRect(String.Format("{0}px", Unit2Pix(fX)),
                                             String.Format("{0}px", Unit2Pix(fY)),
                                             String.Format("{0}px", Unit2Pix(fW)),
                                             String.Format("{0}px", Unit2Pix(fH)),
                                             String.Format("{0}px", lLine),
                                             boxFillColor,
                                             newBox.Pen.Color,
                                             "10px",
                                             "10px",
                                             newBox.Image,
                                             newBox.Transparent ? pChart.BackColor : Color.Empty);
                    break;

                case BoxStyle.Shape:
                case BoxStyle.Delay:
                default:

                    last_node = sMan.AddPath(sMan.Shape2Path(newBox),
                                             String.Format("{0}px", lLine),
                                             newBox.Pen.Color,
                                             boxFillColor);

                    break;
                }

                sMan.AddGradient(last_node, newBox.Brush);
                sMan.AddRotation(last_node, newBox);
                sMan.AddText(newBox);
                bOk = true;
            }

            catch (Exception ex)
            {
                Trace.WriteLine(String.Format("{0} error {1}\n", "CreateBox", ex.Message));
                bOk = false;
            }

            return(bOk);
        }