Example #1
0
        /// <summary>
        /// This function assumes that the file has already been saved
        /// after setting the variable, it will re-save the file
        /// </summary>
        /// <param name="varname"></param>
        /// <param name="value"></param>
        public void SetStringVar(string varname, string value)
        {
            //m_filename = filename;
            XmlHelper xh = new XmlHelper();

            xh.StartNew(m_filename, "SliceBuildConfig");
            SaveInternal(ref xh);
            //save the var
            XmlNode sbc = xh.m_toplevel;

            xh.SetParameter(sbc, varname, value);
            try
            {
                xh.Save(FILE_VERSION);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogRecord(ex.Message);
            }
        }
Example #2
0
 void m_tmr_Tick(object sender, EventArgs e)
 {
     try
     {
         if (Visible == false)
         {
             return;
         }
         Screen oldscr = m_dlpscreen;
         m_dlpscreen = GetDLPScreen(false);
         if (m_dlpscreen != oldscr)
         {
             ShowDLPScreen(false);
         }
     }
     catch (Exception ex)
     {
         DebugLogger.Instance().LogError(ex);
     }
 }
 public bool Save(String filename)
 {
     try
     {
         XmlWriter xw = XmlWriter.Create(filename);
         xw.WriteStartElement("ApplicationConfig");
         xw.WriteElementString("LastModelName", m_LastModelFilename);
         xw.WriteElementString("SliceProfileName", m_cursliceprofilename);
         xw.WriteElementString("MachineProfileName", m_curmachineeprofilename);
         xw.WriteElementString("AutoConnect", m_autoconnect?"True":"False");
         xw.WriteElementString("LoadLastModel", m_loadlastmodel ? "True" : "False");
         xw.WriteEndElement();
         xw.Close(); // close the file
         return(true);
     }catch (Exception ex)
     {
         DebugLogger.Instance().LogRecord(ex.Message);
         return(false);
     }
 }
        public bool LoadModel(String filename)
        {
            try
            {
                Object3d obj = new Object3d();

                string ext = Path.GetExtension(filename);
                bool   ret = false;
                ext = ext.ToLower();
                if (ext.Equals(".dxf"))
                {
                    ret = obj.LoadDXF(filename);
                }
                if (ext.Equals(".stl"))
                {
                    ret = obj.LoadSTL(filename);
                }
                if (ext.Equals(".obj"))
                {
                    ret = obj.LoadObjFile(filename);
                }
                if (ret == true)
                {
                    m_engine3d.AddObject(obj);
                    m_selectedobject = obj;
                    m_slicefile      = null; // the slice file is not longer current
                    RaiseAppEvent(eAppEvent.eModelLoaded, "Model Loaded");
                }
                else
                {
                    RaiseAppEvent(eAppEvent.eModelNotLoaded, "Model " + filename + " Failed to load");
                }

                return(ret);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogRecord(ex.Message);
                return(false);
            }
        }
        void SliceEv(Slicer.eSliceEvent ev, int layer, int totallayers, SliceFile sf)
        {
            //  String path = "";
            // String fileName = "";
            switch (ev)
            {
            case Slicer.eSliceEvent.eSliceStarted:

                break;

            case Slicer.eSliceEvent.eLayerSliced:

                break;

            case Slicer.eSliceEvent.eSliceCompleted:     // this all needs to be changed....
                m_slicefile = sf;
                //generate the GCode
                m_gcode = GCodeGenerator.Generate(m_slicefile, m_printerinfo);
                //we only need the file name of the gcode if we're saving it somewhere...
                //see if we're exporting this to a zip file
                //if (sf.m_config.m_exportopt.Contains("ZIP") && sf.m_config.export)
                if (sf.m_config.export)
                {
                    // open the existing scene file
                    //store the gcode
                    MemoryStream stream = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(m_gcode.RawGCode));
                    String       gcn    = Path.GetFileNameWithoutExtension(UVDLPApp.Instance().SceneFileName) + ".gcode";
                    SceneFile.Instance().RemoveExistingGCode(UVDLPApp.Instance().SceneFileName);
                    SceneFile.Instance().AddGCodeToFile(UVDLPApp.Instance().SceneFileName, stream, gcn);
                }
                //save the slicer object for later too
                //save the slice file

                // UVDLPApp.Instance().m_slicefile.Save(path + UVDLPApp.m_pathsep + fn + ".sliced");
                break;

            case Slicer.eSliceEvent.eSliceCancelled:
                DebugLogger.Instance().LogRecord("Slicing Cancelled");
                break;
            }
        }
Example #6
0
 public void PerformPluginCommand(string cmd, bool verifyLicense)
 {
     foreach (PluginEntry pe in m_plugins)
     {
         try
         {
             // iterate through all loaded plugins
             if (!verifyLicense || (pe.m_licensed == true))
             {
                 if (pe.m_enabled == true)
                 {
                     pe.m_plugin.ExecuteFunction(cmd);
                 }
             }
         }
         catch (Exception ex)
         {
             DebugLogger.Instance().LogError(ex);
         }
     }
 }
Example #7
0
        /// <summary>
        /// This function will return the Screen specified in the machine configuration file
        /// If the screen cannot be found, it will return null.
        /// This is a change in behaviour from before
        /// </summary>
        /// <returns></returns>
        public Screen GetDLPScreen(bool reportError)
        {
            Screen dlpscreen = null;

            foreach (Screen s in Screen.AllScreens)
            {
                string mn  = Utility.CleanMonitorString(s.DeviceName);
                string mid = Utility.CleanMonitorString(m_screenid);
                if (mn.Contains(mid))
                {
                    dlpscreen = s;
                    break;
                }
            }
            if ((dlpscreen == null) && reportError)
            {
                //dlpscreen = Screen.AllScreens[0]; // default to the first if we can't find it
                DebugLogger.Instance().LogRecord("Can't find screen " + m_screenid);
            }
            return(dlpscreen);
        }
 private void CheckLicensing()
 {
     foreach (PluginEntry pe in m_plugins)
     {
         try
         {
             // iterate through all loaded plugins
             // get the vendor id
             int        vid = pe.m_plugin.GetInt("VendorID");
             LicenseKey lk  = KeyRing.Instance().Find(vid);
             if (lk != null)
             {
                 pe.m_licensed = true;
             }
         }
         catch (Exception ex)
         {
             DebugLogger.Instance().LogError(ex);
         }
     }
 }
Example #9
0
        /// <summary>
        /// This function returns a list of Slice/Build Profiles
        /// </summary>
        /// <returns></returns>
        public List <string> SliceProfiles()
        {
            List <string> profiles = new List <string>();

            try
            {
                string[] filePaths = Directory.GetFiles(UVDLPApp.Instance().m_PathProfiles, "*.slicing");
                string   curprof   = Path.GetFileNameWithoutExtension(UVDLPApp.Instance().m_buildparms.m_filename);
                //create a new menu item for all build/slice profiles
                foreach (String profile in filePaths)
                {
                    String pn = Path.GetFileNameWithoutExtension(profile);
                    profiles.Add(pn);
                }
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex.Message);
            }
            return(profiles);
        }
Example #10
0
        public bool Load(string filename)
        {
            try
            {
                m_filename = filename;
                bool      retval = false;
                XmlReader xr     = XmlReader.Create(filename);
                xr.ReadStartElement("MachineConfig");
                int ver = int.Parse(xr.ReadElementString("FileVersion"));
                if (ver != FILE_VERSION)
                {
                    return(false);
                }
                m_XDLPRes      = double.Parse(xr.ReadElementString("DLP_X_Res"));
                m_YDLPRes      = double.Parse(xr.ReadElementString("DLP_Y_Res"));
                m_PlatXSize    = double.Parse(xr.ReadElementString("PlatformXSize"));
                m_PlatYSize    = double.Parse(xr.ReadElementString("PlatformYSize"));
                m_PlatZSize    = double.Parse(xr.ReadElementString("PlatformZSize"));
                m_Xpixpermm    = double.Parse(xr.ReadElementString("PixPermmX"));
                m_Ypixpermm    = double.Parse(xr.ReadElementString("PixPermmY"));
                m_XMaxFeedrate = double.Parse(xr.ReadElementString("MaxXFeedRate"));
                m_YMaxFeedrate = double.Parse(xr.ReadElementString("MaxYFeedRate"));
                m_ZMaxFeedrate = double.Parse(xr.ReadElementString("MaxZFeedRate"));
                m_monitorid    = xr.ReadElementString("MonitorID");
                CalcPixPerMM();

                if (m_driverconfig.Load(xr))
                {
                    retval = true;
                }
                xr.ReadEndElement();
                xr.Close();
                return(retval);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogRecord(ex.Message);
                return(false);
            }
        }
Example #11
0
 public void ScanForPlugins()
 {
     // get a list of dll's in this current directory
     // try to register them as a plug-in
     //string[] filePaths = Directory.GetFiles(m_apppath + m_pathsep + "Plugins", "*.dll");
     string[] filePaths = Directory.GetFiles(m_apppath, "*.dll");
     foreach (String pluginname in filePaths)
     {
         string args = Path.GetFileNameWithoutExtension(pluginname);
         if (args.ToLower().StartsWith("pl"))
         {
             // located a dll that is a potential plugin
             Type ObjType = null;
             try
             {
                 // load it
                 Assembly ass = null;
                 //string args = Path.GetFileNameWithoutExtension(pluginname);
                 ass = Assembly.Load(args);
                 if (ass != null)
                 {
                     ObjType = ass.GetType(args + ".PlugIn"); // look for the plugin interface
                     // OK Lets create the object as we have the Report Type
                     if (ObjType != null)
                     {
                         IPlugin plug = (IPlugin)Activator.CreateInstance(ObjType);
                         m_plugins.Add(plug);
                         plug.Host = this;
                         DebugLogger.Instance().LogInfo("Loaded plugin " + args);
                     }
                 }
             }
             catch (Exception ex)
             {
                 DebugLogger.Instance().LogError(ex.Message);
             }
         }
         //profiles.Add(pn);
     }
 }
Example #12
0
 /// <summary>
 /// This function will perform an auxilary command as specified by the command name
 /// This can encompass a single extra gcode command defined somewhere else,
 /// or an algorithm that blocks until complete
 /// This needs to be changed to allow for command parameters to be passed to aux command
 /// </summary>
 /// <param name="line"></param>
 public void PerformAuxCommand(string line)
 {
     try
     {
         line = line.Replace(';', ' '); // remove comments
         line = line.Replace(')', ' '); // remove comments
         int bidx = line.IndexOf('>');
         if (bidx == -1)
         {
             DebugLogger.Instance().LogError("Improperly formated auxerillery command");
             return;
         }
         string ss1 = line.Substring(bidx + 1);
         //ss1 should now contain the command to perform
         ss1 = ss1.Trim();
         AuxBuildCmds.Instance().RunCmd(ss1);
     }
     catch (Exception ex)
     {
         DebugLogger.Instance().LogError(ex);
     }
 }
Example #13
0
        private static int getvarfromline(String line)
        {
            try
            {
                int val = 0;
                line = line.Replace(';', ' '); // remove comments
                line = line.Replace(')', ' ');
                String[] lines = line.Split('>');
                if (lines[1].ToLower().Contains("blank"))
                {
                    val = -1; // blank screen
                }
                else if (lines[1].Contains("Special_"))
                {
                    val = -3; // special image
                }
                else if (lines[1].Contains("outline"))
                { //;<slice> outline XXX
                    //
                    val = SLICE_OUTLINE;
                    //still need to pull the number
                    String[] lns2 = lines[1].Trim().Split(' ');
                    outlinelayer = int.Parse(lns2[1].Trim()); // second should be variable
                }
                else
                {
                    String[] lns2 = lines[1].Trim().Split(' ');
                    val = int.Parse(lns2[0].Trim()); // first should be variable
                }

                return(val);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(line);
                DebugLogger.Instance().LogError(ex);
                return(0);
            }
        }
Example #14
0
        public static bool StoreInZip(string zipname, string zipentryname, Stream stream)
        {
            ZipFile zip = null;

            try
            {
                zip = ZipFile.Read(zipname);
                zip.AddEntry(zipentryname, stream);
                zip.Save();
                zip.Dispose();
                return(true);
            }
            catch (Exception ex)
            {
                if (zip != null)
                {
                    zip.Dispose();
                }
                DebugLogger.Instance().LogError(ex.Message);
                return(false);
            }
        }
Example #15
0
 public bool Load(String filename)
 {
     try
     {
         XmlHelper xh        = new XmlHelper();
         bool      fileExist = xh.Start(filename, "ApplicationConfig");
         XmlNode   ac        = xh.m_toplevel;
         m_LastModelFilename      = xh.GetString(ac, "LastModelName", "");
         m_cursliceprofilename    = UVDLPApp.Instance().m_PathProfiles + UVDLPApp.m_pathsep + xh.GetString(ac, "SliceProfileName", "default.slicing");
         m_curmachineeprofilename = UVDLPApp.Instance().m_PathMachines + UVDLPApp.m_pathsep + xh.GetString(ac, "MachineProfileName", "NullMachine.machine");
         m_autoconnect            = xh.GetBool(ac, "AutoConnect", false);
         m_loadlastmodel          = xh.GetBool(ac, "LoadLastModel", true);
         m_slic3rloc                 = xh.GetString(ac, "Slic3rLocation", "");
         m_slic3rparameters          = xh.GetString(ac, "Slic3rParams", "");
         m_foregroundcolor           = xh.GetColor(ac, "ForegroundColor", Color.White);
         m_backgroundcolor           = xh.GetColor(ac, "BackgroundColor", Color.Black);
         m_previewslicesbuilddisplay = xh.GetBool(ac, "PreviewSlices", false);
         m_viewslice3d               = xh.GetBool(ac, "Preview3dSlice", false);
         m_viewslice3dheight         = xh.GetBool(ac, "Preview3dSliceHeight", false);
         m_driverdebuglog            = xh.GetBool(ac, "DriverLogging", false);
         m_ignore_response           = xh.GetBool(ac, "IgnoreGCRsp", false);
         m_showBoundingBox           = xh.GetBool(ac, "ShowBoundingBox", true);
         m_showShaded                = xh.GetBool(ac, "ShowShaded", false);
         m_showOutline               = xh.GetBool(ac, "ShowOutline", false);
         m_licensekey                = xh.GetString(ac, "LicenseKey", "00000000000000000000");
         m_serveraddress             = xh.GetString(ac, "ServerAddress", "www.buildyourownsla.com");
         m_contactform               = xh.GetString(ac, "ContactForm", "cwupdate.php");
         if (!fileExist)
         {
             xh.Save(FILE_VERSION);
         }
         return(true);
     }
     catch (Exception ex)
     {
         DebugLogger.Instance().LogRecord(ex.Message);
         return(false);
     }
 }
 public bool SendProjCommand(string displayname, string commandname)
 {
     try
     {
         // get the projector command for 'on'
         // ACER_ON
         ProjectorCommand pcmd = UVDLPApp.Instance().m_proj_cmd_lst.FindByName(commandname);
         if (pcmd != null)
         {
             DeviceDriver dd = DisplayManager.Instance().FindDisplaySerialPortDriverByName(displayname);
             if (dd != null)
             {
                 if (dd.Connected)
                 {
                     byte[] data = pcmd.GetBytes();
                     dd.Write(data, data.Length);
                     return(true);
                 }
                 else
                 {
                     DebugLogger.Instance().LogError("Projector Driver not connected");
                 }
             }
             else
             {
                 DebugLogger.Instance().LogError("Projector Driver not found");
             }
         }
         else
         {
             DebugLogger.Instance().LogError("Projector command not found");
         }
     }
     catch (Exception ex)
     {
         DebugLogger.Instance().LogError(ex);
     }
     return(false);
 }
Example #17
0
        public bool Load(String filename)
        {
            try
            {
                XmlReader xr = XmlReader.Create(filename);
                xr.ReadStartElement("ApplicationConfig");

                m_LastModelFilename      = xr.ReadElementString("LastModelName");
                m_cursliceprofilename    = xr.ReadElementString("SliceProfileName");
                m_curmachineeprofilename = xr.ReadElementString("MachineProfileName");
                m_autoconnect            = bool.Parse(xr.ReadElementString("AutoConnect"));
                m_loadlastmodel          = bool.Parse(xr.ReadElementString("LoadLastModel"));
                xr.ReadEndElement();
                xr.Close();
                return(true);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogRecord(ex.Message);
                return(false);
            }
        }
Example #18
0
 private void cmdConnect1_Click(object sender, EventArgs e)
 {
     try
     {
         if (!UVDLPApp.Instance().m_deviceinterface.Connected) //
         {
             //maybe get the com port if it's different?
             //UVDLPApp.Instance().m_printerinfo.m_driverconfig.m_connection.comname = com;
             UVDLPApp.Instance().m_deviceinterface.Configure(UVDLPApp.Instance().m_printerinfo.m_driverconfig.m_connection);
             String com = UVDLPApp.Instance().m_printerinfo.m_driverconfig.m_connection.comname;
             DebugLogger.Instance().LogRecord("Connecting to Printer on " + com + " using " + UVDLPApp.Instance().m_printerinfo.m_driverconfig.m_drivertype.ToString());
             if (!UVDLPApp.Instance().m_deviceinterface.Connect())
             {
                 DebugLogger.Instance().LogRecord("Cannot connect printer driver on " + com);
             }
         }
     }
     catch (Exception ex)
     {
         DebugLogger.Instance().LogRecord(ex.Message);
     }
 }
Example #19
0
        private void SliceEv(Slicer.eSliceEvent ev, int layer, int totallayers, SliceFile sf)
        {
            try
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new MethodInvoker(delegate() { SliceEv(ev, layer, totallayers, sf); }));
                }
                else
                {
                    switch (ev)
                    {
                    case Slicer.eSliceEvent.eSliceStarted:
                        SetMainMessage("Slicing Started");
                        break;

                    case Slicer.eSliceEvent.eLayerSliced:
                        break;

                    case Slicer.eSliceEvent.eSliceCompleted:
                        //show the gcode
                        ctlGcodeView1.Text = UVDLPApp.Instance().m_gcode.RawGCode;
                        ctl3DView1.SetNumLayers(totallayers);
                        ctlSliceView1.SetNumLayers(totallayers);
                        SetMainMessage("Slicing Completed");
                        String timeest = BuildManager.EstimateBuildTime(UVDLPApp.Instance().m_gcode);
                        SetTimeMessage("Estimated Build Time: " + timeest);
                        //show the slice in the slice view
                        ViewLayer(0, null, BuildManager.SLICE_NORMAL);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex.Message);
            }
        }
Example #20
0
        /// <summary>
        /// Loads a model, adds it to the 3d engine to be shown, and raises an app event
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public bool LoadModel(String filename)
        {
            try
            {
                ModelLoader     ml   = new ModelLoader();
                List <Object3d> objs = ml.Load(filename);
                if (objs != null)
                {
                    foreach (Object3d obj in objs)
                    {
                        obj.CenterOnPlatform();
                        m_engine3d.AddObject(obj);
                        m_undoer.SaveAddition(obj);
                        SelectedObject = obj;
                        //test code to create a preview, this should definitely go somewhere else

                        /*PreviewGenerator pg = new PreviewGenerator();
                         * Bitmap preview = pg.GeneratePreview(512, 512, obj);
                         * if(preview !=null)
                         *  preview.Save(UVDLPApp.Instance().m_apppath + "\\testpreview.png");*/
                    }
                    UVDLPApp.Instance().m_engine3d.UpdateLists();
                    m_slicefile = null; // the slice file is not longer current
                    RaiseAppEvent(eAppEvent.eModelAdded, "Model Loaded " + filename);
                }
                else
                {
                    RaiseAppEvent(eAppEvent.eModelNotLoaded, "Model " + filename + " Failed to load");
                }

                return(objs != null);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogRecord(ex.Message);
                return(false);
            }
        }
Example #21
0
 /// <summary>
 /// Removes the currently selected object
 /// </summary>
 public void RemoveCurrentModel()
 {
     try
     {
         if (SelectedObject != null)
         {
             UVDLPApp.Instance().m_undoer.SaveDelition(SelectedObject);
             foreach (Object3d sup in SelectedObject.m_supports)
             {
                 UVDLPApp.Instance().m_undoer.SaveDelition(sup);
                 UVDLPApp.Instance().m_undoer.LinkToPrev();
                 m_engine3d.RemoveObject(sup, false); // remove all the supports of this object, hold out on sending events
             }
             m_engine3d.RemoveObject(SelectedObject); // now remove the object
             SelectedObject = null;
             RaiseAppEvent(eAppEvent.eModelRemoved, "model removed");
         }
     }
     catch (Exception ex)
     {
         DebugLogger.Instance().LogError(ex);
     }
 }
Example #22
0
 /// <summary>
 /// this is a cheat to find, parse and return the number of slices in a gcode file for UV DLP GCode
 /// </summary>
 /// <returns></returns>
 public int GetVar(string var)
 {
     try
     {
         foreach (string s in Lines)
         {
             if (s.Contains(var))
             {
                 String str = s;
                 str = str.Replace('(', ' ');
                 str = str.Replace(')', ' ');
                 str = str.Replace(';', ' ');
                 string[] tmp = str.Split('=');
                 return(int.Parse(tmp[1]));
             }
         }
     }
     catch (Exception ex)
     {
         DebugLogger.Instance().LogError(ex.StackTrace);
     }
     return(-1);
 }
Example #23
0
        /// <summary>
        /// Support Event handler
        /// </summary>
        /// <param name="ev"></param>
        /// <param name="message"></param>
        /// <param name="obj"></param>
        public void SupEvent(SupportEvent ev, string message, Object obj)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(delegate() { SupEvent(ev, message, obj); }));
            }
            else
            {
                try
                {
                    switch (ev)
                    {
                    case SupportEvent.eCompleted:
                        ctl3DView1.UpdateSceneTree();
                        break;

                    case SupportEvent.eCancel:
                        break;

                    case SupportEvent.eProgress:
                        break;

                    case SupportEvent.eStarted:
                        break;

                    case SupportEvent.eSupportGenerated:
                        //
                        // SetupSceneTree();
                        break;
                    }
                }
                catch (Exception ex)
                {
                    DebugLogger.Instance().LogError(ex.Message);
                }
            }
        }
        public bool Save(String filename) 
        {
            try
            {
                XmlHelper xh = new XmlHelper();
                bool fileExist = xh.Start(filename, "ApplicationConfig");
                XmlNode ac = xh.m_toplevel;
                xh.SetParameter(ac, "LastModelName", m_LastModelFilename);
                xh.SetParameter(ac, "SliceProfileName", Path.GetFileName(m_cursliceprofilename));
                xh.SetParameter(ac, "MachineProfileName", Path.GetFileName(m_curmachineeprofilename));
                xh.SetParameter(ac, "AutoConnect", m_autoconnect ? "True" : "False");
                xh.SetParameter(ac, "LoadLastModel", m_loadlastmodel ? "True" : "False");
                xh.SetParameter(ac, "Slic3rLocation", m_slic3rloc);
                xh.SetParameter(ac, "Slic3rParams", m_slic3rparameters);
                xh.SetParameter(ac, "ForegroundColor", m_foregroundcolor);
                xh.SetParameter(ac, "BackgroundColor", m_backgroundcolor);
                xh.SetParameter(ac, "PreviewSlices", m_previewslicesbuilddisplay);
                xh.SetParameter(ac, "Preview3dSlice", m_viewslice3d);
                xh.SetParameter(ac, "Preview3dSliceHeight", m_viewslice3dheight);
                xh.SetParameter(ac, "DriverLogging", m_driverdebuglog);
                xh.SetParameter(ac, "IgnoreGCRsp", m_ignoreGCrsp);
                xh.SetParameter(ac, "ShowBoundingBox", m_showBoundingBox);
                xh.SetParameter(ac, "ShowOutline", m_showOutline);
                xh.SetParameter(ac, "ShowShaded", m_showShaded);
                xh.SetParameter(ac, "LicenseKey", m_licensekey);
                xh.SetParameter(ac, "ServerAddress", m_serveraddress);
                xh.SetParameter(ac, "ContactForm", m_contactform);
                xh.Save(FILE_VERSION);

                return true;
            }catch(Exception ex)
            {
                DebugLogger.Instance().LogRecord(ex.Message);
                return false; 
            }
            
        }
Example #25
0
        static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.ThreadException +=
                new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.EnableVisualStyles();
            Application.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            SetDefaultCulture(System.Globalization.CultureInfo.InvariantCulture);
            Application.SetCompatibleTextRenderingDefault(false);
            //init the app object


            if (UVDLPApp.Instance().DoAppStartup() == false) // start the app and load the plug-ins
            {
                Application.Exit();                          // by esyeon 20160127
                return;
            }



            // by esyeon 20151230


            try
            {
#if !DEBUG                                          // no splash screen under debug release
                frmSplash splash = new frmSplash(); // should pull from a licensed plug-in if need-be
                splash.Show();
#endif
                Application.Run(new frmMain2());
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex);
            }
        }
Example #26
0
        void PrintStatus(ePrintStat printstat)
        {
            // displays the print status
            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(delegate() { PrintStatus(printstat); }));
            }
            else
            {
                String message = "";
                switch (printstat)
                {
                case ePrintStat.ePrintCancelled:
                    message = "Print Cancelled";
                    break;

                case ePrintStat.eLayerCompleted:
                    message = "Layer Completed";
                    break;

                case ePrintStat.ePrintCompleted:
                    message = "Print Completed";
                    MessageBox.Show("Build Completed");
                    break;

                case ePrintStat.ePrintStarted:
                    message = "Print Started";
                    if (!ShowDLPScreen())
                    {
                        MessageBox.Show("Monitor " + UVDLPApp.Instance().m_printerinfo.m_monitorid + " not found, cancelling build", "Error");
                        UVDLPApp.Instance().m_buildmgr.CancelPrint();
                    }
                    break;
                }
                DebugLogger.Instance().LogRecord(message);
            }
        }
        // currently, this will save both into a zip file and into a subdirectory
        private void LayerSliced(string scenename, int layer, int numslices, Bitmap bmp)
        {
            string path;

            try
            {
                // if (m_buildparms.exportimages)
                {
                    // get the model name
                    String modelname = scenename;
                    // strip off the file extension
                    path = SliceFile.GetSliceFilePath(modelname);
                    // = null;
                    String imname    = Path.GetFileNameWithoutExtension(modelname) + String.Format("{0:0000}", layer) + ".png";
                    String imagename = path + UVDLPApp.m_pathsep + imname;
                    if (m_sf.m_config.m_exportopt.ToUpper().Contains("ZIP"))
                    {
                        // create a memory stream for this to save into
                        MemoryStream ms = new MemoryStream();
                        bmp.Save(ms, ImageFormat.Png);
                        ms.Seek(0, SeekOrigin.Begin); // seek back to beginning
                        m_zip.AddEntry(imname, ms);
                    }
                    else
                    {
                        bmp.Save(imagename);
                    }

                    RaiseSliceEvent(eSliceEvent.eLayerSliced, layer, numslices);
                }
            }
            catch (Exception ex)
            {
                string s = ex.StackTrace;
                DebugLogger.Instance().LogError(ex.Message);
            }
        }
Example #28
0
 public bool Save(string filename)
 {
     try
     {
         bool      retval = false;
         XmlWriter xw     = XmlWriter.Create(filename);
         m_filename = filename;
         xw.WriteStartDocument();
         xw.WriteStartElement("MachineConfig");
         xw.WriteElementString("FileVersion", FILE_VERSION.ToString());
         xw.WriteElementString("DLP_X_Res", m_XDLPRes.ToString());
         xw.WriteElementString("DLP_Y_Res", m_YDLPRes.ToString());
         xw.WriteElementString("PlatformXSize", m_PlatXSize.ToString());
         xw.WriteElementString("PlatformYSize", m_PlatYSize.ToString());
         xw.WriteElementString("PlatformZSize", m_PlatZSize.ToString());
         xw.WriteElementString("PixPermmX", m_Xpixpermm.ToString());
         xw.WriteElementString("PixPermmY", m_Ypixpermm.ToString());
         xw.WriteElementString("MaxXFeedRate", m_XMaxFeedrate.ToString());
         xw.WriteElementString("MaxYFeedRate", m_YMaxFeedrate.ToString());
         xw.WriteElementString("MaxZFeedRate", m_ZMaxFeedrate.ToString());
         xw.WriteElementString("MonitorID", m_monitorid.ToString());
         if (m_driverconfig.Save(xw))
         {
             retval = true;
         }
         xw.WriteEndElement();
         xw.WriteEndDocument();
         xw.Close();
         return(retval);
     }
     catch (Exception ex)
     {
         DebugLogger.Instance().LogRecord(ex.Message);
         return(false);
     }
 }
        public void SaveGCodes()
        {
            try
            {
                String profilepath = Path.GetDirectoryName(m_filename);
                profilepath += UVDLPApp.m_pathsep;
                profilepath += Path.GetFileNameWithoutExtension(m_filename);
                //create the directory if it doesn't exist
                if (!Directory.Exists(profilepath))
                {
                    Directory.CreateDirectory(profilepath);
                }

                SaveFile(profilepath + UVDLPApp.m_pathsep + "start.gcode", m_headercode);
                SaveFile(profilepath + UVDLPApp.m_pathsep + "end.gcode", m_footercode);
                SaveFile(profilepath + UVDLPApp.m_pathsep + "prelift.gcode", m_preliftcode);
                SaveFile(profilepath + UVDLPApp.m_pathsep + "postlift.gcode", m_postliftcode);
                SaveFile(profilepath + UVDLPApp.m_pathsep + "preslice.gcode", m_preslicecode);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex.Message);
            }
        }
Example #30
0
        /*
         * This function is called when the device status changes
         * most of this is for display purposes only,
         * the real business logic should be held in the app class
         */
        void DeviceStatusEvent(ePIStatus status, String Command)
        {
            switch (status)
            {
            case ePIStatus.eConnected:
                SetConnectionStatus();
                DebugLogger.Instance().LogRecord("Device Connected");
                break;

            case ePIStatus.eDisconnected:
                SetConnectionStatus();
                DebugLogger.Instance().LogRecord("Device Disconnected");
                break;

            case ePIStatus.eError:
                break;

            case ePIStatus.eReady:
                break;

            case ePIStatus.eTimedout:
                break;
            }
        }