Esempio n. 1
0
    public void DoOnClickDeleteSaveGameBtn()
    {
        SvgManager.DeleteSavegameDEBUG();

        //reset toogles AND savegame with all upgrades at their default values
        for (int i = 0; i < upgradeToggles.Length; i++)
        {
            string upgName = upgradeToggles[i].GetComponentInChildren <Text>().text;
            upgradeToggles[i].isOn = DefaultUpgradeValues[i];
        }
    }
Esempio n. 2
0
 /// <summary>
 /// Converts measure in GraphicsUnit into PIXELS
 /// </summary>
 /// <param name="dValue">Value in GraphicsUnit</param>
 /// <param name="iUnit">GraphicsUnit</param>
 /// <returns>Returns value in PIXELS</returns>
 private long Unit2Pix(double dValue, GraphicsUnit iUnit)
 {
     return(SvgManager.Unit2Pix(dValue, iUnit, pChart.MeasureUnit, PixPerInch));
 }
Esempio n. 3
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);
        }
Esempio n. 4
0
        /// <summary>
        /// Main method to export Flowchart.NET into SVG
        /// </summary>
        /// <param name="flowChart">Flowchart.NET object reference</param>
        /// <param name="filePath">String path of the target SVG file</param>
        /// <returns>String report or error description</returns>
        public string Export(FlowChart flowChart, string filePath)
        {
            string sResult = "";

            try
            {
                // Initializing variables
                pChart = flowChart;

                if (pChart == null)
                {
                    throw new Exception("Empty chart reference was passed");
                }

                if (filePath == null)
                {
                    throw new Exception("Empty VDX path was passed");
                }

                // Getting screen resolution 'Pix-Per-Inch' parameter
                IntPtr        hWnd = SvgManager.GetActiveWindow();
                System.IntPtr hDC  = SvgManager.GetDC(hWnd);
                PixPerInch      = SvgManager.GetDeviceCaps(hDC, 88);
                PixPerInchFirst = PixPerInch;


                // Getting FlowChartX document's dimensions

                double OffsetX = 0, OffsetY = 0;

                OffsetX   = pChart.DocExtents.X;
                OffsetY   = pChart.DocExtents.Y;
                DocLeft   = pChart.DocExtents.Left;
                DocTop    = pChart.DocExtents.Top;
                DocRight  = pChart.DocExtents.Right;
                DocBottom = pChart.DocExtents.Bottom;

                lDocX = DocRight - DocLeft;
                lDocY = DocBottom - DocTop;


                lDocX = pChart.DocExtents.Width;
                lDocY = pChart.DocExtents.Height;

                // Calculating FlowChartX document's dimensions	in INCHES

                sMan = new SvgManager(String.Format("{0}px", Unit2Pix(lDocX)), String.Format("{0}px", Unit2Pix(lDocY)), PixPerInch, pChart.MeasureUnit, m_GlueLines, pChart);


                // Preparing item's enumeration

                ResetID();

                // Processing items [ Tables ]

                foreach (MindFusion.FlowChartX.Table Table in pChart.Tables)
                {
                    if (Table == null)
                    {
                        continue;
                    }

                    CreateTable(Table);
                }

                // Processing items [ Boxes ]

                ArrayList.Adapter(pChart.Boxes).Sort(new BoxComparer(true));
                foreach (MindFusion.FlowChartX.Box Box in pChart.Boxes)
                {
                    if (Box == null)
                    {
                        continue;
                    }

                    CreateBox(Box);
                }

                // Processing items [ Arrows ]

                foreach (MindFusion.FlowChartX.Arrow Arrow in pChart.Arrows)
                {
                    if (Arrow == null)
                    {
                        continue;
                    }

                    CreateArrow(Arrow);
                }



                sMan.Save(filePath);
            }
            catch (Exception ex)
            {
                sResult = String.Format("Error occured when exporting: {0}", ex.Message);
                Trace.WriteLine(String.Format("{0} error {1}\n", "ExportVDX", ex.Message));
            }

            return(sResult);
        }