public bool Save(String filename)
        {
            try
            {
                XmlWriter xw = XmlWriter.Create(filename);
                xw.WriteStartElement("SliceBuildConfig");
                xw.WriteElementString("DotsPermmX", dpmmX.ToString());
                xw.WriteElementString("DotsPermmY", dpmmY.ToString());
                xw.WriteElementString("XResolution", xres.ToString());
                xw.WriteElementString("YResolution", yres.ToString());
                xw.WriteElementString("SliceHeight", ZThick.ToString());
                xw.WriteElementString("LayerTime", layertime_ms.ToString());
                xw.WriteElementString("FirstLayerTime", firstlayertime_ms.ToString());
                xw.WriteElementString("BlankTime", blanktime_ms.ToString());
                xw.WriteElementString("PlatformTemp", plat_temp.ToString());
                xw.WriteElementString("ExportGCode", exportgcode.ToString());
                xw.WriteElementString("ExportSVG", exportsvg.ToString());
                xw.WriteElementString("ExportImages", exportimages.ToString());
                xw.WriteElementString("XOffset", XOffset.ToString());
                xw.WriteElementString("YOffset", YOffset.ToString());
                xw.WriteElementString("Direction", direction.ToString());
                xw.WriteElementString("LiftDistance", liftdistance.ToString());

                xw.WriteEndElement();
                xw.Close();
                return(true);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogRecord(ex.Message);
                return(false);
            }
        }
        // these get stored to the gcode file as a reference
        public override String ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(";(****Build and Slicing Parameters****)\r\n");
            sb.Append(";(Pix per mm X            = " + String.Format("{0:0.00000}", dpmmX) + " px/mm )\r\n");
            sb.Append(";(Pix per mm Y            = " + String.Format("{0:0.00000}", dpmmY) + " px/mm )\r\n");
            sb.Append(";(X Resolution            = " + xres + " )\r\n");
            sb.Append(";(Y Resolution            = " + yres + " )\r\n");
            // sb.Append(";(X Pixel Offset          = " + XOffset + " px )\r\n");
            // sb.Append(";(Y Pixel Offset          = " + YOffset + " px )\r\n");
            sb.Append(";(Layer Thickness         = " + String.Format("{0:0.00000}", ZThick) + " mm )\r\n");
            sb.Append(";(Layer Time              = " + layertime_ms + " ms )\r\n");
            sb.Append(";(Render Outlines         = " + m_createoutlines.ToString() + "\r\n");
            sb.Append(";(Outline Width Inset     = " + m_outlinewidth_inset.ToString() + "\r\n");
            sb.Append(";(Outline Width Outset    = " + m_outlinewidth_outset.ToString() + "\r\n");
            sb.Append(";(Bottom Layers Time      = " + firstlayertime_ms + " ms )\r\n");
            sb.Append(";(Number of Bottom Layers = " + numfirstlayers + " )\r\n");
            sb.Append(";(Blanking Layer Time     = " + blanktime_ms + " ms )\r\n");
            sb.Append(";(Build Direction         = " + direction.ToString() + ")\r\n");
            sb.Append(";(Lift Distance           = " + liftdistance.ToString() + " mm )\r\n");
            sb.Append(";(Slide/Tilt Value        = " + slidetiltval.ToString() + ")\r\n");
            sb.Append(";(Anti Aliasing           = " + antialiasing.ToString() + ")\r\n");
            sb.Append(";(Use Mainlift GCode Tab  = " + usemainliftgcode.ToString() + ")\r\n");
            sb.Append(";(Anti Aliasing Value     = " + aaval.ToString() + " )\r\n");
            sb.Append(";(Z Lift Feed Rate        = " + String.Format("{0:0.00000}", liftfeedrate) + " mm/s )\r\n");
            sb.Append(";(Z Bottom Lift Feed Rate = " + String.Format("{0:0.00000}", bottomliftfeedrate) + " mm/s )\r\n");
            sb.Append(";(Z Lift Retract Rate     = " + String.Format("{0:0.00000}", liftretractrate) + " mm/s )\r\n");
            sb.Append(";(Flip X                  = " + m_flipX.ToString() + ")\r\n");
            sb.Append(";(Flip Y                  = " + m_flipY.ToString() + ")\r\n");
            return(sb.ToString());
        }
        public bool Save(String filename)
        {
            try
            {
                m_filename = filename;
                XmlWriter xw = XmlWriter.Create(filename);
                xw.WriteStartElement("SliceBuildConfig");
                xw.WriteElementString("FileVersion", FILE_VERSION.ToString());
                xw.WriteElementString("DotsPermmX", dpmmX.ToString());
                xw.WriteElementString("DotsPermmY", dpmmY.ToString());
                xw.WriteElementString("XResolution", xres.ToString());
                xw.WriteElementString("YResolution", yres.ToString());
                xw.WriteElementString("SliceHeight", ZThick.ToString());
                xw.WriteElementString("LayerTime", layertime_ms.ToString());
                xw.WriteElementString("FirstLayerTime", firstlayertime_ms.ToString());
                xw.WriteElementString("BlankTime", blanktime_ms.ToString());
                xw.WriteElementString("PlatformTemp", plat_temp.ToString());
                xw.WriteElementString("ExportGCode", exportgcode.ToString());
                xw.WriteElementString("ExportSVG", exportsvg.ToString());
                xw.WriteElementString("ExportImages", exportimages.ToString());
                xw.WriteElementString("XOffset", XOffset.ToString());
                xw.WriteElementString("YOffset", YOffset.ToString());
                xw.WriteElementString("NumberofBottomLayers", numfirstlayers.ToString());
                xw.WriteElementString("Direction", direction.ToString());
                xw.WriteElementString("LiftDistance", liftdistance.ToString());
                xw.WriteElementString("SlideTiltValue", slidetiltval.ToString());
                xw.WriteElementString("AntiAliasing", antialiasing.ToString());
                xw.WriteElementString("AutoCalcDelay", autocalcdelay.ToString());
                xw.WriteElementString("UseMainLiftGCode", usemainliftgcode.ToString());
                xw.WriteElementString("AntiAliasingValue", aaval.ToString());
                xw.WriteElementString("LiftFeedRate", liftfeedrate.ToString());
                xw.WriteElementString("LiftRetractRate", liftretractrate.ToString());

                // xw.WriteElementString("Raise_Time_Delay",raise_time_ms.ToString());
                xw.WriteEndElement();
                xw.Close();
                SaveGCodes();
                return(true);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogRecord(ex.Message);
                return(false);
            }
        }