示例#1
0
        private bool WriteConf(List <GrblConf.GrblConfParam> conf, bool import)
        {
            bool noerror = false;

            try
            {
                Cursor = Cursors.WaitCursor;
                Core.WriteConfig(conf);
                Cursor = DefaultCursor;
                ActionResult(String.Format(import ? Strings.BoxImportConfigWithoutError : Strings.BoxWriteConfigWithoutError, conf.Count));

                noerror = true;
            }
            catch (GrblCore.WriteConfigException ex)
            {
                Cursor = DefaultCursor;
                System.Windows.Forms.MessageBox.Show(String.Format(import ? Strings.BoxImportConfigWithError : Strings.BoxWriteConfigWithError, conf.Count, ex.Errors.Count) + "\n" + ex.Message, Strings.BoxExportConfigErrorTitle, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                Cursor = DefaultCursor;
                System.Windows.Forms.MessageBox.Show(String.Format(import ? Strings.BoxImportConfigWithError : Strings.BoxWriteConfigWithError, conf.Count, "unknown"), Strings.BoxExportConfigErrorTitle, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            finally
            {
                try { Core.RefreshConfig(); }                 //ensure to have the last conf at least in core
                catch { }
            }


            return(noerror);
        }